var addthis_config = {
     ui_language: "de"
};

$(document).ready(function(){

	var clearMePrevious = '';

	// clear input on focus
	$('.clearMeFocus').focus(function()
	{
		if($(this).val() == $(this).attr('title'))
		{
			clearMePrevious = $(this).val();
			$(this).val('');
		}
	});

	// if field is empty afterward, add text again
	$('.clearMeFocus').blur(function()
	{
		if($(this).val()== '')
		{
			$(this).val(clearMePrevious);
		}
	});
	
	$("#noJS").hide();

	// NAVIGATION ACCORDION
	jQuery('#navigationJQ').accordion({
		
		autoheight: false,
		alwaysOpen: false,
		active: '.selected'
		
		/*
		 * animated: "easeslide", navigation: true, collapsible: true, header:
		 * '.mainCat', selectedClass: 'selected'
		 */
		
	});
	
	// ganze SubCat als Link
	$('.sub_cat_item, .sub_cat_special_item').click( function() {
        document.location.href = $(this).find("a").attr("href");
    });
	
	// SubCat -> Linkfarbe aendern
	$(".sub_cat_item").hover(function(){

		$(this).children(".sub_cat_link").children(".sub_cat_text").css("color", "#ffffff");

	},	function(){

		$(this).children(".sub_cat_link").children(".sub_cat_text").css("color", "#99ccff");

	});
	
	$(".sub_cat_special_item").hover(function(){

		$(this).children(".sub_cat_link").children(".sub_cat_text").css("color", "#ffffff");

	},	function(){

		$(this).children(".sub_cat_link").children(".sub_cat_text").css("color", "#ebc2c2");

	});
	
	// #########################################################################
	
	// WARENKORB PREVIEW AJAX
	/*
	 * $(".warenkorb_preview_delete_link").click( function() {
	 * $(this).parent().slideUp("slow");//.warenkorbFadeTextsOut($(this).html());
	 * $.get("test.cgi", { name: "John", time: "2pm" }, function(data){
	 * alert("Data Loaded: " + data); });
	 * $("#msg").ajaxComplete(function(request, settings){ $(this).append("<li>Request
	 * Complete.</li>"); }); //return warenkorbFadeTextsOut($(this).html());
	 * return false; });
	 * 
	 * function warenkorbFadeTextsOut(link) {
	 * $("#warenkorb_preview_text_shipping_all").fadeOut("slow");
	 * $("#warenkorb_preview_text_total_price").fadeOut("slow"); var linkArr =
	 * link.match(/.*aid=(.*)&size=(.*)/); var aid = linkArr[1]; var size =
	 * linkArr[2]; $("#warenkorb_preview_text_shipping_all").html(aid);
	 * $("#warenkorb_preview_text_total_price").html(size); return false; }
	 */
	
	// ROLLOVER DIRECT (direct over img) ::adds "_active"
	$(".rollover_directJPG").hover(function(){
	
		var imgsrc = $(this).attr("src");
  		var imgsrcON = imgsrc.replace(/.jpg$/ig,"_active.jpg");
		$(this).attr("src", imgsrcON);

	},	function(){

		var imgsrc = $(this).attr("src");
  		var imgsrcON = imgsrc.replace(/_active.jpg$/ig,".jpg");
		$(this).attr("src", imgsrcON);

	});
	
	$(".rollover_directGIF").hover(function(){
	
		var imgsrc = $(this).attr("src");
  		var imgsrcON = imgsrc.replace(/.gif$/ig,"_active.gif");
		$(this).attr("src", imgsrcON);

	},	function(){

		var imgsrc = $(this).attr("src");
  		var imgsrcON = imgsrc.replace(/_active.gif$/ig,".gif");
		$(this).attr("src", imgsrcON);

	});
	
	// ROLLOVER IN-DIRECT (indirect over div) ::adds "_active"
	$(".rollover_indirect").hover(function(){
	
		var imgsrc = $(this).children("img").attr("src");
  		var imgsrcON = imgsrc.replace(/.gif$/ig,"_active.gif");
		$(this).children("img").attr("src", imgsrcON);

	},	function(){

		var imgsrc = $(this).children("img").attr("src");
  		var imgsrcON = imgsrc.replace(/_active.gif$/ig,".gif");
		$(this).children("img").attr("src", imgsrcON);

	});
	
	// ROLLOVER LANGUAGE BUTTONS (TOP)
	$(".language_buttons").hover(function(){
	
		var imgsrc = $(this).children("img").attr("src");
  		var imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif");
		$(this).children("img").attr("src", imgsrcON);

	},	function(){

		var imgsrc = $(this).children("img").attr("src");
  		var imgsrcON = imgsrc.replace(/_over.gif$/ig,".gif");
		$(this).children("img").attr("src", imgsrcON);

	});
	
	$(".language_buttons").mousedown(function(){
	
		var imgsrc = $(this).children("img").attr("src");
  		var imgsrcON = imgsrc.replace(/_over.gif$/ig,"_down.gif");
		$(this).children("img").attr("src", imgsrcON);

	},	function(){

		var imgsrc = $(this).children("img").attr("src");
  		var imgsrcON = imgsrc.replace(/_down.gif$/ig,"_over.gif");
		$(this).children("img").attr("src", imgsrcON);

	});
	
	// POPUP
	$('A[rel="popup"]').click( function() {
        window.open($(this).attr('href'),
        			'Pantau',
        			'width=500,height=500,left=100,top=200,toolbar="no",scrollbars="no",menubar="no"' );
        return false;
    });
	
	// Order Process - telephone numer
	var wasFocused = false;
	$('#order_telephone_no').focus( function() {
		if(!wasFocused){
			$(this).val('');
			wasFocused = true;
		}
    });
	
});
