// JavaScript Document
function centra(){
	ancho = (screen.width/2)-250;
	alto = (screen.height/2)-190;
	window.moveTo(ancho,alto)
	self.focus();

}
function tamany(que,cual,tamh,tamv){
	if(que==1){
		ntamanyh = (document.getElementById('img_'+cual).width*112)/100;
		ntamanyv = (document.getElementById('img_'+cual).height*112)/100;
		document.getElementById('img_'+cual).width = ntamanyh;
		document.getElementById('img_'+cual).height = ntamanyv;
		document.getElementById('img_'+cual).hspace = 7;
		document.getElementById('img_'+cual).vspace = 7;
	} else {
		document.getElementById('img_'+cual).width = tamh;
		document.getElementById('img_'+cual).height = tamv;
		document.getElementById('img_'+cual).hspace = 11;
		document.getElementById('img_'+cual).vspace = 10;
	}
}
function pon_imgs(n){
	for(j=1;j<=n;j++){
		opacity('img_'+j,100,60,500);
	}
}
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}


function DetectaMouse01(e) {
	var posx = 0;
	var posy = 0;
	var ancho = 0;
	
	 ancho = (document.body.clientWidth -780) / 2;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX - ancho;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = (e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft) - ancho;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	if((posx<80)||(posx>205)||(posy<75)||(posy>175)){
		roloveaOf();
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
function DetectaMouse02(e) {
	var posx = 0;
	var posy = 0;
	var ancho = 0;
	
	 ancho = (document.body.clientWidth -780) / 2;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX - ancho;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = (e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft) - ancho;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	if((posx<220)||(posx>385)||(posy<75)||(posy>165)){
		roloveaOf();
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
function DetectaMouse03(e) {
	var posx = 0;
	var posy = 0;
	var ancho = 0;
	
	 ancho = (document.body.clientWidth -780) / 2;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX - ancho;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = (e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft) - ancho;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	document.formulari.resx.value = posx;
	document.formulari.resy.value = posy;
	
	if((posx<390)||(posx>565)||(posy<75)||(posy>125)){
		roloveaOf();
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
function DetectaMouseDos(e) {
	var posx = 0;
	var posy = 0;
	var ancho = 0;
	
	 ancho = (document.body.clientWidth -780) / 2;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX - ancho;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = (e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft) - ancho;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	/*document.res.posix.value = posx;
	document.res.posiy.value = posy;*/
	if(((posx<74)||(posx>212)||(posy<50))&&(document.getElementById('submenu01').style.visibility=="visible")){
		roloveaOf(1);
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
function DetectaMouseTres(e) {
	var posx = 0;
	var posy = 0;
	var ancho = 0;
	
	 ancho = (document.body.clientWidth -780) / 2;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX - ancho;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = (e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft) - ancho;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	/*document.res.posix.value = posx;
	document.res.posiy.value = posy;*/
	if(((posx<212)||(posx>405)||(posy<50))&&(document.getElementById('submenu02').style.visibility=="visible")){
		roloveaOf(2);
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
function DetectaMouseQuatre(e) {
	var posx = 0;
	var posy = 0;
	var ancho = 0;
	
	 ancho = (document.body.clientWidth -780) / 2;
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX - ancho;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = (e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft) - ancho;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	/*document.res.posix.value = posx;
	document.res.posiy.value = posy;*/
	if(((posx<390)||(posx>595)||(posy<50))&&(document.getElementById('submenu03').style.visibility=="visible")){
		roloveaOf(3);
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}
function rolovea(cual){
	document.getElementById('submenu0'+cual).style.visibility="visible"; 
	document.getElementById('submenu0'+cual+'txt').style.visibility="visible"; 
	document.getElementById('bt0'+cual).src='img/bt0'+cual+'02.gif';
}
function roloveaOf(cual){
if(!cual){
	for(i=1;i<=3;i++){
		document.getElementById('submenu0'+i).style.visibility="hidden"; 
		document.getElementById('submenu0'+i+'txt').style.visibility="hidden";
		document.getElementById('bt0'+i).src='img/bt0'+i+'01.gif';
	}
	} else {
		document.getElementById('submenu0'+cual).style.visibility="hidden"; 
		document.getElementById('submenu0'+cual+'txt').style.visibility="hidden";
		document.getElementById('bt0'+cual).src='img/bt0'+cual+'01.gif';
	}
}

function comprova_formulari(){
	if(document.formulari.terreno.value=='si'){
		document.formulari.carac.disabled = false;
		document.formulari.tpoblacion.disabled = false;
		document.formulari.tprovincia.disabled = false;
	} else {
		document.formulari.carac.disabled = true;
		document.formulari.tpoblacion.disabled = true;
		document.formulari.tprovincia.disabled = true;
		}
}