changeduser = false;
origuser = '';
changedpasswd = false;
origpasswd = '';

function upload(url, pars){
	var url = url;
	var pars = pars;
	
	var myAjax = new Ajax.Updater(
		'salida', 
		url, 
		{
			method: 'post', 
			parameters: pars
		});
}

function opacity(id){
	new Effect.Opacity(e.getElementById(id), {duration:0.5, from:1.0, to:0.7});
}

function limpiarTextControl(e){
	if( e.id == 'username' && (!changeduser || e.value == origuser)){
		if(!changeduser){
			origuser = e.value;
		}
		e.value = '';
		e.className = e.className + ' sel';
		changeduser = true;
	}
	if( e.id == 'password' && (!changedpasswd || e.value == origpasswd)){
		if(!changedpasswd){
			origpasswd = e.value;
		}
		e.value = '';
		e.className = e.className + ' sel';
		changedpasswd = true;
	}
}

function comprobar(e,text){
	if(e.value == ''){
		e.value = text;
		e.className = e.className.replace(" sel", "");
	}	
}

//findPos function is from http://www.quirksmode.org/js/findpos.html;
//where its workings are explained in more detail.
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

//Display a named menu, at the position of another object
function display_menu(parent,named)
{
	//get the named menu
	var menu_element = document.getElementById(named);
	//override the 'display:none;' style attribute
	menu_element.style.display = "";
	//get the placement of the element that invoked the menu...
	var placement = findPos(parent);
	//...and put the menu there
	menu_element.style.left = placement[0] + "px";
	menu_element.style.top = placement[1] + "px";
}

//Hide a named menu
function hide_menu(named)
{
	//get the named menu
	var menu_element = document.getElementById(named);
	//hide it with a style attribute
	menu_element.style.display = "none";
}

// Condiciones
function condiciones(enlace){
	var url     = enlace.href;
	var id      = (enlace.id || ''); 
	var popup = window.open(url, id,
				'width=475,height=300,scrollbars=yes,toolbar=no,status=no,resizable=no');
	popup.focus();
	return false;
};

// JavaScript Document
function FSL(url){
	if (window.screen){
		var hori=screen.availWidth;
		var verti=screen.availHeight;
		window.open(url,'visor', 'width='+hori+',height='+verti+',fullscreen=1, scrollbars=0,left='+(0)+',top='+(0));
	}
}

/*
$(function() {
	$('#visornumeros span').Tooltip({ 
		track: true, 
		delay: 0, 
		showURL: false, 
		showBody: " - ", 
		extraClass: "pretty", 
		fixPNG: true, 
		opacity: 0.95, 
		left: -120 
	});
});
*/
/*
$(document).ready(function() {
	$.modaldialog.success('<b>argentina</b> - <b>resto mundo</b>', {
	  title: 'Escoger País'
});

$('.imagen img').rotateLeft(7);
*/