﻿   
    jQuery(function($){
    
        
        
        $("#byStyle #index.cats img").live("mouseenter", function() {
            $(this).attr("src", $(this).attr("src").replace(".jpg", "_hover.jpg"));
        });
    
        $("#byStyle #index.cats img").live("mouseleave", function() {
            $(this).attr("src", $(this).attr("src").replace("_hover.jpg", ".jpg"));
        });
    
        $('.slideshow').cycle({
		    fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	    });
        
        if ($("#homecontent").length = 1) {
            
            setTimeout(function(){ 
                $("#hmpageimg1, #hmpageimg2, #hmpageimg3, #hmpageimg4").fadeTo(2500, 1, function() {
                    $("#homecontent .loader").remove();
                    setTimeout(function(){ 
                        $('#hmpageimg1').animate({
                            opacity: 0,
                            left: '-=250'
                        }, 3000, function() {});
                        $('#hmpageimg2').animate({
                            opacity: 0,
                            left: '-=500'
                        }, 3000, function() {});
                        $('#hmpageimg3').animate({
                            opacity: 0,
                            left: '+=500'
                        }, 3000, function() {});
                        $('#hmpageimg4').animate({
                            opacity: 0,
                            left: '+=250'
                        }, 3000, function() {
                            $(".mainlogo").fadeTo(3000, 1, function() {
                                $("#homenav").fadeTo(1500, 1, function() {});
                            });
                        });
                    },1500);
                });
            },3000);
        }
        
        var timer;
        var timer2;
        var timer3;
        
        $('#index.alt a').lightBox({});
        
        $(".details ul#detail_nav li a").live("click", function() {
            $(".details ul li a.active").removeClass("active");
            $("#rel").hide();
            $("#alt").hide();
            $("#specs").hide();
            $(".loader").show();
            var Object = $(this); 
            Object.addClass("active");
            timer3 = setTimeout(function(){ 
                if (Object.hasClass("specs")) {
                    $(".loader").hide();
                    $("#rel").hide();
                    $("#alt").hide();
                    $("#specs").show();
                }
                if (Object.hasClass("rel")) {
                    $(".loader").hide();
                    $("#specs").hide();
                    $("#alt").hide();
                    $("#rel").show();
                }
                if (Object.hasClass("alt")) {
                    $(".loader").hide();
                    $("#specs").hide();
                    $("#rel").hide();
                    $("#alt").show();
                }
            },500);
        });
        
        $("#index .item img").live("mouseenter", function() {
            clearTimeout(timer);
            var Object = $(this); 
            timer2 = setTimeout(function(){ 
                Object.removeClass("fade");
                Object.parents(".item").addClass("active");
                $("#index.prds .item:not(.active,.dull) img").addClass("fade")
            },100);
        });
        
        $(".style_button").live("mouseenter", function() {
            $(this).attr("src", "/public/images/Stylisations_over.png");
        });
        
        $(".style_button").live("mouseleave", function() {
            $(this).attr("src", "/public/images/style_button.png");
        });
               
        $(".furniture_button").live("mouseenter", function() {
            $(this).attr("src", "/public/images/furniture_over.png");
        });
        
        $(".furniture_button").live("mouseleave", function() {
            $(this).attr("src", "/public/images/furniture_button.png");
        });
        
        $("#index.prds .item img").live("mouseleave", function() {
            clearTimeout(timer2);
            $(this).parents(".item").removeClass("active");
            timer = setTimeout(function(){ 
                $("#index .item:not(.active) img").removeClass("fade")
            },100);
        });
           
        $("#index.cats .item").live("mouseleave", function() {
            clearTimeout(timer2);
            $(this).removeClass("active");
        });
        
    });
    
    function ajaxDetails(inURL) {
       $('#ajax-details').load('/ajax/' + inURL); 
    }
    
    function ajaxStyles() {
       $('#ajax-styles').load('/styles.aspx'); 
    } 
    
    
