
/*//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 sets the cookie for the menu state//*/
        function menuState(){
            //This is to maintain the state in which it was open by setting a cookie
            //if(GetCookie ('menuState') != null)window.accordion_jso.runAccordion(GetCookie ('menuState'), true);
            if(GetCookie ('menuState') == null)return;
            if(GetCookie ('menuState') == 1)document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.height = '150px';
            if(GetCookie ('menuState') == 2)document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.height = '130px';
            if(GetCookie ('menuState') == 3)document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.height = '90px';
            if(GetCookie ('menuState') == 4)document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.height = '90px';
            if(GetCookie ('menuState') == 5)document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.height = '50px';
            if(GetCookie ('menuState') == 6)return;
            if(GetCookie ('menuState') == 7)document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.height = '60px';
            document.getElementById('Menu' + GetCookie ('menuState') + 'Content').style.display = 'block';
            window.accordion_jso.lastClicked = document.getElementById("menu"+GetCookie ('menuState'));
            window.accordion_jso.openAccordion = 'Menu' + GetCookie ('menuState') + 'Content';
            window.accordion_jso.setImage(document.getElementById("menu"+GetCookie ('menuState')));
            
        }
        
/*This is to make the main menu animate open/*/
window.accordion_jso = {
    //ContentHeight: 200,
    TimeToSlide: 250.0,
    openAccordion: '',
    lastClicked: null,

    runAccordion: function(index,lnum, animate)
    
    {
			//if you change the height value change it in the menuState Function above as well
			window.accordion_jso.ContentHeight=(22*lnum);
         
			var nID = "Menu" + index + "Content";
         
			if(animate == false)window.accordion_jso.TimeToSlide=35.0;
			
			
         
          if(window.accordion_jso.openAccordion == nID)
            nID = '';
           
          setTimeout("window.accordion_jso.animate("
              + new Date().getTime() + "," + window.accordion_jso.TimeToSlide + ",'"
              + window.accordion_jso.openAccordion + "','" + nID + "')", 22);
         
          window.accordion_jso.openAccordion = nID;
          
          var d = document.getElementById("menu"+index);
          if(window.accordion_jso.lastClicked != null && d != window.accordion_jso.lastClicked) 
                window.accordion_jso.setBold(window.accordion_jso.lastClicked,1);
         
          window.accordion_jso.setBold(d);
          window.accordion_jso.lastClicked = d;
		 
		 createCookie('menuState',index,0) ;

		window.accordion_jso.TimeToSlide=250.0;
        },

        animate: function(lastTick, timeLeft, closingId, openingId)
        { 
          var curTick = new Date().getTime();
          var elapsedTicks = curTick - lastTick;
         
          var opening = (openingId == '') ?
              null : document.getElementById(openingId);
          var closing = (closingId == '') ?
              null : document.getElementById(closingId);
         
          if(timeLeft <= elapsedTicks)
          {
            if(opening != null)
              opening.style.height = window.accordion_jso.ContentHeight + 'px';
           
            if(closing != null)
            {
              closing.style.display = 'none';
              closing.style.height = '0px';
            }
            return;
          }
         
          timeLeft -= elapsedTicks;
          var newClosedHeight =
              Math.round((timeLeft/window.accordion_jso.TimeToSlide) * window.accordion_jso.ContentHeight);

          if(opening != null)
          {
            if(opening.style.display != 'block')
              opening.style.display = 'block';
            opening.style.height =
                (window.accordion_jso.ContentHeight - newClosedHeight) + 'px';
          }
         
          if(closing != null)
            closing.style.height = newClosedHeight + 'px';

          setTimeout("window.accordion_jso.animate(" + curTick + "," + timeLeft + ",'"
              + closingId + "','" + openingId + "')", 22);
        },
        setBold: function (o, force){
			if (force==1)
			{
				o.style.fontWeight="normal"
			}
			else
			{
				o.style.fontWeight=(o.style.fontWeight=="bold")?"normal":"bold";
			}
		},
        setImage: function (o, force){
         if(o.getAttribute("Xstate") == "opened" || force == 1){
                o.src=o.src.replace(/_open\.gif/,'_closed.gif');
                o.setAttribute("Xstate","closed");
               }
          else{
               o.src=o.src.replace(/_closed\.gif/,'_open.gif');
               o.setAttribute("Xstate","opened");
              }
         }


}
/*//this switches to the subsub menu for the third tier/*/
function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "block" ) {
		el.style.display = 'block';
	}
	else {
		el.style.display = '';
	}
	}

function hsub(obj) {
	var el = document.getElementById("smenu_"+obj);
	if ( el.style.display != "block" ) {
		el.style.display = 'block';
	}
	else {
		el.style.display = 'none';
	}
}
/*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'
	};


//This is to validate the users Email Address GET UPDATES in the preferences page

function isEmail(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,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);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
