// Revision History
//----------------------------------------------------------------------------------
// Version:	Auth.:	Date:		Remark:								
// 04.03.00	JM	14-02-2005	added Start()


/////////////////////////////////////////// very common used functions ///////////////////////////////

//------------------------ functions used for image mouseovers ------------------------
function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//------------------------ function used to show popup in the centre of screen ------------------------
function newPopup(url, breedte, hoogte, resize, scroll, menubar, toolbar)
{
	var winLeft = (screen.width-breedte)/2;
	var winTop = (screen.height-hoogte)/2;
	if(!scroll){ scroll = "no" }
	window.open(url, "WindowPopup", "menubar=" +menubar+ ",toolbar=" +toolbar+ ",resizable=" +resize+ ",scrollbars=" +scroll+ ",width=" +breedte+ ",height=" +hoogte+ ",top=" +winTop+ ",left=" +winLeft);
}
// note: the title of the popup is the same as the <title>-tag in the given html page (as url)

//------------------------ function used to show popup with a content string ------------------------
function popupContent(titel, HTMLinhoud, hoogte, breedte)
{
  var generator=window.open('','CtrlWindow','toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, height='+hoogte+',width='+breedte );
  

  generator.document.write('<html><head><title>' +titel+ '</title>');
  generator.document.write('<link rel="stylesheet" href="style.css">');
  generator.document.write('</head><body>');
  generator.document.write(HTMLinhoud);
  generator.document.write('</body></html>');
  generator.document.close();
  return false;
}

//------------------------ function used to load another window in the centre of screen ------------------------
function Start(page) 
{
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,height=400,width=400");
}


//------------------------ function used to set the focus of an element ------------------------
function setFocus(myElement)
{
   if( !(navigator.appName.indexOf("Netscape")>(-1)) && ((parseFloat(navigator.appVersion))<6) )
   {
      document.getElementById(myElement).focus();
   }
}
// note: getElementById compatible with NN 6.0 or higher


//------------------------ function used to bookmark a page ------------------------
function addFavorites(href, title)
{

   if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4))
   {
       window.external.AddFavorite(href, title);
   }
}
// note: not compatible with other browsers. IE is the only browser that can automatically adjust 
// these kind of settings. Users of other browsers are displayed a security message.
// example: msdn.microsoft.com


//------------------------ function used to set value of title attribute of a given element -----------------
function setImageTitles(element,txt) {
  //fill array with all image elements
  arrImg = document.getElementsByTagName("img");

  for(var i=0; i < arrImg.length; i++){
     if(arrImg[i].id == element){
        arrImg[i].title = txt;
     }
  }
} 
//note: this function can be used to easily specify the title attribute. It should be called at the end 
//of page. Otherwise, elements are still not present. (css cannot be applied to standard attributes)


//------------------------ function used to set value of title attribute of a given element -----------------
function setImageAlts(element,txt) {
  //fill array with all image elements
  arrImg = document.getElementsByTagName("img");

  for(var i=0; i < arrImg.length; i++){
     if(arrImg[i].id == element){
        arrImg[i].alt = txt;
     }
  }
}
//note: this function can be used to easily specify the title attribute. It should be called at the end 
//of page. Otherwise, elements are still not present. (css cannot be applied to standard attributes)

//------------------------ function used to set the cursor in the end of a text element ------------------------
function SetEnd (TB)
{
  if (TB.createTextRange)
  {
    var FieldRange = TB.createTextRange();
    FieldRange.moveStart('character', TB.value.length);
    FieldRange.collapse();
    FieldRange.select();
  }
}
// note: the textfield itself must call this function on focus: 
// <input type="text" size="30" id="Txt_Zoek" onfocus="SetEnd(this)">

/////////////////////////////////////////// section for slechtzienden module ///////////////////////////////

//------------------------ function that changes the font-size of the given html-elements  ------------------------

function ndeCheck()
{
if (ndeReadCookie("Session_Enlarge", true) == "1") 
	{
	ndeSetTextSize('incr');
	}
}


function ndeSetTextSize(chgsize,rs) 
{
  var startSize;
  var newSize;

  if (!document.getElementsByTagName){
    return;
  }

  startSize = parseInt(ndeGetDocTextSize());
  
  if (!startSize){
    startSize = 12;
  }

  switch (chgsize)
  {
  	case 'incr':
    		newSize = startSize + 10;
    		break;

	case 'decr':
	   	newSize = startSize - 2;
	   	break;

	case 'reset':
		if (rs){
		   newSize = rs;
		} 
		else{
		   startSize = 14;
		}
    break;

  	default:
    		newSize = parseInt(ndeReadCookie("nde-textsize", true));
	    	if (!newSize)
    		{
  			newSize = startSize;
    		}
    		break;
  }

  if (newSize < 10){
    	newSize = 10;
  }

  newSize = 18;
	lineHeight = 1.2;
  

  var thisImgs = document.getElementsByTagName("SPAN");
  
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('SPAN')[idx].style.fontSize += newSize;
		document.getElementsByTagName('SPAN')[idx].style.lineHeight += lineHeight; 
  }
  

    var thisImgs = document.getElementsByTagName("table");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('table')[idx].style.fontSize += newSize;
		document.getElementsByTagName('table')[idx].style.lineHeight += lineHeight; 
  }
  
    var thisImgs = document.getElementsByTagName("TR");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('TR')[idx].style.fontSize += newSize;
		document.getElementsByTagName('TR')[idx].style.lineHeight += lineHeight; 
  }
  
  var thisImgs = document.getElementsByTagName("TD");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('TD')[idx].style.fontSize += newSize;
		document.getElementsByTagName('TD')[idx].style.lineHeight += lineHeight; 	
  }
  
  var thisImgs = document.getElementsByTagName("B");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('B')[idx].style.fontSize += newSize;
 		document.getElementsByTagName('B')[idx].style.lineHeight += lineHeight; 
  } 
  
  var thisImgs = document.getElementsByTagName("A");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('A')[idx].style.fontSize += newSize;
		document.getElementsByTagName('A')[idx].style.lineHeight += lineHeight; 
  }
  
  var thisImgs = document.getElementsByTagName("INPUT");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('INPUT')[idx].style.fontSize += newSize;
		document.getElementsByTagName('INPUT')[idx].style.lineHeight += lineHeight; 
  } 
  
  var thisImgs = document.getElementsByTagName("FONT");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('FONT')[idx].style.fontSize += newSize;
		document.getElementsByTagName('FONT')[idx].style.lineHeight += lineHeight; 
  } 
  
  var thisImgs = document.getElementsByTagName("IMG");
  for (var idx = 0; idx < thisImgs.length; idx++){
		document.getElementsByTagName('IMG')[idx].style.fontSize += newSize;
		document.getElementsByTagName('IMG')[idx].style.lineHeight += lineHeight; 
  } 
 
  ndeCreateCookie("nde-textsize", newSize, 365, true);
}


//------------------------ function that fetches the current font-size  ------------------------
function ndeGetDocTextSize() 
{
  if (!document.getElementsByTagName){
    return 0;
  }

  var size = 0;
  var body = document.getElementsByTagName('body')[0];
  
  if (body.style && body.style.fontSize)
  {
    size = body.style.fontSize;
  }
  else if (typeof(getComputedStyle) != 'undefined')
  {
    size = getComputedStyle(body,'').getPropertyValue('font-size');
  }
  else if (body.currentStyle)
  {
    size = body.currentStyle.fontSize;
  }
  return size;
}

//------------------------ function that sets the cookie  ------------------------
function ndeCreateCookie(name,value,days,useLang) 
{
  var langString = useLang ? ndeGetLang() : "";
  var cookie = name + langString + "=" + value + ";";

  if (days) 
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    cookie += " expires=" + date.toGMTString() + ";";
  }
  cookie += " path=/";

  document.cookie = cookie;
}

//------------------------ function that reads the cookie  ------------------------
function ndeReadCookie(name, useLang) 
{
  var langString = useLang ? ndeGetLang() : "";
  var nameEQ = name + langString + "=";
  var ca = document.cookie.split(';');

  for(var i = 0; i < ca.length; i++) 
  {
    var c = ca[i];
    while (c.charAt(0) == ' '){
      c = c.substring(1, c.length);
    }

    if (c.indexOf(nameEQ) == 0){
      return c.substring(nameEQ.length,c.length);
    }
  }
  return null;
}

//------------------------ function that checks the browser version  ------------------------
function ndeGetLang()
{
  var langString = "";

  if (document.documentElement){//IE?
    langString = document.documentElement.lang;
    if (langString != ""){
      langString = "-" + langString;
    }
  }  
  return langString;
}


/////////////////////////////////////////// section for publicationflow module ///////////////////////////////


imgout=new Image(15,15);
imgin=new Image(15,15);

imgout.src="pict/uitklapTekst_plus.png"; //---- only this line can be edited
imgin.src="pict/uitklapTekst_minus.png"; //---- only this line can be edited

//------------------------ function that switches expand collapse icons ------------------------
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}


//------------------------ show OR hide funtion depends on if element is shown or hidden ------------------------
function shoh(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}
	
//------------------------ Publicatie Flow Functions ------------------------

function rollback(URL)
{
	if (confirm("Weet u zeker dat u de aktie rollback op deze pagina wilt uitvoeren?\n\nEr wordt dan een kopie gemaakt van deze gearchiveerde pagina.\nDeze zal vervolgens het publicatie proces doorlopen.")) {
		document.location.href = URL;
	}	
	else
	{
		return false;	
	}
}
