function openWindow(pgn, parametros, ancho, alto, scrollbars, resizable) {
	derecha=(screen.width-ancho)/2;
	arriba=(screen.height-alto)/2;
	
	if(resizable==true)
		resizable = 1;
	else
		resizable = 0;
		
	if(scrollbars==true)
		scrollbars = 1;
	else
		scrollbars = 0;
	
	string="toolbar=0,scrollbars="+scrollbars+",location=0,statusbar=0,menubar=0,resizable="+resizable+",width="+ancho+",height="+alto+",left="+derecha+",top="+arriba+"";
	fin=window.open(pgn+'?'+parametros,"ventana", string);
}

function dimensionar(ancho, alto, centro) {
	if(centro==true) {
		derecha=(screen.width-ancho)/2;
		arriba=(screen.height-alto)/2;
		window.moveTo(derecha,arriba);
	}
	
	window.resizeTo(ancho,alto);
}

function darFoco(id) {
	id = document.getElementById(id);
	if(id)  {
		id.focus();
	} else {
		self.focus();
	}
}

function doPost(frm, params) {
	var frm = document.getElementById(frm);
	if(frm) {
		frm.action = params;
		frm.submit();
	}
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	
	if (endstr == -1)
		endstr = document.cookie.length;
		
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while (i < clen) {
		var j = i + alen;
		
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
			
		i = document.cookie.indexOf(" ", i) + 1;
		
		if (i == 0) 
			break; 
	}

	return null;
}

function setCookie (name, value) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	
	path="/";
	
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}


