﻿$(document).ready(function() {
	
	function bindRegisterFormLink(selector) {
		$(selector).colorbox({
			href:'/club-avene/account-erstellen',
			onComplete: function() {
				WebApi.colorboxForm('.form-club form');
			}
		});
		return false;
	}
	
	function bindSendToFriendFormLink(selector) {
		$(selector).colorbox({
			href:$(this).attr('href'),
			// data:{url:window.location.href},
			onComplete: function() {
				WebApi.colorboxForm('.form-send-to-friend form');
			}
		});
		return false;
	}
	
	// register link in club
	bindRegisterFormLink('.club-register');
	bindSendToFriendFormLink('a.send-to-friend');
	
	$('.newsletter-box').colorbox({
		href:"/newsletter",	
		onComplete: function(){
			WebApi.colorboxForm('#cboxContent form', function(){
				bindRegisterFormLink('.form-newsletter-right img')
			});
			bindRegisterFormLink('.form-newsletter-right img');
		}
	});
	
	$('#allProductsLink').colorbox({
		href:"#allProductsBox",
		inline: true,
		onClosed : function(){$('#tooltip').hide();}
	});
	
	$('#aCategories').click(function (event) {
        $('#allAlphabetic').hide();
        $('#allByCat').show();
    });

    $('#aAlphabetic').click(function (event) {
        $('#allByCat').hide();
        $('#allAlphabetic').show();
    });
	
	if ($('.box-product-list li').length > 0) {
		$('.box-product-list li').tooltip({
			track: true,
			delay: 0,
			showURL: false,
			bodyHandler: function() {
				return $("<img/>").attr("src", $(this).attr('img'));
			}
		});
	}
	
	// $.colorbox({href:'/club-avene/account-erstellt'});
});
