/* ************ GLOBAL JAVASCRIPT FUNCTIONS ******************* */

(function($) { 
 $(document).ready(function() { 


	//add class to remove margin from list item links
	var navFirst = $('ul#nav-global li:first, #nav-news ul li:first');
	var navLast = $('ul#nav-global li:last');
	navFirst.addClass('first');
	navLast.addClass('last');
	
	$('#news-scroll').cycle({ 
    fx: 'scrollUp',
	delay: 2000,
	pause: 1,
	cleartypeNoBg: true
	}); 

	});	

$(document).ready(function() { 
				
var options = { 
	target:    '#alert'
	}; 
	$('#rotaform').ajaxForm(options); 
	}); 
										
	$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
		});
	};
$(document).ready(function(){	

	$("ul#glnav li ul").hide();
	$('ul#glnav li.current_page_item').parents('ul').show();
	$('ul#glnav li.current_page_item > ul').show();
	$('ul#glnav ul:has(li.current_page_item) > ul').show();	
	
	var parentLi = $('ul#glnav li:has(ul)');
		parentLi.addClass('first');
		
		if ( parentLi.children().size() > 1 ) { 
			parentLi.addClass('has-children');
		} else {
			parentLi.removeClass('has-children');
		}

	});

	
$(document).ready(function(){
       $(".map-link").click(function(event){
               //prevent the default action for the click event
               event.preventDefault();

               //get the full url - like mysitecom/index.htm#home
               //var full_url = this.href;

               //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
               //var parts = full_url.split("#");
               //var trgt = parts[1];

               //get the top offset of the target anchor
               var target_offset = $('html, body').offset();
               var target_top = target_offset.top;

               //goto that anchor by setting the body scroll top to anchor top
               $('html, body').animate({scrollTop:target_top}, 1200);
       });
	   
	// map page over states locations page
	$('#map-block li a').hover( function() {  
    var region = ( this.id );  
	$('ul#map-block').addClass(region);
	}, function () {
	$('ul#map-block').removeClass()
	}); 
	
});
	
}) (jQuery);  



