function chek_forget_form(f){
	document.getElementById("forget_div").innerHTML="";
	if(f.sname.value<1){
		document.getElementById("forget_div").innerHTML="<?=SNAME?>";
		f.sname.focus();
		return false;
	}
	if(!check_email(f.smail.value)){
		document.getElementById("forget_div").innerHTML="<?=SEMAIL?>";
		f.smail.focus();
		return false;
	}
if(f.fname.value<1){
		document.getElementById("forget_div").innerHTML="<?=FNAME?>";
		f.fname.focus();
		return false;
	}
	if(!check_email(f.fmail.value)){
		document.getElementById("forget_div").innerHTML="<?=FEMAIL?>";
		f.fmail.focus();
		return false;
	}
} 
  function checkforget(){
	document.getElementById("forget_table").style.display="";
document.getElementById('forget_table').style.left=eval(document.getElementById('sendtofriend').offsetLeft-90)+"px";
	document.getElementById('forget_table').style.top=eval(document.getElementById('sendtofriend').offsetTop+30)+"px"; 
}
function exite(){
	document.getElementById("forget_table").style.display="none";
}
 

// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e)
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0)
		{
			return (false);
		}
	} 
	
	if(document.images)
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if(!e.match(re) && e.match(re_two))
		{
			return (-1);
		}
	}
}

function poll(ttid,num,f,div_ajax)
{
	var rad_val=0;
	for (var i=0; i < f.radiobutton.length; i++)
	{
		if (f.radiobutton[i].checked)
		{
			rad_val = f.radiobutton[i].value;
		
		}
	}
	if(rad_val==0)
	{
		alert('please select answer!'); 
	}
	else
	{
		var getstr = "?ttid=1&num="+num+"&radio="+rad_val; 
		run_ajax('poll_ajax.php',getstr,div_ajax,1);
		// makeRequest2('poll_ajax.php', getstr,7);
	}
	return false;
}

function check_email(e)
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0)
		{
			return (false);
		}
	}
	if(document.images)
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two))
		{
			return (-1);
		}
	}
}
function check_ensure(f)
{
	if(!f.model.value)
	{
		alert("يرجى ادخال الهاتف");
		f.model.focus();
		return false;
	}
	if(!check_email(f.price.value))
	{
		alert("يرجى التأكد من الايميل");
		f.price.focus();
		return false;
	}
	alert(f.id.value);
	run_ajax("add_ensure.php","?phone="+f.model.value+"&email="+f.price.value+"&id="+f.id.value,"divs",1);
	return false;
}

function mask(f)
{ 
	tel='';
	var val =f.value.split(''); 

	for(var i=0;i<val.length;i++)
	{
		if(val[i]!='1'&&val[i]!='2'&&val[i]!='3'&&val[i]!='4'&&val[i]!='5'&&val[i]!='6'&&val[i]!='7'&&val[i]!='8'&&val[i]!='9'&&val[i]!='0')
		{
			val[i]='';
		}

		tel=tel+val[i];
	}
	
	f.value=tel;
}

function clicked(box)
{
	if(box.checked)
	{
		document.getElementById('register').disabled=false;
	}
	else
	{
		document.getElementById('register').disabled=true;
	}
}
function register_check(f)
{
	if(!f.username.value)
	{
		alert("يرجى ادخال الاسم");
		f.username.focus();
		return false;
	}
	if(!f.password.value)
	{
		alert("يرجى ادخال كلمة السر");
		f.password.focus();
		return false;
	}
	if(!f.confirmPassword.value)
	{
		alert("يرجى اعادة ادخال كلمة السر");
		f.confirmPassword.focus();
		return false;
	}
	if(f.password.value!=f.confirmPassword.value)
	{
		alert("كلمة السر يجب أن تكون متطابقة");
		f.confirmPassword.focus();
		return false;
	}
	if(!check_email(f.email.value))
	{
		alert("يرجى التأكد من الإيميل");
		f.email.focus();
		return false;
	}
	if(!check_email(f.confirmEmail.value))
	{
		alert("يرجى التأكد من اعادة الإيميل");
		f.confirmEmail.focus();
		return false;
	}
	if(f.email.value!=f.confirmEmail.value)
	{
		alert("كلمة السر يجب أن تكون متطابقة");
		f.confirmEmail.focus();
		return false;
	}
	if(!f.year.value)
	{
		alert("يرجى التاكد من التاريخ");
		f.year.focus();
		return false;
	}
	if(!f.ct_captcha.value)
	{
		alert("يرجى ادخال الرموز الوجودة بالصورة");
		f.ct_captcha.focus();
		return false;
	}
	else
	{
		run_ajax("check_validation.php","?ct_captcha="+f.ct_captcha.value,f,6);
		return false;
	}
	return false;
}
function show_custom_search()
{
	$("#custom_search").slideToggle(200);
	return false;
}
function SubCity(option)
{
	if(option == 2)
	{
		document.getElementById('subCityDiv').innerHTML = '<select id="subCity" name="subCity"><option value="1">محافظة الشمال</option><option value="2">محافظة غزة</option><option value="3">محافظة الوسطى</option><option value="4">محافظة خانيونس</option><option value="5">محافظة رفح</option></select>';
	}
	else
	{
		if(option == 1)
		{
			document.getElementById('subCityDiv').innerHTML = '<select id="subCity" name="subCity"><option value="1">محافظة جنين</option><option value="2">محافظة طوباس</option><option value="3">محافظة طولكرم</option><option value="4">محافظة نابلس</option><option value="5">محافظة قلقيلية</option><option value="6">محافظة سلفيت</option><option value="7">محافظة رام الله والبيرة</option><option value="8">محافظة أريحا</option><option value="9">محافظة بيت لحم</option><option value="10">محافظة القدس</option><option value="11">محافظة الخليل</option></select>';
		}
		else
		{
			document.getElementById('subCityDiv').innerHTML = '';
		}
	}
}
function findall(f)
{
	try
	{
		var subCity=f.subCity.value;
	}
	catch(e)
	{
		
	}
	try
	{
		var dates=f.date.value;
	}
	catch(e)
	{
		
	}
	if(f.city.value==0)
	{
		var subCity=0;
	}
	run_ajax("show_search_result.php?",'name='+f.name.value+'&age='+f.age.value+'&gender='+f.gender.value+'&city='+f.city.value+'&subCity='+subCity+'&presion='+f.presion.value+'&rule='+f.rule.value+'&study='+f.study.value+'&status='+f.status.value+'&date='+dates+'&arrest_count='+f.arrest_count.value+'&address='+f.address.value,"search_result",1);
}

function check_email(e)
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0)
		{
			return (false);
		}
	}
	if(document.images)
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two))
		{
			return (-1);
		}
	}
}

function search1(f)
{
	location.replace("index.php?inid=13&lookfor="+encodeURIComponent(f.lookfor.value));
}

function insert(f)
{
	if(!f.name.value)
	{
		alert("يرجى ادخال الاسم");
		f.name.focus();
		return false;
	}
	if(!f.country.value)
	{
		alert("يرجى ادخال البلد");
		f.country.focus();
		return false;
	}
	if(!f.gender.value)
	{
		alert("يرجى ادخال الجنس");
		f.gender.focus();
		return false;
	}
	if(!check_email(f.email.value))
	{
		alert("يرجى التحقق من الايميل");
		f.email.focus();
		return false;
	}
	if(!f.typeconsultation.value)
	{
		alert("يرجى ادخال نوع الاستشارة");
		f.typeconsultation.focus();
		return false;
	}
	if(!f.title.value)
	{
		alert("يرجى ادخال عنوان الاستشارة");
		f.title.focus();
		return false;
	}
	if(!f.content.value)
	{
		alert("يرجى ادخال نص الاستشارة");
		f.content.focus();
		return false;
	}
	run_ajax('insert.php',"?name="+f.name.value+"&country="+f.country.value+"&gender="+f.gender.value+"&email="+f.email.value+"&phone="+f.phone.value+"&typeconsultation="+f.typeconsultation.value+"&title="+f.title.value+"&content="+f.content.value,'divs',1);
	//location.replace("index.php?inid=3");
	return false;
}


function ensure(f)
{
	if(!f.name.value)
	{
		alert("يرجى ادخال الاسم");
		f.name.focus();
		return false;
	}
	if(!f.country.value)
	{
		alert("يرجى ادخال البلد");
		f.country.focus();
		return false;
	}
	if(!check_email(f.email.value))
	{
		alert("يرجى التحقق من الايميل");
		f.email.focus();
		return false;
	}
	if(!f.participate.value)
	{
		alert("يرجى ادخال عنوان المشاركة");
		f.participate.focus();
		return false;
	}
	run_ajax("add_ensure.php","?name="+f.name.value+"&country="+f.country.value+"&email="+f.email.value+"&phone="+f.phone.value+"&participate="+f.participate.value+"&help="+f.help.value+"&inquiry="+f.inquiry.value,"divs",1);
	//location.replace("index.php?inid=3");
	return false;
}

function test1(element)
{
	$('#high').show();
	$('#full_div').show();
}

function test2(element)
{
	$('#high').hide();
	$('#full_div').hide();
}

function photo_comment()
{
	$('html, body').animate({scrollTop: 425}, 1500);
	setTimeout("test1();",1500);
}

function check_solidarity(f)
{
	document.getElementById("divs1").innerHTML="";
	if(f.name.value.length < 1)
	{
		document.getElementById("divs1").innerHTML="يرجى ادخال الاسم";
		f.name.focus(); 
		return false;
	}
	if(!check_email(f.email.value))
	{
		document.getElementById("divs1").innerHTML="يرجى التأكد من الإيميل"
		f.email.focus(); 
		return false;
	}
	if(f.ar.value.length < 1)
	{
		document.getElementById("divs1").innerHTML="يرجى إدخال العنوان"
		f.ar.focus(); 
		return false;
	}
	if(f.ar_des.value.length < 1)
	{
		document.getElementById("divs1").innerHTML="يرجى إدخال الشرح"
		f.ar_des.focus(); 
		return false;
	}
	run_ajax("add_solidarity.php?","name="+f.name.value+"&email="+f.email.value+"&ar="+f.ar.value+"&ar_des="+f.ar_des.value+"&pid="+f.pid.value,"divs1",1);
	return false;
}
function  check_titl(f,span,lenstr)
{
	var v=f.value;
	var ln=f.value.length; 	
	if(ln>lenstr)
	{	
		f.value= v.substr(0,lenstr)
		ln=lenstr;
	}
	document.getElementById(span).innerHTML=lenstr-ln+' محرف';
}
