// Browser information
var browser;
var version;
var os;
var isNetscape = (navigator.appName.indexOf('Netscape') != -1);

browser = navigator.appName;
version = navigator.appVersion;
os = navigator.platform;

// random nummer nodig voor Adlink
var adlink_randomnumber=Math.floor(Math.random()*10000000000);

// functie voor de klok op de home pagina 
function clock(pTaal) {
var t = new Date();
var h = t.getHours();
var m = t.getMinutes();
var s = t.getSeconds();
var units = new String("");
var hours = t.getHours();
var min = t.getMinutes();
var sec = t.getSeconds();
if (hours < 10)
hours = " " + hours;
if (min < 10)
min = "0" + min;
if (sec < 10)
sec = "0" + sec;
document.clock.h.value = hours;
document.clock.m.value = min;
document.clock.s.value = sec;
//alert (pTaal);
if (pTaal == "FR") {
document.clock.time.value = hours + "h" + min + ":" + sec + " " ;
window.setTimeout("clock('FR')", 900);
}
else {
document.clock.time.value = hours + "u" + min + ":" + sec + " " ;
window.setTimeout("clock('NL')", 900);
}
//+ status;

}

// functie die door hlnId() en door ShowBIMPopup() gebruikt wordt
function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    } 
  }
  return null;
}

// functie die door hlnId() en door ShowBIMPopup() gebruikt wordt
function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

// functie om deze pagina te bookmarken : Enkel Internet Explorer
function addbookmark(pTaal)
{
  if (pTaal == "FR") {
    if (document.all)
        window.external.AddFavorite('http://www.7s7.be', '7 sur 7');
  }
  else {
    if (document.all)
        window.external.AddFavorite('http://www.hln.be', 'Hat Laatste Nieuws');
  }
}

// functie om venster te openen : TE VERVANGEN DOOR openwindow
function openVenster(theURL,winName,features)
{
window.open(theURL,"_blank",features);
}


// Macromedia functie : TE VERVANGEN DOOR openwindow
function getSCSO() {
if ((typeof scsoGuest != "boolean") || scsoGuest) { return ""; }
else if (self.scsoName && self.scsoEMail && self.scsoAge && self.scsoGender && self.scsoCountryID && self.scsoKey) { return "&scsoGuest=false" + "&scsoN=" + escape(scsoName) + "&scsoE=" + escape(scsoEMail) + "&scsoA=" + escape(scsoAge) + "&scsoG=" + escape(scsoGender) + "&scsoI=" + escape(scsoCountryID) + "&scsoK=" + escape(scsoKey); }
else { return ""; }
}
// Macromedia functie : TE VERVANGEN DOOR openwindow
function popUp(popupURL)
{
width = 700; height = 550; leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
if (screen.height && (screen.height <= 600)) { topPosition = 0; } else { topPosition = (screen.height) ? (screen.height-height)/2 : 0; }
var settings='width='+width+',height='+height+',left='+leftPosition+',top='+topPosition+'toolbar=0,location=0,directories=0,menubar=0,scrollbar=0,resizable=0,status=0';
var popup=window.open(popupURL+getSCSO(), 'gamepopup', settings); popup.focus();
}
// Macromedia functie TE VERVANGEN DOOR openwindow
function hsPopUp(popupURL)
{
width = 445; height = 440; leftPosition = (screen.width) ? (screen.width-width)/2 : 0; topPosition = (screen.height) ? (screen.height-height)/2 : 0;
var settings='width='+width+',height='+height+',left='+leftPosition+',top='+topPosition+'toolbar=0,location=0,directories=0,menubar=0,scrollbar=0,resizable=0,status=0';
var hspopup=window.open(popupURL+getSCSO(), 'exthspopup', settings);
hspopup.focus();
}

// functie om SMS in popup te openen
function showSMSDienst(pDienst, pReeks, pPage, pCat) {
 openwindow("../../mbl/pag/hln_mbl_dienstDetail.jsp?p_smsdienst="+pDienst+"&p_reeks="+pReeks+"&p_page="+pPage+"&p_cat="+pCat,500,420);
}

// functie Macromedia : OVERBODIG?
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// functie Macromedia : OVERBODIG?
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// functie Macromedia : OVERBODIG?
function MM_preloadImages() { //v3.0
  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];}}
}

// functie Macromedia : OVERBODIG?
function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

// functie Macromedia : OVERBODIG?
function MM_swapImage() { //v3.0
  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];}
}

// functie die gebruikt wordt in de popups van SMS
function changeParentHREF(myURL) { 
  if(!window.opener.closed && window.opener != null) {
    //window is open      
    window.opener.location.href=myURL;  
		}  
  else {
    // window is not open }      
    newWindow=open(myURL,'harry','');     
		}
} 


// iFrame calculate height 2e functie als de eerste niet gelukt is
// enkel bedoeld voor explorer 5 en opera
function  calcHeightForSpecialBrowsers() {
	if(browser.indexOf('Opera') != -1) {
	 document.getElementById('hln_poll').style.height = 295;
	}
	if(browser.indexOf('Internet Explorer') != -1) {
	  if(version.indexOf('MSIE 5.') != -1) {
    document.getElementById('hln_poll').style.height = 295;
		 }
	}

}

// iFrame calculate height
function calcHeight(srcId,srcBody) {
    if(isNetscape) {
				  document.getElementById('hln_poll').style.height = document.getElementById('hln_poll').contentDocument.body.scrollHeight;
				}
				else {
      var oBody = srcBody;
      var oFrame      =       document.all(srcId);
      oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);
    } 
}    

// functie die wordt opgeroepen onload om de hoogte te fixen
function go() {

var agt=navigator.userAgent.toLowerCase(); 
  if ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) )  {
                
                 if (agt.indexOf("msie") != -1) {
                          // alert('explorer');
                        divRechts = document.getElementById('hlnFrameRechts'); 
                                                divRechts.style.marginRight = 4;
                        }                      
                }
}

// functie die de window-hoogte berekent
function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
	return windowHeight;
}

// functie die de hoogte van hlnFrameKanaal wijzigt indien de pagina kleiner is dan de window-height
function setContentHeight() {
  if(document.getElementById) {
		  var windowHeight = getWindowHeight();

				if(windowHeight > 0) {
				  var topElement = document.getElementById('hlnTopFrames');
						var topHeight = topElement.offsetHeight;
				  var middenElement = document.getElementById('hlnFrame');
						var middenHeight = middenElement.offsetHeight;
						var totalHlnHeight = topHeight + middenHeight;

						if(windowHeight-totalHlnHeight>0) {
							var middenFrameElement = document.getElementById('hlnFrameKanaal');
       middenFrameElement.style.height = windowHeight + 'px';							
						}
				}
				
		}
}  

// parameters voor upSize en downSize
var max = 20 
var min = 8 

// functie om in topartikel de fontsize te verhogen
function upSize() { 
size = parseInt(document.getElementById("artContent").style.fontSize) 
if (size != max) { 
size = size + 2 
} 
document.getElementById("artContent").style.fontSize = size + "pt" 
document.getElementById("artContent").style.lineHeight = size+2 + "pt" 
} 

// functie om in topartikel de fontsize te verkleinen
function downSize() { 
size = parseInt(document.getElementById("artContent").style.fontSize) 
if (size != min) { 
size = size - 2 
} 
document.getElementById("artContent").style.fontSize = size + "pt" 
document.getElementById("artContent").style.lineHeight = size+2 + "pt" 
} 

/* WIB */
function dummyFunc() { var i = 0;}

function clearTimeOuts() {
 window.clearTimeout(links);
 window.clearTimeout(rechts);
}

function movePics(direction, p_speed) {
 speed=p_speed;
 if (direction == "L") {
  goLeft();
 }

 if (direction == "R") {
  goRight();
 }
}

function goRight() {
 clearTimeOuts();
 if (currPos < 0) {
  currPos = parseInt(document.getElementById("fotos").style.left);
  currPos += 3;
  document.getElementById("fotos").style.left = currPos;
  rechts=window.setTimeout("goRight()",speed) //ex
 }
 else {
  clearTimeOuts();
 }
}

function goLeft() {
 clearTimeOuts();
 if (currPos > -totalwidth) {
  currPos = parseInt(document.getElementById("fotos").style.left);
  currPos -= 3;
  document.getElementById("fotos").style.left = currPos;
  links=window.setTimeout("goLeft()",speed) //ex
 }
 else {
  clearTimeOuts();
 }
}

/*CHARACTERS TELLER VOOR TEXT AREA*/
function textCounter( pTaal, field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
	if (pTaal == "FR") {
    alert( 'Vous avez dépassé le maximum de caractères' );
    }
	else {
	alert( 'Je hebt het maximum aantal karakters overschreden' );
	}
	return false;
  }
  else
  {
    countfield.value = maxlimit - field.value.length;
  }
}

// functions for buttons
function relBtn(o,size) { o.className = "btn"+size;  }
function pressBtn(o,size) {	o.className = "btn"+size+"On"; }

// Function voor HLN-id (Cookie lezen)
function hlnid() {
var voornaam = getCookie("pVoornaam");
var naam = getCookie("pNaam");

if (voornaam==null && naam==null) {
 document.write('<div class="smallTxt" style="font-weight:bold;"><a href="../../alg/pag/hln_index.jsp?p_page=sso&p_cat=registreer&pMode=full">aanmelden</a>&nbsp;</div>');
  }
else {
 document.write('<div class="smallTxt">Welkom <b><a href="../../alg/pag/hln_index.jsp?p_page=sso&p_cat=profiel">' + voornaam + ' ' + naam + '</a></b>&nbsp;</div>');
 }
}