/**
* @author hmmh multimediahaus ag.
*/

var o = new Array();

$(document).ready(function(){



 

  
		
		
	// Buttonhack - Button koennen jetzt auch links sein ;)
	$("button.link").click(function(){
		document.location.href = $(this).attr("href");
		return false;
	})

	// script for superfish
	$(".noindent").superfish( { delay : 0 } ).find(">li[ul]").mouseover(function() {
		$("ul", this).bgIframe({opacity:false});
	}).find("a").focus(function(){
		$("ul", $(".noindent>li[ul]")).bgIframe({opacity:false});
	});
	// superfish finished

	//	initImageScroller();

	$.ifixpng('/is-bin/intershop.static/WFS/Apart-ApartDe-Site/-/de_DE/imagesOnline/pixel.gif');

    $('img[@src$=.png]').ifixpng();



    $("#hilfeselect").change(function(){
        var hideAll = $("#help1,#help2,#help3,#help4,#help5,#help6,#help7,#help8,#help9").css({display: "none"});
        var part = this.options[this.selectedIndex].value;
        show(part);
    });

    /** hmmh multimediahaus ag **/
	// toggle-funktionen in der Loginstrecke
	
	
	$('.change').click( function () {
if ( $(this).hasClass('change-active') ) {
$('.change').removeClass('change-active'); 
}
else {
$('.change').removeClass('change-active'); 
$(this).toggleClass('change-active'); 
}
refid = this.id;
ref = '.editblock.' + refid; 
if ( $('.editblock').hasClass('activeedit') ) {
elem = $('.editblock.activeedit');
elem.slideUp('slow', function () {
elem.removeClass('activeedit');
if ( !(elem.hasClass(refid)) ) {
$(ref).slideDown('slow', function () {
$(ref).addClass('activeedit');
});
}
});
}
else {
$(ref).slideToggle('slow', function () {
$(ref).toggleClass('activeedit');
});
}
return false;
});

	
	$('.lostpwd').click( function () { //.change
		/*if ( $(this).hasClass('change-active') ) {
			$('.lostpwd').removeClass('change-active');	
		}
		else {
			$('.lostpwd').removeClass('change-active');	
			$(this).toggleClass('change-active');	
		}*/
		refid = this.id;
		ref = '.lostblock.' + refid; //editblock
		if ( $('.lostblock').hasClass('activeedit') ) {
			elem = $('.lostblock.activeedit');
			elem.slideUp('slow', function () {
				elem.removeClass('activeedit');
				if ( !(elem.hasClass(refid)) ) {
					$(ref).slideDown('slow', function () {
						$(ref).addClass('activeedit');
					});
				}
			});
		}
		else {
			$(ref).slideToggle('slow', function () {
				$(ref).toggleClass('activeedit');
			});
		}
		return false;
	});
	// toggle ende
	/** END hmmh multimediahaus ag **/

	// preloading der Produktbilder 
	$.preload( '.articleRollover a img', { 
		threshold:2,
		onFinish:function(){
		    $('.articleRollover').each(function(i) {
		        minus_left = 0;
		        plus_width = 0;
		        minus_top = 0;
		
		        if($.browser.msie) {
		            minus_left = 1;
		            plus_width = 10;
		            minus_top = 97;
		        }
		
		        offset = $('img', this).offset();
		        $('span', this).css('position', 'absolute');
		        $('span', this).css('left', offset.left - minus_left);
		        $('span', this).css('width', $('img', this).width() - parseInt($('span', this).css('padding-right')) - parseInt($('span', this).css('padding-left')) + plus_width);
		        $('span', this).css('top', offset.top + $('img', this).height() - $('span', this).height() - parseInt($('span', this).css('padding-bottom')) - parseInt($('span', this).css('padding-top')) - minus_top);
		
		        $('img', this).bind('mouseover', function() {
		            x = $(this).parent().parent();
		            $('span', x).css('visibility', 'visible');
		        } );
		
		        $('img', this).bind('mouseout', function() {
		            x = $(this).parent().parent();
		            $('span', x).css('visibility', 'hidden');
		        });
		
		        $('span', this).bind('mouseover', function() {
		            x = $(this).parent();
		            $('span', x).css('visibility', 'visible');
		        } );
		
		        $('span', this).bind('mouseout', function() {
		            x = $(this).parent();
		            $('span', x).css('visibility', 'hidden');
		        });
		    });
		}
	});
	// preloading ende
	    
	$('#accordion').Accordion(  {
        active: '.open',
        alwaysOpen: true,
        selectedClass: 'open',
        header: '.button',
        event: 'click',
        animated: false
    });
    
    $('#accordion a').each(function (i) {
        $(this).bind('click', function() {
           a = this;
           window.setTimeout(function(n) {
               if(a.href != 'undefined') {
                   
                   /* PLEASE INSERT THE AJAX-CALL FOR UPDATING
                   THE CONTENT-DIV WHITH NEW INTRO-CONTENT HERE 
                   AND COMMENT THE NEXT LINE OUT*/
                    location.href = a.href;
               }
           }, 300);
        });
    });

	/* Login-Formular-Tooltips */
	$('.ttip').tooltip({
		bodyHandler: function() {
			node = $(this).attr("id");
			return $('#tt-' + node).html();
		},
		showURL: false,
		track: false,
		delay: 0,
//		event: "click", 
		opacity: 0.0,
//		showBody: " - ",
		top: 15,
		left: 50
	});
	

	
//	$('a.ttip').click(function(){
//		return false;
//	});
	// Tooltips ende
	// Datum-Felder Sprungfunktion
	$("#nk_gebd").keyup(function(){
		if (this.value.length >= 2 && $(this).valid()) {
			$("#nk_gebm").focus();
		}
	});
	$("#nk_gebm").keyup(function(){
		if (this.value.length >= 2 && $(this).valid()) {
			$("#nk_geby").focus();
		}
	});
	$("#lh_gebd").keyup(function(){
		if (this.value.length >= 2 && $(this).valid()) {
			$("#lh_gebm").focus();
		}
	});
	$("#lh_gebm").keyup(function(){
		if (this.value.length >= 2 && $(this).valid()) {
			$("#lh_geby").focus();
		}
	});
	$("#lw_gebd").keyup(function(){
		if (this.value.length >= 2 && $(this).valid()) {
			$("#lw_gebm").focus();
		}
	});
	$("#lw_gebm").keyup(function(){
		if (this.value.length >= 2 && $(this).valid()) {
			$("#lw_geby").focus();
		}
	});




});

function toogleForms(el){
$(document).ready(function(){
	// toggle-funktionen in der Loginstrecke
	el.click( function () {
		if ( $(this).hasClass('change-active') ) {
			$('.change').removeClass('change-active');	
		}else {
			$('.change').removeClass('change-active');	
			$(this).toggleClass('change-active');	
		}
		refid = this.id;
		ref = '.editblock.' + refid; 
		if ( $('.editblock').hasClass('activeedit') ) {
			elem = $('.editblock.activeedit');
			elem.slideUp('slow', function () {
				elem.removeClass('activeedit');
				if ( !(elem.hasClass(refid)) ) {
					$(ref).slideDown('slow', function () {
						$(ref).addClass('activeedit');
					});
				}
			});
		}else {
			$(ref).slideToggle('slow', function () {
				$(ref).toggleClass('activeedit');
			});
		}
		});
		// toggle ende
	});
}

function closeAllForms()
{
  if ( jQuery('.editblock').hasClass('activeedit') )
  {
    elem = jQuery('.editblock.activeedit');
    elem.slideUp('slow', function ()
    {
      elem.removeClass('activeedit');
      /*if ( !(elem.hasClass(refid)) )
      {
        jQuery(ref).slideDown('slow', function () {
        jQuery(ref).addClass('activeedit');
	    });
      }*/
    });
  }
}

function showError(Message)
{
  if(jQuery('#econ #econtainer'))
  {
    jQuery('#econ #econtainer').html(Message);
  }
}

function clearDefault(el) {
    if (el.defaultValue==el.value) el.value = ""
}

function gotoDiv(viewDiv){
    var hideAll = $("#help1,#help2,#help3,#help4,#help5,#help6,#help7,#help8,#help9").css({display: "none"});
    show(viewDiv);
};

function gotoDiv2(viewDiv){
    var hideAll = $("#mesure1,#mesure2,#mesure3,#mesure4,#mesure5,#mesure6,#mesure7").css({display: "none"});
    show(viewDiv);
};

var pop = null;

function popdown() {
    if (pop && !pop.closed) pop.close();
}

// <a href="html-or.jpg" onclick="return popup(this,123,456)" title="..."
// or
// <a href="html-or.jpg" onclick="return popup(this)" title="..."

function popup(obj,w,h) {
    var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
    if (!url) return true;
    w = (w) ? w += 20 : 150;  // 150px*150px is the default size
    h = (h) ? h += 25 : 150;
    var args = 'width='+w+',height='+h+',scrollbars=yes';
    popdown();
    pop = window.open(url,'',args);
    return (pop) ? false : true;
}

function show(ele) {
    var srcElement = document.getElementById(ele);
    if(srcElement != null) {
        if(srcElement.style.display == "block") {
            srcElement.style.display= 'none';
        }
        else {
            srcElement.style.display='block';
        }
        return false;
    }
	return
}

function showFonField2(id1,id2){
	$(document).ready(function(){
		$("#"+ id1).slideToggle("slow",$("#"+ id2).slideToggle("slow"));
		$("#morefon").css("display","none");
		$("#morefon2").css("display","block");
	});
	return false;
}

function showFonField3(id1,id2){
	$(document).ready(function(){
		$("#"+ id1).slideToggle("slow",$("#"+ id2).slideToggle("slow"));
		$("#morefon2").css("display","none");
	});
	return false;
}
