﻿var bigPic="";
var ProductName="";
var tempArea="0";
var tempDisID="0";

function writeHTML(html)
{
	document.write(html);
}
function GoTo(obj)
{

if (obj.value=="" || obj.id == "List11")
return;
Target="17.html#" //FAQ

if (obj.id=="List5" || obj.id=="List6")
{

    var area="02"    
    switch (obj.value)
	{	 
	case "141":				
	area="04"
	break;
	case "143":				
	case "148":				
	area="09"
	break;
	case "146":				
	area="03"
	break;		
	case "149":				
	area="08"	
	break;
	}    
    Target="64.html?Area="+ area +"&id="
    
 }
 if (obj.id=="List0")    
 Target="";
	if(obj.value)
    {
        	document.location.href=Target+obj.value;
	}
        else
 
          document.location.href=Target;
}

function changecity(cityID,path)
{
var checks="";
if(cityID.length==0)
{
alert("Please, choose city")
return;
}
for(i=0; i<document.forms[0].elements.length; i++)
{
if(document.forms[0].elements[i].name=="ServSearch")
	if(document.forms[0].elements[i].checked)
	checks=checks+","+document.forms[0].elements[i].value
}

if(checks.length>0)
	checks=checks.substring(1)

document.location.href=path+ "?City="+cityID+"&checks="+checks;
}
function resetData(form)
{

	
	for(i=0; i<form.elements.length; i++)
	{
		if (form.elements[i].type=="text")
			form.elements[i].value="";
	}
	
	
}



var gCurrId = "";
function FAQ_Display(MessageID)
{
    var id = MessageID.substr(6,MessageID.length-6);
 
    var div = document.getElementById("AllTextAnswer" + id);

    var img = document.getElementById("Answer" + id);
            
    div.style.display = "";
    img.src = "res/FAQ_Minus.gif";
	    
	if(gCurrId != "")
	{
	    var currDiv = document.getElementById("AllTextAnswer" + gCurrId);
	    var currImg = document.getElementById("Answer" + gCurrId);
	    
	    currDiv.style.display = "none";
	    currImg.src = "res/FAQ_Plus.gif"
	}	
	
	if(gCurrId == id)
	    gCurrId = "";
	else
	    gCurrId = id;
}


//Find Distributor==============================================================================================================================================
var ContNAmerica = 3342;
var ContSAmerica = 3355;
var ContCAmerica = 3354;
var ContEurope = 3340;
var ContAsia = 3341;
var ContAfrica = 3356;
var ContAustralia = 3357;
var objID;
//Start to build new div
function hideCountriesList(e)
{
var ev
var tObj 
if (window.event) 
{
    tObj = event.srcElement.tagName;
}
else 
{
    tObj = e.target.tagName;
}


	//var tObj = event.srcElement.tagName;
	
	if ((tObj != "TABLE") && (tObj != "TBODY") && (tObj != "TR") && (tObj != "TD") && (tObj != "A")&& (tObj != "AREA"))
	{
	
		if (document.getElementById(objID) != null)
		{

			document.getElementById(objID).style.visibility = "hidden";
		}
	}
}
function showCountriesList(xPos,yPos,id)
{

	objID = "t" + id;
	var obj = document.getElementById("t" + objID ); 
	if (obj != null)
	{

		document.getElementById(objID ).style.visibility = "hidden"; 
	}
	
	obj = document.getElementById("t" + ContAfrica);

	if (obj != null)
	{

		document.getElementById("t" + ContAfrica).style.visibility = "hidden"; 
	}
	obj = document.getElementById("t" + ContAsia);
	if (obj != null)
	{
		document.getElementById("t" + ContAsia).style.visibility = "hidden"; 
	}
	obj = document.getElementById("t" + ContAustralia);
	if (obj != null)
	{
		document.getElementById("t" + ContAustralia).style.visibility = "hidden"; 
	}
	obj = document.getElementById("t" + ContCAmerica);
	if (obj != null)
	{
		document.getElementById("t" + ContCAmerica).style.visibility = "hidden"; 
	}
	obj = document.getElementById("t" + ContEurope);
	if (obj != null)
	{
		document.getElementById("t" + ContEurope).style.visibility = "hidden"; 
	}
	obj = document.getElementById("t" + ContNAmerica);
	if (obj != null)
	{
		document.getElementById("t" + ContNAmerica).style.visibility = "hidden"; 
	}
	obj = document.getElementById("t" + ContSAmerica);
	if (obj != null)
	{
		document.getElementById("t" + ContSAmerica).style.visibility = "hidden"; 
	}

	obj = document.getElementById("t" + id);
	if (obj != null)
	{
		var x = document.getElementById("WorldMap").offsetLeft + document.getElementById("WorldMap").parentNode.parentNode.parentNode.parentNode.offsetLeft;
		var y = document.getElementById("WorldMap").offsetTop + document.getElementById("WorldMap").parentNode.parentNode.parentNode.parentNode.offsetTop;
		document.getElementById("t" + id).style.left = x + xPos;
		document.getElementById("t" + id).style.top = y + yPos;
		document.getElementById("t" + id).style.visibility = "visible";
		return;
	}
}

function TableOut(tblObj)
{
	if (event.srcElement.tagName == "TABLE")
	{
		tblObj.style.visibility = "hidden";
	}
}

function GetId(parentId,CatID)
{
	
	
	if (document.getElementById("dataControl_cmb_Search").selectedIndex != 0)
	{
		document.location.href = "EngInner.aspx?itemid=" + parentId + "&countryid=" + document.getElementById("dataControl_cmb_Search").value + "&countryname=" + document.getElementById("dataControl_cmb_Search").options[document.getElementById("dataControl_cmb_Search").selectedIndex].text;
	}
}
/*if (window.attachEvent) 
{
window.document.attachEvent("onmousemove",hideCountriesList);
}
else
{
window.addEventListener("onmousemove",hideCountriesList,false);
}*/

document.onmousemove=hideCountriesList;




function SelectCase(objId)
{

	switch (objId.id)
	{	 
	case "List11":		
	var obj = document.getElementById("CountrySel");
	obj.value=objId.value;	
	break;
	}
	
		
}


function CountryTarget(page)
{
var obj = document.getElementById("CountrySel");
if (obj.value!="")
parent.window.location.href=page+".html?&countryid=" + obj.value;		

}

function OpenBigPic(picPath,lan,id,theProductName)
{
	
	bigPic=picPath;
	ProductName=theProductName;
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 310;
	wTop = (window.screen.height/2) - 260;
	if (lan=="True")
	temp="234.html?munuroot=" + id
	else
	temp="236.html?munuroot=" + id		
	var w = window.open(temp,"","top=" + wTop + ",left=" + wLeft + ",width=638,height=520,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
	

}

function PrintDis(id)
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 310;
	wTop = (window.screen.height/2) - 260;	
	var Pagex="1870.html"	
	tempDisID=id;	
	var w = window.open(Pagex,"","top=" + wTop + ",left=" + wLeft + ",width=600,height=520,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
	

}
function PrintDiller(id)
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 310;
	wTop = (window.screen.height/2) - 260;	
	var Pagex="4633.html"	
	tempDisID=id;	
	var w = window.open(Pagex,"","top=" + wTop + ",left=" + wLeft + ",width=600,height=520,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
	

}


function DisplayContent(id,Action)
{
	
	var eltidShow = document.getElementById("showData"+id);			 
	
	var eltid = document.getElementById("DisData"+id);	
	if (!eltid)
	    return;
	if (eltid.style.display=="")		
	{
	eltid.style.display="none";
	if(eltidShow)
	    eltidShow.style.display="";
	}
	else
	{
	eltid.style.display="";
	if(eltidShow)
	    eltidShow.style.display="none";
	}


}

function validateFormCode()
{
var inputCode = document.getElementById("textcode");	
if (inputCode)
{
	if (inputCode.value=="")	
	alert(inputCode.getAttribute("validationError")) 	
return inputCode.value

}
return "";	
}


function validateForm(form, title, submit)
{
	var i, j, u, sum;
	var input;
	var valid;
	var sErrorMsg = "";

	for (i=0; i<form.elements.length; i++)
	{
		input = form.elements[i];
		// skip input when it's not rendered (ie. parent display:none)
		if (input.offsetHeight == 0) continue;
		valid = true;

		// Validate value according to element type and validation type
		switch (input.type.toLowerCase())
		{
		case "text":
		case "password":
		case "textarea":
		case "file":
			if (!input.getAttribute("validation"))
				input.setAttribute("validation", "string");
			if (input.getAttribute("mandatory"))
			{
				if (input.getAttribute("mandatory").toLowerCase() != "true" && input.value.length == 0)
					continue;
			}
			else
				if (input.value.length == 0)
					continue;
			switch (input.getAttribute("validation").toLowerCase())
			{
			case "string":
			case "password":
				if (input.value.length == 0)
					valid = false;
				break;
			case "integer":
				if (!/\d+/.test(input.value))
					valid = false;
				break;
			case "email":
				if (!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(input.value))
					valid = false;
				break;
			case "phone":
				if (!/^\+?\d+(-\d+)*$/.test(input.value))
					valid = false;
				break;
			case "id":
				j = input.value.toString();
				input.value = j.replace(/\D/g, "");
				if (/\d+/.test(input.value))
				{
					sum = 0;
					for (j=0; j<input.value.length; j++)
					{
						u = (j % 2 ? 2 : 1) * parseInt(input.value.charAt(input.value.length - j - 1));
						sum += u > 9 ? Math.floor(u / 10) + u % 10 : u;
					}
					if (sum % 10) valid = false;
				}
				else
					valid = false;
				break;
			case "compare":
				// Check the compareInput attribute
				if (input.getAttribute("compareInput"))
					if (input.value != form.elements[input.getAttribute("compareInput")].value)
						valid = false;
				break;
			default:
				var regExp = new RegExp(input.getAttribute("validation"), "im");
				valid = regExp.test(input.value);
			}

			// Validate max and min according to validation type
			if (valid == true)
			{
				switch (input.getAttribute("validation").toLowerCase())
				{
				case "integer":
					if (input.getAttribute("validmax"))
					{
						if (parseInt(input.value) > parseInt(input.getAttribute("validmax")))
							valid = false;
					}
					if (input.getAttribute("validmin"))
					{
						if (parseInt(input.value) < parseInt(input.getAttribute("validmin")))
							valid = false;
					}
					break;
				default:
					if (input.getAttribute("validmax"))
					{
						if (input.value.length > input.getAttribute("validmax")) valid = false;
					}
					if (input.getAttribute("validmin"))
					{
						if (input.value.length < input.getAttribute("validmin")) valid = false;
					}
					break;
				}
			}
			break;
		case "select-one":
			if (input.getAttribute("mandatory"))
				if (input.selectedIndex == 0)
					valid = false;
			break;
		case "select-multiple":
			if (input.getAttribute("mandatory"))
			{
				sum = 0;
				for (j=0; j<input.options.length; j++)
				{
					if (input.options[j].selected) sum++;
				}
				if ((!input.getAttribute("validmax")) && (!input.getAttribute("validmin")))
				{
					if (sum == 0) valid = false;
				}
				else
				{
					if (input.getAttribute("validmax"))
					{
						if (sum > input.getAttribute("validmax")) valid = false;
					}
					if (input.getAttribute("validmin"))
					{
						if (sum < input.getAttribute("validmin")) valid = false;
					}
				}
			}
			break;
		case "checkbox":
			if (input.getAttribute("mandatory"))
				valid = input.checked;
			break;
		}

		if (!valid)
		{
			if (input.getAttribute("validationError"))
				sErrorMsg += input.getAttribute("validationError") + "\n";
			else
				sErrorMsg += "Error in field " + input.name + "\n";
		}
	}
	if (sErrorMsg.length)
	{
		alert((title ? title + "\n" : "") + sErrorMsg);
		return false;
	}
	else
	{
		if (submit)
			form.submit();
		return true;
	}
}

function checkformLogin(form)
{
var empty=0;
for (i=0; i<form.elements.length; i++)
	{
		input = form.elements[i];								
		    if (input.value.length == 0 && input.title!="")		
		    {		    
		    alert("Please Fill in " + input.title)
		    return false;	
		    }
		    else
		    {
		    if(input.title=="E-mail")
				if (!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(input.value))
				{
				alert("Envalid E-mail address")
		            return false;	
					
			}
		    }
		    
		}		
	
	return true;
}

function checkformPassword(form)
{
if (form.txtNewPassword.value!=form.txtNewPasswordagain.value)
{
    alert("Reentered new password does  not match new password")	
    return false;
}
var empty=0;
for (i=0; i<form.elements.length; i++)
	{
		input = form.elements[i];								
		    if (input.value.length == 0 && input.title!="")		
		    {		    
		    alert("Please enter " + input.title)
		    return false;	
		    }
		    else
		    {
		            if(input.title=="E-mail")
		            {
				        if (!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(input.value))
				        {
				            alert("Envalid E-mail address")
		                    return false;						
			            }
			        }
			         if(input.type=="password")
			         {
			       
				     if (input.value.length<6)
				     {
				        alert("Password must be at least 6 charachters ")
		                return false;						
			         } 			    
		            }		    
		    }		
}
	
	return true;
}






function checkform(obj)
{

//debugger;
if (event.keyCode==13 && obj.value.length>0)
    return true;
return false;    
 //if (event.keyCode == 13 && document.getElementById('searchquery').value.length>0)
}
