// Libreria de Funciones Generales Javascript
// Optimizada para Netscape 4, Netscape 6, Explorer 4, Explorer 5.
//
// Última modificación: 01/03/2002
//

//Check de navegador y su versión
function CheckNav(){
	// 0 Navegador indeterminado/no reconocido	
	// 1 Netscape 4 o inferior	
	// 2 Microsoft Explorer 4 o inferior	
	// 3 Microsoft Explorer 5	
	// 4 Netscape 5 (Mozilla)	
	var navegador = 0	
	if (document.layers) {navegador=1}	
	if ((document.all) && !(document.getElementById)) {navegador=2}	
	if (document.getElementById) {		
	if (document.all) {navegador=3}		
	else {navegador=4}		
	}	
	return navegador;
}

//Actualiza el contenido de una capa(pasada por parametro)	
function ActualizaCapa(id,content) {	
var navegador = CheckNav();
	switch (navegador)		
	{			
	case 1 : 			
		var lyr = document.layers[id].document;			
		lyr.open();			
		lyr.write(content);			
		lyr.close();
		break;
	case 2 :
	case 3 : 
		document.all[id].innerHTML = content;
		break;		
	case 4 : 
		document.getElementById(id).innerHTML = content;
		break;		
	}
}

//Recupera parametros de la url
function GetParam(sNomParam) {
	var sCerca,asParametres,asParam;
	sCerca = location.search.substring(1,location.search.length);
	asParametres = sCerca.split("&");
	for(var i=0;i<asParametres.length;i++) {
		asParam = asParametres[i].split("=");
		if (asParam[0] == sNomParam) return asParam[1];
	}
    return "";
}		

/*******************************/
//Funciones MACROMEDIA
//Precarga de imagenes
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];}}
}

//Oculta o muestra capas
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//Busqueda de objetos DIV
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;
}

//Rollover
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Restaura TODOS los cambios realizados por la funcion MM_swapImage()
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function prepareFlash ( fitxer, nom, ample, alt ) {
	
if ((window.ActiveXObject) && 
      (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
{
d = '<OBJECT id="'+nom+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';
d += ' WIDTH='+ample+' HEIGHT='+alt+'>';
d += '<PARAM NAME=movie VALUE="'+fitxer+'">';
d += '<PARAM name="allowScriptAccess" value="sameDomain"/>';
d += '<PARAM NAME=quality VALUE=high>';
d += '<param name=menu value=false>';
d += '<PARAM NAME=wmode VALUE=transparent>';
d += '</OBJECT>';
}
else
{
d = '<OBJECT id="'+nom+'"  data="'+fitxer+'" type="application/x-shockwave-flash"';
d += ' WIDTH='+ample+' HEIGHT='+alt+'>';
d += '<PARAM NAME=movie VALUE="'+fitxer+'">';
d += '<PARAM name="allowScriptAccess" value="sameDomain"/>';
d += '<PARAM NAME=quality VALUE=high>';
d += '<param name=menu value=false>';
d += '<PARAM NAME=wmode VALUE=transparent>';
d += '</OBJECT>';
}
return d;
}	
