//detect browser:
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 3) browserVer = "1";
else if (browserName == "Microsoft Internet Explorer" && browserVer == 4) browserVer = "1";
else browserVer = "2";

$().ready(function() {
	$('#txtSearch').keyup(function(e) {
      		if(e.keyCode == 13) {
			submitsearch();
			e.preventDefault();
			return false;
      		}
	});

if($('#homefooter').height() != null) return;

//workaround for the product list page
	if($('#productListText').height()==null){
		resize();
	}
	else{
		$('#outer').height($(document).height());
		//if($('#homefooter').height() == null){
			//product list page needs to wait just a second
			//setTimeout('resize()', 1000);
		//	$('#outer').height($(document).height());
		//}
	}
});


//preload images:
if (browserVer == 1) {
	whoweare1 = new Image(133,116);
	whoweare1.src = "/images/button_whoweare-1.png";
	whoweare2 = new Image(133,116);
	whoweare2.src = "/images/button_whoweare-2.png";
	dna1 = new Image(133,116);
	dna1.src = "/images/button_UnderstandingDNA-1.png";
	dna2 = new Image(133,116);
	dna2.src = "/images/button_UnderstandingDNA-2.png";
	newsandblogs1 = new Image(133,116);
	newsandblogs1.src = "/images/button_healthnews-1.png";
	newsandblogs2 = new Image(133,116);
	newsandblogs2.src = "/images/button_healthnews-2.png";
	ourtests1 = new Image(133,116);
	ourtests1.src = "/images/button_ourtests-1.png";
	ourtests2 = new Image(133,116);
	ourtests2.src = "/images/button_ourtests-2.png";
	howworks1 = new Image(133,116);
	howworks1.src = "/images/button_genetictesting-1.png";
	howworks2 = new Image(133,116);
	howworks2.src = "/images/button_genetictesting-2.png";
	myhealth1 = new Image(133,116);
	myhealth1.src = "/images/button_myhealth-1.png";
	myhealth2 = new Image(133,116);
	myhealth2.src = "/images/button_myhealth-2.png";
	myprofile1 = new Image(133,116);
	myprofile1.src = "/images/button_myprofile-1.png";
	myprofile2 = new Image(133,116);
	myprofile2.src = "/images/button_myprofile-2.png";
	mytests1 = new Image(133,116);
	mytests1.src = "/images/button_mytests-1.png";
	mytests2 = new Image(133,116);
	mytests2.src = "/images/button_mytests-2.png";
}

	//image swapping function:
function changeImage(imgDocID, imgObjName) {
	if (browserVer == 1) {
	document.images[imgDocID].src = eval(imgObjName + ".src");
	 return true;
	}
}


      function resize() {
		//alert($(document).height());
	//if this is the home page (#title0) then don't do anything
	if($('#Title0').height()==null){
		if($(document).height()>764){
			if(($(document).height() - $(window).height()) > 30){
				$('#outer').height($(document).height()-20);
			}
			else{
				if($.browser.msie){
					$('#outer').height($(document).height()-52);
				}
				else{
					$('#outer').height($(document).height()-45);
				}
			}
		}
	}
      } 


	//image swapping function:
	function changeImage(imgDocID, imgObjName) {
	if (browserVer == 1) {
		document.images[imgDocID].src = eval(imgObjName + ".src");
	 	return true;
		}
	}

	 function clearTextbox(txt) {
	     if (txt.value == txt.defaultValue) {
	         txt.value = ""
	     }
	 }

	function submitsearch() { 
		document.getElementById("search").value = document.getElementById("txtSearch").value;
		var myForm = document.forms['searchform'];
		myForm.submit(); 
	}

