
/*//This sets and gets cookies and will be on every page ///*/ 
function createCookie(name,value,days) {
    if (days) {
	    var date = new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
	    var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return _getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

// "Internal" function to return the decoded value of a cookie
//
function _getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

/*This is for the pop up divs//*/
	
	window.productDetails_jso={
	    showPopup: function(o, e, s){
	        var d=document.getElementById(s);
	        d.style.visibility='visible';
	    },
	    
	    hidePopup: function(o, e, s){
	        var d=document.getElementById(s);
	        d.style.visibility='hidden';
	    },
	    
	    'end':'end'
	};

function clear_searchBox(who)
	{
		if(who=='cs'){
			if (document.searchForm.SearchFor.value == "Product Search"){
				document.searchForm.SearchFor.value = "";
			}
		}else{
			if(document.ErrorSearchForm.ErrorSearchFor.value == "Product Search"){
				document.ErrorSearchForm.ErrorSearchFor.value = "";
			}
		}
	}  
//This is to validate the users Email Address GET UPDATES in the preferences page

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.emailForm.EMAIL
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

/* This is for the pop new windows/*/
function nogo() { ; }

function openWindow( url )
{
//var w = window.open (url, "win", "height=200,width=500,location,menubar,resizable,scrollbars,status,toolbar");
var w = window.open (url, "win", "height=100,width=575");
}

function OpenWindowSRC(url, name, width, height, scroll) {
			popupWin = window.open(url, name, 'status=no,menubar=no,location=no,toolbar=no,scrollbars=' + scroll +',resizable=no,width=' + width +',height=' + height + ',screenX=0,screenY=0,top=0,left=0')
}
function OpenWindowHoliday(url, name, width, height, scroll) {
		popupWin = window.open(url, name, 'status=no,menubar=no,toolbar=no,scrollbars=' + scroll +',resizable=no,width=' + width +',height=' + height + ',screenX=0,screenY=0,top=0,left=0')
	}

/*This is for switching Class Names//*/
function changeClass(idElement,myClass){
    document.getElementById(idElement).setAttribute('className', myClass);
    document.getElementById(idElement).setAttribute('class', myClass);
}