function showsub(id) {
	if(document.getElementById(id)) { document.getElementById(id).style.display = 'block'; }	
}

function hidesub(id) {
	if(document.getElementById(id)) { document.getElementById(id).style.display = 'none'; }	
}

function swap(id) {
	var href = "a"+id+"";
	//if(document.getElementById(id)) { document.getElementById(id).style.backgroundImage = 'url(images/menu_sub_back_over2.jpg)'; }
	if(document.getElementById(href)) { document.getElementById(href).style.fontWeight = 'bold'; }
}

function swapback(id) {
	var href = "a"+id+"";
	//if(document.getElementById(id)) { document.getElementById(id).style.backgroundImage = 'url(images/menu_sub_back2.jpg)'; }	
	if(document.getElementById(href)) { document.getElementById(href).style.fontWeight = 'normal'; }
}

function swaph(id) {
	var href = "a"+id+"";
	if(document.getElementById(href)) { document.getElementById(href).style.color = '#ffbd2e'; }
}

function swaphback(id) {
	var href = "a"+id+"";
	if(document.getElementById(href)) { document.getElementById(href).style.color = '#3e3d8b'; }
}



function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
 
function getPageSize(){

	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) { 
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
 
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.scrollHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	} 
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){ pageHeight = windowHeight; } 
	else { pageHeight = yScroll; }
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){ pageWidth = windowWidth; } 
	else { pageWidth = xScroll; }
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}




function showinlog() { 
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	if(document.getElementById('inlog')) {	
		document.getElementById('inlog').style.display = "block"; 
	}
	if(document.getElementById('inlogback')) {	
		document.getElementById('inlogback').style.height = (arrayPageSize[1] + 'px');
		document.getElementById('inlogback').style.display = "block"; 
	}
}
function hideinlog() { 
	if(document.getElementById('inlog')) {	document.getElementById('inlog').style.display = "none"; }
	if(document.getElementById('inlogback')) {	document.getElementById('inlogback').style.display = "none"; }
}
function forgetpassword() {
	if(document.getElementById('inlog')) {	document.getElementById('inlog').style.display = "none"; }
	if(document.getElementById('forgetpassword')) {	document.getElementById('forgetpassword').style.display = "block"; }
}
function forgetpasswordhide() {
	if(document.getElementById('inlog')) {	document.getElementById('inlog').style.display = "block"; }
	if(document.getElementById('forgetpassword')) {	document.getElementById('forgetpassword').style.display = "none"; }
}
function forgetpasswordhide2() {
	if(document.getElementById('inlog')) {	document.getElementById('inlog').style.display = "block"; }
	if(document.getElementById('forgetpassword2')) {	document.getElementById('forgetpassword2').style.display = "none"; }
}

$(function(){
  
  
  	var hoogte = $(document).height();
	if(document.getElementById('lijn')) 	{ document.getElementById('lijn').style.height = hoogte + 'px'; }
  
	var maxHeight = 0;
	$(".contentkols").each(function(){
		if (maxHeight < $(this).height()) {maxHeight = $(this).height()}
	});
	$(".contentkols").each(function(){	$(this).height(maxHeight);	});
	
	
	$(".icontop").hover(
		function(){	$(this).prev().css("color", "#e4e4e1"); },
		function(){	$(this).prev().css("color", "#696768"); }
	);

	$(".roicontext").hover(
		function(){	$(this).css("color", "#e4e4e1"); },
		function(){	$(this).css("color", "#696768"); }
	);
	
	// Functie aanroepen via id in div, daarna doormiddel van hide sluiten //
	// this is de functie (knop) die je op dat moment aanroept //
	
	$('#closeaward').click(function(){
		$.get("http://www.rubitech.com/includes/displayaward.php",
			  function(data){ //alert(data);
			  });
		$('#award').hide();
		$(this).hide();
		
	});

	
	$('#search').click(function(e){
		if($("#search").val() == "_SEARCH") {
			$("#search").attr("value"," ");
		}
    });
	
	function dosearch() {
	
		if($('#search').val().length > 2) {
			$.get("includes/search.php", { search: $('#search').val() },
			function(data){
			 alert("Data Loaded: " + data);
			});
		}
	}
	
	$('#password').keydown(function(e){
        if (e.keyCode == 13) {
	
			$.get("http://www.rubitech.com/includes/checklogin.php", { gebruikersnaam: $('#gebruiker').val(), wachtwoord: $('#password').val() },
			function(data){
				if(data == "wel") { window.location="http://www.rubitech.com/rubitech/extranet/"; } 
				if(data == "niet" || data == "") { alert('Incorrect login!'); } 
			});
            return false;
        }
    });
	
	$('#logout').click(function(e){
      
			$.get("http://www.rubitech.com/includes/loguit.php",
			function(data){
				if(data == "wel") { window.location="http://www.rubitech.com/rubitech/"; } 
				if(data == "niet" || data == "") { alert('Logout failed!'); } 
			});
            return false;
       
    });
	
	
	$('#search').keydown(function(e){
        if (e.keyCode == 13) {
			//dosearch();
			$('#searchform').submit();
			return false;
        }
    });

	
	$('#forgetpasswordbtn').click(function(e){
		$.get("http://www.rubitech.com/includes/forgetpassword.php", { gebruikersnaam: $('#fggebruikersnaam').val() },
		function(data){
			if(data == "wel") { alert('A link to change your password has been sent to your emailaddress.'); forgetpasswordhide(); } 
			if(data == "niet" || data == "") { alert('An user with this username doesn\'t exist!'); } 
		});
	});

	
	$('#forgetpasswordbtn2').click(function(e){
		if($('#fgwachtwoord').val() == $('#fgwachtwoordconfirm').val() || $('#fgwachtwoord').val() == '' || $('#fgwachtwoordconfirm').val() == '') {
			$.get("http://www.rubitech.com/includes/forgetpassword.php", { keystring: $('#fgkeystring').val(), wachtwoord: $('#fgwachtwoord').val() },
			function(data){
				if(data == "wel") { alert('Your password has been changed. You can login with your new password now'); forgetpasswordhide2(); } 
				if(data == "niet" || data == "") { alert('Your new password don\'t fit the requirements'); } 
			});
		} else {
			alert('The passwords don\'t match.');
		}
	});

	
	$('#loginbutton').click(function(e){
		$.get("http://www.rubitech.com/includes/checklogin.php", { gebruikersnaam: $('#gebruiker').val(), wachtwoord: $('#password').val() },
		function(data){
			if(data == "wel") { window.location="http://www.rubitech.com/rubitech/extranet/"; } 
			if(data == "niet" || data == "") { alert('Incorrect login!'); } 
		});
	});
	

	$('#logoutbutton').click(function(e){
	
		var check = confirm("Weet u zeker dat u wilt uitloggen?");
		if(check == true) {	
			
			$.get("http://www.rubitech.com/includes/loguit.php", function(data){
				if(data == "wel") { window.location="http://www.rubitech.com/rubitech/"+p+"/"; } 
				if(data == "niet" || data == "") { alert('Logout failed!'); } 
			});
		
	
		}
	});

	
		//alert(hoogte);
		//alert(document.getElementById('lijn').style.height);
		
		var hoogte = $(document).height();
//		alert(hoogte);
		
		//var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
		//alert(hoogte);
		//alert(viewportHeight);
	//	var hoogte2 = $(window).height();
	//	if(hoogte < hoogte2) { hoogte = hoogte2; }
	//	else { hoogte = hoogte; }
		//$.getDocHeight = function(){
			var hoogte = Math.max(
				$(document).height(),
				$(window).height(),
				/* For opera: */
				document.documentElement.clientHeight
			);
			if($("#lijn")) { 
		//$("#lijn").html("&nbsp;");
		$("#lijn").height(hoogte);
		//document.getElementById('lijn').style.height = hoogte + 'px'; 
		}
		//	alert(hoogte);
		//};
			
		
		
});



function verlenglijn() {
		
	//alert( getDocHeight() );
	
	/*var htmlheight = document.body.parentNode.clientHeight; 
	var windowheight = window.innerheight; 
	if ( htmlheight < windowheight ) { var hoogte = windowheight; } 
	else { var hoogte = htmlheight; } 

//var hoogte = window.innerHeight ? window.innerHeight : document.body.clientHeight;
	if(document.getElementById('lijn')) 	{ document.getElementById('lijn').style.height = hoogte + 'px'; }
	*/
}

/*
function verlenglijn() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	if(document.getElementById('lijn')) 	{ document.getElementById('lijn').style.height = (arrayPageSize[1] + 'px'); }
}
*/

/*
function checklogin() {
	
	var gebruikersnaam = document.loginform.gebruikersnaam.value;
	var wachtwoord = document.loginform.wachtwoord.value;

	myRand=parseInt(Math.random()*99999999);
	myRanda=parseInt(Math.random()*999999999);
	http5.open("GET", "includes/checklogin.php?random="+myRand+myRanda+"&gebruikersnaam="+gebruikersnaam+"&wachtwoord="+wachtwoord+"", true); 
	http5.onreadystatechange = handleRefResponse5; 
	http5.send(null);

}

*/
function gethoogte() {
	
	var hoogte = document.getElementById('maincontent').offsetHeight;
	

	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
//	alert(maxhoogte);
//	var hoogtev = myHeight - maxhoogte;
		
//	if(hoogte < hoogtev) { 
		document.getElementById('lijn').style.height = ""+myHeight+"px";
//	}
}


function verleng() {
	
	var hoogte = document.getElementById('maincontent').offsetHeight;
	

	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
//	alert(maxhoogte);
	var hoogtev = myHeight - maxhoogte;
		
	if(hoogte < hoogtev) { 
		document.getElementById('maincontent').style.height = ""+hoogtev+"px";
		}
}

/*
function handleRefResponse5() { 
    if (http5.readyState == 4) { 
		if(http5.responseText == "wel") { window.location="http://localhost/werk/rubitech/extranet/"; } 
		if(http5.responseText == "niet") { alert('Onjuiste login!'); } 
	}
}

var http5 = getHTTPObject(); // We create the HTTP Object
*/
/*
function loguit() {
	
	var check = confirm("Weet u zeker dat u wilt uitloggen?");
		if(check == true) {	
		myRand=parseInt(Math.random()*99999999);
		myRanda=parseInt(Math.random()*999999999);
		http4.open("GET", "includes/loguit.php?random="+myRand+myRanda+"", true); 
		http4.onreadystatechange = handleRefResponse4; 
		http4.send(null);
		}
}

function handleRefResponse4() { 
    if (http4.readyState == 4) { 
		window.location="http://localhost/werk/rubitech/";	
	}	
}

var http4 = getHTTPObject(); // We create the HTTP Object
*/

function showback(waarde) { 
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	
	if(document.getElementById('back')) {	
		document.getElementById('back').style.height = (arrayPageSize[1] + 'px');
		document.getElementById('back').style.display = "block"; 
		document.getElementById('back').style.overflowY = "hidden";
	}
	if(document.getElementById('movie')) { 
	
		document.getElementById('movie').style.display = "block"; 
		myRand=parseInt(Math.random()*99999999);
		myRanda=parseInt(Math.random()*999999999);
		http.open("GET", "player.php?random="+myRand+myRanda+"&flvid="+waarde+"", true); 
		http.onreadystatechange = handleRefResponse; 
		http.send(null);
		
		
	}
	
}

function hideback() { 

	if(document.getElementById('back')) {	document.getElementById('back').style.display = "none"; }
	if(document.getElementById('movie')) {	document.getElementById('movie').style.visibility = "hidden"; }
}





function handleRefResponse() { 
    if (http.readyState == 4) { 
		document.getElementById('movieflv').innerHTML = http.responseText; 
		document.getElementById('movie').style.visibility = "visible"; 
	}						
}



function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
    xmlhttp = false;
    }
    }
    @else
    xmlhttp = false;
    @end @*/
    
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try { xmlhttp = new XMLHttpRequest(); } 
        catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}


var http = getHTTPObject(); // We create the HTTP Object


function toongegevens(veld) {

	// alle velden uitzetten
	if(document.getElementById('introductie')) { document.getElementById('introductie').style.display = "none"; }
	if(document.getElementById('afbeeldingen')) { document.getElementById('afbeeldingen').style.display = "none"; }
	if(document.getElementById('videos')) { document.getElementById('videos').style.display = "none"; }
	if(document.getElementById('publicaties')) { document.getElementById('publicaties').style.display = "none"; }
	if(document.getElementById('brochures')) { document.getElementById('brochures').style.display = "none"; }
	if(document.getElementById('presentaties')) { document.getElementById('presentaties').style.display = "none"; }
	if(document.getElementById('ontwerpbestanden')) { document.getElementById('ontwerpbestanden').style.display = "none"; }
	if(document.getElementById('projectdocumenten')) { document.getElementById('projectdocumenten').style.display = "none"; }
	if(document.getElementById('ontwerpen')) { document.getElementById('ontwerpen').style.display = "none"; }
	if(document.getElementById('offertes')) { document.getElementById('offertes').style.display = "none"; }
	if(document.getElementById('orderbevestigingen')) { document.getElementById('orderbevestigingen').style.display = "none"; }
	if(document.getElementById('facturen')) { document.getElementById('facturen').style.display = "none"; }
	if(document.getElementById('logboeken')) { document.getElementById('logboeken').style.display = "none"; }
	if(document.getElementById('certificaten')) { document.getElementById('certificaten').style.display = "none"; }
	if(document.getElementById('montagehandleidingen')) { document.getElementById('montagehandleidingen').style.display = "none"; }
	if(document.getElementById('onderhoudscontracten')) { document.getElementById('onderhoudscontracten').style.display = "none"; }
	if(document.getElementById('overige_documenten')) { document.getElementById('overige_documenten').style.display = "none"; }
	
	if(document.getElementById(veld)) { document.getElementById(veld).style.display = "block"; }
}
/*
function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

 $(document).ready(function(){
	mainmenu();
});
*/