
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expiredays]  Expiration days of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expiredays, path, domain, secure)
{
if(expiredays){
	var expireDate = new Date();
	expireDate.setTime(expireDate.getTime() + (expiredays * 24 * 3600 * 1000));
}

    document.cookie= name + "=" + escape(value) +
        ((expiredays) ? "; expires=" + expireDate.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
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));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
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 searchCookie(name){
	lang=getCookie(name);
	if (lang != null) {
		queryString = "";
		if(typeof error != 'undefined'){
    		queryString = "?e="+ error;
    	}
		window.location.href= lang +"/" + queryString;
	}
}

function write_mail(mail, domain, word){
	if (word == undefined){
	word = mail +"@"+domain;
	}
	
	document.write("<a href='mailto:"+ mail +"@"+domain+"'>"+word+"</a>"); 
}

function CreateBookmarkLink() {

 title = document.title; 

 url = document.location;

	if (window.sidebar) { // Mozilla Firefox Bookmark
		alert("please hit CTRL+D to add a bookmark");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

/**
* Open a popup window
*/ 
function screenshot(url, stitle){
	imgWin=window.open(url,'','location=0,resizable=1,status=0,scrollbars=1');
	imgWin.focus();
}
/**
* drop down box script
*/
var cancelHide = false;

function doCancelHide(){
	cancelHide = true;
}

function showGroupSitesItems(){
	if(document.getElementById("selectGroupSitesItems").style.display != "block"){
		document.getElementById("selectGroupSitesItems").style.display = "block";
		doCancelHide();
	}else{
		hideGroupSitesItems();
	}
}

function hideGroupSitesItems(){

	if (document.getElementById("selectGroupSitesItems") != null){
	if(!cancelHide){

			document.getElementById("selectGroupSitesItems").style.display = "none";

	}else{
		cancelHide = false;
	}
	}
}

function showGroupSitesItems2(){
	if(document.getElementById("selectGroupSitesItems").style.display != "block"){
		document.getElementById("selectGroupSitesItems").style.display = "block";
	}
}

function hideGroupSitesItems2(){
	if (document.getElementById("selectGroupSitesItems") != null){
			document.getElementById("selectGroupSitesItems").style.display = "none";
	}
}

document.onclick = hideGroupSitesItems;

function hop(anchor) { document.location.href = '#'+anchor } 

/**
* AJAX POPUP SCREEN
*/
var map = new Object();
map['nl_BE'] = "<br><br><center><b>Bezig met laden ...</b><br><br><img src='/global/template/images/ajax/LoadingProgressBar.gif'></center>";
map['fr_BE'] = "<br><br><center><b>Loading ...</b><br><br><img src='/global/template/images/ajax/LoadingProgressBar.gif'></center>";
map['fr_FR'] = "<br><br><center><b>Loading ...</b><br><br><img src='/global/template/images/ajax/LoadingProgressBar.gif'></center>";
map['en_UK'] = "<br><br><center><b>Loading ...</b><br><br><img src='/global/template/images/ajax/LoadingProgressBar.gif'></center>";

var ajax_flash_object = null;
var ajax_flash_div = null;
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;

function ajaxpage(url, containerid, outercontainerid, modelBackground, language){
	
	document.getElementById(containerid).innerHTML = map[language];
	document.getElementById(containerid).style.height = "100px";
	document.getElementById(containerid).style.width = "220px";
	document.getElementById(containerid).style.top = "-50px";
	document.getElementById(containerid).style.marginLeft = "-110px";
	document.getElementById(modelBackground).style.display="";
	if (IE6 == true){
		document.getElementById(modelBackground).style.position = "absolute";
	} else {
	document.getElementById(modelBackground).style.position = "fixed";
	}
	document.getElementById(outercontainerid).style.display="";

	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}catch (e){}
		}
		}else
			return false
		page_request.onreadystatechange=function(){
		loadpage(page_request, containerid, outercontainerid)
	}
	page_request.open('GET', url, true)
	page_request.send(null)
}

function loadpage(page_request, containerid, outercontainerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
		document.getElementById(outercontainerid).style.display="none";
		document.getElementById(containerid).style.height = "500px";
		document.getElementById(containerid).style.width = "720px";
		document.getElementById(containerid).style.top = "-250px";
		document.getElementById(containerid).style.marginLeft = "-360px";		
		document.getElementById(containerid).innerHTML=page_request.responseText;
		document.getElementById(outercontainerid).style.display="";
		if(ajax_flash_object != null){ 
			ajax_flash_object.write(ajax_flash_div);
		}
	}
}

function closeAjax(containerid, outercontainerid, modelBackground){
	document.getElementById(outercontainerid).style.display = "none"; 
	document.getElementById(modelBackground).style.display = "none"; 
	document.getElementById(containerid).innerHTML = "";
}

