var UserOK

function load(scriptName)
{
	var ROOT_DIR = _PROJECT_URL + 'css/';
	var scriptElem = document.createElement('link'); 
	scriptElem.setAttribute('type','text/css'); 
	scriptElem.setAttribute('rel','stylesheet'); 
	scriptElem.setAttribute('href',ROOT_DIR+scriptName); 
	document.getElementsByTagName('head')[0].appendChild(scriptElem); 
}

//All fields with id filled in are required fields.
function cOn(td, color) {
    if(document.getElementById||(document.all && !(document.getElementById))) {
	  td.style.backgroundColor= color;
	  td.style.cursor = 'pointer';
	}
}

function cOut(td,color) {
    if(document.getElementById||(document.all && !(document.getElementById))) {
	  td.style.backgroundColor= color;
	}
}

function openOverlay(title,url,width,height) {
	GB_showCenter(title, url, /* optional */ height, width)
}

function initSIFR() {
	if(typeof sIFR == "function"){
		// header big, black
		sIFR.replaceElement(named( {
			sSelector:"h1",
			sFlashSrc: _PROJECT_URL + "flash/h1.swf",
			sColor:"#ffffff",
			sLinkColor:"#ffffff", 
			sHoverColor:"#FF6600", 
			sWmode:"transparent",
			nPaddingTop:0,
			nPaddingBottom:0,
			sFlashVars:"textalign=left&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 display(a) {    
	if(a!=undefined) {
		//var a = arr.split(',')
		for(i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display='block'
		}
	}	
	return false
}

function hide(a) {    
	if(a!=undefined) {
		//var a = arr.split(',')
		for(i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display='none'
		}
	}	
	return false
}

function del_onclick(str) {
	return confirm('Weet u zeker dat u ' + str + ' wilt verwijderen?');
}

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}
	document.getElementById('cntChars').innerHTML = qty - obj.value.length;
	document.getElementById('charQty').value = qty;
}

function printme() {
	var objOut = document.getElementById("output");
	var out = objOut.innerHTML;
		
	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()",2000);';	
	output += '</'+'script>';
	wh.document.writeln(output);
	wh.document.close();
}

function MouseOver(obj){
	obj = document.getElementById(obj)
	if (obj){
		if (obj.src.indexOf('_on') > -1){
			obj.src = obj.src.replace('_on.gif','.gif')
		}else{
			obj.src = obj.src.replace('.gif','_on.gif')
		}
	}
}

function changeImage(id,url){    
	if(document.getElementById(id)){
		document.getElementById(id).src = url;
	}
}


//Toevoegen van een youtube movie
function loadYouTube(url){
if (url.indexOf("http://") == 0) 
	{
		var so = new SWFObject(""+url+"", "site", "200", "150", "8,0,0,0", "#000000");
	} else {
		var so = new SWFObject("http://www.youtube.com/v/"+url+"&rel=1", "site", "200", "150", "8,0,0,0", "#000000");
	}	
	so.addParam("allowFullscreen","true")
	so.write("video_box");
}

function setClass(obj,className){    
    obj.className = className
}

function showTooltip(obj,strContent,e){
    document.getElementById('qContent').innerHTML = strContent
    var objTooltip = document.getElementById('tooltip')    
    if(obj){
        if(IE){        
        status = event.clientY  + ' / ' +  document.body.scrollTop + ' / ' + objTooltip.clientHeight
            tempX = event.clientX + document.body.scrollLeft - (objTooltip.clientWidth)
            tempY = event.clientY + document.body.scrollTop - (objTooltip.clientHeight * 1.5)
        } else {  // grab the x-y pos.s if browser is NS
            tempX = e.pageX - objTooltip.style.width
            tempY = e.pageY - objTooltip.style.height
        }                  
        objTooltip.style.left = tempX + 'px'
        objTooltip.style.top = tempY + 'px'
        objTooltip.style.display='block'
    }
}


function postback(form,idField,keepValue){
    var objForm = document.getElementById(form)
    var objField = document.getElementById(idField)
    var objCmd = document.getElementById('cmd')    
    if (objForm && objField){
        if(keepValue != ''){        
            objField.value = keepValue
        }
        if(objCmd){
            objCmd.value=''
        }
        objForm.submit()
    }        
}
