$j(document).ready(function() {

     var imgTitle = $j(".image_thumb ul li").find('a').attr("rel"); //Get Main Image URL
     var imgAlt = $j(".image_thumb ul li").find('a img').attr("alt"); //Get Alt Tag of Image
     var li_imgsrc = $j(".icon",$j(this)).attr("src");
     var srcHref = $j(".image_thumb ul li").find('a').attr("href");
     $j(".main_image img").attr({ src: imgTitle , alt: imgAlt});
     $j(".main_image .thumb-block-js img").attr({ src:  li_imgsrc, alt: imgAlt});
     $j(".desc").find('a.thumb-block').attr({"href" : srcHref})  ;

     

    // this is for slider //
    $j('#promo-slideshow-home').cycle({
            fx: 'fade',
            cleartypeNoBg:true,
            speed:    2000,
            timeout:  4000
    });

    $j(".cycleElementsContainer").multipleElementsCycle({
            vertical: true,
            prev: '#verticalPrev',
            next: '#verticalNext',
            container: '.image_thumb',
            start: 0,
            show: 5,        // Items to show from the list (int)
            speed: 1000,	// Speed to scroll elements (int)
            scrollCount: 5	// How many elements to scroll when clicking next / prev,

    });

    // this is for about sliding //    
    // -------------hook for the sliding about page -------------------------//
    var ourlocation = location.href;
    var splittedUrl = ourlocation.split("?");
    if (splittedUrl[1]){
        var idarray = splittedUrl[1].split("&");
    } else {
        var idarray = new Array();
        idarray[1] = null;
    }
    if (idarray[1]){
        var slideId = idarray[1].split("=");
    }else{
        var slideId = new Array();
        slideId[1] = 0;
    }


    $j(function() {
            $j('#about-carousel').cycle({
                fx: 'scrollUp',
                speed: 1000,
                timeout: 0,  // milliseconds between slide transitions (0 to disable auto advance)
                pager:  '#about-carousel-nav',
                slideResize:   null,     // force slide width/height to fixed size before every transition
                after: onAfter,
                startingSlide: slideId[1], // zero-based
                pagerAnchorBuilder: function(idx, slide) {
                    // return sel string for existing anchor
                    return '#about-carousel-nav li:eq(' + (idx) + ') a';
                }
            });
    });

    function onAfter(curr, next, opts, fwd) {
         var $ht = $j(this).height();

         //set the container's height to that of the current slide
         $j(this).parent().animate({height: $ht});
    }

    //------------------------------------------------------------------------//



    // this is for sliding of sign-up of artist and promoter side info bar
     $j("#accordion > li > h4").click(function(){
            if(false == $j(this).next().is(':visible')) {
                $j('#accordion ul').slideUp(300);
            }
            $j(this).next().slideToggle(300);
        });
     $j('#accordion ul:eq(0)').show();


    /*------------------------------------------------------*/


    //Show Banner
    $j(".main_image .desc").show(); //Show Banner
    $j(".main_image .thumb-block-js").animate({ opacity: 1.0 }, 1 ); //Set Opacity

    $j(".image_thumb ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)
    $j(".image_thumb ul li").click(function() {
        //Set Variables
        var imgAlt = $j(this).find('a img').attr("alt"); //Get Alt Tag of Image
        var imgTitle = $j(this).find('a').attr("rel"); //Get Main Image URL
        var imgDesc = $j(this).find('.thumb-block-js').html();  //Get HTML of the "thumb-block-js" container
        var imgDescHeight = $j(".main_image").find('.thumb-block-js').height(); //Find the height of the "thumb-block-js"

        if ($j(this).is(".active")) {  //If the list item is active/selected, then...
            return false; // Don't click through - Prevents repetitive animations on active/selected list-item
        }
        //If not active then
        else {
            var li_imgsrc = $j(".icon",$j(this)).attr("src");
            //Animate the Description
            //Pull the thumb-block-js down (negative bottom margin of its own height)
            $j(".main_image .thumb-block-js").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {

                //swap the html of the thumb-block-js, then pull the thumb-block-js container back up and set opacity
                $j(".main_image .thumb-block-js").html(imgDesc).animate({ opacity: 1.0,  marginBottom: "0" }, 250 );
                //Switch the main image (URL + alt tag)
                $j(".main_image img").attr({ src: imgTitle , alt: imgAlt});
                //get the currently selected icon
                $j(".main_image .thumb-block-js img").attr({ src:  li_imgsrc, alt: imgAlt});
                
            });
        }
        //Show active list-item
        $j(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all list-items
        $j(this).addClass('active');  //Add class of 'active' on the selected list
        return false;

        }) .hover(function(){
            //Hover effects on list-item
            $j(this).addClass('hover');
            //Add class "hover" on hover
            $j(".header",$j(this)).addClass("blockSelected");
        
            }, function() {
                $j(this).removeClass('hover'); //Remove class "hover" on hover out
                $j(".header",$j(this)).removeClass("blockSelected");
        });

});//Close Function

// this is for sliding of sign-up of artist and promoter side info bar
$j(document).ready(function() {
        $j('#accordion ul').slideUp(-100);
});
//-------------------------------------//




