function cotizar(valor){
	$("#curso").fadeOut("fast"); 
	//$("#detalle").fadeOut("fast"); 
	noCache = new Date().getTime();					
	      $.ajax({
		   type: "POST",
		   url: "capacitacion_contacto.asp?nocache=" + noCache + "&id_curso=" + valor,
		   success: function( msg )
		   { 
			  $("#curso").html(  msg );	
			   $("#curso").fadeIn("slow");
		   }
		   ,error: function( msg )
		   {
	    
		   alert('Error contacte con su administrador')
		   }
		   
		  });
	
}


function cerrar_ventana(valor){
	switch (valor) { 
   	case 1: 
      	 $("#detalle").fadeOut("fast"); 
      	 break 
	case 2: 
      	 $("#curso").fadeOut("fast"); 
      	 break 
   	default: 
      	 alert("La Sección no se pudo ocultar"); 
	} 
	
}
function ocultar_listado(valor){
		$("#detalle").fadeOut("fast",mostrar_listado(valor));
		
}
function mostrar_listado(valor_linea){
//  1=VOLVO // 2=MANITOU  //  3=TOYOTA	
	//$("#detalle").fadeOut("fast");
	noCache = new Date().getTime();					
	      $.ajax({
		   type: "POST",
		   url: "detalle_linea.asp?nocache=" + noCache + "&id_linea=" + valor_linea,
		   success: function( msg )
		   { 
			  $("#detalle").html(  msg );	
			   $("#detalle").fadeIn("slow");
		   }
		   ,error: function( msg )
		   {
	    
		   alert('Error contacte con su administrador')
		   }
		   
		  });
	
	}

function mostrar_curso(valor){
	 $("#curso").fadeOut("fast");
	noCache = new Date().getTime();					
	      $.ajax({
		   type: "POST",
		   url: "curso.asp?nocache=" + noCache + "&id_curso=" + valor,
		   success: function( msg )
		   
		   { 
			  $("#curso").html(  msg );	
			   $("#curso").fadeIn("slow");
		   }
		   ,error: function( msg )
		   {
	    
		   alert('Error contacte con su administrador')
		   }
		   
		  });
	}
//**********************************************************************************************
// JavaScript Document
//**********************************************************************************************
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];}
}


function despliegueServicio(target){
	jQuery("#descripcion"+antiguo).css( "display", "none" );
	jQuery("#descripcion"+target).css( "display", "block" );
	
	antiguo=target;
}

function despliegueModelos(target,primermodel){
	
	if(target != antiguomodelo){
		jQuery("#detallemodelo"+antiguodetalle).css( "display", "none" );
		jQuery("#detallemodelo"+primermodel).css( "display", "block" );
		
		jQuery("#modelos"+antiguomodelo).css( "display", "none" );
		jQuery("#modelos"+target).css( "display", "block" );
		jQuery("#maquinas"+antiguomodelo).attr( "bgcolor", "#cccccc" )
		jQuery("#maquinas"+target).attr( "bgcolor", "#ffffff" ) 
		antiguodetalle=primermodel;
		antiguomodelo=target;
	}
}

function despliegueDetalle(target){
	if(target != antiguodetalle){
		jQuery("#detallemodelo"+antiguodetalle).css( "display", "none" );
		jQuery("#detallemodelo"+target).css( "display", "block" );
		/*jQuery("#maquinas"+antiguodetalle).attr( "bgcolor", "#cccccc" )
		jQuery("#maquinas"+target).attr( "bgcolor", "#ffffff" ) */
	}	
		antiguodetalle=target;	
	
}

function Mensaje(valor)
{
 if(valor==1)
 {
   csscody.alert('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Concurso SKCM</b><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ahora estas Participando en Nuestro Concurso <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Buena Suerte..!!!');return false;
 }
 if(valor==2)
 {
   csscody.alert('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Cotizacion SKCM</b><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nos contactaremos con Ud. a la brevedad <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');return false;
 }	
}

function despliegueUsados(target){
	jQuery("#cuadroRojo").css( "display", "block" );
	jQuery("#cate"+cateold).css( "display", "none" );
	jQuery("#cate"+target).css( "display", "block" );
	cateold=target;
}

String.prototype.isEmail=function() {
	var emailReg =/^[a-z][a-z0-9_\.\-]+@[a-z0-9_\.\-]+\.[a-z][a-z][a-z]?$/i;			
	return emailReg.test(this);
}
String.prototype.trim=function() {
	return this.replace(/^\s+|\s+$/g,'');
}
String.prototype.ltrim=function() {
	return this.replace(/^\s+/,'');
}
String.prototype.rtrim=function() {
	return this.replace(/\s+$/,'');
}


function validarCiente(){
	
	
	var error=new Array();
	if (jQuery.trim(jQuery('#nombre').val()) == ''){
		error.push("Ingrese Nombre");
		alert("Ingrese Nombre")
	}
	if (jQuery.trim(jQuery('#apellido').val()) == ''){
		error.push("Ingrese apellido");
		alert("Ingrese apellido")
	}
	if (jQuery.trim(jQuery('#rut').val()) == ''){
		error.push("Ingrese Rut");
		alert("Ingrese rut")
	}
	if (jQuery.trim(jQuery('#cargo').val()) == ''){
		error.push("Ingrese cargo");
		alert("Ingrese cargo")
	}
	if (jQuery.trim(jQuery('#telefono').val()) == ''){
		error.push("Ingrese telefono");
		alert("Ingrese telefono")
	}
	
	if (jQuery.trim(jQuery('#mail').val()) == ''){
		error.push("Ingrese mail");
		alert("Ingrese mail")
	}
	if (jQuery.trim(jQuery('#empresa').val()) == ''){
		error.push("Ingrese empresa");
		alert("Ingrese empresa")
	}
	if (jQuery.trim(jQuery('#rutemp').val()) == ''){
		error.push("Ingrese Rut Empresa");
		alert("Ingrese Rut Empresa")
	}
	if (jQuery.trim(jQuery('#direccion').val()) == ''){
		error.push("Ingrese direccion");
		alert("Ingrese direccion")
	}
	
	
	var email;
	email=jQuery.trim(jQuery('#mail').val());
	if(email.isEmail()){
	}else{
		error.push("Ingrese  Mail Valido");
		alert("Ingrese  Mail Valido")
	}
	 
	 var rute; 
	 rute='rut';
	 if (!valida_rut(rute))
	  {	
	   error.push("Ingrese  Rut Valido");
	   alert("Ingrese  Rut Valido")
	  }
     var rute2; 
	 rute2='rutemp';
	 if (!valida_rut(rute))
	  {	
	   error.push("Ingrese  Rut Empresa Valido");
	   alert("Ingrese  Rut Empresa Valido")
	  }
	 
	
	if(error.length > 0){
        return false;
    }else{
	
        return true;
    }
    
    return false;

}
function validarCiente_2(){
	
	
	var error=new Array();
	if (jQuery.trim(jQuery('#nombre').val()) == ''){
		error.push("Ingrese Nombre");
		alert("Ingrese Nombre")
	}
	if (jQuery.trim(jQuery('#apellido').val()) == ''){
		error.push("Ingrese apellido");
		alert("Ingrese apellido")
	}
	
	if (jQuery.trim(jQuery('#cargo').val()) == ''){
		error.push("Ingrese cargo");
		alert("Ingrese cargo")
	}
	if (jQuery.trim(jQuery('#telefono').val()) == ''){
		error.push("Ingrese telefono");
		alert("Ingrese telefono")
	}
	
	if (jQuery.trim(jQuery('#mail').val()) == ''){
		error.push("Ingrese mail");
		alert("Ingrese mail")
	}
	if (jQuery.trim(jQuery('#empresa').val()) == ''){
		error.push("Ingrese empresa");
		alert("Ingrese empresa")
	}
	if (jQuery.trim(jQuery('#rutemp').val()) == ''){
		error.push("Ingrese Rut Empresa");
		alert("Ingrese Rut Empresa")
	}
	if (jQuery.trim(jQuery('#direccion').val()) == ''){
		error.push("Ingrese direccion");
		alert("Ingrese direccion")
	}
	
	
	var email;
	email=jQuery.trim(jQuery('#mail').val());
	if(email.isEmail()){
	}else{
		error.push("Ingrese  Mail Valido");
		alert("Ingrese  Mail Valido")
	}
	 
	
     var rute2; 
	 rute2='rutemp';
	 if (!valida_rut(rute2))
	  {	
	   error.push("Ingrese  Rut Empresa Valido");
	   alert("Ingrese  Rut Empresa Valido")
	  }
	 
	
	if(error.length > 0){
        return false;
    }else{
	
        return true;
    }
    
    return false;

}

function valida_rut( obj )
{
	
	var Objeto=eval(document.getElementById(obj));
	var tmpstr = "";
	var intlargo = Objeto.value
	if (intlargo.length> 0)
	{
		crut = Objeto.value
		largo = crut.length;
		if ( largo <2 )
		{
			//alert('rut inválido')
			//Objeto.focus()
			return false;
		}
		for ( i=0; i <crut.length ; i++ )
		if ( crut.charAt(i) != ' ' && crut.charAt(i) != '.' && crut.charAt(i) != '-' )
		{
			tmpstr = tmpstr + crut.charAt(i);
		}
		rut = tmpstr;
		crut=tmpstr;
		largo = crut.length;
	
		if ( largo> 2 )
			rut = crut.substring(0, largo - 1);
		else
			rut = crut.charAt(0);
	
		dv = crut.charAt(largo-1);
	
		if ( rut == null || dv == null )
		return 0;
	
		var dvr = '0';
		suma = 0;
		mul  = 2;
	
		for (i= rut.length-1 ; i>= 0; i--)
		{
			suma = suma + rut.charAt(i) * mul;
			if (mul == 7)
				mul = 2;
			else
				mul++;
		}
	
		res = suma % 11;
		if (res==1)
			dvr = 'k';
		else if (res==0)
			dvr = '0';
		else
		{
			dvi = 11-res;
			dvr = dvi + "";
		}
	
		if ( dvr != dv.toLowerCase() )
		{
			//alert('El Rut Ingreso es Invalido')
			//Objeto.focus()
			return false;
		}
		//alert('El Rut Ingresado es Correcto!')
		//Objeto.focus()
		return true;
	}
}




function validarContacto(){
	var error=new Array();
	if (jQuery.trim(jQuery('#nombre').val()) == ''){
		error.push("Ingrese un Nombre de usuario");
	}
	if (jQuery.trim(jQuery('#empresa').val()) == ''){
		error.push("Ingrese un Nombre de Empresa");
	}
	if (jQuery.trim(jQuery('#mail').val()) == ''){
		error.push("Ingrese un Mail Valido");
	}
	var email;
	email=jQuery.trim(jQuery('#mail').val());
	if(email.isEmail()){
	}else{
		error.push("Ingrese un Mail Valido");	
	}
	
	if (jQuery.trim(jQuery('#comentarios').val()) == ''){
		error.push("Ingrese un Comentario");
	}
	if(error.length > 0){
        return false;
    }else{
	
        return true;
    }
    
    return false;

}
