jQuery(document).ready(function(){
//	jQuery('.logoslogan').click(function(){alert(jQuery.cookie('sc'))});
	jQuery('.addToCart').click(function(event){
		event.preventDefault();
		var purChaseID = jQuery(this).attr('id').toString().substr(3);
		if(jQuery(this).hasClass('expired') == false){
			var shoppingLayer = '<p>You just added the workshop into your shopping cart.</p>';
			addToCookiesCart(purChaseID);
		}else{
			var shoppingLayer = '<p>The time has expired on this workshop and it\'s no longer available as a single purchase. If you are still interested in viewing this workshop you have to purchase all 14 workshops. This will grant you unlimited (24/7) access to all of the workshops for 6 weeks.</p>';
		}
		var overLayer = jQuery('<div id="overLayer"></div>').appendTo('body');
		var msgLayer = jQuery('<div id="layerShopping"><div>' + shoppingLayer + '<p class="layerbuttons"><button id="contbut">continue shopping</button><button id="checkbut">go to checkout page</button></p></div></div>').appendTo('body');
		overLayer.fadeIn();
		msgLayer.fadeIn();
	});


	jQuery('#contbut').live('click',function(){
		jQuery('#layerShopping').fadeOut();
		jQuery('#overLayer').fadeOut();
		jQuery('#layerShopping').remove();
		jQuery('#overLayer').remove();
	});

	jQuery('#checkbut').live('click',function(){
		top.document.location.href='registration.html';
	});
    $('#req-swither').click(function(){
			if($('#req-desc').hasClass('hdn')){
				$('#req-desc').slideDown();
				$('#req-desc').removeClass('hdn')
			}else{
				$('#req-desc').slideUp();
				$('#req-desc').addClass('hdn')
			}
		});
});



function addToCookiesCart(objID){
	var currentShCart = jQuery.cookie('sc');
	if(currentShCart != null) currentShCart += ',' + objID;
	else currentShCart = objID;
	jQuery.cookie('sc', currentShCart);
}


function generateCart(){
	if(typeof(eventsArray) == 'object' && jQuery.cookie('sc') != null){
		var currentCart = jQuery.cookie('sc').split(',');
		for (var idx = 0; idx < currentCart.length; idx++){
			if(typeof(eventsArray[currentCart[idx]]) != 'undefined'){
                		var itemPrice = jQuery('#eve'+eventsArray[currentCart[idx]][0]).find('.item-price').text();
				addItemToCart(eventsArray[currentCart[idx]][2], 'by ' + eventsArray[currentCart[idx]][1], itemPrice,idx,eventsArray[currentCart[idx]][0]);
				jQuery("#eve" + eventsArray[currentCart[idx]][0]).hide();
			}
		}
	}
}

function removeCartItem(objIdx){
	if(jQuery.cookie('sc') != null){
		var newCarItemsList = '';
		var currentCart = jQuery.cookie('sc').split(',');
		for (var idx = 0; idx < currentCart.length; idx++){
			if(objIdx != idx && currentCart[idx] != null){
				newCarItemsList += ',' + currentCart[idx];
			}
		}
		if(newCarItemsList.indexOf(',') == 0) newCarItemsList = newCarItemsList.substr(1);
		jQuery.cookie('sc',newCarItemsList);
		if(jQuery('#cart-items')) jQuery('#cart-items').find('tbody').empty();
		generateCart();
		updateCartStatus();
	}
}



(function(jQuery) {
    function uitoggle() {
        var obj = jQuery('#faq');
        var clas = 'active';

        if(obj.length > 0) {
            jQuery('dd', obj).hide();
            jQuery('dt', obj).click(function() {
                if(jQuery(this).hasClass(clas)) {
                    jQuery(this).removeClass(clas);
                }else {
                    jQuery(this).addClass(clas);
                }

                jQuery(this).next('dd')
                    .slideToggle();
            });
        }
    }

    jQuery(function() {
        uitoggle();
    });
})(jQuery);


jQuery(document).ready(function () {

	//instrScroller();

    prevTabInd = 0;
    jQuery("#video ul li a").click(function (event) {
		event.preventDefault();
        jQuery("#video ul li.active").removeClass("active");
        jQuery(this).parent().addClass("active");

        index = jQuery(this).parent().index();

        indexPrev = jQuery(".main-top-blocks .main-top-block.active").index();

        jQuery(".main-top-blocks .main-top-block").eq(indexPrev).animate({
            opacity: 0,
            queue: false
        }, 300, function () {
            // Animation complete.
            jQuery(".main-top-blocks .main-top-block").eq(indexPrev).removeClass("active");
        });

        jQuery(".main-top-blocks .main-top-block").eq(index).addClass("active");
        jQuery('.main-top-blocks .main-top-block').eq(index).animate({
            opacity: 1,
            queue: false
        }, 400, function () {
            // Animation complete.
        });
    });


		jQuery('.utube img').click(function(){
			jQuery.ajax({
			  url: '/utajax.php',
			  success: function(data) {
				jQuery('.utube img').remove();
			    jQuery(".utube").append(data);
			  }
			});
		});

	});

