var slideShowSpeed = 5000

var crossFadeDuration = 3

var Pic = new Array() // don't touch this


Pic[0] = 'image/banner1.jpg'
Pic[1] = 'image/banner2.jpg'
Pic[2] = 'image/banner3.jpg'


var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}
(function($) {
    $(document).ready(function() {
        
        // Special Class for No JavaScript
        //------------------------------------------
        //remove the nojs class so that non-JS browsers can have custom styles
        $("body").removeClass("nojs");
        
        var options = {default_color:'#d0d0d0',focus_color:'#000'};
        $('input.defaultvalue').addDefaultValueBehavior(options);
        
        // Text Field Image Substitution
        //-----------------------------------------------------------------------------------------------------
        $("fieldset.fancy p.replace input").focus(function(){
            $(this).parent().addClass('active');
            $(this).parent().parent().parent().addClass('in_focus');
        });
        
        $("fieldset.fancy p.replace input").blur(function(){ 
            $(this).parent().removeClass('active');
            $(this).parent().parent().parent().removeClass('in_focus');
        });
        
        $("fieldset.fancy div.replace_textarea_large textarea").focus(function(){
            $(this).parent().addClass('active');
            $(this).parent().parent().parent().addClass('in_focus');
        });
        $("fieldset.fancy div.replace_textarea_large textarea").blur(function(){ 
            $(this).parent().removeClass('active');
            $(this).parent().parent().parent().removeClass('in_focus');
        });

          /* Highlight Row and show tooltip */
          $(".field_block_wrap").hover(function(){
              $(this).addClass("highlight");
              $(".field_block_wrap.highlight + .field_block_wrap").addClass("no_border")
          },
          function(){
              $(".field_block_wrap.highlight + .field_block_wrap").removeClass("no_border")
              $(this).removeClass("highlight");
          });

          /* Make / Model Selection */

        $("select#make").change(function(){
            $.getJSON("/ajax/getModelsAddition.php",{make: $(this).val(), ajax: 'true'}, function(j) {
              var options = '<option></option>';
              for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i] + '">' + j[i] + '</option>'; }
              $("select#model").html(options);
            })
          });

        $.getJSON("/ajax/getModelsAddition.php",{make: $("select#make").val(), ajax: 'true'}, function(j){
            var options = '<option></option>';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i] + '">' + j[i] + '</option>';
            }
            $("select#model").html(options);
                    });

    });
    })(jQuery);