// JQuery Codes
$(document).ready(function() {

	// top navigation: http://www.sohtanaka.com/web-design/examples/fancy-navigation/
	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the a tag
		$(this).find("span").show().html(linkText); //Add the text in the span tag
	});

	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({
			marginTop: "-40" //Find the span tag and move it up 40 pixels"
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0" //Move the span back to its original state (0px)
		}, 250);
	});


	// fancybox
	// 280x280 images
	$("a.grouped_elements1").fancybox({
		'transitionIn'	 : 'elastic',
		'transitionOut'	 : 'fade',
		//'easingIn'     : 'easeOutBack',
		//'easingOut'    : 'easeInBack',
		'overlayColor'   : '#111',
		'overlayOpacity' : 0.75,
		'titlePosition'  : 'inside',
		'titleFormat'	 : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside">&nbsp;<strong>' + (title.length ? ' &nbsp; ' + title : '') + '</strong><span style="float:right; padding-right:10px;">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
		}
	});
	// recommendation images
	$("a.grouped_elements2").fancybox({
		'transitionIn'	 : 'elastic',
		'transitionOut'	 : 'elastic',
		'overlayColor'   : '#111',
		'overlayOpacity' : 0.75,
		'titlePosition'  : 'inside',
		'titleFormat'	 : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside">&nbsp;<strong>' + (title.length ? ' &nbsp; ' + title : '') + '</strong><span style="float:right; padding-right:10px;">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
		}
	});


	// hides the slickbox as soon as the DOM is ready (a little sooner that page load)
	$('#giftMSG_input').hide();

	$('#slick-down_giftHeader').click(function() {
    	$('#giftMSG_input').slideDown('fast');
    	return false;
	});
	$('#slick-up_cancel').click(function() {
    	$('#giftMSG_input').slideUp('fast');
		$('#giftMSG_display').slideDown('fast');
    return false;
	});
	$('#slick-down_edit').click(function() {
		$('#giftMSG_input').slideDown('fast');
    	return false;
	});
	/* toggle effect no in use
	$('#slick-slidetoggle').click(function() {
    	$('#giftMSG').slideToggle(400);
    	return false;
	});
	*/

	// shows and hides and toggles the slickbox on click (just another effect but not in use) 
	/*
	$('#slick-show').click(function() {
    	$('#slickbox').show('slow');
    	return false;
	});
	$('#slick-hide').click(function() {
    	$('#slickbox').hide('fast');
    	return false;
	});
	$('#slick-toggle').click(function() {
    	$('#slickbox').toggle(400);
    	return false;
	});
	*/

	// checkout step 1 payment option
	$('.paymentopt_class').click(function(){
		if($(this).val() === "bankTransfer") $('#bankAcct').show();
		else $('#bankAcct').hide();
	});


});
