
function EvenRow( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#B4DCFF';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#D7D7D7';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}
function OddRow( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#B4DCFF';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#ffffff';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}
function navBarClick( tableCellRef, navStyle, url ) {
	navBar( tableCellRef, 0, navStyle );
	window.location.href = url;
}
// CookieToolkit.js

// Create a cookie
function writeCookie(cookieName, cookieValue, expires, domain, path, secureFlag)
{
   if (cookieName)
   {
      var cookieDetails = cookieName + "=" + escape(cookieValue);
      cookieDetails += (expires ? "; expires=" + 
         expires.toGMTString(): '');
      cookieDetails += (domain ? "; domain=" + domain: '');
      cookieDetails += (path ? "; path=" + path: '');
      cookieDetails += (secureFlag ? "; secure": '');
      document.cookie = cookieDetails;
   }
}


// Obtain a cookies unescaped value
function readUnescapedCookie(cookieName)
   {
   var cookieValue = document.cookie;
   var cookieRegExp = new RegExp("\\b" + cookieName + "=([^;]*)");
   cookieValue = cookieRegExp.exec(cookieValue);

   if (cookieValue != null)
   {
      cookieValue = cookieValue[1];	
   }

   return cookieValue;
}


// Obtain a cookies value
function readCookie(cookieName)
{
   cookieValue = readUnescapedCookie(cookieName)

   if (cookieValue != null)
   {
      cookieValue = unescape(cookieValue);
   }

   return cookieValue;
}


// Deletes existing cookie
function deleteCookie(cookieName)
{
   var expiredDate = new Date();
   expiredDate.setMonth(-1);
   writeCookie(cookieName,"",expiredDate);
}


// Create a cookie and specify a sub value
function writeMultiValueCookie( cookieName, multiValueName, value, expires, domain, path, secureFlag)
{
   var cookieValue = readUnescapedCookie(cookieName);
   if (cookieValue)
   {
      var stripAttributeRegExp = new RegExp("(^|&)" + 
         multiValueName + "=[^&]*&?");
      cookieValue = cookieValue.replace(stripAttributeRegExp,"$1");
      if (cookieValue.length != 0)
      {
         cookieValue += "&";
      }
   }
   else
   {
      cookieValue = "";
   }
   cookieValue += multiValueName + "=" + escape(value);
   var cookieDetails = cookieName + "=" + cookieValue;
   cookieDetails += (expires ? "; expires=" + expires.toGMTString(): '');
   cookieDetails += (domain ? "; domain=" + domain: '');
   cookieDetails += (path ? "; path=" + path: '');
   cookieDetails += (secureFlag ? "; secure": '');
   document.cookie = cookieDetails;
}


// Obtain sub value stored inside a cookie
function readMultiValueCookie(cookieName, multiValueName)
{
   var cookieValue = readUnescapedCookie(cookieName)
   var extractMultiValueCookieRegExp = new RegExp("\\b" + 
      multiValueName + "=([^;&]*)");
   cookieValue = extractMultiValueCookieRegExp.exec(cookieValue);

   if (cookieValue != null)
   {
      cookieValue = unescape(cookieValue[1]);	
   }

   return cookieValue;
}


// Deletes sub value stored inside a cookie
function deleteMultiValueCookie(cookieName, multiValueName, expires, domain, path, secureFlag)
{
   var cookieValue = readUnescapedCookie(cookieName);
   if (cookieValue)
   {
      var stripAttributeRegExp = new RegExp("(^|&)" + 
         multiValueName + "=[^&]*&?");
      cookieValue = cookieValue.replace(stripAttributeRegExp,"$1");

      if (cookieValue.length != 0)
      {
         var cookieDetails = cookieName + "=" + cookieValue;
         cookieDetails += (expires ? "; expires=" + 
            expires.toGMTString(): '');
         cookieDetails += (domain ? "; domain=" + domain: '');
         cookieDetails += (path ? "; path=" + path: '');
         cookieDetails += (secureFlag ? "; secure": '');
         document.cookie = cookieDetails;
      }
      else
      {
         deleteCookie(cookieName);
      }
   }
}


// Returns true if cookies are supported by browser &switched on by user
function cookiesEnabled()
{
   var cookiesEnabled = window.navigator.cookieEnabled;

   if (!cookiesEnabled)
   {
      document.cookie = "cookiesEnabled=True";
      cookiesEnabled = new Boolean(document.cookie).valueOf();
   }

   return cookiesEnabled;
}


function set_cookie()
{
	var icount= document.forms[0].elements.length;
	var isChecked=0;
	for (var i=0;i<icount;i++)
	{
		if (document.forms[0].elements[i].type=="checkbox")
		{
			if (document.forms[0].elements[i].checked)
				isChecked=1;
			else
				isChecked=0;
			writeMultiValueCookie("formvalue",document.forms[0].elements[i].name,isChecked);
		}
		else
			writeMultiValueCookie("formvalue",document.forms[0].elements[i].name,document.forms[0].elements[i].value);
			
	}
}
function mysubpage(q)
{
	set_cookie();
	writeMultiValueCookie("multipage","page"+q,1);
	if (q==0)
		document.location.href="inforequest.php";
	else
		document.location.href="inforequest.php?cid="+q;
}
function window_onload()
{
   if (cookiesEnabled() == false)
   {
      alert("You'll need to enable cookies to use this page");
   }

   var icount= document.forms[0].elements.length;
   firstload=readMultiValueCookie("formvalue","firstload");
   if (firstload!=1)
   {
	   writeMultiValueCookie("formvalue","firstload",1);
	   return;
   }
	for (var i=0;i<icount;i++)
	{
		if (document.forms[0].elements[i].type=="checkbox")
		{
			isChecked=readMultiValueCookie("formvalue",document.forms[0].elements[i].name);
			if (isChecked==1)
				document.forms[0].elements[i].checked=true;
			else
				document.forms[0].elements[i].checked=false;
		}
		else
		{
			fvalue=readMultiValueCookie("formvalue",document.forms[0].elements[i].name);
			if (fvalue!=null)
			{
			document.forms[0].elements[i].value=fvalue;
			}
		}
	}
}
function reset_form(theForm)
{
   isOK=confirm("Click \"OK\" to reset all answers, Click \"Cancel\" to return.");
   if (isOK)
   {
	   deleteCookie("formvalue");
	   window_onload();
   }
}

function validate_form(theForm)
{
	set_cookie();
/*	for(i=1;i<12;i++)
	{
		if (readMultiValueCookie("multipage", "page"+i)!=1)
		{
			isOK=confirm("You haven't visit question "+i+". Do you want to submit the form? Click \"OK\" to submit, Click \"Cancel\" to return.");
			if (isOK)
				return true;
			else
				return false;
		}
	}
*/
	if (theForm.company.value=="")
	{
		alert("Please fill in your Company's name");
		theForm.company.focus();
		return false;
	}
	if (theForm.title.value=="")
	{
		alert("Please fill in your Title");
		theForm.title.focus();
		return false;
	}
	if (theForm.firstname.value=="")
	{
		alert("Please fill in your Firstname");
		theForm.firstname.focus();
		return false;
	}
	if (theForm.lastname.value=="")
	{
		alert("Please fill in your Lastname");
		theForm.lastname.focus();
		return false;
	}
	if (theForm.industry.value=="")
	{
		alert("Please choose your Industry");
		theForm.industry.focus();
		return false;
	}
	if (theForm.address.value=="")
	{
		alert("Please fill in your Address");
		theForm.address.focus();
		return false;
	}
	if (theForm.city.value=="")
	{
		alert("Please fill in your City");
		theForm.city.focus();
		return false;
	}
	if (theForm.state.value=="")
	{
		alert("Please fill in your State");
		theForm.state.focus();
		return false;
	}
	if (theForm.zip.value=="")
	{
		alert("Please fill in your Zip");
		theForm.zip.focus();
		return false;
	}

	if (theForm.email.value=="")
	{
		alert("Please fill in your Email");
		theForm.email.focus();
		return false;
	}
	if (theForm.phone.value=="")
	{
		alert("Please fill in your Phone number");
		theForm.phone.focus();
		return false;
	}

	pidChecked=false;
   	var icount= document.forms[0].elements.length;
	for (var i=0;i<icount;i++)
	{
		
		if (document.forms[0].elements[i].type=="checkbox"&&document.forms[0].elements[i].name.match("pid"))
		{
			if (document.forms[0].elements[i].checked==true)
			{
				pidChecked=true;
				break;
			}
		}
	}
	if (pidChecked==false)
	{
		alert("Please choose at least one product that you are interested, click on \"+\" sign to expand the product line.");
		return false;
	}
	

	if (theForm.dealerid.value == "")
	{
		pidChecked=false;
		var icount= document.forms[0].elements.length;
		for (var i=0;i<icount;i++)
		{
			
			if (document.forms[0].elements[i].type=="checkbox"&&document.forms[0].elements[i].name.match("way_"))
			{
				if (document.forms[0].elements[i].checked==true)
				{
					pidChecked=true;
					break;
				}
			}
		}
		if (pidChecked==false)
		{
			alert("Please tell us how you find us.");
			return false;
		}
	}
	if (theForm.way_Other.checked==true &&theForm.others.value=="" )
	{
		alert("Please specify Others:( How did you find us?)");
		theForm.others.focus();
		return false;
	}
	return true;
}

function del_form(theForm)
{
	var length=theForm.elements.length;
	ischecked=false;
	for (i=0;i<length;i++)
	{
		if (theForm.elements[i].type=="checkbox")
		{
			if (theForm.elements[i].checked)
			{
				ischecked=true;
				break;
			}
		}
	}
	if (!ischecked)
	{
		alert("To delete any record, please check one check box.");
		return false;
	}
	else
	{
		isok=confirm("You are going to delete record. Click \"OK\" to continue or \"Cancel\" to return");
		return isok;
	}
}
function autotab(original,destination)
{
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
		destination.focus()
}
function openURL(url)
{
	window.open(url);
}