// pkPrototype son funciones ??? verificar dónde son llamadas! creo contiene las usadas para los errores bonitos
var confirmacion = "";

function makeRequest(url,type,function_handler,params) {
	var http_request = false;
	var doc = null;

   	if(window.XMLHttpRequest){ // Mozilla, Safari,...
    	http_request = new XMLHttpRequest();
        if(http_request.overrideMimeType){
        	http_request.overrideMimeType('text/xml');
            // Ver nota sobre esta linea al final
        }
	}else if(window.ActiveXObject){ // IE
        try{
        	http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
        	try{
            	http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){}
        }
  	}

    if(!http_request){
    	mensaje('Falla :( No es posible crear una instancia XMLHTTP','alert_red');
        return false;
    }
	//http_request.async = false;
    http_request.onreadystatechange = function (){
	    if(http_request.readyState == 4){
	    	if(http_request.status == 200){
				if(type == 'xml') 
					doc = http_request.responseXML;
				else
					doc = http_request.responseText;
				if(function_handler != null) function_handler(doc,params);
			}else{
            	mensaje('Hubo problemas con la petición. Error: '+http_request.status,'alert_red');
            }
		}
	}
//	prompt("debug",url);
	var index=url.indexOf('?');
	if(index!=-1){
		http_request.open('POST', url.substring(0,index), true);
		http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request.send(url.substring(index+1));
	}else{
		http_request.open('POST', url, true);
		http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request.send(null);
	}
}
	
//<----------------------------------------------------------------------------------->
var initForm = new Array();
function makeForm(xmldoc,params){
 	//LIMPIAR los campos
	formulario = params['form']; 
	name1 = null;
	name2 = null;

	for(i = 0; i < formulario.length; i++){ 
	 	name1 = formulario.elements[i].name;
		name2 = name1.substr(4,name1.length);
		
		if(xmldoc.getElementsByTagName(name2).item(0)!= null){
	    	switch (formulario.elements[i].tagName)	{
	   			case 'INPUT':
			 		switch (formulario.elements[i].type){	
						case 'text':
							//eval(formulario.name+'.'+name1+'.value=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
							formulario.elements[i].value = xmldoc.getElementsByTagName(name2).item(0).firstChild.data;
							
							break;
						case 'button':
							//eval(formulario.name+'.'+name1+'.value=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
							formulario.elements[i].value = xmldoc.getElementsByTagName(name2).item(0).firstChild.data;
							break;
						case 'hidden': 
							//eval(formulario.name+'.'+name1+'.value=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
							formulario.elements[i].value = xmldoc.getElementsByTagName(name2).item(0).firstChild.data;
							break;
						case 'image':
							//eval(formulario.name+'.'+name1+'.src=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
							formulario.elements[i].src = xmldoc.getElementsByTagName(name2).item(0).firstChild.data;
							break;
						case 'checkbox': // si es multiple se tira 3
							if(xmldoc.getElementsByTagName(name2).item(0).firstChild.data == 1) 
								//eval(formulario.name+'.'+name1+'.checked=true;');
								formulario.elements[i].checked = true;
							else
								//eval(formulario.name+'.'+name1+'.checked=false;');
								formulario.elements[i].checked = false;
							break;
						case 'radio':
							if(xmldoc.getElementsByTagName(name2).item(0).firstChild.data == formulario.elements[i].value)	
								formulario.elements[i].checked = true;
							else
								formulario.elements[i].checked = false;
							break;	
						case 'submit':
							// por si hace falta
							//	eval(formulario.name+'.'+name1+'.src=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
							break;
					}	
					break;
				case 'TEXTAREA':
						//eval(formulario.name+'.'+name1+'.value=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
						formulario.elements[i].value = xmldoc.getElementsByTagName(name2).item(0).firstChild.data;
						break;
				case 'SELECT': // si es multiple se tira 3
						//eval(formulario.name+'.'+name1+'.value=xmldoc.getElementsByTagName(name2).item(0).firstChild.data;');
						formulario.elements[i].value = xmldoc.getElementsByTagName(name2).item(0).firstChild.data;
						break;
		   }
		}
	}
	eval(params['function_handler']);
}
 
//<----------------------------------------------------------------------------------->
function stringForm(formulario){
 	string = "";
	for (i = 0; i < formulario.elements.length; i++){
		if(formulario.elements[i].type == 'checkbox' || formulario.elements[i].type == 'radio'){
			if(formulario.elements[i].checked == true)	aux = "si";
			else aux = "no";	
		}else{
			if(!formulario.elements[i].disabled && !formulario.elements[i].readOnly && formulario.elements[i].type != "button") 
				aux = formulario.elements[i].value;
			else
				aux = "";

		}
		string = string+"~¤¥"+aux;
	}
	return string;	
}


var sentido = 'ASC';
var ordenActual = '';
//<----------------------------------------------------------------------------------->
function makeTable(xmldoc,params){
	// Nota: la tabla que se esta pasando tiene que tener definido
	// una cabecera, un cuerpo y un pie de pagina
	//alert(params['idTabla']);
	//alert(xmldoc);
	blah = params['order'];
	sentido = blah.substr(blah.indexOf(" ")+1);
	sentido = sentido.toUpperCase();
	table = document.getElementById(params['idTabla']);
	anterior= document.getElementById(params['idAnclaAnt']);
	proximo	= document.getElementById(params['idAnclaProx']);
	paginas = document.getElementById(params['idPages']);
	show = document.getElementById(params['idShow']);
	paginador = document.getElementById(params['idPaginador']);
	
	for(i = 0; i < table.childNodes.length; i++){
		switch(table.childNodes[i].nodeName){	
			case 'THEAD':
				thead = table.childNodes[i];
				break;
			case 'TBODY':
				tbody = table.childNodes[i];
				break;
			case 'TFOOT':
				tfoot = table.childNodes[i];
				break;	
		}
	}
		
	// Se buscan los id de las cabeceras para hacer  
	// la busqueda por tag en el XML
	for(i = 0; i < thead.childNodes.length; i++){
		if(thead.childNodes[i].nodeName == 'TR'){	
			aux = thead.childNodes[i];
			tdId = new Array();
			tagName = new Array();
			j = 0;
				
			for(i = 0; i < aux.childNodes.length; i++){
				if(aux.childNodes[i].nodeName == 'TD'){
					tdId[j] = aux.childNodes[i].getAttribute('id');
					tagName[j] = tdId[j];
					j++;	
				}
			}
			break;	
		}	
	}
	
	
	if(xmldoc.getElementsByTagName(tagName[0]).length == 0) {
		//if(params['flag'] == true){
			table.style.display = "none" 
			paginador.style.display = "none";
			show.style.display = "block";
			show.innerHTML = "No se produjeron resultados";
		//}
		return;
	}

	// Se borran los nodos viejos del tbody antes de insertar nuevos nodos
	while(tbody.hasChildNodes()) tbody.removeChild(tbody.firstChild);

	// Se insertan los registros nuevos a la tabla
	if(xmldoc.getElementsByTagName(tagName[0]).length >= params['end']){
		
		if(sentido == 'ASC'){
			fin = params['end']-1 ;
			comienzo = 0;
		}else{
			fin = params['end'];
			comienzo = 1;
		}
	}else{
		fin = xmldoc.getElementsByTagName(tagName[0]).length; 
		comienzo = 0;
	}
	cont = 0;
	for(i = comienzo; i < fin; i++){
		tr = document.createElement('tr');
		
		for(j = 0; j < tagName.length ; j++){   
			if(xmldoc.getElementsByTagName(tagName[j]).item(i).hasChildNodes()){
				if(xmldoc.getElementsByTagName(tagName[j]).item(i).firstChild.data == "") texto = "&nbsp;";
				else texto = xmldoc.getElementsByTagName(tagName[j]).item(i).firstChild.data;
			}else
				texto = "&nbsp;";
			
			td = document.createElement('td');
			if(j == 0)	td.className = 'td_first';
			if(params['links'] != null){
				for(k = 0; k < params['links'].length; k++){
					if(texto != "&nbsp;" && params['links'][k]['colId'] == tagName[j]){	
						texto = "<a href="+params['links'][k]['url']+"?id="+texto+" target=\""+(params['links'][k]['target']!=null?params['links'][k]['target']:"_self")+"\">"+texto+"</a>";
					}
				}
			}			
			td.innerHTML = texto;
		
//			td.setAttribute('align','center');
			
			tr.appendChild(td);
		}
		//if( cont%2 == 0) tr.setAttribute('class','greyTR');
		//else   tr.setAttribute('class','whiteTR');
		if( cont%2 == 0) tr.className='greyTR';
		else   tr.className='whiteTR';
		
		
		cont = cont + 1;
		tbody.appendChild(tr);

		
	}
		
	// Lógica del paginador empieza aquí
	if(params['ini'] > 0){
		//se le coloca el link al botón "back"
		aux = params['ini']-params['end']+1;
		anterior.setAttribute('href','javascript:exec('+params['params']+','+aux+','+params['end']+')');
		anterior.style.visibility = "visible";

	}else{
		//se le quita el link al botón "back"
		anterior.style.visibility = "hidden";
		anterior.removeAttribute('href');
	}
	
	
	if(xmldoc.getElementsByTagName(tagName[0]).length >= params['end']){
		//se le coloca el link al botón "next"
		aux = params['ini']+params['end']-1;
		proximo.style.visibility = "visible";
		proximo.setAttribute('href','javascript:exec('+params['params']+','+aux+','+params['end']+')');
	}else{
		//se le quita el link al botón "bext"
		proximo.removeAttribute('href');
		proximo.style.visibility = "hidden";
	}
	

	aux = params['ini'] + xmldoc.getElementsByTagName(tagName[0]).length;
	
	if(xmldoc.getElementsByTagName(tagName[0]).length == params['end'])	aux--;
	paginas.innerHTML = params['ini']+1+" - "+aux;
	
	table.style.display = (document.layers)? 	"table":"";
	table.style.display = (document.all)? 		"block":"";
	document.getElementById(paginador.id).style.display = (document.layers)? 	"table":"";
	document.getElementById(paginador.id).style.display = (document.layers)? 	"block":"";

	show.style.display = "none";
}

//<----------------------------------------------------------------------------------->
function exec(params,ini,end){	
	params['ini'] = ini;
	params['end'] = end;
	params['flag'] = false;
	url = makeURL(params);
	makeRequest(url,'xml',makeTable,params);
}

//<----------------------------------------------------------------------------------->
function makeURL(params){
	string = '';
	parametros = '';
	if(params['funcionParams'] != null){
		for(i = 0; i < params['funcionParams'].length; i++){
			if (i == params['funcionParams'].length - 1)	parametros = parametros + params['funcionParams'][i];
			else parametros = parametros + params['funcionParams'][i]+',';
		}
	}
	
	if(params['paginar']){
		parametros  = parametros+','+params['ini'];
		parametros  = parametros+','+params['end'];
		string = string+'tam_pagina='+params['end']+'&';
	}
	
	if(params['clase'] != null)		string = string+'clase='+params['clase']+'&';
	if(params['funcion'] != null)	string = string+'funcion='+params['funcion']+'('+parametros+')&';
	if(params['id'] != null)		string = string+'id='+params['id']+'&';
	if(params['order'] != null)		string = string+'order='+params['order']+'&';
	if(params['formato_fecha'] != null)		string = string+'formato_fecha='+params['formato_fecha']+'&';
	url = 'genXML.php?'+string;
	return url;
}

//<----------------------------------------------------------------------------------->
function showResponse(htmldoc,params){	
	reference = document.getElementById(params['content']);
	reference.innerHTML = htmldoc;
	eval(params['function_handler']);
}


//<----------------------------------------------------------------------------------->
// source: http://www.dustindiaz.com/getelementsbyclass
function getElementsByClass(searchClass,node,tag){
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	
	els = node.getElementsByTagName(tag);
	elsLen = els.length;
	pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	
	for (i = 0, j = 0; i < elsLen; i++){
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	
	return classElements;
}

//<----------------------------------------------------------------------------------->

function saveForm(formulario,id,clase,handler){
	if(id==null || id==undefined || id==''){ insertForm(formulario,clase,handler); return; }
	if(handler==null || handler== undefined ) handler=function(doc,params){mensaje("Se guardaron los datos."); };
	name1 = null;
	name2 = null;
	insertado = false;
	url = 'modify.php?id='+id+'&clase='+clase+'&params=array(';
													  
	for(var i = 0; i < formulario.length; i++){ 
	 	name1 	= formulario.elements[i].name;
		prefix 	= name1.substr(0,3);
		name2 	= name1.substr(4,name1.length);
		if(formulario.elements[i].readOnly == true || formulario.elements[i].disabled == true) continue;
		switch (formulario.elements[i].tagName){
			case 'INPUT':
				switch (formulario.elements[i].type){	
					case 'text':
						valor = formulario.elements[i].value;
						valor = valor.replace(/\"/g,"");
						valor = valor.replace(/\'/g,"");
						valor = valor.replace(/\\/g,"\/");
						
						//valor = htmlEntities(valor);
						if(insertado) url = url+',';
						url = url+'"'+name1+'" => ';
						if(prefix == 'int') url = url+valor;
						else url = url+'"'+valor+'"';
						insertado = true;
						break;
						
					case 'button':						
						break;
						
					case 'hidden': 
						if(formulario.elements[i].name != "script_string" && formulario.elements[i].name != "script_string_solucion" && formulario.elements[i].name != "script_string_nuevos"){
							valor = formulario.elements[i].value;
							valor = valor.replace(/\"/g,"");
							valor = valor.replace(/\'/g,"");
							valor = valor.replace(/\\/g,"\/");
						//	valor = htmlEntities(valor);
							if(insertado) url = url+',';
							url = url+'"'+name1+'" => ';
							if(prefix == 'int') url = url+valor;
							else url = url+'"'+valor+'"';
							insertado = true;
						}
						break;
						
					case 'image':			
						break;
						
					case 'checkbox':
						if(insertado) url = url+',';
						url = url+'"'+name1+'" => ';
						if(formulario.elements[i].checked == true) 
							url = url+'1';
						else
							url = url+'0';
						insertado = true;
						break;

					case 'radio':
						if(formulario.elements[i].checked == true) {
							if(insertado) url = url+',';
							url = url+'"'+name1+'" => ';
							url = url+formulario.elements[i].value;
							insertado = true;
						}
						break;	
						
					case 'submit':
						break;
				}	
				break;
	
			case 'TEXTAREA':
					valor = formulario.elements[i].value;
					valor = valor.replace(/\"/g,"");
					valor = valor.replace(/\'/g,"");
					valor = valor.replace(/\\/g,"\/");
					//valor = htmlEntities(valor);
					if(insertado) url = url+',';
					url = url+'"'+name1+'" => ';
					if(prefix == 'int') url = url+valor;
					else url = url+'"'+valor+'"';
					insertado = true;
					break;
			case 'SELECT': 
					if(insertado) url = url+',';
					url = url+'"'+name1+'" => ';
					if(prefix == 'int') url = url+formulario.elements[i].value;
					else url = url+'"'+formulario.elements[i].value+'"';
					insertado = true;
					break;
		}
	}
	url = url+')';
	//prompt("",url);
	makeRequest(url,'otro',handler,null);
	initForm["'"+formulario.id+"'"] = stringForm(formulario);

}

function insertForm(formulario,clase,handler){
	if(handler==null || handler==undefined)
		handler=function(){mensaje("Se insertaron los datos.")};
		
	name1 = null;
	name2 = null;
	insertado = false;
	url = 'insert.php?clase='+clase+'&params=array(';
									  
	for(var i = 0; i < formulario.length; i++){ 
	 	name1 	= formulario.elements[i].name;
		prefix 	= name1.substr(0,3);
		name2 	= name1.substr(4,name1.length);
		
		switch (formulario.elements[i].tagName){
			case 'INPUT':
				switch (formulario.elements[i].type){	
					case 'text':
						if(formulario.elements[i].value != null){
							valor = formulario.elements[i].value;
							valor = valor.replace(/\"/g,"");
							valor = valor.replace(/\'/g,"");
							valor = valor.replace(/\\/g,"\/");
							//valor = htmlEntities(valor);
							if(insertado) url = url+',';
							url = url+'"'+name1+'" => ';
							if(prefix == 'int') url = url+valor;
							else url = url+'"'+valor+'"';
							insertado = true;
						}
						break;
						
					case 'button':						
						break;
						
					case 'hidden': 
						if(formulario.elements[i].name != "script_string" && formulario.elements[i].value != null){
							valor = formulario.elements[i].value;
							valor = valor.replace(/\"/g,"");
							valor = valor.replace(/\'/g,"");
							valor = valor.replace(/\\/g,"\/");
							//valor = htmlEntities(valor);
							if(insertado) url = url+',';
							url = url+'"'+name1+'" => ';
							if(prefix == 'int') url = url+valor;
							else url = url+'"'+valor+'"';
							insertado = true;
						}
						break;
						
					case 'image':			
						break;
						
					case 'checkbox':
						if(formulario.elements[i].value != null){
							if(insertado) url = url+',';
							url = url+'"'+name1+'" => ';
							if(formulario.elements[i].checked == true) 
								url = url+'1';
							else
								url = url+'0';
							insertado = true;
						}
						break;

					case 'radio':
						if(formulario.elements[i].checked == true) {
							if(insertado) url = url+',';
							url = url+'"'+name1+'" => ';
							url = url+formulario.elements[i].value;
							insertado = true;
						}
						break;	
						
					case 'submit':
						break;
				}	
				break;
	
			case 'TEXTAREA':
				if(formulario.elements[i].value != null){
					valor = formulario.elements[i].value;
					valor = valor.replace(/\"/g,"");
					valor = valor.replace(/\'/g,"");
					
					valor = valor.replace(/\\/g,"\/");
					
					//valor = htmlEntities(valor);
					if(insertado) url = url+',';
					url = url+'"'+name1+'" => ';
					if(prefix == 'int') url = url+valor;
					else url = url+'"'+valor+'"';
					
					insertado = true;
				}
				break;
			case 'SELECT': // si es multiple se tira 3
				if(formulario.elements[i].value != null){
					if(insertado) url = url+',';
					url = url+'"'+name1+'" => ';
					if(prefix == 'int') url = url+formulario.elements[i].value;
					else url = url+'"'+formulario.elements[i].value+'"';
					insertado = true;
				}
				break;
		}
	}
	url = url+')';
	//prompt('',url);
	makeRequest(url,'text',handler,null);
	initForm["'"+formulario.id+"'"] = stringForm(formulario);
}

function makeSelect(xmldoc,params){
	selID = params['selID'];
	selName = params['selName'];
	selected = params['selected'];
	if(selID.substr(0,4) == 'sel_'){
		prefix = '';
		ID = selID.substr(4,selID.length);
	}else{
		prefix = 'sel_';
		ID = selID;
	}
	formulario = params['form'];
	eval('selection = formulario.'+prefix+ID+';');
	objetos = xmldoc.getElementsByTagName(ID);
	nombres = xmldoc.getElementsByTagName(selName);
	selection.options.length = 0;
	
	if(!params['valorNulo'])
		valorNulo = 'NULL';
	else
		valorNulo = '';
	if(params['mensaje'] == null)
		selection.options[0] = new Option('-- Cualquiera --',valorNulo);
	else
		selection.options[0] = new Option('-- '+params['mensaje']+' --',valorNulo);
	for(i = 0; i < objetos.length; i++){
		selection.options[i+1] = new Option(nombres.item(i).firstChild.data,objetos.item(i).firstChild.data);
	}
	if (selected!=null && selected!='') selection.value = selected;
}

function ordenarTabla(campo,formulario,func){	
	if(ordenActual == campo){
		if(sentido == 'ASC') sentido = 'DESC';
		else sentido = 'ASC';
	}else{
		if(ordenActual != ''){
			document.getElementById(ordenActual).getElementsByTagName('img')[0].src = '';
			document.getElementById(ordenActual).getElementsByTagName('img')[0].style.display = 'none';
		}
		sentido = 'ASC';
		ordenActual = campo;
	}
	formulario.orderby.value = campo+' '+sentido;
	func(formulario);
	document.getElementById(campo).getElementsByTagName('img')[0].src = (sentido == 'ASC')? 'images/arw_up.gif' : 'images/arw_dwn.gif';
	document.getElementById(campo).getElementsByTagName('img')[0].style.display = 'inline';
}

function disabledAll(f){
	var _input=f.elements;
	for(i=0; i < _input.length; i++){
		_input[i].disabled=true;
	}
}
function getClientSize(){
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function mensaje(texto,clase,titulo,onclick){
	
	div_mensaje = document.getElementById('mensaje');
	pantalla = document.getElementById('overlay');
	conf = "";
	codigo_cerrar = 
		"document.getElementById('overlay').style.display='none';"+
		"document.getElementById('mensaje').style.display='none';"+
		"document.getElementById('overlay').style.visibility='hidden';"+
		"document.getElementById('mensaje').style.visibility='hidden';"+
		"document.getElementById('overlay').innerHTML = '';";

	if(titulo == null) titulo = "Mensaje";
	if(onclick == null) onclick = codigo_cerrar;
	if(clase == null) clase = "alert_green";
	
	
	var scrollSize 	= getScrollXY();
	var winSize 	= getClientSize();

	//construye el div de mensaje dinámicamente según los parámetros obtenidos
	div_mensaje.className = clase;
	
	div_mensaje.innerHTML =
		"<div id='general'>"+
			"<div id='text'>"+
				"<p>"+texto+"</p>"+
				"<input type='button' value='Aceptar' onclick=\""+onclick+"\"/>"+
			"</div>"+
		"</div>"+
		"<div id='pie'></div>";
	
	
	pantalla.innerHTML = 
	"<!--[if lte IE 6.5]><iframe></iframe><![endif]-->";

	//elemento div para hacer el alert de forma modal
	pantalla.style.display 		= "block";
	div_mensaje.style.display 	= "block";
	pantalla.style.visibility 	= "visible";
	div_mensaje.style.visibility= "visible";
	
	posicionarAlert();
	
	//asocia el posicionamiento del mensaje a cada evento de cambio de pantalla (resize, scrol) 
	//para que siempre se mantenga en el centro de la pantalla
	window.onscroll = posicionarAlert;
	window.onresize = posicionarAlert;
	
	with(pantalla.style){
		width= (winSize[0]<document.body.offsetWidth)? document.body.offsetWidth+"px" : winSize[0]+"px";
		height=(winSize[1]<document.body.offsetHeight+20)? document.body.offsetHeight+20+"px" :  winSize[1]+"px";
		filter = "alpha(opacity=30)";
		opacity = "0.3";
		
	}

}

function confirmar(texto,titulo,onclick){
	confirmacion = "";
	mensaje(texto,"confirm",titulo,onclick);
//	return confirm_timeOut();
//	return true;
}

function confirm_timeOut(){
	if(confirmacion != "") return (confirmacion=="true")? true:false;
	setTimeout('return confirm_timeOut();',0);


}
function posicionarAlert(){
	div_msj = document.getElementById('mensaje');
	pantalla =document.getElementById('overlay');
	if(div_msj.style.visibility!="hidden"){
		scrollSize = getScrollXY();
		winSize = getClientSize();
		div_msj.style.left 	= (winSize[0]*0.5 + scrollSize[0] - div_msj.offsetWidth/2)+"px";
		div_msj.style.top 	= (winSize[1]*0.5 + scrollSize[1] - div_msj.offsetHeight/2)+"px";
	}
}
