$(document).ready(function() {

	$('#LanguageSelect').hover(function () {
		if ($("#HiddenLanguageBox").is(":hidden")) {
			$('#HiddenLanguageBox').stop(false,true).slideDown();
		}
		else {
			$('#HiddenLanguageBox').stop(false,true).slideUp();
		}
	});	
	
	$('#bottomContentBox2 #coin-slider').coinslider({
		width: 403, // width of slider panel
		height: 230, // height of slider panel
		spw: 1, // squares per width
		sph: 1, // squares per height
		delay: 6000, // delay between images in ms
		sDelay: 30, // delay beetwen squares in ms
		opacity: 1.0, // opacity of title and navigation
		titleSpeed: 500, // speed of title appereance in ms
		effect: '', // random, swirl, rain, straight
		navigation: true, // prev next and buttons
		links : false, // show images as links 
		hoverPause: false // pause on hover
	});
	
	$(".eff").colorbox({opacity:"0.5", width:"900px", height:"580px", iframe:true, overlayClose:false, title:'Forum'});
	$("a[rel='screens']").colorbox({opacity:"0.5",transition:"none", width:"660px", height:"530px",current:"Screenshot {current} von {total}"});
	$(".trailer").colorbox({opacity:"0.5", width:"582px", height:"490px", iframe:true });
	$(".anmeldeLink").colorbox({width:"660px", inline:true, overlayClose:false, href:"#ColorBoxAnmeldung", scrolling:false});
	
	$(".forgotPassword").colorbox({width:"570px", height:"370px", inline:true, overlayClose:false, href:"#forgotPasswordBox", scrolling:false});


	$(".imprint").colorbox({width:"660px", height:"640px", inline:true, overlayClose:false, href:"#impressum"});
	
	if ( ($.getUrlVar('action') === 'pwchange') ||
	   ($.getUrlVar('action') === 'activate') ||
	   ($.getUrlVar('action') === 'changemail') ||
	   ($.getUrlVar('action') === 'vacation') ){
    	$.colorbox({opacity:"0.5", width:"660px", height:"200px", inline:true, href:"#statusmessage", scrolling:false});	
  	}
	
	if ($.getUrlVar('action') === 'activate'){
    	$.colorbox({opacity:"0.5", width:"660px", height:"400px", inline:true, href:"#activationBox", scrolling:false});	
  	}
	else if ( $.getUrlVar('action') === 'boxcode') {
    	$.colorbox({opacity:"0.5", width:"660px", height:"500px", inline:true, href:"#statusmessage", overlayClose:false, scrolling:false});	
  	}
	else if (  ($.getUrlVar('action') === 'transferDiamonds') ){
    	$.colorbox({opacity:"0.5", width:"660px", height:"380px", inline:true, href:"#statusmessage", overlayClose:false ,scrolling:false});	
  	}
	else if (  ($.getUrlVar('action') === 'changeUniverse') ){
    	$.colorbox({opacity:"0.5", width:"660px", height:"520px", inline:true, href:"#statusmessage", overlayClose:false ,scrolling:false});	
  	}
	else if (  ($.getUrlVar('action') === 'sws') || ($.getUrlVar('action') === 'help')){
    	$.colorbox({opacity:"0.5", width:"515px", height:"430px", inline:true, href:"#statusmessage", overlayClose:false, scrolling:false});	
  	}
	


	$('.LoginButton').click(function(){	
  		$('#loginForm').submit();
	});
	
	/**** KEY ENTER USERNAME****/
	$('#loginNameID').keyup(function(e) {
       if(e.keyCode == 13) {
       	$('#loginForm').submit();
       }
    });
	
	/**** KEY ENTER ****/
	$('#loginPasswordID').keyup(function(e) {
       if(e.keyCode == 13) {
       	$('#loginForm').submit();
       }
    });

	$('.facebookConnect').click(function(){
		TrvApi.facebook.connect();
	});
	
	
	$('.radio').live('click', function() {

		tmp =	$(this).next("input").attr("id");
		if (tmp == 'female'){
			$('#registrationMan').addClass('female');
			
		}  else
		if (tmp == 'male'){
			$('#registrationMan').removeClass('female');
			$('#registrationMan').addClass('male');
		} else {
			
			$('#registrationMan').addClass('male');
		} 

		if (tmp == 'race1'){
			$('#registrationMan').removeClass('race2');
			$('#registrationMan').removeClass('race3');
			$('#registrationMan').addClass('race1');
		} else
		if (tmp == 'race2'){
			$('#registrationMan').removeClass('race3');
			$('#registrationMan').removeClass('race1');
			$('#registrationMan').addClass('race2');
		} else
		if (tmp == 'race3'){
			$('#registrationMan').removeClass('race2');
			$('#registrationMan').removeClass('race1');
			$('#registrationMan').addClass('race3');
		} 
		
	
	});
	
	$('#successRegister').live('click', function() {

		$('#loginForm').submit();
	});
	
	
	$('#close_error_box').click(function(){
		$('#error_Box').fadeOut();
	});	


});

$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

function NoEnter(){    
	if (event.keyCode == 13) {        
		event.cancelBubble = true;
		event.returnValue = false;
		//alert('DRIN');
   	}
} 


 
