function add_status_note(cla,cli){ 
	var url= "/status_notes.php?cla="+cla+"&cli="+cli;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=600,height=620');
	win_status.focus(); 
	return false; 
} 
function change_comment(cla,cli,file){
	var url= "/upload_pictures.php?cla="+cla+"&cli="+cli+"&i="+file;  
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=615,height=530');

    win_status.focus();
	return false;		
}

function upload_pictures(cla,cli){ 
	var url= "/upload_pictures.php?cla="+cla+"&cli="+cli;  
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=600,height=600');

    win_status.focus();
	return false;	
}
function ask_additional(cla,cli){ 
	var url= "/ask_additional.php?cla="+cla+"&cli="+cli;  
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=462,height=406');

    win_status.focus();
	return false;	
}

function do_close(obj){
	if(obj!=''){
		val = eval(obj+".value");
		//alert(val);
		if(val !=''){
			x= confirm("Are you sure you want to leave without save the Info?\nAll Text will be lost\nClick OK to continue without save ");
			//x = MsgBox("do you want only YES and NO?", vbYesNoCancel)
			if(x){
				window.close();
			}
		}else{
			window.close();
		}
	}else{
			window.close();
	}
}	


function show_postit(ins){
	var url= "/postit.php?ins="+ins;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=590,height=340');
	win_status.focus(); 
}	
	
	

function set_name(obj,number){
	str = "images.name"+number+".value='"+obj.value+"';";
	eval(str);	
}

/////////////////////////////////////////////
function reload_the_matrix(value) {
	document.location.href="areas_inspector.php?s="+value;
}

/////////////////////////////////////////

function growup(obj){
	var val = new Number(obj.rows);
	var key = event.keyCode;
	
    if (key==13) { 
		obj.rows = val+1;
	}	
}
////////////////////////////////
function move(source,dest){
	var key = event.keyCode;
	if( (key !=8) && (key !=0)){ 
		var num = new String(source.value);
		if(num.length > 2){
			dest.focus();
		}
	}
}
////////////////////////////////

function check_login(form_obj){
	if(form_obj.username.value==''){
		alert("Please fill your username");
		form_obj.username.focus();
		return false;
	}
	
	if(form_obj.password.value==''){
		alert("Please fill your password");
		form_obj.password.focus();
		return false;
	}		
	return true;
}
///////////////////////////////////////////////////////////////////////////////////////
function check_review(obj){
	if(obj.comment.value==''){
		alert("Please fill the comment");
		obj.comment.focus();
		return false;
	}		
	return true;	
}
///////////////////////////////////////////////////////////////////////////////////////
function check_users(obj){
	if(obj.user_type.value ==''){
		alert('Please fill the user_type');
		obj.user_type.focus();
		return false;
	}				

	if(obj.name.value ==''){
		alert('Please fill the name');
		obj.name.focus();
		return false;
	}				

	if(obj.lastname.value ==''){
		alert('Please fill the lastname');
		obj.lastname.focus();
		return false;
	}				

	if(obj.username.value ==''){
		alert('Please fill the username');
		obj.username.focus();
		return false;
	}				

	if(obj.password.value ==''){
		alert('Please fill the password');
		obj.password.focus();
		return false;
	}				

	if(obj.address.value ==''){
		alert('Please fill the address');
		obj.address.focus();
		return false;
	}				

	if(obj.city.value ==''){
		alert('Please fill the city');
		obj.city.focus();
		return false;
	}				

	if(obj.state.value ==''){
		alert('Please fill the state');
		obj.state.focus();
		return false;
	}				

	if(obj.zipcode.value ==''){
		alert('Please fill the zipcode');
		obj.zipcode.focus();
		return false;
	}				

	if(obj.email.value ==''){
		alert('Please fill the email');
		obj.email.focus();
		return false;
	}				

	return true;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function check_user_signup(obj){
	
	/*
	if(obj.company.value ==''){
		alert('Please fill the company');
		obj.company.focus();
		return false;
	}	*/

	if(obj.name.value ==''){
		alert('Please fill the name');
		obj.name.focus();
		return false;
	}				

	if(obj.lastname.value ==''){
		alert('Please fill the lastname');
		obj.lastname.focus();
		return false;
	}				

	if(obj.username.value ==''){
		alert('Please fill the username');
		obj.username.focus();
		return false;
	}				

	if(obj.password.value ==''){
		alert('Please fill the password');
		obj.password.focus();
		return false;
	}	
	
	
	if(obj.password.value !=obj.password2.value){
		alert('The password do not match');
		obj.password.focus();
		return false;
	}	
	
	
	if(obj.email.value ==''){
		alert('Please fill the email');
		obj.email.focus();
		return false;
	}	
/*
	if(obj.city.value ==''){
		alert('Please fill the city');
		obj.city.focus();
		return false;
	}				

	if(obj.state.value ==''){
		alert('Please select the state');
		obj.state_id.focus();
		return false;
	}				

	if(obj.zipcode.value ==''){
		alert('Please fill the zipcode');
		obj.zipcode.focus();
		return false;
	}				
*/
	if(obj.area_phone.value ==''){
		alert('Please fill the area code');
		obj.area_phone.focus();
		return false;
	}				

	if(obj.phone.value ==''){
		alert('Please fill the number');
		obj.phone.focus();
		return false;
	}				
	
return true;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function check_inspector_signup(obj){
	if(obj.company.value ==''){
		alert('Please fill the company');
		obj.company.focus();
		return false;
	}				
		
	if(obj.name.value ==''){
		alert('Please fill the name');
		obj.name.focus();
		return false;
	}				

	if(obj.lastname.value ==''){
		alert('Please fill the lastname');
		obj.lastname.focus();
		return false;
	}				

	if(obj.username.value ==''){
		alert('Please fill the username');
		obj.username.focus();
		return false;
	}				

	if(obj.password.value ==''){
		alert('Please fill the password');
		obj.password.focus();
		return false;
	}	
	
	if(obj.password.value != obj.password2.value){
		alert('The password do not match');
		obj.password.focus();
		return false;
	}		

	if(obj.email.value ==''){
		alert('Please fill the email');
		obj.email.focus();
		return false;
	}	
	
	if(obj.street.value =='' &&  obj.pobox.value =='' ){
		alert('Please fill the street or the PO Box');
		obj.street.focus();
		return false;
	}				

	if(obj.city.value ==''){
		alert('Please fill the city');
		obj.city.focus();
		return false;
	}				

	if(obj.state.value ==''){
		alert('Please fill the state');
		obj.state.focus();
		return false;
	}				

	if(obj.zipcode.value ==''){
		alert('Please fill the zipcode');
		obj.zipcode.focus();
		return false;
	}				


	if(obj.area_phone.value ==''){
		alert('Please fill the area phone');
		obj.area_phone.focus();
		return false;
	}				

	if(obj.phone.value ==''){
		alert('Please fill the phone');
		obj.phone.focus();
		return false;
	}				


	if(obj.certifications.value ==''){
		alert('Please fill the certifications');
		obj.certifications.focus();
		return false;
	}				

	
}



////////////////////////////////////////////////////////////////////////////////////////////////
	function check_modules(obj){
			if(obj.name.value ==''){
				alert('Debe indicar el valor de name');
				obj.name.focus();
				return false;
			}				
		
			if(obj.link.value ==''){
				alert('Debe indicar el valor de link');
				obj.link.focus();
				return false;
			}				
		
			if(obj.nivel.value ==''){
				alert('Debe indicar el valor de nivel');
				obj.nivel.focus();
				return false;
			}				
		
					if(isNaN(obj.nivel.value) ){
						alert('El valor de nivel debe ser un numero');
						obj.nivel.focus();
						return false;
					}				
					
		return true;
	}
/////////////////////////////////
	function check_rol(obj){
			if(obj.name.value ==''){
				alert("Please Fill the Rol's name");
				obj.name.focus();
				return false;
			}				
			
		return true;
	}
	
//////////////////////////////////////////////////////
function check_states(obj){
	if(obj.country.value ==''){
		alert('Please fill the country');
		obj.country.focus();
		return false;
	}				

			if(isNaN(obj.country.value) ){
				alert('country must be a number');
				obj.country.focus();
				return false;
			}				
		
	if(obj.code.value ==''){
		alert('Please fill the code');
		obj.code.focus();
		return false;
	}				

			if(isNaN(obj.code.value) ){
				alert('code must be a number');
				obj.code.focus();
				return false;
			}				
		
	if(obj.name.value ==''){
		alert('Please fill the name');
		obj.name.focus();
		return false;
	}				
	
return true;
}
///////////////////////////////////////////////////////////
function check_claim(obj){
	
	if(obj.id_manufacturer.value==''){
		alert('Please select the client');
		obj.id_manufacturer.focus();
		return false;
	}

	if(obj.id_user.value==''){
		alert('Please select the user');
		obj.id_user.focus();
		return false;
	}


	if(obj.number.value ==''){
		alert('Please fill the number');
		obj.number.focus();
		return false;
	}				

			

	if(obj.style.value ==''){
		alert('Please fill the style');
		obj.style.focus();
		return false;
	}				
	

	if(obj.claim.value ==''){
		alert('Please fill the claim');
		obj.claim.focus();
		return false;
	}				

	if(obj.name.value ==''){
		alert('Please fill the name');
		obj.name.focus();
		return false;
	}				

	if(obj.street.value ==''){
		alert('Please fill the street');
		obj.street.focus();
		return false;
	}				

	if(obj.city.value ==''){
		alert('Please fill the city');
		obj.city.focus();
		return false;
	}				

	if(obj.state.value ==''){
		alert('Please fill the state');
		obj.state.focus();
		return false;
	}				
		

	if(obj.home_area_phone.value ==''){
		alert('Please fill the area code');
		obj.home_area_phone.focus();
		return false;
	}				

	if(obj.home_phone.value ==''){
		alert('Please fill the phone number');
		obj.home_phone.focus();
		return false;
	}				
	
	return true;
}

///////////////////////////////////////////////////////////////
/*
function add_status_note(id_claim){ 
	var url= "/sn.php?c="+id_claim;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=750,height=430');
	win_status.focus(); 
	//return false; 
} 
*/
///////////////////////////////////////////////////////////////

function open_send_review(id_claim){
	var url= "/review.php?c="+id_claim;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=600,height=350');
	win_status.focus(); 
	
}

///////////////////////////////////////////////////////////////

function open_upload_images(id_claim){
	var url= "/upload.php?c="+id_claim;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=600,height=600');
	win_status.focus(); 
	
}

///////////////////////////////////////////////////////////////
function check_scn(obj){
	if(obj.claim_number.value==''){
		alert("Plese indicate the claim number");
		obj.claim_number.focus();
		return false;
	}
	return true;	
}
///////////////////////////////////////////////////////////////
function check_cn(obj){
	if(obj.consumer.value==''){
		alert("Plese indicate the consumer's name");
		obj.consumer.focus();
		return false;
	}
	return true;	
}
/////////////////////////////////////////////////////

function check_inspector_report(obj){

	if(obj.do_check.value=='T'){
			//alert(obj.inspection_date.value);
			if(obj.inspection_date.value =='' || obj.inspection_date.value =='0-0-00'){
				alert('Please Select the Inspection Date');
				obj.inspection_date.focus();
				return false;
			}	


			if(isNaN(obj.id_claim.value) ){
				alert('Error on navigation');
				history.back();
			}				
				
		
			if(obj.present_inspection.value ==''){
				alert('Please fill the Individual(s) Present Upon Inspection');
				obj.present_inspection.focus();
				return false;
			}				
		
			if(obj.product_description.value ==''){
				alert('Please fill the Product Description');
				obj.product_description.focus();
				return false;
			}				
		
			if(obj.b_use.value ==''){
				alert('Please select the building use');
				obj.b_use.focus();
				return false;
			}				
		
			if(obj.condition.value ==''){
				alert('Please select the building condition');
				obj.condition.focus();
				return false;
			}				
		
			if(obj.b_type.value ==''){
				alert('Please select the building type');
				obj.b_type.focus();
				return false;
			}				
		
			if(obj.trafic_count.value ==''){
				alert('Please select the trafic count');
				obj.trafic_count.focus();
				return false;
			}				
		
			if(obj.adults.value ==''){
				alert('Please fill the adults');
				obj.adults.focus();
				return false;
			}				
		
			if(obj.childrens.value ==''){
				alert('Please fill the childrens');
				obj.childrens.focus();
				return false;
			}				
		
			if(obj.pets.value ==''){
				alert('Please fill the pets');
				obj.pets.focus();
				return false;
			}				
		
			if(obj.ac.value ==''){
				alert('Please select the ac');
				obj.ac.focus();
				return false;
			}				
		
			if(obj.heat.value ==''){
				alert('Please select the heat');
				obj.heat.focus();
				return false;
			}				
		
			if(obj.gradient.value ==''){
				alert('Please select the gradient');
				obj.gradient.focus();
				return false;
			}				
		
			if(obj.subfloor.value ==''){
				alert('Please select the subfloor');
				obj.subfloor.focus();
				return false;
			}				
		
		

			if(obj.installed_by.value ==''){
				alert('Please select the installed by');
				obj.installed_by.focus();
				return false;
			}				
		
			if(obj.date_noticed_m.value ==''){
				alert('Please select the month');
				obj.date_noticed_m.focus();
				return false;
			}	

			if(obj.date_noticed_a.value ==''){
				alert('Please select the year');
				obj.date_noticed_a.focus();
				return false;
			}	
			
		
			if(obj.observations.value ==''){
				alert('Please fill the observations');
				obj.observations.focus();
				return false;
			}				
		
			if(obj.conclusion.value ==''){
				alert('Please fill the conclusion');
				obj.conclusion.focus();
				return false;
			}				
		
	}
	
return true;
}
/////////////////////////////////////////////
function check_form1(obj){

	if(obj.do_check.value=='T'){

			if(obj.inspection_date.value =='' || obj.inspection_date.value =='00-00-0000'){
				alert('Please Select the Inspection Date');
				obj.inspection_date.focus();
				return false;
			}	

			if(isNaN(obj.id_claim.value) ){
				alert('Error on navigation');
				history.back();
			}				
				
		
			if(obj.present_inspection.value ==''){
				alert('Please fill the Individual(s) Present Upon Inspection');
				obj.present_inspection.focus();
				return false;
			}				
		
			if(obj.product_description.value ==''){
				alert('Please fill the Product Description');
				obj.product_description.focus();
				return false;
			}				
		
			if(obj.b_use.value ==''){
				alert('Please select the building use');
				obj.b_use.focus();
				return false;
			}				
		
			if(obj.condition.value ==''){
				alert('Please select the building condition');
				obj.condition.focus();
				return false;
			}				
		
			if(obj.b_type.value ==''){
				alert('Please select the building type');
				obj.b_type.focus();
				return false;
			}				
		
			if(obj.trafic_count.value ==''){
				alert('Please select the trafic count');
				obj.trafic_count.focus();
				return false;
			}				
		
			if(obj.adults.value ==''){
				alert('Please fill the adults');
				obj.adults.focus();
				return false;
			}				
		
			if(obj.childrens.value ==''){
				alert('Please fill the childrens');
				obj.childrens.focus();
				return false;
			}				
		
			if(obj.pets.value ==''){
				alert('Please fill the pets');
				obj.pets.focus();
				return false;
			}				
			if(obj.subfloor.value ==''){
				alert('Please select the subfloor');
				obj.subfloor.focus();
				return false;
			}				
			if(obj.observations.value ==''){
				alert('Please fill the observations');
				obj.observations.focus();
				return false;
			}				
			if(obj.conclusion.value ==''){
				alert('Please fill the conclusion');
				obj.conclusion.focus();
				return false;
			}				
		
	}
	
return true;

}
/////////////////////////////////////////////
function check_form2(obj){
	if(obj.do_check.value=='T'){

			if(obj.inspection_date.value =='' || obj.inspection_date.value =='00-00-0000'){
				alert('Please Select the Inspection Date');
				obj.inspection_date.focus();
				return false;
			}	


			if(obj.present_inspection.value ==''){
				alert('Please fill the Individual(s) Present Upon Inspection');
				obj.present_inspection.focus();
				return false;
			}				
		
			if(obj.product_description.value ==''){
				alert('Please fill the Product Description');
				obj.product_description.focus();
				return false;
			}				
		
			if(obj.b_use.value ==''){
				alert('Please select the building use');
				obj.b_use.focus();
				return false;
			}				
		
			if(obj.condition.value ==''){
				alert('Please select the building condition');
				obj.condition.focus();
				return false;
			}				
		
			if(obj.b_type.value ==''){
				alert('Please select the building type');
				obj.b_type.focus();
				return false;
			}				
		
			if(obj.trafic_count.value ==''){
				alert('Please select the trafic count');
				obj.trafic_count.focus();
				return false;
			}				
		
			if(obj.adults.value ==''){
				alert('Please fill the adults');
				obj.adults.focus();
				return false;
			}				
		
			if(obj.childrens.value ==''){
				alert('Please fill the childrens');
				obj.childrens.focus();
				return false;
			}				
		
			if(obj.pets.value ==''){
				alert('Please fill the pets');
				obj.pets.focus();
				return false;
			}				
			if(obj.subfloor.value ==''){
				alert('Please select the subfloor');
				obj.subfloor.focus();
				return false;
			}				
			if(obj.observations.value ==''){
				alert('Please fill the observations');
				obj.observations.focus();
				return false;
			}				
			if(obj.conclusion.value ==''){
				alert('Please fill the conclusion');
				obj.conclusion.focus();
				return false;
			}				
		
	}
	
return true;
}/////////////////////////////////////////////
function check_form3(obj){
	if(obj.do_check.value=='T'){

			if(obj.inspection_date.value =='' || obj.inspection_date.value =='00-00-0000'){
				alert('Please Select the Inspection Date');
				obj.inspection_date.focus();
				return false;
			}	

			if(obj.present_inspection.value ==''){
				alert('Please fill the Individual(s) Present Upon Inspection');
				obj.present_inspection.focus();
				return false;
			}
			
			if(obj.observations.value ==''){
				alert('Please fill the Report');
				obj.observations.focus();
				return false;
			}			
	}
	
return true;	
}/////////////////////////////////////////////
function check_form4(obj){
	if(obj.do_check.value=='T'){
			if(obj.inspection_date.value =='' || obj.inspection_date.value =='00-00-0000'){
				alert('Please Select the Inspection Date');
				obj.inspection_date.focus();
				return false;
			}	


			if(obj.present_inspection.value ==''){
				alert('Please fill the Individual(s) Present Upon Inspection');
				obj.present_inspection.focus();
				return false;
			}				
		
			if(obj.product_description.value ==''){
				alert('Please fill the Product Description');
				obj.product_description.focus();
				return false;
			}				
		
			if(obj.b_use.value ==''){
				alert('Please select the building use');
				obj.b_use.focus();
				return false;
			}				
		
			if(obj.condition.value ==''){
				alert('Please select the building condition');
				obj.condition.focus();
				return false;
			}				
		
			if(obj.b_type.value ==''){
				alert('Please select the building type');
				obj.b_type.focus();
				return false;
			}				
		
			if(obj.trafic_count.value ==''){
				alert('Please select the trafic count');
				obj.trafic_count.focus();
				return false;
			}				
		
			if(obj.adults.value ==''){
				alert('Please fill the adults');
				obj.adults.focus();
				return false;
			}				
		
			if(obj.childrens.value ==''){
				alert('Please fill the childrens');
				obj.childrens.focus();
				return false;
			}				
		
			if(obj.pets.value ==''){
				alert('Please fill the pets');
				obj.pets.focus();
				return false;
			}				
			if(obj.subfloor.value ==''){
				alert('Please select the subfloor');
				obj.subfloor.focus();
				return false;
			}				
			if(obj.observations.value ==''){
				alert('Please fill the observations');
				obj.observations.focus();
				return false;
			}				
			if(obj.conclusion.value ==''){
				alert('Please fill the conclusion');
				obj.conclusion.focus();
				return false;
			}
	}
}

/////////////////////////////////////////////////
function check_areas(obj){
		if(obj.name.value ==''){
			alert('Please fill the name');
			obj.name.focus();
			return false;
		}				
	
		if(obj.code.value ==''){
			alert('Please fill the code');
			obj.code.focus();
			return false;
		}				
	
		if(obj.state.value ==''){
			alert('Please select the state');
			obj.state.focus();
			return false;
		}				
		
	return true;
}


///////////////////////////////////////////////////
function do_filter(obj){
	var value = new String(obj.value);
	var current = "";
	var counter =0;
	if(value!=''){
		if(value.length > 0){
			searchf.company_list.options.length = 0;
			for(i=0; i < keys_array.length; i++){
				current = new String(names_array[i]);
				current = current.toUpperCase();
				if(current.indexOf(value) >= 0 ){
				  var optionObject = new Option(names_array[i],keys_array[i])
				  var optionRank = searchf.company_list.options.length;
				  searchf.company_list.options[optionRank]=optionObject;
				  counter ++;		  
				}//if
			}//for
		}
		 searchf.company_list.size = counter ;
		 if(counter ==1){
			searchf.company_list.options.length =2 ;
		 }
	}//if
	else{
		searchf.company_list.options.length = 0;	
		searchf.company_list.size=0;
	}
}
////////////////////////////////////////////////
function layer_managment(modo){
	if(modo == 1){
		document.getElementById('Layer7').style.visibility= 'visible';
	}else{
		document.getElementById('Layer7').style.visibility= 'hidden';
	}			
}	
////////////////////////////////////////////////

function do_fill(obj){
	var value = new String(obj.value);
	if(value.length > 0){
		key = get_index(value);
		users.company.value= names_array[key];
		users.street.value  =street_array[key];
		users.pobox.value   =pobox_array[key];
		users.city.value  =city_array[key];		
		users.zipcode.value  =zipcode_array[key];	
		users.state.value  =state_array[key];

		users.area_phone.value  =aarea_phone_array[key];
		users.area_cell.value  =area_cell_array[key];
		users.area_fax.value  =area_fax_array[key];
		
		users.phone.value  =phone_array[key];
		users.fax.value  =fax_array[key];
		users.cell.value  =cell_array[key];	

		
		users.ship_street.value  =ship_street_array[key];
		users.ship_city.value  =ship_city_array[key];
		users.ship_state.value  =ship_state_array[key];	
		users.ship_zipcode.value  =ship_zipcode_array[key];	
		users.ext.value  =ext_array[key];	
		users.website.value  =website_array[key];			
		
		//users.ship_pobox.value  =ship_pobox_array[key];					
	}
}
////////////////////////////////////////////////

function do_fill_v2(value){
		key = get_index(value);
		users.company.value= names_array[key];
		users.street.value  =street_array[key];
		users.pobox.value   =pobox_array[key];
		users.city.value  =city_array[key];		
		users.zipcode.value  =zipcode_array[key];	
		users.state.value  =state_array[key];

		users.area_phone.value  =aarea_phone_array[key];
		users.area_cell.value  =area_cell_array[key];
		users.area_fax.value  =area_fax_array[key];
		
		users.phone.value  =phone_array[key];
		users.fax.value  =fax_array[key];
		users.cell.value  =cell_array[key];	

		
		users.ship_street.value  =ship_street_array[key];
		users.ship_city.value  =ship_city_array[key];
		users.ship_state.value  =ship_state_array[key];	
		users.ship_zipcode.value  =ship_zipcode_array[key];	
		users.ext.value  =ext_array[key];	
		users.website.value  =website_array[key];			
		
		//users.ship_pobox.value  =ship_pobox_array[key];					
}
////////////////////////////////////////////////

function check_caracter(){
	var key = event.keyCode;
    if (event.keyCode==13) { 
		do_fill(searchf.company_list);
	}
}
////////////////////////////////////////////////

function move_down(){
	var key = event.keyCode;
    if (event.keyCode==40 && users.company.value!='') { 
		searchf.company_list.focus();
	}
}
//////////////////////////////////////////////
function get_index(value){
	for(i=0; i < keys_array.length; i++){
		if(keys_array[i] == value)	
			return i;
	}
	return -1;
}

////////////////////////////////////////////
function confirm_action(command,param1,param2,param3){

	switch (command){
		case 'chk_del_fav' : {
			x = confirm("Are you sure you want to DELETE \nthis Inspector from your list?");	
			if(x){
				location.href='/core/misc.php?a=rf&idr='+param1;
			}	
		}
		break;
		
		case 'chk_add_fav' : {
			x = confirm("Are you sure you want to ADD \nthis Inspector to your list?");	
			if(x){
				location.href='/core/misc.php?a=af&t='+param1;
			}	
		}
		break;
		
		case 'chk_del_line' : {
			x = confirm("Are you sure you want to delete this line?");	
			if(x){
				//chk_del_line',".$row['id_bd'].",".$id_cr.",".$id_bm.")
				location.href="/core/misc.php?a=dline&id_bd="+param1+"&id_cr="+param2+"&id_bm="+param3;
			}	
		}		


		
		break;
		
		default  : alert('Validation Command Not Found');
	}
	
}
////////////////////////////////////////////

function openSpellChecker() {
	
	// example 1. 
	// Pass in the text inputs or textarea inputs that you 
	// want to spell-check to the object's constructor,
	// then call the openChecker() method.
	/*
	var text1 = document.form1.text1;
	var textarea1 = document.form1.textarea1;
	var speller = new spellChecker( text1, textarea1 );
	speller.openChecker();
	*/
	// example 2.
	// Rather than passing in the form elements to the object's
	// constructor, populate the object's textInputs property,
	// then call the openChecker() method.
	/*
	var speller = new spellChecker();
	var spellerInputs = new Array();
	for( var i = 0 ; i < document.form1.elements.length; i++ ) {
		if( document.form1.elements[i].type.match( /^text/ )) {
			spellerInputs[spellerInputs.length] = document.form1.elements[i];
		}
	}
	speller.textInputs = spellerInputs;
	speller.openChecker();
	*/

	// example 3.
	// use the spellCheckAll() method to check every text input
	// and textarea input in every form in the HTML document.
	// You can also use the checkTextBoxes() method or checkTextAreas()
	// method instead of spellCheckAll() to check only text inputs
	// or textarea inputs, respectively
	
	var speller = new spellChecker();
	speller.spellCheckAll();
	
	
}	
//////////////////////////////////////////////////////////////////////////
function check_add_line(obj){
	if(invoice_form.check_form.value  == "T"){
		if(obj.item.value==''){
			alert("Please fill the service name");	
			obj.item.focus();
			return false;
		}
		if(obj.description.value==''){
			alert("Please fill the description");	
			obj.description.focus();
			return false;
		}
		if(obj.amount.value==''){
			alert("Please fill the amount");	
			obj.amount.focus();
			return false;
		}	
    }else{
		if(obj.amount.value ==''){
			obj.amount.value=0;
		}
	}

	return true;
}

//////////////////////////////////////////////////////////////////////////
function check_add_line_auto(obj){

		
		
	if(obj.item.value ==''){
		alert('Please fill the item');
		obj.item.focus();
		return false;
	}				

	if(obj.description.value ==''){
		alert('Please fill the description');
		obj.description.focus();
		return false;
	}				

			
		
			
		
	if(obj.consumer.value ==''){
		alert('Please fill the consumer');
		obj.consumer.focus();
		return false;
	}				

	if(obj.dealer.value ==''){
		alert('Please fill the dealer');
		obj.dealer.focus();
		return false;
	}				

	if(obj.amount.value ==''){
		alert('Please fill the amount');
		obj.amount.focus();
		return false;
	}				

			if(isNaN(obj.amount.value) ){
				alert('amount must be a number');
				obj.amount.focus();
				return false;
			}	
	return true;
}
//////////////////////////////////////////////////////////////////////////
function save_cont(){
	invoice_form.check_form.value  = "F";
	invoice_form.amount.value =0;
}
//////////////////////////////////////////////////////////////////////////

function only_numbers(obj){
	var value = obj.value;
	var largo = value.length;
	
	if(isNaN(value) ){
		obj.value = value.substr(0,(largo-1));
	}
}
///////////////////////////////////////////////////
function format(precio){
	var Nprecio = new String(precio);
	var partes = Nprecio.split('.');
	var dec ="00";
	if(partes.length >1){
		dec = partes[1];
	}
	precio = partes[0];
	
	if(precio =='0.00'){
		return "$0.00";
	}
	if(dec ==''){
		dec="00";
	}
		
	if(precio.length > 6){
		p3 = precio.substr(precio.length-3,3);
		p2 = precio.substr(precio.length-6,3);
		p1 = precio.substr(0,(precio.length-6));	
		formated = "$"+p1+","+p2+","+p3;
	}
	else{
		if(precio.length > 3){
			p3 = precio.substr( (precio.length-3),3);
			p2 = precio.substr(0,(precio.length-3));	
			formated = "$"+p2+","+p3;	
		}else{
			if(precio != 0){
				formated = "$"+precio;
			}else{
				formated ="0";
			}	
		}
	}
	if(formated !='N/A'){
		formated +="."+dec;
	}			
	
	return formated;
}
///////////////////////////////////////////////////
function formatns(precio){
	var Nprecio = new String(precio);
	var partes = Nprecio.split('.');
	var dec ="00";
	if(partes.length >1){
		dec = partes[1];
	}
	precio = partes[0];
	
	if(precio =='0.00'){
		return "0.00";
	}
	if(dec ==''){
		dec="00";
	}
		
	if(precio.length > 6){
		p3 = precio.substr(precio.length-3,3);
		p2 = precio.substr(precio.length-6,3);
		p1 = precio.substr(0,(precio.length-6));	
		formated = p1+","+p2+","+p3;
	}
	else{
		if(precio.length > 3){
			p3 = precio.substr( (precio.length-3),3);
			p2 = precio.substr(0,(precio.length-3));	
			formated = p2+","+p3;	
		}else{
			if(precio != 0){
				formated = precio;
			}else{
				formated ="0";
			}	
		}
	}
	if(formated !='N/A'){
		formated +="."+dec;
	}			
	
	return formated;
}
//////////////////////////////////////
function check_payment(obj){
	if(obj.checkn.value==''){
		alert("Please fill the check number");	
		obj.checkn.focus();
		return false;
	}
	
	
	var cantidad = new Number(obj.cantidad.value);
	var ready = false;
	//alert(cantidad);
	if(cantidad > 1){
		for(i=0; i< cantidad; i++){
			cmd = "pay_amount = new Number(document.payment.amount_"+i+".value)";
			eval(cmd);
			if(pay_amount >0 ){
				ready = true;
			}
		}	
	}else{
			pay_amount = new Number(document.payment.amount_0.value);
			if(pay_amount >0 ){
				ready = true;
			}	
		}
	
	if(!ready){
		alert("Please fill the payment amount");	
		document.payment.amount_0.focus();
	}
	return ready;
}
//////////////////////////////////////
function show_pending(value){
	var url = 	"/movements.php?c="+value
	location.href=url;
}
///////////////////////////////////////
function check_movement(obj){
	if(obj.amount.value ==''){
		alert('Please fill the amount');
		obj.amount.focus();
		return false;
	}				

	if(isNaN(obj.amount.value) ){
		alert('the amount must be a number');
		obj.amount.focus();
		return false;
	}				

	var amount = new Number(obj.amount.value);
	var due = new Number(obj.pending.value);
	
	if(amount > due){
		x = confirm("The amount can't more than "+format(due)+"\nDo you want to fix it automaticly ?");
		if(x){
			obj.amount.value=due;
		}else{
			obj.amount.focus();
		}	
		return false;
	}	
	return true;
}
///////////////////////////////////
function check_item(obj){
		if(obj.name.value ==''){
			alert('Please fill the name');
			obj.name.focus();
			return false;
		}				
		
	return true;
}

///////////////////////////////////

function chech_manufacturer(obj){
		if(obj.name.value ==''){
			alert('Please fill the name');
			obj.name.focus();
			return false;
		}				
	
		if(obj.pobox.value =='' && obj.street.value ==''){
			alert('Please fill the pobox or street');
			obj.pobox.focus();
			return false;
		}				
			
	
		if(obj.city.value ==''){
			alert('Please fill the city');
			obj.city.focus();
			return false;
		}				
	
		if(obj.state.value ==''){
			alert('Please fill the state');
			obj.state.focus();
			return false;
		}				
	
		if(obj.zipcode.value ==''){
			alert('Please fill the zipcode');
			obj.zipcode.focus();
			return false;
		}				
	
		if(obj.phone_area.value ==''){
			alert('Please fill the phone area');
			obj.phone_area.focus();
			return false;
		}				
	
		if(obj.phone_number.value ==''){
			alert('Please fill the phone number');
			obj.phone_number.focus();
			return false;
		}				
			
		if(obj.mstatus.value ==''){
			alert('Please fill the mstatus');
			obj.mstatus.focus();
			return false;
		}				
		
	return true;
}
///////////////////////////////////

function chech_manufacturer_signup(obj){
		if(obj.name.value ==''){
			alert('Please fill the name');
			obj.name.focus();
			return false;
		}		
		if(obj.contact.value ==''){
			alert('Please fill the contact');
			obj.contact.focus();
			return false;
		}				
		
		if(obj.position.value ==''){
			alert('Please fill the position');
			obj.position.focus();
			return false;
		}

		if(obj.email.value ==''){
			alert('Please fill the email');
			obj.email.focus();
			return false;
		}

		if(obj.email.value != obj.email2.value ){
			alert("The email do not match");
			obj.email.focus();
			return false;
		}
		
		if(obj.phone_area.value ==''){
			alert('Please fill the phone area');
			obj.phone_area.focus();
			return false;
		}	
		
		if(obj.phone_number.value ==''){
			alert('Please fill the phone number');
			obj.phone_number.focus();
			return false;
		}		
		
		if(obj.pobox.value =='' && obj.street.value ==''){
			alert('Please fill the pobox or street');
			obj.pobox.focus();
			return false;
		}				
			
	
		if(obj.city.value ==''){
			alert('Please fill the city');
			obj.city.focus();
			return false;
		}				
	
		if(obj.state.value ==''){
			alert('Please fill the state');
			obj.state.focus();
			return false;
		}				
	

		if(obj.username.value ==''){
			alert('Please fill the username');
			obj.username.focus();
			return false;
		}	
		if(obj.password.value ==''){
			alert('Please fill the password');
			obj.password.focus();
			return false;
		}	
		
		if(obj.password.value =='' && obj.password2.value ==''){
			alert('The password do not match');
			obj.password.focus();
			return false;
		}				
		
		
	return true;
}

function check_number(obj){
		if(obj.last.value ==''){
			alert('Please fill the number');
			obj.last.focus();
			return false;
		}	
		
		if(isNaN(obj.last.value)){
			alert("The Starting Invoice Number must be a NUMBER without qoutes, spaces or letters");
			obj.last.focus();
			return false;
		}	
		
		return true;
}

function open_inspector_notes(inspector){
	var url= "/inspector_notes.php?i="+inspector;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=746,height=293');
	win_status.focus(); 
}
		
function unScramble(eMail1,eMail2,linkText,subjectText,statusText){
	var a,b,c,d,e;
	a=eMail1;
	c=linkText;
	b=eMail2.substring(0,eMail2.length-9);
	//alert(eMail2);
	if(subjectText!=""){
		d="?subject="+escape(subjectText);}else{d="";
	}
	if(statusText!=""){
		e=" onMouseOver=\"top.status=\'"+statusText+ "\'\;return true\;\" onMouseOut=\"top.status=\'\'\;return true\;\"";
	}
	else{
		e="";
	}
	//alert("<A HREF=\"mai"+"lto:"+a+"@"+b+d+"\""+e+">"+c+"</A>" );
	document.write("<A HREF=\"mai"+"lto:"+a+"@"+b+d+"\""+e+">"+c+"</A>");
}

function show_history(id_bm){ 
	var url= "/history.php?c="+id_bm;   
	var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=570,height=230');
	win_status.focus(); 
	//return false; 
}	

function validate_emails(mails){
	var maildirs = new String(mails);
	var mailsarray = maildirs.split(',');
	for(i=0; i < mailsarray.length; i++){
		var email = new String(mailsarray[i]);
		emailparts = email.split("@");
		if( (emailparts.length < 2) || (emailparts.length >= 3) ) {
			alert('The email: '+email+' Please check it');				
			return false;
		}else{
			usuario = new String(emailparts[0]);
			servidor = new String(emailparts[1]);
			if(usuario.length==0){
				alert('The email: '+email+' Please check it');				
				return false;
			}else{
				if(servidor.length==0){
				alert('The email: '+email+' Please check it');				
					return false;
				}else{
					servidorparts = servidor.split('.');
					if(servidorparts.length < 2){
					alert('The email: '+email+' Please check it');				
						return false;
					}//servidorparts
				}//servidor length	
			}//usuario.length
		}//emailparts.length
	}//for
	
	return true;
}

function show_sent(id_claim,id_client){
		var url= "/email_printer_friendly.php?cla="+id_claim+"&cli="+id_client;  
		var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=395,height=370');
		win_status.focus();	
	}
	
	



function checkscn(obj){
		if(obj.claim_number.value==''){
			alert("Plese indicate the claim number");
			obj.claim_number.focus();
			return false;
		}
		return true;
	}


	
	function checksi(obj){
		if(obj.dealer.value==''){
			alert("Plese indicate the dealer's name");
			obj.dealer.focus();
			return false;
		}
		return true;
	}		
		
	function checkcn(obj){ 
		if(obj.consumer.value==''){
			alert("Plese indicate the consumer's name");
			obj.consumer.focus();
			return false;
		}
		return true;
	}

	function checkdn(obj){
		if(obj.dealer.value==''){
			alert("Plese indicate the dealer's name");
			obj.dealer.focus();
			return false;
		}
		return true;
	}
	
	
	function show_history_payments(id){
		var url= "book_client_payments_history.php?c="+id;  
		var win_status = window.open(url,'notes','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=450,height=370');
		win_status.focus();
	}
	
	
	function check_claim_number(number,id_client){
		if(number !='' && id_client!=''){
			var url = "ajax_comps/check_claim_number.php?number="+number+"&id_client="+id_client;	
			//alert(url);
			do_ajax(url,'display_layer');
		}	
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	function save_field(field_name,field_value,id_client,id_claim){
		var field_value = new String(field_value);

		field_value = field_value.replace(/\n/g,"<br>");
		//field_value = field_value.replace(/\+/g,"%2B");	
		field_value = escape(field_value);		
		
		if(field_name !='' && field_value!='' && id_client !='' && id_claim!=''){
			var url = "/ajax_comps/update_report_field.php?field_name="+field_name+"&field_value="+field_value+"&id_client="+id_client+"&id_claim="+id_claim;	
			//do_ajax(url,'display_layer');
			//alert(url);
		}	
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	function save_inspection_date(id_client,id_claim){
		var date_install_day = document.myform.inspection_date_d.value ;
		var date_install_month = document.myform.inspection_date_m.value ;
		var date_install_year = document.myform.inspection_date_a.value ;
		var field_value = date_install_year+"-"+date_install_month+"-"+date_install_day;
		var field_name = "inspection_date";

		if(date_install_day !='' && date_install_month!='' && date_install_year!='' && id_client !='' && id_claim!=''){
			var url = "/ajax_comps/update_report_field.php?field_name="+field_name+"&field_value="+field_value+"&id_client="+id_client+"&id_claim="+id_claim;	
			//do_ajax(url,'display_layer');
		}	
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	function save_noticed_date(id_client,id_claim){
		var problem_noticed_m = document.myform.problem_noticed_m.value ;
		var problem_noticed_a = document.myform.problem_noticed_a.value ;
		var field_value = problem_noticed_a+"-"+problem_noticed_m+"-01";
		var field_name = "problem_noticed";

		if(problem_noticed_m !='' && problem_noticed_a!=''  && id_client !='' && id_claim!=''){
			var url = "/ajax_comps/update_report_field.php?field_name="+field_name+"&field_value="+field_value+"&id_client="+id_client+"&id_claim="+id_claim;	
			//do_ajax(url,'display_layer');
		}	
	}	
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	function save_date_install(id_client,id_claim){
		var date_install_month = document.myform.instalation_m.value ;
		var date_install_year = document.myform.instalation_a.value ;
		var field_value = date_install_year+"-"+date_install_month+"-01";
		var field_name = "date_installed";
		
		if( date_install_month!='' && date_install_year!='' && id_client !='' && id_claim!=''){
			var url = "/ajax_comps/update_claim_field.php?field_name="+field_name+"&field_value="+field_value+"&id_client="+id_client+"&id_claim="+id_claim;	
			//do_ajax(url,'display_layer');
		}	
	}	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	function save_claim_field(field_name,field_value,id_client,id_claim){
		var field_value = new String(field_value);
		field_value = escape(field_value);

		
		
		if(field_name !='' && field_value!='' && id_client !='' && id_claim!=''){
			var url = "/ajax_comps/update_claim_field.php?field_name="+field_name+"&field_value="+field_value+"&id_client="+id_client+"&id_claim="+id_claim;	
			//do_ajax(url,'display_layer');
			//alert(url);
		}	
	}	
