var strSelectMaxThree = "A maximum of 3 products can be selected";
var strSelectUpToThree = "Please select up to three products";
var strInvalidEmailAddress = "Please enter a valid email address";
var strNotSimilar = "The email addresses are not the the same";
var strVPOLogin = "The password you provided is incorrect.";
var strFillOut = "Not all mandatory fields have been filled in.";
var strInfoRequest = "";
function cmdPrintPage()
{
	var lObjArrProperties = new Array()
	lObjArrProperties["Title"] = document.title
	var lObjAllPrintSpans = document.getElementsByName("PrintElement")
	if(lObjAllPrintSpans.length == 0)
	{
                                lObjArrProperties["NoElements"] = true
                               	lObjArrProperties["PrintElements"] = document.body.firstChild
	}
                else
                {
                                lObjArrProperties["NoElements"] = false
	                lObjArrProperties["PrintElements"] = lObjAllPrintSpans
                }


	var lStrFixedAttributes = "center:1;help:0;status:0;resizable:1;"
	var lStrSize			= "dialogWidth:800px;dialogHeight:600px;"
	var lStrPopupLocation	= "/system/printpage.xhtml"

	return showModalDialog(lStrPopupLocation, lObjArrProperties, lStrSize + lStrFixedAttributes);

}

function printwin()
{
               window.print();
}

function swapDisplay(element)
{
   var objULelement = element.parentNode.parentNode.children[1];
   for (i=0; i< objULelement.children.length; i++) {
      var objLIelement = objULelement.children[i];
   	if (objLIelement.style.display == "block") {
		objLIelement.style.display = "none";
	} else {
		objLIelement.style.display = "block";
   	}
   }
}


// Have Global Navigation MouseOver Swapped Static Ver.

function swaponBg(target) {
	if(window.opera){
		return true;
	}
	else{
		target.style.backgroundColor = '#006699';
	}
}

function swapoffBg(target) {
	if(window.opera){
		return true;
	}
	else{
		target.style.backgroundColor = '#44AADD';
	}
}

function showImg(imgID) {
	document.images['imgMain'].src = document.images[imgID].src;
}

//this function checks if the VPO fields contain values
function vpoCheck(form){
	if ((form.username.value == "") || (form.password.value == "")){
		alert(strVPOLogin);
		return false;
	}	else	{
		return true;
	}
}

function checkWhenChecked(form, lastbox){
	// 3 products can be selected
	var total = 0;
	var box = null;
	var total = checkCheckedCheckBoxes(form);
	if (total > 3) {
		for (var cntProduct = 0; cntProduct < form.product.length; cntProduct++) {
			if (form.product[cntProduct].id == lastbox) {
				box = form.product[cntProduct];
				box.checked = false;
				alert(strSelectMaxThree);	
				return false;
			}
		}
	}	
}	

function checkProdSubmit(form) {
// at least one product must have been selected
var	total = 0;
total = checkCheckedCheckBoxes(form);
if (total < 1) {
	alert(strSelectUpToThree);
	}
else{
	form.submit();
	}
}

function checkCheckedCheckBoxes(form) {
//counts the number of checkboxes that was checked
var total = 0;
var max = form.product.length;
for (var counter = 0; counter < max; counter++) {
if (eval("form.product[" + counter + "].checked") == true) {
    total += 1;
   }
}
return total;	   
}

function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
        //emailRef.focus();
        //emailRef.value = '';
	alert(strInvalidEmailAddress);
	return false;
	}
else{
	return true;
	}
}

function resetAll(form) {
	form.reset();
	return false;
}

function enewsCheck(form){
	var strEmail=form.email.value;
	var strConfirmEmail=form.confirmemail.value;

	if (emailCheck(strEmail)){
		if (strEmail == strConfirmEmail){
			return true;
		}
		else {
			alert(strNotSimilar);
			return false;
		}
	}
	else {
		return false;
		}	
}


function productFormCheck(form){
	var strEmail=form.email.value;
	var strFirstName=form.firstname.value;
	var strLastName=form.lastname.value;
	var strCountry=form.country.value;

	if (emailCheck(strEmail)) {
	 if (strFirstName == "") {
	 alert (strFillOut);
	 return false;
	 } else {
	 	if (strLastName == "") {
		alert (strFillOut);
	    return false;
		} else {
			if (strCountry == "") {
			alert (strFillOut);
	    	return false;
			} else {
			return true;
			}
		}
	 }
	}
	else {
		return false;
		}	
}

function vpoRequestFormCheck(form){

	var strFirstName=form.firstname.value;
	var strLastName=form.lastname.value;
	var strEmail=form.email.value;
	var strPublication=form.publication.value;
	var strAddress=form.address.value;
	var strPostalCode=form.postalcode.value;
	var strCity=form.city.value;
	var strCountry=form.country.value;

	if (emailCheck(strEmail)) 
	{
		if (strFirstName == "") 
		{
			alert (strFillOut);
			return false;
		} 
		else 
		{
	 		if (strLastName == "") 
	 		{
				alert (strFillOut);
				return false;
			} 
			else 
			{
				if (strPublication == "") 
				{
					alert (strFillOut);
	    			return false;
				} 
				else 
				{

					if (strAddress == "") 
					{
						alert (strFillOut);
	    				return false;
					} 
					else 
					{
						if (strPostalCode == "") 
						{
							alert (strFillOut);
	    					return false;
						} 
						else 
						{
							if (strCity == "") 
							{
								alert (strFillOut);
	    						return false;
							} 
							else 
							{
								if (strCountry == "") 
								{
									alert (strFillOut);
	    							return false;
								} 
								else 
								{
									return true;
								}
							}
						}
					}
				}
			}
		}
	}
	else 
	{
		return false;
	}	
}

//random image picker
function pickImage(upperlimit){
	// get a random number in the specified range (0 - upperlimit)
	var rndNumber = Math.round(upperlimit*Math.random());
	
	// create ID string
	var id = 'banner' + rndNumber;

	//change the mainimage location
	document.images['mainbanner'].src = (document.getElementById ? document.getElementById(id).getAttribute('href') : document.all[id].href) ;
}

//random partner image picker
function pickPartnerImage(upperlimit){
	// get a random number in the specified range (0 - upperlimit)
	var rndNumber = Math.round(upperlimit*Math.random());
	//specify interval between rotating banners (in mili seconds)
	var delay = 5000;
	// create ID string
	var id = 'partner' + rndNumber;

	//change the mainimage location
	document.images['partnerimage'].src = (document.getElementById ? document.getElementById(id).getAttribute('href') : document.all[id].href) ;
	setTimeout("pickPartnerImage('" + upperlimit + "')", delay);
}

function forward(href){
location.href (href.value);
}

function openWin(img, varWidth, varHeight) {
if (varWidth==0){
varWidth=640;
}
if (varHeight==0){
varHeight=480;
}
window.open(img.href, '', 'toolbar=no , width=' + varWidth + ', height= ' + varHeight);
}


//# MM_functions
function MM_swapImgRestore() {
	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_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_findObj(n, d) {
	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_preloadImages() {
	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];}}
}

MM_preloadImages('{$MULTIMEDIA_URL}map_europe_asia.gif','{$MULTIMEDIA_URL}map_america.gif');
// get the browser information

function getOsName( )

{

	var userOs      = "" ;

	var regexResult = "" ;

	var moreInfo    = true ;

	var usrAgent    = navigator.userAgent.toUpperCase( ) ;



	if ( usrAgent.indexOf("WIN") != -1 ) userOs = "Windows" ;

	if ( usrAgent.indexOf("MAC") != -1 ) userOs = "MacOS" ;

	if ( usrAgent.indexOf("X11") != -1 ) userOs = "UNIX" ;



	return userOs ;

}



function getBrowserName( )

{

	var userBrowser = "" ;

	var appName     = navigator.appName.toUpperCase( ) ;



	if ( appName.indexOf("NETSCAPE")  != -1 ) userBrowser = "Netscape" ;

	if ( appName.indexOf("MICROSOFT") != -1 ) userBrowser = "Explorer" ;



	return userBrowser ;

}



function getBrowserVersion( )

{

	var version    = "" ;

	var start      = 0  ;

	var end        = 0  ;

	var usrBrowser = getBrowserName( ) ;

	var usrAgent   = navigator.userAgent.toUpperCase( ) ;

	var appVersion = navigator.appVersion ;



	if ( usrBrowser == "Netscape" )

	{

		start   = appVersion.indexOf(" ",0) ;

		version = appVersion.substring(0,start) ;

	}

	if ( usrBrowser == "Explorer" )

	{

		start   = appVersion.indexOf("MSIE ",0) + 5 ;

		end     = appVersion.indexOf(";",start) ;

		version = appVersion.substring(start,end) ;

	}



	return version ;

}


function printStyleSheet( )
{
	var WIN_IE4_SRC = "/system/win_ie.css" ;
	var WIN_IE5_SRC = "/system/win_ie.css" ;
	var WIN_NN4_SRC = "/system/win_nn4.css" ;
	var WIN_NN6_SRC = "/system/win_ie.css" ;
	var WIN_OPERA_SRC = "/system/win_ie.css" ;

	var MAC_IE4_SRC = "/system/mac_ie.css" ;
	var MAC_IE5_SRC = "/system/mac_ie.css" ;
	var MAC_NN4_SRC = "/system/mac_nn4.css" ;
	var MAC_NN6_SRC = "/system/mac_nn.css" ;
	var MAC_OPERA_SRC = "/system/mac_nn.css" ;

	// put the browser information in variable
	var os      = getOsName( ) ;
	var browser = getBrowserName( ) ;
	var version = getBrowserVersion( ).charAt( 0 ) ;

	var cssSrc = null ;

	if ( os == "Windows" )
	{
		if ( browser == "Explorer" )
		{
			if ( version == 4 )
			{
				cssSrc = WIN_IE4_SRC ;
			}
			if ( version >= 5 )
			{
				cssSrc = WIN_IE5_SRC ;
			}
		}
		else if ( browser == "Netscape" )
		{
			if ( version == 4 )
			{
				cssSrc = WIN_NN4_SRC ;
			}
			if ( version >= 5 )
			{
				cssSrc = WIN_NN6_SRC ;
			}
		}
		else if ( browser == "OPERA" )
		{
			cssSrc = WIN_OPERA_SRC ;
		}
	}
	else if ( os == "MacOS" )
	{
		if ( browser == "Explorer" )
		{
			if ( version == 4 )
			{
				cssSrc = MAC_IE4_SRC ;
			}
			if ( version >= 5 )
			{
				cssSrc = MAC_IE5_SRC ;
			}
		}
		else if ( browser == "Netscape" )
		{
			if ( version == 4 )
			{
				cssSrc = MAC_NN4_SRC ;
			}
			if ( version >= 5 )
			{
				cssSrc = MAC_NN6_SRC ;
			}
		}
		else if ( browser == "OPERA" )
		{
			cssSrc = MAC_OPERA_SRC ;
		}
	}

	// output the stylesheet
	if ( cssSrc )
	{
		document.open( ) ;
		document.write( '<LINK REL="stylesheet" TYPE="text/css" HREF="' + cssSrc + '">' ) ;
		document.close( ) ;
	}
}


printStyleSheet( ) ;
function Goto_Country(country) {
    if (country != "") {
       hideAllCountries();
       Hide_This(bycategory)
       Hide_This(bycompany)
       document.getElementById(country).style.display = "";
    }
}

function hideAllCountries()
{

    tmp = document.getElementsByTagName('div');

    for (i=0;i<tmp.length;i++)
    {
        idString = tmp[i].id;
        if (idString.indexOf("country_") > -1)  tmp[i].style.display = "none";
    }
    
}


function Show_Solution(Click_Menu)
{
  hideAllCountries()
switch (Click_Menu) {
  case bycategory:
    Show_This(bycategory)
    Hide_This(bycompany)
  break
  case bycompany:
    Show_This(bycompany)
    Hide_This(bycategory)
  break
}
}

function Show_Text_Block(Click_Menu)
{
switch (Click_Menu) {
case text1:
Show_This(text1)
Active_Link(link1)
Hide_This(text2)
Hide_This(text3)
Hide_This(text4)
Hide_This(text5)
InActive_Link(link2)
InActive_Link(link3)
InActive_Link(link4)
InActive_Link(link5)
break
case text2:
Show_This(text2)
Active_Link(link2)
Hide_This(text1)
Hide_This(text3)
Hide_This(text4)
Hide_This(text5)
InActive_Link(link1)
InActive_Link(link3)
InActive_Link(link4)
InActive_Link(link5)
break
case text3:
Show_This(text3)
Active_Link(link3)
Hide_This(text1)
Hide_This(text2)
Hide_This(text4)
Hide_This(text5)
InActive_Link(link1)
InActive_Link(link2)
InActive_Link(link4)
InActive_Link(link5)
break
case text4:
Show_This(text4)
Active_Link(link4)
Hide_This(text1)
Hide_This(text2)
Hide_This(text3)
Hide_This(text5)
InActive_Link(link1)
InActive_Link(link2)
InActive_Link(link3)
InActive_Link(link5)
break
case text5:
Show_This(text5)
Active_Link(link5)
Hide_This(text1)
Hide_This(text2)
Hide_This(text3)
Hide_This(text4)
InActive_Link(link1)
InActive_Link(link2)
InActive_Link(link3)
InActive_Link(link4)
break
}
}
function Show_This(Click_Menu)
{
Click_Menu.style.display = "";
}
function Hide_This(Click_Menu)
{
Click_Menu.style.display = "none";
}

function Active_Link(oLink)
{
//oLink.style.color = "#ff0000";  //;"localnavff0000boldclass5th";
oLink.className = "localnavff0000boldclass5th";
}
function InActive_Link(oLink)
{
//oLink.style.color = "#006699";  //"localnav006699boldclass5th";
oLink.className = "localnav006699boldclass5th";
}
