var sto;
jQuery(document).ready(function() {
	//Enlaces colorbox
	jQuery("#linkPolitica").colorbox({width:"750px", height:"80%", iframe:true});
	jQuery("#linkCreditos").colorbox({width:"750px", height:"80%", iframe:true});
	jQuery("#linkSugerencias").colorbox({width:"750px", height:"80%", iframe:true});

	setLinkClientes();
	jQuery("#tools *").blur(function() { waitForReset(); });
	jQuery("#tools").focus(function() { clearTimeout(sto); });
	
	updateHideflash();
});
function updateHideflash(){
	jQuery().bind('cbox_open', function(){ 
		jQuery("#sidebar_flash").hide();
	}).bind('cbox_closed', function(){ 
		jQuery("#sidebar_flash").show();
	});
}
function setLoginForm(){
	var f = '<div id="formLogin">';
		f += '<form id="loginForm" method="post">';
		f += '<input type="text" id="user" name="user" value="Usuario" />';
		f += '<input type="password" id="pass" name="pass" value="Contrase&ntilde;a" />';
		f += '<input type="image" id="btLogin" src="'+path+'/img/bt_login.gif" />';
		f += '</form>';
		f += '<p id="loginMsg"></p>';
		f += '</div>';
	jQuery("#tools").html(f);
	jQuery("#formLogin").css({opacity: 0.0})
		.animate({opacity: 1.0}, 100, function() {
			
		});
	jQuery("#btLogin").click(function(event) {
		event.preventDefault();
		jQuery("#tools").focus();
		jQuery("#tools").blur();
		waitForReset();
		if (true) {
			jQuery("#loginMsg").html("Nombre de usuario incorrecto");
		}
	});
}
function waitForReset() {
	sto = setTimeout(resetLoginForm,5000);
}
function resetLoginForm(){
	jQuery("#tools").html('<a href="" title="Acceso Clientes" id="linkClientes">Acceso clientes</a>');
	setLinkClientes();
}
function setLinkClientes() {
	jQuery("#linkClientes").click(function(event) {
		event.preventDefault();
		jQuery("#tools").focus();
		jQuery("#tools").blur();
		jQuery(this).hide();
		setLoginForm();
	});
}