///////////////////////////////////////////////////////////////
var popup;
////////////////////////
var style = "";

style += "<style>";
style += "body, div, img, h1 {padding:0px; margin:0px;}";
style += "body {min-width:600px; background-position:center; background-repeat:repeat-y; background-color:#ffffff; font-family:Arial, Helvetica, sans-serif; font-size:14px; margin-left:10px;}";
style += "h1 {font-size:18px; font-weight:bold;}";
style += ".main {width:600px; cursor:default;}";
style += "</style>";
////////////////////////
///////////////////////////////////////////////////////////////
function printTextPage(pWindowTitle, pLink, pPageTitle, pText) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "</div>";
	html += "<br/><br/>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printEyeGuidePage(pWindowTitle, pLink, pPageTitle, pText, pFaceTypes) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "<br/><br/><br/>";
	
	html += "<table style='font-family:Arial, Helvetica, sans-serif; font-size:14px;'>";
	for(var i = 0; i < pFaceTypes.length; i++) {	
		html += "<tr>";
		html += "<td colspan=2><br/><b>" + pFaceTypes[i].title + "</b></td>";
		html += "</tr>";
		html += "<tr>";
		html += "<td>";
		html += "<img src='http://www.obos.be/img/eyeguide/" + pFaceTypes[i].image + "' width='117' height='147'/>";
		html += "</td>";
		html += "<td style='vertical-align:top;'>";
		html += pFaceTypes[i].desc;
		html += "</td>";
		html += "</tr>";
		/*
		html += "<div class='container' style='clear:both; float:left;'>";
		html += "<div class='eyeguide' style='float:left; width:460px;'><b>" + pFaceTypes[i].title + "</b></div>";
		html += "<br/>";
		html += "<div class='eyeguideImage' style='float:left; width:120px; padding-bottom:20px;'>";
		html += "<img src='http://www.obos.be/img/eyeguide/" + pFaceTypes[i].image + "' width='117' height='147'/></div>";
		html += "<div class='eyeguide' style='float:left; width:460px;'>" + pFaceTypes[i].desc + "</div>";
		html += "<div>";
		*/
	}
	html += "</table>";
	
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printCatalogPage(pWindowTitle, pLink, pPageTitle, pText, pImage, pNameLabel, pName, pBrandLabel, pBrand, pColorLabel, pColors) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/>";
	html += "<img class='product' src='http://www.obos.be/img/catalog/full/" + pImage + "' width='460' height='260' alt='image' />";
	html += "<br/><br/>";
	if(pName != null && pName != "NULL" && pName != "") {
		html += "<span class='label'>" + pNameLabel.toUpperCase() + "</span>&nbsp;" + pName;
	}
	html += "<br/>";
	html += "<span class='label'>" + pBrandLabel.toUpperCase() + "</span>&nbsp;" + pBrand;
	html += "<br/>";
	html += "<span style='float:left; margin-right:10px;' class='label'>" + pColorLabel.toUpperCase() + "</span>&nbsp;";
	
	html += "<span>";
	for (var i = 0; i < pColors.length; i++) {
		if(pColors[i] == 0) {
			pColors[i] = "000000";
		}
		html += "<div style='width:10px; height:10px; float:left; margin-right:5px; margin-top:1px; border-style:solid; border-width:1px; border-color:#999999; background-color:#";
		html += pColors[i] + ";'></div>";
	}
	html += "</span>";
	html += "<br/><br/>";
	html += pText;
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printRevolutionPage(pWindowTitle, pLink, pPageTitle, pText, pImage) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "<br/><br/>";
	html += "<img src='http://www.obos.be/" + pImage + "' width='598' height='385' />";	
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printLensAdvantagePage(pWindowTitle, pLink, pPageTitle, pText, pAdvantages) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "<br/><br/>";
	
	for(var i = 0; i < pAdvantages.length; i++) {
		html += "<b>" + pAdvantages[i].title.toUpperCase() + "</b><br/>";
		html += pAdvantages[i].desc + "<br/><br/>";
	}
	
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printLensPage(pWindowTitle, pLink, pPageTitle, pText, pLenses) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "<br/><br/>";

	for(var i = 0; i < pLenses.length; i++) {		
		html += "<div style='clear:both; width:590px;'>";
		html += "<div style='float:left; margin-right:10px; width:120px;'>";
		html += "<img src='" + pLenses[i].image + "' width='115' height='75' /></div>";
		html += "<div style='float:left; width:460px;'>";
		html += "<div>" + pLenses[i].type + "</div>";
		html += "<div>" + pLenses[i].material + "</div>";
		html += "<div>" + pLenses[i].supplier + "</div>";
		html += "<div>" + pLenses[i].price + "</div><br/>";
		html += "<div>" + pLenses[i].feature + "</div><br/>";
		html += "<div>" + pLenses[i].ideal + "</div><br/>";
		html += "<div>" + pLenses[i].fluid + "</div><br/>";
		html += "<br/><br/></div>";
		html += "</div>";
	}
	
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printViewPage(pWindowTitle, pLink, pPageTitle, pDeviations) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	
	for(var i = 0; i < pDeviations.length; i++) {
		html += "<b>" + pDeviations[i].title.toUpperCase() + "</b><br/>";
		html += pDeviations[i].desc;
		html += "<br/><br/>";
	}

	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printPublicationPage(pWindowTitle, pLink, pPageTitle, pText, pImages) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "<br/><br/>";

	for(var i = 0; i < pImages.length; i++) {
		html += "<img src='" + pImages[i].image + "' width='100' height='130' /><br/>";
		html += pImages[i].desc;
		html += "<br/><br/>";
	}

	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printOpticianList(pWindowTitle, pLink, pPageTitle, pOpticians) {	
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/>";
	html += "<table style='font-family:Arial, Helvetica, sans-serif; font-size:14px; width:590px;'>";
	
	for(var i = 0; i < pOpticians.length; i++) {
    	html += "<tr>";
		html += "<td colspan='2' style='font-weight:bold; border-top-style:solid; border-top-color:#000000; border-width:1px;'>";
		html += "<br/>";
		html += (i + 1) + ". " + pOpticians[i].name;
		html += "</td>";
		html += "</tr>";
		
		html += "<tr>";
		html +=	"<td style='vertical-align:top; width:160px;'>";
		html += "<img src='" + pOpticians[i].image + "' width='150' height='100' />";
		html += "<br/>";
		html += pOpticians[i].desc + "<br/><br/>";
		html += "</td>";
		html += "<td style='padding-bottom:15px;'>";
		html += pOpticians[i].address + "<br/><br/>";
		html += "t. " + pOpticians[i].telephone + "<br/><br/>";
		
		if(pOpticians[i].fax != "") {
			html += "f. " + pOpticians[i].fax + "<br/><br/>";
		}
		
		html += pOpticians[i].hours + "<br/><br/>";
		
		if(pOpticians[i].website != "") {
			html += pOpticians[i].website + "<br/><br/>";
		}
		
		if(pOpticians[i].email != "") {
			html += pOpticians[i].email;
		}	
		
		html += "</td>";
		html += "</tr>";
	}
	
	html += "</table>";
	html += "<br/><br/>";
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printCustomPage(pWindowTitle, pLink, pPageTitle, pText, pImages, pLogo) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";
	html += pText;
	html += "<br/><br/>";

	for(var i = 0; i < pImages.length; i++) {
		html += "<img src='" + pImages[i].image + "' width='230' height='160' /><br/><br/>";
	}
	
	html += "<br/>";
	if(pLogo != "") {	
		html += "<img src='" + pLogo + "' /><br/>";
	}
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printAboutPage(pWindowTitle, pLink, pPageTitle, pImages, pPersons) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";

	for(var i = 0; i < pImages.length; i++) {
		html += "<img src='" + pImages[i].image + "' width='325' height='200' /><br/>";
		html += pImages[i].desc + "<br/><br/>";
	}
	
	html += "<br/>";
	for(var j = 0; j < pPersons.length; j++) {
		html += "<img src='" + pPersons[j].image + "' width='60' height='80' /><br/>";
		html += pPersons[j].name + "<br/>";
		html += pPersons[j].desc + "<br/><br/>";
	}
	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function printActionsPage(pWindowTitle, pLink, pPageTitle, pActions) {
	var html = "";
	
	html += "<html>";
	html += createHeader(pWindowTitle);	
	html += "<body>";
	html += "<div class='main'>";
	html += "<br/>";
	html += pLink;
	html += "<br/><br/>";
	html += "<h1>" + pPageTitle + "</h1>";
	html += "<br/><br/>";

	for(var i = 0; i < pActions.length; i++) {
		html += "<table style='border-style:dashed; border-width:1px; border-color:#999999; font-size:14px; width:580px;'>";
		html += "<tr>";
		html += "<td colspan='2' style='border-bottom-style:dashed; border-bottom-width:1px; border-bottom-color:#999999;'>";
		html += "<b>" + pActions[i].title + "</b>&nbsp;&nbsp;<span style='color:#666666;'>" + pActions[i].date + "</span>";
		html += "</td>";
		html += "</tr><tr>";
		html += "<td style='vertical-align:top;'><img src='" + pActions[i].image + "' width='100' height='120' /></td>";
		html += "<td style='vertical-align:top;'>" + pActions[i].desc + "<br/><small>" + pActions[i].note + "</small></td>";
		html += "</tr>";
		html += "</table>";
		html += "<br/><br/>";
	}

	html += "</div>";
	html += "</body></html>";
	
	printPage(html);
}
///////////////////////////////////////////////////////////////
function createHeader(pTitle) {
	return "<head><title>" + pTitle + "</title>" + style + "</head>";
}
///////////////////////////////////////////////////////////////
function printPage(pHtml) {
	if(BrowserDetect.browser != "Safari"){
		createPopup(pHtml);
	} else {
		var evt = document.createEvent("MouseEvents");
		evt.initEvent("click", false, true);
		document.getElementById("printLink").onclick = function() {
			createPopup(pHtml);
		};
		document.getElementById("printLink").dispatchEvent(evt);
	}
}
///////////////////////////////////////////////////////////////
function createPopup(pHtml) {
	popup = openWindow("", "print", 640, 500, 1, 0, 1);

	popup.document.write(pHtml);
	popup.document.close();
	
	popup.focus();
	
	popup.onload = setTimeout("onLoadHandler()", 500);
}
///////////////////////////////////////////////////////////////
function openWindow(pUrl, pWinName, pWidth, pHeight, pCenter, pShowMenu, pShowScrollbars) {	
	posX = 0; 
	posY = 0; 
	
	if ((parseInt(navigator.appVersion) >= 4 ) && (pCenter)){ 
		posX = (screen.width - pWidth) / 2; 
		posY = (screen.height - pHeight) / 2; 
	} 
	
	args = "width=" + pWidth + "," + "height=" + pHeight + "," + "location=0," + "menubar=" + (pShowMenu != null ? pShowMenu : "0") + "," + "resizable=1," 
	+ "scrollbars=" + (pShowScrollbars != null ? pShowScrollbars : "1") + "," + "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0," 
	+ "screenx=" + posX + ","  //NN Only 
	+ "screeny=" + posY + ","  //NN Only 
	+ "left=" + posX + ","     //IE Only 
	+ "top=" + posY;           //IE Only 
	
	return window.open(pUrl, pWinName, args); 
}
///////////////////////////////////////////////////////////////
function onLoadHandler() {
	popup.print();
}
///////////////////////////////////////////////////////////////