/**************************************************

Print Functions 
i-Merge 2002

if you'd also would like to use this print function 
or have any remarks or suggestions, 
please contact us at info@i-merge.net

*******************************************************/

// verander deze variabelen indien nodig:
var siteRoot = ""; // afstand van js-mapje tot rootniveau (bv/ "http://domain/map1/map2/js" zou "/map1/map2" worden) mag leeg zijn ("") indien het op rootniveau staat
var printTemplate = defaultTemplate = "default"; // default template om te gebruiken (kan in principe om het even welke naam zijn, maar dit is wel het duidelijkste : )
// browser not compatible with function:
var txtBrowserNotCompatible = "Deze functie wordt niet ondersteund door uw browser.\nSelecteer het PRINT-commando in het browsermenu om deze pagina te printen"; 
// confirm selection or full page print:
var txtSelectionOnly = "Wilt u enkel de geselecteerde tekst afdrukken?\n\nDruk OK als u enkel selectie wilt afdrukken\nDruk Cancel als u volledige pagina wilt afdrukken\n\n"; 

// *****************$ actual script $*************************
var selectedText = ""; var windowObj=null; var printEntirePage = false; var onSameServer = false; // if page to be printed is on the same server...

function printContent(iPageID,sLangCode) { var temp = arguments.length;
if (temp>0) { for ( var i=0; i<arguments.length; i++) { switch( typeof(arguments[i]) ){ case "object": windowObj = arguments[i]; break; 	case "string": printTemplate = arguments[i]; break;	case "boolean": printEntirePage = arguments[i]; break; }}} 		
if ((isNav4 && !isMac) || isOpera ) { 	printSimple(); } else if (isDOM) { var txt=""; var tempObj = (windowObj!=null) ? windowObj : window; onSameServer = (tempObj.location.hostname.toLowerCase() == top.window.location.hostname.toLowerCase());
if (onSameServer) {
if (tempObj && document.getSelection) { txt = tempObj.document.getSelection(); } //NS4+
else if (tempObj && document.selection) { txt = tempObj.document.selection.createRange().text; } // IE4+			
if (txt!="") { if ( confirm(txtSelectionOnly) ) { txt = txt.replace(new RegExp('<', 'g'),"&lt;"); txt = txt.replace(new RegExp('>', 'g'),"&gt;"); txt = txt.replace(new RegExp('\\n', 'g'),"<p></p>"); txt = txt.replace(new RegExp('\\t', 'g'),"&nbsp;&nbsp;&nbsp;&nbsp;"); selectedText = txt;}}
popup(siteRoot+"/js/print/templates/default/frameset_print.asp?iPageID=" + iPageID +"&sLangCode="+ sLangCode,"printwindow");
printTemplate = defaultTemplate; // restore to default template
}} else { alert (txtBrowserNotCompatible); }} 
function printSimple() { if ((isNav4 && !isMac) || isOpera || isDOM ) { if (windowObj!=null) { windowObj.print(); } else { window.print(); }	} else { alert (txtBrowserNotCompatible); }}
function popup(url,name,winoptions) {
// opens a new window with url 'url'
// to open windows in top of each other give them a different name 
// mostly used as subfunction of function gotoURL()
if (!name) name = "newWin";
if (!winoptions) {
var pWidth= 750; pHeight=550; // fixed dimensions
w = (window.screen.availWidth-pWidth)/2; h = (window.screen.availHeight-pHeight)/2; // center onscreen:
newWin = window.open(url,name,"scrollbars=yes,resizable=yes,width="+pWidth+",height="+pHeight+",screenX="+w+",screenY="+h+",top="+h+",left="+w+"'");
} else { newWin = window.open(url,name,winoptions); } 
if (!newWin.opener) newWin.opener = self; // new
if (!isIE4) setTimeout("newWin.focus()",250); // put focus on new window (IE4 gives an 'acces denied'-error)
}
