// Funciones by Oskratch 2006

// Funcion Popup 

ventanas=new Array();

function abre(destino,name,ancho,alto){
	//alert(destino);
	anchura="";
	altitud="";
	anchura+="width=";
	anchura+=ancho;
	altitud+="height=";
	altitud+=alto;
	tamany="";
	tamany=anchura;
	tamany+=",";
	tamany+=altitud;
	
    if (ventanas[name]!=undefined) ventanas[name].close();
			
	ventanas[name]=window.open(destino,name,tamany);
					
}

// Creditos

function abreCreditos(idioma){
		
	abre('popups/creditos.php?idioma='+idioma,'creditos',250,80);
		
}

// Fotitos

function ver_foto(esta,lang){
	
	abre('imagen_taller.php?imagen='+esta+'&lang='+lang,'taller',100,100);
	
}

// Funcion anti-objeto explorer (flash)

function deshabilita(){
	
	objects = document.getElementsByTagName("object");
	
	for (var i = 0; i < objects.length; i++){
    
	objects[i].outerHTML = objects[i].outerHTML;
	
	}
}

// Contacto (Formulario)

function contactar(idioma){
	
	abre('contactar.php?lang='+idioma,'contactar',365,400);	
	
}

// Contacto (Formulario)

function mapa(idioma){
	
	abre('mapa.php?lang='+idioma,'contactar',490,400);	
	
}

// Horarios

function horarios(idioma){
	
	abre('horaris.php?lang='+idioma,'horaris',365,312);	
	
}

// Control de la ventana

function tamany(ancho,alto){
	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
	//var ample:Number=0;
    ample=ancho-4;
	alt=alto-5;
	restaurtamany(ample,alt);
	//alert("Non IE : Ancho y alto: "+ancho+" / "+alto+" Tratado a: "+ample+" / "+alt);
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
	//alert("ie6+");
 restaurtamany(ancho,alto);
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
   restaurtamany(ancho,alto);
   //alert("ie4");
  }
}

function restaurtamany(ancho,alto){
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(myWidth<ancho){
  for(l=myWidth;l<ancho;l+=5){
	  window.resizeTo(l,myHeight);
  }
  }else{
	   for(l=myWidth;l>ancho;l-=5){
	  window.resizeTo(l,myHeight);
  }
  }
  if(myHeight<alto){
   for(y=myHeight;y<alto;y+=5){
	  window.resizeTo(ancho,y);
  }
  }else{
	  for(y=myHeight;y>alto;y-=5){
	  window.resizeTo(ancho,y);
  }
  }
	window.resizeTo(ancho,alto);
}

// Mi Alert (errores)

function miAlert(lang,text,texto){
	
if(lang == "esp"){

url = "popups/errores.php?lang="+lang+"&texto="+texto;

}else{
	
url = "popups/errores.php?lang="+lang+"&texto="+text;

}

abre(url,'error',220,120);
	
}

// Envia formulario Contacto / Validar

function envia_form(lang){
	
	if(document.contacta.nombre.value != ""){
		
	if(document.contacta.email.value != ""){
		
	if(document.contacta.comentario.value != ""){
	
	document.contacta.submit();
		
	}else{
	
	miAlert(lang, 'Escriu el teu comentari o missatge', 'Escribe tu comentario o mensaje');
		
	}		
	
	}else{
		
	miAlert(lang, 'Escriu la teva adreça de correu electrònic', 'Escribe tu dirección de correo electrónico');
		
	}		
		
	}else{
	
	miAlert(lang, 'Escriu el teu nom', 'Escribe tu nombre');
		
	}
	
}

// Funcion temporal propia dreamweaver

	function preloadImagesss(idioma) { 
	
	}
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	
	
	function preload(){
	
	MM_preloadImages('img/botigueta_1.jpg','img/botigueta_2.jpg','img/botigueta_linea.jpg','img/carta_1esp.jpg','img/carta_2.jpg','img/carta_1.jpg','img/cartasgrups_1.jpg','img/cartasgrups_1esp.jpg','img/recomanen1.jpg','img/recomanen1esp.jpg','img/recomanen2.jpg.','img/taller_1_esp.jpg','img/taller_1.jpg','img/taller_2.jpg','img/qui_1.jpg','img/qui_1_esp.jpg','img/cartas_1esp.jpg','img/cartas_1.jpg','img/home_1.jpg');
		
	}


// Otra opcion insertar flash
	
	function insertarFlash(name,width,height){
		
		document.write('<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="'+width+'" height="'+height+'">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="'+name+'" /><param name="wmode" value="transparent"><param name="menu" value="false" /><embed src="'+name+'" quality="high" width="'+width+'" height="'+
					   height+'" quality="high" allowScriptAccess="sameDomain" wmode="transparent" menu="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
		
	}