( function( $ ) {
	$(document).ready(function(){

		/* erweiterte Suche */
    $('#extsearch').click(function(){
        if($('#extsearchbox').height() != "20")
        $('#extsearchbox').animate({height:"20px",width:"100%"},500);
        else
        $('#extsearchbox').animate({height:"160px",width:"100%"},500);
    });     


    /* Varianten */
    $('#mastervariants').change(function(){
          var currentid = $('#currentid').val();
          
          var newid = $('#mastervariants').val();
          
          $('#anid').attr('value', newid);
          
          //hide all SubVariant Stuff
          $('#subvarname').css({'display':'none'});
          $('#subvariants').find('select').css({'display':'none'});
          
          //show subvariants
          if( $('#subvariants_' + newid ).val() ) {
            $('#subvarname').css({'display':'inline'});
            $('#subvariants_' + newid ).css({'display':'inline'});
          }
          
          $('#mgvariantform').submit();
	  });
	  
	  $('#subvariants').find('select').change(function(){
	        var newid = $('#subvariants').find('select:visible').val();
          
          $('#anid').attr('value', newid);
          $('#mgvariantform').submit();
	  });	      

    /* Warenkorb oben rechts */
		$('#MiniBasketBox').mouseover(function(){
	        $('#BasketRollOut').slideDown();
    });
    	
    $('#BasketRollOut').mouseleave(function(){
        $('#BasketRollOut').slideUp();
    });
    	
		$('#MiniBasketBox').find('a[href="'+document.location.href+'"]')
	    .css({'font-weight':'Bold'}).addClass('Blue')
	    .parent().parent().parent().addClass('LinkActive');
		
  
    	
		/* Kategoriefilter */
    $('#catfilter').click(function(){
        if(!$('#listfilter').is(':hidden') ) {
          $('#listfilter').slideUp();
          $('#updown').removeClass('open');
        } else {
          $('#listfilter').slideDown("slow");
          $('#updown').addClass('open');
        }
    	});
      
    /* Sortierung */
    $('#listorderby_Top').change(function(){
        $('#_listsort_Top').submit();
    });
    
    $('#listorderby_Bottom').change(function(){
        $('#_listsort_Bottom').submit();
    });
    
    $('#sortupdown_Top').click(function(){
        $('#_listsort_Top').submit();         
    });
    
    $('#sortupdown_Bottom').click(function(){
        $('#_listsort_Bottom').submit();         
    });                          
    	

		$('.NaviHeadBox').children('.Link').not('.LinkActive').not('.MiniBasketRight')
 		    .mouseover(function(){
	            $(this).css({'cursor':'pointer'})
	            .children().css({'color':'#fff','text-decoration':'none'});
    	    })
		    .mouseout(function(){
	            $(this).not('.LinkActive').css({'cursor':'auto'})
	            .children().css({'color':'#000','text-decoration':'none'});
    	    })
    	    /*
          .click(function(){
	            window.location = $(this).children().attr('href');
    	    })
    	    */
   	        .find('a[href="'+document.location.href+'"]')
            .parent().addClass('LinkActive');

		$('#NaviLeftBox').find('a[href="'+document.location.href+'"]')
		    .css({'font-weight':'Bold'}).addClass('Blue')
		    .parent().addClass('LinkActive');

		
		$('.BasketStepLinkIt').not('.jQActive')
		    .mouseover(function(){
	            $(this).css({'cursor':'pointer'}).addClass('OrderStepOsActive');
    	    })
		    .mouseout(function(){
	            $(this).css({'cursor':'auto'}).addClass('OrderStep').removeClass('OrderStepOsActive');
		    })
 		    .click(function(){
                window.location = $(this).children().attr('href');
	        });


		LastProductListBoxes('#StartNA');
		LastProductListBoxes('#StartTS');
		LastProductListBoxes('#ArticleList');
		
	});

} ) ( jQuery );

function LastProductListBoxes(BoxID) {
	if($(BoxID).children('.ProductBoxesMedium').length %2 == 0){
		$(BoxID).children('.ProductBoxesMedium').slice(-2).css({'border-bottom':'0px'});
	}
	else{
		$(BoxID).children('.ProductBoxesMedium').slice(-1).css({'border-bottom':'0px'});
	}
}

/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* All about Scroling Boxes
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

$(document).ready(function() {
	var LspBoxesAmount = jQuery('div[id^="LSPBox"]').size();
	for ( var i=1; i<=LspBoxesAmount;i++  )
	{
		if( i > 1 )
		{
		   	$('#LSPBox'+i).animate({width:"105px",opacity: 0.45},300);
		}
		if( i == LspBoxesAmount )
		{
		   	$('#LSPBox'+i).css('border-right','1px solid RGB(200,200,200)');
		
		}
	}
});

$(document).ready(function() {
	var LspBoxesAmount = jQuery('div[id^="ProCrsBox"]').size();
	for ( var i=1; i<=LspBoxesAmount;i++  )
	{
		if( i > 1 )
		{
		   	$('#ProCrsBox'+i).animate({width:"105px",opacity: 0.45},300);
		}
		if( i == LspBoxesAmount )
		{
		   	$('#ProCrsBox'+i).css('border-right','1px solid RGB(200,200,200)');
		}
	}
});

function ShowZihaBox(MyID,BoxName)
{
	var CatBoxesAmount = jQuery('div[id^="'+BoxName+'"]').size();

	for ( var i=1; i<=CatBoxesAmount;i++  )
	{
		if( BoxName+i != MyID )
		{
		   	$('#'+BoxName+i).animate({width:"105px",opacity: 0.45},300);
		}
	}

   	$('#'+MyID).animate({width:"220px",opacity: 1},300);
}

/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* All about Inputfields
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */

function deleteText(id,std)
{
	if(document.getElementById(id).value == std )
	{
		document.getElementById(id).value='';
	}

}

function changePasswdField(fieldaid,fieldbid)
{
	document.getElementById(fieldaid).style.display = 'none';
	document.getElementById(fieldbid).style.display = 'block';
	document.getElementById(fieldbid).focus();
}

function activateCheckBox(myid)
{
	document.getElementById(myid+'_Hidden').value = '1';
	document.getElementById(myid+'_Img').src      = '/out/mystyle/img/CkeckBoxB.png';
	document.getElementById(myid+'_Link').href    = 'javascript:deactivateCheckBox(\''+myid+'\');';
}

function deactivateCheckBox(myid)
{
	document.getElementById(myid+'_Hidden').value = '';
	document.getElementById(myid+'_Img').src      = '/out/mystyle/img/CkeckBoxA.png';
	document.getElementById(myid+'_Link').href    = 'javascript:activateCheckBox(\''+myid+'\');';
}

/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* All about Rating
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */


function ShowStars(get)
{
      for (i=1;i<=get;i++)
      {
	      document.getElementById('Star'+i).src='/out/mystyle/img/StarActiv.png';
      }

	for (i=get+1;i<=5;i++)
	{
	      document.getElementById('Star'+i).src='/out/mystyle/img/StarDeactiv.png';
	}
}

function HideStars()
{
	for (i=1;i<=5;i++)
	{
		document.getElementById('Star'+i).src='/out/mystyle/img/StarDeactiv.png';
	}
}

function sjhUpdateRating(get)
{
	document.getElementById('artrating').value=get;

	for (i=1;i<=get;i++)
	{
	      document.getElementById('Star'+i).onmouseout='';
	}
	
	for (i=get+1;i<=5;i++)
	{
	      document.getElementById('Star'+i).src='/out/mystyle/img/StarDeactiv.png';
	}
	
}

/* Passwort hilfe */
function changePasswortStatus() {
  var pw = document.getElementById('test_lgn_pwd').value;

  if(pw.length < 6) status = 'red';
  else if(pw.length >= 6 && pw.length < 9) status = 'orange';
  else if(pw.length >= 9) status = 'green';
  
  document.getElementById('pwd_state').className = 'pwStatus '+status;    
}






