﻿var ROOTDIR = "/";

function printPage(element, title, width, height)
{
    var subpage = document.getElementById(element);
    
    if(subpage)
    {
        var body = subpage.innerHTML;

        var sStart = "";
        sStart += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
        sStart += "<html>\n";
        sStart += " <head>\n";
        sStart += " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
        
        sStart += " <link rel=\"stylesheet\" type=\"text/css\" href=\""+ ROOTDIR +"Customer/Styles/Reset.css\"/>\n";
        sStart += " <link rel=\"stylesheet\" type=\"text/css\" href=\""+ ROOTDIR +"Customer/Styles/Screen.css\"/>\n";
        sStart += " <!--[if lte IE 6]>\n";
        sStart += " <link rel=\"stylesheet\" type=\"text/css\" href=\""+ ROOTDIR +"Customer/Styles/BrostromIE6.css\"/>\n";
        sStart += " <![endif]-->\n";
        sStart += " <!--[if IE 7]>\n";
        sStart += " <link rel=\"stylesheet\" type=\"text/css\" href=\""+ ROOTDIR +"Customer/Styles/BrostromIE7.css\"/>\n";
        sStart += " <![endif]-->\n";
        sStart += " <title>Broström - " + title + "</title>\n";
        sStart += " <style>.IndexArticlePrint{display: none} .IndexArticleHeader { float:none; page-break-before: avoid; } .IndexArticleBorder { float:none; } .IndexArticleIngress { float:none; } .IndexArticleContent { float:none; }</style>";
        sStart += " </head>\n";
        sStart += " <body id=\"printbody\" onload='window.print();'>\n";

        var sStop = "";
        sStop += " </body>\n";
        sStop += "</html>\n";

        var w = window.open('','printWin','width=' + width + ',height=' + height + ',scrollbars=yes');
        wdoc = w.document;
        wdoc.open();
        wdoc.write(sStart);
        wdoc.write(body);
        wdoc.writeln(sStop);
        wdoc.close();
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	//alert(id);
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
} 