/////////////////////////
/* DOM-READY           */
/////////////////////////

$(function() {


    var i;
    for (i in document.images) {
        if (document.images[i].src) {
            var imgSrc = document.images[i].src;
            if (imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG') {
                document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
            }
        }
    }

    //HIDE ALL THAT SHOULD BE HIDDEN
    $(".hidden").hide();

    // External Links Wrapper for Valid XHTML
    $('a[rel*=external]').live("click", function(event) {
		window.open(this.href);
		return false;
	});

	// open and close content of boxes
	$("a.boxHeadingLink").click(function(event) {

	    event.preventDefault();
		$(this).parent().next("div.boxContent").slideToggle('slow');

		/*
	    $("div.boxContent").each(function(){
	       $(this).slideUp("slow");
	    });

	    $("a.boxHeadingLink").each(function(){
	       $(this).removeClass('boxHeadingLinkActive');
	    });
	    */

	  	//event.preventDefault();
		//$($(this).attr("href")).slideToggle("slow");
		$(this).addClass('boxHeadingLinkActive');
	});

    //open and close content of boxes
	$("a.boxHeadingLinkAll").click(function(event) {

	    $("div.boxContent").each(function(){
	       $(this).slideUp("slow");
	    });

	    event.preventDefault();


	    if ($(this).hasClass('boxHeadingLinkAllActive')) {

	        console.log('test');
	        //$($(this).attr("href")).slideUp("slow");
	        $(this).removeClass('boxHeadingLinkAllActive');

	    } else {

	        $($(this).attr("href")).slideDown("slow");
	        $("a.boxHeadingLinkAll").each(function(){
    	       $(this).removeClass('boxHeadingLinkAllActive');
    	    });
    	    $(this).addClass('boxHeadingLinkAllActive');

	    }

	});

	$("#select_versand").change(function() {
         this.form.submit();
    });

});
