
//
// ticker
//
$(function() {
	$("div#scrollingText").smoothDivScroll({scrollingSpeed: 50, autoScroll: "always", autoScrollOnStart: true, autoScrollDirection: "endlessloop", pauseAutoScroll: "mouseover"});
});
//
// esbrinat posició element (id) en pantalla
//
function posicioelement(nomelement) {
	alert(nomelement);
	//posicio_x_nomelement=document.getElementById(nomelement).appendChild(x);
	document.getElementById(nomelement).style.visibility="visible";
	//document.getElementById(nomelement).style.top="100";
	//return posicio_x_campelement;
	//alert(posicio_x_campelement);
}

//
// buscar des de qualsevol pàgina
//
function buscadorc() {
	var zona    =document.buscadorcases.lzones.value;
	var poblacio=document.buscadorcases.lpoblacions.value;
	var tipus   =document.buscadorcases.ltipus.value;
	// ------------------------
	//alert("zona:" +zona+"\n"+"poblacio:"+poblacio+"\n"+"tipus:"+tipus);
	opcions="";
	if (zona == 0) { alert("Avís:\n\nHeu d'indicar una zona."); }
		else {
			document.buscadorcases.submit();
		}
}
//
// gestió de capes/submenús
//
function mostrar(nomcapa) {
	document.getElementById(nomcapa).style.visibility="visible";
	setTimeout("amagar('"+nomcapa+"');",10000);
} 
function amagar(nomcapa)  {
	document.getElementById(nomcapa).style.visibility="hidden";
} 
//
//
function setStyle(element, styleText){
	if(element.style.setAttribute)
		element.style.setAttribute("cssText", styleText );
	else
		element.setAttribute("style", styleText );
}
function getStyle(element){
 	var styleText = element.getAttribute('style');
 	if(styleText == null)
		return "";
	if (typeof styleText == 'string') // !IE
		return styleText;
	else  // IE
		return styleText.cssText;
}
function mantefons(a,b,c,d) {
	//alert(a +"\n" + b);
	bb="linkopccat"+c;
	/* <![CDATA[ */
	var my_element = document.getElementById(b);
	//var estilinici = getStyle(my_element);
	var estilinici1 = "background:none;";
	var estilmodif1 = "background-image:url(/galeria/fons_opcio_cat_02.png); background-position: left top;";
	var estilinici2 = "background-color:#ffffff;";
	var estilmodif2 = "background-color:#B6C2C1;";
	/* ]]> */
	
	if (a=="s") { // amb el ratolí A SOBRE
		//document.getElementById(b).style.background="red"; // canviar color fons
		//document.getElementById(b).style.backgroundImage="url(/galeria/fons_opcio_cat_02.png)"; // canviar imatge fons
		//document.getElementById(b).style.textAlign ="right"; // aliniar el text a la dreta
		if (d=="1") { // si l'opcio es del menu 1
			document.getElementById(bb).style.color="#000"; // color del text (no dels enllaços)
			setStyle(my_element, estilmodif1); // modificar imatge de fons (compatible amb IE)
		}
		if (d=="2") { // si l'opcio es del menu 2
			document.getElementById(bb).style.color="#000"; // color del text (no dels enllaços)
			setStyle(my_element, estilmodif2); // modificar imatge de fons (compatible amb IE)
		}
	}
	if (a=="n") { // amb el ratolí FORA
		//document.getElementById(b).style.background=""; // deixar sense color fons
		//document.getElementById(b).style.backgroundImage=""; // deixar sense imatge fons
		//document.getElementById(b).style.textAlign="left"; // aliniar el text a l'esquerra
		if (d=="1") { // si l'opcio es del menu 1
			document.getElementById(bb).style.color="#000"; // color del text (no dels enllaços)
			setStyle(my_element, estilinici1); // modificar imatge de fons (compatible amb IE)
		}
		if (d=="2") { // si l'opcio es del menu 2
			document.getElementById(bb).style.color="#000"; // color del text (no dels enllaços)
			setStyle(my_element, estilinici2); // modificar imatge de fons (compatible amb IE)
		}
	}

}
//
//
// imatge en 360º
//
function DoAutorotationStart() { document.vista.startAutoPan( 0.3, 0.0, 1.0 ); }
function DoAutorotationStop() { document.vista.stopAutoPan(); }
function DoZoomIn() { document.vista.startAutoPan( 0.0, 0.0, 1/1.002 ); }
function DoZoomOut() { document.vista.startAutoPan( 0.0, 0.0, 1.002 ); }
function DoShowHideHotspots() {	document.vista.toggleHS(); }
function DoReset() { document.vista.gotoView( -45, -60, 80 ); }
function DisplayPan() {	status = document.vista.pan().toString() ; }
function DisplayTilt() { status = document.vista.tilt().toString() ; }
function DisplayFov() { status = document.vista.fov().toString() ; }
//
function mousehs(n) {
	if ( n== -1 ) document.cn.hsnum.value = "---" ;
	else document.cn.hsnum.value = n ;
}
function getview(p,t,f) {
	document.cn.pan.value = p ; document.cn.tilt.value = t ; document.cn.fov.value = f ;
}
//
function NewPano( pano ) {
	document.vista.newPano( pano ) ;   document.vista.start();
}
//
function passaparam(ii,d,m,a,sel) { //paràmetre cercar activitats agenda
	//    ii=mes i any    d=dia    m=mes    a=any
	document.agenda.ii.value=ii   ;   document.agenda.d.value=d;
	document.agenda.m.value=m     ;   document.agenda.a.value=a;
	document.agenda.sel.value=sel ; 
	//
	document.agenda.submit();
}
//
function canvititolpagina(nomweb,titolpagina) {
	titolpagina = titolpagina.replace(/<[^>]+>/g,''); // eliminar les etiquetes html (per si n'hi ha)
	document.title = nomweb + ": " + titolpagina;
}
//
function enviar_recomanacio() { // comprovar formulari recomanació de contingut
	msg=""; idioma=document.formrecomana.idioma.value;
	// -----------------------
	email=document.formrecomana.email.value;
	amic=document.formrecomana.amic.value;
	paraulaverif=document.formrecomana.paraulaverif.value;
	paraulaverif=paraulaverif.toLowerCase();
	camp1=document.formrecomana.camp1.value;
	//
	if (idioma=="ca") {
		paraulaavis="Avís";
		if (email == "")		{ msg=msg+" - no heu indicat el vostre correu electrònic \n"; }
		if (email != 0)		{
			if ((email.indexOf('@') == -1) || (email.indexOf('.')== -1)) msg= msg+" - el vostre correu electronic no és correcte \n"; }
		//
		if (amic == "")		{ msg=msg+" - no heu indicat el correu electrònic del destinatari \n"; }
		if (amic != 0)		{
			if ((amic.indexOf('@') == -1) || (amic.indexOf('.')== -1)) msg= msg+" - el correu electronic del destinatari no és correcte \n"; }
		//
		if (paraulaverif=="")	{ msg=msg+" - no heu escrit la paraula de verificació \n"; }
		if ((paraulaverif!="") && (paraulaverif!=camp1)) { msg=msg+" - la paraula de verificació escrita no coincideix amb la de la imatge mostrada \n"; }
	}
	//
	if (idioma=="es") {
		paraulaavis="Aviso";
		if (email == "")		{ msg=msg+" - no ha indicado su e-mail \n"; }
		if (email != 0)		{
			if ((email.indexOf('@') == -1) || (email.indexOf('.')== -1)) msg= msg+" - su e-mail no es correcto \n"; }
		//
		if (amic == "")		{ msg=msg+" - no ha indicado el e-mail del destinatario \n"; }
		if (amic != 0)		{
			if ((amic.indexOf('@') == -1) || (amic.indexOf('.')== -1)) msg= msg+" - el e-mail del destinatario no es correcto \n"; }
		//
		if (paraulaverif=="")	{ msg=msg+" - no ha escrito la palabra de verificación \n"; }
		if ((paraulaverif!="") && (paraulaverif!=camp1)) { msg=msg+" - la palabra de verificación escrita no coincide con la de la imagen mostrada \n"; }
	}
	// -----------------------
	if (msg!="") {
		alert (paraulaavis + ":\n\n"+msg);
		}
		else {
			document.formrecomana.submit();
			}
}
//
//



