$(document).ready( function() {

	/*===========================
	*
	* Date Created: 07/08/2010
	* Last Update: 19/07/2011
	* Source: -
	* Description: -
	*
	*===========================*/

	$("p:last-child").addClass('last-child');
	
	// STELLENANGEBOTE
	if ( $('.tx-powermail-pi1').length ) {		
		$('.tx_powermail_pi1_fieldwrap_html label').each(function() {			
			if ( $( 'span', this ).hasClass('powermail_mandatory') ) {
				$( this ).addClass('mandatory');
			}			
		});		
	}		

	// CLEAR INPUT FIELD
	$('.setclear').each(function() {
		var default_value = this.value;
		$(this).focus(function(){
			if(this.value == default_value) {
				this.value = '';
			}
		});

		$(this).blur(function(){
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	
	
	if ( $( '.news-list' ).length) {
		$( '.news-list' ).hover( function () {
			$(this).addClass("list-hover");
		},function () {
			$(this).removeClass("list-hover");
		});
	}
	

	$('table.app td').live('mouseover', function(){
    $(this).parent().addClass('hover')
	}).live('mouseout', function(){
    $(this).parent().removeClass('hover');
	});

	$('.mainnavi ul').each(function(index) {
		var jC = $(this).children('li');
		$(this).children('li:eq(5)').css({'border-bottom':'1px solid #F3F2F2'})
		if(jC.length > 6) {
			var jLi = $(this).children('li:eq(5)');
			var jLis = jLi.nextAll('li');
			var jOl = $('<ul class="sec"/>').append(jLis);
			jLi.parent().after(jOl);
		}
	});

	/*$('.mainnavi ul.level1 li.active a').click(function(){
		return false;
	});

	$('.mainnavi a.current').click(function(){
		return false;
	});*/


	$(".c-post-europe").change(function() {
		$(this).submit()
	})
	$(".c-post-world").change(function() {
		$(this).submit()
	})


	/*===========================
	*
	* Date Created: 07/08/2010
	* Last Update: 10/08/2010
	*	Source: http://www.prismstudio.co.uk/plugins/stylish-select/0.4/
	* Description: Stylish Select
	*
	*===========================*/

	if ($('.c-select').length) {
	//$('.c-select').sSelect();
	}
	
	if ($('.tx-powermail-pi1').length) {
		$('.tx-powermail-pi1 select').sSelect();		
	}

	/*===========================
	*
	* Date Created: 10/08/2010
	* Last Update: 10/08/2010
	*	Source: http://nivo.dev7studios.com/
	* Description: image slider
	*
	*===========================*/

	if ($('.slider').length) {
  	$('.slider').nivoSlider({
			effect:'fade',
			/*animSpeed:3000,
			pauseTime:5000,*/
			directionNav:false,
			directionNavHide:false,
			controlNav:false
		});
  }

	/*===========================
	*
	* Date Created: 03/08/2010
	* Last Update: 03/08/2010
	*	Source: http://css-tricks.com/simple-jquery-dropdowns/
	* Description: simply dropdown
	*
	*===========================*/

	var config = {
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
		interval: 200,  // number = milliseconds for onMouseOver polling interval
		over: doOpen,   // function = onMouseOver callback (REQUIRED)
		timeout: 200,   // number = milliseconds delay before onMouseOut
		out: doClose    // function = onMouseOut callback (REQUIRED)
	};

  function doOpen() {
	  $(this).addClass("hover");
	  //$('ul:first',this).css('visibility', 'visible');
	  $('ul',this).css('visibility', 'visible');
  }

  function doClose() {
	  $(this).removeClass("hover");
	  //$('ul:first',this).css('visibility', 'hidden');
	  $('ul',this).css('visibility', 'hidden');
  }

 //$(".mainnavi li").hoverIntent(config);


	/*===========================
	*
	* Date Created: 07/08/2010
	* Last Update: 07/08/2010
	*	Source: http://nyromodal.nyrodev.com/
	* Description: nyroModal
	*
	*===========================*/

	if ($('a.openform').length) {
  	$('a.openform').nyroModal({
  		bgColor: 'transparent',
  		width: 392,
  		height: 540,
  		closeButton: ''
  	});
  }

});
