if (document.images) {
	var n_administratoroffgif = new Image();
	var n_administratorovergif = new Image();
	
	n_administratoroffgif.src = "../images/glucometer/nav/n_administratoroff.gif";
	n_administratorovergif.src = "../images/glucometer/nav/n_administratorover.gif";
}

function checker(){
	for (i=0;i<document.forms[0].elements.length;i++){
		thisField = document.forms[0].elements[i];
		if(thisField.value==""){
			alert("Please enter your " + thisField.name + ".");
			thisField.focus();
			return false;
		}
	}
	return true;
}

function startTest(win){
	var arguments = "\"scrollbars=yes,resizable=yes,height=650,width=700\"";
	var testWindow=window.open("swf/"+win+"/"+win+".jsp","testIntro", arguments);
}

///////////////////////////
// Cookie Related Functions

function makeCookie(){
	document.cookie = "verify=itworked|";
	focusOnFirstFormElement();
	//if (document.location.href.indexOf("startTest.jsp") != -1){
	//	startTest();
	//}
	return findCookie();
}

function findCookie(){
	var start = document.cookie.indexOf("verify")
	if (start != -1){
		start += 7;
		end = document.cookie.indexOf("|", start);
		if (end != -1){
			var value = document.cookie.substring(start, end);
			value = unescape(value);
		}
	}
	if (value != "itworked"){
		if (document.location.search.indexOf("?reason=noCookie") == -1)
		{
			alert("You must have cookies turned on to use this site.\nPlease enable cookies in your web browser.");
			var here = document.location.href;
			if (here.indexOf("cookieError.jsp") == -1){
				document.location = "cookieError.jsp?reason=noCookie";
			}
		}
		return false;
	}
	else{
		return true;
	}
}

function focusOnFirstFormElement(){
	if(document.forms[0])
	{
		document.forms[0].elements[0].focus();
	}
}

var df;

function checkHosp(){
	df = document.forms[0];
	
	// Check Hospital Name
	if (df.site_name.value == null || df.site_name.value.length < 5){
		alert("All fields must contain between 5 and 100 characters.");
		df.site_name.focus();
		return false;
	}
	
	//Check email address
	if ((df.mail_id.value.indexOf("@") == -1) || df.mail_id.value.indexOf(".") == -1)
	{
		alert("Please enter a valid email address.");
		df.mail_id.focus();
		return false;
	}  
  // check the syntax of the user's entry. Allow the user to proceed only if all syntax is OK
	return (noQuotes() && phoneCheck() && zipCodeCheck());		
}
	
function noQuotes()
	{
	for (i = 0; i < df.elements.length; i++)
		{		
		//alert("checking " + df.elements[i].name);
		
		// only check form fields where the user enters text.
		// don't check fields with no "value" attribute
		if (df.elements[i].value)
			{
			// return false for double quotes
			if (df.elements[i].value.indexOf("\"") != -1)
				{
				alert("You cannot use quotation marks in any of these fields.\nPlease remove the quotation marks from this field.");
				df.elements[i].focus();
				return false;
				}	
			}
		
		// return false for blank fields
		if (df.elements[i].value == "" && df.elements[i].name != "address2")
			{
			alert("You must fill in all fields.")
			df.elements[i].focus();
			return false;
			}
		}
    return true;
	}	

function phoneCheck()
    {
    // create a regular expression for matching the pattern of a phone number
    var phonePattern = new RegExp("\\d{3}-\\d{3}-\\d{4}$");    
    
    // if the phone number doesn't match the pattern, return false and provide a helpful error message.
    if (!phonePattern.test(df.phone.value))
        {
        alert("Please enter your phone number\nwith area code and dashes\nlike this: xxx-xxx-xxxx");
        df.phone.focus();
        return false;
        }
    // if the phone number does match, return true
    return true;
    }
    
function zipCodeCheck()
    {
    // create a regular expression for matching the pattern of a phone number
    var zipPattern = new RegExp("\\d{5}(-\\d{4})?");
    
    // if the phone number doesn't match the pattern, return false and provide a helpful error message.
    if (!zipPattern.test(df.zip.value))
        {
        alert("Please enter a valid US zip code");
        df.zip.focus();
        return false;
        }
    // if the phone number does match, return true
    return true;
    }
    
    
function confirmCookiesAreEnabled(){
	var confirmation = makeCookie();
	if(confirmation){
		window.history.back();
	}
	else{
		alert("Please enable cookies in your web browser");
	}
}

function checkHospital()
	{
	// all hospital names must have at least 3 letter characters in them.
	// don't allow submission otherwise.
	var name = document.forms[0].hospitalname.value;
	var result;
	//store the characters of the match
	result = name.match(/[a-zA-Z]/g);
		
		//check the result and length of alpha characters of the hospital name entered
	if (result == null || result.length < 3)
		{
		alert("Your Hospital Name has fewer than 3 letter characters in it. Please enter a different Hospital Name.");
		document.forms[0].hospitalname.focus();
		return false;
		}
		
	if (document.forms[0].mailid.value.indexOf("@") == -1 || document.forms[0].mailid.value.indexOf(".") == -1)
		{
		alert("Please enter a valid email address.");
		document.forms[0].mailid.focus();
		return false;
		}	
	
	for (i = 0; i < document.forms[0].elements.length -1; i++)
		{
		thisField = document.forms[0].elements[i];
		if (thisField.value == "")
			{
			alert("You must complete all fields before submission.");
			thisField.focus();
			return false;
			}
				
		if (thisField.value.indexOf("\"") != -1)
			{
			alert("You cannot use quotation marks for this field.");			
			thisField.focus();
			return false;
			}
		}

    return true;
	}
	
function checkHospSearch(field){
	var dfe = document.forms[0].elements;
	for (i = 0; i < dfe.length; i++){
		if (dfe[i].name == field && dfe[i].value == ""){
			HospSearchErrorMsg(dfe[i]);
			return false;
		}
	}
	return true;
}

function HospSearchErrorMsg(field){
	alert("Please enter your search criteria in this field.");
	field.focus();
  return false;
}

function seeAll(){
	var df = document.forms[0];
	var dfe = document.forms[0].elements;
	for (i = 0; i < dfe.length; i++){
		if (i == 2 || i == 4){
			//dfe[i].value = "";
		}
	}
	df.submit();
}

//for menus
if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;


if (document.images) {
	//on Images
  nav_companyon = new Image();
  nav_companyon.src = "img/navtop_company_on.gif";
	nav_productson = new Image();
  nav_productson.src = "img/navtop_products_on.gif";
	nav_diabetescareon = new Image();
  nav_diabetescareon.src = "img/navtop_diabetescare_on.gif";
	nav_promotionson = new Image();
  nav_promotionson.src = "img/navtop_promotions_on.gif";
	nav_communitieson = new Image();
  nav_communitieson.src = "img/navtop_communities_on.gif";
  //off  Images
  nav_companyoff = new Image();
  nav_companyoff.src = "img/navtop_company.gif";
	nav_productsoff = new Image();
  nav_productsoff.src = "img/navtop_products.gif";
	nav_diabetescareoff = new Image();
  nav_diabetescareoff.src = "img/navtop_diabetescare.gif";
	nav_promotionsoff = new Image();
  nav_promotionsoff.src = "img/navtop_promotions.gif";
	nav_communitiesoff = new Image();
  nav_communitiesoff.src = "img/navtop_communities.gif";
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

var imageNumberI = 3 ;
var randomnumberI = Math.random() ;
var imageSelectI = Math.round( (imageNumberI-1) * randomnumberI) + 1 ;