//JavaScript 

addEvent(window,'load',Carga,false);

function Carga(e)
{
	var boton = document.getElementById('ir');
	var texto = document.getElementById('buscar');
	var imprimir = document.getElementById('imprimir');
	
	if(texto)
	{
	texto.value = "Busca tu producto aquí";
	texto.style.color = "#999";
	texto.style.fontSize = "12px";
	texto.style.width = "150px";
	texto.style.fontFamily = "Verdana, Arial, Helvetica, sans-serif";
	addEvent(texto,'click',Clear,false);
	}
	
	if(boton)
	{
	boton.style.cursor = "pointer";
	boton.title = "Busca tu producto";
	addEvent(boton,'click',Ir,false);
	}
	
	if(imprimir)
	{
	addEvent(imprimir,'click',Imprimir,false);
	imprimir.style.cursor = "pointer";
	}
	

}

function Imprimir()
{
	var cadena = window.location.toString();
	longitud = cadena.length;

	var htmlExtension = longitud-5;
	cadena = cadena.substr(0,htmlExtension);

	var nuevaCadena="";
	for(i=htmlExtension;i>=0;i--)
	{
		if(cadena.charAt(i)=='/')
			break;
		else
			nuevaCadena += cadena.charAt(i);
	}

	var cadenaFinal = "";
	for(i=nuevaCadena.length-1;i>=0;i--)
	{
		cadenaFinal += nuevaCadena.charAt(i);
	}
	
	
	var direccion = "http://www.sinpro.com.mx/images/imprimir/" + cadenaFinal + ".pdf";

	window.location = direccion;
	

}


function ImprimirLegacy()
{
	var lista2=document.getElementsByTagName('table');
	
	for(f=1;f<5;f++)
  	{
	lista2[f].style.visibility = "hidden";
  	}

	var tabla = lista2[5];
	var listaX = tabla.getElementsByTagName('td');
	listaX[2].style.visibility = "hidden";
	
	var fondo = lista2[lista2.length-1];
	fondo.style.visibility = "hidden";
	
	var imprimir = document.getElementById('imprimir');
	imprimir.style.visibility = "hidden";
	
	
	
	print();
	
	imprimir.style.visibility = "visible";

	for(f=1;f<5;f++)
  	{
	lista2[f].style.visibility = "visible";
  	}
	listaX[2].style.visibility = "visible";
	fondo.style.visibility = "visible";

}

function Clear()
{
	var texto = document.getElementById('buscar');
	texto.value = "";
}



function Ir()
{
	var origen = 'http://www.sinpro.com.mx/';
	
	var texto = document.getElementById('buscar');
	var cadena = texto.value;
	cadena = cadena.toLowerCase(cadena);
	cadena = Limpiar(cadena);
	
	switch(cadena)
	{
		//Cámaras económicas
		case 'lcdshf' : window.location = origen + 'cctv/c_economicas/lcdshf.html';
			break;
		case 'lcs23hf' : window.location = origen + 'cctv/c_economicas/lcs23hf.html';
			break;
		case 'lirdphf' : window.location = origen + 'cctv/c_economicas/lirdphf.html';
			break;
		case 'minichcmos' : window.location = origen + 'cctv/c_economicas/minichcmos.html';
			break;
				
		//Cámaras espías
		
		case 'btr35' : window.location = origen + 'cctv/c_espia/btr35.html';
			break;
		case 'cl35' : window.location = origen + 'cctv/c_espia/cl35.html';
			break;
		case 'pdr25m' : window.location = origen + 'cctv/c_espia/pdr25m.html';
			break;
		case 'pdr50m' : window.location = origen + 'cctv/c_espia/pdr50m.html';
			break;
		case 'pn35' : window.location = origen + 'cctv/c_espia/pn35.html';
			break;
		case 'sg35' : window.location = origen + 'cctv/c_espia/sg35.html';
			break;
			
		//Cámaras z
		
		case 'clr16irsl' : window.location = origen + 'cctv/camaras_z/clr16irsl.html';
			break;
			
		case 'clr16irsl' : window.location = origen + 'cctv/camaras_z/clr16irsl.html';
			break;
			
		case 'clr16ir' : window.location = origen + 'cctv/camaras_z/clr16irsl.html';
			break;
			
		case 'clr36irwex' : window.location = origen + 'cctv/camaras_z/clr36irwex.html';
			break;
			
		case 'cz100irrc' : window.location = origen + 'cctv/camaras_z/cz100irrc.html';
			break;
			
			
		//Domos
		
		case 'dirc24h' : window.location = origen + 'cctv/domos/dirc24h.html';
			break;
			
		case 'dirc35a' : window.location = origen + 'cctv/domos/dirc35a.html';
			break;
			
		case 'dirc42vantivandalico' : window.location = origen + 'cctv/domos/dirc42va.html';
			break;

		case 'ecl555' : window.location = origen + 'cctv/domos/ecl555.html';
			break;
		
		case 'ecl557antivandalico' : window.location = origen + 'cctv/domos/ecl557a.html';
			break;
			
		case 'ecl557varifocal' : window.location = origen + 'cctv/domos/ecl557va.html';
			break;
			
			
		// Domos PT
		
		case 'pt400' : window.location = origen + 'cctv/domos_pt/pt400.html';
			break;
		case 'pt400e' : window.location = origen + 'cctv/domos_pt/pt400e.html';
			break;
			
		//HDV
		
		case 'cc45nvdsl' : window.location = origen + 'cctv/hdv/cc45nvdsl.html';
			break;
		
		case 'cd35vpwsl' : window.location = origen + 'cctv/hdv/cd35vpwsl.html';
			break;
			
		case 'cd45vawd' : window.location = origen + 'cctv/hdv/cd45vawd.html';
			break;
			
		case 'clr16irsl' : window.location = origen + 'cctv/hdv/clr16irsl.html';
			break;
			
		case 'cz100irrc' : window.location = origen + 'cctv/hdv/cz100irrc.html';
			break;
		
		case 'hd21222pir' : window.location = origen + 'cctv/hdv/hd21222pir.html';
			break;
			
		case 'hdzw1216t' : window.location = origen + 'cctv/hdv/hdzw1216t.html';
			break;


		//Infrarojas
		
		case 'birc100' : window.location = origen + 'cctv/infrarrojas/birc100.html';
			break;
		case 'birc12' : window.location = origen + 'cctv/infrarrojas/birc12.html';
			break;
		case 'birc12v' : window.location = origen + 'cctv/infrarrojas/birc12v.html';
			break;
		case 'birc24' : window.location = origen + 'cctv/infrarrojas/birc24.html';
			break;
		case 'birc36' : window.location = origen + 'cctv/infrarrojas/birc36.html';
			break;
		case 'birc36hv' : window.location = origen + 'cctv/infrarrojas/birc36hv.html';
			break;
		case 'birc48hv' : window.location = origen + 'cctv/infrarrojas/birc48hv.html';
			break;
		case 'birc80' : window.location = origen + 'cctv/infrarrojas/birc80.html';
			break;
		case 'ecl597' : window.location = origen + 'cctv/infrarrojas/ecl597.html';
			break;
		case 'minich35' : window.location = origen + 'cctv/infrarrojas/minich35.html';
			break;
			
		//Ocultas
		case 'eclcexit' : window.location = origen + 'cctv/ocultas/eclcexit.html';
			break;
		case 'eclcpir' : window.location = origen + 'cctv/ocultas/eclcpir.html';
			break;
		case 'eclcsmoke' : window.location = origen + 'cctv/ocultas/eclcsmoke.html';
			break;
		case 'fssprinkel' : window.location = origen + 'cctv/ocultas/fssprinkel.html';
			break;
		
		//Profesionales
		case 'cb24' : window.location = origen + 'cctv/profesionales/cb24.html';
			break;
		case 'ecl553hq1' : window.location = origen + 'cctv/profesionales/ecl553hq1.html';
			break;
		case 'ecl554' : window.location = origen + 'cctv/profesionales/ecl554.html';
			break;
		case 'ecl554ph' : window.location = origen + 'cctv/profesionales/ecl554ph.html';
			break;
		case 'ecl596' : window.location = origen + 'cctv/profesionales/ecl596.html';
			break;
		case 'ecl596varifocal' : window.location = origen + 'cctv/profesionales/ecl596v.html';
			break;
			
		//PTZ
		
		case 'eclptzir' : window.location = origen + 'cctv/ptz/eclptzir.html';
			break;
		case 'ptz10x' : window.location = origen + 'cctv/ptz/ptz10x.html';
			break;
		case 'ptz40022x' : window.location = origen + 'cctv/ptz/ptz40022x.html';
			break;
		case 'ptz40036x' : window.location = origen + 'cctv/ptz/ptz40036x.html';
			break;
		
		
		//Control de acceso
		
		case 'eclacc900' : window.location = origen + 'control_acceso/eclacc900.html';
			break;
		case 'eclacc910' : window.location = origen + 'control_acceso/eclacc910.html';
			break;
		case 'eclacc940' : window.location = origen + 'control_acceso/eclacc940.html';
			break;
		case 'eclacc950' : window.location = origen + 'control_acceso/eclacc950.html';
			break;
		case 'eclacc960' : window.location = origen + 'control_acceso/eclacc960vandal.html';
			break;
		case 'eclacc970' : window.location = origen + 'control_acceso/eclacc970.html';
			break;
		case 'eclacc990' : window.location = origen + 'control_acceso/eclacc990lr.html';
			break;
		case 'eclacc995' : window.location = origen + 'control_acceso/eclacc995.html';
			break;


	//DVR's
	
		case 'blackdiamod' : window.location = origen + 'dvrs/blackdiamod.html';
			break;
		case 'dv3' : window.location = origen + 'dvrs/dv3.html';
			break;
		case 'dv4' : window.location = origen + 'dvrs/dv4.html';
			break;
		case 'jv' : window.location = origen + 'dvrs/jv.html';
			break;



		default: alert('No se encuentra el modelo');
			
			
	}
}



function Limpiar(c)
{
	resultado = '';
	for(i=0;i<c.length;i++)
	{
		if((c.charAt(i)==' ')||(c.charAt(i)=='-'))
			resultado = resultado;
		else
		resultado = resultado + c.charAt(i);
	}
	
	return resultado;
	

}


//Código para que el sistema trabaje con varios navegadores

function addEvent(elemento,nomevento,funcion,captura)
{
	if(elemento.attachEvent)
	{
		elemento.attachEvent('on'+nomevento,funcion);
		return true;
	}
	else
	if(elemento.addEventListener)
	{
		elemento.addEventListener(nomevento,funcion,captura);
		return true;
	}
	else
		return true;
}