function confirmLink(theLink, theText){
    if (theText == '' || typeof(window.opera) != 'undefined') {return true;}
    var is_confirmed = confirm(theText);
    if (is_confirmed) {
        theLink.href += '&confirmado=1';
    }
    return is_confirmed;
}
//------------------------------------------------------------------------
function doPreview(wich, where){
	var objFile = document.getElementById(wich); //imagen
	var objImg = document.getElementById(where); //preview

	objImg.src = objFile.value;
}
//------------------------------------------------------------------------
function openWin(url, ancho, alto) {
	var day = new Date();
	var id  = day.getTime();
	var w   = screen.width;
  var h   = screen.height;
	var leftPos = (w-ancho)/2;
	var topPos = (h-alto)/2;

	eval("page" + id +
		 " = window.open(url, '" + id + "', '" +
		 "toolbar=0,"   +
		 "scrollbars=1,"+
		 "statusbar=0," +
		 "menubar=0,"   +
		 "resizable=0," +
		 "width="+ ancho + "," +
		 "height="+ alto + "," +
		 "top="+ topPos + ","  +
		 "left="+ leftPos +"');");
}
//------------------------------------------------------------------------
function highlight_div(checkbox_node){
    label_node = checkbox_node.parentNode;

    if (checkbox_node.checked){
		label_node.style.backgroundColor='#5B646C';
		label_node.style.color='#ffffff';
	} else {
		label_node.style.backgroundColor='#ffffff';
		label_node.style.color='#000000';
	}
}
//------------------------------------------------------------------------
function checkAll(caja){
	var qEstado = false;
	var cantidad= caja.length;
	if (document.getElementById('check_todos').checked){
		qEstado = true;
	}
	for (i=0; i<cantidad; i++){caja[i].checked = qEstado;}
}
//------------------------------------------------------------------------
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
	}}}
//------------------------------------------------------------------------
function checkEmail(str){
	var at  = "@";
	var dot = ".";
	var lat = str.indexOf(at);
	var lstr= str.length;
	var ldot= str.indexOf(dot);

	if (str.indexOf(at)==-1){return false;}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false;}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false;}
	if (str.indexOf(at,(lat+1))!=-1){return false;}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false;}
	if (str.indexOf(dot,(lat+2))==-1){return false;}
	if (str.indexOf(" ")!=-1){return false;}

	return true;
}
//------------------------------------------------------------------------
function $(id) {return document.getElementById(id);}
//------------------------------------------------------------------------
function checkLogin(){		
	var email = $('login_mail');
	var passw = $('login_pass');
	
	if (email.value == ''){alert('Completa tu email'); email.focus(); return false;}
	if (passw.value == ''){alert('Completa tu password'); passw.focus(); return false;}

	return true;
}
//------------------------------------------------------------------------
function etFireEvent(obj,evt){
	var fireOnThis = obj;

	if (document.createEvent){
		var evObj = document.createEvent('MouseEvents');
		evObj.initEvent(evt, true, false);
		fireOnThis.dispatchEvent(evObj);
	}
	else if (document.createEventObject){
		fireOnThis.fireEvent('on'+evt);
	}
}