﻿
function openwindow (theURL, winName, features) { 
	var empieza_ancho=parseInt(features.indexOf("width="));  
	if (empieza_ancho != -1){
	   var acaba_ancho=parseInt(features.indexOf(",",empieza_ancho));
	   if (acaba_ancho == -1 ) acaba_ancho=features.length;             
	   var pos_izq=parseInt((screen.width - features.substr(empieza_ancho+6,acaba_ancho - (empieza_ancho + 6))) / 2) ;
	   if (features.indexOf("left=") == -1 && pos_izq >= 0 ) features+=",left=" + pos_izq ;
	}
	var empieza_alto=parseInt(features.indexOf("height="));  
	if (empieza_alto != -1){
	   var acaba_alto=parseInt(features.indexOf(",",empieza_alto));
	   if (acaba_alto == -1 ) acaba_alto=features.length;             
	   var pos_sup=parseInt((screen.height - features.substr(empieza_alto+7,acaba_alto - (empieza_alto + 7))) / 2) ;
	   if (features.indexOf("top=") == -1 && pos_sup >= 0 ) features+=",top=" + pos_sup ;
	}
	if (features.indexOf("scrollbars") == -1) features+=",scrollbars=no";
	window.open (theURL, winName, features);
}
function viewobject (sender, id, url, css) {
	var element = document.getElementById(id);
	var sender = document.getElementById(sender);
	if ( sender==null ) {
		return;
	}
	if ( element==null ) {
		element = document.createElement("div");
		element.setAttribute("id", id);
		sender.appendChild(element);
	}
	var object = document.createElement("iframe");
	object.setAttribute("src", encodeURI(url));
	object.setAttribute("frameborder", "0");
	object.setAttribute("class", css);
	element.appendChild(object);
	window.location.hash="#" + id;
	sender=null; element=null;
}
function closewindow (reload) {
	if (parseFloat(reload)==1) {
		window.opener.location.reload();
	}
	window.close();
}
function imprimirpantalla () {
	if (navigator.appName.substring(0,8) == 'Netscape') {
		(parseFloat(navigator.appVersion.substring(0,1)) > 3)?window.print():void(0);
	} else {
		if ( (navigator.appVersion.indexOf(5)) != -1 ) {
			window.print();
		} else if (parseInt(navigator.appVersion.substring(0,1)) > 3) {
			var OLECMDID_PRINT = 6;
			var OLECMDEXECOPT_DONTPROMPTUSER = 2;
			var OLECMDEXECOPT_PROMPTUSER = 1;
			var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
			document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
			WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
			WebBrowser1.outerHTML = "";
		}
	}
}
function capturaError (sMessage, sURL, sLine) {
	var debugpage = false;
	if ( debugpage== true ) window.alert ("Error: " + sMessage + "\r\nLinea: " + sLine);
	return true;
}
