//
// Create a true getElementsByClassName function
//
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
}; // -end-

//
// g e t A t t r i b u t e T e s t
//
function getAttributeTest(clsname)
{
	var current;
	var elementArray = [];
	
	elementArray = document.getElementsByClassName(clsname);

	if (elementArray.length > 0)
	{
		for (var i = 0; (current = elementArray[i]); i++)
		{
		  current.setAttribute('style', 'visibility:hidden');
			/*
			document.write(current.getAttribute("title"));
			document.write('<br/>');
			*/

		}
	}
	return;
}

//
// o p e n W i n d o w
//
function openWindow(url) {
  popupWin = window.open(url, 'popup',  'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,\
                                         dependent=yes,status=no,personalbar=no,height=425,width=550,left=500,top=400')
} // --- openWindow ---

//
// g e t B r o w s e r W i d t h
//
function getBrowserWidth() {
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight 
 if (typeof window.innerWidth != 'undefined')
 {
      return(window.innerWidth)    
 }
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       return(document.documentElement.clientWidth);
 } 
 // older versions of IE
 else
 {
       return(document.getElementsByTagName('body')[0].clientWidth)
 }
document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
}  // --- getBrowserWidth  ---

//
// w h i c h B r s
//
function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
} // --- whichBrs ---

//
// p o p u p P r o d u c t W i n d o w
//
function popupProductWindow(url) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	  
		var width = 0;
		var height = 0;
		
		var browser = whichBrs();
		if ( browser.toLowerCase() == "Safari".toLowerCase() ) {
		  width = 768;
			height = 590;
		}
		else {
		  width = 750;
		  height = 580;
		}
			
	  var left = (myWidth - width) / 2;
		var top = (myHeight - height) / 2;
		var params = 'width='+width+', height='+height;
        params += ', top='+top+', left='+left;
        params += ', directories=no';
        params += ', location=no';
        params += ', menubar=no';
        params += ', resizable=no';
        params += ', scrollbars=no';
        params += ', status=no';
        params += ', toolbar=yes';
				params += ', dependent=no';
				params += ', personalbar=no';
     popupwin=window.open(url,'popup', params);
 //    if (window.focus) {popupwin.focus()}
 //    return false;
} // --- popupProductWindow ---

//
// p o p u p R e c i p e W i n d o w
//
function popupRecipeWindow(url) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	  
		var width = 650;
		var height = 455;
			
	  var left = (myWidth - width) / 2;
		var top = (myHeight - height) / 2;
		var params = 'width='+width+', height='+height;
        params += ', top='+top+', left='+left;
        params += ', directories=no';
        params += ', location=no';
        params += ', menubar=no';
        params += ', resizable=no';
        params += ', scrollbars=no';
        params += ', status=no';
        params += ', toolbar=no';
				params += ', dependent=no';
				params += ', personalbar=no';
     popupwin=window.open(url,'popup', params);
}  // --- popupRecipeWindow ---

//
// g u p  --- parse url parameter by name
//
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
} // --- gup ---

//
// c l e a r F o r m --- clear all the fields from a form
//
function clearForm(oForm) 
{ 
  var elements = oForm.elements; 
    
  oForm.reset();

  for(i=0; i<elements.length; i++) {
      
	field_type = elements[i].type.toLowerCase();
	
	switch(field_type) {
	
		case "text": 
		case "password": 
		case "textarea":
	        case "hidden":	
			
			elements[i].value = ""; 
			break;
        
		case "radio":
		case "checkbox":
  			if (elements[i].checked) {
   				elements[i].checked = false; 
			}
			break;

		case "select-one":
		case "select-multi":
            		elements[i].selectedIndex = -1;
			break;

		default: 
			break;
	}
    }
} // --- clearForm ---

//
// o p e r a T h u m b n a i l --- write special thumbnail code for Opera Browser
//
function operaThumbnail() 
{
   var browser = whichBrs();
    if ( browser.toLowerCase() == "Opera".toLowerCase() ) 
	{
	   document.write('\
		<style type="text/css">\
		.thumbnail:hover span\
		{\
            visibility: visible;\
            top: -300px;\
            left: -250px;\
	    }\
		</style>\
	   ');
	   
    } 
}// --- operaThumbnail ---


//
// headline --- write a headline
//
function headline() 
{
  return(document.write('<h1>Home of Colonel Don\'s<br/>Secret Salmon Sauce!</h1>'));
}// --- headline ---






