$(document).ready(function() {
    $("#print-button-container").css('display', 'block');
});

function OpenInNewWindow(url) {
    // Change "_blank" to something like "newWindow" to load all links in the same new window
    var newWindow = window.open(url);
    newWindow.focus();
    return false;
}
function printContent(printPageUrl) {
	var pW = openWindow(printPageUrl, 'print', 650, 550, 1, 1, 1);
	pW.focus();
}
function toggleElement(id) {
    if ($(id).is(":visible")) {
        $(id).hide();
    }
    else {
        $(id).show();
    }

}
function PrintPreview() {
    var w = 1000; // <-- dit is een vaste waarde in de print.css van RDW deze is overgenomen
    var h = 768; // <-- TODO: dit mogelijk dynamisch doen?

    wleft = (screen.width - w) / 2;
    wtop = (screen.height - h) / 2;

    if (wleft < 0) {
        w = screen.width;
        wleft = 0;
    }
    if (wtop < 0) {
        h = screen.height;
        wtop = 0;
    }
    var printpreview = window.open('', 'PrintPreview', 'width=' + w + ',height=' + h + ',left=' + wleft + ",top=" + wtop);
    var newHtml = $("html").html().replace(/media=(?:"print"|'print'|print)/g, "");

    printpreview.document.open();
    printpreview.document.write(newHtml);
    printpreview.document.close();
    printpreview.print();
    //$("html").html(oldHtml);

    return false;
}

// ----------------------------------------  tabs Rdw  nav ------------------------------//
	
	
function topheaderHover(id, baseSrc, tabHover) {
	document.getElementById(id).src = baseSrc + 'sel_' + tabHover + '.gif';
}

function printHover(baseSrc, tabHover) {
	document.getElementById('printHeader').src = baseSrc + tabHover + '.gif';
}


function swapImage(id, id2) {
	document.getElementById(id).src = "/media/nav/" + id2 + ".gif";
}

function newPage(url){
	if(url!="niets"){
		document.location.href = url;
		return false;
		}		
}

function newFacts(url){
	if(url!=""){
		textFrame.location.href = url;
		return false;
		}		
}

var myUitlegWindow;

function OpenInfoPopup( inUrl, inWidth, inHeight )
{

	if (myUitlegWindow)
	{
		myUitlegWindow.close()
	}
	
	maxWidth = (inWidth > 330 ? inWidth : 330 )
	
    if (window.screen) 
    {
        maxResX = parseInt(window.screen.availWidth);
        maxResY = parseInt(window.screen.availHeight);
        emptySpace = 50;
        
        myLeft = maxResX - maxWidth - emptySpace;
        myTop =  emptySpace;        
    }
    else
    {
		maxResY = 600;
    }

    maxHeight = (inHeight < maxResY ? inHeight : maxResY);
    maxWidth = (inWidth < 424 ? inWidth : 424 )
    
    myUitlegWindow = window.open( inUrl, 
								  "RdwInfoPopup", 
		                          "channelmode=no, directories=no, fullscreen=no," +
                                  "left=" + myLeft + "," + 
                                  "resizable=no, scrollbars=no," + 
                                  "top=" + myTop + "," +
                                  "menubar=no, status=no, titlebar=no, toolbar=no," + 
                                  "height=" + inHeight + ",width=" + maxWidth );                                  
	myUitlegWindow.focus();
}
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

