var cookiename = "2goclosed";
var today = new Date();
var cookie_expire_date = new Date(today.getTime() + (8 * 7 * 86400000));


function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}


function sh(dId){
	var imgId = "img"+dId;
	
	if(	document.getElementById(dId).className == "b_ch" ){
		document.getElementById(dId).className = "b_c";
		document.getElementById(imgId).src="imgs/m.gif";

		var add = Get_Cookie(cookiename);
		var cookiestring = add.replace("|"+dId, "");
		Set_Cookie(cookiename, cookiestring, cookie_expire_date, "/", "", "");
	}
	else{
		document.getElementById(dId).className = "b_ch";
		document.getElementById(imgId).src="imgs/p.gif";
		
		var add = Get_Cookie(cookiename);
		if(add != null){
			var cookiestring = add.replace("|"+dId, "");
			var cookiestring = cookiestring+"|"+dId;
		}
		else{
			var cookiestring = "|"+dId;
		}
		Set_Cookie(cookiename, cookiestring, cookie_expire_date, "/", "", "");
	}
}

function closeOnload(){
	var ids = Get_Cookie(cookiename);
	if(ids != null){
		var ids_array = ids.split("|");
		for(i = 1; i < ids_array.length; i++){
			var imgId = "img"+ids_array[i];
			if(document.getElementById(ids_array[i]) != undefined){
				document.getElementById(ids_array[i]).className = "b_ch";
				document.getElementById(imgId).src="imgs/p.gif";
			}
		}
	}
}

function delc(){
	var today = new Date();
	var cookie_expire_date = new Date(today.getTime() + (8 * 7 * 86400000));
	Set_Cookie("closed", "", cookie_expire_date, "/", "", "");
}

function zoek(){
	
	var st = document.getElementById('st').value;
	var gog = document.getElementById('zmg');
	var got = document.getElementById('zmo');
	var ebay = document.getElementById('ebay');	
	var wiki = document.getElementById('wiki');	
	var yaho = document.getElementById('yaho');	
	var alta = document.getElementById('alta');	
	var vind = document.getElementById('vind');	
	var youtube = document.getElementById('youtube');	
	var bing = document.getElementById('bing');	
	
	if(gog.checked){ 
//		window.open("http://www.google.be/custom?q="+st+"&amp;sa=Zoeken&amp;client=pub-6260739818757150&amp;forid=1&amp;channel=0556479872&amp;ie=ISO-8859-1&amp;oe=ISO-8859-1&amp;cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A1&amp;hl=nl");
		window.open("http://www.google.be/custom?q="+st+"&amp;sa=Zoeken&amp;client=pub-6161337754763312&amp;forid=1&amp;channel=7819999500&amp;ie=ISO-8859-1&amp;oe=ISO-8859-1&amp;cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A1&amp;hl=nl");
//		window.open("http://www.google.be/search?hl=nl&q="+st+"&btnG=Google+zoeken&meta=");
//		window.open("http://www.google.be/custom?q="+st+"&amp;sa=Zoeken&amp;client=pub-6260739818757150&amp;forid=1&amp;ie=ISO-8859-1&amp;channel=5938121188&amp;oe=ISO-8859-1&amp;cof=GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1&amp;hl=nl");
// target="google_window" ?
	}
	if(got.checked){
		document.location.href="zoeken.php?q="+st;	
	}
	if(youtube.checked){
		window.open("http://www.youtube.com/results?search_query="+st+"");
	}
	if(bing.checked){
		window.open("http://www.bing.com/search?q="+st+"");
	}
	if(yaho.checked){
		window.open("http://search.yahoo.com/search?p="+st+"");
	}
	if(vind.checked){
		window.open("http://clk.tradedoubler.com/click?p=58375&amp;a=414835&amp;g=&amp;&url=http://www.vinden.nl/td?q="+st+"");
	}
	if(alta.checked){
		window.open("http://be.altavista.com/web/results?q="+st+"");
	}
	if(ebay.checked){
		window.open("http://rover.ebay.com/rover/1/1553-53471-19255-0/1?ff3=4&amp;pub=5574871612&amp;toolid=10001&amp;campid=5336472194&amp;customid=&amp;mpre=http://search.benl.ebay.be/"+st+"");
	}
	if(wiki.checked){
		window.open("http://nl.wikipedia.org/wiki/"+st+"");
	}
}

function moresearch(){
	document.getElementById('zm_less').style.display='';
	document.getElementById('zm_mor').style.display='none';
}

function hidesearch(){
	document.getElementById('zm_mor').style.display='';
	document.getElementById('zm_less').style.display='none';
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  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")
       ) 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);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
