/************************************************************
 // Function showHideAJAX - by Yannick Van Avermaet
 // Arguments:
 //        id                 --> id of the to_display_element (REQUIRED)
 //        a_reference        -->    reference to the clicked a-tag (NOT REQUIRED)
 //        arr_words        --> words to be shown when clicking the link (NOT REQUIRED)
 //            arr_words[0]: word shown when 'closing'
 //            arr_words[1]: word shown when 'opening'
 // Returns: false

 // ATTENTION! If you want to change the word when clicking the link, you have to pass on a_reference and arr_words
 // Example: <a href="javascript:void(0);" onclick="return showHideAJAX('my_div_id', this, new Array('change','cancel'));">click me</a>
 ************************************************************/
function showHideAJAX(id, a_reference, arr_words){
	if ($(id)){
		if ($(id).style.overflow != 'visible' || $(id).style.display == 'none'){
			if (a_reference != null && arr_words.length == 2){
				a_reference.innerHTML = arr_words[1];
			}
			if ($(id).style.height == null || $(id).style.height == 0){
				Effect.BlindDown(id, {
					duration: 0.5
				});
			}
		}
		else{
			if (a_reference != null && arr_words.length == 2){
				a_reference.innerHTML = arr_words[0];
			}
			Effect.BlindUp(id, {
				duration: 0.5
			});
		}
	}
	return false;
}

var height = 0;
var width = 0;
function createPageDimensions() {
	var windowWidth, windowHeight;
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	if(yScroll < windowHeight){
		height = windowHeight;
	} else {
		height = yScroll;
	}

	if(xScroll < windowWidth){
		width = windowWidth;
	} else {
		width = xScroll;
	}
}

function createLayer(){
	var my_layer = document.createElement('div');
	my_layer.id = 'layer';
	my_layer.className = 'layer';
	my_layer.style.height = height+'px';
	my_layer.style.width = '100%';
	my_layer.innerHTML = "&nbsp;";
	/*my_layer.style.backgroundImage = 'url(/jobs/alg/gif/black-70.png)';
	my_layer.style.backgroundRepeat = 'repeat';*/
	document.body.appendChild(my_layer);
}

function deleteLayer(){
	 document.body.removeChild(document.getElementById('layer'));	
}

// JavaScript Document
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

function trim(s) {
	return s.replace(/^\s+|\s+$/g, "");
}

String.prototype.trim = function() {
    return this.replace( /^\s+|\s+$/, "" );
}

function addClassName (elem, className) {
    removeClassName (elem, className);
    elem.className = (elem.className + " " + className).trim();
}

function removeClassName (elem, className) {
    elem.className = elem.className.replace(className, "").trim();
}

// google adsense 
// var prev_ads = 0;
// var pe_adsense = null;
function google_ad_request_done(google_ads) {
    var s = '';
    var i;

    if (google_ads.length == 0) {
      return;
    }

	if(pe_google_layout == 1) {
		s += '<h3>'  + '<a href="http://services.google.com/feedback/online_hws_feedback">' + 'Ads door Google' + '</a>' + '</h3>';
		for(i=0; i < google_ads.length; ++i) {
			url = '<a style="cursor:pointer;cursor:hand;" target="_blank" onclick="javascript:window.open(\'' + google_ads[i].url  +
				 '\');" onmouseover="window.status=\'ga naar ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">';
			s += '<div style="float:left;width:230px;padding:10px 5px;"><dl>';
			s += '<dt>' + url + google_ads[i].line1 + '</a></dt>';
			s += '<dd>' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</dd>';
			s += '</dl>';
			s +=  url + google_ads[i].visible_url + '</a></div>';
		}
	}	
	else if(pe_google_layout == 2) { 
		s += '<h3>'  + '<a href="http://services.google.com/feedback/online_hws_feedback">' + 'Ads door Google' + '</a>' + '</h3>';
		for(i=0; i < google_ads.length; ++i) {
			url = '<a style="cursor:pointer;cursor:hand;" target="_blank" onclick="javascript:window.open(\'' + google_ads[i].url  +
				 '\');" onmouseover="window.status=\'ga naar ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">';
			s += '<div style="width:492px;float:left;padding:5px"><dl>';
			s += '<dt>' + url + google_ads[i].line1 + '</a></dt>';
			s += '<dd>' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</dd>';
			s += '</dl>';
			s +=  url + google_ads[i].visible_url + '</a></div>';		
		}	
			s+= '<div class="gen_clear"></div>';		
	}
	else if(pe_google_layout == 3) { 
		s += '<h3>'  + '<a href="http://services.google.com/feedback/online_hws_feedback">' + 'Ads door Google' + '</a>' + '</h3>';
		for(i=0; i < google_ads.length; ++i) {
			url = '<a style="cursor:pointer;cursor:hand;" target="_blank" onclick="javascript:window.open(\'' + google_ads[i].url  +
				 '\');" onmouseover="window.status=\'ga naar ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">';
			s += '<div style="float:left;width:326px;padding:0 0 5px 0;"><dl>';
			s += '<dt>' + url + google_ads[i].line1 + '</a></dt>';
			s += '<dd>' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</dd>';
			s += '</dl>';
			s +=  url + google_ads[i].visible_url + '</a></div>';
		}
	}
	else if(pe_google_layout == 4) {
		s += '<h3>'  + '<a href="http://services.google.com/feedback/online_hws_feedback">' + 'Ads door Google' + '</a>' + '</h3>';
			for(i=0; i < google_ads.length; i++) {
				url = '<a style="cursor:pointer;cursor:hand;" target="_blank" onclick="javascript:window.open(\'' + google_ads[i].url  + '\');" onmouseover="window.status=\'ga naar ' + google_ads[i].visible_url + '\'" onmouseout="window.status=\'\'">';
				
				s += '<div style="margin: 0 10px 0 0; padding: 10px 0px; float: left; width: 192px;">';
				s += '<dl>';
				s += '<dt>' + url + google_ads[i].line1 + '</a></dt>';
				s += '<dd>' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</dd>';
				s += '</dl>';
				s +=  url + google_ads[i].visible_url + '</a>';
				s += '</div>';
			}
	}

	document.write(s);
	return;
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

//googleAnalytics
function measureClick (zone){
	var component='gClicks';
	if (zone!=undefined  && zone != ''){
		component += '/'+zone;
	}
pageTracker._trackPageview(component);
}
