//----------------------------------------------------------
function clearf(object,text){
 if (object.value == text) {
  object.value = "";  object.focus();
  }
}
//----------------------------------------------------------
function setf(object,text){
 if(object.value == "") {
  object.value =
  text;  this.focus();
 }
}
//-------------------------------------------------------------
function sendRequest(){
country_id=aqar_form.country_id.options[aqar_form.country_id.selectedIndex].value
send_val="country_id="+country_id;
var url="ajax_get.php?get_action=add_cities&"+send_val;
xmlHttp.open("POST",url,true);
document.getElementById("ajax_get").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("ajax_get").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
//---------------------------------------------
function get_city_forguestbook(){
country_id=share_form.country_id.options[share_form.country_id.selectedIndex].value
send_val="country_id="+country_id;
var url="ajax_get.php?get_action=add_cities&"+send_val;
xmlHttp.open("POST",url,true);
document.getElementById("guestbook_div").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("guestbook_div").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
//-----------------------------------------------------------------
function get_aqar_details(aqar_id,num_divs,div_id){
send_val="aqar_id="+aqar_id;
var url="ajax_get.php?get_action=get_aqar_details&"+send_val;
xmlHttp.open("POST",url,true);
ajax_get_id="ajax_get"+div_id;
document.getElementById(ajax_get_id).innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById(ajax_get_id).innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
//-----------------------------------------------------------------
function addtomarq(act){
var url="ajax_get.php?get_action="+act;
xmlHttp.open("POST",url,true);
document.getElementById("ajax_marquee").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("ajax_marquee").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
//------------------------------------------------------------------
function art_news_marq(act){
var url="ajax_get.php?get_action="+act;
xmlHttp.open("POST",url,true);
document.getElementById("ajax_marquee_2").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("ajax_marquee_2").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
//-----------------------------------------------------------------
//show video , map of aqar
function det_aqar(aqar_id,req){
var url="ajax_get.php?get_action=put_in_details&aqar_id="+aqar_id+"&req="+req;
xmlHttp.open("POST",url,true);
document.getElementById("div_det_aqar").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("div_det_aqar").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}

//------------------------------------------------------------------
//------------------------------------------------------------------
function fx_init(img){
	if(img && img.filters && img.filters[0]){
		img.filters[0].apply();
		img.filters[0].play();
	}
}
function fx_over(img){
	if(img && img.filters && img.filters[0]){
		img.filters[0].apply();
		img.filters[0].play();
	}
}
function high(img){
	if(img && img.filters && img.filters.alpha){
		img.filters.alpha.opacity=60;
		if (window.highlighting)
			clearInterval(highlighting);
	}
}

function low(img){
	if(img.filters){
		tmp = img;
		highlighting=setInterval("chlight(tmp)",50)
	}
}
function chlight(img){
	if(img.filters && img.filters.alpha){

		if (img.filters.alpha.opacity<100){
			img.filters.alpha.opacity+=4;
		}else{
			if (window.highlighting)
				clearInterval(highlighting);
		}
	}
}
// EOF
//----------------------------------------------------
function is_valid_conflict_send()
{
if (send_conflict_form.sender_name.value=="" )
 {
 alert(" أكمل البيانات المطلوبة ");
 return false;
 }
else
 {
    if( document.send_conflict_form.random.value== document.send_conflict_form.new_string.value)
     {
   	   send_conflict_form.submit();
       return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
 }
}
//----------------------------------------------------------
function is_valid_share(){

 if(document.share_form.name.value==""   )
  {
     alert(" أكمل الببانات المطلوبة");return false;
  }
 else
  {

  if( document.share_form.random.value== document.share_form.new_string.value)
     {
   	     document.share_form.submit();return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
}
//----------------------------------------
function open_page(new_url)
{
LeftPosition = (screen.width) ? (screen.width-750)/2 : 0;
TopPosition = (screen.height) ? (screen.height-600)/2 : 0;
settings="status=0,toolbar=0,width=750,height= 600 , top="+TopPosition+", left="+LeftPosition+", scrollbars=yes resizeable=no";
window.open (new_url,"search_result",settings);
}
//-----------------------------------------------------------
function is_valid_contact() {
if (contactform.sender_name.value=="" ||contactform.sender_email.value=="" ||contactform.subject.value=="") {
 alert(" أكمل البيانات المطلوبة ");
 return false;
}
else
 {
    var x = contactform.sender_email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	  {
	   alert('بريد الراسل غير صحيح');
	  }
    else
      {
         if( document.contactform.random.value== document.contactform.new_string.value)
	     {
	   	   contactform.submit();
	       return true;
	     }
	    else
		 {
		   alert("كود التحقق الذي أدخلته غير صحيح");return false;
		 }
      }
  }
}
//*********************************************
function is_valid_register() {
  if (document.register_form.cname.value == "") {
	alert('يجب كتابة الاسم ')
	register_form.cname.focus();
	return false;
	}

  if (document.register_form.cjawaal.value == "") {
	alert('يجب كتابة الجوال ')
	register_form.cjawaal.focus();
	return false;
	}

  if (document.register_form.cemail.value == "") {
	alert('يجب كتابة البريد الالكتروني')
	register_form.cemail.focus();
	return false;
	}

  if (document.register_form.user_name.value == "") {
	alert('يجب كتابة اسم المستخدم')
	register_form.user_name.focus();
	return false;
	}

  if (document.register_form.user_name.value.length < 6) {
	alert('يجب الا يقل اسم المستخدم عن 6 احرف ')
	register_form.user_name.focus();
	return false;
	}


  if (document.register_form.password.value == "") {
	alert('يجب كتابة كلمة المرور')
	register_form.password.focus();
	return false;
	}

  if (document.register_form.password.value.length < 6) {
	alert('يجب الا يقل عدد حروف كلمة المرور عن 6 احرف')
	register_form.password.focus();
	return false;
	}

  if (document.register_form.password.value!=document.register_form.password_conf.value) {
	alert('تأكيد كلمه المرور غير صحيح . ')
	register_form.password_conf.focus();
	return false;
	}

  if( document.register_form.random.value != document.register_form.new_string.value)   {
    alert("كود التحقق الذي أدخلته غير صحيح");
    register_form.new_string.focus();
	return false;
    }
 document.register_form.submit();return true;
}

//-------------------------------------------------------------
function is_valid_aqar(){
  if (document.aqar_form.aqar_name.value == "") {
	alert('يجب كتابة عنوان الإعلان ')
	aqar_form.aqar_name.focus();
	return false;
	}
  if (document.aqar_form.cat_id.value == "") {
	alert('يجب اختيار نوع العقار ')
	aqar_form.cat_id.focus();
	return false;
	}
  if (document.aqar_form.service_id.value == "") {
	alert('يجب اختيار نوع الخدمة ')
	aqar_form.service_id.focus();
	return false;
	}
  if (document.aqar_form.country_id.value == "") {
	alert('يجب اختيار الدولة ')
	aqar_form.country_id.focus();
	return false;
	}
 if( document.aqar_form.random.value != document.aqar_form.new_string.value)   {
    alert("كود التحقق الذي أدخلته غير صحيح");
    aqar_form.new_string.focus();
	return false;
    }
 document.aqar_form.submit();return true;
}
//-------------------------------------------------------------
function is_valid_free_aqar(){
  if (document.aqar_form.aqar_name.value == "") {
	alert('يجب كتابة عنوان الإعلان ')
	aqar_form.aqar_name.focus();
	return false;
	}
  if (document.aqar_form.cat_id.value == "") {
	alert('يجب اختيار نوع العقار ')
	aqar_form.cat_id.focus();
	return false;
	}
  if (document.aqar_form.service_id.value == "") {
	alert('يجب اختيار نوع الخدمة ')
	aqar_form.service_id.focus();
	return false;
	}
  if (document.aqar_form.country_id.value == "") {
	alert('يجب اختيار الدولة ')
	aqar_form.country_id.focus();
	return false;
	}
  if (document.aqar_form.guset_name.value == "") {
	alert('يجب كتابة الاسم ')
	aqar_form.guset_name.focus();
	return false;
	}
  if (document.aqar_form.guset_jawaal.value == "") {
	alert('يجب كتابة رقم الجوال')
	aqar_form.guset_jawaal.focus();
	return false;
	}
  if (document.aqar_form.guest_email.value == "") {
	alert('يجب كتابة البريد الالكتروني ')
	aqar_form.guest_email.focus();
	return false;
	}
 if( document.aqar_form.random.value != document.aqar_form.new_string.value)   {
    alert("كود التحقق الذي أدخلته غير صحيح");
    aqar_form.new_string.focus();
	return false;
    }
 document.aqar_form.submit();return true;
}
//*************************************************
function is_valid_login(){
 if(document.login_form.user_name.value !="" && document.login_form.password.value !="" )
  {
   document.login_form.submit();
   return true;
  }
 else
 {
  alert("أكمل البيانات المطلوبة");return false;
 }
}

//-----------------------------------------------------------
function is_valid_get_pass_email() {
if (get_pass_form.email.value=="")
 {
 alert(" أدخل بريدك");
 return false;
}
else
 {
    var x = get_pass_form.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	  {
	   alert('بريدك غير صحيح ');
	  }
    else
      {
	    if( document.get_pass_form.random.value== document.get_pass_form.new_string.value)
	     {
	   	   get_pass_form.submit();
	       return true;
	     }
	    else
		 {
		   alert("كود التحقق الذي أدخلته غير صحيح");return false;
		 }
      }
  }
}
//------------------------------------------------------
function is_vaild_comment(){
 if(document.commentform.subject.value!="" && document.commentform.comment.value!="")
  {
   if( document.commentform.random.value== document.commentform.new_string.value)
     {
   	    document.commentform.submit();return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }

  }
 else
  {
   alert(" أكمل البيانات المطلوبة ");
   return false;
  }
}

//------------------------------------------------------------
function is_valid_send() {
if (sendform.sender_name.value=="" ||sendform.sender_email.value=="" ||sendform.frind_email.value=="" ) {
 alert(" أكمل البيانات المطلوبة ");
 return false;
}
else
 {
    $valid_email=true;

    var x = sendform.sender_email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	  {
	   alert('بريد الراسل غير صحيح');
	   return false;
	   $valid_email=false;
	  }

	var x = sendform.frind_email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	  {
	    alert('بريد المرسل إليه غير صحيح');
	    return false;
	    $valid_email=false;
	  }

  if($valid_email==true)
    {
	  if( document.sendform.random.value== document.sendform.new_string.value)
	     {
	   	   sendform.submit();
	       return true;
	     }
	    else
		 {
		   alert("كود التحقق الذي أدخلته غير صحيح");return false;
		 }
	}
 }
}
//-----------------------------------------------------------
function is_valid_email() {
if (mail_form.email.value==""){
 alert(" أكمل البيانات المطلوبة ");
 return false;
}
else
 {
    var x = mail_form.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	  {
	   alert('البريد غير صحيح ');
	  }
    else
      {
        mail_form.submit();
	    return true;
      }
  }
}
//----------------------------------------------------------
function show_aqarat_part_details()
 {
  cat_id=parts.cat_id.options[parts.cat_id.selectedIndex].value;
  if(cat_id)
    window.location.href='index.php?view=aqarat&aqarat_action=show_part_details&cat_id='+cat_id;
 }
//----------------------------------------------------------
function change_cat_details_add(){
  cat_id=aqar_form.cat_id.options[aqar_form.cat_id.selectedIndex].value;
  if(cat_id)
    window.location.href='index.php?view=my_control&control_action=add_aqar&step=1&cat_id='+cat_id;
}
//----------------------------------------------------------
function change_cat_details_edit(){
  cat_id=aqar_form.cat_id.options[aqar_form.cat_id.selectedIndex].value;
  aqar_id=aqar_form.aqar_id.value;
  if(cat_id)
    window.location.href='index.php?view=my_control&control_action=edit_aqar&edit=true&step=1&cat_id='+cat_id+'&aqar_id='+aqar_id;
}

//----------------------------------------------------------
function isvalid_search(){
   if(document.searchform.search_word.value=="")
    {window.alert("أدخل كلمة البحث ");return false;}
   else
    {document.searchform.submit();return true;}
 }
//----------------------------------------------------------
function isvalid_matger(){
   if(document.matger_form.matger_name.value=="" || document.matger_form.matger_title.value=="")
    {window.alert("أدخل إسم متجرك ");return false;}
   else
    {document.matger_form.submit();return true;}
 }
//----------------------------------------------
function Layers(X)
{

		if(document.all[X].style.display == 'none')
		{
			document.all[X].style.display = ''
		}else
		{
			document.all[X].style.display = 'none'
		 }
}

function Layers2(Y)
{

		if(document.all[Y].style.display == 'none')
		{
			document.all[Y].style.display = ''
		}else
		{
			document.all[Y].style.display = 'none'
		 }
}

function val(Parent,Child)
	{
	if(document.form[Parent].checked==true)
		{
		for (i=0 ; i < document.form[Child].length ; i++)
			document.form[Child][i].checked = true ;
		}
	if(document.form[Parent].checked==false)
		{
		for (i=0 ; i < document.form[Child].length ; i++)
			document.form[Child][i].checked = false ;
		}
	}

//---------------------------------------------------------------
function is_valid_require_aqar(){
if(document.require_aqar_form.send_user.value !="" && document.require_aqar_form.mobile.value !="")
  {
   	if( document.require_aqar_form.random.value== document.require_aqar_form.new_string.value)
     {
   	   require_aqar_form.submit();
       return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
 else
 {
  alert("أكمل البيانات المطلوبة");
  return false;
 }
}

//-----------------------------------------------------------
function confirm_delete_image(image_id,id){
if(confirm("سوف يتم حذف السجل , هل أنت متأكد ؟ "))
 {
 path="my_aqarat,edit_aqar_images,step,4,"+image_id+","+id+".html";
 location.href=path;
 }
}


//-----------------------------------------------------------
function is_valid_moderator(){
 if(document.adduser_form.user_name.value !="" && document.adduser_form.password.value !="" )
  {
  if(document.adduser_form.password.value==document.adduser_form.password_conf.value)
    {
	    document.adduser_form.submit();
        return true;
	}
   else
	{
     alert("كلمة المرور لا تتوافق");return false;
	}
  }
 else
 {
  alert("أكمل البيانات المطلوبة");return false;
 }
}
//----------------------------------------------------------
function confirm_logout(){
	if(window.confirm("هل أنت متأكد "))
      {
       top.location.href="logout.php";
	  }
}
//---------------------------------------------------------------
function is_valid_new(){
if(document.site_new_form.new_title.value !="" )
  {
  if( document.site_new_form.random.value== document.site_new_form.new_string.value)
     {
        document.site_new_form.submit();
        return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
 else
 {
  alert("أكمل البيانات المطلوبة");
  return false;
 }
}
//---------------------------------------------------------------
function is_valid_article(){
if(document.article_form.title.value !="" )
  {
   if( document.article_form.random.value== document.article_form.new_string.value)
     {
   	   document.article_form.submit();
       return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
 else
 {
  alert("أكمل البيانات المطلوبة");
  return false;
 }
}
//---------------------------------------------------------------
function is_valid_office(){
if(document.office_form.office_title.value !="" )
  {
   	if( document.office_form.random.value== document.office_form.new_string.value)
     {
   	   document.office_form.submit();
       return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
 else
 {
  alert("أكمل البيانات المطلوبة");
  return false;
 }
}
//---------------------------------------------------------------
function is_valid_msg(){
if(document.msg_form.msg_subject.value !="" )
  {
   	if( document.msg_form.random.value== document.msg_form.new_string.value)
     {
   	   document.msg_form.submit();
       return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
 else
 {
  alert("أكمل البيانات المطلوبة");
  return false;
 }
}


//---------------------------------------------------
function createRequestObject(){

var req;

if(window.XMLHttpRequest){
//For Firefox, Safari, Opera
//req = new XMLHttpRequest();
 req = new XMLHttpRequest();
  if (req.overrideMimeType)
	{
		req.overrideMimeType('text/xml');
	}

}
else if(window.ActiveXObject){
//For IE 5+
req = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
//Error for an old browser
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}

return req;
}
//---------------------------------------------------
function is_valid_sendmaillist(){
if(document.sendmaillist_form.subject.value !="" )
  {
   	if( document.sendmaillist_form.random.value== document.sendmaillist_form.new_string.value)
     {
   	   	document.sendmaillist_form.submit();
       return true;
     }
    else
	 {
	   alert("كود التحقق الذي أدخلته غير صحيح");return false;
	 }
  }
 else
 {
  alert("أكمل البيانات المطلوبة");
  return false;
 }
}
//-------------------------------------------------------
function funChangeMenu(vObj, vColor,num_tabs){
	for(i = 1; i <= num_tabs; i++){
		document.getElementById("vLinks" + i).style.display = "none";
	}
	if(vColor == 1){
		document.getElementById("vLinks" + vObj).style.display = "block";
		document.getElementById("vLinks" + vObj).style.height = "23px";
	}else{
		document.getElementById("vLinks" + vObj).style.display = "block";
		document.getElementById("vLinks" + vObj).style.height = "23px";
	}
}
//-------------------------------------------------------------
function get_city_forsearch(){
country_id=search_aqar_form.country_id.options[search_aqar_form.country_id.selectedIndex].value
send_val="country_id="+country_id;
var url="ajax_get.php?get_action=add_cities&"+send_val;
xmlHttp.open("POST",url,true);
//document.getElementById("search_div").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("search_div").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
//----------------------------------------------------------------------
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload == 'function') {
window.onload = function() {
oldonload();
func();
}
} else {
window.onload = func;
}}


//-------------------------------------------------------------
function show_img(img_path){
var url="ajax_get.php?get_action=show_full_img&img_path="+img_path;
xmlHttp.open("POST",url,true);
document.getElementById("full_img").innerHTML = 'جاري التحميل... <img src="images/loading.gif" />';
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.getElementById("full_img").innerHTML=xmlHttp.responseText;
  }
}
xmlHttp.send(null);
}
