function drops_show(){ $j(this).addClass('show');  $j(this).removeClass('with-js'); }
function drops_hide(){ $j(this).removeClass('show'); $j(this).addClass('with-js'); }

$j = jQuery.noConflict(); 
$j(document).ready(function() {
	
	/* Init Countdown */
	countdown();
	
	
	/* Columnizer */
	$j('.product_group_search_content .exhibitor_categories_list > ul').columnize({ columns: 2 });
	
	
	/* Fix Newsletter form */
	$j('.mod_registration #ctrl_newsletter input').attr('checked', true);
	$j('.mod_registration #ctrl_country option[value=de]').attr('selected', true);
	$j('body.lang_de .mod_registration label[for=ctrl_xt_visitor_industry]').html('Branche');
	
	
	/* Delayed navigation */
    $j("#nav_main .level_1 > li").hoverIntent({
        interval: 150,
        over: drops_show,
        timeout: 350,
        out: drops_hide
    });
    $j("#nav_main .level_1 > li").addClass('with-js');
    
    
    /* Roundabout slider */
	$j('.myRoundabout').roundabout({
		minOpacity: 0.5,
   		minScale: 0.3,
		clickToFocus: false
	});
	
	setInterval(function() {
		$j('.myRoundabout').roundabout_animateToNextChild();
	}, 5000);
	
	
	/* Cufon */
	Cufon.replace('h1', {
		hover: true
	});
	
	Cufon.replace('h2:not(.no_cufon)', {
		hover: true
	});
	
	
	/* Tab navigation */
	$j('.tab_content:not(.active)').css('display', 'none');
	$j('.tab_nav > li').click(function(e){
		$j('.tab_content').hide();
		$j('.tab_nav li').removeClass('active');
		$j('.' + e.target.id + '_content').fadeIn();
		$j(this).addClass('active');
		return false;
	});
	
	
	/* Drop down boxes */
	$j('.ddbox').each(function(index) { 
		$j(this).find('.ce_text').wrapAll('<div class="content cont_' + index + '" />');
		$j(this).find('.content').hide();	
		$j(this).click(
			function() {
				var cont = $j(this).find('.content');
				if(cont.css('display') == 'none') 
				{	
					cont.slideDown();
					$j(this).addClass('active');
				}
				else 
				{
					cont.slideUp();
					$j(this).removeClass('active');
				}
		});
	});
		
	
	/* Keywordsearch */
	if($j('.keywordsearch #ctrl_keywords').val() == '')
	{
		$j('body.lang_de .keywordsearch #ctrl_keywords').val('Suchbegriff');
		$j('.keywordsearch #ctrl_keywords').click(function() {
			if($j('body.lang_de .keywordsearch #ctrl_keywords').val() == 'Suchbegriff')
				$j('.keywordsearch #ctrl_keywords').val('');
		});
		$j('.keywordsearch #ctrl_keywords').focusout(function() {
			if($j('.keywordsearch #ctrl_keywords').val() == '')
				$j('body.lang_de .keywordsearch #ctrl_keywords').val('Suchbegriff');
		});
		
		$j('body.lang_en .keywordsearch #ctrl_keywords').val('Keyword');
		$j('.keywordsearch #ctrl_keywords').click(function() {
			if($j('body.lang_en .keywordsearch #ctrl_keywords').val() == 'Keyword')
				$j('.keywordsearch #ctrl_keywords').val('');
		});
		$j('.keywordsearch #ctrl_keywords').focusout(function() {
			if($j('.keywordsearch #ctrl_keywords').val() == '')
				$j('body.lang_en .keywordsearch #ctrl_keywords').val('Keyword');
		});
	}
	
	
	/* Exhibitorsticker */
	$j('.exhibitorsticker_list').jCarouselLite({
		vertical: true,
		auto: 800,
    	speed: 1000,
    	visible: 2
	});
	
	
});
	
	
	
function countdown()
{
	today = new Date();
	BigDay = new Date("February 6, 2012")
	msPerDay = 24 * 60 * 60 * 1000 ;
	timeLeft = (BigDay.getTime() - today.getTime());
	e_daysLeft = timeLeft / msPerDay;
	daysLeft = Math.floor(e_daysLeft);
	e_hrsLeft = (e_daysLeft - daysLeft)*24;
	hrsLeft = Math.floor(e_hrsLeft);
	minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
	
	$j('span.countdown_days').text(daysLeft);
}
