

var switchacount = "0";
var switchbasket = "0";
var $normalbasketsize = 250;
var $count = 0;
var $hmbi = 0;


	function basketitems($count) {
		$hmbi = $count * 90;
		$normalbasketsize = $normalbasketsize + $hmbi;
	}
	
	function closeinfo() {
		$('.mynewdiv').remove();
	}
	
	function divloadcontent() {
		if ( !$(".mynewdiv").length ) {
			$('#content').append('<div class="mynewdiv">Lade Treuhand Informationen...</div>');
			$('#content').addClass('havediv');
		}
			$('.mynewdiv').show();
		$('.mynewdiv').load('http://www.bergundberg.de/Treuhandservice/ #mycontent', function() {
			$('.mynewdiv').append('<p><b><u><a href="#" onClick="closeinfo();">schliessen</a><u><b></p>');
			$('.mynewdiv').prepend('<p><b><u><a href="#" onClick="closeinfo();">schliessen</a><u><b></p>');
		});
	}
	
	function rastermeonoff() {
		$("#rasterme").toggle("slow");
	}
	
	
$(document).ready(function slideout() {	
	// CHECK CONTENT LINK AND SHOW IT 
		var mydomainname = $('#logo_bergundberg a').attr('href');
		var mylocation = $(location).attr('href');
		var myonlyloc = mylocation.split(mydomainname).join('');
		myonlyloc = myonlyloc.split('/').join('');
		//alert(myonlyloc.value+' - '+myonlyloc);
		if (typeof(myonlyloc) != 'undefined' && myonlyloc != '') {
			if ($('.tree li ul li').hasClass(myonlyloc)) {
				//do something
				$('.nosortmient .tree li').removeClass('aktuell');
				$('.tree li ul li.'+myonlyloc).parent().parent().addClass('aktuell');
				$('.tree li ul li.'+myonlyloc).parent().parent().parent().parent().addClass('cm_open');
				$('.tree li ul li.'+myonlyloc+' a').attr('style', 'font-weight: bold !important; color: #963A2A !important;');
			}
			else if ($('.tree li').hasClass(myonlyloc)) {
				//do something
				$('.tree li').removeClass('aktuell');
				$('.tree li.'+myonlyloc).addClass('aktuell');
				$('.tree li').parent().parent().removeClass('aktuell');
				$('.tree li.'+myonlyloc).parent().parent().addClass('cm_open');
				$('.tree li.'+myonlyloc+' a').css('color', '#ffffff'); 
			}
			else if ($('#left div h2').hasClass(myonlyloc)) {
				$('#left div').removeClass('cm_open');
				$('#left div h2.'+myonlyloc).parent().addClass('singleactivemaincat');
			}
			else if ($('#left div').hasClass(myonlyloc)) {
				$('#left div').removeClass('cm_open');
				$('#left div').removeClass('aktuell');
				$('#left div.'+myonlyloc).addClass('aktuell');
				$('#left div.'+myonlyloc).addClass('cm_open');
				$('#left div.'+myonlyloc).attr('style','height:100%');
			}

			
		
		} 


		
	var test_RightLogin_Email = 'Email oder Kundennr.';
	var test_RightLogin_Pwd = 'passwort';
	var searchparam = 'Holzart/Parkettart/Sortierung';
	var url= $('#logo_bergundberg a').attr('href');
	var myvalue;
	var myvaluenew;
	var myid;
	
	$('#head-account').click(function() {
		if (switchacount == "0") {
			$("#header_account").css("overflow","visible");
			$("#header_account").animate({height:'230px'},300);  
			$("#head-account img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/closeslidedown.png')
			switchacount = "1";
		}
		else {
			$("#header_account").css("overflow","hidden");
			$("#header_account").animate({height:'97px'},300);
			$("#head-account img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/openslidedown.png')
			switchacount = "0";
		}
	});
	
	$('#head-basket').click(function() {
		if (switchbasket == "0") {
			//$("#header_basket").css("overflow","visible");
			$("#header_basket").animate({height:$normalbasketsize},300);  
			$("#head-basket img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/closeslidedown.png')
			switchbasket = "1";
		}
		else {
			//$("#header_basket").css("overflow","hidden");
			$("#header_basket").animate({height:'97px'},300);
			$("#head-basket img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/openslidedown.png')
			switchbasket = "0";
		}
	});
	$('.ERROR_CLOSE').click(function() {
			$("#error_message").css("visibility","hidden");
			$(".error_box").css("visibility","hidden");
	});
	$('input[type=password]').focus(function() {
		myid = $(this).attr('id');
		myvalue = $(this).attr('value');
		$(this).attr('value','');
	}).blur(function() {
		myvaluenew = $('#'+myid).attr('value');
		if (myvaluenew == '') {
			$('#'+myid).attr('value', myvalue);
		}
	});
		$('input[type=text]').focus(function() {
			myid = $(this).attr('id');
			myvalue = $(this).attr('value');
			$(this).attr('value','');
		}).blur(function() {
			myvaluenew = $('#'+myid).attr('value');
			if (myvaluenew == '') {
				$('#'+myid).attr('value', myvalue);
			}
		});


	


	
	$('#test_OrderConfirmAGBTop').click(function() {
		if ( $('#test_OrderConfirmAGBTop').attr("checked") == true) {
			$('#test_OrderConfirmAGBBottom').attr("checked", "checked")
		}
		else {
				$('#test_OrderConfirmAGBBottom').attr("checked", "")
		}
	});
	
	$('#test_OrderConfirmAGBBottom').click(function() {
		if ( $('#test_OrderConfirmAGBBottom').attr("checked") == true) {
			$('#test_OrderConfirmAGBTop').attr("checked", "checked")
		}
		else {
				$('#test_OrderConfirmAGBTop').attr("checked", "")
		}
	});
	/* Left Side Clicks */
	$('.bigger_cm').click(function() {
		slidepositionleft = $(this).parent().attr("id");
		//alert('-'+slidepositionleft);
		if ($('#'+slidepositionleft).hasClass('cm_open')) {
			$('#'+slidepositionleft).animate({
				height: '36px',
			  }, 200, function() {
				$('#'+slidepositionleft).removeClass('cm_open');
				$('#'+slidepositionleft+' div img').attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/openslidedown.png');
				// Animation complete.
			  });
		}
		else {
			$('.left_white_box').animate({
				height: '36px',
			  }, 200, function() {
			  $('.left_white_box div img').attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/openslidedown.png');
				// Animation complete.
			  });
			  
			  $('#'+slidepositionleft).animate({
				height: '100%',
			  }, 200, function() {
				$('#'+slidepositionleft+' div img').attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/closeslidedown.png');
				// Animation complete.
			  });

			$('.left_white_box').removeClass('cm_open');
			$('#'+slidepositionleft).addClass('cm_open');
		}
	});
	$('#service .tree li').click(function() {
		if (!$(this).hasClass('onlyone')) {
			$('.onlyone').addClass('fontcolor');
		}
		else {
			$('.onlyone').removeClass('fontcolor');
			myclickclass = $(this).attr('class');
			myclickclass = myclickclass.replace( "onlyone ", "" ); 
			myclickclass = myclickclass.replace( "aktuell ", "" ); 
			myclickclass = '.' + myclickclass + ' p a';
			//alert(myclickclass);
			location.href = $(myclickclass).attr('href');
		}
		$('#service .tree li').removeClass('aktuell');
		$(this).addClass('aktuell');
	});
	
	/*$('#prospekte').click(function() {
		//$(this).addClass('opennow');
		//mainsingleboxlink = $('.opennow h2 a').attr('href');
		alert('test');
	}*/
	
	$('.mainsinglebox').click(function() {
			$(this).addClass('opennow');
			var newpros = $('.opennow a').attr('href');
			location.href = newpros;
	});
	
	$('#prospekte .tree li').click(function() {
		if (!$(this).hasClass('onlyone')) {
			$('#prospekte .tree li').removeClass('aktuell');
			$(this).addClass('aktuell');
		}
		else {
			$('.onlyone').removeClass('fontcolor');
			$(this).addClass('opennow');
			myclickclass = $(this).attr('class');
			myclickclass = myclickclass.replace( "onlyone ", "" ); 
			myclickclass = myclickclass.replace( "aktuell ", "" ); 
			myclickclass = '.' + myclickclass + ' a';
			//alert(myclickclass);
			var newpros = $('.opennow a').attr('href');
			//alert(newpros);
			location.href = newpros;
		}
	});
	
	$('#sortiment .tree li').click(function() {

		if ($(this).children().length <= 1) {
			$('.onlyone').removeClass('fontcolor');
			$(this).addClass('opennow');
			myclickclass = $(this).attr('class');
			myclickclass = myclickclass.replace( "onlyone ", "" ); 
			myclickclass = myclickclass.replace( "aktuell ", "" ); 
			myclickclass = '.' + myclickclass + ' a';
			var newpros = $('.opennow a').attr('href');
			location.href = newpros;
		}
	});

	
	// TEST FOR USABILITY
	
	if ($('#header_account .login_btn').length == 0) {
		$('#header_account').mouseover(function() {
				//$("#header_account").css("overflow","visible");
				$("#header_account").stop().animate({height:'230px'},300);  
				$("#head-account img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/closeslidedown.png')
				switchacount = "1";
		})
		.mouseout(function(){
				//$("#header_account").css("overflow","hidden");
				$("#header_account").stop().animate({height:'97px'},300);
				$("#head-account img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/openslidedown.png')
				switchacount = "0";	
		});
	}
	
	$('#header_basket.basketscrolldown').mouseover(function() {
			$("#header_basket").stop().animate({height:$normalbasketsize},300);  
			$("#head-basket img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/closeslidedown.png')
			switchbasket = "1";
	})
	.mouseout(function() {
			$("#header_basket").stop().animate({height:'97px'},300);
			$("#head-basket img").attr('src','http://www.bergundberg.com/out/bergundberg/src/bg/openslidedown.png')
			switchbasket = "0";
	});
	
});
