function CentrarVentana(url, nombre, ancho, alto){
  var x, y
  x = (window.screen.width-ancho)/2
  y = (window.screen.height-alto)/2
  window.open(url, nombre, "menu=no, location=no, width="+ancho+",height="+alto+", left="+ x + ", top=" + y)
}

function AbrirVentana(url){
  var win
  win = window.open(url)
} 

function VerExposicion(nombre,ancho,alto){
  CentrarVentana("exposicionesPopUp.asp?image=" + nombre ,"Exposiciones",ancho,alto);
}
function VerRegalo(nombre,ancho,alto){
  CentrarVentana("regalosPopUp.asp?image=" + nombre ,"Regalos",ancho,alto);
}

function VerCliente(referencia){
  CentrarVentana("datospersonales.asp?num=" + referencia ,"Cliente",450,250);
}
function VerCliente2(referencia){
  CentrarVentana("datospersonalesCOM.asp?num=" + referencia ,"Cliente",450,250);
}

// FUNCIONES PARA onMouseOver de Dreamweaver

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) { //v3.0
  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); 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];}
}
// *****************************************



// --- PARA RECALCULAR COMPRA --- YA NO SE UTILIZA ----
function parametros(j) {
		var resul,i
		resul = ""
		j = j + 1
			
			for (i = 2; i <=j; i++){
				if (i == 2)  {
								resul = "?par" + (i - 1) + "=" + document.forms[0].elements[i].value
								}				
				else			{
							resul = resul + "&par" + (i - 1) + "=" + document.forms[0].elements[i].value
								}
								}

		resul =   "recalcular.asp" + resul + "&portesprecio=" + document.forms[0].portes.options[document.forms[0].portes.selectedIndex].value + "&portesindex=" + document.forms[0].portes.selectedIndex	
			
		document.location = resul			
					}
// ***************************


// -- COMPRAR VIDEO
function comprarvideo(ref,parametro){
	 
	result = " "
	precio = 0
	
	if (parametro.length > 1 ) {	
				if (parametro[0].checked) {
											//precio = parametro[0].value
											tipo = "PAL"
											}
				if (parametro[1].checked) {
											//precio = parametro[1].value
											tipo = "NTSC"
											}
								}
	else 						{ 
				//precio = parametro.value
				tipo = "PAL"
								}
	result = "carro_comprar.asp?referencia=" + ref + "&categoria=Video&tipo=" + tipo
	
	document.location = result

					}
// ****************************

// --- COMPRAR DVD
function comprardvd(ref,parametro){
	 
	result = " "
	precio = 0
	
	if (parametro.length > 1 ) {	
				if (parametro[0].checked) {
											//precio = parametro[0].value
											tipo = "PAL"
											}
				if (parametro[1].checked) {
											//precio = parametro[1].value
											tipo = "NTSC"
											}
								}
	else 						{ 
				//precio = parametro.value
				tipo = "PAL"
								}
	result = "carro_comprar.asp?referencia=" + ref + "&categoria=DVD&tipo=" + tipo
	
	document.location = result

					}
// ****************************

// --- COMPRAR INSTRUMENTO
function comprarinstrumento(ref,precio){
	 
	cad = "carro_comprar.asp?referencia=" + ref + "&categoria=Instrumento";
	if 	(document.forms[0].color.value != "no") { cad = cad + "&color=" + document.forms[0].color.value;}
	
	//alert (cad);
	document.location = cad;
}

// ****************************


// --- COMPRAR MUSICA --- YA NO SE UTILIZA ----
function comprarmusica(ref,parametro){
	 
	result = " "
	precio = 0
	
	if (parametro.length > 1 ) {	
				if (parametro[0].checked) {
											//precio = parametro[0].value
											tipo = "CD"
											}
				if (parametro[1].checked) {
											//precio = parametro[1].value
											tipo = "CASETE"
											}
								}
	else 						{ 
				//precio = parametro.value
				tipo = "CD"
								}
	result = "carro_comprar.asp?referencia=" + ref + "&categoria=Música&tipo=" + tipo
	
	document.location = result

					}
// ****************************

// --- COMPRAR ROPA
function comprarropa(ref,precio){
	 
	cad = "carro_comprar.asp?referencia=" + ref + "&categoria=Ropa";
	if 	(document.forms[0].color.value != "no") { cad = cad + "&color=" + document.forms[0].color.value;}
	if 	(document.forms[0].talla.value != "no") { cad = cad + "&talla=" + document.forms[0].talla.value;}
	if 	(document.forms[0].material.value != "no") { cad = cad + "&material=" + document.forms[0].material.value;}
	if 	(document.forms[0].cierre.value != "no") { cad = cad + "&cierre=" + document.forms[0].cierre.value;}
	if 	(document.forms[0].tacones.value != "no") { cad = cad + "&tacones=" + document.forms[0].tacones.value;}

	
	document.location = cad;

					}
// ****************************

// --- VERIFICA QUE HA METIDO TODOS LOS DATOS EN EL FORMULARIO DE PEDIDO
function formComprarSubmit(){
var exito = 0;
	if ( document.principal.nombre.value == '' ) {
			alert("Debe introducir su nombre.");
			exito = 1;
	}
	if ( document.principal.domicilio.value == '' ) {
			alert("Debe introducir su Domicilio.");
			exito = 1;
	}
	if ( document.principal.poblacion.value == '' ) {
			alert("Debe introducir su población.");
			exito = 1;
	}
	if ( document.principal.provincia.value == '' ) {
			alert("Debe introducir su provincia.");
			exito = 1;
	}
	if ( document.principal.pais.value == '' ) {
			alert("Debe introducir su pais.");
			exito = 1;
	}
	if ( document.principal.cp.value == '' ) {
			alert("Debe introducir su código postal.")
	}
	if ( document.principal.email.value == '' && document.principal.telefono.value == '') {
			alert("Debe introducir su E-mail o bien su Teléfono.");
			exito = 1;
	}
	if (exito == 0) {
		document.principal.submit();
	}
}

// ****************************
