//##############################################################################
//##  DOM																	  ##
//##############################################################################
$(document).ready( externalLinks );
$(document).ready(function() { $.preloadImages('/public/images/front_nav1_on.jpg',
											   '/public/images/front_nav2_on.jpg',
											   '/public/images/front_nav3_on.jpg',
											   '/public/images/front_nav4_on.jpg',
											   '/public/images/front_nav5_on.jpg',
											   '/public/images/front_nav6_on.jpg')
});
$(document).ready(function() {	
  if (jQuery.isFunction(jQuery.fn.easySlider)) {
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		controlsShow: false,
		firstShow: false,
		lastShow: false,				
		vertical: false,
		speed: 800,
		pause: 4000
	});
  }
});
/*###########################################
##  Dropdown Menus						   ##
###########################################*/
/* Options */
var __global_menuObject = '.navigation';
/* Controls */
$(document).ready(function() {
	  var lis = $(__global_menuObject).children('li').get();
      $.each(lis, function(){
        $(this).hover(
	      function () { //on
	        $(this).addClass("sfhover")
	      }, 
	      function () { //off
	        $(this).removeClass("sfhover")
	      }
	    );
      });
});
//##############################################################################
//##############################################################################
//##  Image Rollover Functions												  ##
//##############################################################################
jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } }
//##############################################################################
//##############################################################################
//##  Form Handler Functions												  ##
//##############################################################################
$.fn.resetOptions = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
      return $(':input',this).resetOptions();
    if (tag == 'select')
      this.selectedIndex=0;
  });
}; //end resetOptions
//##############################################################################
//##############################################################################
//##  User Handler Functions												  ##
//##############################################################################
function externalLinks() {
  var exs = $('a[rel=external]');
  $.each(exs, function() {
    if ($(this).attr('href')) { $(this).attr('target','_blank'); }
  });
  //non-jQuery version:
  /*if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if ((anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "external"))
     anchor.target = "_blank";
  }*/
}
//##############################################################################
//##############################################################################
//##  Quote Form Functions													  ##
//##############################################################################
$(function(){
  $("input[@name='category']").change(function(){
    $.getJSON("/public/php/_dynamic_quote_select.php",{page: $(this).val(), ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#policytype").html(options);
    })
  })
})
//##############################################################################
//##############################################################################