
//this is for the menu
function mainmenu(){
    $(" #nav ul ").css({
        display: "none"
    }); // Opera Fix
    $(" #nav li").hover(function(){
        $(this).find('ul:first').css({
            visibility: "visible",
            display: "none"
        }).show(400);
    },function(){
        $(this).find('ul:first').css({
            visibility: "hidden"
        });
    });
}
//Sidebar Sliding widget
function xSlidebarSlideWidget(){
    $(".xSidebar .xWidget .xCustom h4 a").click(function(){
        $('.xSidebar .xWidget .xCustom h4 a').removeClass('xSelected');
        Cufon.replace('.xSidebar .xWidget .xCustom h4 a',{
            hover:true
        });
        $(this).addClass('xSelected');
        
        if($(this)[0]==$('.xSidebar .xWidget .xCustom h4:nth-child(1) a')[0]){
            $('.xSidebar .xWidget .xSlider .xSliderContent').animate({
                marginTop:'0px'
            },1000,'swing');
        }
        if($(this)[0]==$('.xSidebar .xWidget .xCustom h4:nth-child(2) a')[0]){
            $('.xSidebar .xWidget .xSlider .xSliderContent').animate({
                marginTop:'-266px'
            },1000,'swing');
        }
        if($(this)[0]==$('.xSidebar .xWidget .xCustom h4:nth-child(3) a')[0]){
            $('.xSidebar .xWidget .xSlider .xSliderContent').animate({
                marginTop:'-532px'
            },1000,'swing');
        }
        
    });

}
//Header Categories
function xHeaderCategories(xThis){
    $(xThis).mouseenter(function(){
        this.object = new Object();
        $("div",this).animate({
            marginTop: "-71px",
            height: "71px"
        }, 200,'swing');
    });
    $(xThis).mouseleave(function(){
        $("div",this).animate({
            marginTop: "-31px",
            height: "31px"
        }, 200,'swing');
    });
}
//Slide to Top
function xSlideToTop(){
    var xSlidex = 'html, body';
    if(navigator.appName=="Opera"){
        xSlidex='html';
    }
    $('.xFooter .xCenter .xBottom span').click(function(){
        $(xSlidex).animate({
            scrollTop: '0px'
        }, 500);
        return false;
    });
}

//search box
function xSearchBox(){
    $('.xMiddle .xSearch form input').click(function(){
        if($('.xSearch form input').attr('value')=="Type here to search...."){
            $('.xSearch form input').attr('value','');
        }
    });
}
function xPrettyPhoto(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
}
//Gallery Slide
function xGallerySlide(){
    $('.xGallery ul li .xContainer').mouseenter(function(){
        $('.xGallerySlideBG',this).animate({
            marginLeft:'300px'
        },500,'swing');
    });
    $('.xGallery ul li .xContainer').mouseleave(function(){
        $('.xGallerySlideBG',this).animate({
            marginLeft:'61px'
        },500,'swing');
    });
}

jQuery(document).ready(function($){
    //Menu nice slide
    mainmenu();
    //Sidebar Widget
    xSlidebarSlideWidget();
    //Slide to top
    xSlideToTop();
    //Search Box
    xSearchBox();
    //PrettyPhoto
    xPrettyPhoto();
    //Cufon
    xGallerySlide();
    //Cufon
    Cufon.replace('.xLogo a,.xContent .xCenter .xCategoryTitle');
    Cufon.replace('h1, h2, h3, h4, h5', {
        hover: true
    });
    Cufon.replace('.xListSSMenu ul li h4', {
        hover: true
    });
    
    //Categories hover effect
    xHeaderCategories(".xHeader .xCategories ul li");
    // Different slideshow functions
    switch(xSlideshow){
        case 1:
            xSplitSlide(995,365);
            break;
        case 2:
            slideshowList(365);
            break;
        case 3:
            slideshowBasic(995);
            break;
        case 4:
            slideshowLight();
            break;
    }
});
