// JavaScript Document
function checksize(){
	//Detect browser
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if(browser == "Netscape"){
		//if mozilla ff
		if (window.innerWidth % 2 == 0){
		 	
			document.getElementById("all").style.backgroundImage = "url(images/bg_all_R.png)";
		 }else{
			document.getElementById("all").style.backgroundImage = "url(images/bg_all.png)";
		}
	}else if(browser == "Microsoft Internet Explorer"){
		//if IE
		if (document.body.clientWidth % 2 == 0){
			document.getElementById("all").style.backgroundImage = "url(images/bg_all_L.png)";
		}else{
			document.getElementById("all").style.backgroundImage = "url(images/bg_all.png)";
		}	
	}
}
//
function closewindow(){
	//Check for cookie
	
	//if there is a set cookie remove button
	var leadsubmit = getCookie("leadsubmit")
	if(leadsubmit == true || leadsubmit == "true"){
		document.getElementById('hider').style.display = "none";
	}
	//close window
	document.getElementById('leader').style.display = "none";
}
function leadcheck(){
	//
	var leadsubmit = getCookie("leadsubmit")
	//if(leadsubmit == true || leadsubmit == "true"){
		document.getElementById('hider').style.display = "none";
	//}else{
	//	document.getElementById('hider').style.display = "block";
	//}
}
//
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//
function itemshow(div,bt){
document.getElementById(div).style.display = "block"
document.getElementById("slink"+bt).style.display = "none"
document.getElementById("hlink"+bt).style.display = "inline"
}
function itemhide(div,bt){
document.getElementById(div).style.display = "none"
document.getElementById("slink"+bt).style.display = "inline"
document.getElementById("hlink"+bt).style.display = "none"
}
//
function openglass(){
	window.open('popglassinfo.html','glassinfo','width=400,height=200');
}
//
function vlmcheckform(){
	if(document.vlmmyform.FromEmail.value == ""){
		alert("Please Enter The Field Labeled: Email Address");
		return false
	}
	if(document.vlmmyform.FirstName.value == ""){
		alert("Please Enter The Field Labeled: First Name");
		return false
	}
	if(document.vlmmyform.LastName.value == ""){
		alert("Please Enter The Field Labeled: Last Name");
		return false
	}
	if((document.vlmmyform.FromEmail.value.indexOf(".") < 2) || (document.vlmmyform.FromEmail.value.indexOf("@") < 1)){
		alert("Please Enter A Valid Email Address");
		return false
	}
	return true
}
////CART DD
var defcartheight = 126;
var dropcart = false
function opencart(){
	if(dropcart == false){
		document.getElementById("cartdrop").style.display = "block";
		showcart()
	}else{
		hidecart()
	}
}
function hidecart(){
	//var cartheight = parseInt(document.getElementById("cartdrop").style.height);
	///cartheight -= 10
	//document.getElementById("cartdrop").style.height = cartheight + "px"
	//if(cartheight > 0){
	//var opener = setTimeout ( "hidecart()", 10); 
	//}else{
	//dropcart = false
	//document.getElementById("cartdrop").style.display = "none";
	//document.getElementById("cartdrop").style.height = "0px";
	//}
}
function showcart(){
	var cartheight = parseInt(document.getElementById("cartdrop").style.height);
	cartheight += 5
	document.getElementById("cartdrop").style.height = cartheight + "px"
	if(cartheight < defcartheight){
	var opener = setTimeout ( "showcart()", 10); 
	}else{
	dropcart = true
	document.getElementById("cartdrop").style.height = defcartheight+"px";
	}
}
document.onclick = hidecart; 
//
//******************************************************************************************
//
// A CGI program uses the following syntax to add cookie information to the HTTP header:
// 
// Set-Cookie:   name=value   
// [;EXPIRES=dateValue]   
// [;DOMAIN=domainName]   
// [;PATH=pathName]   
// [;SECURE]
//
// This function sets a client-side cookie as above.  Only first 2 parameters are required
// Rest of the parameters are optional. If no szExpires value is set, cookie is a session cookie.
//
// Prototype : setCookie(szName, szValue [,szExpires] [,szPath] [,szDomain] [,bSecure])
//******************************************************************************************


function setCookie(szName, szValue, szExpires, szPath, szDomain, bSecure)
{
 	var szCookieText = 	   escape(szName) + '=' + escape(szValue);
	szCookieText +=	 	   (szExpires ? '; EXPIRES=' + szExpires.toUTCString() : '');
	szCookieText += 	   (szPath ? '; PATH=' + szPath : '');
	szCookieText += 	   (szDomain ? '; DOMAIN=' + szDomain : '');
	szCookieText += 	   (bSecure ? '; SECURE' : '');
	
	document.cookie = szCookieText;
}

//******************************************************************************************
// This functions reads & returns the cookie value of the specified cookie (by cookie name) 
//
// Prototype : getCookie(szName)
//******************************************************************************************

function getCookie(szName)
{
 	var szValue =	  null;
	if(document.cookie)	   //only if exists
	{
       	var arr = 		  document.cookie.split((escape(szName) + '=')); 
       	if(2 <= arr.length)
       	{
           	var arr2 = 	   arr[1].split(';');
       		szValue  = 	   unescape(arr2[0]);
       	}
	}
	return szValue;
}

//******************************************************************************************
// To delete a cookie, pass name of the cookie to be deleted
//
// Prototype : deleteCookie(szName)
//******************************************************************************************

function deleteCookie(szName)
{
 	var tmp = 	  			 	 getCookie(szName);
	if(tmp) 
	{ setCookie(szName,tmp,(new Date(1))); }
}

//==========================================^-^==============================================//
//    This and many more interesting and usefull scripts at http://www.technofundo.com/		 //
//==========================================^-^==============================================//   
