/**
 * @author Francisco Ruiz, 2008
 * funciones stmanager.dll
 */



function writelog(aid,acontent) {
		$.get('writelog',{ id: aid, content: acontent });
};

/*
function loginuser(aemail,apassword,aredirect) {
	$('#panelerror').hide();
	
	$.get('login',{ email: aemail, password: apassword }, function(data){
		if (data == 'OK') {
			window.location = '../stmanager.dll/home';
		}
		else 
		{
			$('#panelerror').fadeIn('slow');
		}
	});
};
*/

function logout () {
		$.get('logout',function(data){alert("Resultado Logout " + data)});
};

function getcookie(name)
{
  
  var cookie, offset, end;
  cookie  = " "+document.cookie;
  offset  = cookie.indexOf(" "+name+"=");
  
  if (offset == -1) return '';  /* inicialmente era return undefined, pero fallaba en iexplorer en todas sus versiones */
  offset += name.length+2;
  end     = cookie.indexOf(";", offset)
  if (end    == -1) end = cookie.length;
  var resultado = unescape(cookie.substring(offset, end));
  return resultado;
};

function isInteger(value) {
	return value.match(/^\d+$/);
};

function isFloat(value) {
	return value.match(/^\d+(\,\d+)?$/);
};


function modal(text, autoclose, time, modalwidth, modalheigth) {
					
	$("<div id='showmodal'></div>").css({
		  width: "100%",
		  height: "100%",
		  position: "fixed",
		  left: "0px",
		  top: "0px",
		  zIndex: "100",
		  backgroundColor: "#000",
		  opacity: "0.5"
		}).appendTo(document.body);
		
	var tempcontent = "<div id='showmodalcontent' style='text-align: center' >" + text + "</div>";
	
	var wscr = $(window).width();
    var vscroll = $(document).scrollTop();
	var windowheight = $(window).height();
	var leftpos = (wscr - modalwidth) / 2;
	var toppos = vscroll + (windowheight - modalheigth) / 2;

	$(tempcontent).css({
	  zIndex: "101",
	  border: "1px solid #333",
	  padding: "20px", 
	  backgroundColor: "#fff",
	  color: "#333",
	  position: "absolute",
	  width: modalwidth,
	  height: modalheigth,
	  left: leftpos,
	  top: toppos
	}).appendTo(document.body).click(function() {
		$(this).remove();
		$("#showmodal").remove();
	});
	
	if (autoclose == 'S') {
		setTimeout("$('#showmodal').fadeOut('fast').remove(); $('#showmodalcontent').fadeOut('slow').remove();", time);
	};
};


