function extraeModels(iObj){
  wCadRet=ExtractInfo("ModulMag.asp?SData=1&SMarca=" + iObj.value,true,false);
  document.getElementById("LModel").innerHTML=wCadRet;
}
function extraeDecrip(){
  var iMarca=document.getElementById("iMarca").value;
  var iModelo=document.getElementById("iModelo").value;  
  wCadRet=ExtractInfo("ModulMag.asp?SData=2&SMarca=" + iMarca +"&SModelo=" + iModelo ,true,false);
  document.getElementById("LDescr").innerHTML=wCadRet;
}

function ValidateStep2(){
  if(document.getElementById("iMarca").value==''){alert("Es necesario seleccionar una marca para poder continuar..");return;}
  if(document.getElementById("iModelo").value=='-1'){alert("Es necesario seleccionar un modelo para poder continuar..");return;}
  if(document.getElementById("iDescrip").value==''){alert("Es necesario seleccionar un vehiculo para poder continuar..");return;}
   document.forma.submit();
}

function ShowAllOptions(NameObj){
   var TTable=document.getElementById(NameObj);var TRow=TTable.rows;
   for (var j=3;j<=TRow.length-2;j++){TRow[j].style.display=((TRow[j].style.display=='')?'none':''); }
   var iImg=document.getElementById("Img" + TTable.id); iImg.src="images/"+  ((TRow[3].style.display=='')?'BtUp.gif':'BtDown.gif')  ;
}

function CreaCot(iNumCot){
 document.getElementById("iDataCotSel").value=document.getElementById("InpCot" +iNumCot).value;
 document.forma.submit();
}
function CheckUser(){
  if(document.forma.IdCli.value!=""){  // Trae ya el cliente
     document.forma.action="pantallaC1.asp";document.forma.submit();return;
  }
  CreateMask("NUser");
  var ICadHTML="";
  var wTop=((document.documentElement.clientHeight/2)-200) + document.documentElement.scrollTop ;
  /*Crea el Div Para el Mensaje  */
  var iDialogAlert = document.createElement('div');iDialogAlert.id = 'ElementReg';iDialogAlert.className='dialogReg'; 
  iDialogAlert.style.left=parseInt((document.documentElement.clientWidth/2)-200) +'px';  iDialogAlert.style.top =wTop +'px';  
  ICadHTML="<table border='0' cellpadding='0' cellspacing='0' class='TableDes'>";
  ICadHTML+="<tr><td width='100%' colspan='2' align='center'><img src='images/registrado.jpg'/></td></tr>";
  ICadHTML+=" <tr><td width='50%' align='center'><a href='javascript:Descision(1)'><img src='images/si.jpg'/></a></span></td>"
  ICadHTML+="<td width='50%' align='center'><a href='javascript:Descision(0)'><img src='images/no.jpg'/></a></span></td></tr></table>";
  iDialogAlert.innerHTML=ICadHTML;
  document.body.appendChild(iDialogAlert);
  /*SE COLOCO IMAGEN DE SI Y NO NUEVA   JAVIER MAG */
}
function Descision(NumDesc){
   KillMask("NUser");
   document.body.removeChild(document.getElementById('ElementReg'));
   if(NumDesc==0){document.forma.action="pantalla8.asp"; }else{document.forma.action="pantalla7.asp";}
   document.forma.submit();
}
function CreateMask(iName,ZIndexOpt){
    var NameI=((typeof iName!='undefined')?iName:''); var iHeight=document.body.clientHeight;
    dialogmask = document.createElement('div');dialogmask.id = 'dialog-mask_' + NameI;dialogmask.className='dialogmask'; 
    dialogmask.style.height = iHeight + 'px';  dialogmask.style.width =document.documentElement.clientWidth + 'px';    
    document.body.appendChild(dialogmask);      
} 
function KillMask(iName){
    var NameI=((typeof iName!='undefined')?iName:'');
    if(document.getElementById('dialog-mask_'+NameI)) {       
       document.body.removeChild(document.getElementById('dialog-mask_'+NameI));  
   }
}

function registerUser(){
  if(document.form1.Nombre.value==""){alert("Nombre, Dato Requerido..");return;}  
  if(document.form1.Apellido_paterno.value==""){alert("Apellido Paterno, Dato Requerido..");return;}
  if(document.form1.Usuario.value==""){alert("Usuario, Datos Requerido..");return;}
  if(document.form1.Password.value==""){alert("Password, Datos Requerido..");return;}
  if(!document.form1.Politicas.checked){alert("Es necesario aceptar las politicas de uso..");return;}  
  var iParams=ReturnAllFields(document.form1);
  var iCadRet=SaveToDB("ModulMag.Asp?SData=4",iParams,false);
  if (iCadRet=="OK"){
     document.form1.action="savedata.asp"; document.form1.submit();
  }else{
     alert("Lo siento el usuario que desea utilizar ya existe, por favor escriba uno diferente...");
  }  
}

function registerUser_n(){
  if(document.form1.Nombre.value==""){alert("Nombre, Dato Requerido..");return;}  
  if(document.form1.Apellido_paterno.value==""){alert("Apellido Paterno, Dato Requerido..");return;}
  if(document.form1.Usuario.value==""){alert("Usuario, Datos Requerido..");return;}
  if(document.form1.Password.value==""){alert("Password, Datos Requerido..");return;}
  if(!document.form1.Politicas.checked){alert("Es necesario aceptar las politicas de uso..");return;} 
  if(document.form1.imagentexto.value!=document.form1.Restexto.value)
     {
	  alert("El caracter capturado es incorrecto");document.form1.action="pantalla8.asp"; document.form1.submit();return;
	  }
	 else
{	 
  var iParams=ReturnAllFields(document.form1);
  var iCadRet=SaveToDB("ModulMag.Asp?SData=4",iParams,false);
  if (iCadRet=="OK"){
     document.form1.action="savedata.asp"; document.form1.submit();
  }else{
     alert("Lo siento el usuario que desea utilizar ya existe, por favor escriba uno diferente...");
  }
}
}

function CheckVerify(iValue){
  var iParam=ReturnAllFields(document.form1)
  var WCadRet=SaveToDB("ModulMag.Asp?SData=3",iParam,false);
  if (WCadRet=="0"){
     alert("Lo siento, es necesario proporcionar un usuario correcto...");
  }else{
     if (iValue==0){document.form1.action="PantallaC1.asp"; document.form1.submit();}else{ document.form1.IdCli.value=WCadRet; document.form1.action="MiCuenta.asp"; document.form1.submit();}}  
}

function ProcesarNP(){
	if (document.getElementById("user").value==""){alert('El usuario está vacio.');return;}	
	if (document.getElementById("correoelec").value==""){alert('El correo electronico está vacio');return;}
	var iParam=ReturnAllFields(document.formnc);
	var iCardRet=SaveToDB("ModulMag.asp?SData=5",iParam,false)
  if (iCardRet=="2"){
     alert("Tu Password se te ha enviado a tu correo electronico");document.formnc.action="index.asp"; document.formnc.submit();return;
  }else{
     alert("Los datos no concuerdan con los registrados, por favor intentelo mas tarde.");return;
  }

}

function showPart(NumDiv,Enc){
   document.getElementById("Part"+NumDiv).style.display=((Enc==1)?"block":"none");
}
function CheckRegOne(){
   if(document.form1.Serie.value==""){alert("Es necesario escribir el no. de serie.");return;}
   if(!confirm("Estas seguro que deseas continuar? (Confirma que tus datos sean correctos)")){
      return;
   }else{
      document.form1.action="SaveData2.asp"; document.form1.submit();	  
   }      
}
function CheckRegTwo(){
  var PassTC=true;
  if(document.form1.TipoCob.value=="1"){
     for(var j=1;j<=18;j++){if(document.getElementById("C" + j).value==""){PassTC=false;break;}}
  }else{
     for(var j=1;j<=4;j++){if(document.getElementById("NC" + j).value==""){PassTC=false;break;}}
  }
  if(!PassTC){alert("es necesario proporcionar correctamente los datos..");return;}
  document.form1.action="SaveData3.asp"; document.form1.submit();
}

function CambTVenta(iObj){
 var IValue=iObj.value;
 var iValN=((IValue==0)?1:0);
 document.getElementById("TCobro" + IValue).style.display="block";
 document.getElementById("TCobro" + iValN).style.display="none";
}

/*  Functiones de Mag title  */
function GetThis(T, C, U, L)
{
    var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T)
    + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
    window.open(targetUrl);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*************************** Funciones de Mi Cuenta**************** */
function OpenMisCot(){
  var iCli=document.getElementById("IdCli").value;
  var iCadRet=ExtractInfo("ModulMag2.asp?TInfo=0&IdCli=" + iCli,true,false);
  document.getElementById("containerACount").innerHTML=iCadRet; 
}
function OpenMisPol(){
  var iCli=document.getElementById("IdCli").value;
  var iCadRet=ExtractInfo("ModulMag2.asp?TInfo=2&IdCli=" + iCli,true,false);
  document.getElementById("containerACount").innerHTML=iCadRet; 
}
function OpenMisDatas(){
  var iCli=document.getElementById("IdCli").value;
  var iCadRet=ExtractInfo("ModulMag2.asp?TInfo=5&IdCli=" + iCli,true,false);  
  document.getElementById("containerACount").innerHTML=iCadRet; 
}
function NewCotiza(){document.MiCta.action="Pantalla2.asp"; document.MiCta.submit();}
function AsegCotiza(idCot){
  document.MiCta.IDCotWeb.value=idCot;document.MiCta.action="PantallaC1.asp"; document.MiCta.submit();
}

function GuardaCambios(){
  if (document.MiCta.NameUser.value==''){alert("Es requerido el nombre de usuario ...");return;}
  if (document.MiCta.EMail.value==''){alert("Es requerido el correo electronico...");return;}  
  if (document.MiCta.PassUser.value!=document.MiCta.PassUser2.value || document.MiCta.PassUser.value==''){alert("La contraseña es incorrecta...");return;}
  var iCli=document.getElementById("IdCli").value;
  var iParam=ReturnAllFields(document.MiCta);
  var iCardRet=SaveToDB("ModulMag2.asp?TInfo=6&IdCli="+iCli,iParam,false)
  if (iCardRet=="OK"){
     alert("Informacion actualizda..");
  }else{
     alert("Ocurrio un error al actualizar los datos, por favor intentelo mas tarde...");
  }
}
function OpenDetailCot(idCot){
  CreateMask("nInfoData");
  var ICadHTML="";
  var wTop=((document.documentElement.clientHeight/2)-200) + document.documentElement.scrollTop ;
  /*Crea el Div Para el Mensaje  */
  var iDialogAlert = document.createElement('div');iDialogAlert.id = 'ElementReg';iDialogAlert.className='dialogReg'; 
  iDialogAlert.style.left=parseInt((document.documentElement.clientWidth/2)-200) +'px';  iDialogAlert.style.top =wTop +'px';    
  /*-------------------------------------*/
  var ICadHTML=ExtractInfo("ModulMag2.asp?TInfo=1&IdCot=" + idCot,true,false);
  iDialogAlert.innerHTML=ICadHTML;
  document.body.appendChild(iDialogAlert);
}
function OpenDetailPol(NPol){
  CreateMask("nInfoData");
  var ICadHTML="";
  var wTop=((document.documentElement.clientHeight/2)-200) + document.documentElement.scrollTop ;
  /*Crea el Div Para el Mensaje  */
  var iDialogAlert = document.createElement('div');iDialogAlert.id = 'ElementReg';iDialogAlert.className='dialogReg'; 
  iDialogAlert.style.left=parseInt((document.documentElement.clientWidth/2)-200) +'px';  iDialogAlert.style.top =wTop +'px';    
  /*-------------------------------------*/
  var ICadHTML=ExtractInfo("ModulMag2.asp?TInfo=3&NPol=" + NPol,true,false);
  iDialogAlert.innerHTML=ICadHTML;
  document.body.appendChild(iDialogAlert);
}
function OpenDetailCob(iPolNum){
  CreateMask("nInfoData");
  var ICadHTML="";
  var wTop=((document.documentElement.clientHeight/2)-200) + document.documentElement.scrollTop ;
  /*Crea el Div Para el Mensaje  */
  var iDialogAlert = document.createElement('div');iDialogAlert.id = 'ElementReg';iDialogAlert.className='dialogReg'; 
  iDialogAlert.style.left=parseInt((document.documentElement.clientWidth/2)-200) +'px';  iDialogAlert.style.top =wTop +'px';    
  /*-------------------------------------*/
  var ICadHTML=ExtractInfo("ModulMag2.asp?TInfo=4&NPol=" + iPolNum,true,false);
  iDialogAlert.innerHTML=ICadHTML;
  document.body.appendChild(iDialogAlert);
}
function CloseDetail(){
   document.body.removeChild(document.getElementById('ElementReg'));
   KillMask("nInfoData");
}
