//precaching de pestañas
pst1 = new Image (100, 18);
pst2 = new Image (100, 18);
pst3 = new Image (100, 18);
pst4 = new Image (100, 18);
pst5 = new Image (100, 18);
pst6 = new Image (100, 18);
pst1.src="http://www.e-noticies.com/images/menu/subscripcions_si.gif";
pst2.src="http://www.e-noticies.com/images/menu/enviar_si.gif";
pst3.src="http://www.e-noticies.com/images/menu/hemeroteca_si.gif";
pst4.src="http://www.e-noticies.com/images/menu/subscripcions_no.jpg";
pst5.src="http://www.e-noticies.com/images/menu/enviar_no.jpg";
pst6.src="http://www.e-noticies.com/images/menu/hemeroteca_no.jpg";



size = 0.70;
function zoomIn() {
	if (size < 0.9){
		size += 0.2;
	    document.body.style.fontSize = size+'em';
	}
}
function zoomOut() {
	if ( size > 0.70 ){
		size -= 0.2;
		document.body.style.fontSize = size+'em';
	}
}
function comentar(obj){
	var a= document.getElementById(obj).style.display;
	//alert(a);
	if (a == "none"){
		document.getElementById(obj).style.display="";
	}else{
		document.getElementById(obj).style.display="none";
	}
}
function overMenu(obj,which){

	switch(which){
		case "1":
			obj.src="http://www.e-noticies.com/images/menu/subscripcions_si.gif";
			break;
		case "2":
			obj.src="http://www.e-noticies.com/images/menu/enviar_si.gif";
			break;
		case "3":
			obj.src="http://www.e-noticies.com/images/menu/hemeroteca_si.gif";
			break;
		case "4":
			obj.src="http://www.e-noticies.com/images/menu/etv_si.gif";
			break;
		default:
			break;
	}
	var i=1;
	while (1){
		var menu=document.getElementById("menu"+i);

		if (menu){
			menu.style.display="none";
		}else{
			break;
		}
		i++;
	}
	document.getElementById("menu"+which).style.display="";

}
function outMenu(obj,which){

	switch(which){
		case "1":
			obj.src="http://www.e-noticies.com/images/menu/subscripcions_no.jpg";
			break;
		case "2":
			obj.src="http://www.e-noticies.com/images/menu/enviar_no.jpg";
			break;
		case "3":
			obj.src="http://www.e-noticies.com/images/menu/hemeroteca_no.jpg";
			break;
		case "4":
			obj.src="http://www.e-noticies.com/images/menu/etv_no.jpg";
			break;
		default:
			break;
	}
}

function caracteresPermitidos(num){
	var obj=document.getElementById("permesos");
	var op=255-num;
	obj.innerHTML=op;

}

function caracteresPermitidosDown(valor){

	if(valor.length >= 255){ 
			alert(valor.length);
		return false;
	}
	//if(valor.length >= 255){ 
		//alert(window.event.wich);return false;
		//if (code == "8" || code == "46"){
		//	return true;
		//}else{
		//	return false;
		//}
	//}
}

function imprimir(iddoc, cat, subcat){
	width = 502; 
	height = 450; 
	leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	if (screen.height && (screen.height <= 600)) {
		topPosition = 0;
	} else {
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	}
	var settings='width='+width+', height='+height+', left='+leftPosition+', top='+topPosition+', toolbar=0, location=0, directories=0, menubar=0, scrollbars=1, resizable=0, status=0';
	var popup=window.open("http://www.e-noticies.com/pop/print/?iddoc="+iddoc+"&cat="+cat+"&subcat="+subcat, 'imprimir', settings);
	popup.focus();
}

function cargaAudio(param){
	document.getElementById("capa_audio").style.display="";
//	document.location.href="#mul";
}
function escondeAudio(param){
	document.getElementById("capa_audio").style.display="none";
//	document.location.href="#mul";
}
function cargaVideo(param){
	document.getElementById("capa_video").style.display="";
//	document.location.href="#mul";
}

function escondeVideo(param){
	document.getElementById("capa_video").style.display="none";
//	document.location.href="#mul";
}

function cargaMultimedia(doc, indice){
	width = 780; 
	height = 500; 
	leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	if (screen.height && (screen.height <= 600)) {
		topPosition = 0;
	} else {
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	}
	var settings='width='+width+', height='+height+', left='+leftPosition+', top='+topPosition+', toolbar=0, location=0, directories=0, menubar=0, scrollbars=0, resizable=0, status=0';
	var popup=window.open("http://www.e-noticies.com/pop/multimedia/?iddoc="+doc+"&indice="+indice, 'imprimir', settings);
	popup.focus();
}


function cargaGaleria(doc){
	width = 795; 
	height = 600; 
	leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	if (screen.height && (screen.height <= 600)) {
		topPosition = 0;
	} else {
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	}
	var settings='width='+width+', height='+height+', left='+leftPosition+', top='+topPosition+', toolbar=0, location=0, directories=0, menubar=0, scrollbars=1, resizable=0, status=0';
	var popup=window.open("http://www.e-noticies.com/pop/galeries/?iddoc="+doc, 'galeries', settings);
	popup.focus();
}

function openTv(cat, subcat, iddoc){
	width = 820; 
	height = 500; 
	leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	if (screen.height && (screen.height <= 600)) {
		topPosition = 0;
	} else {
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	}
	var settings='width='+width+', height='+height+', left='+leftPosition+', top='+topPosition+', toolbar=0, location=0, directories=0, menubar=0, scrollbars=0, resizable=0, status=0';
	var popup=window.open("http://www.e-noticies.com/pop/e-tv/?idcat="+cat+"&subcat="+subcat+"&iddoc="+iddoc, 'multimedia', settings);
	popup.focus();
}

function openMunicipals(cat, subcat, iddoc){
	width = 820; 
	height = 500; 
	leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	if (screen.height && (screen.height <= 600)) {
		topPosition = 0;
	} else {
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	}
	var settings='width='+width+', height='+height+', left='+leftPosition+', top='+topPosition+', toolbar=0, location=0, directories=0, menubar=0, scrollbars=0, resizable=0, status=0';
	var popup=window.open("http://www.e-noticies.com/pop/e-municipals/?idcat="+cat+"&subcat="+subcat+"&iddoc="+iddoc, 'multimediamunicipals', settings);
	popup.focus();
}

function openHumor(cat, subcat, iddoc){
	width = 820; 
	height = 500; 
	leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	if (screen.height && (screen.height <= 600)) {
		topPosition = 0;
	} else {
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	}
	var settings='width='+width+', height='+height+', left='+leftPosition+', top='+topPosition+', toolbar=0, location=0, directories=0, menubar=0, scrollbars=0, resizable=0, status=0';
	var popup=window.open("http://www.e-noticies.com/pop/e-humor/?idcat="+cat+"&subcat="+subcat+"&iddoc="+iddoc, 'humor', settings);
	popup.focus();
}

function comentar(){
	if (document.getElementById("mod_com").style.display == ""){
		document.getElementById("mod_com").style.display="none";
	}else{
		document.getElementById("mod_com").style.display="";
		document.getElementById("mod_tra").style.display="none";
//		document.location.href="#com";
	}
	
}

function trametre(){
	if (document.getElementById("mod_tra").style.display == ""){
		document.getElementById("mod_tra").style.display="none";
	}else{
		document.getElementById("mod_tra").style.display="";
		document.getElementById("mod_com").style.display="none";
//		document.location.href="#tra";
	}
	
}

function valFormTrametre(frm){
	/*if (!validarEmail(frm.tra_origen.value)){
		alert("Informar el mail origen correctament és obligatori.");
		frm.tra_origen.focus();
		return false;
	}*/
	if (!validarEmail(frm.tra_destino.value)){
		alert("Informar el mail destí correctament és obligatori.");
		frm.tra_destino.focus();
		return false;
	}

	/*if (frm.tra_comentari.value == ""){
		alert("Informar el comentari és obligatori.");
		frm.tra_comentari.focus();
		return false;
	}*/
	var poststr = "iddoc="+frm.iddoc.value+"&orig="+frm.tra_origen.value+"&dest="+frm.tra_destino.value+"&comentari="+frm.tra_comentari.value;
	//alert(poststr);
	makePostRequest("/proc/trametre.php", 'tra_msg', poststr);

}

function valFormSendGaleria(frm, i){
	//alert(frm);alert(i);return false;
	//eval("emilio=frm.emilio"+i+".value;");
	var email=document.getElementById("email"+i);
	var iddoc=document.getElementById("iddoc"+i);
	var urlimg=document.getElementById("urlimg"+i);
	var comentari=document.getElementById("comentari"+i);

	if (!validarEmail(email.value)){
		alert("Informar el mail correctament és obligatori.");
		email.focus();
		return false;
	}
	var poststr = "iddoc="+iddoc.value+"&email="+email.value+"&comentari="+comentari.value+"&urlimg="+urlimg.value;
	makePostRequest("/proc/trametre_galeria.php", 'tra_msg', poststr);

}

function valFormComentaris(frm){
	if (frm.com_nom.value == ""){
		alert("Informar el nom és obligatori.");
		frm.com_nom.focus();
		return false;
	}
	if (!validarEmail(frm.com_email.value)){
		alert("Informar el mail correctament és obligatori.");
		frm.com_email.focus();
		return false;
	}
	if (frm.com_ciutat.value == ""){
		alert("Informar la ciutat és obligatori.");
		frm.com_ciutat.focus();
		return false;
	}
	if (frm.com_comentari.value.length > 255){
		alert("No pot excedir els 255 caràcters per enviar el comentari.");
		frm.com_comentari.focus();
		return false;
	}
	//if (frm.com_comentari.length()){
	//}
	if (frm.com_comentari.value == ""){
		alert("Informar el comentari és obligatori.");
		frm.com_comentari.focus();
		return false;
	}
	var poststr = "iddoc="+frm.iddoc.value+"&nom="+frm.com_nom.value+"&email="+frm.com_email.value+"&ciutat="+frm.com_ciutat.value+"&comentari="+frm.com_comentari.value;
	//alert(poststr);
	makePostRequest("/proc/comentarios.php", 'com_msg', poststr);

}

function hmrtcFooter(){
	//alert(window.document.location.href);
	var regexp=/edicio-/;
	var cad=document.location.href;
	if (regexp.test(cad)){
		//document.write("<center><div style=\"position:absolute;top:0px;left:0px;width:780px;text-align:center;background-color:#FFFF99\"><div style=\"width:728px;margin:auto;text-align:center;white-space:nowrap;color:#000000;line-height:30px;height:20px;line-height:20px\">Estàs navegant per l'hemeroteca d'enotícies. Fes <a href=\"http://hemeroteca.e-noticies.com\">click aquí</a> per tornar</div></center>");
	}
}
function vistaBackoffice(url){
	//var wnd=window.open(url, "vista", "");

	window.opener.location.href=url;
	window.opener.focus();
}
