// INSERTAR FLASH ////////////////////
function insertFlash(url,w,h) {
	var str='';
	str+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ w +'" height="'+ h +'">';
	str+='<param name="movie" value="'+url+'" />';
	str+='<param name="quality" value="high" />';
	str+='<param name="wmode" value="transparent" />';
	str+='<param name="menu" value="false" />';
	str+='<param value="exactfit" name="scale" />';
	str+='<embed src="'+url+'" quality="high" wmode="transparent" scale="exactfit" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="sameDomain" width="'+ w +'" height="'+ h +'"></embed>';
	str+='</object>';
	document.write(str);
}


// PESTANYES //////////////////////
function swapTabClassName(count,tabPre,llistaPre,id,className) {
	for(var i=1;i<=count;i++) {
		var tabIdNow = tabPre+i;
		var llistaIdNow = llistaPre+i;
		document.getElementById(tabIdNow).className = '';
		document.getElementById(llistaIdNow).className = 'hide';
		if(i == id){
			document.getElementById(tabIdNow).className = className;
			document.getElementById(llistaIdNow).className = className;
		}
	}
}

// SLIDE //////////////////////
function FotogaleriaHV(uid) { 
	this.id = uid;
}

FotogaleriaHV.prototype.update = function(symbol) {

	if (symbol == "seguent") {
		this.vo.actual++;
		if(this.vo.actual+1 >= this.vo.size){
			this.vo.actual =this.vo.size-2;
		}
		
	}
	else {
		this.vo.actual--;
		if(this.vo.actual < 0) {
			this.vo.actual = 0;
		}
	}

	var tope=this.vo.actual+1;
	if(tope<=this.vo.foto.length && tope >= 0)
	{
		document.getElementById("Foto0").src =  this.vo.foto[getNextElement(this.vo.foto, this.vo.actual, symbol)] ;
		document.getElementById("Foto0").alt =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual, symbol)] ;	
		document.getElementById("Foto0").title =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual, symbol)] ;	
		//document.getElementById("Link0").href = this.vo.href[getNextElement(this.vo.href, this.vo.actual, symbol)] ;
		document.getElementById("Foto1").alt =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual+1, symbol)] ;
		document.getElementById("Foto1").title =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual+1, symbol)] ;
		document.getElementById("Foto1").src =  this.vo.foto[getNextElement(this.vo.foto, this.vo.actual+1, symbol)] ;
		//document.getElementById("Link1").href = this.vo.href[getNextElement(this.vo.href, this.vo.actual+1, symbol)] ;
	}
		
}
function VO() {
}

function getNextElement(vector, index, symbol){
	if(index >= vector.length){
		return 0;
	}
	else if(index < 0) {
		return  vector.length;
	}
	else{
		if(symbol == "seguent"){
			return index;
		}
		else{
			return index;
		}
	}
}


/*  SLIDE PER QUAN HI HAGI TRES VÍDEOS O MÉS !!!!!!!!

function FotogaleriaHV(uid) { 
	this.id = uid;
}

FotogaleriaHV.prototype.update = function(symbol) {

	if (symbol == "seguent") {
		this.vo.actual++;
		if(this.vo.actual+2 >= this.vo.size){
			this.vo.actual =this.vo.size-3;
		}
		
	}
	else {
		this.vo.actual--;
		if(this.vo.actual < 0) {
			this.vo.actual = 0;
		}
	}

	var tope=this.vo.actual+2;
	if(tope<=this.vo.foto.length && tope >= 0)
	{
		document.getElementById("Foto0").src =  this.vo.foto[getNextElement(this.vo.foto, this.vo.actual, symbol)] ;
		document.getElementById("Foto0").alt =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual, symbol)] ;	
		document.getElementById("Foto0").title =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual, symbol)] ;	
		//document.getElementById("Link0").href = this.vo.href[getNextElement(this.vo.href, this.vo.actual, symbol)] ;
		document.getElementById("Foto1").alt =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual+1, symbol)] ;
		document.getElementById("Foto1").title =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual+1, symbol)] ;
		document.getElementById("Foto1").src =  this.vo.foto[getNextElement(this.vo.foto, this.vo.actual+1, symbol)] ;
		//document.getElementById("Link1").href = this.vo.href[getNextElement(this.vo.href, this.vo.actual+1, symbol)] ;
		document.getElementById("Foto2").alt =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual+2, symbol)] ;
		document.getElementById("Foto2").title =  this.vo.alt[getNextElement(this.vo.alt, this.vo.actual+2, symbol)] ;		
		document.getElementById("Foto2").src =  this.vo.foto[getNextElement(this.vo.foto, this.vo.actual+2, symbol)] ;
		//document.getElementById("Link2").href = this.vo.href[getNextElement(this.vo.href, this.vo.actual+2, symbol)] ;	
	}
		
}
function VO() {
}

function getNextElement(vector, index, symbol){
	if(index >= vector.length){
		return 0;
	}
	else if(index < 0) {
		return  vector.length;
	}
	else{
		if(symbol == "seguent"){
			return index;
		}
		else{
			return index;
		}
	}
}
*/

/* VALIDA FORMULARI */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='El camp '+nm+' La direcció e-mail no és correcte.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' ha de contenir un número entre '+min+' i '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += 'El camp '+nm+' és necessari.\n'; }
  } if (errors) alert('S\'han detectat els següents errors\n'+errors);
  document.MM_returnValue = (errors == '');
}