function Ticker(name, id, shiftBy, interval) {
  this.name     = name;
  this.id       = id;
  this.shiftBy  = shiftBy ? shiftBy : 1;
  this.interval = interval ? interval : 100;
  this.runId	= null;
  this.div = document.getElementById(id);
  var node = this.div.firstChild;
  var next;

  while (node) {
    next = node.nextSibling;
    if (node.nodeType == 3)
      this.div.removeChild(node);
    node = next;
  }

  this.left = 0;
  this.shiftLeftAt = this.div.firstChild.offsetWidth;
  this.div.style.height	= this.div.firstChild.offsetHeight;
  this.div.style.width = 2 * screen.availWidth;
  this.div.style.visibility = 'visible';
}

function startTicker() {
  this.stop();
  this.left -= this.shiftBy;

  if (this.left <= -this.shiftLeftAt) {
    this.left = 0;
    this.div.appendChild(this.div.firstChild);
    this.shiftLeftAt = this.div.firstChild.offsetWidth;
  }

  this.div.style.left = (this.left + 'px');
  this.runId = setTimeout(this.name + '.start()', this.interval);
}

function stopTicker() {
  if (this.runId)
    clearTimeout(this.runId);

  this.runId = null;
}

function changeTickerInterval(newinterval) {

  if (typeof(newinterval) == 'string')
    newinterval =  parseInt('0' + newinterval, 10);

  if (typeof(newinterval) == 'number' && newinterval > 0)
    this.interval = newinterval;

    this.stop();
    this.start();
}

/* Prototypes for Ticker */
Ticker.prototype.start = startTicker;
Ticker.prototype.stop = stopTicker;
Ticker.prototype.changeInterval = changeTickerInterval;

var ticker = null;

function setTickerSpeed() {
	ticker.changeInterval(document.forms.frmTickerSpeed.speed.value);
}

function startticker() {
	ticker = new Ticker('ticker', 'tickerID', 1, document.forms.frmTickerSpeed.speed.value);
	ticker.start();
}
// -->
function doRollOver(whatItem) {
	if (whatItem=='') {
		document.getElementById('rollovertekst').innerHTML='';
		document.getElementById('rollovertekst').style.visibility='hidden';
	} else if (whatItem=='quickscan') {
		document.getElementById('rollovertekst').style.visibility='visible';
		document.getElementById('rollovertekst').innerHTML='Test snel wat jouw mogelijkheden bij de marine zijn';
	} else if (whatItem=='filmpje') {
		document.getElementById('rollovertekst').style.visibility='visible';
		document.getElementById('rollovertekst').innerHTML='De marine in 60 seconden';
	} else if (whatItem=='hoogte') {
		document.getElementById('rollovertekst').style.visibility='visible';
		document.getElementById('rollovertekst').innerHTML='Laat hier je gegevens achter en wij houden je op de hoogte van alles wat er gebeurt bij de marine';
	}
}

function popUP(url) {
	//alert('testing 1,2,3');
	var width=420;
	var height=480;
    var look = "toolbar=no,menubar=no,location=no,status=no,scrollbars=auto,resizable=yes,height=" + height + ",width=" + width + ",top=15,left=15";        
	window.open (url,'',look);
}

function setVar(totalIDs,formName) {
	var j=selectbox=0;
	//alert(formName.elements.length);
	for(var i = 0; i < formName.elements.length; i++){
		if (formName.elements[i].type.toLowerCase() == 'radio') {
			if(formName.elements[i].checked == true) {
				j++;
			}
		}
	}

	if (j>=totalIDs) {
		formName.theSubmitBtn.disabled=false;
	} else {
		formName.theSubmitBtn.disabled=true;
	}	
	
}

function setSelect(totalIDs,formName) {
	//alert(formName.elements.length);

	var j=selectbox=0;
	
	for(var i = 0; i < formName.elements.length; i++){
        if ((formName.elements[i].name.indexOf('opleidingID') > -1)) {
			selectbox = formName.elements[i].options[formName.elements[i].selectedIndex].value + ' ';
        }		
	}

	//if (selectbox>0) {
		formName.submit()
	//} else {
		//alert('Je moet een opleiding kiezen');
		//return false;
	//}		
}

function clearForm(daForm) {
	if (daForm == 'sendafriend') {
		for(var i = 0; i < document.sendAFriendForm.elements.length; i++){
			//alert("Clearing number "+1);
			if (document.sendAFriendForm.elements[i].type.toLowerCase() == 'text') {
				document.sendAFriendForm.elements[i].value='';
			}
		}
	} else {
		for(var i = 0; i < daForm.elements.length; i++){
			if (daForm.elements[i].type.toLowerCase() == 'text') {
				daForm.elements[i].value='';
			}
		}	
	}
}

function alternate(tableID){
	for(i=0;i<=10;i++) {
		id =tableID+'_'+i;
		alertnateIT(id);
	}
}

function alertnateIT(id) {
	if(document.getElementsByTagName){ 
		var table = document.getElementById(id); 
		if (table) {
			//alert('HUH voor '+id);	
			var rows = table.getElementsByTagName("tr");  
			for(j = 0; j < rows.length; j++){          
				//manipulate rows
				if(j % 2 == 0){
					rows[j].className = "odd";
				} else {
					rows[j].className = "even";
				}      
			}
		}	
	}
}

function toggle( targetId ){ 
	if (document.getElementById){ 
		target = document.getElementById( targetId ); 
		if (target.style.display == "none"){ 
			target.style.display = ""; 
		} else { 
			target.style.display = "none"; 
		} 
	} 
} 

function showErrorInputs(id) {
	var inputFormElement = document.getElementById(id);
	if (inputFormElement) {
		inputFormElement.className = 'formError';
	}
}

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];}}
}

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;
}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

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];}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

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;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}

function addItem(){
        sNewItem = new Option(document.contentorder.lijst.options[document.contentorder.lijst.selectedIndex].text,document.contentorder.lijst.options[document.contentorder.lijst.selectedIndex].value);
        document.contentorder.resultaat.add(sNewItem);
        Sobj = document.contentorder.lijst.options[document.contentorder.lijst.selectedIndex].value;
        //alert(Sobj);
        MM_changeProp(Sobj,'','value',document.contentorder.Counter.value,'INPUT/TEXT');
        document.contentorder.Counter.value = eval(document.contentorder.Counter.value)+1;
        for (var i = 0; i<document.contentorder.elements.length; i++) {
                if ((document.contentorder.elements[i].name == Sobj)) {
                        document.contentorder.elements[i].value = document.contentorder.Counter.value;
                }
        }
}

function Verplaats() {
        if(eval(document.contentorder.lijst.selectedIndex)==-1) {
                alert('You have to select something first!')
        } else {
                addItem();
                document.contentorder.lijst.remove(document.contentorder.lijst.selectedIndex);
        }
}

function remItem(){
        var Teller,Label,Inhoud;
        Teller = eval(document.contentorder.Counter.value)-1
        Label = document.contentorder.resultaat.options[Teller].text;
        Inhoud = document.contentorder.resultaat.options[Teller].value;
        sNewItem = new Option(Label,Inhoud);
        document.contentorder.lijst.add(sNewItem);
        document.contentorder.Counter.value = Teller;
        //document.contentorder..value = document.contentorder.Counter.value;
}

function Verplaats_rev() {
        Teller = eval(document.contentorder.Counter.value)-1
    if(eval(document.contentorder.Counter.value != 0)){ 
                remItem();
        document.contentorder.resultaat.remove(Teller);
        }
}
//-->

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;
}

function fixWindowHeight(contentDiv,backgroundDiv) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			if (document.getElementById(contentDiv)) {
				var contentHeight = document.getElementById(contentDiv).innerHeight+200;	
				if (document.getElementById('footer')) {
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;				
					if (windowHeight - (contentHeight + footerHeight) < 0) {
						document.getElementById(backgroundDiv).style.height=contentHeight+20 + 'px';			
					} else {
						document.getElementById(backgroundDiv).style.height=windowHeight-footerHeight-20 + 'px';			
					}					
				} else {
					//alert(contentHeight);
					document.getElementById(backgroundDiv).style.height=contentHeight+200 + 'px';				
				}
			} else {
				//alert(contentDiv +' bestaat niet');	
			}
		}
	}
}



//-->
