$(document).ready(function() {

$(document).pngFix();

//        $("ul.sf-menu").superfish({
//			speed:         '0', 
//		    autoArrows:    false,
//		    dropShadows:   false,               
//		    disableHI:     false
//	});

    $('.slides').cycle({
    fx:     'scrollHorz', 
    timeout: 6000, 
    next:   '#next', 
    prev:   '#prev' 
    });

$("a[href^='http']").not("[href*='zillihome.com']").click(function(){
	window.open(this.href);
	return false;
});


$("a[href$='.pdf']").click(function(){
	window.open(this.href);
	return false;
});

$("a[href$='.pdf']").addClass("pdf");
$("a[href$='.doc']").addClass("doc");



$(".prefilled").focus(function() { 
	this.value = '';
});  

$(".prefilled").blur(function() {  
     if ($.trim(this.value) == ''){  
         this.value = (this.defaultValue ? this.defaultValue : '');  
     }  
});  


        $('a[href*=#]').click(function() {
          if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target
            || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
              var targetOffset = $target.offset().top;
              $('html,body')
              .animate({scrollTop: targetOffset}, 1000);
             return false;
            }
          }
        });



  createDropDown(); 

  $(".dropdown dt a").click(function(event) { 
    event.preventDefault(); 
    var dropID = $(this).closest("dl").attr("id"); 
    $("#" + dropID).find("ul").toggle(); 
  }); 

  $(document).bind('click', function(e) { 
    var $clicked = $(e.target); 
    if (! $clicked.parents().hasClass("dropdown")) 
      $(".dropdown dd ul").hide(); 
  }); 


  $(".dropdown dd ul a").click(function() { 
    var dl = $(this).closest("dl"); 
    var dropID = dl.attr("id"); 
    var text = $(this).html(); 
    var source = dl.prev(); 
    $("#" + dropID + " dt a").html(text); 
    $("#" + dropID + " dd ul").hide(); 
    source.val($(this).find("span.value").html()) 
  }); 


				

 });




function createDropDown() { 
  var selects = $("select.select"); 
  var idCounter = 1; 
  selects.each(function() { 
    var dropID = "dropdown_" + idCounter; 
    var source = $(this); 
    var selected = source.find("option:selected"); 
    var options = $("option", source); 
    source.after('<dl id="' + dropID + '" class="dropdown"></dl>'); 
    $("#" + dropID).append('<dt><a href="#">' + selected.text() + '<span class="value">' + selected.val() + '</span></a></dt>'); 
    $("#" + dropID).append('<dd><ul></ul></dd>'); 
    options.each(function() { 
      $("#" + dropID + " dd ul").append('<li><a href="#">' + $(this).text() + '<span class="value">' + $(this).val() + '</span></a></li>'); 
    }); 
    idCounter++; 
  }); 
} 



