<!--
// for search submission
function submitsearch() {
var msg = "You need type a keyword to start search";
var space = "";
var twospace = " ";

if (window.document.forms.srch.keyword.value == space ||window.document.forms.srch.keyword.value == twospace) {
	alert(msg);
        return false;
   }
   else {
	window.document.forms.srch.keyword.value = window.document.forms.srch.keyword.value + '%';
	window.document.forms.srch.submit();
        return true;
   }
}

function popup2(filename,height,width) {
	width=200;
	window.open(filename,"Promo",'height=' + height,'width=' + width, resizable=1)
}

function popup(filename,options) {
	window.open(filename,"promo",options)
}

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_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 pausecomp(Amount)
{
d = new Date() //today's date
while (1)
{
mill=new Date() // Date Now
diff = mill-d //difference in milliseconds
if( diff > Amount ) {break;}
}
}

// for compare page

function changeImage(sel)
	{
//	 var trimname
//	check duplicate selection
	if (! valid(sel))
		{
		switch(sel)
			{
			case 1:
				window.document.forms.compare.product1.selectedIndex=0
				break
			case 2:
				window.document.forms.compare.product2.selectedIndex=0
				break
	                case 3:
				window.document.forms.compare.product3.selectedIndex=0
				break
			case 4:
				window.document.forms.compare.product4.selectedIndex=0
				break
			}
		ImageSwapRemove(sel)
		return true
		}
	ImageSwap(sel)
	}
function show(Element)
{
 document.getElementById(Element).style.display = "block";
}

function Toggle2(Element, Button, ButtonDefaultValue, ButtonChangedValue)
{

  switch(document.getElementById(Element).style.display)
  {
    case "block" :
      document.getElementById(Element).style.display = "none";
      document.getElementById(Button).value = ButtonDefaultValue;
    break;
    case "none" :
      document.getElementById(Element).style.display = "block";
      document.getElementById(Button).value = ButtonChangedValue;
    break;
    default :
      document.getElementById(Element).style.display = "none";
      document.getElementById(Button).value = ButtonDefaultValue;
	}
}
function Toggle(Element, Button, ButtonDefaultValue, ButtonChangedValue)
{

  switch(document.getElementById(Element).className)
  {
    case "divshow" :
      document.getElementById(Element).className = "divhide";
      document.getElementById(Button).value = ButtonDefaultValue;
    break;
    case "divhide" :
      document.getElementById(Element).className = "divshow";
      document.getElementById(Button).value = ButtonChangedValue;
    break;
    default :
      document.getElementById(Element).className = "divhide";
      document.getElementById(Button).value = ButtonDefaultValue;
	}
}




function ImageSwapRemove(sel)
	{
	if (sel==1)
		{
        	document.s1.src="en/images/sp.gif"
		}
	else if (sel==2)
		{
        	document.s2.src="en/images/sp.gif"
		}
	else if (sel==3)
		{
        	document.s3.src="en/images/sp.gif"
		}
	else if (sel==4)
		{
        	document.s4.src="en/images/sp.gif"
		}
	}
//change image
function ImageSwap(sel)
	{
        var trimname, pos, strarray
	if (sel==1)
		{
 		trimname=document.forms.compare.product1.options[document.forms.compare.product1.selectedIndex].value
                pos = trimname.indexOf(";")
   		document.s1.src=trimname.substring(0, pos)
                if (document.forms.compare.product1.selectedIndex == 0) 
                     {
                     document.s1.src="en/images/sp.gif"
                     }

		}
	else if (sel==2)
		{
		trimname=document.forms.compare.product2.options[document.forms.compare.product2.selectedIndex].value
                pos = trimname.indexOf(";")
		document.s2.src=trimname.substring(0, pos)
                if (document.forms.compare.product2.selectedIndex == 0) 
                     {
                     document.s2.src="en/images/sp.gif"
                     }

		}
	else if (sel==3)
		{
		trimname=document.forms.compare.product3.options[document.forms.compare.product3.selectedIndex].value
                pos = trimname.indexOf(";")
		document.s3.src=trimname.substring(0, pos)
                if (document.forms.compare.product3.selectedIndex == 0) 
                     {
                     document.s3.src="en/images/sp.gif"
                     }
		}
	else if (sel==4)
		{
		trimname=document.forms.compare.product4.options[document.forms.compare.product4.selectedIndex].value
                pos = trimname.indexOf(";")
		document.s4.src=trimname.substring(0, pos)
                if (document.forms.compare.product4.selectedIndex == 0) 
                     {
                     document.s4.src="en/images/sp.gif"
                     }
		}	
		
	return true
	}

function valid(sel)
	{
	var sel1,sel2,sel3, sel4
	sel1=document.forms.compare.product1.selectedIndex
	sel2=document.forms.compare.product2.selectedIndex
	sel3=document.forms.compare.product3.selectedIndex
	//sel4=document.forms.compare.product4.selectedIndex
		

	if (sel1==0) {sel1=10001}
	if (sel2==0) {sel2=10002}
	if (sel3==0) {sel3=10003} 
	if (sel4==0) {sel4=10004} 
	//if ((sel1==sel2) || (sel1==sel3) || (sel1==sel4) || (sel2==sel3) || (sel3==sel4) || (sel2==sel4)){
        if ((sel1==sel2) || (sel1==sel3) || (sel2==sel3)) {
	  alert("You have selected this product already.")
	  return false}
	else {
	  return true  
	}
}


function compareSubmit()
{
var sel1,sel2,sel3,sel4, msg
var selTrim1,selTrim2,selTrim3
msg="You must select at least two products for comparision"
msgd="You can not select the same product more than once for comparision"

sel1=document.forms.compare.product1.selectedIndex
sel2=document.forms.compare.product2.selectedIndex
sel3=document.forms.compare.product3.selectedIndex
//sel4=document.forms.compare.product4.selectedIndex

//check
//if (sel1==0 && sel2==0 && sel3==0 && sel4==0)  {alert(msg);return false}
if (sel1==0 && sel2==0 && sel3==0)  {alert(msg);return false}
//if ((sel1==0 && sel2==0 && sel3==0) || (sel1==0 && sel2==0 && sel4==0) || (sel2==0 && sel3==0&& sel4==0) || (sel1==0 && sel3==0&& sel4==0))  {alert(msg);return false}
if ((sel1==0 && sel2==0) || (sel1==0 && sel3==0) || (sel2==0 && sel3==0))  {alert(msg);return false}
//if (((sel1!=0) && ((sel1==sel2) ||(sel1==sel3) ||(sel1==sel4)))||((sel2!=0) && ((sel2==sel3) ||(sel2==sel4))) ||((sel3!=0) && (sel3==sel4))) {alert(msgd);return false}
if (((sel1!=0) && ((sel1==sel2) ||(sel1==sel3)))||((sel2!=0) && (sel2==sel3))) {alert(msgd);return false}

}

function sendemail() {
msg="";
hasemail=false;
    with (document.forms["emailpdf"]) {
        if (sender.value.length == 0) { // sender email address is required
	    msg = "Please provide your email address\n";
        } else {
           if (!validEmailAddress(sender.value, false)) // validate sender email address
	        msg = msg + "Your email address is not valid\n";
        }

	if (email1.value.length > 0) {
             hasemail = true;
             if (!validEmailAddress(email1.value, false))
                    msg = msg + "First email address is not valid\n";
        }

	if (email2.value.length > 0) {
             hasemail = true;
             if (!validEmailAddress(email2.value, false))
                    msg = msg + "Second email address is not valid\n";
        }
	if (email3.value.length > 0) {
             hasemail = true;
             if (!validEmailAddress(email3.value, false))
                    msg = msg + "Third email address is not valid\n";
        }
	if (email4.value.length > 0) {
             hasemail = true;
             if (!validEmailAddress(email4.value, false))
                    msg = msg + "Fourth email address is not valid\n";
        }
	if (email5.value.length > 0) {
             hasemail = true;
             if (!validEmailAddress(email5.value, false))
                    msg = msg + "Fifth email address is not valid\n";
        }

	if (!hasemail) {
               msg = msg + "Provide at least one address to receive the email.\n";
	}
    }
	if (msg.length > 0)
		alert(msg);
	return (msg.length == 0);

}


function validEmailAddress(email, allowempty) {
	if (email.length == 0)
		return allowempty;
	a = email.split('@');
	if (a.length == 2) {
		if (a[0].length >= 2 && a[1].length >= 3) {
			//a = email.split('.');
			//if (a.length >= 2) {
				//for(i=0; i < a.length; i++) {
					//if (a[i].length < 2)
						//return false;
				//}
				return true;
			//}
		}
	}
	return false;
}


function recompare() {
    if(window.opener.closed) {
        document.returntocompare.submit();
    } else {
        window.opener.focus();
        window.opener.document.forms["returntocompare"].submit();
        window.close();
    }
    return true;
}

	


function printpage() {
location.href=location.href + "&printpage=T"
}


//cookie functions from http://www.webmasterbase.com/static/popjs.php
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

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;
}

function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}



function setFromState() {
   
   var el1,state1=GetCookie("product"),el2,state2=GetCookie("articles");
   var icon
    if (document.getElementByID) {
      el1=document.getElementById("product");
      el2=document.getElementById("articles");
    } else if (document.all){
	  el1=document.all["product"]
	  el2=document.all["articles"]
    }
    if (el1 && state1) {
	 el1.style.display=state1;
         if (el1.style.display=="block" && document.images["icon2"]) document.images["icon2"].src = "/web/en/images/minus.gif";
    } else   if (el1) el1.style.display="none";
    
    	
    if (el2 && state2) {
	el2.style.display=state2;
       if (el2.style.display=="block" && document.images["icon1"]) document.images["icon1"].src = "/web/en/images/minus.gif";
    } else if (el2) el2.style.display="none";
     
     
    
    return null; 
}

function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
{
if(mySel.form.target)myWin = parent[mySel.form.target];
else myWin = window;
if (! myWin) return true;
myWin.location = myVal;
}
return false;
}


//-->



