
// String.trim() for IE
if(typeof String.prototype.trim !== 'function') {
	String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g, '');
	}
}

var menuVisibleDuration = 2;

$(document).ready(function() {
	//multiple form enter button error
	$(".mainsubmenu").css({display: "none"});
	$(".menuitem").hover(function(){
		if($.browser.msie && $.browser.version == 7.0) {
			$(this).children("ul:first").css({display: "block"});
		};
		$(this).children('ul')
		.css({visibility:"visible"})
		.stop(true,true)
		.slideDown(200, "easeOutCirc");
	},
	function(){
		$(this).children('ul')
		.stop(true,true)
		.delay(0)
		.fadeOut(50);
	});
	
	$("input[type=text]")
    .keydown(function(e) { 
        if (e.keyCode == 13) 
            $(this).closest("form").submit();
    });
	
	$('#profil_galery').css('display', 'none');
	
	$('#galeryBtn').mouseover(function(){
      $('#profil_galery').fadeIn(1000, isVisible() );
    });
	
	
	$('#profil_galery').mouseout(function(){
		$('#profil_galery').fadeOut(1000,isHidden() );
	});
	
	$('.overClass').hover( function(){
		$('#profil_galery').css('display', 'block');
	},
	function(){
		$('#profil_galery').css('display', 'none');
	});

	
	/*
	$('#galeryBtn').mouseover(function(){
      $('#profil_galery').fadeIn("slow", startCounting);
    });
    $('#profil_galery').mouseover(function(){
      stopCounting();
    });
    $('#galeryBtn').mouseout(function(){
      startCounting();
    });	
	*/
	$('#pane2').jScrollPane({showArrows:true});
	$('#pane3').jScrollPane({showArrows:true});
	/*
	$('.main a', '.left_headbar').click( function(event,ui){
		content = $(this)
				.parents('.left_headbar')
				.siblings('.left_content');
		url = $(this)
			.attr('href');
		$.get( url, 
			function( response ){
				$(content).html( response );
			});
		return false;	
			
	});
	*/
	$('.weiter a').click( function(event, ui){
		/*var headbar = $(this).parents('.left_headbar');
		$('.main a', headbar).click();
		*/
		content = $(this)
				.parent().parent()
				.siblings('.left_content');
		url = $(this).attr('href');
		
		$.get( url, 
			function( response ){
				$(content).html( response );
			} 
			
			);

		return false;	
		});

})

function isVisible()
{
	//$('#profil_galery').toggleClass("visibleElement");
	//$('#profil_galery').addClass("visibleElement");
	$('#profil_galery').css('display', 'block');
}

function isHidden()
{
	//$('#profil_galery').removeClass('visibleElement');
	$('#profil_galery').css('display', 'none');
}


function closeMenu ()
{
	$('#profil_galery').fadeOut('slow');
}

function startCounting ()
{
	toVisible = setTimeout('closeMenu()',menuVisibleDuration*1000);
}

function stopCounting ()
{
	clearTimeout(toVisible);
}

function loadsearchsuperpremium(i) {
	var val=$(i).val();
	if(val.length>3) {
		$.ajax({
			url: "/profiles/searchtipp/"+val,
			type: "POST",
			context: document.body,
			success: function(r){
				r='<img style="margin-top:10px; margin-bottom:10px;" src="/img/premium-tenner.png" />'+r+' <img style="margin-top:10px; margin-bottom:20px;"src="/img/premium-tenner-down.png">';
				$('#searchtipp').html(r);
				$('.premiumspace').css('height','auto');
			}
		});
	}
}

