/* Screenresolution check */
window.onload = function() {
	if (screen.width < 1024 && screen.height < 768)	{

		show_resolution_message();

	}
};


function doen() {
	var elements = new Array();

	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);

		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}

Array.prototype.find = function (s) {
	for (var i=0; i < this.length; i++)
		if (this[i] == s) return i;
	return false;
};

Array.prototype.in_array = function(value, strict) {
    if (strict) function equals(a,b) { return a === b }
    else function equals(a,b) { return a == b }

    for (var i in this) if (equals(this[i], value)) return true;
    return false;
}

var insideLayer = false;
var useNS = (navigator.appName == "Netscape");

function navOver(id, clsname) {

	if (!clsname) clsname = 'navigation_item';
	var itm = document.getElementById('nav_item_'+id);
	var lbl = document.getElementById('nav_label_'+id);
	if (itm) itm.className = clsname + '_over';
	if (lbl) lbl.className = clsname + '_label_over';

}

function navOut(id, clsname) {

	if (!clsname) clsname = 'navigation_item';
	var itm = document.getElementById('nav_item_'+id);
	var lbl = document.getElementById('nav_label_'+id);
	if (itm) itm.className = clsname;
	if (lbl) lbl.className = clsname + '_label';

}

function barOver(id) {

	var il = document.getElementById('bar_btn_' + id);
	if (il && il.getAttribute('hl') == 0 && il.getAttribute('sel') == 0) {

		il.className = 'navigation_top_container_medium';
		var prv = il.previousSibling.firstChild;
		var nxt = il.nextSibling.firstChild;

		if (prv) {
			prv.src = '/img/background/top_sep_' + (prv.getAttribute('sl') == 'w' ? 'white' : (prv.getAttribute('sl') == 'd' ? 'dark' : 'light')) + '_dark' + '.png';
			prv.setAttribute('sr', 'd');
		}

		if (nxt) {
			nxt.src = '/img/background/top_sep_dark_' + (nxt.getAttribute('sr') == 'd' ? 'dark' : 'light') + '.png';
			if (nxt.getAttribute('sl') != 'w') nxt.setAttribute('sl', 'd');
		}

		il.setAttribute('hl', 1);

	}
}

function barOut(id) {

	var il = document.getElementById('bar_btn_' + id);
	if (il && il.getAttribute('hl') == 1 && il.getAttribute('sel') == 0) {

		il.className = '';

		var prv = il.previousSibling.firstChild;
		var nxt = il.nextSibling.firstChild;

		if (prv) {
			prv.src = '/img/background/top_sep_' + (prv.getAttribute('sl') == 'w' ? 'white' : (prv.getAttribute('sl') == 'd' ? 'dark' : 'light')) + '_light' + '.png';
			prv.setAttribute('sr', 'l');
		}

		if (nxt) {
			nxt.src = '/img/background/top_sep_light_' + (nxt.getAttribute('sr') == 'd' ? 'dark' : 'light') + '.png';
			if (nxt.getAttribute('sl') != 'w') nxt.setAttribute('sl', 'l');
		}

		il.setAttribute('hl', 0);

	}

}

var active_product_popup = '';
function toggle_product(el) {

	popup = document.getElementById(el);

	if (popup.style.display == 'none') {

		if (active_product_popup) document.getElementById(active_product_popup).style.display = 'none';

		popup.style.display = '';
		popup.style.left = document.body.scrollLeft + (document.body.clientWidth / 2) - (popup.offsetWidth ? popup.offsetWidth / 2 : 200);
		popup.style.top = document.body.scrollTop + (document.body.clientHeight / 2) - (popup.offsetHeight ? popup.offsetHeight / 2 : 125);
		active_product_popup = el;

	} else {

		popup.style.display = 'none';

	}

}

/*function showLogin(obj, pos) {

	if (!pos) pos = new Array(1, 1, 1, 0, 0, -1);
	showMenuLayer(document.getElementById('login_container'), obj, pos[0], pos[1], pos[2], pos[3], pos[4], pos[5]);

	var il = document.getElementById('login_username');
	if (il) {
		if (il.value.length == 0) document.getElementById('login_username').focus();
		else document.getElementById('login_password').focus();
	}

}*/

function _ikb_add_favorite(id, org, is_fav) {

	window.aiframe.location.href = '/my.php?cat=' + id + '&org=' + org + (is_fav ? '&mode=del' : '');
	document.getElementById('_ikb_fav_on').style.display = (is_fav ? 'none' : '');
	document.getElementById('_ikb_fav_off').style.display = (is_fav ? '' : 'none');

}

function _prs_add_favorite(type, org, is_fav) {

	window.aiframe.location.href = '/my.php?'+type+'=' + org + (is_fav ? '&mode=del' : '');
	document.getElementById('_prs_fav_on').style.display	= (is_fav ? 'none' : '');
	document.getElementById('_prs_fav_off').style.display	= (is_fav ? '' : 'none');

}

function _ctl_add_favorite(org, is_fav) {

	window.aiframe.location.href = '/my.php?ctl=' + org + (is_fav ? '&mode=del' : '');
	
	//-- voor inkoopboek pagina
	if (document.getElementById('_ctl_fav_on')) document.getElementById('_ctl_fav_on').style.display = (is_fav ? 'none' : '');
	if (document.getElementById('_ctl_fav_off')) document.getElementById('_ctl_fav_off').style.display = (is_fav ? '' : 'none');
	
	//-- voor inkoopboek pagina
	if (document.getElementById('btn_fav_add_'+org)) document.getElementById('btn_fav_add_'+org).style.display = (is_fav ? 'none' : '');
	if (document.getElementById('btn_fav_delete_'+org)) document.getElementById('btn_fav_delete_'+org).style.display = (is_fav ? '' : 'none');

}

function toggle_ikb_nav(cat_id) {

	var arr = document.getElementById('ikb_arrow_'+cat_id);
	var sec = document.getElementById('ikb_sections_'+cat_id);

	if (sec) {
		if (sec.style.display == 'none') {
			sec.style.display = '';
			arr.src = '/mod_bin/general/arrow.php?fc=CC0000&d=d';
		} else {
			sec.style.display = 'none';
			arr.src = '/mod_bin/general/arrow.php?fc=CC0000&d=r';
		}
	}

}

function agree() {

	document.getElementById('vpl_agreed').value = 'Y';
	document.forms['frm_agree'].submit();

	/*var chk_agreed = document.getElementById('chk_agreed');
	if (chk_agreed) {

		if (chk_agreed.value == "on") {
			document.frm_agree.submit();
		} else {
			alert('U moet akkoord gaan met de gebruiksvoorwaarden om verder te gaan');
		}

	}
	*/

}

function writepng(src, clsname, action) {

	if (navigator.appName == 'Microsoft Internet Explorer') {
		document.write('<div class="js_png_image ' + (clsname ? clsname : '') + '"'+ (action ? 'onclick="' + action + '" ' : '') + 'style="width: 10px; height: 10px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+src+'\', sizingMethod=\'image\');">&nbsp;</div>');
	} else {
		document.write('<img ' + (clsname ? 'class="' + clsname + '" ' : '') + (action ? 'onclick="' + action + '" ' : '') + ' border="0" alt="" src="'+src+'">');
	}

}

function show_brd_selector() {

	var bt = document.getElementById('brand_list_selector_btn');
	var dv = document.getElementById('brand_list_selector_div');
	var ofs = new totalElementOffset(bt);
	dv.style.display = '';
	dv.style.top = (ofs.y - dv.offsetHeight + bt.offsetHeight + 50) + 'px';
	dv.style.left = (ofs.x - bt.offsetWidth - 50) + 'px';

}

function hide_brd_selector() {

	var dv = document.getElementById('brand_list_selector_div');
	if (typeof(dv) != 'undefined' && dv) dv.style.display = 'none';

}

function closeAllLayers(force) {

	if (force) insideLayer = false;
	if (!insideLayer) {

//		var il;
		if (typeof(closeAllSubMenus) != 'undefined') closeAllSubMenus();
		/*var il = document.getElementById('login_container');
		if (il) il.style.display = 'none';
		*/

		var il = document.getElementById('top_menu');
		if (il) il.style.display = 'none';

		hide_brd_selector();

	}

}

function eventObject(event) {

	if (useNS) {
		this.keycode = event.which;
		this.element = event.target;
	} else {
		this.keycode = event.keyCode;
		this.element = event.srcElement;
	}

}

function _vp_handle_frm_key(event, form) {

	var evt = new eventObject(event);
	if (form && (evt.keycode == 13 || evt.keycode == 27)) {

		closeAllLayers(true);
		if (evt.keycode == 13) form.submit();
		return false;

	}

}


function alert_r(elm) {
	var msg = '';
	for (idx in elm) {
		msg += '['+idx+'] = ' + elm[idx] + '\n';
	}
	alert(msg);

}

// Browser Slide-Show script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
function RunSlideShow(pictureName,imageFiles,displaySecs) {
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);
	if (document.all) {
		document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
	document.getElementById(pictureName).src = nextImage;
	if (document.all) {
		document.getElementById(pictureName).filters.blendTrans.Play();
	}

	var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length) + ';' + nextImage;
	setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")", displaySecs*1000);
}

function ubw_search_by_cat(cat_id, url) {

	frm = document.forms['frm_ubw_search'];
	if (frm.elements['search_refine'].value == '1') {
		new_loc = '/'+url+'/zoek/bewerking/'+frm.elements['ubw_subvar'].value+':'+cat_id+'/';
	} else {
		new_loc = '/'+url+'/zoek/bewerking/'+cat_id+'/'
	}
	new_loc += '&highlight=' + cat_id;

	window.location.href = new_loc;
}

function ubw_search_refine_by_param() {
	frm = document.forms['frm_ubw_search'];
	if (frm) {
		var cat_ids = frm.elements['ubw_subvar'].value.split(':');
		var param_replace = [];

		for (var i=0; i < frm.elements.length; i++) {

			var el_name = typeof(frm.elements[i].name) != 'undefined' ? frm.elements[i].name : '?';

			if (el_name.indexOf('ubw_param[') >= 0) {
				param_id = el_name.match(/ubw_param\[([0-9]*)\]/)[1];

				//-- check for current selection
				prev_param = frm.elements['ubw_param_current['+param_id+']'];

				if (prev_param && prev_param.value) {

					//--- found a previous selected, replace id in the cat_list
					//cat_ids[cat_ids.find(prev_param.value)] = frm.elements[el_name].value != '0' ? frm.elements[el_name].value : '';

					if (frm.elements[el_name].value == '0') {

						//--- delete element from array
						if (cat_ids.find(prev_param.value) !== false) cat_ids.splice(cat_ids.find(prev_param.value),1);

					} else {

						//--- replace element
						cat_ids[cat_ids.find(prev_param.value)] = frm.elements[el_name].value;

					}

				} else if (frm.elements[el_name].value != '0') {

					//--- no prev available, we can safely add it to the cat-list
					cat_ids[cat_ids.length] = frm.elements[el_name].value;
				}
			}
		}
		//alert(cat_ids);

		reload_ubw(cat_ids);

	}
}

function ubw_search_remove_cat(cat_id) {
	if (!confirm('Zeker weten?')) return;

	frm = document.forms['frm_ubw_search'];
	if (frm) {
		var cat_id_list = frm.elements['ubw_subvar'].value.split(':');

		//--- delete element from array
		if (cat_id_list.find(cat_id) !== false) cat_id_list.splice(cat_id_list.find(cat_id),1);

		//--- delete all subeleme
		if (ubw_all_cat_options[cat_id]) {
			for (var i=0; i < ubw_all_cat_options[cat_id].length; i++) {
				if (ubw_all_cat_options[cat_id][i]) {
					delete_id = ubw_all_cat_options[cat_id][i];
					if (cat_id_list.find(delete_id) !== false) cat_id_list.splice(cat_id_list.find(delete_id),1);
				}
			}

		}
		//alert(cat_id_list);
		reload_ubw(cat_id_list);

	}
}

function reload_ubw(cat_ids) {
	var frm = document.forms['frm_ubw_search'];
	var url = '/uitbesteedwijzer/zoek/bewerking/' + cat_ids.join(':');

	if (frm.elements['highlight'].value && cat_ids.in_array(frm.elements['highlight'].value)) url += '&highlight='+frm.elements['highlight'].value;

	window.location.href = url;
}

// productwijzer
function pdw_search_by_cat(cat_id, url) {

	frm = document.forms['frm_ubw_search'];
//	if (frm.elements['search_refine'].value == '1') {
//		new_loc = '/'+url+'/zoek/productgroep/'+frm.elements['ubw_subvar'].value+':'+cat_id+'/';
//	} else {
		new_loc = '/'+url+'/zoek/productgroep/'+cat_id+'/'
//	}
	new_loc += '&highlight=' + cat_id;

	window.location.href = new_loc;
}


function show_resolution_message() {

	if (!getCookie('seen_resolution_message')) {
		document.getElementById('screenres_message_container').style.left = (document.body.clientWidth / 2) -185 +'px';
		document.getElementById('screenres_message_container').style.top = '150px';
		document.getElementById('screenres_message_container').style.display = '';
	}

}


function hide_resolution_message() {

	setCookie('seen_resolution_message', 1);

	document.getElementById('screenres_message_container').style.display = 'none';


}


/*******************\
|	Notes           |
\*******************/

var _current_note_type = null;
var _current_note_type_id = null;
var _current_note_title = null;

function show_note(type, id, note_title) {
	hide_note();

	_current_note_type = type;
	_current_note_type_id = id;
	_current_note_title = note_title;

	var url = '/action.php?action=get_note&not_type='+type+'&id='+id;
	xmlHttp.get(url, type+'_'+id);

}

function hide_note() {

	document.getElementById('note_container').style.display = 'none';

	document.getElementById('popup_not_title').value = '';

	document.getElementById('popup_not_text').value = '';
	document.getElementById('popup_not_text_DISPLAY').value = '';

	document.getElementById('not_id').value = '';
	document.getElementById('not_type').value = '';
	document.getElementById('not_type_id').value = '';

	_current_note_type = null;
	_current_note_type_id = null;

}

function save_note() {

	var not_id = '';
	if (document.getElementById('not_id')) not_id = document.getElementById('not_id').value;

	url = '/action.php?action=save_note&not_id='+not_id
		+ '&not_title='+document.getElementById('popup_not_title').value
		+ '&not_text='+document.getElementById('popup_not_text').value.replace(/\r\n/g,'[[enter]]').replace(/\n/g,'[[enter]]')
		+ '&not_type='+_current_note_type
		+ '&not_type_id='+_current_note_type_id;

		xmlHttp.post(url);

	hide_note();


}

function delete_note() {

	if (confirm('Zeker weten?'))	{
		var not_id = document.getElementById('not_id').value;
		if (not_id) {
			xmlHttp.get('/action.php?action=delete_note&not_id='+not_id);
			hide_note();

			note_show_link = document.getElementById('show_note_'+not_id);
			if (note_show_link) {
				note_show_link.parentNode.removeChild(note_show_link);
			}
		}
	}

}


function xmlHttp_onReadyStateCompleted(text, id) {


	if (id) {
	
		_not_org_id = null;

		note_data = id.split('_');
		_note_type = note_data[0];
		_note_type_id = note_data[1];

		if (text.length > 10) {
			eval(text);
			if (_note_id && _note_title && _note_text) {

				document.getElementById('popup_not_title').value = _note_title;
				document.getElementById('popup_not_text').value = _note_text;
				document.getElementById('popup_not_date').innerHTML = 'Laatst gewijzigd: '+_note_date;
				document.getElementById('popup_not_text_DISPLAY').value = _note_text;

				document.getElementById('not_id').value = _note_id;
				document.getElementById('not_type').value = _note_type;
				document.getElementById('not_type_id').value = _note_type_id;
				document.getElementById('not_org_id').value = _not_org_id;
			}
		}

		document.getElementById('link_all_notes').style.display = _not_org_id ? '' : 'none';

		if (typeof(_note_title) == 'undefined') {
			document.getElementById('popup_not_title').value = _current_note_title;
		}

		showNoteContainer();

	}

}


function showNoteContainer() {
	var nc = document.getElementById('note_container');
	if (nc) {
		offsetTop = parseInt(document.body.scrollTop + (document.body.clientHeight / 2) - (nc.offsetHeight ? nc.offsetHeight / 2 : 125));
		nc.style.top = offsetTop + 'px';

		nc.style.display = '';
	}
}

function open_all_notes() {

	if (document.getElementById('not_org_id').value) {

		window.location.href = '/mijnfavorieten/notities/&org_id='+ document.getElementById('not_org_id').value;

	}

}

var active_popup_id;
function open_popup(popup_id, parent, hOffset, vOffset) {
	if (active_popup_id) close_popup(active_popup_id);
	popup = doen(popup_id);

	if (!vOffset) {
		var scroll_top = window.pageYOffset ? window.pageYOffset : document.getElementsByTagName("body")[0].scrollTop;
		vOffset = scroll_top+80;
	}

	if (popup) {

		active_popup_id = popup_id;

		if (parent) {

			showLayer(popup_id, parent, 0, 0, 0, 0, hOffset, vOffset);

		} else {

			popup.style.display = '';

		}
	}
}

function close_popup(popup_id) {
	popup = doen(popup_id);
	if (popup) popup.style.display = 'none';
}

function vpc_open_cat(org_id, cat_id) {

	loc = '/catalogus/'+org_id+'/cat/'+cat_id+'/';
	window.location.href = loc;

}

function vpc_prd_browse(page) {
	frm = document.forms['product_browser'];
	if (frm) {
		base_url = document.location.href.substr(0, document.location.href.indexOf('&'))
		window.location = base_url
							+ '&_vpc_offset='+page
							+ '&_vpc_order='+frm.elements['_vpc_order'].value
							+ '&_vpc_order_dir='+frm.elements['_vpc_order_dir'].value;
	}
}

function vpc_prd_sort(fld, sort_desc) {
	frm = document.forms['product_browser'];
	if (frm) {
		base_url = document.location.href.substr(0, document.location.href.indexOf('&'))
		window.location = base_url + '&_vpc_offset=1&_vpc_order='+fld + (sort_desc ? '&_vpc_order_dir=DESC' : '');
	}
}

function vpc_hover_row (row, state) {

	if (state) {
		row.style.backgroundColor = '#A7CAD3';
	} else {
		row.style.backgroundColor = '';

	}
return;
	if (state) {
		row.className += ' hover';
	} else {
		row.className = row.className.replace(' hover', '');
	}


}

/*

	Shows a layer at a specific position.
	id is the layer id, parent is the object to align
	the layer to and the pos and align arguments specify
	the layer's position relative to the parent object;
	The vAlign/hAlign side of the layer will be placed at the
	vPos/hPos coordinate of the parent object:

	          ----------------  <- [vPos 0]
			 |     PARENT     |
	          ----------------  <- [vPos 1]
             ^                ^
	      [hPos 0]         [hPos 1]


	          --------------  <- [vAlign 0]
			 |     LAYER     |
	          --------------  <- [vAlign 1]
             ^               ^
	     [hAlign 0]      [hAlign 1]

*/
function showLayer(id, parent, hPos, vPos, hAlign, vAlign, hOffset, vOffset) {

	var layer = document.getElementById(id);
	var offset = new totalElementOffset(parent);
	var left = offset.x;
	var top = offset.y;

	if (hPos == 1) left += parent.offsetWidth;
	if (vPos == 1) top += parent.offsetHeight;
	if (hAlign == 1) left -= layer.style.width.replace(/px/,'');
	if (vAlign == 1) top -= layer.style.height.replace(/px/,'');
	if (hOffset) left += hOffset;
	if (vOffset) top += vOffset;

	layer.style.display = '';
	layer.style.left = left+'px';
	layer.style.top = top+'px';

}

// Crossbrowser compatible positioning
// Returns an object containing the total x and y offsets for obj relative to the document
function totalElementOffset(obj) {

	var yOffset = (obj.offsetTop ? obj.offsetTop : 0);
	var xOffset = (obj.offsetLeft ? obj.offsetLeft : 0);
	var elParent = obj.offsetParent;

	while (elParent) {
		yOffset += (elParent.offsetTop ? elParent.offsetTop : 0);
		xOffset += (elParent.offsetLeft ? elParent.offsetLeft : 0);
		elParent = elParent.offsetParent;
	}

	this.y = yOffset;
	this.x = xOffset;

}

function createPopup(title,src,artnr)  {
	var popup_holder = document.createElement('div');
	var _body = document.getElementsByTagName("body")[0];

	// Grey overlay
	//show_overlay();
	popup_holder.id = 'popup';
	var content = '<h2 onclick="javascript:closePopup();">' + title + '</h2><img src="/catalogus/3/image/' + src + '/" alt=""><p>Artikelnummer: ' + artnr + '</p>';
	popup_holder.innerHTML = content;
	_body.appendChild(popup_holder);
	center_layer(popup_holder, 500, 60);
}

function closePopup() {
	//hide_overlay();
	var pu = document.getElementById('popup');
	if (pu) pu.parentNode.removeChild(pu);
}

function center_layer(layer, width, top_offset) {
	if (typeof(layer) == 'string') layer = document.getElementById(el);

	if (!layer) return false;


	var docElem = (window.document.documentElement) ? window.document.documentElement : docElem = window.document.body
	var scroll_top = window.pageYOffset ? window.pageYOffset : docElem.scrollTop;
	var page_width = (docElem.scrollWidth ? docElem.scrollWidth : docElem.offsetWidth);
	var page_height = docElem.offsetHeight;
	layer.style.left = ((page_width - width) / 2) + 'px';
	layer.style.top = ((page_height - 0) / 2) + 'px';

}

function showPrd(id, width, top_offset) {
	var layer = document.getElementById(id);

	var docElem = (window.document.documentElement) ? window.document.documentElement : docElem = window.document.body
	var scroll_top = window.pageYOffset ? window.pageYOffset : docElem.scrollTop;
	var page_width = (docElem.scrollWidth ? docElem.scrollWidth : docElem.offsetWidth);
	var page_height = docElem.offsetHeight;
	layer.style.display = '';
	layer.style.left = ((page_width - width) / 2) + 'px';
	layer.style.top = ((page_height - 300) / 2) + 'px';

}

function closePrd(id) {
	var layer = document.getElementById(id);
	layer.style.display = 'none';
}

function popUp(URL) {
	var day = new Date();
	var id = day.getTime();	
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=875,height=525,left = 50%,top = 100');");
}

// Google maps
var map = null;
var geocoder = null;

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));        
		map.addControl(new GSmallMapControl());
		map.addControl(new GScaleControl()) ;
		geocoder = new GClientGeocoder();
	}
}

function showAddress(city,street) {
	if (geocoder) {
		var address = street +', '+city;
    	geocoder.getLatLng(address,
      		function(point) {
        		if (!point) {
        			//alert(address + " not found");
        			//map = document.getElementById("map");
        		} else {
          			map.setCenter(point, 15);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					var org = doen("#gm_orgname").text();
					var content = "<h1>"+org+"</h1>";
					content += "<p>"+address+"</p>";
					content += "<a href=\"http://maps.google.com/maps?f=d&hl=nl&q="+address+"&sll=sspn=&ie=UTF8&z=16&iwloc=addr&om=1\">Routebeschrijving</a>";
					marker.openInfoWindowHtml(content);
				}
			}
		);
	}
}

function _delPopup(id) {
	var pu = document.getElementById(id);
	if (pu) pu.parentNode.removeChild(pu);
}

function _createPopup(uri, org_id, name, btn_code, title) {
	
	// quick & dirty
	if (name == '') var name = document.createElement("org_name");
	var popup_holder = document.createElement("div");
	var _body = document.getElementById("wrapper");
	if(btn_code != '') {
		var btn = '&btn='+ btn_code;
	} else {
		var btn = '&btn=netto';
	}
	popup_holder.id = "popupje";
	var hdr = '<div class="popupje_title">'+ title +'<img src="/img/btn/x-close.png" alt="Sluiten" class="img_cls" onclick="_delPopup(\'popupje\')"/></div>';
	var ftr = '<a href="/redirect.php?org_id='+ org_id + btn +'" class="redirect" target="remote" onclick="_delPopup(\'popupje\')">'+ name +'</a>'
	_body.appendChild(popup_holder);
	center_layer(popup_holder, 550, 220);
	jQuery.ajax({
		url : "/uri/?uri="+uri,
		type: "get",
		dataType: "html",
		success : function (html) {	
			popup_holder.innerHTML = hdr + html + ftr;
		}
	});
}

function createHelpPopup(uri, title, id) {
	// quick & dirty
	if (!document.getElementById(id))
	{
		var popup_holder = document.createElement("div");
		var _body = document.getElementById("wrapper");
		popup_holder.id = id;
		var hdr = '<div class="popupje_title">'+ title +'<img src="/img/btn/x-close.png" alt="Sluiten" class="img_cls" onclick="_delPopup(\'popupje\')"/></div>';
		_body.appendChild(popup_holder);
		center_layer(popup_holder, 365, 220);
		jQuery.ajax({
			url : "/uri/?uri="+uri,
			type: "get",
			dataType: "html",
			success : function (html) {	
				popup_holder.innerHTML = hdr + html;
			}
		});
	} else {
		if (document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}

	}
}

function createHelp(code, title, id) {

	if (!document.getElementById(id))
	{
		var popup_holder = document.createElement("div");
		var _body = document.getElementById("wrapper");
		popup_holder.id = id;
		var hdr = '<div class="popupje_title">'+ title +'</div>';
		_body.appendChild(popup_holder);
		center_layer(popup_holder, 365, 220);
		jQuery.ajax({
			url : "/pages/p"+code+"&do=1",
			type: "get",
			dataType: "html",
			success : function (html) {	
				popup_holder.innerHTML = hdr + html;
			}
		});
	} else {
		if (document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}

	}
}

function hideHelpPopup(id) {
	document.getElementById(id).style.display = 'none';
}

function clickIE4(){
	if (event.button==2){
		alert(message);
		return false;
	}
}

function clickNS4(e){
	if (document.layers || document.getElementById && !document.all){
		if (e.which == 2 || e.which == 3) {
			alert(message);
			return false;
		}
	}
}

function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none";
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
		target.style.cursor = "default";
}
/*
jQuery(document).ready(function(){
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = clickNS4;
	} else if (document.all && !document.getElementById){
		document.onmousedown = clickIE4;
	}
	document.oncontextmenu = new Function("return false");
	disableSelection(document.body);
});
*/

//jQuery(document).ready(function() {
//	alert('YO');
//	var logo = document.getElementById("lev_logos");
//	if (logo) {
//    	setTimeout("getLevLogo()", 5000);
//	}
//});
// included in home_openbaar.tpl (getElementById didnt work in IE7)

function getLevLogo() {
	var logo = document.getElementById("lev_logos");
	jQuery.ajax({
		url : "action.php?action=get_lev_logo",
		type: "get",
		//dataType: "html",
		success: function(msg){
     		logo.innerHTML = msg;
		}
	});
	//getImgSize("levpic");
	setTimeout("getLevLogo()", 5000);
}

function getImgSize(id){
	var pic = document.getElementById(id);
	var h = pic.offsetHeight;
	var w = pic.offsetWidth;
	alert ('The image size is '+w+'*'+h);
}

function getDlnLogo() {
	var logo = document.getElementById("dln_logos");
	jQuery.ajax({
		url : "action.php?action=get_dln_logo",
		type: "get",
		//dataType: "html",
		success: function(msg){
     		logo.innerHTML = msg;
		}
	});
	//getImgSize("dlnpic");
	setTimeout("getDlnLogo()", 7000);
}

function showVideoPlayer(title, flv_filename) {
	//alert(flv_filename);

	var popup_holder = document.createElement('div');
	var _body = document.getElementsByTagName("body")[0];
	

	// Grey overlay
	//show_overlay();
	popup_holder.id = 'popup_video_player';
	//popup_holder.style.position = 'absolute';
	//popup_holder.style.backgroundColor = 'white';
	//popup_holder.style.border = '2px solid black';
	var content = '<div class="top_video"><h2 onclick="javascript:closeVideoPlayer();">' + title + '</h2></div><div id="video_player_holder"></div>';
	popup_holder.innerHTML = content;
	_body.appendChild(popup_holder);

	var so = new SWFObject("/swf/player.swf?file=" + flv_filename, "/swf_player", "298", "237", "0", "#000");
	so.skipDetect = true;

//	so.addParam("quality", "high");
//	so.addParam("wmode", "transparent");
//	so.addParam("movie", '/flv/' + flv_filename);
	so.write("video_player_holder");

	center_layer(popup_holder, 300, 60);
}

function closeVideoPlayer() {
	popup = document.getElementById('popup_video_player');
	if (popup) {
		popup.parentNode.removeChild(popup);
	}
}

function mpause(millis)
{
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < millis);
}


