function redirect(url) {
	window.top.location.href = url; //siteurl+url;
}

function openpopup(popurl,width,height){
var winpops=window.open(popurl,"","width=" + width + ",height=" + height + ",scrollbars,resizable")
}

function show_confirm(message, url)
{
if(confirm(message)) redirect(url);
}

var original = document.title;
var timeout;

window.flashTitle = function (newMsg, howManyTimes) {

    function step() {
        document.title = (document.title == original) ? newMsg : original;
        if (--howManyTimes > 0) {
            timeout = setTimeout(step, 1000);
        };
    };

    howManyTimes = parseInt(howManyTimes);
    if (isNaN(howManyTimes)) {
        howManyTimes = 12;
    };
    clearTimeout(timeout);
    step();
};

window.cancelFlashTitle = function () {
    clearTimeout(timeout);
    document.title = original;
};

$('.ui-widget-overlay').live("click", function() {
    //Close the dialog
    $(".ui-dialog-titlebar-close").trigger('click');
});

var dn = "";
function Clock() {
	myElement = document.getElementById("clock");
	arr = myElement.innerHTML.split(":");
	hours =  arr[0];
	minutes = arr[1];
	seconds = arr[2];
	
	arr2 = seconds.split(" ");
	seconds = arr2[0];
	dn = arr2[1];
	
	seconds++;
	if (seconds > 59) { 
	seconds = 0; minutes++; 
		if (minutes < 10) { minutes = "0" + minutes; }
	}
	if (minutes > 59) { minutes = "00"; hours++;
		if (hours == 12) {
			//hours = 1;
				if (dn == "PM") { 
				dn = "AM";
				} else {
				dn = "PM";
				}
		}
		if (hours > 12) {
		hours = 1;
		} 		
	}
	
	if (seconds < 10) { seconds = "0" + seconds; }
	if (minutes.length < 2) { minutes = "0" + minutes; }
    
    myElement.innerHTML = hours + ":" + minutes + ":" + seconds + " " + dn;
   
	setTimeout("Clock()", 1000);

}


function EmpireClock() {
	myElement = document.getElementById("empireclock");
	arr = myElement.innerHTML.split(":");
	hours =  arr[0];
	minutes = arr[1];
	seconds = arr[2];
	
	arr2 = seconds.split(" ");
	seconds = arr2[0];
	dn = arr2[1];
	
	seconds++;
	if (seconds > 59) { 
	seconds = 0; minutes++; 
		if (minutes < 10) { minutes = "0" + minutes; }
	}
	if (minutes > 59) { minutes = "00"; hours++;
		if (hours == 12) {
			//hours = 1;
				if (dn == "PM") { 
				dn = "AM";
				} else {
				dn = "PM";
				}
		}
		if (hours > 12) {
		hours = 1;
		} 		
	}
	
	if (seconds < 10) { seconds = "0" + seconds; }
	if (minutes.length < 2) { minutes = "0" + minutes; }
    
    myElement.innerHTML = hours + ":" + minutes + ":" + seconds + " " + dn;
   
setTimeout("EmpireClock()", 250);
}




var dn = "";



///////////////////////////////////////////////////////////

function t_format1(myElement) {
	//00:01:30 wird zu 90s umformatiert
	arr = myElement.innerHTML.split(":");
	//hours = arr[0];
	minutes =  arr[0];
	seconds = arr[1];
	//sec = hours*3600+minutes*60+seconds*1;
	sec = minutes*60+seconds*1;
	return sec;
}

///////////////////////////////////////////////////////////

function t_format2(s) {
	if(s > -1) {
		hours = Math.floor(s/3600);
		minutes = Math.floor(s/60) % 60;
		seconds = s % 60;
		//t = hours + ":";
		t = "";
		if(minutes < 10) {
			t += "0";
		}
		t += minutes + ":";
		if (seconds < 10) {
			t += "0";
		}
		t += seconds;
	} else {
		t = "00:00";
	}
	return t;
}

///////////////////////////////////////////////////////////

function countd(resetTime) {
	for(i=1;; i++) {
		myElement = document.getElementById("counter" + i);
		if(myElement != null) {
		sec = t_format1(myElement);
		sec -= 1;
		if (sec < 0) {
			myElement.innerHTML=resetTime;
		} else {
			sec = t_format2(sec); 
			myElement.innerHTML=sec;}
		}
		else break;
	}
	setTimeout("countd('"+resetTime+"')", 1000);
}

///////////////////////////////////////////////////////////

function alert_box(alert_text)
{
	if (confirm(alert_text))
	{
		return true;
	}
	else
	{
		return false;
	}
}

///////////////////////////////////////////////////////////

function helpfloatie(id, event){
helppopup(id);
}

function helppopup(id) {
	$('body').append('<div id="modal-help"><div class="loading">Loading...</div></div>');
	$('div#modal-help').dialog({
									modal: true,
									draggable: false,
									width: 500,
									resizable: false,
									title: 'Help',
									position: ['center',55],
									close: function(event, ui) {
									$('div#modal-help').remove();
									}
					});
					
$("div#modal-help").load("ajax/ajaxHelpPopup.php?id="+encodeURIComponent(id));					
//$("div#modal-help").load("help.popup.php?id="+id);
}

function showAchievement(ID) {
	$('body').append('<div id="modal-achievement"><div class="loading">Loading...</div></div>');
	$('div#modal-achievement').dialog({
									modal: true,
									draggable: false,
									width: 600,
									resizable: false,
									title: 'Achievement Unlocked',
									position: ['center',70],
									close: function(event, ui) {
									$('div#modal-achievement').remove();
									}
					});
$("div#modal-achievement").load("ajax/achievement.php?id="+ID);
}

$(document).ready(function(){


	$("div.res").hover(
	  function () {
		var offset = $(this).offset();
		var title = $(this).attr('rel');
		$('body').append('<div class="popover below"><div class="arrow"></div><div class="inner"><div class="content">'+title+'</div></div></div>');
		var width = parseFloat($('div.popover').css('width'), 10);
		var width2 = width/3;
		$('div.popover div.inner').css({'text-align': 'center'});
		$('div.popover').css({top: offset.top+36, left: offset.left-width2}).show();
	  }, 
	  function () {
		$('div.popover').remove();
	  }
	);

	
	$('img.res').popover({
                  offset: 3,
				  placement: 'above'
                });


	$("a.hname").click(function () {
	var id = $(this).attr('rel');
	$(this).parent().parent().find('div.desc').load("ajax/ajaxHelpPopup.php?id="+encodeURIComponent(id)).show();	
	});



});











!function( $ ) {

 /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
  * ======================================================= */

  var transitionEnd

  $(document).ready(function () {

    $.support.transition = (function () {
      var thisBody = document.body || document.documentElement
        , thisStyle = thisBody.style
        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
      return support
    })()

    // set CSS transition event type
    if ( $.support.transition ) {
      transitionEnd = "TransitionEnd"
      if ( $.browser.webkit ) {
      	transitionEnd = "webkitTransitionEnd"
      } else if ( $.browser.mozilla ) {
      	transitionEnd = "transitionend"
      } else if ( $.browser.opera ) {
      	transitionEnd = "oTransitionEnd"
      }
    }

  })


 /* TWIPSY PUBLIC CLASS DEFINITION
  * ============================== */

  var Twipsy = function ( element, options ) {
    this.$element = $(element)
    this.options = options
    this.enabled = true
    this.fixTitle()
  }

  Twipsy.prototype = {

    show: function() {
      var pos
        , actualWidth
        , actualHeight
        , placement
        , $tip
        , tp

      if (this.getTitle() && this.enabled) {
        $tip = this.tip()
        this.setContent()

        if (this.options.animate) {
          $tip.addClass('fade')
        }

        $tip
          .remove()
          .css({ top: 0, left: 0, display: 'block' })
          .prependTo(document.body)

        pos = $.extend({}, this.$element.offset(), {
          width: this.$element[0].offsetWidth
        , height: this.$element[0].offsetHeight
        })

        actualWidth = $tip[0].offsetWidth
        actualHeight = $tip[0].offsetHeight
        placement = _.maybeCall(this.options.placement, this.$element[0])

        switch (placement) {
          case 'below':
            tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
            break
          case 'above':
            tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
            break
          case 'left':
            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}
            break
          case 'right':
            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}
            break
        }

        $tip
          .css(tp)
          .addClass(placement)
          .addClass('in')
      }
    }

  , setContent: function () {
      var $tip = this.tip()
      $tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
      $tip[0].className = 'twipsy'
    }

  , hide: function() {
      var that = this
        , $tip = this.tip()

      $tip.removeClass('in')

      function removeElement () {
        $tip.remove()
      }

      $.support.transition && this.$tip.hasClass('fade') ?
        $tip.bind(transitionEnd, removeElement) :
        removeElement()
    }

  , fixTitle: function() {
      var $e = this.$element
      if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
        $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
      }
    }

  , getTitle: function() {
      var title
        , $e = this.$element
        , o = this.options

        this.fixTitle()

        if (typeof o.title == 'string') {
          title = $e.attr(o.title == 'title' ? 'data-original-title' : o.title)
        } else if (typeof o.title == 'function') {
          title = o.title.call($e[0])
        }

        title = ('' + title).replace(/(^\s*|\s*$)/, "")

        return title || o.fallback
    }

  , tip: function() {
      if (!this.$tip) {
        this.$tip = $('<div class="twipsy" />').html('<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>')
      }
      return this.$tip
    }

  , validate: function() {
      if (!this.$element[0].parentNode) {
        this.hide()
        this.$element = null
        this.options = null
      }
    }

  , enable: function() {
      this.enabled = true
    }

  , disable: function() {
      this.enabled = false
    }

  , toggleEnabled: function() {
      this.enabled = !this.enabled
    }

  }


 /* TWIPSY PRIVATE METHODS
  * ====================== */

   var _ = {

     maybeCall: function ( thing, ctx ) {
       return (typeof thing == 'function') ? (thing.call(ctx)) : thing
     }

   }


 /* TWIPSY PLUGIN DEFINITION
  * ======================== */

  $.fn.twipsy = function (options) {
    $.fn.twipsy.initWith.call(this, options, Twipsy, 'twipsy')
    return this
  }

  $.fn.twipsy.initWith = function (options, Constructor, name) {
    var twipsy
      , binder
      , eventIn
      , eventOut

    if (options === true) {
      return this.data(name)
    } else if (typeof options == 'string') {
      twipsy = this.data(name)
      if (twipsy) {
        twipsy[options]()
      }
      return this
    }

    options = $.extend({}, $.fn[name].defaults, options)

    function get(ele) {
      var twipsy = $.data(ele, name)

      if (!twipsy) {
        twipsy = new Constructor(ele, $.fn.twipsy.elementOptions(ele, options))
        $.data(ele, name, twipsy)
      }

      return twipsy
    }

    function enter() {
      var twipsy = get(this)
      twipsy.hoverState = 'in'

      if (options.delayIn == 0) {
        twipsy.show()
      } else {
        twipsy.fixTitle()
        setTimeout(function() {
          if (twipsy.hoverState == 'in') {
            twipsy.show()
          }
        }, options.delayIn)
      }
    }

    function leave() {
      var twipsy = get(this)
      twipsy.hoverState = 'out'
      if (options.delayOut == 0) {
        twipsy.hide()
      } else {
        setTimeout(function() {
          if (twipsy.hoverState == 'out') {
            twipsy.hide()
          }
        }, options.delayOut)
      }
    }

    if (!options.live) {
      this.each(function() {
        get(this)
      })
    }

    if (options.trigger != 'manual') {
      binder   = options.live ? 'live' : 'bind'
      eventIn  = options.trigger == 'hover' ? 'mouseenter' : 'focus'
      eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'
      this[binder](eventIn, enter)[binder](eventOut, leave)
    }

    return this
  }

  $.fn.twipsy.Twipsy = Twipsy

  $.fn.twipsy.defaults = {
    animate: true
  , delayIn: 0
  , delayOut: 0
  , fallback: ''
  , placement: 'above'
  , html: false
  , live: false
  , offset: 0
  , title: 'title'
  , trigger: 'hover'
  }

  $.fn.twipsy.elementOptions = function(ele, options) {
    return $.metadata ? $.extend({}, options, $(ele).metadata()) : options
  }

}( window.jQuery || window.ender );


/*
	--------------------------------------------------------------------------------------------------------
*/

!function( $ ) {

  var Popover = function ( element, options ) {
    this.$element = $(element)
    this.options = options
    this.enabled = true
    this.fixTitle()
  }


  Popover.prototype = $.extend({}, $.fn.twipsy.Twipsy.prototype, {

    setContent: function () {
      var $tip = this.tip()
      $tip.find('.title')[this.options.html ? 'html' : 'text'](this.getTitle())
      $tip.find('.content')[this.options.html ? 'html' : 'text'](this.getContent())
      $tip[0].className = 'popover'
    }

  , getContent: function () {
      var content
       , $e = this.$element
       , o = this.options

      if (typeof this.options.content == 'string') {
        content = $e.attr(o.content)
      } else if (typeof this.options.content == 'function') {
        content = this.options.content.call(this.$element[0])
      }
      return content
    }

  , tip: function() {
      if (!this.$tip) {
        this.$tip = $('<div class="popover" />')
          .html('<div class="arrow"></div><div class="inner"><div class="content"></div></div>')
      }
      return this.$tip
    }

  })


 /* POPOVER PLUGIN DEFINITION
  * ======================= */

  $.fn.popover = function (options) {
    if (typeof options == 'object') options = $.extend({}, $.fn.popover.defaults, options)
    $.fn.twipsy.initWith.call(this, options, Popover, 'popover')
    return this
  }

  $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { content: 'data-content', placement: 'right'})

}( window.jQuery || window.ender );

$.fn.popover.defaults.animate = false
$.fn.twipsy.defaults.animate = false

/*
	--------------------------------------------------------------------------------------------------------
*/

