function c(e)
{
	try
	{
		img = null;
		for (i in e.childNodes)
			if (e.childNodes[i].nodeName == 'IMG') img = e.childNodes[i];

		if(img.src.match(/\.off\./))
			img.src = img.src.replace(/\.off\./, '.on.');
		else
			img.src = img.src.replace(/\.on\./, '.off.');
	}
	catch(err)
	{return;}
}

// Achica la imagen si desproporcionar
function imageresize(objimage, maxpix) { 

	tempimage = new Image();
	tempimage.src = objimage.src;
		
	var height = tempimage.height; // Alto
	var width = tempimage.width;	// Ancho
	var info = width+'x'+height+' pxs.';
		
	if (width > maxpix || height > maxpix) { // Controlo si es reamente más grande que los pxs máximos
		if (width > height) {
			// Es más ancha
			height = (maxpix*height)/width;
			width = maxpix;
		} else {
			// Es más alta
			width = (maxpix*width)/height;
			height = maxpix;	
		}
		info += ' (Red)'
	} else {
		/*
		// Es mas chica
		if (width < maxpix || height < maxpix) { 
			if (width > height) {
				// Es más ancha
				height = (maxpix*height)/width;
				width = maxpix;
			} else {
				// Es más alta
				width = (maxpix*width)/height;
				height = maxpix;	
			}
			info += ' (Red)'
		} 
		*/	
	}
		
	objimage.height = height; 
	objimage.width = width;
}
/*
function emubox(action, src, pxwidth, pxheight) {  

	var objbox = document.getElementById("emubox");
	var objbox_src = document.getElementById("emubox_src");
	
	// Dejo en blanco el iframe y oculto
	objbox.style.visibility = "hidden";
	
	if (action == "open") {
		// Abro o cambio
		objbox_src.src = "box_white.html";
		
		var layerpos = document.getElementById("emubox_pos");
		var scrwidth = layerpos.offsetLeft;
		var scrheight = layerpos.offsetTop;
		
		objbox.style.width = pxwidth;
		objbox.style.height = pxheight;
		objbox.style.top = parseInt((scrheight-pxheight)/2);
		objbox.style.left = parseInt((scrwidth-pxwidth)/2);
		
		objbox.style.visibility = "visible";
		objbox_src.src = src;
	} 
}

// control de popups!
function openbox(url,name,features) { 
	
	winPopup = window.open(url,name,features);
		
	if (winPopup == 'failed' || winPopup == null) {
	
		winPopup = 'bloqueado';
	} else {
		winPopup = 'ok';
	}

	if (winPopup == 'bloqueado') {
		// Tiene popups killers
		aryfeatures = features.split(",");
		// ancho
		arytemp = aryfeatures[0].split("=");
		pxwidth = parseInt(arytemp[1]);
		// alto
		arytemp = aryfeatures[1].split("=");
		pxheight = parseInt(arytemp[1]);
		
		emubox('open', url, pxwidth, pxheight);
	} 
}
*/
/* 
// Abre un box de browser *** VIEJO ***
function openbox(url,name,features) { 
	window.open(url,name,features);
}
*/

// Abre popup del envio por email
function openboxmail(section, urlvariables) { 
	var url;
	url = 'box_mail.php?body='+section+'&'+urlvariables;
	features = 'width=300,height=210';
	window.open(url, 'MailBox', features);	
}

// Abre popup del envio de consulta por email
function openboxconsulta(section, urlvariables) { 
	var url;
	url = 'box_consulta.php?body='+section+'&'+urlvariables;
	features = 'width=500,height=290';
	window.open(url, 'MailConsulta', features);	
}

// Abre popup del envio por email
function sendprint(section, urlvariables) { 
	var url;
	url = 'box_print.php?body='+section+'&'+urlvariables;
	features = 'width=650,height=500,scrollbars=yes,resizable=yes';
	window.open(url, 'Print', features);
}

// Abre la ventana de chat
function openboxchat(){
	var url = "box_chat.php"
	window.open(url,'ChatBox','width=310,height=459');

}

function emubox(action, src, pxwidth, pxheight) {  

	var objbox = document.getElementById("emubox");
	var objbox_src = document.getElementById("emubox_src");
	
	// Dejo en blanco el iframe y oculto
	objbox.style.visibility = "hidden";
	
	if (action == "open") {
		// Abro o cambio
		objbox_src.src = "box_white.html";
		
		var layerpos = document.getElementById("emubox_pos");
		var scrwidth = layerpos.offsetLeft;
		var scrheight = layerpos.offsetTop;
		
		objbox.style.width = pxwidth;
		objbox.style.height = pxheight;
		objbox.style.top = parseInt((scrheight-pxheight)/2);
		objbox.style.left = parseInt((scrwidth-pxwidth)/2);
		
		objbox.style.visibility = "visible";
		objbox_src.src = src;
	} 
}

function openbox(url,name,features) { 
	
	winPopup = window.open(url,name,features);
		
	if (winPopup == 'failed' || winPopup == null) {
	
		winPopup = 'bloqueado';
	} else {
		winPopup = 'ok';
	}

	if (winPopup == 'bloqueado') {
		// Tiene popups killers
		aryfeatures = features.split(",");
		// ancho
		arytemp = aryfeatures[0].split("=");
		pxwidth = parseInt(arytemp[1]);
		// alto
		arytemp = aryfeatures[1].split("=");
		pxheight = parseInt(arytemp[1]);
		
		emubox('open', url, pxwidth, pxheight);
	} 
}
