<!--

// $Author: dp $
// $Date: 2006-04-27 15:41:43 -0500 (Thu, 27 Apr 2006) $
// $Revision: 8269 $

/** GENERIC FUNCTIONS **/

function getObj(name)
{
  myObj = new Object();
  if (document.getElementById)
    {
      myObj.obj = document.getElementById(name);
      if(myObj.obj != null)
	myObj.style = document.getElementById(name).style;
    }
  else if (document.all)
    {
      myObj.obj = document.all[name];
      if(myObj.obj != null)
	myObj.style = document.all[name].style;
    }
  else if (document.layers)
    {
      myObj.obj = document.layers[name];
      if(myObj.obj != null)
	myObj.style = document.layers[name];
    }
  if (!myObj.obj) return null;
  return myObj;
}

/**
 * returns the key of the first time needle is located in array haystack.
 * if 'all' is true an array is returned of all keys found to contain needle
 * if no match is found, returns null
 */
function in_array(needle, haystack, all) {
  var toReturn = new Array(), flag = false;
  if (arguments.length == 3 && all == true) flag = true;
  for (hay in haystack) {
    if (typeof(haystack[hay]) == 'object') {
      if (array_compare(needle, haystack[hay]) == 0) continue;
    }
    else if (needle != haystack[hay]) continue;
    if (flag) toReturn.push(hay);
    else return hay;
  }
  if (toReturn.length == 0) return null;
  return toReturn;
}

/**
 * recursively compares 2 arrays
 * returns 1 if equal, 0 otherwise
 */
function array_compare(a, b) {
  if (typeof(a) != 'object' || typeof(b) != 'object') return 0;
  if (a.length != b.length) return 0;
  for (id in a) {
    if (typeof(b[id]) == 'undefined') return 0;
    if (typeof(a[id]) == 'object' && array_compare(a[id], b[id]) == 0) return 0;
    if (a[id] != b[id]) return 0;
  }
  return 1;
}

/** END GENERIC FUNCTIONS **/

function formSubmit(formname) {

  myform = getObj(formname);
  if (!myform) return null;
  myform = myform.obj;

  switch (formname) {
  case 'IglooSearch' :
    if (myform.searchString.value == '') return;
    break;
  case 'ProductFinder':
    radio = myform.numpeople;
    submit = false;
    for (i=0; i<radio.length; i++) if (radio[i].checked) submit = true;
    if (!submit) return;
  }
  //alert('Submitted');
  myform.submit();
}

var cleared = false;

function clearHeaderSearch(srch) {
  if (!cleared) {
    srch.value = '';
    cleared = true;
  }
  return;
}

//start splash page functions
function ImageOn(section, image) {
	switch(section) {
		case 'splash_red':
			if(document.splash_red)	document.splash_red.src = image;
			document.right.src = "images/splash/consumer/large_picture.jpg";
		break;
		case 'splash_yellow':
			if(document.splash_yellow) document.splash_yellow.src = image;
			document.right.src = "images/splash/commercial/large_picture.jpg";
		break;		
		case 'splash_green':
			if(document.splash_green) document.splash_green.src = image;
			document.right.src = "images/splash/premium/large_picture.jpg";
		break;
		case 'splash_blue':
			if(document.splash_blue) document.splash_blue.src = image;
			document.right.src = "images/splash/international/large_picture.jpg";
		break;	
	}
}

function ImageOff(section, image) {
	switch(section) {
		case 'splash_red':
			document.splash_red.src = image;
		break;
		case 'splash_yellow':
			document.splash_yellow.src = image;
		break;
		case 'splash_green':
			document.splash_green.src = image;
		break;	
		case 'splash_blue':
			document.splash_blue.src = image;
		break;	
	}
}
//end splash page functions

//alert('functions loaded');
//-->
