(function ($) {
$.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'sblur';
  }
  return this.each(function () {
    var $input = $(this),
      title = $input.attr('title'),
      $form = $(this.form),
      $win = $(window);
    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }
	if (title) { 
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur();      
      $form.submit(remove);
      $win.unload(remove);
    }
  });
};
})(jQuery);


function SwitchPage(to)
{
	//pageTracker._trackPageview('/page/'+to);
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		window.location="/page/"+to;
	}
	$(".rightcolumn")
		.stop()
		.animate({"margin-left":-700,opacity:0},800,function() {
			$("#twrapper").addClass("mloading");
			$(".rightcolumn").load("/index.php?mini=1&page="+to,function() {
				$(".rightcolumn").stop().animate({"margin-left":0,opacity:1},800,function ()
				{
					$("#twrapper").removeClass("mloading");
					GFunc();
				});			
			});
		});
}

function GFunc()
{
		$(".rfade").hover(function() {
			$(this).stop().fadeTo(600,1);
		}, function() {
			$(this).stop().fadeTo(800,0.6);
		});
		
		$(".button").click(function()
		{
			$(".button").removeClass("buttonactive");
			$(this).addClass("buttonactive");
		});
		
		$(".button, .block").click(function()
		{
			var dest=$(this).attr("rel");
			if (!dest=="") {
				SwitchPage(dest);			
				return false;
			}
		});
}

$(document).ready(function(){
	GFunc();
	
	$("input[name='s']").hint();
	
	$(".rfade").fadeTo(0,0);
	$(".rfade").each(function() {
		$(this).doTimeout(1000*Math.random(),function() { $(this).fadeTo(2000*Math.random(),0.6) });
	});

	var GenericTooltip={ show:'mouseover', hide:'mouseout', position: { corner: {target:'leftMiddle',tooltip:'rightMiddle'} }, style: { color: 'white', background: '#553d53', tip:'rightMiddle', border:{width:1,radius:4,color:'#765c73'} } };
	$('.button').qtip(GenericTooltip);
});