window.onload				= init;

function init()
{

	try
	{
		if(window.initKSForm) initKSForm();	
	}catch(e){}
}

function send_sendToAFriend(nPopupWinWidth, nPopupWinHeight, bPopupWinScrollbars, bPopupWinToolbar, lang)
{
	var language = (lang==1) ? 'EN' : 'HE';
	 
	nPopupWinTop = screen.height/2 - nPopupWinHeight/2;
	nPopupWinLeft = screen.width/2 - nPopupWinWidth/2;		
	
	window.open(getHostAddress() + '/TemplateControls/SendToAFriend/SendToAFriendTemplatePopup.aspx?lang='+language  , 'sendToFrient','top=' + nPopupWinTop + ',left=' + nPopupWinLeft + ',width=' + nPopupWinWidth + ',height=' + nPopupWinHeight + ',scrollbars=' + bPopupWinScrollbars + ',toolbar=' + bPopupWinToolbar);		
}

function getHostAddress()
	{
		var	urlPrefix		= getUrlPrefix();
		lastSlashPos		= urlPrefix.lastIndexOf('/');
		hostAddress			= urlPrefix.substring(0,lastSlashPos);
	
		return hostAddress;
	}

function getUrlPrefix()
{
	// cut all the url file & query suffix
	var	urlPath			= location.href.substring(0,location.href.indexOf('.aspx'));
	var lastSlashPos	= urlPath.lastIndexOf('/');
	var urlPrefix		= urlPath.substring(0,lastSlashPos);	
	
	return urlPrefix;
}
function KeyPressSiteSearch()
{
	try
	{
		if (event.keyCode==10 || event.keyCode==13)
		{
			siteSearch();
		}
	}catch(e){}
}

	function OpenDiv(name, id)
	{
		//var menuDiv	= window.document.getElementsByTagName("div");
		
		//for(var i=0; i<menuDiv.length; i++)
	//	{
	//		if(menuDiv[i].type == "menuDiv")
	//		{
	//			menuDiv[i].style.display = "none"
	//		}
	//	}
	
		if(document.getElementById("Overview") != null)
		{
			document.getElementById("Overview").style.display = "none"
		}
		if(document.getElementById("Benefits") != null)
		{
			document.getElementById("Benefits").style.display = "none"
		}
		if(document.getElementById("Specifications") != null)
		{
			document.getElementById("Specifications").style.display = "none"
		}
		if(document.getElementById("Features") != null)
		{
			document.getElementById("Features").style.display = "none"
		}
		
	
		
		if(document.getElementById("tabDiv0")!= null)
		{
			document.getElementById("tabDiv0").className = "tab_close";
		}
		if(document.getElementById("tabDiv1")!= null)
		{
			document.getElementById("tabDiv1").className = "tab_close";
		}
		if(document.getElementById("tabDiv2")!= null)
		{
			document.getElementById("tabDiv2").className = "tab_close";
		}
		if(document.getElementById("tabDiv3")!= null)
		{
			document.getElementById("tabDiv3").className = "tab_close";
		}
	
		var elem = document.getElementById("tabDiv"+id);
		
		elem.className= 'tab_open'
	
		document.getElementById(name).style.display = "block";
		//elem.style.display = "block";
	}
	
	
	
	function ShowDemo(image, demoImage, demo)
	{
	
		var Image		= window.document.getElementById("Product_productImage");
		var Demo		= window.document.getElementById("Product_productDemo");
		var DemoImage	= window.document.getElementById("Product_productDemoImage");
		var prodDiv		= window.document.getElementById("prodDiv");
		var newProdDiv	= window.document.getElementById("newProdDiv");
		var newProdImg	= window.document.getElementById("newProdImg");
		
		newProdDiv.style.display = 'none';
		
		
		if(image != null && image.length>2)
		{
		
			Image.style.display = 'block';
			prodDiv.style.display = 'block';
			Image.src = image;
		}
		else
		{
			if(Image != null)
				{
					Image.style.display = 'none';
				}
		}
		if(demo != null && demo.length>2 )
		{
			if(demoImage != null && demoImage.length>2)
			{
				prodDiv.style.display = 'block';
				Demo.href = demo;
				DemoImage.src = demoImage;
			}
			else
			{
			
				prodDiv.style.display = 'none';
			}
		}
		else
		{
			if(demoImage != null && demoImage.length>2)
			{
				prodDiv.style.display = 'none';
				newProdDiv.style.display = 'block';
				newProdImg.src = demoImage;	
			}
			else
			{
			
				prodDiv.style.display = 'none';
			}
			
		}
	
		
	}
	
	
	function marque_direction(direction){
	
		var marqee = window.document.getElementById("marqee");
		//marqee.style.cursor = 'hand';
		marqee.direction = direction;		
	}
	
	function border(obj,i){
	
		var td = window.document.getElementById(obj.id);
		td.style.border = (i == 1) ? "solid 3px #CCCCCC" : "solid 3px #FFFFFF";
	}



function hasInvalidChars(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (isInvalidChar(obj.charAt(i)))
			return true;
	}
	return false;
}


function hasInvalidChars2(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (isInvalidChar2(obj.charAt(i)))
			return true;
	}
	return false;
}


function hasInvalidChars3(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (isInvalidChar3(obj.charAt(i)))
			return true;
	}
	return false;
}

function isNotNumbers(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (!isNumber(obj.charAt(i)))
			return true;
	}
	return false;
}

function displayErorr(errMsg, focusControl) {
	alert(errMsg);
	focusControl.focus();
	return false;
} 

function displayErorr2(errMsg) {
	alert(errMsg);
	return false;
} 

var arrInvalidChars	= ["'", " "];
function isInvalidChar(obj) {
	for (var i = 0; i < arrInvalidChars.length; i++) {
		if (obj == arrInvalidChars[i])
			return true;
	}
	return false;
}

var arrInvalidChars2	= ["'","-"];
function isInvalidChar2(obj) {
	for (var i = 0; i < arrInvalidChars2.length; i++) {
		if (obj == arrInvalidChars2[i]) {						
			return true;
		}
	}
	return false;
}

var arrInvalidChars3	= ["'","-","&"];
function isInvalidChar3(obj) {
	for (var i = 0; i < arrInvalidChars2.length; i++) {
		if (obj == arrInvalidChars3[i]) {						
			return true;
		}
	}
	return false;
}


function isNumber(obj) {
	return (obj >= 0) && (obj <= 9);					
}

function isNotGoodLength(obj) {
	return (obj.length < 2) || (obj.length > 8);
}

function isMin2Length(obj) {
	return (obj.length < 2);
}

function isNotNullOrEmpty(obj) {
	return (obj != null) && (obj != "");
}	

var arrNotValidEMailChars = ["/",":",";"," ","^","$","(",")","[","]","{","}","+","=","|","\\","*","~","`","'","#","!",",","?"];
function isValidEmail(strValue)
{
	var strValue = new String (strValue);
	
	// check if '@' is exist
	arrValue = strValue.split("@");
		
	if (arrValue.length != 2)
	{
		return false;
	}
	
	var strLeftSection = arrValue[0];
	var strRightSection = arrValue[1];
	
	if (strLeftSection == "")
	{
		return false;
	}	
			
	if (strRightSection == "")
	{
		return false;	
	}
	
	// check if there is one dot or two dots in the second section
	arrRightSection = strRightSection.split(".");
	if (arrRightSection.length != 2 && arrRightSection.length != 3)
	{
		return false;	
	}	
			
	// check there 	are no two dots one beside other
	for (var i=0 ; i<arrRightSection.length ; i++)
	{
		if (arrRightSection[i] == "")
		{
			return false;
		}
	}
	
	// check all chars are valid
	for (var i=0 ; i<arrNotValidEMailChars.length ; i++)
	{
		if (strValue.indexOf(arrNotValidEMailChars[i]) > -1)
		{
			return false;
		}
	}		
	
	if (strValue.indexOf('"') > -1)
	{
		return false;
	}
	
	for (var i=0 ; i<strValue.length ; i++)
	{
		// 1488 = 'à', 1514 = 'ú', 
		
		var ch = strValue.charAt(i);
		if (ch.charCodeAt(0) >= 1488 && ch.charCodeAt(0) <= 1514)
		{
			return false
		}
	}
	
	return true;	
}

//Open popup centerized.
function openDownloadDetails(url) {
	var w, h;
		
	var winW = 335;
	var winH = 340;
	
	w = screen.availWidth;
	h = screen.availHeight;


	var leftPos	= (w-winW)/2;
	var topPos	= (h-winH)/2;
	
	window.open(url, "Download", "toolbar=0, status=0, resizable=0, top=" + topPos + ", left=" + leftPos + ", width=" + winW + ", height=" + winH + "");
}


var arrAllowedExtentions = [".doc", ".txt"];
function isAllowedExtenstion(fileName) {
	var indexOfExt = fileName.lastIndexOf(".");
	var fileExt = fileName.substring(indexOfExt);
	
	for (var i = 0; i < arrAllowedExtentions.length; i++) {
		if (fileExt.toLowerCase() == arrAllowedExtentions[i])
			return true;
	}
	
	return false;
}

function initUpload (path, host){
	var url= "http://"+host+path;	
	document.location = url;
	setTimeout("self.close();", 10000);
}