	function sendForm(){
	
		var flag = true, sFname, sLname, sEmail, rExp, eExp,minPrice;
		sQuestion = document.getElementById("question").value;
		
		minPrice = document.getElementById("MinPrice").value*1;
		
		var mprice = document.getElementById("mPrice").value*1;
		var rExp =  new RegExp(/^(\s*)$/);
		var eExp=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
		if(isNaN(mprice))
		{
			alert("נא הלהקליד שדה מספרי שלם");
			return false;
		}
		else
		{
			if(mprice < minPrice)
				{alert("ניתן לרשום סכום השווה או גבוה מ - "+minPrice+" ש''ח");document.getElementById("mPrice").select();return false;}
			else
			{
				if(Math.round(mprice) != mprice)
				{
					alert("נא להקליד מספר שלם");
					document.getElementById("mPrice").value=Math.ceil(mprice);
				}
				if(document.getElementById("kolcredit").value-document.getElementById("mPrice").value < 0){
					alert("היתרה שלך אינה מספיקה\r\n אנא טען את כרטיס המנוי שלך\r\nיתרתך הנוכחית היא "+document.getElementById("kolcredit").value+" ש''ח");
					document.getElementById("tokolcard").style.display = "block";
					return false;
				}
			}
		}
		ret=false;
		for(i=0; i<document.questionform.rdLevel.length; i++)
		{
			if(document.questionform.rdLevel[i].checked)
				ret=true;
		}
		if(!ret)
		{
			alert("בבקשה בחר/י את רמת התשובה");
			return false;
		}
		if(rExp.test(sQuestion))
		{
			alert("נא למלא שדות חובה שאלה/מידע")		
		}
		else
		{
			newWin=window.open('popup2.html',"popup","status=no,location=no,toolbar=no,width=360,height=330,scrollbars=no")
			document.questionform.submit()
			//return true;
		}	
		return false;
	}



function clsForm(varForm){

var errMessage=[];
    errMessage[0] = "שכחת למלא שדה חובה";
    errMessage[1] = "יש למלא שם משפחה";
    errMessage[2] = "יש למלא כתובת דוא\"ל";
    errMessage[3] = "יש למלא שאלה";


var currentField;
this.validator=true;
this.form = varForm;
this.checkFields = checkFields;
this.checkZero = checkZero;
this.checkMail = checkMail;
this.errHandler = errHandler;


		function checkFields()

			{
				
				for(var i=0;i<=this.form.elements.length-1;i++)
					{
						
						currentField=this.form.elements[i];
						if(this.validator)
							{
								
								
								switch (this.form.elements[i].id)
										{
	
											case "R":
											
												this.validator=checkZero(this.form.elements[i].value)
												break ;
												
											
											
											


											case "Email":
												
												this.validator=checkMail(this.form.elements[i].value)
												break ;




										}
							
									
								
							
							
							
							
							}			
						else

							{
								return 	this.validator

							}



					}


			return this.validator

			}





	function checkZero(varValue, errCode){
		
		if(varValue.length==0)
			{
				errHandler(0);return false;
			
			
			
			
			
			}
		else{return true;}
		

		


	}


	function checkMail(varEmail){
		
		var a = varEmail;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if(!filter.test(a)){errHandler(2);return false;}
		else{return true;}


	}


	function errHandler(varErrCode){
		var strP
		
			for(var i=0;i<=varForm.elements.length-1;i++)
				{
					if(varForm.elements[i].type=="text" || varForm.elements[i].type=="textarea")
					{
						varForm.elements[i].style.background="white"
						
					}	

				}
		
		currentField.style.background="lightyellow"

		currentField.focus()
		alert(errMessage[varErrCode])


	}






}


function checkForm(){


var objForm = new clsForm(document.getElementById("toValidate"))



return(objForm.checkFields())


}




function sendForm2(){
	
		var flag = true, sFname, sLname, sEmail, rExp, eExp,minPrice;
		sQuestion = document.getElementById("question").value;
		
		minPrice = document.getElementById("MinPrice").value*1;
		
		var mprice = document.getElementById("mPrice").value*1;
		var rExp =  new RegExp(/^(\s*)$/);
		var eExp=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
		if(isNaN(mprice))
		{
			alert("נא הלהקליד שדה מספרי שלם");
			return false;
		}
		else
		{
			if(mprice < minPrice || mprice="0")
				{alert("ניתן לרשום סכום השווה או גבוה מ - "+minPrice+" ש''ח");document.getElementById("mPrice").select();return false;}
			else
			{
				if(Math.round(mprice) != mprice)
				{
					alert("נא להקליד מספר שלם");
					document.getElementById("mPrice").value=Math.ceil(mprice);
				}
				if(document.getElementById("kolcredit").value-document.getElementById("mPrice").value < 0){
					alert("היתרה שלך אינה מספיקה\r\n אנא טען את כרטיס המנוי שלך\r\nיתרתך הנוכחית היא "+document.getElementById("kolcredit").value+" ש''ח");
					document.getElementById("tokolcard").style.display = "block";
					return false;
				}
			}
		}
		ret=false;
		
		if(rExp.test(sQuestion))
		{
			alert("נא למלא שדות חובה שאלה/מידע")		
		}
		else
		{
			newWin=window.open('popup2.html',"popup","status=no,location=no,toolbar=no,width=360,height=330,scrollbars=no")
			document.questionform.submit()
			//return true;
		}	
		return false;
	}




