// vars

windowopened = null;
pophtmlbgcolor = "FFFFFF";
pophtmltxtcolor = "101077";
//



if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

function findtag(n,d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findtag(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var dateexp = new Date();
var expdays = 900; //cookie 900 days to last
var exp = new Date(); 
exp.setTime(exp.getTime() + (expdays*24*60*60*1000));


function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function addMyBxl (a,b,c){
	if(!document.cookie) {
		if(b=="FR")	alerthtml('My Brussels','Votre navigateur ne semble pas accepter des \'cookies\'');
		if(b=="EN")	alerthtml('My Brussels','Your navigator seems not to be accepting \'cookies\'');
		if(b=="NL")	alerthtml('My Brussels','Uw navigator blijkt geen \'cookies\' te aanvaarden');
	}else{
	
		var count = getCookie(c);
		if(count!=null){
					var tmpvar = count.split("|");
					var setted = 0;
					for(i=0;i<tmpvar.length;i++){
						if(tmpvar[i]==a) setted = 1;
					}
					if (setted == 0 ) setCookie(c,count+"|"+a,exp,"/");
		}else{
					setCookie(c,a,exp,"/");
		}
		if(b=="FR")	alerthtml('My Brussels','Cette page fait maintenant partie de votre sélection');
		if(b=="EN")	alerthtml('My Brussels','This page now has been included in your selection');
		if(b=="NL")	alerthtml('My Brussels','Deze pagina wordt nu in uw selektie opgenomen');
	}
}
function delMyBxl (a,b,c){
	var count = getCookie(c);
	if(count!=null){
		var tmpvar = count.split("|");
		var setted = new Array();
		for(i=0;i<tmpvar.length;i++){
			if(tmpvar[i]!=a) setted[setted.length] = tmpvar[i];
		}
		if (setted.length == 0 ) {
			deleteCookie(c,"/");
		} else {
			tmpcookie = setted[0];
			for(i=1;i<setted.length;i++){
				tmpcookie = tmpcookie + "|" + setted[i];
			}
			setCookie(c,tmpcookie,exp,"/")
		}
	}
	if(b=="FR")	alerthtml('My Brussels','La page a été enlevée de votre sélection');
	if(b=="EN")	alerthtml('My Brussels','The page has been removed from your selection');
	if(b=="NL")	alerthtml('My Brussels','De pagina werd uit uw selektie verwijderd');
}


function pop(url,name,height,width){
	if (windowopened!=null) windowopened.close();
	windowopened = window.open(url,name,"\'location=no,left="+ ((screen.width-(width ? width : 350))/2) +",top="+ ((screen.height-(height ? height : 100))/2)+",width="+ (width ? width : 350) +",height="+ (height ? height : 100) +"\'");
	windowopened.focus();
}

function alerthtml(title,content,height,width){
	var windowopenedhtml = window.open('','alert',"\'location=no,left="+ ((screen.width-(width ? width : 350))/2) +",top="+ ((screen.height-(height ? height : 100))/2)+",width="+ (width ? width : 350) +",height="+ (height ? height : 100) +"\'");
	var msg ="<html>\n<head>\n";
	msg += "<link href='/wabxlint/style/common.css' rel='stylesheet' type='text/css'>\n";
	msg += "<title>"+ title +"</title>\n</head>\n";
	msg += "<body bgcolor=#"+pophtmlbgcolor+ " text=#" + pophtmltxtcolor + ">\n<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' width='100%' height='100%'><tr><td align='center' valign='middle'><span class=\"bluetext_big\">\n";
	msg += content;
	msg += "</span><br><br>\n";
	msg += ((document.layers)? "" :"<input type=button value='   OK   ' onclick='window.close();' class='form_button'>");
	msg += "</td></tr></table>\n</body>\n</html>";
	windowopenedhtml.document.open();
	windowopenedhtml.document.write(msg);
	windowopenedhtml.document.close();
	windowopenedhtml.focus();
}

