function valida() {
	var continuar = 1;
	var mensaje = 'Completa los campos';
	if($('#paterno').val() == '') {
		continuar = 0;
	}
	if($('#materno').val() == '') {
		continuar = 0;
	}
	if($('#nombre').val() == '') {
		continuar = 0;
	}
	if($('#mail').val() != '') {
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($('#mail').val()))){
			continuar = 0;
			mensaje += "\nEl campo E-mail no es valido\n";
		}
	}
	if($('#telefono').val() == '') {
		continuar = 0;
	}
	if($('#pais').val() == '') {
		continuar = 0;
	}
	if($('#comentario').val() == '') {
		continuar = 0;
	}
	
	if(continuar == 1) {
		document.forms[0].submit();
	} else {
		alert(mensaje);
		return false;
	}
}

function mostrar(id) {
	$('#submenu-principal').show();
}

function nuevoAjax() { 
	var xmlhttp=false;
	try{
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E){
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

function estados(id) {
	var ajax=nuevoAjax();
	ajax.open("POST", 'estados.asp?pais_id='+id, true);
		
	ajax.onreadystatechange=function() { 
		if (ajax.readyState==1){ }
		if (ajax.readyState==4){
			document.getElementById('contiene-estados').innerHTML = ajax.responseText;
		} 
	}
	ajax.send(null);
}

function r_imagen(img) {
	$('#imagen').attr("src", img);
}

function cambio_info(ocultar, mostrar) {
	var o1 = '.'+ocultar;
	var o2 = '#'+mostrar;
	$(o1).hide();
	$(o2).hide();
	var m1 = '.'+mostrar;
	var m2 = '#'+ocultar;
	$(m1).show();
	$(m2).show();
}

function checkS(e){
	var posx = 0;
	var posy = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY)
    {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
        posx = e.clientX;
        posy = e.clientY;
    }
    
    if(!(!document.all)){
		document.all['globo'].style.left = (posx-10)+'px';
	    document.all['globo'].style.top = (posy+50)+'px';
	    
	}else{
		document.getElementById('globo').style.left = (posx+2)+'px';
	    document.getElementById('globo').style.top = (posy-190)+'px';
	}
}

function pegar(texto) {
	$('#globo').html(texto);
}

function tooltip(opcion){
	if(opcion == 1){
		getObj('globo').style.visibility = 'visible';
	}else{
		getObj('globo').style.visibility = 'hidden';
	}
}

function openOriginales(){
		changeFrm (	'frmPop', "http://italika.com.mx/Refacciones/App/Default.aspx",'&nbsp;&nbsp;Partes Originales', 800, 500 );
		showPop( 'pop' ); 
	}
// Schema5	
function abrirpagina (id)	{
switch(id)
{
	case "motos":
		cadena = 'QSPDI/Solicitud_D_Motos.aspx';
		mensaje = 'Quiero ser distribuidor de motos ITALIKA';
		tam = '700';
		limpiatitulos();
		getObj('span-quienes').style.borderBottom = "double";
	break;
	case "cesit":
		cadena = 'QSPDI/Solicitud_CESIT.aspx';
		mensaje = 'Quiero ser un centro de servicio ITALIKA(CESIT)';
		tam = '700';
		limpiatitulos();
		getObj('span-quienes').style.borderBottom = "double";
	break;
	case "refacciones":
		cadena = 'QSPDI/SolDistRef.aspx';
		mensaje = 'Quiero ser distribuidor de refacciones ITALIKA';
		tam = '700';
		limpiatitulos();
		getObj('span-quienes').style.borderBottom = "double";
	break;
	case "italika":
		cadena = 'QSPDI/CV_Italika.aspx';
		mensaje = 'Quiero trabajar en el equipo ITALIKA';
		tam = '700';
		limpiatitulos();
		getObj('span-quienes').style.borderBottom = "double";
	break;
	case "compara":
		cadena = 'Files/Modelos/comparativo.pdf'
		mensaje = 'Compara Modelos';
		tam = '1000';
		limpiatitulos();
		getObj('span-productos').style.borderBottom = "double";
	break;	
		case "eventos":
		cadena = 'eventos/eventos.aspx?EventoId=0'
		mensaje = 'Eventos';
		tam = '925';
		limpiatitulos();
		getObj('span-mundo').style.borderBottom = "double";
	break;
	case "centrosservicio":
		cadena = 'http://www.italika.com.mx/itkcenso/Censo/busca_cesit.aspx?fiFiltro=0'
		mensaje = 'Centro de Servicio';
		tam = '850';
	    limpiatitulos();
		getObj('span-centro').style.borderBottom = "double";
	break;
		case "dondecomprar":
	    cadena = 'DondeComprar.htm'
		mensaje = 'Donde Comprar';
		tam = '700';
	break;
	case "encuesta":
    	cadena = 'encuesta/EncuestaEvaluacionCesit.aspx'
		mensaje = 'Encuesta Cesit';
		tam = '1050';
		limpiatitulos();
		getObj('span-contacto').style.borderBottom = "double";
	break;
case "comentarios":
            
            cadena = 'contactenos.aspx'
            mensaje = 'Contactenos';
            tam = '1050';
            limpiatitulos();
            getObj('span-contacto').style.borderBottom = "double";
            break;
	case "privacidad":
	    cadena = 'privacidad/legal.htm'
		mensaje = 'Privacidad';
		tam = '550';
	break;
        case "blogRBS":
            cadena = 'www.limpiemosnuestromexico.com'
            mensaje = '';
            tam = '1050';
            limpiatitulos();
            getObj('span-contacto').style.borderBottom = "double";
            break;
        case "Avisoprivacidad":
            cadena = 'privacidad/legal2.htm'
            mensaje = 'Aviso';
            tam = '800';
            break;
}	
	changeFrm (	'frmPop', cadena ,'&nbsp;&nbsp;'+mensaje , tam , 440 );
	showPop( 'pop' ); 
}

function limpiatitulos()
{
	getObj('span-productos').style.borderBottom = "none";
	getObj('span-index').style.borderBottom = "none";
	getObj('span-quienes').style.borderBottom = "none";
	getObj('span-refacciones').style.borderBottom = "none";
	getObj('span-mundo').style.borderBottom = "none";
	getObj('span-contacto').style.borderBottom = "none";
	getObj('span-centro').style.borderBottom = "none";
}


function abrirpp(pagina) {
	window.open(pagina,'window','width=800,height=650');
	limpiatitulos();
}

function abrirrf(pagina) {
	window.open(pagina,'window','width=800,height=600, resizable=1');
	limpiatitulos();
}

function abrirrf_vr(pagina) {
   // if (aviso_privacidad()) {
        window.open(pagina, 'window', 'width=800,height=600, resizable=1');
        limpiatitulos();
  //  }
}
function abrir_Ref() {
	window.open('../Default.aspx?UserType=0','window','width=800,height=600');
	limpiatitulos();
}



function abrirRef()
{
    document.forms[0].reset();
    getObj('sMensajeLogin').innerHTML = "";
    document.getElementById("barra-login2").style.visibility='hidden';
    window.open('../Refacciones/App/Default.aspx?UserType=0','window','width=800,height=600,resizable=1');
}

function abrircotizador(sRuta,mensaje)
{
    changeFrm (	'frmPop', sRuta ,'Cotizador para el modelo&nbsp;&nbsp;'+ mensaje , 760 , 440 );
    showPop( 'pop' ); 
}


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_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_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 m_i(ig,tt){
	getObj('imgShow').src = ig;
	getObj('ttShow').innerHTML = tt + '&nbsp;';	
}

function getObj(nom){
	
	if(!(!document.all)){
		var a = document.all[nom];
	}else{
		var a = document.getElementById(nom);
	}
	return a;
}

function srcImagenC (id){
switch(id)
{
	case "partes":
		getObj('imgCentro').src = "imgTemplate/partesoriginales.jpg";	
	break;
	case "atencion":
		getObj('imgCentro').src = "imgTemplate/servicioyatencion.jpg";	
	break;
	case "ensamblika":
		getObj('imgCentro').src = "imgTemplate/ensamblika.jpg";
	break;
	case "diseno":
		getObj('imgCentro').src = "imgTemplate/productoydiseno.jpg";
	break;
	case "calidad":
		getObj('imgCentro').src = "imgTemplate/controldecalidad.jpg";
	break;	
    }
}	

function ChgArea(e){
		var s = "";
		if(e.value == "servicios" || e.value == "refacciones" || e.value == "garantias" )
		{
			s = "";
		}else{
			s = "none";
		}
		getObj('tr_guia').style.display = s;
		getObj('tr_serie').style.display = s;		
		}
/* Login */	
	
	function op()
{

    document.getElementById("barra-login2").style.visibility='visible';
}
function cl()
{
    document.forms[0].reset();    
    getObj('sMensajeLogin').innerHTML = "";
    document.getElementById("barra-login2").style.visibility='hidden';
     
}

function oplogin()
{
  var xmlHttp;
	try{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}catch (e){  // Internet Explorer  
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}catch (e){
				alert("no hay Soporte para AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
				getObj('sMensajeLogin').innerHTML =xmlHttp.responseText;				
			}		
	}
	getObj('sMensajeLogin').innerHTML ="Procesando";
	//alert("oblogin.aspx?ln=" + getObj('txtUsuario').value + "&pd=" + getObj('txtPassword').value);
	//url = "http://www.italika.com.mx/menuitk3.aspx?sUsuario='" + getObj('txtUsuario').value + "'&sPassword='" + getObj('txtPassword').value + "'";
	//alert(url);
	//window.open(url,'ventana', 'menubar=1, status=1,resizable=1');
//	frmLogin.submit();

	user = getObj('txtUsuario').value;
	pass = getObj('txtPassword').value;
	
	
    	if(user.length==0 || pass.length==0)
    	{
		alert('Favor de ingresar usuario y contrasena');
	}
	else 
	{
	    document.forms["frmLogin"].submit();
	    xmlHttp.open("POST","oblogin.aspx?ln=" + getObj('txtUsuario').value + "&pd=" + getObj('txtPassword').value ,true);
	    xmlHttp.send(null);   
	}

/*
	document.forms["frmLogin"].submit();
	xmlHttp.open("POST","oblogin.aspx?ln=" + getObj('txtUsuario').value + "&pd=" + getObj('txtPassword').value ,true);
	xmlHttp.send(null);  
*/ 
}



function opvideo(sVideo)
{
  var xmlHttp;
	try{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}catch (e){  // Internet Explorer  
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}catch (e){
				alert("no hay Soporte para AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
				getObj('sVideo').innerHTML =xmlHttp.responseText;				
			}		
	}
	xmlHttp.open("GET","optvideo.aspx?Vd=" + sVideo ,true);
	xmlHttp.send(null);  
}

function ticker_label()
{
    getObj('et-mx').innerHTML = '<img src="imgTemplate/mx.png" />&nbsp;01 800 333 MOTO (6686)';
    getObj('et-pe').innerHTML = '<img src="imgTemplate/pe.png" />&nbsp;(01) 613-0085';
    getObj('et-gt').innerHTML = '<img src="imgTemplate/gt.png" />&nbsp;1-801-000MOTO (6686)';
    getObj('et-hn').innerHTML = '<img src="imgTemplate/hn.png" />&nbsp;(800) 2559-8000';
}



        function av_privacidad(id) {
            dato = showModalDialog('privacidad/legal3.htm', null, 'dialogWidth:450px;status:no; dialogHeight:210px; resizable:no; center:yes; help: no; location:no;');
            if (dato) {
                    abrirpagina(id);
            }
        
        }

