 var xmlhttp;
  var xmlhttp2;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  xmlhttp2=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
  
 

  $(document).ready(function(){

 
/*
$('span.Poll_span').hide();

$("#myformS :input").each(function(i){
 if($(this).val() == '' && $(this).attr("type") != 'submit')
 {
	 $('span#'+$(this).attr("id")+'_span').show();
	 alert()
 }
});
*/
//$('input[id=When_Dr_Name]')
 
 

$('#Food_radio input').click( function() { 
										   
		$('div#row_neighborhoods_span').show();
		
// alert($(this).attr("id"));
if($(this).attr("id") == 'Food_radio_row_neighborhoods')
{
$('div#row_neighborhoods_span').hide();	
	
}
//$('span#'+$(this).attr("id")+'_span').show();										   
});//$('#Type_of_damage input').click( function() { 
										   
$('#Food_radio input:checked').click();
//$('#Food_radio input#Food_radio_row_neighborhoods').click();
//$('input:checked').focus( function() { alert("Hello"); } );
 
 
function chec()
{
	$('tr.Hade_tr_all').hide();
var n =$('#Type_of_damage input:checked').length;
//var n =$('#Type_of_damage input[type=checkbox]').length;
$('#Type_of_damage input:checked').each(function(i){
 
 //$('tr.Hade_tr_all').hide();
	$('tr#'+$(this).attr("id")+'_tr').show();
	 //alert($(this).attr("id"))
//var n2 = $('tr#'+$(this).attr("id")+'_tr :input').length;
//alert(n2)
 	
 
 	
 
});

 
} 

 chec();

$(":checkbox").click(chec);



 





















$("select#Select_Apartments").change(function(event){

 $('select#NeighborhoodS').attr({ disabled: ""}); 
 
//alert($(this).val())
//$('strong.report_print_strong').hide();

 //$BoolInputValuesFrom = $(this).val();
if($(this).val() == 'Apartments_All')
{
 
$('select#NeighborhoodS').attr({ disabled: "disabled"}); 
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}else if($(this).val() == 'Apartments_one')
{
 $('select#NeighborhoodS').attr({ disabled: ""});
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}											
											
});



$("select#Select_ToFromDate_N_A").change(function(event){

 $('select#NeighborhoodS').attr({ disabled: ""}); 
 
//alert($(this).val())
//$('strong.report_print_strong').hide();

 //$BoolInputValuesFrom = $(this).val();
if($(this).val() == 'All')
{
 
$('select#NeighborhoodS').attr({ disabled: "disabled"}); 
$('select#Select_Apartments').attr({ disabled: "disabled"}); 
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}else if($(this).val() == 'Apartments')
{
 $('select#NeighborhoodS').attr({ disabled: ""});
 $('select#Select_Apartments').attr({ disabled: ""}); 
 $("select#Select_Apartments").change();
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}else if($(this).val() == 'Neighborhood')
{
 $('select#NeighborhoodS').attr({ disabled: ""}); 
 $('select#Select_Apartments').attr({ disabled: "disabled"}); 
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}											
											
});

$("select#Select_ToFromDate_N_A").change();

//$("div#cho_report_in input:radio")

$("div#cho_report_in input").click(function(event){
//$hrefVALd = $(this).val();	
 //alert($hrefVALd);
 //$BoolInputValuesFromTo = false;
 //$BoolInputValuesFromDay = false;
 //$BoolInputValuesFromMonth = false;
 //$BoolInputValuesFromYear = false;
 
  
   $('#ToFromDate :input').each(function(i){
if($(this).attr("id") != 'Select_ToFromDate_N_A' && $(this).attr("id") != 'NeighborhoodS' && $(this).attr("id") != 'Select_Apartments' ) 
$(this).attr({ disabled: ""});
//enabled
});
   
  
if($(this).val() == 'FromTime')
{
 
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}else if($(this).val() == 'FromDay')
{

  $('#ToFromDate :input').each(function(i){
 
 if($(this).attr("id") != 'DYearsFrom' &&  $(this).attr("id") != 'DMonthFrom' &&  $(this).attr("id") != 'DdayFrom' && $(this).attr("id") != 'show_report_print' && $(this).attr("id") != 'FROM_SHOW_Time' && $(this).attr("id") != 'LIMIT_SHOW_Time' && $(this).attr("id") != 'Select_ToFromDate_N_A' && $(this).attr("id") != 'NeighborhoodS' && $(this).attr("id") != 'Select_Apartments'  && $(this).parents('table').attr("id") !='Type_of_damage' && $(this).parents('table').attr("id") !='active_id_sr')
 {
//$(this).hide() 
$(this).attr({ disabled: "disabled"});
 }
});// $('#ToFromDate :input').each(function(i){
	
 
	//$BoolInputValuesFromDay = true;
	// $BoolInputValuesFrom ='FromDay';
}else if($(this).val() == 'FromMonth')
{//DMonthFrom
 
  
 $('#ToFromDate :input').each(function(i){
 
 if($(this).attr("id") != 'DYearsFrom' &&  $(this).attr("id") != 'DMonthFrom' &&$(this).attr("id") != 'show_report_print' && $(this).attr("id") != 'FROM_SHOW_Time' && $(this).attr("id") != 'LIMIT_SHOW_Time' && $(this).attr("id") != 'Select_ToFromDate_N_A' && $(this).attr("id") != 'NeighborhoodS'	 && $(this).attr("id") != 'Select_Apartments' && $(this).parents('table').attr("id") !='Type_of_damage' && $(this).parents('table').attr("id") !='active_id_sr')
 {
//$(this).hide() 
$(this).attr({ disabled: "disabled"});
 }
});// $('#ToFromDate :input').each(function(i){
	//$BoolInputValuesFromMonth = true;
	// $BoolInputValuesFrom ='FromMonth';
}else if($(this).val() == 'FromYear')
{
 	
	//ToFromDate

 
 $('#ToFromDate :input').each(function(i){
 
 if($(this).attr("id") != 'DYearsFrom' && $(this).attr("id") != 'show_report_print'  && $(this).attr("id") != 'FROM_SHOW_Time' && $(this).attr("id") != 'LIMIT_SHOW_Time' && $(this).attr("id") != 'Select_ToFromDate_N_A'  && $(this).attr("id") != 'Select_Apartments'  && $(this).attr("id") != 'NeighborhoodS' && $(this).parents('table').attr("id") !='Type_of_damage' && $(this).parents('table').attr("id") !='active_id_sr')
 {
//$(this).hide() 
$(this).attr({ disabled: "disabled"});
 }
});// $('#ToFromDate :input').each(function(i){
 
	//$BoolInputValuesFromYear = true;
	//$BoolInputValuesFrom ='FromMonth';
}



});

$('div#cho_report_in input:checked').click();



 


 
});
 
 
 function dilogShow_report_print(PATH)
{
var BOL = true;	
 //isNaN
//alert(PATH);
//var FromTime = $("input#FromTime");
var urlP =PATH;
 $('#ToFromDate :input').each(function(i){
 
if($(this).attr("id") != 'show_report_print' && $(this).parents('table').attr("id") !='Type_of_damage' && $(this).parents('table').attr("id") !='active_id_sr')
 {
	 if(!$(this).attr("disabled") && $(this).val() !='' )
	 {
		
if($(this).attr("id") == 'FromTime' && isNaN($(this).val()))
{
	$(this).focus();
	alert('الوقت  يجب ان يكون رقم');
	 BOL = false;
}else if($(this).attr("id") == 'FromTime' && $(this).val() >24)
{
	$(this).focus();
	alert('الوقت يجب ان يكون اقل من 24');
	 BOL = false;
}

// alert($(this).parents('table').attr("id"))
 //return false;

//alert($(this).val().length)

	 urlP = urlP +'&'+$(this).attr("name")+'='+$(this).val();
	 //alert($(this).attr("disabled")) 
	 //alert($(this).val())
	// alert($(this).attr("name")) 
	 }
//$(this).hide() 
//$(this).attr({ disabled: "disabled"});
 }

});// $('#ToFromDate :input').each(function(i){



//$(this).parents('table').attr("id") !='Type_of_damage' && $(this).parents('table').attr("id") !='active_id_sr'

var Type_of_damage = new Array();
$('table#Type_of_damage input:checked').each(function(i){
//alert($(this).val())
Type_of_damage[i] =  $(this).val();
// urlP = +'&'+urlP +'&'+$(this).attr("name")+'='+$(this).val();
});// $('table#Type_of_damage input:checked').each(function(i){
	
if(Type_of_damage.length > 0)
urlP = urlP +'&Type_of_damage='+Type_of_damage;


var active_id_sr = new Array();
$('table#active_id_sr input:checked').each(function(i){
//alert($(this).val())
active_id_sr[i] =  $(this).val();
// urlP = +'&'+urlP +'&'+$(this).attr("name")+'='+$(this).val();
});// $('table#Type_of_damage input:checked').each(function(i){
	

if(active_id_sr.length > 0)
urlP = urlP +'&active_id_sr='+active_id_sr;

//alert(Type_of_damage.length)
//alert(active_id_sr.length)

 
 //alert($('table#Type_of_damage :input').length);//نوع الضرر :
 // alert($('table#active_id_sr :input').length); //نوع الحالة :

// alert(PATH);
//var urlP =PATH +'&FROM_SHOW='+FROM_SHOW+'&LIMIT_SHOW='+LIMIT_SHOW;

//alert(urlP);
//return false;
if(BOL)
window.open(urlP,'','toolbar=no,location=no,directories=no,status=no,menubar=no,width=1000,height=800,scrollbars=1','');

} 

 
 
 
 
 
 
 
 
 
 
   
function dilogShow_RESULT(PATH)
{
	
 //isNaN
//alert(PATH);
var FROM_SHOW = $("input#FROM_SHOW").val()
var LIMIT_SHOW = $("input#LIMIT_SHOW").val()
var hidden_FROM_SHOW = $("input#hidden_FROM_SHOW").val()
var hidden_LIMIT_SHOW = $("input#hidden_LIMIT_SHOW").val()

if(isNaN(FROM_SHOW))
{
	$("input#FROM_SHOW").focus();
	alert('من يجب ان يكون رقم');
	return false;
}

if(isNaN(LIMIT_SHOW))
{
	$("input#LIMIT_SHOW").focus();
	alert('عدد النتائج يجب ان يكون رقم');
	return false;
}

if(FROM_SHOW == '' || isNaN(FROM_SHOW))
FROM_SHOW = hidden_FROM_SHOW;

if(LIMIT_SHOW == '' || isNaN(LIMIT_SHOW))
LIMIT_SHOW = hidden_LIMIT_SHOW;

// alert(PATH);
var urlP =PATH +'&FROM_SHOW='+FROM_SHOW+'&LIMIT_SHOW='+LIMIT_SHOW;

//alert(urlP);
//return false;
window.open(urlP,'','toolbar=no,location=no,directories=no,status=no,menubar=no,width=1000,height=800,scrollbars=1','');

} 
  
/*  
function ajaxFunction(ActionePTH,val_this)
{

// alert(ActionePTH+'?val_this='+val_this);

var obj = document.getElementById('Resultreturn');
//$('#Resultreturn').hide();
//$('#img_load').show();



var Actione =ActionePTH+'?val_this='+val_this;
alert(Actione);
xmlhttp.onreadystatechange=function()
{
//xmlhttp.getAllResponseHeaders();
if(xmlhttp.readyState==4)
  {   	  
  obj.innerHTML = xmlhttp.responseText;
  alert(xmlhttp.responseText);
//$('#img_load').hide();
//$('#Resultreturn').show();
 //$("div.DIVdetails").children().width(200);
  }
}
xmlhttp.open("GET",Actione,true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8;");
xmlhttp.send(null);
 

}
*/

 
  function ajaxFuncheck_domains()
{
//domains_name,domains_type
$('#identification').css({ border:'#3a7ab0 solid 1px'});
$('#main_title_check_domains_icon_loading_span').hide();

$('#main_title_check_domainsNO_span').hide();

$('#submit').hide();

//alert($('#main_title_check_domains').val() +'\n'+ $('#TEPE_domains').val())
if($('#identification').val()!='')
{
	$('#main_title_check_domains_icon_loading_span').show();
$.ajax({
  type: "POST",
  url: "ajaqx_c.php",
  data: "identification="+$('#identification').val(),
  success: function(msg){
	  $('#main_title_check_domains_icon_loading_span').hide();
	  if(msg == 1)
	  {
		  $('#submit').hide();
	  $('#main_title_check_domainsNO_span').show();
	  }else
	  $('#submit').show();
  // alert(msg );
  }
});
}else if($('#identification').val().length =='')
{
	$('#identification').focus();
$('#identification').css({ border:'#FF0000 solid 1px'});	
}

/*var obj = document.getElementById('hpmestrdonatiRSULT');
var Actione =ActionePTH;

xmlhttp.onreadystatechange=function()
{
//xmlhttp.getAllResponseHeaders();
if(xmlhttp.readyState==4)
  {   	  
  obj.innerHTML = xmlhttp.responseText;
$('#hpmestrdonatimsg').hide();
$('#hpmestrdonatiRSULT').show();
  }
}
xmlhttp.open("GET",Actione,true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8;");
xmlhttp.send(null);
*/
}
