//var $j = jQuery.noConflict();

$(document).ready(function(){

	
	$('#countries').hide();
	$('#countries_select').toggle(function(){
		$('#countries').show();
	},
	function () {
		$('#countries').hide();
	});
	

    if ($.browser.mozilla || $.browser.opera) {
	    $('.fp_jteaser_acc_content').fadeOut('fast');
	    $('.fp_jteaser_header_animated').children('h1').addClass("not_selected");
	    $('.fp_jteaser_header_animated').addClass('cursor');
	    $('.fp_jteaser_header_animated').click(function(){
	        $(this).next('.fp_jteaser_acc_content').slideToggle('slow');
	        $(this).children('h1').toggleClass("selected");
	    });
	    $('.fp_jteaser').corner('20px');
    	
    }
    
    if ($.browser.msie) {
        if ($.browser.version == '7.0') {
            $('.fp_jteaser_acc_content').fadeOut('fast');
		    $('.fp_jteaser_header_animated').children('h1').addClass("not_selected");
		    $('.fp_jteaser_header_animated').addClass('cursor');
		    $('.fp_jteaser_header_animated').click(function(){
		        $(this).next('.fp_jteaser_acc_content').slideToggle();
		        $(this).children('h1').toggleClass("selected");
		    });
		    $('.fp_jteaser').corner('20px');
		    
        }
        if ($.browser.version == '6.0') {
			$('.fp_jteaser').corner('20px');
        }
    }

    
    $('div.is_closed').hide();
    $('b.NodeSwitcher img').hide();
    $('b.NodeSwitcher img.active').show();
    
    $('b.NodeSwitcher').click(function(){
        var myNode = $(this).children('input').val();
        var actThis = this;
        var SR = $('div#' + myNode).attr('class').search(/is_open/);
        if (SR != -1) {
            $(this).children('img.minus').hide();
            $(this).children('img.O2C').show();
            $('div#' + myNode).removeClass('is_open');
            $('div#' + myNode).addClass('is_closed');
            window.setTimeout(function(){
                $(actThis).children('img.O2C"').hide();
                $(actThis).children('img.plus').show();
            }, 1200);
        }
        else {
            $(this).children('img.plus').hide();
            $(this).children('img.C2O').show();
            $('div#' + myNode).removeClass('is_closed');
            $('div#' + myNode).addClass('is_open');
            window.setTimeout(function(){
                $(actThis).children('img.C2O').hide();
                $(actThis).children('img.minus').show();
            }, 1200);
        }
        var duration = $('div#' + myNode).children('div[@class$=_Level_Item]').size() * 100;
        if (duration < 300) {
            duration = 300
        };
        $('div#' + myNode).toggle(duration);
    });
    	
	$('.cleanupSelection option').not('option:selected').remove();
	$('.cleanupSelection option:selected').removeAttr('selected');
    $(".sortMe").sortOptions();
 
 $('.Produkts').hide();
   $('.ProduktBarProdukt').hover(function(){
   	  $('.Produkts').hide();
   	$(this).next('.Produkts').fadeIn(1000);
  	},
   	function(){
     	
   });
   $(".Produkts").mouseout(function(){
         $(this).hide();
       }).mouseover(function(){
         $(this).show();
       });

 $('.additional_pdf_content').hide();
 $('.additional_pdf').click(function(){
 	$('.additional_pdf_content').toggle(1000);
 });
 
 
 $('.anfrage_toggle').click(function() {
 			$('#anfrage_dialog').dialog('open');
 });

 
 $(function() {
 		$("#anfrage_dialog").dialog({
			autoOpen: false,
 			bgiframe: true,
 			height: 800,
 			width: 750,
 			position: top,
 			modal: true,
 			open: function() {
			     $("#anfrage_dialog").load("/layout/set/anfrage/content/view/full/2585/"); 
			     }
 			

 		});
  });
 


 
 
 });



function Numsort(a, b){
    return a - b;
}


/*
 *
 * Produktgruppen Slider Effekt Anfang
 *
 */
function mySlider(firstItem, lastItem){
    allItems = $('.mySliderItem');
    $('.mySliderItem').each(function(i){
    
        if (i < firstItem || i > lastItem) {
            $(this).hide();
        }
    });
    mySliderSet(firstItem, lastItem)
}

function mySliderSet(firstItem, lastItem){
    $('div.scrollNext').unbind();
    $('div.scrollPrev').unbind();
    if (firstItem <= 0) {
        $('div.scrollPrev').hide();
    }
    else {
        $('div.scrollPrev').show();
        $('div.scrollPrev').click(function(){
            mySlideScrollerPrev(firstItem - 1, lastItem);
        });
    }
    
    if (lastItem + 1 >= $('.mySliderItem').size()) {
        $('div.scrollNext').hide();
    }
    else {
        $('div.scrollNext').show();
        $('div.scrollNext').click(function(){
            mySlideScrollerNext(firstItem, lastItem + 1);
        });
    }
}

function mySlideScrollerPrev(firstItem, lastItem){
    $(allItems[lastItem]).animate({
        width: '0'
    }).animate({
        opacity: 'hide'
    });
    $(allItems[firstItem]).animate({
        width: '240'
    });
    mySliderSet(firstItem, lastItem - 1);
}

function mySlideScrollerNext(firstItem, lastItem){
    $(allItems[firstItem]).animate({
        width: '0'
    }).animate({
        opacity: 'hide'
    });
    $(allItems[lastItem]).animate({
        width: '240'
    });
    mySliderSet(firstItem + 1, lastItem);
}




//		$.ajax({
// 		  url: "/layout/set/anfrage/content/view/full/2585/",
// 		  cache: false,
// 		  beforeSend: function(){
//		  	$(".anfrage_toggle").append("#loading");
// 		  	},
// 		  success: function(html){
// 		  	$(".loading").hide();
 //		    $('body').append("<div id='anfrage_modal_div'>");
 //		    $('#anfrage_modal_div').append(html);
 //		    //$("#anfrage_modal_div").hide();
 //		    //$("#anfrage_modal_div").fadeIn(1000);
 //		  }
 //		});
 //
 
 //function ladeDaten(lD){
//	 $.ajax({
//	 	url: "/layout/set/anfrage/content/view/full/2585/",
//	 	cache: false,
//	 	success: function(html){
//	 		$("#anfrage_dialog_inhalt").append(html);
//}