var BrowserDetect = {
   init: function () {
      this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
      this.version = this.searchVersion(navigator.userAgent)
         || this.searchVersion(navigator.appVersion)
         || "an unknown version";
      this.OS = this.searchString(this.dataOS) || "an unknown OS";
   },
   searchString: function (data) {
      for (var i=0;i<data.length;i++)   {
         var dataString = data[i].string;
         var dataProp = data[i].prop;
         this.versionSearchString = data[i].versionSearch || data[i].identity;
         if (dataString) {
            if (dataString.indexOf(data[i].subString) != -1)
               return data[i].identity;
         }
         else if (dataProp)
            return data[i].identity;
      }
   },
   searchVersion: function (dataString) {
      var index = dataString.indexOf(this.versionSearchString);
      if (index == -1) return;
      return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
   },
   dataBrowser: [
      {    string: navigator.userAgent,
         subString: "OmniWeb",
         versionSearch: "OmniWeb/",
         identity: "OmniWeb"
      },
      {
         string: navigator.vendor,
         subString: "Apple",
         identity: "Safari"
      },
      {
         prop: window.opera,
         identity: "Opera"
      },
      {
         string: navigator.vendor,
         subString: "iCab",
         identity: "iCab"
      },
      {
         string: navigator.vendor,
         subString: "KDE",
         identity: "Konqueror"
      },
      {
         string: navigator.userAgent,
         subString: "Firefox",
         identity: "Firefox"
      },
      {
         string: navigator.vendor,
         subString: "Camino",
         identity: "Camino"
      },
      {      // for newer Netscapes (6+)
         string: navigator.userAgent,
         subString: "Netscape",
         identity: "Netscape"
      },
      {
         string: navigator.userAgent,
         subString: "MSIE",
         identity: "Explorer",
         versionSearch: "MSIE"
      },
      {
         string: navigator.userAgent,
         subString: "Gecko",
         identity: "Mozilla",
         versionSearch: "rv"
      },
      {       // for older Netscapes (4-)
         string: navigator.userAgent,
         subString: "Mozilla",
         identity: "Netscape",
         versionSearch: "Mozilla"
      }
   ],
   dataOS : [
      {
         string: navigator.platform,
         subString: "Win",
         identity: "Windows"
      },
      {
         string: navigator.platform,
         subString: "Mac",
         identity: "Mac"
      },
      {
         string: navigator.platform,
         subString: "Linux",
         identity: "Linux"
      }
   ]

};
BrowserDetect.init();


function negre(boto){
	document.getElementById(boto).src="imatges/plantilla_principal/botons/"+boto+"_negre.png";
}
function blanc(boto){
	document.getElementById(boto).src="imatges/plantilla_principal/botons/"+boto+"_gris.png";
}
function vermell(boto){
	document.getElementById(boto).src="imatges/plantilla_principal/botons/"+boto+"_vermell.png";
}
function mapa_activat(){
	document.getElementById("mapa").className="mapa_activat";
}
function mapa_desactivat(){
	document.getElementById("mapa").className="mapa";
}
function pintar_botons(apartat){
	var boto="boto_" + apartat;
	document.getElementById(boto).onmouseout=""; document.getElementById(boto).onmousemove="";
	if (apartat=="serveis_preparacio"){
		document.getElementById("1_presentacioC").className="botons";
		document.getElementById("1_presentacioC").src="imatges/plantilla_principal/botons/1_presentacioC_gris.png";
		document.getElementById("1_serveisC").className="boto_desactivat";
		document.getElementById("1_serveisC").src="imatges/plantilla_principal/botons/1_serveisC_vermell.png";
		document.getElementById("1_productesC").className="botons";
		document.getElementById("1_productesC").src="imatges/plantilla_principal/botons/1_productesC_gris.png";
		document.getElementById("1_comandesC").className="botons";
		document.getElementById("1_comandesC").src="imatges/plantilla_principal/botons/1_comandesC_gris.png";
		document.getElementById("1_contacteC").className="botons";
		document.getElementById("1_contacteC").src="imatges/plantilla_principal/botons/1_contacteC_gris.png";
	} else if (apartat=="productes_tripes"){
		document.getElementById("1_presentacioC").className="botons";
		document.getElementById("1_presentacioC").src="imatges/plantilla_principal/botons/1_presentacioC_gris.png";
		document.getElementById("1_serveisC").className="botons";
		document.getElementById("1_serveisC").src="imatges/plantilla_principal/botons/1_serveisC_gris.png";
		document.getElementById("1_productesC").className="boto_desactivat";
		document.getElementById("1_productesC").src="imatges/plantilla_principal/botons/1_productesC_vermell.png";
		document.getElementById("1_comandesC").className="botons";
		document.getElementById("1_comandesC").src="imatges/plantilla_principal/botons/1_comandesC_gris.png";
		document.getElementById("1_contacteC").className="botons";
		document.getElementById("1_contacteC").src="imatges/plantilla_principal/botons/1_contacteC_gris.png";
	} else if (apartat=="comandes"){
		document.getElementById("1_presentacioC").className="botons";
		document.getElementById("1_presentacioC").src="imatges/plantilla_principal/botons/1_presentacioC_gris.png";
		document.getElementById("1_serveisC").className="botons";
		document.getElementById("1_serveisC").src="imatges/plantilla_principal/botons/1_serveisC_gris.png";
		document.getElementById("1_productesC").className="botons";
		document.getElementById("1_productesC").src="imatges/plantilla_principal/botons/1_productesC_gris.png";
		document.getElementById("1_comandesC").className="boto_desactivat";
		document.getElementById("1_comandesC").src="imatges/plantilla_principal/botons/1_comandesC_vermell.png";
		document.getElementById("1_contacteC").className="botons";
		document.getElementById("1_contacteC").src="imatges/plantilla_principal/botons/1_contacteC_gris.png";
	} else if (apartat=="contacte"){
		document.getElementById("1_presentacioC").className="botons";
		document.getElementById("1_presentacioC").src="imatges/plantilla_principal/botons/1_presentacioC_gris.png";
		document.getElementById("1_serveisC").className="botons";
		document.getElementById("1_serveisC").src="imatges/plantilla_principal/botons/1_serveisC_gris.png";
		document.getElementById("1_productesC").className="botons";
		document.getElementById("1_productesC").src="imatges/plantilla_principal/botons/1_productesC_gris.png";
		document.getElementById("1_comandesC").className="botons";
		document.getElementById("1_comandesC").src="imatges/plantilla_principal/botons/1_comandesC_gris.png";
		document.getElementById("1_contacteC").className="boto_desactivat";
		document.getElementById("1_contacteC").src="imatges/plantilla_principal/botons/1_contacteC_vermell.png";
	}
}
function omplir_contingut(apartat){
	document.getElementById("iframe_contingut").src="contingut_" + apartat + ".php";
}
function canviar_apartat_iframe(apartat_iframe){
	document.getElementById("iframe_contingut").src=apartat_iframe;
}
function link_temps_negre(){
	document.getElementById("link_temps").style.color="#000000";
}
function link_temps_gris(){
	document.getElementById("link_temps").style.color="#999999";
}
function deixar_esterisc_parent(index){
	window.iframe_contingut.desactivar_barra_parent();
}
function avis_legal_negre(){
	document.getElementById("boto_avis_legal").style.color="#000000";
}
function avis_legal_gris(){
	document.getElementById("boto_avis_legal").style.color="#666666";
}
function certificats_negre(){
	document.getElementById("boto_certificat").style.color="#000000";
}
function certificats_gris(){
	document.getElementById("boto_certificat").style.color="#666666";
}
function posar_data(){
	mydate = new Date();
	document.getElementById("data").value=mydate;
	if (BrowserDetect.browser=="Explorer"){
		document.getElementById("lateral_menu_gris").style.left="-269px";
		document.getElementById("logo_gran").style.left="60px";
	}
}