
function showNieuwsByGuid(guid, width, height)
{
	putIF("popup", 50, 50, width, height, "/werken_cms/system/ShowFlash.aspx?id=" + guid)
}


function putIF(hldr,x,y,w,h,url)
{
	holder=document.getElementById(hldr); //wrap around div
	var theTop;
	if (document.documentElement && document.documentElement.scrollTop)
		theTop = document.documentElement.scrollTop;
	else if (document.body)
		theTop = document.body.scrollTop;
	else   
		theTop = window.pageYOffset;
		
	holder.style.left = String(x) + "px";
	holder.style.top = String(theTop + y) + "px";
	holder.style.width = String(w) + "px";
  
	var iframe = document.getElementById("iframepopup");
	iframe.style.width = String(w) + "px";
	iframe.style.height = String(h) + "px";
	iframe.src = url;
	holder.style.visibility='visible';  // the div gets styled   
}

function closeIF(obj)
{
  obj.style.visibility='hidden';
  var iframe = document.getElementById("iframepopup");
  iframe.src = "";
  
}

function WriteOutObject(flashFile, althtml, width, height, holder, wmode, flashvars) {
    var html = ''
    html = html +  '<!--[if !IE]> -->';
    html = html +  '<object type="application/x-shockwave-flash" data="' + flashFile + '" width="' + width + '" height="' + height + '">';
    html = html +  '<!-- <![endif]-->';
    html = html +  '<!--[if IE]>';
    html = html +  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
    html = html +  '    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"';
    html = html +  '    width="' + width + '" height="' + height + '">';
    html = html +  '    <param name="movie" value="' + flashFile + '" />';
    html = html +  '<!--><!---->';
    html = html +  '    <param name="quality" value="high" />';
    html = html +  '    <param name="wmode" value="' + wmode + '" />';
    html = html +  '    <param name="flashvars" value="' + flashvars + '" />';
    html = html +		althtml
    html = html +  '</object>';
    html = html +  '<!-- <![endif]-->';
    var objHolder = document.getElementById(holder);
    objHolder.innerHTML = html;
}

function SetDivContent(divId, content) {
	var div = document.getElementById(divId)
	div.innerHTML = content;
}

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength) {
		this.relatedElement.className = 'toomuch';
	} else {
		this.relatedElement.className = '';
	}
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}
function ns_flashcounter(ns_flashn){
var
ns_flash="http://nl.sitestat.com/umc/werkenbij/s?"+ns_flashn+"&amp;ns_type=flash"+"&amp;ns__t="+(new Date()).getTime();
document.ns_flashp.src=ns_flash;}


function format(input){
 var num = input.value.replace(/[^0123456789]/g,'');
 input.value = num
}


function numbersonly(myfield, e, dec) {
   var key;
   var keychar;
 
    if (window.event)
       key = window.event.keyCode;
    else if (e)
       key = e.which;
    else
       return true;
    keychar = String.fromCharCode(key);
 
    // control keys
    if ((key==null) || (key==0) || (key==8) || 
        (key==9) || (key==13) || (key==27) )
       return true;
 
    // numbers
    else if ((("-0123456789").indexOf(keychar) > -1))
    //else if ((("0123456789")))
       return true;
 
      else
       return false;
}