//Need mycarousel_itemList to add images to carousel dynamically. 
var mycarousel_itemList = [
    { url: "", href: "", smallImage: "", title: "", alt: "", img1: "" }
];
var mycarousel_itemListRP = [
    {url: "", href: "", smallImage: "", title: "11", alt: "Flower1", img1: ""}
];

/* rotation img product */
function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
});
/* end */

















/***********************************************************************************************************/
/* moon hover */
		$(document).ready(function() {
		
			$curtainopen = false;
		
			$(".rope").mouseover(function(){
				$(this).blur();
				if ($curtainopen == false){ 
					$(this).stop().animate({top: '0px' }, {queue:false, duration:1050, easing:'easeOutBounce'}); 
					$curtainopen = true;
				}else{
					$(this).stop().animate({top: '-130px' }, {queue:false, duration:1050, easing:'easeOutBounce'}); 
					$curtainopen = false;
				}
				return false;
			});
			
			$(".rope").mouseout(function(){
				$(this).blur();
				if ($curtainopen == false){ 
					$(this).stop().animate({top: '0px' }, {queue:false, duration:950, easing:'easeOutBounce'}); 
					$curtainopen = true;
				}else{
					$(this).stop().animate({top: '-130px' }, {queue:false, duration:950, easing:'easeOutBounce'}); 
					$curtainopen = false;
				}
				return false;
			});
			
		});
/* end */



/* cards and strat shopping */
	
	$(document).ready(function() {
	
	// Animate cards
		$("#nav-shadow li").mouseover(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "-30px" }, 250, function() {
		    	$(e).find("a").animate({ marginTop: "-20px" }, 500);
		    });
		});
		
		$("#nav-shadow li").mouseout(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "10px" }, 250, function() {
		    	$(e).find("a").animate({ marginTop: "0px" }, 250);
		    });
		});
	// End Cards
	
	
	// Animate start shopping
		$("#start-card li").mouseover(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginLeft: "25px" }, 250, function() {
		    	$(e).find("a").animate({ marginLeft: "15px" }, 500);
		    });
		});
		
		$("#start-card li").mouseout(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginLeft: "-5px" }, 250, function() {
		    	$(e).find("a").animate({ marginLeft: "0px" }, 250);
		    });
		});
	// End start shopping
	
	
	
	// Animate logo
		$("#logo-nav").hover(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "10px" }, 100, function() {
		    	$(e).find("a").animate({ marginTop: "0px" }, 350);
		    });
		},function(){
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "-5px" }, 100, function() {
		    	$(e).find("a").animate({ marginTop: "0px" }, 250);
		    });
		});
	// End logo
	
	});
/* end */





$(document).ready(function(){

	$(".btn-slide1").click(function(){
		$("#panel_1").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	$(".btn-slide1").click(function(){
		$("#panel_2").slideUp("slow");
		$(this).toggleClass("active"); return false;
	});
	
	//
	$(".btn-slide1").click(function(){
		$("#arrow_1").slideToggle("faster");
	});
	$(".btn-slide1").click(function(){
		$("#arrow_2").slideUp("slow");
	});
	//

	$(".btn-slide2").click(function(){
		$("#panel_2").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	$(".btn-slide2").click(function(){
		$("#panel_1").slideUp("slow");
		$(this).toggleClass("active"); return false;
	});
	 
});




$(document).ready(function() {
    $('#mycarouse2').jcarousel();

    $('#mycarousel').jcarousel({
        scroll: 1,
        visible: 15,
        width: 35,
        height: 55,
        itemFallbackDimension: 35

    });
    var mycarousel = jQuery('#mycarousel').data('jcarousel');
if(mycarousel)
{
    var ss = mycarousel.size();
    if (ss == null || ss <1) {
        $("#mycarouselholder").css("display", "none");
        $("#mycarouselNoProducts").css("display", "block");
    }
}
else
{
$("#mycarouselholder").css("display", "none");
        $("#mycarouselNoProducts").css("display", "block");
}
});



$(document).ready(function(){
	
	$(".accordion2 b").eq(0).addClass("active");
	$(".accordion2 p").eq(0).show();

	$(".accordion2 b").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("b").removeClass("active");
	});

});



function GetHomeScripts()//used after GN calls
{
    $("ul.catalogue_products li").hover(function() {
        $(this).find('div.quickLookBtn').show();	
	    } , function() {
	    $(this).find('div.quickLookBtn').hide();	
    });
}
$(document).ready(function(){

//Larger thumbnail preview 

//$("ul.catalogue_products li").hover(function() {
//	$(this).css({'z-index' : '10'});
//	$(this).find('div').addClass("hover").stop()
//		.animate({
//			marginTop: '-18px', 
//			marginLeft: '-25px', 
//			top: '12%', 
//			left: '10%', 
//			width: '135px', 
//			height: '200px',
//			padding: '10px' 
//		}, 200);
//	
//	} , function() {
//	$(this).css({'z-index' : '0'});
//	$(this).find('div').removeClass("hover").stop()
//		.animate({
//			marginTop: '0', 
//			marginLeft: '0',
//			top: '0', 
//			left: '0', 
//			width: '135px', 
//			height: '210px', 
//			padding: '0px'
//		}, 300);
//});
 
 GetHomeScripts();
});




$(document).ready(function () {
		
		//jCarousel Plugin
//	    $('#carousel').jcarousel({
//			vertical: true,
//			scroll: 1,
//			auto: 0,
//			width: 75,
//			height: 95,
//			wrap: 'last',
//			initCallback: mycarousel_initCallback
//	   	});


 $('#carousel').jcarousel({
            vertical: true,
			scroll: 1,
			auto: 0,
			width: 73,
			height: 95,
			wrap: 'last',
			initCallback: mycarousel_initCallback,
			itemFallbackDimension: 95,
        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
    });
 $('#carouselRP').jcarousel({
            scroll: 1,
            visible: 5,
			width: 25,
			height: 35,
			itemFallbackDimension: 25,
            itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallbackRP}
    });
	//Front page Carousel - Initial Setup
   	$('div#slideshow-carousel a img').css({'opacity': '1.0'});
   	$('div#slideshow-carousel a img:first').css({'opacity': '1.0'});
   	$('div#slideshow-carousel li a:first').append('<span class="arrow"></span>')

  
  	//Combine jCarousel with Image Display
    $('div#slideshow-carousel li a').hover(
       	function () {
        		
       		if (!$(this).has('span').length) {
        		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '1.0'});
   	    		$(this).stop(true, true).children('img').css({'opacity': '1.0'});
       		}		
       	},
       	function () {
        		
       		$('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '1.0'});
       		$('div#slideshow-carousel li a').each(function () {

       			if ($(this).has('span').length) $(this).children('img').css({'opacity': '1.0'});

       		});
        		
       	}
	).click(function () {
		
		$('span.arrow').remove();        
		$(this).append('<span class="arrow"></span>');
       	$('div#slideshow-main li').removeClass('active');        
       	$('div#slideshow-main li.' + $(this).attr('rel')).addClass('active');	
        	
       	return false;
	});


});






//Carousel Tweaking

function mycarousel_initCallback(carousel) {
	
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
	
}
function mycarousel_initCallbackRP(carousel) {
	
//	// Pause autoscrolling if the user moves with the cursor over the clip.
//	carousel.clip.hover(function() {
//		carousel.stopAuto();
//	}, function() {
//		carousel.startAuto();
//	});
//	
//	            theModelCarouselRP = carousel; 
}
	
function mycarousel_itemLoadCallback(carousel, state)
{
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }
 
        if (i > mycarousel_itemList.length) {
            break;
        }
 
        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
    }
    
};
function mycarousel_itemLoadCallbackRP(carousel, state)
{
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }
 
        if (i > mycarousel_itemListRP.length) {
            break;
        }
 
        carousel.add(i, mycarousel_getItemHTMLRP(mycarousel_itemListRP[i-1]));
    }
    
};
/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    //return '<img src="' + item.url + '" width="75" height="75" alt="' + item.url + '" />';
    var abc = '<a onclick="SIC(\'' + item.img1 + '\')" href="' + item.href + '" class="cloud-zoom-gallery" title="Blue" rel="useZoom: \'zoom1\', smallImage: \'' + item.smallImage + '\'"><img height="95" width="73" class="zoom-tiny-image" src="' + item.url + '" alt = "' + item.alt + '"/></a>';
    return abc;
};
function mycarousel_getItemHTMLRP(item) {
    return '<a class="rpproduct" onclick="DoAction('+item.href+',999)" ><img src="' + item.url + '" width="35" height="45" alt="' + item.alt + '"/></a>';
    //    var abc='<img height="35" width="25" class="zoom-tiny-image" src="'+item.url+'" alt = "Thumbnail 3"/>';
    //    return abc;
};



						   
if(document.getElementById)
document.write('<style type="text/css">.detail {float:left;display:none;}#zero {display:block;}<\/style>');
function reveal(det){
if(!document.getElementById) return;
if (!document.getElementsByClassName){
document.getElementsByClassName = function(cn){
cn = cn.replace(/ +/g, ' ').split(' ');
var ar = [], testname = function(n){
for (var re, i = cn.length - 1; i > -1; --i){
re = new RegExp('(^|\W)' + cn[i] + '(\W|$)');
if(!re.test(n)) return false;
}
return true;
}
for(var d = document.all || document.getElementsByTagName('*'), i = 0; i < d.length; ++i)
if(testname(d[i].className))
ar[ar.length] = d[i];
return ar;
};
document.getElementsByClassName.spoof = true;
}
for (var d = document.getElementsByClassName('detail'), i = d.length - 1; i > -1; --i)
d[i].style.display = 'none';
document.getElementById(det).style.display = 'block';
if (document.getElementsByClassName.spoof)
document.getElementsByClassName.spoof = document.getElementsByClassName = null;
}



$(function() {
	$('#container-4').tabs({ fxFade: true, fxSpeed: 'fast' });
	$('#container-5').tabs({ fxFade: true, fxSpeed: 'fast' });
});


