//----------caja del loading-------------//
document.write ("<div id=\"cajamensaje\" onclick=\"alert('En estos momentos se esta ejecutando la acción informada, por favor aguarde unos instantes.')\"></div><div id=\"contenido\"><span class='cero'>.</span></div>")

//document.write ("<div id=\"condiciones\" class=\"condiciones\"></div>")
//document.write ("<div id=\"mensajecontenido\" class=\"mensajes\">")
//document.write ("</div>")


function cargamensa(n,z,titulo,imprime){
	
document.getElementById("cajamensaje").style.display = "block";

if (n==1){
		mensaje= "<table width=\"408\" height=\"70\"  cellpadding=\"0\" cellspacing=\"0\" class='estilodetexto'>"
		mensaje= mensaje + "  <tr >"
		mensaje= mensaje + "    <td width=\"100\" align=\"center\" valign=\"middle\" id=\"immensajecontenido\"></td>"
		mensaje= mensaje + "    <td width=\"308\" align=\"center\" valign=\"middle\" id=\"txmensajecontenido\"></td>"
		mensaje= mensaje + "  </tr>"
		mensaje= mensaje + "</table>"
		// montando cuerpo del mensaje
		document.getElementById('contenido').innerHTML= mensaje
	if (z==1){ // cargando normal, iniciandose
		document.getElementById('immensajecontenido').innerHTML="<img src=\"imagen/loading.gif\">"
		document.getElementById('txmensajecontenido').innerHTML="Generando la información solicitada.<br> Un momento por favor ..."
		cuentaloguin()
	}else if (z==2){// llevando el producto al carrito
		document.getElementById('immensajecontenido').innerHTML="<img src=\"imagen/loading3.jpg\"/>"
		document.getElementById('txmensajecontenido').innerHTML="Enviando el producto al carrito.<br>Un momento por favor ..."
	}else if (z==3){// llevando el producto al carrito
		document.getElementById('immensajecontenido').innerHTML="<img src=\"imagen/loading.gif\">"
		document.getElementById('txmensajecontenido').innerHTML="Recuperando información de su Compra.<br> Un momento por favor ..."
	}else if (z==4){// accediendo a clientes
		document.getElementById('immensajecontenido').innerHTML="<img src=\"imagen/loading.gif\">"
		document.getElementById('txmensajecontenido').innerHTML="Verificando datos de Cliente.<br> Un momento por favor ..."
	}
				document.getElementById("contenido").className='cajamensajepequeno'
				document.getElementById("contenido").style.display = "block";

}else if (n==2) {
	///	mensaje= "<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+titulo+"</div><div id='TB_closeAjaxWindow'><a href='#' onclick='cierraloading()' title='Cerrar'><img src='imagen/cerrar.gif' /></a></div></div>"
	 	
	//	mensaje = mensaje + "<iframe name='docuprint' src='' width='700px' height='420px' marginwidth='0' marginheight='0' hspace='0' vspace='0' scrolling='auto' frameborder='0' border='0' name='docuprint"+Math.round(Math.random()*1000)+"'></iframe>"
	//	if (imprime =="s"){
	//	mensaje= mensaje + "<table width=\"700\"  cellpadding=\"0\" cellspacing=\"0\" class='estilodetexto'>"
	//	mensaje= mensaje + "  <tr>"
	//	mensaje= mensaje + "    <td width=\"50%\" align=\"center\" valign=\"middle\" ><a href=\"javascript:cierraloading()\"><img src=\"imagen/botones/cancelar_formulario.gif\" alt=\"Cerrar Ventana.\"/></a></td>"
	//	mensaje= mensaje + "    <td width=\"50%\" align=\"center\" valign=\"middle\" ><a href=\"javascript:imprimir()\"><img src=\"imagen/botones/imprime.gif\" alt=\"Pulse para Imprimir.\"/></a></td>"
	//	mensaje= mensaje + "  </tr>"
	//	mensaje= mensaje + "</table>"
	//	}
	//		document.getElementById('contenido').innerHTML= mensaje
	//		document.getElementById("contenido").className='cajacondiciones'
	//		document.getElementById("contenido").style.display = "block";
	//		window.parent.docuprint.location = z

}else if (n==3) {
			mensaje= "<table width=\"408\" height=\"70\"  cellpadding=\"0\" cellspacing=\"0\" class='estilodetexto'>"
		mensaje= mensaje + "  <tr>"
		mensaje= mensaje + "    <td width=\"100\" align=\"center\" valign=\"middle\" id=\"immensajecontenido\"></td>"
		mensaje= mensaje + "    <td width=\"308\" align=\"center\" valign=\"middle\" id=\"txmensajecontenido\"></td>"
		mensaje= mensaje + "  </tr>"
		mensaje= mensaje + "</table>"
		// montando cuerpo del mensaje
		document.getElementById('contenido').innerHTML= mensaje

		document.getElementById('immensajecontenido').innerHTML="<img src=\"imagen/loading1.gif\">" 
		document.getElementById('txmensajecontenido').innerHTML="En estos momentos se está realizando la actualización del catalogo de productos.<br><br><font color='red'>Esta operación puede tardar 10 minutos.<br><br></font><div id='txttiempopendiente'>Solicitando tiempo de reconexíon...</div><br>No cierre la ventana, en cuanto este activa se mostrará de manera automática.<br><br>Att. Dpt Desarrollo Web<br>Gracias." 
	document.getElementById("contenido").className='cajamensajecargando'
	document.getElementById("contenido").style.display = "block";
	toHour=0;
	toMinute=10;
	toSecond=0;
	countDown()

}







}

function cierraloading(){
	//alert('entra')
	//if (document.getElementById("cajamensaje").style.display ="block"){
	document.getElementById("cajamensaje").style.display = "none";
	document.getElementById("contenido").style.display = "none";
	document.getElementById('contenido').innerHTML= ""
	clearTimeout(timerID);
	//}

}

function cuentaloguin(){
timerID = setTimeout("cierraloading()", 5000);
}

function countDown()
{
	toSecond=toSecond-1;
	if(toSecond<0)
	{
		toSecond=59;
		toMinute=toMinute-1;
	}

	if(toMinute<0)
	{
		toMinute=59;
		toHour=toHour-1;
	}
	if(toHour<0)
	{
		//final
		window.location.reload()
	}else{
		setTimeout("countDown()",1000);
		if ((toHour ==0)&&(toMinute ==0)&&(toSecond < 10) ){
			document.getElementById('txttiempopendiente').innerHTML= "Solicitando Contenido Actualizado... en "+toSecond
		}else{
			document.getElementById('txttiempopendiente').innerHTML= toHour+":"+toMinute+":"+toSecond
		}
	}
}
function imprimir() {
if (window.parent.docuprint){
window.parent.docuprint.focus();
window.print();
}}