// JavaScript Document

var la = {
	openPopup : function(aid) {
		var win = window.open('/guias/.?aid=' + aid, '', 'width=500,height=300');
	},
	openPopupAdm : function(aid) {
		var win = window.open('/guias/guia_admin.php?aid=' + aid, '', 'width=500,height=300');
	}
};

var darksp = {
	xmlHttp : function() {
    	var http;
		try {
			// Firefox, Opera 8.0+, Safari
    		http = new XMLHttpRequest();
		}
		catch (e) {
		// Internet Explorer
   			try {
				http = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					http = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		return http;
	},

	getRunUrl : function(url, query) {
		var http = this.xmlHttp();
			http.onreadystatechange = function() {
				if (http.readyState == 2);
				if (http.readyState == 4);
			}

		http.open('GET', url + '?' + query, true);
		http.send(null);
	},

	postRunUrl : function(url, query) {
		var http = this.xmlHttp();
		http.open('POST', url, true);
		http.onreadystatechange = function() {
			if (http.readyState == 2);
			if (http.readyState == 4);// alert(http.responseText);
		}
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
		http.setRequestHeader("Content-length", query.length);
		http.setRequestHeader("Connection", "close");
		http.send(query);
	},

	ajax : function(url, query, method, id, loading) {
		var http = this.xmlHttp();
		if (method == 'get') {
			http.open('GET', url + (query ? '?' + query : ''), true);
			//http.setRequestHeader("Accept-Charset", "iso-8859-1");
		}
		if (method == 'post') {
			http.open('POST', url, true);
			//http.setRequestHeader("Accept-Charset", "iso-8859-1");
		}

		http.setRequestHeader("charset","ISO-8859-1");  
        http.setRequestHeader("Encoding","ISO-8859-1"); 

			http.onreadystatechange = function() {
				if (http.readyState == 2) {
					if (loading) {
						document.getElementById(id).innerHTML = loading;
					}
				}
				if (http.readyState == 4) {
					var ret = http.responseText;
					document.getElementById(id).innerHTML = ret;
				}
			}
		if (method == 'get') {
			http.send(null);
		}
		if (method == 'post') {
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
			http.setRequestHeader("Content-length", query.length);
			http.setRequestHeader("Connection", "close");
			http.send(query);
		}
	},

	openPopup : function(url, w, h, extra) {
		var param = 'width=' + w + ',height=' + h + (extra ? ',' + extra : '');
		var newWin = window.open(url, '', param);
	}
};

function setjs() {
	if (navigator.product == 'Gecko') {
		document.loginform["interface"].value = 'mozilla';
	}
	else if (navigator.appName == 'Microsoft Internet Explorer' &&
		navigator.userAgent.indexOf("Mac_PowerPC") > 0) {
  		document.loginform["interface"].value = 'konqueror';
	}
	else if (navigator.appName == 'Microsoft Internet Explorer' &&
		document.getElementById && document.getElementById('ietest').innerHTML) {
  		document.loginform["interface"].value = 'ie';
	}
	else if (navigator.appName == 'Konqueror') {
  		document.loginform["interface"].value = 'konqueror';
	}
	else if (window.opera) {
  		document.loginform["interface"].value = 'opera';
	}
}
