// Navigation (ohne jQuery)
function showNavItem(elem) {	
	elem.childNodes[1].style.display = "block";
}

function hideNavItem(elem) {
	elem.childNodes[1].style.display = "none";
}

// functions to be executed when document is loadet
$(document).ready(function() {
	//test Abstand contentad
	document.getElementById('content_main').style.border = 'none';		

	// Navigation
	/**
	$('#navigation_main > li').hover(function() {
		if (navi) {
			navi.find('ul').hide();
			navi = null;
		} //if
		
		$(this).find('ul').show();
	}, function() {
		navi = $(this);
		setTimeout(
			"checkHover()",
			400);
	});
	*/
	
	// Login
	$('#login_name').inputLabel("Login", {color:"#ffffff"});

	$('#login_passwd').blur(function() {
		if (!$('input#login_passwd').val()) {
			$(this).addClass('form_input_passwd');
		}
	});
	
	$('#login_passwd').focus(function() {
		if ($(this).hasClass('form_input_passwd')) $(this).removeClass('form_input_passwd');
	});

	$('#login_passwd').blur();
	
	// Newsticker
	try{
		var ticker_holder = $('.tx-caggreeter-pi1').get(0);
		var ticker_text = $('#cag_ticker').get(0);
		var ticker_pos = ticker_text.parentNode.offsetWidth;
		var ticker_scrollamount = 1;
		var ticker_scrolldelay = 40;

		var ticker_data = $(ticker_holder).html();
		$(ticker_text).parent().html(
			'<marquee scrollamount="' + ticker_scrollamount + '" scrolldelay="' + ticker_scrolldelay + '">' + ticker_data + '</marquee>'
		);
		
		ticker_width = 1.25 * $('#cag_ticker_container').width();
		
		$('#cag_ticker_container').width(ticker_width);
		
		//alert(ticker_width);

		$('.tx-caggreeter-pi1').hover(
			function() { $('marquee', this).get(0).stop();  },
			function() { $('marquee', this).get(0).start(); }
		);
	}
	catch (o) {}

    // TODO: only include this on pagebrowse pages
    $('#pagebrowser_select').change(function() {
        if ($(this).attr('value') != 0) {
            location.href = $(this).val();
        }
    });

   
    // making big link targets for teaser
    $('.gamesfun .container_w_previewteaser a.big_target').bigTarget({
        hoverClass: 'over', // CSS class applied to the click zone onHover
        clickZone : 'div.teaser2' // jQuery parent selector
    });


    // initialize ticker
    //$('ul#cag_ticker').liScroll({travelocity: 0.01}); 

    
    // FCE lightbox activation
    $("a[rel^='l_box_fce']").prettyPopin({
        opacity: 0.75,
        followScroll: true,
        loader_path: 'fileadmin/templates/img/loader.gif'
    });
	
	// Tooltip
	initToolTip();
	
	// key counter for input fields
	// usage: initKeyCounter(input_field, max_size, error_display_act, error_display_max);
	// set error_display_act and error_display_max to '' if you donīt want any key counts to be displayed
	initKeyCounter('inputfield_username', 10, 'inputfield_username_zeichen_act', 'inputfield_username_zeichen_max');
	initKeyCounter('inputfield_password', 32, 'inputfield_password_zeichen_act', 'inputfield_password_zeichen_max');
	initKeyCounter('inputfield_password_repeat', 32, 'inputfield_password_repeat_zeichen_act', 'inputfield_password_repeat_zeichen_max');
	initKeyCounter('inputfield_first_name', 30, 'inputfield_first_name_zeichen_act', 'inputfield_first_name_zeichen_max');
	initKeyCounter('inputfield_last_name', 30, 'inputfield_last_name_zeichen_act', 'inputfield_last_name_zeichen_max');
	initKeyCounter('inputfield_address', 30, 'inputfield_address_zeichen_act', 'inputfield_address_zeichen_max');
	initKeyCounter('inputfield_zip', 8, 'inputfield_zip_zeichen_act', 'inputfield_zip_zeichen_max');
	initKeyCounter('inputfield_city', 30, 'inputfield_city_zeichen_act', 'inputfield_city_zeichen_max');
	initKeyCounter('inputfield_country', 30, 'inputfield_country_zeichen_act', 'inputfield_country_zeichen_max');
	initKeyCounter('inputfield_email', 90, 'inputfield_email_zeichen_act', 'inputfield_email_zeichen_max');
	initKeyCounter('inputfield_tx_ltbuser_abonummer', 12, 'inputfield_tx_ltbuser_abonummer_zeichen_act', 'inputfield_tx_ltbuser_abonummer_zeichen_max');
	initKeyCounter('inputfield_tx_ltbuser_anzahlltb', 30, 'inputfield_tx_ltbuser_anzahlltb_zeichen_act', 'inputfield_tx_ltbuser_anzahlltb_zeichen_max');
	initKeyCounter('inputfield_tx_ltbuser_ltbseit', 30, 'inputfield_tx_ltbuser_ltbseit_zeichen_act', 'inputfield_tx_ltbuser_ltbseit_zeichen_max');
	initKeyCounter('inputfield_comments', 255, 'inputfield_comments_zeichen_act', 'inputfield_comments_zeichen_max');
	initKeyCounter('inputfield_tx_ltbuser_lieblingsltb', 255, 'inputfield_tx_ltbuser_lieblingsltb_zeichen_act', 'inputfield_tx_ltbuser_lieblingsltb_zeichen_max');
	initKeyCounter('inputfield_tx_ltbuser_ltbweil', 255, 'inputfield_tx_ltbuser_ltbweil_zeichen_act', 'inputfield_tx_ltbuser_ltbweil_zeichen_max');
	initKeyCounter('inputfield_tx_ltbuser_hobbies', 255, 'inputfield_tx_ltbuser_hobbies_zeichen_act', 'inputfield_tx_ltbuser_hobbies_zeichen_max');
	
	initKeyCounter('tx_cagtsf_grusstext', 160, 'gruessen_zeichen_act', 'gruessen_zeichen_max');
	
	initKeyCounter('inputfield_blogkommentar', 750, 'inputfield_blogkommentar_zeichen_act', 'inputfield_blogkommentar_zeichen_max');
	
	initKeyCounter('inputfield_usergallery_title', 35, 'inputfield_usergallery_title_zeichen_act', 'inputfield_usergallery_title_zeichen_max');
	initKeyCounter('inputfield_usergallery_descr', 250, 'inputfield_usergallery_descr_zeichen_act', 'inputfield_usergallery_descr_zeichen_max');
	
	initKeyCounter('tx_srsendcard_pi1_card_message', 380, '', '');
	initKeyCounter('tx_srsendcard_pi1_from_name', 30, '', '');
	initKeyCounter('tx_srsendcard_pi1_from_email', 30, '', '');
	initKeyCounter('tx_srsendcard_pi1_to_name', 30, '', '');
	initKeyCounter('tx_srsendcard_pi1_to_email', 30, '', '');
	
	// newsletter link target
	$('iframe').contents().find('a').click(function() {
		var hrefArray = $(this).attr('href').split('#');
		if(hrefArray.length == 1) {
			$(this).attr('target', '_top');
		}
		else if(hrefArray.length == 2
			&& (hrefArray[1].match('news-'))) {
				$(this).attr('target', '_top');
		}
	});
});


















