
// 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
function openbox(url,name,features) { 
	window.open(url,name,features);
}
*/

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

// abra popup de impresion
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');
	window.open(url,'ChatBox','width=450,height=470');

}

function openboxchat2(){
	var url = "box_chat2.php"
	window.open(url,'ChatBox','width=450,height=470');

}
