$(document).ready( function() {

	/*===========================
	*
	* Date Created: 21/09/2010
	* Last Update: 05/07/2011
	* Source: -
	* Description: -
	*
	*===========================*/
		
	$("p:last-child").addClass('last-child');
	
	// GET URL PARAMS
	$.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];
	}
	});
	
	// Get object of URL parameters
	var allVars = $.getUrlVars();

	// Getting URL var by its nam
	var mailid = $.getUrlVar('tx_powermail_pi1[mailID]');
	var multiple = $.getUrlVar('tx_powermail_pi1[multiple]');
	var send = $.getUrlVar('tx_powermail_pi1[sendNow]');
	
	var firstchar = '1';
	
	if( typeof(multiple ) !== 'undefined' && multiple  != null ) {
		firstchar = multiple.charAt(0);
	}
	
	/*
	 * AUSBLENDEN 
	 */	
	
	// INFOTEXT ÜBERHALB FORM
	if ( typeof(multiple ) === 'undefined' && multiple == null || firstchar == '1' ) {
		$('#c31161').show(); // GERMANY
		$('#c31536').show(); // ENGLISH GENERAL
		$('#c31719').show(); // AUSTRALIA
		$('#c31714').show(); // DEUTSCH #13521
		$('#c31764').show(); // ENGLISH #13533 
		$('#c31768').show(); // FRENCH #13534 
		$('#c31723').show(); // ENGLISH #13523 
		$('#c31727').show(); // ENGLISH #13524 
		$('#c31736').show(); // IN-INI #13526 
		$('#c31740').show(); // IN-INE #13527 
		$('#c31744').show(); // FRENCH #13528 
		$('#c31748').show(); // ITALIA #13529 
		$('#c31709').show(); // AUSTRIA #13520 
		$('#c31752').show(); // SINGAPORE #13530 
		$('#c31756').show(); // UK #13531 
		$('#c31760').show(); // USA #13532
		$('#c31781').show(); // CHINA #13532
		} else if ( typeof(multiple ) !== 'undefined' && multiple  != null ) {
		$('#c31161').hide(); // GERMANY
		$('#c31536').hide(); // ENGLISH GENERAL
		$('#c31719').hide(); // AUSTRALIA	
		$('#c31714').hide(); // DEUTSCH #13521
		$('#c31764').hide(); // ENGLISH #13533
		$('#c31768').hide(); // FRENCH #13534 
		$('#c31723').hide(); // ENGLISH #13523 
		$('#c31727').hide(); // ENGLISH #13524 
		$('#c31736').hide(); // IN-INI #13524 
		$('#c31740').hide(); // IN-INE #13527 
		$('#c31744').hide(); // FRENCH #13528 
		$('#c31748').hide(); // ITALIA #13529 
		$('#c31709').hide(); // AUSTRIA #13520 
		$('#c31752').hide(); // SINGAPORE #13530 
		$('#c31756').hide(); // UK #13531
		$('#c31760').hide(); // USA #13532
		$('#c31781').hide(); // CHINA #13532
	}
	
	// ANGABEN KORREKT
	if ( typeof(send) !== 'undefined' && send != null && send == '1' ) {
		$('#c31325').hide(); // GERMANY
		$('#c31534').hide(); // ENGLISH GENERAL
		$('#c31717').hide(); // AUSTRALIA				
	}
	
	// GERMANY #13226
	if ( $('.powermail_all').length ) {
		$('#c31161').hide();
	}
	if ( $('.tx-powermail-pi1_thx').length ) {
		$('#c31161').hide();
	}
		
	// ENGLISH GENERAL #13452
	if ( $('.powermail_all').length ) {
		$('#c31534').hide();
	}
	if ( $('.tx-powermail-pi1_thx').length ) {
		$('#c31534').hide();
	}
	
	// POWERMAIL UID: 13226
	$('.powermail_check_inner_uid11_0 input').change(function() {

		if ($(this).is(':checked')) {
            $( '#powermaildiv_uid55' ).show();
           $( '.powermail_check_inner_uid11_1' ).find('.error').remove();
           $( '.powermail_check_inner_uid11_2' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid11_3' ).find('.error').remove();  
           $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Bitte beachten:<br />Die Produkte einer zusätzlich ausgewählten Kategorie werden der Liste zugefügt.</p></div>');
         
        } else {
          	$( '#powermaildiv_uid55' ).hide();
          	$( '.powermail_check_inner_uid11_0' ).find('.error').remove();
        }
	});
	$('.powermail_check_inner_uid11_1 input').change(function() {
		if ($(this).is(':checked')) {
            $( '#powermaildiv_uid56' ).show();
             $( '.powermail_check_inner_uid11_0' ).find('.error').remove();
           $( '.powermail_check_inner_uid11_2' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid11_3' ).find('.error').remove(); 
            $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Bitte beachten:<br />Die Produkte einer zusätzlich ausgewählten Kategorie werden der Liste zugefügt.</p></div>');
        } else {
          	$( '#powermaildiv_uid56' ).hide();
          	$( '.powermail_check_inner_uid11_1' ).find('.error').remove();
        }
	});
	$('.powermail_check_inner_uid11_2 input').change(function() {
		if ($(this).is(':checked')) {
            $( '#powermaildiv_uid57' ).show();
             $( '.powermail_check_inner_uid11_0' ).find('.error').remove();
           $( '.powermail_check_inner_uid11_1' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid11_3' ).find('.error').remove(); 
            $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Bitte beachten:<br />Die Produkte einer zusätzlich ausgewählten Kategorie werden der Liste zugefügt.</p></div>');
        } else {
          	$( '#powermaildiv_uid57' ).hide();
          	$( '.powermail_check_inner_uid11_2' ).find('.error').remove();
        }
	});
	$('.powermail_check_inner_uid11_3 input').change(function() {
		if ($(this).is(':checked')) {
            $( '#powermaildiv_uid58,#powermaildiv_uid59' ).show();
             $( '.powermail_check_inner_uid11_0' ).find('.error').remove();
           $( '.powermail_check_inner_uid11_1' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid11_2' ).find('.error').remove(); 
            $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Bitte beachten:<br />Die Produkte einer zusätzlich ausgewählten Kategorie werden der Liste zugefügt.</p></div>');
        } else {
          	$( '#powermaildiv_uid58,#powermaildiv_uid59' ).hide();
          	$( '.powermail_check_inner_uid11_3' ).find('.error').remove();
        }
	});
	
	
	// POWERMAIL UID: 13452
	$('.powermail_check_inner_uid88_0 input').change(function() {	
	 if ($(this).is(':checked')) {
            $( '#powermaildiv_uid89' ).show();
           $( '.powermail_check_inner_uid88_1' ).find('.error').remove();
           $( '.powermail_check_inner_uid88_2' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid88_3' ).find('.error').remove();  
          $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Products of an additional selected category will be added to the list. </p></div>');
       } else {
          	$( '#powermaildiv_uid89' ).hide();
          	$( '.powermail_check_inner_uid88_0' ).find('.error').remove();
        }        
	});
	$('.powermail_check_inner_uid88_1 input').change(function() {	
	 if ($(this).is(':checked')) {
            $( '#powermaildiv_uid90' ).show();
          $( '.powermail_check_inner_uid88_0' ).find('.error').remove();
           $( '.powermail_check_inner_uid88_2' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid88_3' ).find('.error').remove();  
          $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Products of an additional selected category will be added to the list. </p></div>');
       } else {
          	$( '#powermaildiv_uid90' ).hide();
          	$( '.powermail_check_inner_uid88_1' ).find('.error').remove();
        }        
	});
	$('.powermail_check_inner_uid88_2 input').change(function() {	
	 if ($(this).is(':checked')) {
            $( '#powermaildiv_uid91' ).show();
          $( '.powermail_check_inner_uid88_0' ).find('.error').remove();
           $( '.powermail_check_inner_uid88_1' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid88_3' ).find('.error').remove(); 
           $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Products of an additional selected category will be added to the list. </p></div>');
       } else {
          	$( '#powermaildiv_uid91' ).hide();
          	$( '.powermail_check_inner_uid88_2' ).find('.error').remove();
        }        
	});
	$('.powermail_check_inner_uid88_3 input').change(function() {	
	 if ($(this).is(':checked')) {
            $( '#powermaildiv_uid92,#powermaildiv_uid93' ).show();
          $( '.powermail_check_inner_uid88_1' ).find('.error').remove();
           $( '.powermail_check_inner_uid88_2' ).find('.error').remove(); 
           $( '.powermail_check_inner_uid88_0' ).find('.error').remove(); 
           $(this).after('<div class="error hinweis" style="position:absolute;left:200px;top:-5px"><p>Products of an additional selected category will be added to the list. </p></div>');
       } else {
          	 $( '#powermaildiv_uid92,#powermaildiv_uid93' ).hide();
          	$( '.powermail_check_inner_uid88_3' ).find('.error').remove();
        }        
	});
	
	
	// ADD CLASS SITEMAP
	$('#footersitemap li.tx_bgmadvsitemap_level_1:last').addClass('last');
	$('#footersitemap li.tx_bgmadvsitemap_level_1:first').addClass('first');

	// 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;
			}
		});
	});
	
	// HOVER EFFECT
	$('.st').hover( function () {
		$(this).addClass("box-hover");
	},
	function () {
		$(this).removeClass("box-hover");
	});
	
	// BOXEN HOME CLICKABLE
	if ($('.st').length) {
		$('.st').each(function(){
			var strHref = $('.txt a', this).attr('href');
			//console.log(strHref);
			$(this).click(function(){
				if (strHref != '') {
					window.location.href = strHref;
				}
			});
		});
	}	
	
	
	// TAB MENU
	$('.tab-inner').hide();
	$('.tab-inner:first').show();
	$('.tabnavi li:first').addClass('active');

	$('.tabnavi li a').click(function() {
		$('.tabnavi li').removeClass('active');
		$(this).parent().addClass('active');
		var currentTab = $(this).attr('href');
		$('.tab-inner').hide();
		$(currentTab).show();
		return false;
	});	

	/*===========================
	*
	* Pluginname: Stylish Select Box 0.4.1
	* Date Created: 21/09/2010
	* Last Update: 21/09/2010
	* Source: http://plugins.jquery.com/node/12481
	* Description: -
	*
	*===========================*/
		
	if ($('.langdd').length) {
		$('.langdd').sSelect({
			ddMaxHeight: '187px'
		}).change(function(){
			var strHref = ( $('.langdd').getSetSSValue() );
			if ( strHref != '' ) {
				window.location.href = strHref;
			}
		});
	}
	
	/*===========================
	*
	* Date Created: 21/09/2010
	* Last Update: 21/09/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("over");
		$('ul',this).css('visibility', 'visible');
	}
	
	function doClose() {
		$(this).removeClass("over");
		$('ul',this).css('visibility', 'hidden');
	}
	
	if ( $(".mainnavi li").length > 0 ) {
		$(".mainnavi li").hoverIntent(config);
	}
	
	/*===========================
	*
	* Pluginname: Radiobutton & Checkbox replacement
	* Date Created: 21/09/2010
	* Last Update: 21/09/2010
	* Source: http://www.protofunc.com/scripts/jquery/checkbox-radiobutton/
	* Description: -
	*
	*===========================*/	
	
	$('#mailform input').checkBox();

});

