function goBack() { history.go(-1); }

function goTo(url) { window.location.href = url; }

function waitThenGoTo(url,time)
{
	if(time < 100) time = time * 1000;
	setTimeout("goTo('"+url+"')",time);
}

function waitThenGoBack(time)
{
	if(time < 1000) time = time * 1000;
	setTimeout('goBack()',time);
}

function reload() { window.reload(); }

function isInt(sText)
{
	var ValidChars = "0123456789";
	var isInt=true;
	var Char;

	for (i = 0; i < sText.length && isInt == true; i++)
	{
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) isInt = false;
 	}
	return isInt;
}

function noLeadingZero(input) {
    if((input.length > 1) && (input.substr(0,1) == "0")) return input.substr(1);
    else return input;
}

function datetounixtime(hour, minute, second, month, day, year) {
    var humDate = new Date(Date.UTC(year, (noLeadingZero(month)-1),
     noLeadingZero(day), noLeadingZero(hour), noLeadingZero(minute), noLeadingZero(second)));
    return (humDate.getTime()/1000.0);
}

function ucfirst(str) {
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}

function convertAddr(sDom, sUser){
  return("mail"+"to:"+sUser.replace(/%23/g,".").replace(/%24/g,"-")+"@"+sDom.replace(/%23/g,".").replace(/%24/g,"-"));
}


/* ----------------- SYSTEM ----------------- */

var system = new function() {
    this.basepath = "/";

    this.setBasepath = function(basepath) {
        this.basepath = basepath;
    }
}

/* ----------------- MENU ----------------- */
var menu = new function() {
    this.tabid = '#menutab-';
    this.activeClass = 'active';

    this.select = function(tab) { $(this.tabid+tab).addClass(this.activeClass); }
    this.selectImage = function(tab) { 
        var img = $(this.tabid+tab+' img');
        var imgsrc = img.attr('src');
        var newsrc = imgsrc.replace('.png','_a.png');
        img.attr('src',newsrc); }
}

$(function(){
    $('textarea').tinymce({
        script_url : '/js/tiny_mce/tiny_mce.js',
        theme : "simple"
    });
    Shadowbox.init();
});
