// Copyright Acro Media Inc. 1998-2009, www.acromediainc.com
(function($){
// copyright year
$(function(){
  $('#insertYear').html(new Date().getFullYear());
  check_active_trail();
  drop_down_menu();
});

// external links
$(function(){
    $("a[href^='http']").each(function(){
        var re_matches = /https?:\/\/([^\/]*)/.exec($(this).attr('href'));
        if(re_matches[1] && re_matches[1] != location.hostname){
            $(this).attr('target', '_blank');
        }
    });
});

/// add hovers
$(function(){
  $('#search .form-submit, span.btn').hover(function(){
    $(this).toggleClass('hover');
  }, function(){
    $(this).toggleClass('hover');
  });
});

var isOpen = false;

check_active_trail = function(){
  $('#navCont li').each(function(){
    if($(this).hasClass('active-trail')){
  	$('ul', this).css('display', 'block');
	$("#siteContent").css('padding-top', '60px');
	isOpen = true;
    }
  });
}


// drop down
drop_down_menu = function(){  
  $('#priNav .expanded').hover(
  	function(){   
	
      $(this).find("ul").css("display", "block");
      
      $('#priNav .active-trail ul li a').each(function() {
        $(this).css("display", "none");  
      });        
        
      $('#priNav .active-trail ul li a').each(function() {
        $(this).css("display", "inline");
      });          
          
      $('a', this).addClass('dropOn');
        
      $("#siteContent").stop().animate({ paddingTop: "75px"}, 300 );
  	},
  	function(){
      $('a', this).removeClass('dropOn');
      if(!$(this).hasClass('active-trail')){          
        $(this).find("ul").css("display", "none");
        
        if(!isOpen){        
          $('#siteContent').stop().animate({paddingTop: "2px"}, 200 );     
        }
  	  }
    });
}

/// default input text
jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
    //Make sure we're dealing with text-based form fields
    if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
      return;
    
    //Store field reference
    var fld_current=this;
    
    //Set value initially if none are specified
        if(this.value=='' || this.value == text) {
      this.value=text;
    } else {
      //Other value exists - ignore
      return;
    }
    
    //Remove values on focus
    $(this).focus(function() {
      if(this.value==text || this.value=='')
        this.value='';
    });
    
    //Place values back on blur
    $(this).blur(function() {
      if(this.value==text || this.value=='')
        this.value=text;
    });
    
    //Capture parent form submission
    //Remove field values that are still default
    $(this).parents("form").each(function() {
      //Bind parent form submit
      $(this).submit(function() {
        if(fld_current.value==text) {
          fld_current.value='';
        }
      });
    });
    });
};
})(jQuery);

//Set values
//$(document).ready(function() {
  //$("#search .form-text").DefaultValue("search site");
  //$("#newsName").DefaultValue("Your Name");
 // $("#newsEmail").DefaultValue("Email Address");
//});


