var actual = null;

function open_share_box(id) {
	document.getElementById('share_'+id).style.display = 'block';	
}

function open_foto(titol,foto,sel,total) {
	LeftPosition = (screen.width) ? (screen.width - 900) / 2 : 0;
	TopPosition = (screen.height) ? (screen.height - 700) / 2 : 0;
	window.open ('bigCustom.asp?titol='+titol+'&foto='+foto+'&sel='+sel+'&total='+total,'','width=900,height=600,statusbar=no,scrollbars=no,mainbar=no,toolbar=no,left='+LeftPosition+',top='+TopPosition);
}

function open_w(url,w,h) {
	LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
	TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
	window.open (url,'','width='+w+',height='+h+',statusbar=no,scrollbars=no,mainbar=no,toolbar=no,left='+LeftPosition+',top='+TopPosition+'');
}

function credits()
{
	LeftPosition = (screen.width) ? (screen.width-300)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-150)/2 : 0;
	window.open ('credits.asp','','width=300,height=150,scrollbars=no,statusbar=no,toolbar=no,mainbar=no,left='+LeftPosition+',top='+TopPosition+'');
}

function change_photo(photo,id) {
	document.getElementById('text_inicial').style.display = 'none';
	if (actual!=null) {
		document.getElementById('text_'+actual).style.display = 'none';
	}
	document.getElementById('text_'+id).style.display = 'block';
	actual = id;
	document.getElementById('ampliacio').src = 'imag/galerias/' + photo;
}

function change_photo_i(photo,id) {
	document.getElementById('text_inicial').style.display = 'none';
	if (actual!=null) {
		document.getElementById('text_'+actual).style.display = 'none';
	}
	document.getElementById('text_'+id).style.display = 'block';
	actual = id;
	document.getElementById('ampliacio').src = '../imag/galerias/' + photo;
}

function change_photo_admin(photo,id) {
	document.getElementById('text_inicial').style.display = 'none';
	if (actual!=null) {
		document.getElementById('text_'+actual).style.display = 'none';
	}
	document.getElementById('text_'+id).style.display = 'block';
	actual = id;
	document.getElementById('ampliacio').src = '../imag/galerias/' + photo;
}

function change_photo_news_admin(num,id,foto) {
	document.getElementById('ampliacio_'+id).src='../imag/'+foto;
	
	if (document.getElementById('foto1_'+id)) {
		document.getElementById('foto1_'+id).style.filter='alpha(opacity=40)';	
	}
	if (document.getElementById('foto2_'+id)) {
		document.getElementById('foto2_'+id).style.filter='alpha(opacity=40)';
	}
	if (document.getElementById('foto3_'+id)) {
		document.getElementById('foto3_'+id).style.filter='alpha(opacity=40)';
	}
	
	document.getElementById('foto'+num+'_'+id).style.filter='none';
}

function change_photo_news(num,id,foto) {
	document.getElementById('ampliacio_'+id).src='imag/'+foto;
	
	if (document.getElementById('foto1_'+id)) {
		document.getElementById('foto1_'+id).style.filter='alpha(opacity=40)';	
	}
	if (document.getElementById('foto2_'+id)) {
		document.getElementById('foto2_'+id).style.filter='alpha(opacity=40)';
	}
	if (document.getElementById('foto3_'+id)) {
		document.getElementById('foto3_'+id).style.filter='alpha(opacity=40)';
	}
	
	document.getElementById('foto'+num+'_'+id).style.filter='none';
}

function otros_contacte() {
	
	valor = document.form_contacte.sector_de_actividad.options[document.form_contacte.sector_de_actividad.selectedIndex].value;
	if (valor==19) {	
		document.getElementById('otros_camp').style.visibility = 'visible';
	} else {
		document.getElementById('otros_camp').style.visibility = 'hidden';
	}	
}

function open_url(url) {
	window.location.href = url;
}

function send_newsletter_form() {
	var email = $("#newsletter_in").val();
	if (email!='') {
		$.post('newsletter_sub.asp', { email: email }, function(data) {
			$("#NEWSLETTER_container").html('<p>Gracias por registrarte.</p>');
		});
	}
}

function enviarBuscador() {
	$("#buscador").submit();
}
	
function show_submenu(opt) {
	hide_submenus();
	$("#"+opt).show();
}

function hide_submenus() {
	$("#submenu_productos").hide();
	$("#submenu_especiales").hide();
}
