﻿// JScript File

//------Función para validar que una caja de texto acepte solo valores numéricos.
function calcular(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=507,height=648,left = 415,top = 287');");
}
// End -->

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 goPage(){
var searchForm  = document.getElementById('search_form').value ;
		var Main = document.getElementById('main').value ;
		var Ccsyn = document.getElementById('ccsyn').value ;
		var Rndo  =  document.getElementById('rnd').value ;
		var topcatSearch = document.getElementById('topcat_search').value ;
		var formkeyword = document.getElementById('form_keyword').value ;
var topcatId  =  document.getElementById('topcat_id').options[document.getElementById('topcat_id').selectedIndex].value ;
        
window.open("http://skyboxen.pricegrabber.com/search_gen.php?search_form="+searchForm+"&main="+Main+"&ccsyn="+Ccsyn+"&rnd="+Rndo+"&topcat_search"+topcatSearch+"&form_keyword="+formkeyword+"&topcat_id="+topcatId,"","") ;			

}

function abrirCalculadora(){
var win = new Window({className: "alphacube", title: "Calculadora de Tarifas", width:710, height:450, url: "/calculatorout.aspx"})
win.showCenter();      
}

//here you place the ids of every element you want.
var ids=new Array('default','hogar','musica','juguetes','libros','megatiendas','joyeria','computacion','mascotas','deportes','descuentos','belleza','tiendas','electronicos');

function switchid(id){	
	hideallids();
	showdiv(id);
}
function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}



function fieldNumber () 
{ 
var evento_key = window.event.keyCode; 
	switch (evento_key) 
	{ 
		case 48: 
		case 49: 
		case 50: 
		case 51: 
		case 52: 
		case 53: 
		case 54: 
		case 55: 
		case 56: 
		case 57: 
		break; 
		default: 
		window.event.keyCode = 0; 
		return false; 
	} 
}

function fieldNumberDecimal()
{
var evento_key = window.event.keyCode; 
switch (evento_key) 
	{ 
	    case 46:
		case 48: 
		case 49: 
		case 50: 
		case 51: 
		case 52: 
		case 53: 
		case 54: 
		case 55: 
		case 56: 
		case 57: 
		break; 
		default: 
		window.event.keyCode = 0; 
		return false; 
	} 
}

function AbreCenterPopUp(pagina,ancho,alto)
{
	window.open(pagina,"win_pop","menubar=0,scrollbars=yes,width=" +ancho+ ",height=" +alto+ ",left=400,top=350")
}


//Contador de Checks
function countChoices(objchk,cant,objcont) {

var cont = 1;

cont = parseInt(objcont.value);

if(objchk.checked == true){
if (cont >= cant) {
objchk.checked = false;
}
else{
cont++;
}
}else{
cont--;
}


objcont.value = cont;

}


//------Función para limpiar una caja de texto al posicionar el cursor en ella.
function ClearField (objeto) 
{     
    objeto.value = "";
}

//------Función para abrir una ventana del tipo pop up , dandole la url de la página.
function AbrePopUp(pagina)
{    
	window.open(pagina,"win_pop","toolbar=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes");
}

//------Función para abrir una ventana pop up y mostrar una imagen (Usado en Viewitem.aspx)
function abreFoto(ruta)
{   
   i1 = new Image;
   i1.src = ruta;
   html = '<html><head><title>Imagen</title></head>';
   html += '<body leftmargin=0 marginwidth=0 topmargin=0 marginheight=0>';
   html += '<center><img src="'+ruta+'" border=0 name="Foto" ';
   html += 'onLoad="window.resizeTo(document.Foto.width,document.Foto.height)">';
   html += '</center></body></html>';
   popupImage = window.open('','_blank','scrollbars=0,resizable=1');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close();
}



 function ValidaEntry(){  
       if(document.getElementById('ctl00_cphMySkybox_rblOptionTraking_0').checked){
         Tecla('Alphanumeric') ;
       }
       else if(document.getElementById('ctl00_cphMySkybox_rblOptionTraking_1').checked){
         Tecla('Alphanumeric') ;
       }
  } 
  
 function Tecla(sType) {
  var sKey,sKeyAscii;
  if(window.event.keyCode!=13)
  {sKey = String.fromCharCode(window.event.keyCode);
   sKeyAscii=window.event.keyCode; 
   switch (sType)
   {
    case 'Alphanumeric':
     if(!((sKey <= "Z" && sKey >= "A") || (sKey <= "z" && sKey >= "a") || (sKey == " ") || (sKey == "Ñ") || (sKey == "ñ") || (sKey >= "0" && sKey <= "9") || (sKey == "-") )) {window.event.keyCode = 0;}
     break;
    case 'Character':
     if(!((sKey <= "Z" && sKey >= "A") || (sKey <= "z" && sKey >= "a") || (sKey == " ") || (sKey == "Ñ") || (sKey == "ñ"))) {window.event.keyCode = 0;}
     break;
    case 'CaractExt':
	 if(((sKey =="¡") || (sKey =="!") ||(sKey == "@") || (sKeyAscii == 92)||(sKey == "^") ||(sKey == ",")||(sKeyAscii == 34)||(sKeyAscii == "`")||(sKey == "]")||(sKey == "[")||(sKey == "$")||(sKey == ":")||(sKey == "=")||(sKey == "?")||(sKey == "¿")||(sKey == "}")||(sKey == "{") ||(sKey == "+")||(sKey == ">")||(sKey == "<")||(sKey == "*")||(sKey == "#")||(sKey == ")")||(sKey == "(")||(sKey == "|")||(sKey == "%")||(sKeyAscii == 180)||(sKey == "~"))) {window.event.keyCode = 0;}	
     break;
    case 'Integer':
     if(!(sKey >= "0" && sKey <= "9")) {window.event.keyCode = 0;}
     break;
    case 'Double':
     if(!((sKey >= "0" && sKey <= "9") || (sKey == "."))) {window.event.keyCode = 0;}
     break;
    case 'Date':
     if(!((sKey >= "0" && sKey <= "9") || (sKey == "/"))) {window.event.keyCode = 0;}
     break;
    case 'Time':
     if(!((sKey >= "0" && sKey <= "9") || (sKey == ":"))) {window.event.keyCode = 0;}
     break;
    case 'Telefono':
     if(!((sKey >= "0" && sKey <= "9") || (sKey == " ") || (sKey == "-") )) {window.event.keyCode = 0;}
     break;
   }
  }
  else
  {
   window.event.keyCode = 0;
  }
 }

// Efecto de la imagen - Rotador de Imagenes.
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs)
{
var imageSeparator = imageFiles.indexOf(";");
var nextImage = imageFiles.substring(0,imageSeparator);
if (document.all)
{
document.getElementById(pictureName).style.filter="blendTrans(duration=0.05)";
document.getElementById(pictureName).filters.blendTrans.Apply();
}
document.getElementById(pictureName).src = nextImage;
if (document.all)
{
document.getElementById(pictureName).filters.blendTrans.Play();
}
var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
+ ';' + nextImage;
setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
displaySecs*450);
// cambio de imagen.
imageSeparator = futureImages.indexOf(";");
nextImage = futureImages.substring(0,imageSeparator);
if (slideCache[nextImage] == null) {
slideCache[nextImage] = new Image;
slideCache[nextImage].src = nextImage;
}
}