//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
document.onkeypress 	    = document_onEnterPress;
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function document_onEnterPress(e) 
{
	try
	{
	    var code			= (window.event) ? event.keyCode    : e.keyCode;
        var input			= (window.event) ? event.srcElement : e.target;

		if(input && code==13)
		{
			if(input.tagName.toUpperCase()=="TEXTAREA")	return true;
			
            switch(input.id)
            {
				case 'ucSearchBar_txtUpperSearchBox': 
				case 'ucSearchBar_imgSearchBar': 

					document.getElementById("ucSearchBar_imgSearchBar").click();
                     
 					return false;
				break; 				
				default:
 					return false;
				break; 
            }    
		}
    }
    catch(e){ws(e.description);}
    finally
    {
    }
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


/////////////////////////////////
// general functions 
/////////////////////////////////
var selectedTab = "tdTab1";
var bIsSelectedClass = false;
function mouseoverClass(obj)
{
	bIsSelectedClass = (obj.className.indexOf("not_selected")>-1);
	obj.className = "selected";
	showhand(obj);
}

function mouseoutClass(obj)
{
	if (obj.id!=selectedTab) obj.className = "not_selected";
}

function showhand(obj)
{
	obj.style.cursor = "hand";
}

function imgOnOff(img,on){
imgSrc=img.src
imgSrc = imgSrc.toLowerCase( )
	if(on){
		imageOn=imgSrc.substring(0,imgSrc.indexOf("_off.gif")) + "_on.gif"
		img.src =imageOn
	}
	else{
		imageOff=imgSrc.substring(0,imgSrc.indexOf("_on.gif")) + "_off.gif"
		img.src =imageOff
	}
}

/////////////////////////////////
// products functions 
/////////////////////////////////

var lastProdTextID = "tdText1";

function prod_clickTabNew(obj)
{
	// get current textID
	for (var i=0;i<5;i++)
	{
		var t = document.getElementById("tdTab" + i);
		if (t)
		{
			t.className="not_selected";
		}
	}
	
	var currTextID = obj.id.replace("Tab","Text");
	selectedTab = obj.id;
	// make the currnt tab selected
	mouseoverClass(obj);
	bIsSelectedClass = true;
	
	// if the current tabID and the previous tabID are equales, exit from the function
	if (currTextID == lastProdTextID) 
	{
		return;
	}
					
	// display inline the selected text
	
	if (document.getElementById(currTextID).style.display == "none")
	{
		document.getElementById(currTextID).style.display = "inline";
	}
	
	// hide the previous text
	document.getElementById(lastProdTextID).style.display = "none";
	
	// make the previous tab no selected
	//document.all[lastProdTextID.replace("tdText","tdTab")].className = document.all[lastProdTextID.replace("tdText","tdTab")].className.replace("_on","_off");
	
	// save the current id							
	lastProdTextID = currTextID;
}

function prod_clickTab(obj)
{
	// get current textID
	var currTextID = obj.id.replace("Tab","Text");
	
	// make the currnt tab selected
	mouseoverClass(obj);
	bIsSelectedClass = true;
	
	// if the current tabID and the previous tabID are equales, exit from the function
	if (currTextID == lastProdTextID) 
	{
		return;
	}
					
	// display inline the selected text
	if (document.all[currTextID].style.display == "none")
	{
		document.all[currTextID].style.display = "inline";
	}
	
	// hide the previous text
	document.all[lastProdTextID].style.display = "none";
	
	// make the previous tab no selected
	document.all[lastProdTextID.replace("tdText","fontTab")].className = document.all[lastProdTextID.replace("tdText","fontTab")].className.replace("_on","_off");
	
	// save the current id							
	lastProdTextID = currTextID;
}

var lastExhibitionProdTextID = "tdText1";
var lastExhibitionProdTabID = "tdTab1";
function exhibition_prod_clickTab(obj)
{
	// get current textID
	var currTextID = obj.id.replace("Tab","Text");

	// make the currnt tab selected
	mouseoverClass(obj);
	bIsSelectedClass = true;

	// if the current tabID and the previous tabID are equales, exit from the function
	if (currTextID == lastExhibitionProdTextID) 
	{
		return;
	}

	// display inline the selected text
	if (document.all[currTextID].style.display == "none")
	{
		document.all[currTextID].style.display = "inline";
	}

	// hide the previous text
	document.all[lastExhibitionProdTextID].style.display = "none";

	// make the previous tab no selected
	document.all[lastExhibitionProdTabID].className = document.all[lastExhibitionProdTabID].className.replace("_on","_off");
	
	// save the current id							
	lastExhibitionProdTextID = currTextID;
	lastExhibitionProdTabID = obj.id;

}

/////////////////////////////////
//show footer function
/////////////////////////////////

function ShowFooter()
{
	var bottomObj = null;
	var docCookie = window.document.cookie;
	if(docCookie.indexOf("hideFooter=true")>-1)
	{
		//alert("displayFooter=false");
		bottomObj = document.getElementById("ucBottomBar_bottomText");
		if(bottomObj != null)
		{
			bottomObj.outerHTML = "<span>&nbsp;</span>";
			/*
			alert(bottomObj.outerHTML);
			alert(bottomObj.innerHTML);
			alert(bottomObj.outerText);
			alert(bottomObj.innerText);
			*/
		}
		bottomObj = document.getElementById("BottomBar_bottomText");
		if(bottomObj != null)
		{
			bottomObj.outerHTML = "<span>&nbsp;</span>";
		}
	}
}

/////////////////////////////////
// window open
/////////////////////////////////
function openWindow(sUrl,iHeight,iWidth,sParams)
{
	var size = "";
	try{
		iHeight = parseInt(iHeight)+50;
		iWidth = parseInt(iWidth)+50;
		
		var iTop = 190;
		var iLeft = 30;
		
		
		if(iWidth>window.screen.width) 
		{
			iLeft = 0;
			iWidth = window.screen.width;
		}	
		if(iHeight>window.screen.height) 
		{
			iTop = 0;
			iHeight = window.screen.height-100;
		}	
		
		size = "height="+iHeight+",width="+iWidth;
			
		var params = ",top=" + iTop + ",left=" + iLeft + ",scrollbars=yes,resizable=yes";
		if(sParams)params = sParams;
		
	}catch(e){}
	window.open(sUrl,"_blank",size+params);
}

/////////////////////////////////
// worldWide functions
/////////////////////////////////

function showCountry(mode,coords)
{
   var obj = document.all[coords.doc];
   
   switch(mode)
   {
   
     case 0:
     
		obj.style.display='none';
     
     break;
     
     case 1:
    	
		switch(obj.id.toLowerCase())
		{
			case "c_233":
			
			obj.style.left = 320;
			obj.style.top = 280;
			
			break;
		}
		
		obj.style.display='block'
     
     break;
   }

}
function clearInput(sender)
{
	if(trim(sender.value)==trim(sender.title))
	{
		sender.value		= "";	
	}
}
function returnDefault(sender)
{
	if(trim(sender.value)=='')
	{
		sender.value		= sender.title;	
	}
}
function quickSearch(strLocationPath, prefix)
{
	try
	{
		// get user control name
		//var strUserControl = getTopMenuUserControlName('_SearchBar_searchTmp');
		// get path
		//var strLocationPath = getLocationPath() + "Templates/Search/Search.aspx"; 		
		//var strLocationPath = "../Templates/Search/Search.aspx"; 		
		//var strLocationPath = "/Templates/Search/Search.aspx"; 		

		// params
		var input			= document.getElementById(prefix+"_txtUpperSearchBox");
		var strSearchText	= trim(input.value);
			strLocationPath	= trim(strLocationPath);

		if(strSearchText=='')	
		{
			alert(typeError3);
			
			return false;
		}
		if(strSearchText==trim(input.title))	
		{
			alert(typeError3);
			
			return false;
		}
		//var strSearchText = document.getElementById("txtUpperSearchBox").value;
		//var strSearchText = document.all[strUserControl + "_SearchBar_searchTmp"].value;
		var strLang			= getLang().toUpperCase();

		//alert(strUserControl)
		//alert('strSearchText='+strSearchText)
					
//		var params = "?lang=" + strLang;
		var params = "";

		if(strLocationPath.indexOf("?")>=0)	params		= "&";
		else								params		= "?";

		if (strSearchText!='' && strLocationPath.toLowerCase().indexOf("searchtext")<=0)
		{
			params		+= "SearchText=" + strSearchText + "&Group=0&Unit=0";
		}
		
		// cleen multi spaces
		var re = /\s+/g
		strSearchText	= strSearchText.replace(re,' ');
		
		// if only one chacacter
		if(strSearchText.length == 1  )
		{
			//alert('The Search option is working with two characters and above')
			alert(typeError1);
			
			return false;	
			//return ''	
		}

		// chack for illegal characters
		if (isIllegalChar(strSearchText))
		{
			//alert('The Search contain a illegal characters')
			alert(typeError2)
			
			return false;	
			//return ''
		}
		//alert(strLocationPath + params);
		location.href = strLocationPath + params;
		
	}
	catch (e)
	{

	}	
}

function getLocationPath()
{
	return document.all[getTopMenuUserControlName('_topMenuHeader_txtLocation') + "_topMenuHeader_txtLocation"].value;
}

function getTopMenuUserControlName(namePart)
{
	if (document.all['Header' + namePart])
	{
		return "Header";
	}
	
	return "ucHeader";
}
	
function getLang()
{
	var url = document.URL.split('?');
	if (url.length != 2)
	{
		return "EN";
	}

	var params = url[1].split('&');

	for (var i=0 ; i<params.length ; i++)
	{
		var param = params[i].split('=');
		if (param.length != 2)
		{
			return "EN";
		}

		if (param[0].toLowerCase() == "lang")
		{
			return param[1];
		}
	}
	
	return "EN";
}	

// find illegal characters. 
function isIllegalChar(sStr){
	var re = /[!,@,#,$,%,^,&,~,\\,?,;,:,]/
	return  (re.test(sStr))
}
