var switchacount = "0";
var switchbasket = "0";
var $normalbasketsize = 250;
var $count = 0;
var $hmbi = 0;


	// TAGS 
	
	function chng_tagsubvalue() {
		newtagname = $('#newtagname').attr('value');
		newtagname = '  ' + newtagname;
		$('#newtagname').attr('value',newtagname);
		alert($('#newtagname').attr('value'));
		$('#tagform').submit();
	}

function basketitems($count) {
	$hmbi = $count * 90;
	$normalbasketsize = $normalbasketsize + $hmbi;
}

	function rastermeonoff() {
		$("#rasterme").toggle("slow");
	}

function rastermeopacity() {
	myopacity = $('#opacity').attr('value');
	myopacity = myopacity / 100;
	$("#rasterme").css("opacity",myopacity);
}
	
$(document).ready(function slideout() {
	$('.oldtree li ul li.oldactivetree').parent().parent().addClass('oldactivetree');
	$('.oldtree li ul li.oldactivetree').parent().parent().parent().parent().addClass('oldactivetree');
	$('.tree li ul li ul li.aktuell').parent().parent().parent().parent().addClass('aktuell');
	$('.tree li ul li.aktuell').parent().parent().addClass('aktuell');
	
	// Fancybox for Contents
		$("a[@rel*=fancyvideo]").fancybox({
            overlayShow: true,
            frameWidth:640,
            frameHeight:360
        });
		
		$("a[@rel*=fancypicture]").fancybox({
            overlayShow: true,
            frameWidth:640,
            frameHeight:360
        });
	
	// CHECK CONTENT LINK AND SHOW IT 
		var mydomainname = $('#logo_woca 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%');
				biggersubmen = $('#left div#'+myonlyloc+' ul').size();
				//alert(myonlyloc+' '+biggersubmen); 
				if (biggersubmen == "0") {
					 $('#left div#'+myonlyloc).css('background','#455962');
					 $('#left div#'+myonlyloc+' a').css('color','#ffffff');
					//alert('färbe mich');
				 }
			}
			 
			if ($('#left div h2 a').hasClass(myonlyloc)) {
				$('#left div h2 a.'+myonlyloc).parent().addClass('withsub');
				$('#left div h2 a.'+myonlyloc).parent().parent().addClass('cm_open');
			}
		
		} 
		else {
				//alert( "extern NADA 1");
		}





	var test_RightLogin_Email = 'Email oder Kundennr.';
	var test_RightLogin_Pwd = 'passwort';
	var searchparam = 'Holzart/Parkettart/Sortierung';
	var url= $('#logo_woca 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:'150px'},300);  
			$("#head-account img").attr('src',url+'/out/woca/src/bg/closeslidedown.png')
			switchacount = "1";
		}
		else {
			$("#header_account").css("overflow","hidden");
			$("#header_account").animate({height:'97px'},300);
			$("#head-account img").attr('src',url+'/out/woca/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',url+'/out/woca/src/bg/closeslidedown.png')
			switchbasket = "1";
		}
		else {
			$("#header_basket").css("overflow","hidden");
			$("#header_basket").animate({height:'97px'},300);
			$("#head-basket img").attr('src',url+'/out/woca/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);
		}
	});
	
	$('#search').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','/out/woca/src/bg/openslidedown.png');
				// Animation complete.
			  });
		}
		else {
			$('.left_white_box').animate({
				height: '36px',
			  }, 200, function() {
			  $('.left_white_box div img').attr('src','/out/woca/src/bg/openslidedown.png');
				// Animation complete.
			  });
			  
			  $('#'+slidepositionleft).animate({
				height: '100%',
			  }, 200, function() {
				$('#'+slidepositionleft+' div img').attr('src','/out/woca/src/bg/closeslidedown.png');
				// Animation complete.
			  });

			$('.left_white_box').removeClass('cm_open');
			$('#'+slidepositionleft).addClass('cm_open');
		}
	});
	$('#service .tree li').click(function() {
		$('#service .tree li').removeClass('aktuell');
		$(this).addClass('aktuell');
	});
	
	$('#Prospekte .tree li').click(function() {
		$('#Prospekte .tree li').removeClass('aktuell');
		$(this).addClass('aktuell');
	});
	
	$('#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;
		}
	});
	
	// singlebox opens links
		$('.mainsinglebox').click(function() {
			$(this).addClass('opennow');
			var newpros = $('.opennow h2 a').attr('href');
			location.href = newpros;
	});

	// DELUXE SLIDEOUT
	
	if ($('#header_account .login_btn').length == 0) {
		$('#header_account').mouseover(function() {
				//$("#header_account").css("overflow","visible");
				$("#header_account").stop().animate({height:'150px'},300);  
				$("#head-account img").attr('src','http://www.wocashop.de/out/woca/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.wocashop.de/out/woca/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.wocashop.de/out/woca/src/bg/closeslidedown.png')
			switchbasket = "1";
	})
	.mouseout(function() {
			$("#header_basket").stop().animate({height:'97px'},300);
			$("#head-basket img").attr('src','http://www.wocashop.de/out/woca/src/bg/openslidedown.png')
			switchbasket = "0";
	});
	
		
});


	
