var homepageProducts = [];


$(document).ready(function () {


    //if (products && products.length)updateColourSizeLabel();

        /* Homepage Products Details */
	if ($j("#homepagePromo") && homepageProducts){ 
		var len = homepageProducts.length;
		for(var i=0; i<len; i++){  
			var product = homepageProducts[i]; 
			if ($j("#showPro"+product) && $j("#productdetails"+product)){  
				$j("#showPro"+product).click(function(event) {
					$j(this).next().slideToggle(500,function(){  //this = showPro; this.next=productdetails
						if ($j(this).css("display")=='none'){    //this = productdetails							
							$j(this).prev().removeClass("productActive");						   
						}else {
							$j(this).prev().addClass("productActive");						   
						}
					});
					
				});
			}
		}
	}


	/* Virtual Cart */
	if ($j("#cart-total")){ 
		$j("#cart-total").click(function(event) {
			$j("#virtualcart").slideToggle(500,function(){
			})
		});
	}
	
	/* Catalog side banner */
	if ($j("#side-banner")){
		$j("#side-banner").mouseenter(function(){
			$j(this).fadeTo(100,0.7);
		});
		$j("#side-banner").mouseleave(function(){
			$j(this).fadeTo(100,1);
		});

	}
	
	/* Catalog Search Form - Expand search filter */
	if ($('productSearchFilter')){
		var fxSearchCatalogExpand = new Fx.Styles($('productSearchFilter'), {duration:300,wait:false,transition:Fx.Transitions.Quad.easeIn});
				
		if ($('productSearchExpand')){
			//Expand
			$('productSearchExpand').addEvent('click',function(){			   
				fxSearchCatalogExpand.start({'height':'72px','opacity':1});	
				$('productSearchFilter').style.display='block';
				$('productSearchHide').style.visibility='visible';
				$('productSearchExpand').style.visibility='hidden';
			});
		}
		
		if ($('productSearchHide')){  
			//Hide 
			$('productSearchHide').addEvent('click',function(){ 
				fxSearchCatalogExpand.start({'height':'0px','opacity':0});	
				$('productSearchFilter').style.display='none';
				$('productSearchHide').style.visibility='hidden';
				$('productSearchExpand').style.visibility='visible';
			});
		}
	}
	
	
	
	
	
	/* More Related Products - jquery slideDown */
	if ($j("#btn-more-prod")){
		$j("#btn-more-prod").click(function(){
			$j("#more-related-prod").slideDown(500,function(){})
			$j("#btn-more-prod").css('display','none');	
		});
	}
	
	/* Product thumbnail navigation */
    /*
	if ($('carousel-hero')){  
        productThumbnailNav();
	}
    */

        /* Product Review Form */
        if ($("postlink")){
                $("postlink").addEvent('click',function() {
                        $("reviewFrm_wrappper").style.display='block';
                        $("showReview_wrapper").style.display='none';
                        $("showreview").style.display='block';
                        $("postlink").style.display='none';
		});
        }

        if ($("postlink2")){
                $("postlink2").addEvent('click',function() {
                        $("reviewFrm_wrappper").style.display='block';
                        $("showReview_wrapper").style.display='none';
                        $("showreview").style.display='block';
                        $("postlink").style.display='none';
                });
        }

        if ($("postlink3")){
                $("postlink3").addEvent('click',function() {
                        $("reviewFrm_wrappper").style.display='block';
                        $("showReview_wrapper").style.display='none';
                        $("showreview").style.display='block';
                        $("postlink").style.display='none';
                });
        }

        /* Product Reviews */
        if ($("showreview")){
                $("showreview").addEvent('click',function() {
                        $("reviewFrm_wrappper").style.display='none';
                        $("showReview_wrapper").style.display='block';
                        $("showreview").style.display='none';
                        $("postlink").style.display='block';
		});
        }

        /* Product Review rating initiation */
        if ($j('input.rating')){
//                $j('input.rating').rating({'split':2});  //allow half star rating
                $j('input.rating').rating();
        }


});


//Hide background image on homepage gallery after Flash gallery is loaded
function hideHomepageGalleryBackground(){
        if ($('homepage_gallery')){
                $('homepage_gallery').style.background = '';
        }
}

