function majax()
		{
			var objetoAjax=false;
			try{
					objetoAjax=new ActiveXObject("Msxml2.XMLHTTP");
					//alert(objetoAjax);
			   }
			 catch(e)  
			 	{
					try{
							objetoAjax=new ActiveXObject("Microsoft.XMLHTTP");
						}
					catch(E){objetoAjax=false;}	
				}
			if(!objetoAjax&& typeof XMLHttpRequest!='undefined'){objetoAjax= new XMLHttpRequest();}	
			
			return objetoAjax;
		}
	
function num_veh(valor, section)
{	
	url='php_num_veh.php';
	var contenedor=document.getElementById('cont_section'+section);										
	ajax=majax();
	//alert(document.getElementById('helpme').value);
	switch(document.getElementById('helpme').value){
		case '1': ajax.open('get','contacto/'+url+'?num_veh='+valor+'&section='+section,true); break;
		case '2': ajax.open('get','../contacto/php_num_veh.php?num_veh='+valor+'&section='+section,true);break;
		default: ajax.open('get',url+'?num_veh='+valor+'&section='+section,true);break;
	}
	/*
	if(document.getElementById('helpme')=='1'){
		
	}else{
		ajax.open('get',url+'?num_veh='+valor+'&section='+section,true);
	}
	*/
	ajax.onreadystatechange=function(){
				if(ajax.readyState==4)
					{	contenedor.innerHTML+='Cargando ...';
						if(ajax.status==200)
							{		
								contenedor.innerHTML=ajax.responseText;																	
							}
						else
							{      
								   contenedor.innerHTML+='Cargando ...';
							}	
					}
			}
ajax.send(null);
}

function license_qst(valor)
{
var div_si = document.getElementById('license_yes');
var div_no = document.getElementById('license_no');
var document_number = document.getElementById('document_number');

	if(valor==1){
		div_no.style.display = 'none';
		div_si.style.display = 'block';
	}
	else if(valor==0 && valor!=''){	
		document_number.value = '';
		div_si.style.display = 'none';
		div_no.style.display = 'block';
	}
	else{
		div_si.style.display = 'none';
		div_no.style.display = 'none';
	}
}

function show_add_drivers(valor)
{
var div_si = document.getElementById('add_drivers_1');
var hidden = document.getElementById('number_add_drivers');
var content_total = document.getElementById('content_add_drivers');
var label_question1 = document.getElementById('label_question1');

	if(valor==1){		
		div_si.style.display = 'block';
		label_question1.innerHTML='<div class=\"left\">&iquest;Desea agregar otro conductor?:</div><div class=\"right\"><select name=\"driver16_question1\" id=\"driver16_question1\" onchange=\"javascript:add_drivers(this.value, 1)\"><option value=\"\">---</option><option value=\"1\">Si</option><option value=\"0\">No</option></select></div><div class=\"clear\"></div>';
		if(hidden.value=='')hidden.value = 1;
	}
	else{		
		div_si.style.display = 'none';
		hidden.value = '';
		content_total.innerHTML='';
	}
}

function add_drivers(valor, inicial)
{
	if(valor==1){		 
		var fname = document.getElementById('driver16_fname'+inicial);
		var lname = document.getElementById('driver16_lname'+inicial);
		var month = document.getElementById('driver16_month'+inicial);
		var day = document.getElementById('driver16_day'+inicial);
		var year = document.getElementById('driver16_year'+inicial);
		var relationship = document.getElementById('driver16_relationship'+inicial);
		var question = document.getElementById('driver16_question'+inicial);
		var label_question = document.getElementById('label_question'+inicial);
		var hidden = document.getElementById('number_add_drivers');
		
		if(fname.value!='' && lname.value!='' && month.value!='' && day.value!='' && year.value!='' && relationship.value!='')
		{
			url='php_add_drivers.php';
			var nuevo = inicial+1;
			if (inicial == 1)
				var contenedor=document.getElementById('content_add_drivers');
			else if (inicial > 1)
				var contenedor=document.getElementById('content_add_'+nuevo);
				
			ajax=majax();
			
	/*switch(document.getElementById('helpme').value){
		case '1': ajax.open('get','contacto/'+url+'?num_veh='+valor+'&section='+section,true); break;
		case '2': ajax.open('get','../contacto/php_add_drivers.php?num_veh='+valor+'&section='+section,true);break;
		default: ajax.open('get',url+'?num_veh='+valor+'&section='+section,true);break;
	}*/
	switch(document.getElementById('helpme').value){
		case '1': url='contacto/php_add_drivers.php';break;
		case '2': url='../contacto/php_add_drivers.php';break;
		default: url='php_add_drivers.php';break;
	}
	
			ajax.open('get',url+'?inicial='+inicial,true);
			ajax.onreadystatechange=function(){
						if(ajax.readyState==4)
							{	
								if(ajax.status==200)
									{		
										contenedor.innerHTML=ajax.responseText;
										label_question.innerHTML='&nbsp;';
										hidden.value = nuevo;
									}							
							}
					}
			ajax.send(null);
		}
		else
		{
			alert('Primero complete la información del Conductor'+inicial);
			question.selectedIndex = 0;			
		}

	}	
}

function show_house_itself(valor)
{
var div_si = document.getElementById('label_residence_time');
	if(valor==1){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function show_credit_card(valor)
{
var div_si = document.getElementById('label_credit_card');
	if(valor==1){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function show_bank_account(valor)
{
var div_si = document.getElementById('label_bank_account');
	if(valor==1){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function show_insurance_policy(valor)
{
var div_si = document.getElementById('insurance_policy_yes');
var div_no = document.getElementById('insurance_policy_no');
	if(valor==1){
		div_no.style.display = 'none';
		div_si.style.display = 'block';
	}
	else if(valor==0 && valor!=''){		
		div_si.style.display = 'none';
		div_no.style.display = 'block';
	}
	else{
		div_si.style.display = 'none';
		div_no.style.display = 'none';
	}
}

function show_email_notify(valor)
{
var div_si = document.getElementById('label_email_notify');
	if(valor==1){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function show_govern_org(valor)
{
var div_si = document.getElementById('label_govern_org');
	if(valor==1){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function show_insurance_medical(valor)
{
var div_si = document.getElementById('label_insurance_medical');
	if(valor==1){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function question8(valor)
{
var div_si = document.getElementById('question8');
	if(valor==44 || valor==46){		
		div_si.style.display = 'block';		
	}
	else{		
		div_si.style.display = 'none';
	}
}

function abrirVentana(ancho, alto, url)
{
var sHeight, sWidth;
sHeight = screen.height;
sWidth = screen.width;
var sLeft, sTop;
sLeft=(screen.width - ancho) / 2;
sTop=(screen.height - alto) / 2;
window.open(url, '_blank','top='+sTop+', left='+sLeft+', height='+alto+', width='+ancho+', status=no, menubar=no, resizable=no, scrollbars=yes, toolbar=no, location=no, directories=no');
}



/*funcion creada para los tracking de partner para controlar por tabs el ingreso de leads*/
function trackPartner(){

    url='../contacto/tracking.php';
	var contenedor=document.getElementById('cont_tracking');										
	ajax=majax();
 if(document.getElementById('trackingPartner').value==0){

	ajax.open('get',url+'',true);
	ajax.onreadystatechange=function(){
				if(ajax.readyState==4)
					{	//contenedor.innerHTML+='Cargando ...';
						if(ajax.status==200)
							{		
								contenedor.innerHTML=ajax.responseText;	
								document.getElementById('trackingPartner').value=1;								
								//alert("tracking...");															
							}
						else
							{      
								  contenedor.innerHTML+='';
								  // alert("tracking no...");		
							}	
					}
			}
  ajax.send(null);
 }

}
