function setPng24(obj) {
 obj.width=obj.height="1";
 obj.className=obj.className.replace(/\bpng24\b/i,"");
 obj.style.filter= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
 obj.src="";
 return "";
}

(function ($){
	$(document).ready(function() {
		var banners = $(".view-banner .view-content").children();
		var currentIndex = 0;
		var interval = 5000;
		$(function(){
			if(banners.length > 1) {
				myTimer = setInterval(showNext, interval);
			}
		})
		function showNext() {
			temp = currentIndex;
			nextIndex = currentIndex < banners.length - 1 ? currentIndex + 1 : 0;

			var $active = $(banners[currentIndex]);
			var $next = $(banners[nextIndex]);

			$next.removeClass('banner-not-display');
			$active.removeClass("active");
			$active.addClass('last-active');

			$next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
			currentIndex = nextIndex;
		}

		// comments click and blur
		$('.add_comment').focus(function() {
			if($(this).val() == $(this).attr('rel')) {
				$(this).val('');
			}
		})
		$('.add_comment').blur(function() {
			if($(this).val() == $(this).attr('rel') || ! $(this).val()) {
				$(this).val($(this).attr('rel'));
			}
		})

		// login form click and blur
		$('#edit-name').focus(function() {
			if($(this).val() == 'ID') {
				$(this).val('');
			}
		})
		$('#edit-name').blur(function() {
			if($(this).val() == 'ID' || ! $(this).val()) {
				$(this).val('ID');
			}
		})

		$('#edit-pass').focus(function() {
			if($(this).val() == 'PW') {
				$(this).val('');
			}
		})
		$('#edit-pass').blur(function() {
			if($(this).val() == 'PW' || ! $(this).val()) {
				$(this).val('PW');
			}
		})

		$('#my-edit-update').click(function(e) {
			e.preventDefault();
			$('#edit-update-submit').trigger('click');
		})
		$('#my-edit-checkout').click(function(e) {
			e.preventDefault();
			$('#edit-checkout-submit').trigger('click');
		})
		$('.del_product').click(function(e) {
			e.preventDefault();
			$(this).prev().trigger('click');
		})

		// imitation the click function of the continue shopping and checkout function in the cart page
		$("#imitation-continue").click(function(e) {
			e.preventDefault();
			$("#edit-continue-shopping").trigger('click');
		})
		$("#imitation-checkout").click(function(e) {
			e.preventDefault();
			$("#edit-checkout").trigger('click');
		})

		// open the holiday menu
		$('.open-holiday-menu').click(function(e) {
			e.preventDefault();
			var img = $(this).parent().find('img');
			// open the menu action
			if($(this).closest('.holiday_whole').find('.whole_contents').css('display') == 'none') {
				$(this).closest('.holiday_whole').find('.whole_contents').slideDown();
				img.attr('src', img.attr('closesrc'));
			} else {
				$(this).closest('.holiday_whole').find('.whole_contents').slideUp();
				img.attr('src', img.attr('opensrc'));
			}
		})

		// special price clicked to trigger the event to open the lightbox
		$('.special-price-link').click(function(e) {
			e.preventDefault();
			var product = $(this).parents('tr').find('.colorbox-inline');
			product.trigger('click');
		});
	});
})(jQuery);

