jQuery(document).ready(function() {

    // Link anpassen im Hauptmenü
	$topMenuLink = jQuery('.topitem:contains("Geschenkgutschein")');
	$topMenuLink.attr('href', '/info/coupon/');
	$topMenuLink.click(function(){
		info(this);
		return false;
	});

    // Link anpassen im Untermenü
	$subMenuLink = jQuery('.topmenu_submenu_link:contains("Geschenkgutschein")');
	$subMenuLink.parent().css('margin-top', '10px');
	$subMenuLink.attr('href', '/info/coupon/');
	$subMenuLink.click(function(){
		info(this);
		return false;
	});

    // Link anpassen im Kategoriemenü
	$subMenuLink = jQuery('.sidemenu_category_link:contains("Geschenkgutschein")');
	$subMenuLink.parent().css('margin-top', '10px');
	$subMenuLink.attr('href', '/info/coupon/');
	$subMenuLink.click(function(){
		info(this);
		return false;
	});

});

// Legt einen Artikel in den Warenkorb
function add_to_bag_global(style, color, pAmount, pSize, pShow) {
	var amount  = pAmount;
    var	size    = encodeURIComponent(pSize);

	if (!style || !color) {
		return false;
    }

	var sizes = new Array(size);
	
	new Ajax.Request("/?site=product_to_bag&style_id=" + style + "&colorcode="
			+ color + '&sizes=' + sizes + "&amount=" + amount + "&action=process", {
		method : 'post',
		parameters : '1=1',
		onSuccess : function(rtn, json) {
			try{
				//hier wieder epoq rein siehe /modules/product.js
			}
			catch(e){};
			if (pShow)
			{
				$('top').scrollTo();
				showBasketBoxGlobal(true);
				isBasketBagOpen = true;
	        	answer = eval('('+rtn.responseText+')');
	        	$('bdBasketBoxCountGlobal').innerHTML = answer.articles;
                if (parseInt(answer.articles) == 1) {
                    $('bdBasketBoxCountSingularGlobal').show();
                    $('bdBasketBoxCountPluralGlobal').hide();
                } else {
                    $('bdBasketBoxCountSingularGlobal').hide();
                    $('bdBasketBoxCountPluralGlobal').show();
                }
	        	$('bdBasketBoxSummaryGlobal').innerHTML = answer.amount;
	        	$('bdBasketBoxTextGlobal').innerHTML	= answer.content;
	        	
	        	$('basket_amount').innerHTML    = answer.amount;
	        	$('basket_count').innerHTML 	= answer.articles;
	        	$('basket_arrow').writeAttribute({'src': '/images/layout/RightArrow.png'});
           }
		}
	});
	return false;
}

// Zeigt den Warenkorbslider an
function showBasketBoxGlobal(show)
{
	if(show) {
		$('bdBasketBoxGlobal').style.top    = ($('basket').offsetTop+40) +"px";
		$('bdBasketBoxGlobal').style.left   = ($('basket').offsetLeft-149) +"px";
		new Effect.BlindDown('bdBasketBoxGlobal',{duration: 0.7});
        setTimeout("hideBasketBoxGlobal()", 6000);
    } else {
		var queue = Effect.Queues.get('bdBasketBoxGlobal');
		queue.each(function(effect) {effect.cancel();});
		$('bdBasketBoxGlobal').fade();
	}
	return false;
}

// Blendet den Warenkorbslider aus
function hideBasketBoxGlobal()
{
    if($('bdBasketBoxGlobal').visible()) {
        Effect.SlideUp('bdBasketBoxGlobal', {duration: .5});
    }
}

