var _u='undefined',_d=document;

/**
 * X-MENus functions -- dn20040809
 * Get browser properties
 */
function Browser(){
	var B=this, n=navigator, s, i;
	B.App=n.appName.toLowerCase();
	B.UA=n.userAgent.toLowerCase();
	B.Win=(B.UA.indexOf("win")!=-1);
	B.Mac=(B.UA.indexOf("mac")!=-1);
	i=B.UA.indexOf("msie");
	if(i!=-1){
		B.IE=true;
		i+=5
	}else{
		B.IE=false;
		i=B.UA.indexOf(B.App);
		if(i!=-1){
			i+=B.App.length
		}
	}
	s=B.UA.substring(i);
	s=s.substring(s.indexOf("/")+1);
	B.Maj=parseInt(s);
	B.Min=parseFloat(s);
	B.Gkv=0;
	if(B.UA.lastIndexOf("gecko")!=-1){
		if (B.UA.lastIndexOf("safari")==-1) {
			B.Gkv=parseFloat(B.UA.substring(B.UA.lastIndexOf("rv:")+3))
		} else {
			B.Gkv=1;
		}
	}
}
var Brw=new Browser(),menusWritten=false;
var IEal=(typeof _d.all!=_u),DOM1=(_d.getElementById);
var IEOk=IEal&&(!Brw.Mac||(Brw.Mac&&Brw.Min>=5)),GkOk=(Brw.Gkv>=1),DHTML=(IEal&&IEOk||DOM1&&GkOk);
function b2n(){var r='',i;for(i=0;i<arguments.length;i++){if(arguments[i]){r+=1}else{r+=0}}return r}
function makeCurl(c,o){var e=c.lastIndexOf(','),s=c.lastIndexOf(',',e-1);return c.substring(0,s+1)+o+c.substring(e)}

/**
 * Open a popup window, with specified height and width etc., Version 2 (danieln)
 * Arguments are as follows: (*=required)
 * URI of the page to GET*, (window name), (width), (height), (features)
 * - where 'features' is a comma-delimited string of "property1=value1,property2=value2,.." etc.
 * - non-standard window features are: 
 *   'replace=true' replaces the url in the target window's history, 'center=(anything)' centers the window, 
 *   'cacheBaffle=(anything)' appends a querystring to defeat proxy cacheing (hopefully)
 */
function openPopupWindow() {
	var a = arguments;
	var w = new Array(); // window.open args
	var p = new Object(); // window properties
	var feature;
	p.replace = ""; p.cacheBaffle = ""; p.center=""; // custom properties
	p.width = "600"; p.height = "400"; p.resizable = "yes";	p.scrollbars = "yes"; p.status = "no"; p.toolbar = "no"; p.location = "no"; p.menubar = "no";	p.left = ""; p.top = ""; // standard properties
	w[0] = "about:blank"; w[1] = "popupWin";
	if ((a[0]!=null) && (a[0]!="")) { w[0]=a[0] } //url
	if ((a[1]!=null) && (a[1]!="") && (a[1].toString().indexOf("=")==-1)) { w[1]=a[1] } //name
	if ((a[2]!=null) && (!isNaN(parseInt(a[2])))) { p.width=a[2] } //width
	if ((a[3]!=null) && (!isNaN(parseInt(a[3])))) { p.height=a[3] } //height
	var l = a.length-1;
	if ((l>0) && (a[l].toString().indexOf("=")!=-1)) { // this is probably the features list
		a[l]=a[l].replace(/ /g,"");
		var f = a[l].split(",");
		for (var i=0; i<f.length; i++) {
			var nameVal=f[i].split("=");
			for (feature in p) { if (feature.toLowerCase()==nameVal[0].toLowerCase()) p[feature]=nameVal[1]; }
		}
		if (p.cacheBaffle!="") {
			var o = w[0].match(/^[^#\?]*/), qs = w[0].match(/\?[^#]*/), hsh = w[0].match(/#[^\?]*/);
			if (qs==null) qs= ""; if (hsh==null) hsh= "";
			qs += (qs.length>0) ? "&" : "?"; o += qs + "cacheBaffle=" + Math.random().toString().substring(2) + hsh;
			w[0]=o;
		}
		if (p.center!="") {
			p.left = parseInt((screen.availWidth - p.width)/2);	p.top = parseInt((screen.availHeight - p.height)/2);
		}
	}
	var wf = new Array(); i=0;
	for (feature in p) { 
		if ((p[feature]!="") && (feature!="replace") && (feature!="cacheBaffle") && (feature!="center")) {
			var nameValStr = feature + "=" + p[feature]; wf[i++]=nameValStr;
		}
	}
	w[2]=wf.join(",");
	if (p.replace=="true") w[3]=true;
	eval("window.pop_" + w[1] + " = window.open('" + w.join("','") + "')");
	eval("window.setTimeout('window.pop_" + w[1] + ".focus()',100)"); // allow time for it to be created
}

// set the search scope -dn
function changeExchangeSearchTarget(textValue, dbValue) {
	// set the search field
	_d.simpleSearch.siteID.value = dbValue;
	// get the HTML to search
	var tElem = _d.getElementById("simpleSearch");
	var tSpan = tElem.getElementsByTagName("span")[2];
	tSpan.innerHTML = textValue;
}

// Moved here from content pages --dn20040908
function populateExchDate() {
	var o = _d.getElementById("exch_date");
	if (o) {
		var days   = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
		var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
		var a = new Date();
		o.innerHTML = days[a.getDay()] + " " + a.getDate() + " " + months[a.getMonth()] + " " + a.getFullYear();
	}
}
function populateExchDate1() {
	var o = _d.getElementById("exch_date1");
	if (o) {
		var days   = ["¬P´Á¤é", "¬P´Á¤@", "¬P´Á¤G", "¬P´Á¤T", "¬P´Á¥|", "¬P´Á¤­", "¬P´Á¤»"];
		var months = ["1¤ë", "2¤ë", "3¤ë", "4¤ë", "5¤ë", "6¤ë", "7¤ë", "8¤ë", "9¤ë", "10¤ë", "11¤ë", "12¤ë"];
		var a = new Date();
		o.innerHTML = " " + days[a.getDay()] + " " + a.getFullYear() + "¦~ " + months[a.getMonth()] + " " + a.getDate() + "¤é" ;
	}
}

function populateExchDate2() {
	var o = _d.getElementById("exch_date2");
	if (o) {
		//var days   = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes­", "Sábado"];
		var days   = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];
		var months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
		var a = new Date();
		o.innerHTML = days[a.getDay()] + " " + a.getDate() + " " + months[a.getMonth()] + " " + a.getFullYear();
	}
}

// measure the page - used for DHTML menus -dn
var pWidth = 994, pHeight = 592; // default page dimensions
function measurePage() {
	pWidth = document.body.clientWidth-2;
	pHeight = document.body.clientHeight-2;
}

// set a flag for the onload event -dn
window.loaded = false;
function setLoaded() {
	measurePage();
	populateExchDate();
	populateExchDate1();
	populateExchDate2();
	window.loaded = true;
}
window.onload=setLoaded;