// JavaScript Document

var pDivName = 'PreviewPDF_div';
function EcmPreviewPDF(link,options) {
	if(typeof(options)!="object") options = new Object();
	if(!options.zoom) options.zoom = 100;
	if(!options.toolbar) options.toolbar = 0;
	
	var div = document.getElementById(pDivName);
	if(!div) {
		div = document.createElement('div');
		div_tmp = '<div id=\'PreviewPDF_div\' style="display:none;position:absolute;left:0;top:0;background-color:#000000;width:100%;z-index:999;height:100%;background-image: url(\'include/ECM/EcmPreviewPDF/template/bar_pdf.gif\');background-repeat: repeat-x"><div style="height:23px;font-size:25px;color:white;"><div style="position:absolute;left:5;top:3;"></div><img style="position:absolute;right:2;top:0;cursor:pointer;" src="include/ECM/EcmPreviewPDF/template/x_pdf1.gif" onMouseOver="this.src=\'include/ECM/EcmPreviewPDF/template/x_pdf2.gif\';" onMouseOut="this.src=\'include/ECM/EcmPreviewPDF/template/x_pdf1.gif\';" onmousedown="this.src=\'include/ECM/EcmPreviewPDF/template/x_pdf3.gif\';" onmouseup="this.src=\'include/ECM/EcmPreviewPDF/template/x_pdf1.gif\';" onClick="HidePDF();" /></div><div id=\'PreviewPDF_div_pdf\'></div></div>';
		div.innerHTML = div_tmp;
		div = div.firstChild;
		document.body.appendChild(div);
	}
	if(div) {
		DisplayOther(false);
		div.style.display = '';
		var div_pdf = document.getElementById('PreviewPDF_div_pdf');
		var h_pdf = (div.offsetHeight-div.firstChild.offsetHeight);
		if(div_pdf) {
			div_pdf.innerHTML = "<iframe id=\"PreviewPDF_iframe_pdf\" name=\"PreviewPDF_iframe_pdf\" style='overflow-x: hidden;border:none;width:100%;height:"+h_pdf+"px;' frameborder='no' src='"+link+"#toolbar="+options.toolbar+"&zoom="+options.zoom+"'>Yours browser not accept iframes!</iframe>";
		}
	}
}

function HidePDF() {
	var div = document.getElementById(pDivName);
	if(div) {
		DisplayOther(true);
		div.style.display = 'none';
	}
}

function HidePDFIframe() {
	var div = parent.document.getElementById(pDivName);
	if(div) {
		DisplayOtherIframe(true);
		div.style.display = 'none';
	}
}


function DisplayOther(disp) {
	if(disp) display = ''; else display = 'none';
	for(var i = 0; i < document.body.childNodes.length; i++) {
		var node = document.body.childNodes[i];
		if(node && node.style) {
			if(disp) {
				if(node.setOldDisplay_pdf) {
					node.style.display = node.oldDisplay_pdf;
					node.setOldDisplay_pdf = false;
				}
			} else {
				node.oldDisplay_pdf = node.style.display;
				node.setOldDisplay_pdf = true;
				node.style.display = display;
			}
		}
	}
}
function DisplayOtherIframe(disp) {
	if(disp) display = ''; else display = 'none';
	for(var i = 0; i < parent.document.body.childNodes.length; i++) {
		var node = parent.document.body.childNodes[i];
		if(node && node.style) {
			if(disp) {
				if(node.setOldDisplay_pdf) {
					node.style.display = node.oldDisplay_pdf;
					node.setOldDisplay_pdf = false;
				}
			} else {
				node.oldDisplay_pdf = node.style.display;
				node.setOldDisplay_pdf = true;
				node.style.display = display;
			}
		}
	}
}
function HideMenu(){
}
