
//******************************************
function checkForm(){
	FunForm('user_request');
}

//******************************************
function seccessMessege(msg){
		document.all['seccessMessege'].innerHTML=msg;
		document.all['seccess'].style.top=window.screen.height/2-160;
		document.all['seccess'].style.left=window.screen.width/2-125;
		document.all['seccess'].style.display="";
		window.focus();
	}
//*****************************************************	
function closeSeccess(){
		document.all['seccess'].style.display="none";
		document.all['seccessMessege'].innerHTML="";
		document.all['seccess'].style.top=0;
		document.all['seccess'].style.left=0;
		window.location="/site/he/homepage.asp"

}

//******************************************
function FunForm(formName){
	var myForm	= document.all[formName]
	var sUrl	= "/site/templates/contact/user_request.xx.asp?lang=he"
	for(var i=0;i<myForm.length;i++){
		if(myForm.item(i).name == "email" && myForm.item(i).value !="" ){
			if(checkEmail(myForm.item(i).value)!=true){
				alert(checkEmail(myForm.item(i).value));
				myForm.item(i).focus();
				return;
			}
		}
	
		/*
		else if(myForm.item(i).value != "" && myForm.item(i).name == "telephone"){
			var strVal=myForm.item(i).value;
			if(isNaN(strVal)){
				alert(myForm.item(i).trueName +" "+ "לא תקין")
				myForm.item(i).focus();
				return ;
			}
		}
		*/
		else if(myForm.item(i).value == ""  && myForm.item(i).name !="telephone" && myForm.item(i).name !="telephonecell"){
			alert("נא מלא "+myForm.item(i).trueName)
			myForm.item(i).focus();
			return;
		}
	}

	var xmlDom	= new ActiveXObject("Microsoft.XMLDOM");
	var root	= xmlDom.createElement("root");
	xmlDom.documentElement = root;
	
	
	var doc = xmlDom.createElement("doc");
	var xmlElem	= root.appendChild(doc);
	doc.setAttribute('category',node_pi);
	
	for (var i = 0;i<user_request.length;i++){
		xmlElem=xmlDom.createElement(user_request(i).name);
		xmlElem.text=user_request(i).value;
		doc.appendChild(xmlElem);	
	}
	
	//alert(doc.xml)

	var form = xmlDom.createElement("form");
	var xmlElem	= root.appendChild(form);
	
	for (var i = 0;i<user_request.length;i++){	
		xmlElem=xmlDom.createElement(user_request(i).name);
		xmlElem.text=myForm.item(i).trueName;
		form.appendChild(xmlElem);	
	}
	
	//alert(form.xml)
	
	try {
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.Open("POST", sUrl, false);		
		xmlhttp.Send(xmlDom.xml);
		
		//alert(xmlhttp.responseTEXT)
		try{
			/*var error=xmlhttp.responseXML.documentElement.getAttribute("error")
			var id=xmlhttp.responseXML.documentElement.getAttribute("id")
			if(error!='')
				alert(error+':'+'שגיאה בשליחה')
			else*/
				seccessMessege(" תודה על פניתך. <br> פניתך נרשמה במערכת נציגינו יטפלו בפניתך")
		}
		catch(e){
			//alert("פניתך לא נקלטה אנא נסה שוב")
		}
	}
	catch (e) {
		alert("פניתך לא נקלטה אנא נסה שוב")
		return;
	}

}



function xml_replace(str){return(String(str).replace("<","&lt;"))}
//******************************************