 //************************************************* checkBrowser ******************************************
function checkBrowser() { 
  var verStr=navigator.appVersion 
  var app=navigator.appName 
  var version = parseFloat(verStr);  
  if (app.indexOf('Netscape') != -1) 
  {
   version=version;
   nomBrowser="netscape";
   versionBrowser=version;
  }  

  if (app.indexOf('Microsoft') != -1) 
  {   
   version=verStr.substr((verStr.indexOf('MSIE')+4),(verStr.indexOf(';',verStr.indexOf('MSIE'))-(verStr.indexOf('MSIE')+4)));   
   nomBrowser="explorer";
   versionBrowser=version;
  }
  
  /* 
  RETURNED VALUES
  Netscape 4.7  --> nameBrowser: netscape  versionBrowser: 4.7
  Netscape 6  --> nameBrowser: netscape  versionBrowser: 5 
  Explorer 4  --> nameBrowser: explorer versionBrowser: 4.01
  Explorer 5.0  --> nameBrowser: explorer versionBrowser: 5.01
  Explorer 5.5  --> nameBrowser: explorer versionBrowser: 5.5  
  Explorer 6.0  --> nameBrowser: explorer versionBrowser: 6.0  */    
  return true;
}

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinNS6 = (!document.all && document.getElementById)? true:false;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

var nomBrowser
var versionBrowser

ns= (navigator.appName.substring(0,1) == 'N');
ie= (navigator.appName.substring(0,1) == 'M');

//****************************** mostrarMissatge **************************************

function mostrarMissatge(miss){
  alert(miss);
}

//****************************** obrirFinestraCentrada ********************************

function obrirFinestraCentrada(sarxiu,snom,stoolbar,sstatus,swidth,sheight,sresizable,sscrollbars){
var stop,sleft,parametres;
	sleft = (((screen.width - parseInt(swidth))/2)/10)*10;
	stop = (((screen.height - parseInt(sheight))/2)/10)*10;
	parametres = "toolbar=" + String(stoolbar) + ",status=" + String(sstatus) + ",width=" + String(swidth) + ",height=" + String(sheight) + ",resizable=" + String(sresizable) + ",top=" + String(stop) + ",left=" + String(sleft)+ ",scrollbars=" + String(sscrollbars);
    if (sarxiu.indexOf("https:") == 0)
        return window.open(String(sarxiu),String(snom),String(parametres))
    else
      if (sarxiu.indexOf("http:") != 0)	    
 	 return window.open(String("/"+sarxiu),String(snom),String(parametres))
      else 
 	 return window.open(String(sarxiu),String(snom),String(parametres));
}

//****************************** MM_swapImage *****************************************
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];}
}


//****************************** MM_swapImgRestore ************************************
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;
}


//****************************** MM_findObj *******************************************

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


//****************************** MM_preloadImages *************************************
//exemple MM_preloadImages('imagen1.gif','imagen2.gif','imagen3.gif'...)
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];}}
}


//****************************** escriureCapa *****************************************

function escriureCapa(id,nestref,text) {
        if (isMinNS4) {
                var lyr = document.layers[id];
                lyr.document.open();
                lyr.document.write(text);
                lyr.document.close();                            
        }
        else{
			layer = document.getElementById(id);
			layer.innerHTML = text;
		}
}


//****************************** getLayerContent **************************************

function getLayerContent(id,nestref) {       		
		if (isMinNS4) {
				var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document;
                return lyr.open();
        }
        else{
			layer = document.getElementById(id);
			return layer.innerHTML;
        }
}


//****************************** mostrarCapa ******************************************

function mostrarCapa(id) {
	if (isMinNS4) document.layers[id].visibility = "show"
	else if (isMinIE4) document.all[id].style.visibility = "visible"
		else if (isMinNS6) document.getElementById(id).style.visibility = "visible"
}


//****************************** ocultarCapa ******************************************

function ocultarCapa(id) {
	if (isMinNS4) document.layers[id].visibility = "hide"
	else if (isMinIE4) document.all[id].style.visibility = "hidden"
		else		
			if (isMinNS6){
				 document.getElementById(id).style.visibility = "hidden"
			}
}


//****************************** Mouse Events ******************************************
function getMouseX(e) {
  var tempX;
  if (ie) {
    tempX = event.clientX + document.body.scrollLeft
  } else {  
    tempX = e.pageX
  }  
  if (tempX < 0){tempX = 0}

  return tempX
}

function getMouseY(e) {
  var tempY;
  if (ie) { 
    tempY = event.clientY + document.body.scrollTop
  } else { 
    tempY = e.pageY
  }  
  
  if (tempY < 0){tempY = 0} 
  
  return tempY
}

//****************************** Find Pos ******************************************
function findPosY(obj)
{
	var curtop = 0;

	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}

	}
	else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft + 10;
}

//****************************** Canviar Color/Cursor ******************************************
function canviarCursor(obj) {	
	if (ns) {
		obj.style.cursor='pointer'
	}
	else{
		obj.style.cursor='hand';
	}

}

function canviarColor(obj,color){ 
	obj.style.color = color; 
}


//********************************** Mides pantalla *********************************************
fx= (navigator.appName.substring(0,1) == 'N');
ie= (navigator.appName.substring(0,1) == 'M');

function getDocumentWidth(){
	if (fx){
		return window.innerWidth
	}else{
		if (ie){
			//return document.body.clientWidth
			return document.body.scrollWidth 
		}
	}
}

function getDocumentHeight(){
	if (fx){
		return window.innerHeight
	}else{
		if (ie){
			//return document.body.clientHeight
			return document.body.scrollHeight
		}
	}
}

function getDocumentClientWidth(){
	if (fx){
		return window.innerWidth
	}else{
		if (ie){
			return document.body.clientWidth
			//return document.body.scrollWidth 
		}
	}
}

function getDocumentClientHeight(){
	if (fx){
		return window.innerHeight
	}else{
		if (ie){
			return document.body.clientHeight
			//return document.body.scrollHeight
		}
	}
}

function omplirCapaPantalla(nomcapa){
  var capa = document.getElementById(nomcapa);
  if (capa!=null){
     capa.width  = getDocumentWidth();     
     capa.height = getDocumentHeight();
     
     capa.style.width  = getDocumentWidth();     
     capa.style.height = getDocumentHeight();
  }
  return true;
}

function centrarCapaPantalla(nomcapa){
  var capa = document.getElementById(nomcapa);
  if (capa != null){
	vwidth = String(capa.style.width).split('px');
	vheight = String(capa.style.height).split('px');
	
    capa.style.left = (getDocumentClientWidth()/2) - (vwidth[0]/2) + 'px';
    capa.style.top = (getDocumentClientHeight()/2) - (vheight[0]/2) + 'px';    
  }
  return true;
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
  newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}

function cookiesEnabled(){
	var tmpcookie = new Date();
	chkcookie = (tmpcookie.getTime() + '');
	document.cookie = "chkcookie=" + chkcookie + "; path=/";
    if (document.cookie.indexOf(chkcookie,0) < 0) {
		return false;
    }else {
		return true;
    }
}

function flashInstalled(){
	var doflash = false;
	var player = new MM_FlashInfo();

	if (player.installed) {		
		if (player.version && player.version >= 6) {
			doflash = true;
		}
	}
	
	return doflash;
}

function loadFlash(file,width,height){	
		document.write('<OBJECT id="carrega" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '+
						'height="'+ height +'" width="'+ width +'" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" VIEWASTEXT>'+
						'<PARAM NAME="_cx" VALUE="3969">'+
						'<PARAM NAME="_cy" VALUE="3969">'+
						'<PARAM NAME="FlashVars" VALUE="">'+
						'<PARAM NAME="Movie" VALUE="'+ file +'">'+
						'<PARAM NAME="Src" VALUE="'+ file +'">'+
						'<PARAM NAME="WMode" VALUE="Transparent">'+
						'<PARAM NAME="Play" VALUE="1">'+
						'<PARAM NAME="Loop" VALUE="-1">'+
						'<PARAM NAME="Quality" VALUE="High">'+
						'<PARAM NAME="SAlign" VALUE="">'+
						'<PARAM NAME="Menu" VALUE="-1">'+
						'<PARAM NAME="Base" VALUE="">'+
						'<PARAM NAME="AllowScriptAccess" VALUE="sameDomain">'+
						'<PARAM NAME="Scale" VALUE="ShowAll">'+
						'<PARAM NAME="DeviceFont" VALUE="0">'+
						'<PARAM NAME="EmbedMovie" VALUE="0">'+
						'<PARAM NAME="BGColor" VALUE="5A8A94">'+
						'<PARAM NAME="SWRemote" VALUE="">'+
						'<PARAM NAME="MovieData" VALUE="">'+
						'<PARAM NAME="SeamlessTabbing" VALUE="1">'+
						'<PARAM NAME="Profile" VALUE="0">'+
						'<PARAM NAME="ProfileAddress" VALUE="">'+
						'<PARAM NAME="ProfilePort" VALUE="0">'+
						'<embed src="'+ file +'" quality="high" bgcolor="#5a8a94"'+
						'	width="'+ width +'" height="'+ height +'" name="apropteu" align="middle" allowScriptAccess="sameDomain"'+
						'	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"'+
						'	wmode="transparent" />'+
					'</OBJECT>');
}

function marcar(obj,color){	
	obj.style.cursor='hand';
	obj.style.backgroundColor = color;	
}


function WindowModalDialog(Url, PeuFoto)
{
	var Argumentos = new Array(Url, PeuFoto);
	var img = new Image();
 	img.src = Url;
 	
 	var hg = img.height + 100;
	var wd = img.width;								
    if (wd < 330) {
			wd = 330;
	}
	//self.resizeTo(wd + 10, hg);				
	var tp = (screen.height/2) - (hg/2);
	var lf = (screen.width/2)- (wd/2) ;							
	//window.moveTo( (screen.width/2)- (wd/2), (screen.height/2) - (hg/2)); 
    	
	window.open('MessageBox.html?Url=' + Url + '&PeuFoto=' + PeuFoto, '', 'status=no,toolbar=no,menubar=no,location=no,resizable=yes,top=50000,height='+ hg +'px,width=' + wd + 'px,left=' + lf + ', top=' + tp)
}