
/*=======================================================================================
FUNCION:	deshabilitar(elemento) 
ARGS:		Pasa el elemento del formulario que se deshabilita y oculta
DEVUELVE:	null
DESCRIP:	En el formulario deshabilita un campo y lo oculta
=======================================================================================*/

function deshabilitar(elemento) {
	document.getElementById(elemento).style.visibility = 'hidden'; 
	document.getElementById(elemento).disabled=true; 
} 


/*=======================================================================================
FUNCION:	habilitar(elemento) 
ARGS:		Pasa el elemento del formulario que se habilita y muestra
DEVUELVE:	null
DESCRIP:	En el formulario habilita un campo y lo muestra
=======================================================================================*/

function habilitar(elemento) {
	document.getElementById(elemento).style.visibility = 'visible'; 
	document.getElementById(elemento).disabled=false; 
} 


/*=======================================================================================
FUNCION:	habilitarEnlace(elemento1,elemento2) 
ARGS:		Pasa el elemento del formulario que se habilita y muestra
DEVUELVE:	null
DESCRIP:	En el formulario habilita un campo y lo muestra
=======================================================================================*/

function habilitarEnlace(elemento1,elemento2) {
	ocultarEnlace= elemento1+elemento2;
	document.getElementById(ocultarEnlace).style.visibility = 'hidden'; 
	mostrarEnlace= elemento2+elemento1;
	document.getElementById(mostrarEnlace).style.visibility = 'visible';
}


/*=======================================================================================
FUNCION:	deshabilitarInferiores(elemento1,elemento2)
ARGS:		Pasa el elemento del formulario a partir del cual se tienen que mostrar los inputs
DEVUELVE:	null
DESCRIP:	En el formulario muestra los inputs deshabilitando los inferiores Para que no 
introduzca valores erroneos en las tablas zonas.
=======================================================================================*/

function deshabilitarInferiores(elemento1,elemento2){
	enlace= elemento1+elemento2;
	switch (enlace){
	   case '01' : 
	      //alert("dentro de deshabilitarInferiores(elementos) en case 01");
	      deshabilitar('2');
	      deshabilitar('4');
	      deshabilitar('6');
	      habilitar('3');
	      habilitar('5');
	      habilitar('7');
	      habilitarEnlace('2','3')
	      habilitarEnlace('4','5')
	      habilitarEnlace('6','7')
	      break;
	   case '10' : 
	      deshabilitar('3');
	      deshabilitar('5');
	      deshabilitar('7');
	      habilitar('2');
	      habilitar('4');
	      habilitar('6');
	      habilitarEnlace('3','2')
	      habilitarEnlace('5','4')
	      habilitarEnlace('7','6')
	      break;
	   case '23' : 
	      deshabilitar('4');
	      deshabilitar('6');
	      habilitar('5');
	      habilitar('7');
	      habilitarEnlace('4','5')
	      habilitarEnlace('6','7')
	      break;
	   case '32' : 
	      deshabilitar('5');
	      deshabilitar('7');
	      habilitar('4');
	      habilitar('6');
	      habilitarEnlace('5','4')
	      habilitarEnlace('7','6')
	      break;
	   case '45' : 
	      deshabilitar('6');
	      habilitar('7');
	      habilitarEnlace('6','7')
	      break;
	   case '54' : 
	      deshabilitar('7');
	      habilitar('6');
	      habilitarEnlace('7','6')
	      break;
	}
	
}


/*=======================================================================================
FUNCION:	cargarsubzona(zona,url) 
ARGS:		Pasa el elemento del formulario que se habilita y muestra, la página a la que hay que enviar la información.
DEVUELVE:	null
DESCRIP:	En el formulario habilita un campo y lo muestra
=======================================================================================*/

function cargarsubzona(zona,page) {
	var url =page+".php?zona="+zona+"&idzona="+(document.zona.elements[zona].value);
	window.location.href=url;
	//alert(url);
}


/*=======================================================================================
FUNCION:	checkearReferencia(ref,url) 
ARGS:		Pasa el elemento del formulario que se habilita y muestra, la página a la que hay que enviar la información.
DEVUELVE:	null
DESCRIP:	En el formulario habilita un campo y lo muestra
=======================================================================================*/

function checkearReferencia(ref,page) {
	var url =page+".php?ref="+(document.altaFoto.elements[ref].value);
	//window.location.href=url;
	strFeatures = "width=1,height=1,left=9999,top=9999";
	window.open(url, "", strFeatures);
	//window.open(,'','width=1,height=1,screenX=30,screenY=30');
	//alert(url);
}




/*=======================================================================================
FUNCION:	mostrarmensaje(mensaje) 
ARGS:		Muestra un mensaje si existe una referencia con ese código
DEVUELVE:	null
DESCRIP:	
=======================================================================================*/

function mostrarmensaje(mensaje) {
	alert(mensaje);
	window.close();
}


/*=======================================================================================
FUNCION:	datosentrega() 
ARGS:		En compra/paso1inc.php, copia los datos de facturación en los de entrega.
DEVUELVE:	null
DESCRIP:	En compra/paso1inc.php, copia los datos de facturación en los de entrega
=======================================================================================*/

function datosentrega() {
	//alert(document.paso1Form.nombree.value);
	if(document.paso1Form.datos_chk.checked){
		document.paso1Form.nombree.value = document.paso1Form.nombref.value;
		document.paso1Form.direccione.value = document.paso1Form.direccionf.value;
		document.paso1Form.cpe.value = document.paso1Form.cpf.value;
		document.paso1Form.ciudade.value = document.paso1Form.ciudadf.value;
		document.paso1Form.provinciae.value = document.paso1Form.provinciaf.value;
	}else{
		document.paso1Form.nombree.value = '';
		document.paso1Form.direccione.value = '';
		document.paso1Form.cpe.value = '';
		document.paso1Form.ciudade.value = '';
		document.paso1Form.provinciae.value = '';
	}
}


/*=======================================================================================
FUNCION:	cyc() 
ARGS:		El idfoto que se quiere añadir a la cesta.
DEVUELVE:	null
DESCRIP:	En detalleFoto2.php, añade la foto ampliada a la cesta y cierra la ventana de ampliación
=======================================================================================*/

function cyc(idfoto){
	window.opener.document.location = 'http://www.amilpies.com/web/publica/anhadeACesta.php?idFoto='+idfoto;
	this.close();
}
/*=======================================================================================
FUNCION:	cyc_en() 
ARGS:		El idfoto que se quiere añadir a la cesta.
DEVUELVE:	null
DESCRIP:	En detalleFoto2.php, añade la foto ampliada a la cesta y cierra la ventana de ampliación (para la web en inglés)
=======================================================================================*/

function cyc_en(idfoto){
	window.opener.document.location = 'http://www.amilpies.com/web_en/publica/anhadeACesta.php?idFoto='+idfoto;
	this.close();
}
/*=======================================================================================
FUNCION:	enviapostal() 
ARGS:		El idfoto que se quiere enviar como postal.
DEVUELVE:	null
DESCRIP:	En detalleFoto2.php, muestra en la ventana principal la página de envío de postal
=======================================================================================*/

function enviapostal(idfoto){
	window.opener.document.location = 'http://www.amilpies.com/web/publica/enviarPostal.php?idFoto='+idfoto;
}
/*=======================================================================================
FUNCION:	enviapostal_en() 
ARGS:		El idfoto que se quiere enviar como postal.
DEVUELVE:	null
DESCRIP:	En detalleFoto2.php, muestra en la ventana principal la página de envío de postal (para la web en inglés)
=======================================================================================*/

function enviapostal_en(idfoto){
	window.opener.document.location = 'http://www.amilpies.com/web_en/publica/enviarPostal.php?idFoto='+idfoto;
}




/*=======================================================================================
FUNCION:	printSpecial()
ARGS:		--- 
DEVUELVE:	---
DESCRIP:	Para imprimir el contendio del FrameCuerpo
=======================================================================================*/
var gAutoPrint = true; // Flag for whether or not to automatically call the print function
function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}

		html += '\n</HE' + 'AD>\n<BODY>\n';

		var printReadyElem = document.getElementById("printReady");

		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}

		html += '\n</BO' + 'DY>\n</HT' + 'ML>';

		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}


/*=======================================================================================
	Funciones varias que se utilizan en muestraCesta.php
=======================================================================================*/

function cargarpagina(linea,valorid,form,blncambio,calidad) {
	document.cesta_form.linea.value=linea;
	document.cesta_form.valoridfoto.value=valorid;
	document.cesta_form.valorf.value=form.value;
	document.cesta_form.camb.value=blncambio;
	document.cesta_form.calidad.value=calidad;
	document.cesta_form.submit();
}
function cargarpaginacontrato(contrato,valorid,blncambio,calidad) {
	document.cesta_form.cambcontr_contr.value=contrato.value;
	document.cesta_form.cambcontr_idfoto.value=valorid;
	document.cesta_form.cambcontr.value=blncambio;
	document.cesta_form.calidad.value=calidad;
	document.cesta_form.submit();
}
function cargarpaginacantidad(cant,valorid,blncambio) {
	document.cesta_form.cambcant_cant.value=cant.value;
	document.cesta_form.cambcant_idfoto.value=valorid;
	document.cesta_form.cambcant.value=blncambio;
	document.cesta_form.submit();
}
/*=======================================================================================
=======================================================================================*/
