// JavaScript Document
function OpenPrivacy()
   {
	  sx=screen.width/2-350;
	  tp=screen.height/2-150;
      privacy=window.open("about:blank","privacy","left="+sx+",top="+tp+",width=700,height=300");
   } 
function OpenMailinglist()
   {
	  sx=screen.width/2-250;
	  tp=screen.height/2-100;
      mailinglist=window.open("about:blank","mailinglist","left="+sx+",top="+tp+",width=500,height=200");
   } 
function SendForm(myform) { 
	var theForm = typeof myform != 'object' ? document.getElementById(myform): myform; 
	var ret = Spry.Widget.Form.validate(theForm); 
	if (ret) { 
		return OpenMailinglist(); 
	} 
	return false; 
};

function setActiveStyleSheet(title, quale) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"+quale)) {
      a.disabled = true;
      if(a.getAttribute("title"+quale) == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet(quale) {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"+quale) && !a.disabled) return a.getAttribute("title"+quale);
  }
  return null;
}

function getPreferredStyleSheet(quale) {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title"+quale)
       ) 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");
  var title = cookie ? cookie : getPreferredStyleSheet("");
  setActiveStyleSheet(title, "");

//  var cookie = readCookie("style_col");
//  var title = cookie ? cookie : getPreferredStyleSheet("_col");
//  setActiveStyleSheet(title, "_col");
}

window.onunload = function(e) {
  var title = getActiveStyleSheet("");
  createCookie("style", title, 365);

//  var title = getActiveStyleSheet("_col");
//  createCookie("style_col", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet("");
setActiveStyleSheet(title, "");

//var cookie = readCookie("style_col");
//var title = cookie ? cookie : getPreferredStyleSheet("_col");
//setActiveStyleSheet(title, "_col");
//setBarColor(title.substr(title.length-1,1));
