// Util library
// Copyright (C) 2004 Softeng
// more information on http://www.softeng.es

var nomBrowser
var versionBrowser

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;
}

checkBrowser();

ns= (navigator.appName.substring(0,1) == 'N');
ie= (navigator.appName.substring(0,1) == 'M');

function preloadMenu(){
	preload('blank','img/blank.gif')
	preload('ic_idioma','img/ic_idioma.gif')
	preload('ic_idioma_act','img/ic_idioma_act.gif')
	preload('ic_home','img/ic_home.gif')
	preload('ic_home_act','img/ic_home_act.gif')
	preload('ic_webmap','img/ic_webmap.gif')
	preload('ic_webmap_act','img/ic_webmap_act.gif')
	preload('ic_search','img/ic_search.gif')
	preload('ic_search_act','img/ic_search_act.gif')
	preload('ic_contact','img/ic_contact.gif')
	preload('ic_contact_act','img/ic_contact_act.gif')
	preload('ic_Qmenu','img/ic_Qmenu_buit.gif')
	preload('ic_Qmenu_act','img/ic_Qmenu_ple.gif')
	preload('ic_play_act','img/ic_play_act.gif')
	preload('ic_play','img/ic_play.gif')
}

function preloadMenuEsqCataleg(){
	preload('img_cat_camp','img/img_cat_camp.gif')
	preload('img_cat_cal','img/img_cat_cal.gif')
	preload('img_cat_ext','img/img_cat_ext.gif')
	preload('img_cat_ven','img/img_cat_ven.gif')
}


function load(page) {
	//if (ns4) document.textLayer.src = page
	//else if (ie4) 
	parent.textFrame.document.location = page
}

function construirMenu(){
	var i;
	var str = '';
	for (i=0;i<arguments.length;i+=2){
	    if (i == arguments.length - 2) {
	        if (arguments[i].indexOf('.pdf') > 0) {
	            str += '<a target="_blank" href="' + arguments[i] + '" class="Ver2White" onmouseover="this.style.color=\'#636563\'" onmouseout="this.style.color=\'#FFFFFF\'">' + arguments[i + 1] + '</a>';
	        }
	        else {
	            str += '<a href="' + arguments[i] + '" class="Ver2White" onmouseover="this.style.color=\'#636563\'" onmouseout="this.style.color=\'#FFFFFF\'">' + arguments[i + 1] + '</a>';
	        }
		}
		else{
			str+='<a href="'+arguments[i]+'" class="Ver2White" onmouseover="this.style.color=\'#636563\'" onmouseout="this.style.color=\'#FFFFFF\'">'+arguments[i+1]+'</a><font class="Ver2White">&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;</font>';
		}
	}
	oMenu.write(str);	
	mostrarMenu();
}

function mostrarTitolMenu(text){
	if (eval('titolMenu')){
		document.getElementById("titolMenulyr").innerHTML = '<font class="Ver1White">'+text+'</font>';
		document.getElementById("titolMenulyr").style.visibility = 'visible';
		//titolMenu.write('<font class="Ver1White">'+text+'</font>');
		//titolMenu.show();
	}
}

function unfoldUpDwFAQ(faqid){	
	var obj = document.getElementById(faqid);
	if (obj.style.display == 'none'){
		obj.style.display = 'block';
	}
	else{
	 	obj.style.display = 'none';
	}
}

function MarcarTxt(obj,txtcolor) {	
	canviarCursor(obj);
	obj.style.color = txtcolor;
}

function Marcar(obj,color) {
	obj.style.cursor='hand';
	obj.style.backgroundColor=color
}

function Desmarcar(obj,color) {
	obj.style.cursor='default';
	obj.style.backgroundColor=color
}

function canviarCursor(obj) {	
	if (ns) {
		obj.style.cursor='pointer'
	}
	else{
		obj.style.cursor='hand';
	}

}

function DesmarcarTxt(obj,txtcolor) {
	obj.style.cursor='default';
	obj.style.color = txtcolor;	
}

//drag functions

function dragAdd() {
	for (var i=0; i<arguments.length; i++) {
		var l = this.array.length
		this.array[l] = arguments[i]
		this.array[l].dragGrab = new Array(mywindow.y,this.array[l].w+mywindow.x,this.array[l].h+mywindow.y,0)
		//this.array[l].dragGrab = new Array(0,this.array[l].w+50,this.array[l].h+50,0)
		this.zIndex += 1
	}	
}

function DragMouseMove(x,y) {
	if (!drag.active) return false
	else {
		if (((drag.obj.x)<= mywindow.marginL) && ((drag.obj.w+drag.obj.x)>= mywindow.w)) {
			drag.obj.moveTo(x-drag.offsetX,0)
			drag.onDragMove(x,0)
		}
		return true
	}
}

function dragEnd(x,y){
	if ((drag.obj.x)> mywindow.marginL){
		drag.obj.moveTo(0,0)
	}
	if ((drag.obj.w+drag.obj.x)< mywindow.w){
		drag.obj.moveTo(mywindow.w-drag.obj.w,0)		
	}
	return true
}


function replace(argvalue, x, y) {
    
  while (argvalue.indexOf(x) != -1) {
    var leading = argvalue.substring(0, argvalue.indexOf(x));
    var trailing = argvalue.substring(argvalue.indexOf(x) + x.length, 
	argvalue.length);
    argvalue = leading + y + trailing;
  }

  return argvalue;

}

function layerWrite(layer,html) {
	var id = document.getElementById(layer);

	if (ns) {
		id.open()
		id.write(html)
		id.close()
	}
	else if (ie) {
		id.innerHTML = html
	}
}

function mostrarCapa(id) {
	document.getElementById(id).style.visibility = "visible"
}


//****************************** ocultarCapa ******************************************

function ocultarCapa(id) {
	document.getElementById(id).style.visibility = "hidden"
}

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>');
}