/* Author: Jeff Whitfield */
$().ready(function() {
    if($('#content_foot_slider').length > 0){
        $('#content_foot_slider').cycle({
            fx:     'scrollLeft',
            timeout: 15000,
            pager:  '#content_foot_paging'
        });
    }
    if($('#ticker ul').length > 0){
        $('#ticker ul').cycle({
            fx:     'fade',
            timeout: 8000,
            next:   '#ticker .next', 
            prev:   '#ticker .prev' 
        });
    }
    if ($.fn.jCarouselLite) {
        $('#mim_carousel').jCarouselLite({
            scroll: 1,
            visible: 2,
            circular: false,
            speed: 1000,
            btnNext: '#mim .next',
            btnPrev: '#mim .prev'
        });
        $('#mim .disabled').live('click', function() {
            return false;
        });
    }
    /*
    $('#main a[rel]').overlay({

        mask: '#666',

        onBeforeLoad: function() {

            // grab wrapper element inside content
            var wrap = this.getOverlay().find('.contentWrap');

            // load the page specified in the trigger
            wrap.load(this.getTrigger().attr('href'));
        }

    });
    */
    jQuery(function() {
       jQuery.support.placeholder = false;
       test = document.createElement('input');
       if('placeholder' in test) jQuery.support.placeholder = true;
    });
    // This adds placeholder support to browsers that wouldn't otherwise support it. 
    $(function() {
       if(!$.support.placeholder) { 
          var active = document.activeElement;
          $('input:text').focus(function () {
             if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
                $(this).val('').removeClass('hasPlaceholder');
             }
          }).blur(function () {
             if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                var ph = $(this).val($(this).attr('placeholder'));
                if (ph) { ph.addClass('hasPlaceholder'); }
             }
          });
          $('input:text').blur();
          $(active).focus();
          $('form:eq(0)').submit(function () {
             $('input:text.hasPlaceholder').val('');
          });
       }
    });
    if($('#showcase').length > 0){
        //Larger thumbnail preview 

        $("ul.thumbs li").hover(function() {
            $(this).css({'z-index' : '10'});
            $(this).find('.thumb').addClass("hover").stop()
                .animate({
                    marginTop: '-125px', 
                    marginLeft: '-165px', 
                    top: '50%', 
                    left: '50%', 
                    width: '300px', 
                    height: '225px',
                    padding:'12px 12px 30px 12px' 
                }, 200);
            $(this).find('img').addClass("hover").stop()
                .animate({
                    width: '300px', 
                    height: '225px' 
                }, 205);
            $(this).find('.hover div.actions').stop()
                .animate({
                    opacity:'1'
                }, 300);

            } , function() {
            $(this).css({'z-index' : '0'});
            $(this).find('.thumb').removeClass("hover").stop()
                .animate({
                    marginTop: '0', 
                    marginLeft: '0',
                    top: '0', 
                    left: '0', 
                    width: '200px', 
                    height: '150px'
                }, 400);
            $(this).find('img').removeClass("hover").stop()
                .animate({
                    top: '12px', 
                    left: '12px', 
                    width: '200px', 
                    height: '150px'
                }, 400);
        });
        //Swap Image on Click
            $("ul.thumb li a").click(function() {

                var mainImage = $(this).attr("href"); //Find Image Name
                $("#main_view img").attr({ src: mainImage });
                return false;       
            });
    }
});
