$(document).ready(function() {

	setTimeout('click_sidebar(0)', 1000);	

	$(".check").click(function(){
			var imgsrc = $(this).find("img").attr("src");
			var input = $(this).find("input");
			if(imgsrc.indexOf('-on.gif')==-1){			    
				imgsrc = imgsrc.replace('.gif','-on.gif');
				$(this).find("img").attr('src',imgsrc);
				if ($(input).size() > 0){
					$(input).attr("value","1");
				}
				$('#error').hide();
			}else{
				imgsrc = imgsrc.replace('-on.gif','.gif');
				$(this).find("img").attr('src',imgsrc);
				if ($(input).size() > 0){
					$(input).attr("value","0");
				}
				$('#error').show();
			}
			if ($(input).attr("id") == 'disclaimer'){
				chckField($('#disclaimer').get(0),$('#disclaimer').get(0),$('#disclaimer').attr('title'));
			}
		}
	);
	try
	{
	$("input[type=file]").filestyle({ 
		 image: _PROJECT_URL + "img/bt_bladeren.gif",
		 imageheight : 20,
		 imagewidth : 80,
		 width : 200
	});
	}catch(e)
	{
		
		}
})

var UserOK
var toMenu

function openOverlay(title,url,width,height) {
	GB_showCenter(title, url, /* optional */ height, width)
}

function mOn(obj) {
	var ext = obj.src.slice(-3)
	if(obj.src.indexOf('_o.'+ ext)==-1){
		obj.src=obj.src.replace('.'+ ext,'_o.'+ ext)
	}
}
function mOut(obj) {
	var ext = obj.src.slice(-3)
	obj.src=obj.src.replace('_o.'+ext,'.'+ext)
}

function initSIFR() {
	if(typeof sIFR == "function"){
		//red big title
		sIFR.replaceElement("h1", named({
			sSelector:"h1",
			sFlashSrc:_PROJECT_URL + "flash/h1.swf",
			sColor:"#ed0000",
			sLinkColor:"#ffffff", 
			sWmode:"transparent",
			sCase: "normal",
			nPaddingTop:0,
			nPaddingBottom:0,
			sFlashVars:"offsetTop=0"
			}
		));
		//black title
		sIFR.replaceElement("h2", named({
			sSelector:"h2.black",
			sFlashSrc:_PROJECT_URL + "flash/h2.swf",
			sColor:"#333333",
			sLinkColor:"#ffffff", 
			sWmode:"transparent",
			sCase: "normal",
			nPaddingTop:0,
			nPaddingBottom:0,
			sFlashVars:"offsetTop=0"
			}
		));
		//blue title
		sIFR.replaceElement("h2", named({
			sSelector:"h2",
			sFlashSrc:_PROJECT_URL + "flash/h2.swf",
			sColor: "#a3c2e4",
			sLinkColor:"#ffffff", 
			sWmode:"transparent",
			sCase: "normal",
			nPaddingTop:0,
			nPaddingBottom:0,
			sFlashVars:"offsetTop=0"
			}
		));
		//grey small title
		sIFR.replaceElement("h3", named({
			sSelector:"h3",
			sFlashSrc:_PROJECT_URL + "flash/h3.swf",
			sColor:"#333333",
			sLinkColor: "#ffffff", 
			sWmode:"transparent",
			sCase: "normal",
			nPaddingTop:0,
			nPaddingBottom:0,
			sFlashVars:"offsetTop=0"
			}
		));
	};
}	

function getCheckboxValue(id) {
	var allInputTags = document.getElementById(id+'_group').getElementsByTagName('INPUT');
	for (var c=0; c<allInputTags.length; c++) {
		if (allInputTags[c].checked) {
			return allInputTags[c].value;
			break;
		}
	}
	return ""
}

function selAll() {
	var span = document.getElementById('checkboxes').getElementsByTagName('INPUT')
	var select = span[0].checked
	for(i=0;i<span.length;i++){
		if(span[i].type=='checkbox'){
			span[i].checked = select
		}
	}
}

function countChars(id,qty) {
	var obj = document.getElementById(id)
	obj.onclick=function(){document.getElementById('cntChars').innerHTML = qty - obj.value.length}
	obj.onkeyup=function(){
		document.getElementById('cntChars').innerHTML = qty - obj.value.length; 
		if (obj.value.length >= qty){
			document.getElementById(id).value=document.getElementById(id).value.substring(0,qty)
		}
	}
	document.getElementById('cntChars').innerHTML = qty - obj.value.length
}

function printme() {
	var objOut = document.getElementById("output");

	var out = objOut.innerHTML;

	out = out.replace(/<a/g, '<!--a')
	out = out.replace(/a>/g, 'a>-->')
	out = out.replace(/POSITION: absolute;/g,'');
	out = out.replace(/overflow: visible;/g,'');
	out = out.replace(/height: auto;/g,'');
	out = out.replace(/position: absolute;/g,'');
	out = out.replace(/height: 235px;/g,'');
	
	
	out = out.replace(/$('#p370-420').jScrollPane({showArrows:true, dragMaxHeight: 150,scrollbarWidth: 15, arrowSize: 16});/g,"")		

	var wh = window.open("","wh","width=640px,height=480px,scrollbars=yes");
	wh.document.open();
	var output = '<link href="css/print.css" rel="stylesheet" type="text/css">';
	output = '<html><head>'+output+'</head><body>'+out.replace('<object','<!--object').replace('/object>','/object-->')+'</body></html>';
	output += '<'+'script type="text/javascript">';
	output += 'setTimeout("window.print()",50);';	
	output += '</'+'script>';	
	wh.document.writeln(output);
	wh.document.close();
}

function display(id,arr) {
	if(arr!=undefined) {
		var a = arr.split(',')
		for(i=0;i<a.length;i++){
			if(document.getElementById(a[i])) document.getElementById(a[i]).style.display='none'
		}
	}
	if(id!=''){
		if(document.getElementById(id)){
			var obj = document.getElementById(id).style
			if(obj.display=='none'){
				obj.display='block'
			}
		}
	}
	return false
}

//functie voor setten van checkboxen
function check(v,id,input) {
	var obj = document.getElementById(input)
	var rest
	if(obj.value.indexOf(','+v+',')==-1){
		if(obj.value==''){
			obj.value=','
		}
		if(obj.value!=''){
			obj.value=obj.value+v+',';
		}
		document.getElementById(id).src = document.getElementById(id).src.replace('.gif','_o.gif')
	}else{
		obj.value = obj.value.replace(','+v+',',',')
		if(obj.value.length==1) obj.value=''
		document.getElementById(id).src = document.getElementById(id).src.replace('_o.gif','.gif')
	}
}

//functie voor setten van radiobutton
function radio(val,id,input) {
	var obj = document.getElementById(input)
	var curId = document.getElementById(id)
	var checked = false
	if(curId.src.indexOf('_o.gif')>-1) checked = true
	//reset alle items
	for (var i = 1; i <= document.getElementById(input + '_cnt').value; i++) {
	    document.getElementById('radio' + i).src = document.getElementById('radio' + i).src.replace('_o.gif', '.gif')
	}
	//wanneer nog niet geselecteerd, selecteer item
	if(!checked){
		obj.value=val
		document.getElementById(id).src = document.getElementById(id).src.replace('.gif','_o.gif')
	}else{
		obj.value=''
	}
}

function MouseOver(obj){
	obj = document.getElementById(obj)
	if (obj){
	//	alert(obj.src);
		if (obj.src.indexOf('_o') > -1){
			obj.src = obj.src.replace('_o.png','.png')
		}else{
			obj.src = obj.src.replace('.png','_o.png')
		}
	}
}

function MouseOverItem(obj,arrow){
	obj = document.getElementById(obj)
	arrow = document.getElementById(arrow)	
	if (obj){
		if (obj.className.indexOf('_on') > -1){
			obj.className = obj.className.replace('_on','_off');
			arrow.src = arrow.src.replace('_on.gif','.gif')
		}else{
			obj.className = obj.className.replace('_off','_on');
			arrow.src = arrow.src.replace('.gif','_on.gif')
		}
	}
}

function MouseOverNav(obj)
{
	if (obj)
	{
		objElements = document.getElementById(obj)
		if (objElements)objElements.src = 'img/nav/' + obj + '_o.png';
	}
}

function MouseOutNav(obj){
	if (obj)
	{
		objElements = document.getElementById(obj)
		if(objElements)objElements.src = 'img/nav/' + obj + '.png';
	}
}

function show(id){
	var obj = document.getElementById(id);
	if(obj){
		if(obj.style.display=='none'){
			obj.style.display = 'block';
		}else{
			obj.style.display = 'none'; 
		}
		$('#pane1').jScrollPane({showArrows:true, dragMaxHeight: 150,scrollbarWidth: 15, arrowSize: 16});
	}
}

function show2(id,prefix){
	//Sluit eerst alles	
	$("div[id^='" + prefix + "']").each(function(){				
		$(this).hide();
	});
	
	var obj = document.getElementById(id);
	if(obj){
		if(obj.style.display=='none'){
			obj.style.display = 'block';
		}else{
			obj.style.display = 'none'; 
		}
		$('#pane1').jScrollPane({showArrows:true, dragMaxHeight: 150,scrollbarWidth: 15, arrowSize: 16});
	}
}

// from John Resig's book on JS
function getStyle (elem, name) {
	if (elem.style[name]) {
		return elem.style[name];
	}	else if (elem.currentStyle) {
		return elem.currentStyle[name];
	}	else if (document.defaultView && document.defaultView.getComputedStyle) {
		name = name.replace(/([A-Z])/g, "-$1");
		name = name.toLowerCase();
		var s = document.defaultView.getComputedStyle(elem, "");
		return s && s.getPropertyValue(name);
	} else {
	return null;
	}
}

function isHidden (dOb) {
	while (dOb && dOb !== document && dOb.tagName !== undefined) {
	if (getStyle(dOb, 'display') === 'none') {
		return true;
	}
	dOb = dOb.parentNode;
	}
	return false;
}

function openIframe(o) {
	var w;
	var h;
	/*switch(o){
		case "http://belletjebelletje.almhof.nl/almhof.nl/":
			w = 950;
			h = 600;
			break;
		case "http://watklinktdaarzolekker.almhof.nl":
			w = 950;
			h = 600;
			break;
		default:
			w = 800;
			h = 450;
			break;
	}*/
	return hs.htmlExpand(o, { contentId: 'my-content', objectType: 'iframe', captionEval: '', width: 950, height: 600, align : 'center' });
}
function openGameFrame(href) {
	$('#belletje-link').attr('href', href);
	$('#belletje-link').click();
}

