
function onoff(nom) {
  if (document.getElementById(nom).style.display != '') { marcaC1='';} else { marcaC1='none';}
  document.getElementById(nom).style.display = marcaC1;
}

function afegirweb(){
   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
      window.external.AddFavorite('http://www.pipcat.com/', 'PiPcat.com - Colles de Pitch and Putt - www.PiP.cat');
   } else { 
      if(navigator.appName == "Netscape") alert("Prem Crtl+D per afegir aquesta web als teus Bookmarks"); 
   }
} 

// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

function setActiveStyleSheet(title) {
  var i, a, main, aju;
  aju = title.substring(0,3);
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.getAttribute("title").substring(0,3)==aju) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet(aju) {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.getAttribute("title").substring(0,3)==aju && !a.disabled) return a.getAttribute("title");
  } 
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  if (cookie) setActiveStyleSheet(cookie);

  cookie = readCookie("color");
  if (cookie) setActiveStyleSheet(cookie);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet('tam');
  if (title) createCookie("style", title, 365);

  title = getActiveStyleSheet('col');
  if (title) createCookie("color", title, 365);
}

  var cookie = readCookie("style");
  if (cookie) setActiveStyleSheet(cookie);

  cookie = readCookie("color");
  if (cookie) setActiveStyleSheet(cookie);
