/*function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}*/

function sc(id){ return document.getElementById(id); } 
function createObjAjax(){
	N = Math.round(Math.random()*999);
 	try {
 		this['A'+N] = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			this['A'+N] = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			this['A'+N] = false;
 		}
  	}
	if (!this['A'+N] && typeof XMLHttpRequest!='undefined') {
 		this['A'+N] = new XMLHttpRequest();
	}
	if (this['A'+N].overrideMimeType) {
		this['A'+N].overrideMimeType('text/html');
	}
	return 'A'+N;	
}
function loadPhp(url, divObj ,param){
	//alert('entró div:' + divObj + '	param: ' + param);
	if(divObj != null )sc(divObj).innerHTML = '<img src="images/ajax-loader.gif" alt="cargando"  />';
	var objAjax;
	objAjax=this[createObjAjax()];
	//if(objAjax)alert('created');
	objAjax.onreadystatechange = function (){	
	//alert(objAjax.readyState);
		if (objAjax.readyState == 4) {
			//alert(objAjax.status);
			if (objAjax.status == 200) {
				if(objAjax.responseText=="ERROR"){
					//document.location = "login.php";
					//alert('error' );
				}else{
					if(divObj == null ){
						document.location.href = objAjax.responseText;
						//alert("null div");
					}else{
						//alert("good div");
						sc(divObj).innerHTML = objAjax.responseText;
					}
					//sc(divObj).innerHTML = objAjax.responseText;
					//alert('volvió' + objAjax.responseText);
					
				}
			}
		}
	}
	objAjax.open("POST", url, true);	
	objAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	if(param==''){ 
		param=null;
	}else{
		objAjax.setRequestHeader("Content-length", param.length);
	}	
	objAjax.setRequestHeader("Connection", "close");
	objAjax.send(param);
}

function mq(act ,array){
	str ='act='+act;	
	for(i=0;i<=array.length-1;i++){
		if(sc(array[i])!=null){
			if(sc(array[i]).type == "checkbox"){
				if(sc(array[i]).checked == true){
					str+='&'+array[i]+'=1';
				}else{
					str+='&'+array[i]+'=0'
				}
			}else{
				str+='&'+array[i]+'='+sc(array[i]).value;		
			}
		}else{
			alert("FALSE : "+array[i])	;
		}
	}	
	return str; 
}
