$(function(){
	//round corners
	/*
	$(".submit").corner("5px");
	$(".section:not(.subnav)").corner("5px");
	$(".border:not(.subnav .border)").corner("5px");
	$(".subnav").corner("bottom 5px");
	$(".subnav .border").corner("bottom 5px");
	$("#nav a:not(ul.subnav a)").corner("5px");
	$("blockquote").corner("5px");
	*/
	
	$("#tabs_container ul.tabs").tabs("#tabs_container div.pane");
	$("#tabs_container div.panes div.pane").hide();
	$("#tabs_container div.panes div.pane:eq(0)").show();
	
	//header dropdown navigation
	$("#nav li.main:has(.subnav)").hover(showDropdown, hideDropdown);
	$("#nav li.main:has(.subnav) > a").click( function(){ return false } );
	
	
	
	$(".leadership_title").bind("click", leadershipToggle);
	$(".leadership_detail").hide();
	function leadershipToggle(event){
		var obj = $(event.currentTarget),
			target = obj.parent().find(".leadership_detail");
		
		if(target.is(":visible")){
			target.slideUp("fast");
		} else {
			$(".leadership_detail").slideUp("fast");
			target.slideDown("fast");
		}
	}

	
	(function(){
		$("#announcement_container").delegate("#announcementnav a","click", announcementClick);
		var headlinesID, timeoutID;
		
		function createTimer(){
			headlinesID = window.setInterval(headlinesRotate, 9000);
		}
		
		function stopTimer(){
			clearInterval(headlinesID);
			if(typeof(timeoutID) !== 'undefined'){
				clearTimeout(timeoutID);
			}
		}
		
		function headlinesRotate(){
			$("#announcementnav a.next").trigger("click",["auto"]);		
		}
		

		function announcementClick(event, option){
			var option = option || false;
			
			var obj = $(event.currentTarget),
				url = obj.attr("href");
			
			$.ajax({
				type: "POST",
				url: url,
				dateType: "html",
				success: function (html) {
					$("#announcement_container").html(html);			
				}
			});		
			
			if(!option){
				clearInterval(timeoutID);
				clearInterval(headlinesID);
				timeoutID = setTimeout(createTimer, 6000);
			}			
			
			return false;
		}
		
		createTimer();
		
	})();
	

	function showDropdown(event){
		var obj = $(event.currentTarget);
		var el_anchor = obj.find("a:eq(0)");
		var subnav = obj.find(".subnav");
		//subnav.width(obj.width()-2);
		if(!subnav.is(":animated")){
			subnav.stop(true, true).slideDown("fast");
		} else {
			subnav.stop(true, true);
			subnav.show();
		}
		//el_anchor.uncorner();
		//el_anchor.corner("top 5px");
	}
	
	function hideDropdown(event){
		var obj = $(event.currentTarget);
		var el_anchor = obj.find("a:eq(0)");
		var subnav = obj.find(".subnav");
		if(!subnav.is(":animated")){
			subnav.stop(true, true).slideUp("fast");	
		} else {
			subnav.stop(true, true);	
			subnav.hide();
		}
		//el_anchor.uncorner();
		//el_anchor.corner("5px");
	}
	
	//footer dropdown navigation
	$("#footer li.sub:has(.subnav)").hover(showSubDropdown, hideSubDropdown);
	$("#footer li.sub:has(.subnav) > a").click( function(){ return false } );
	
	
	function showSubDropdown(event){
		var obj = $(event.currentTarget);
		var subnav = obj.find(".subnav");
		subnav.show();
	}
	
	function hideSubDropdown(event){
		var obj = $(event.currentTarget);
		var subnav = obj.find(".subnav");
		subnav.hide();
	}
});


/*!
* jQuery corner plugin: simple corner rounding
* Examples and documentation at: http://jquery.malsup.com/corner/
* version 2.11 (15-JUN-2010)
* Requires jQuery v1.3.2 or later
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Authors: Dave Methvin and Mike Alsup
*/

/**
* corner() takes a single string argument: $('#myDiv').corner("effect corners width")
*
* effect: name of the effect to apply, such as round, bevel, notch, bite, etc (default is round).
* corners: one or more of: top, bottom, tr, tl, br, or bl. (default is all corners)
* width: width of the effect; in the case of rounded corners this is the radius.
* specify this value using the px suffix such as 10px (yes, it must be pixels).
*/
(function(c){var a=document.createElement("div").style,h=a.MozBorderRadius!==undefined,j=a.WebkitBorderRadius!==undefined,e=a.borderRadius!==undefined||a.BorderRadius!==undefined,d=document.documentMode||0,l=c.browser.msie&&((c.browser.version<8&&!d)||d<8),i=c.browser.msie&&(function(){var n=document.createElement("div");try{n.style.setExpression("width","0+0");n.style.removeExpression("width")}catch(m){return false}return true})();c.support=c.support||{};c.support.borderRadius=h||j||e;function g(m,n){return parseInt(c.css(m,n))||0}function k(m){var m=parseInt(m).toString(16);return(m.length<2)?"0"+m:m}function b(o){while(o){var m=c.css(o,"backgroundColor"),n;if(m&&m!="transparent"&&m!="rgba(0, 0, 0, 0)"){if(m.indexOf("rgb")>=0){n=m.match(/\d+/g);return"#"+k(n[0])+k(n[1])+k(n[2])}return m}if(o.nodeName.toLowerCase()=="html"){break}o=o.parentNode}return"#ffffff"}function f(o,m,n){switch(o){case"round":return Math.round(n*(1-Math.cos(Math.asin(m/n))));case"cool":return Math.round(n*(1+Math.cos(Math.asin(m/n))));case"sharp":return Math.round(n*(1-Math.cos(Math.acos(m/n))));case"bite":return Math.round(n*(Math.cos(Math.asin((n-m-1)/n))));case"slide":return Math.round(n*(Math.atan2(m,n/m)));case"jut":return Math.round(n*(Math.atan2(n,(n-m-1))));case"curl":return Math.round(n*(Math.atan(m)));case"tear":return Math.round(n*(Math.cos(m)));case"wicked":return Math.round(n*(Math.tan(m)));case"long":return Math.round(n*(Math.sqrt(m)));case"sculpt":return Math.round(n*(Math.log((n-m-1),n)));case"dogfold":case"dog":return(m&1)?(m+1):n;case"dog2":return(m&2)?(m+1):n;case"dog3":return(m&3)?(m+1):n;case"fray":return(m%2)*n;case"notch":return n;case"bevelfold":case"bevel":return m+1}}c.fn.corner=function(m){if(this.length==0){if(!c.isReady&&this.selector){var n=this.selector,o=this.context;c(function(){c(n,o).corner(m)})}return this}return this.each(function(v){var u=c(this),D=[u.attr(c.fn.corner.defaults.metaAttr)||"",m||""].join(" ").toLowerCase(),K=/keep/.test(D),C=((D.match(/cc:(#[0-9a-f]+)/)||[])[1]),p=((D.match(/sc:(#[0-9a-f]+)/)||[])[1]),G=parseInt((D.match(/(\d+)px/)||[])[1])||10,E=/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/,r=((D.match(E)||["round"])[0]),s=/dogfold|bevelfold/.test(D),q={T:0,B:1},z={TL:/top|tl|left/.test(D),TR:/top|tr|right/.test(D),BL:/bottom|bl|left/.test(D),BR:/bottom|br|right/.test(D)},H,N,F,I,y,O,B,L,J,x,M,P,A,t;if(!z.TL&&!z.TR&&!z.BL&&!z.BR){z={TL:1,TR:1,BL:1,BR:1}}if(c.fn.corner.defaults.useNative&&r=="round"&&(e||h||j)&&!C&&!p){if(z.TL){u.css(e?"border-top-left-radius":h?"-moz-border-radius-topleft":"-webkit-border-top-left-radius",G+"px")}if(z.TR){u.css(e?"border-top-right-radius":h?"-moz-border-radius-topright":"-webkit-border-top-right-radius",G+"px")}if(z.BL){u.css(e?"border-bottom-left-radius":h?"-moz-border-radius-bottomleft":"-webkit-border-bottom-left-radius",G+"px")}if(z.BR){u.css(e?"border-bottom-right-radius":h?"-moz-border-radius-bottomright":"-webkit-border-bottom-right-radius",G+"px")}return}H=document.createElement("div");c(H).css({overflow:"hidden",height:"1px",minHeight:"1px",fontSize:"1px",backgroundColor:p||"transparent",borderStyle:"solid"});N={T:parseInt(c.css(this,"paddingTop"))||0,R:parseInt(c.css(this,"paddingRight"))||0,B:parseInt(c.css(this,"paddingBottom"))||0,L:parseInt(c.css(this,"paddingLeft"))||0};if(typeof this.style.zoom!=undefined){this.style.zoom=1}if(!K){this.style.border="none"}H.style.borderColor=C||b(this.parentNode);F=c(this).outerHeight();for(I in q){y=q[I];if((y&&(z.BL||z.BR))||(!y&&(z.TL||z.TR))){H.style.borderStyle="none "+(z[I+"R"]?"solid":"none")+" none "+(z[I+"L"]?"solid":"none");O=document.createElement("div");c(O).addClass("jquery-corner");B=O.style;try{y?this.appendChild(O):this.insertBefore(O,this.firstChild)}catch(M){/ do nothing /}if(y&&F!="auto"){if(c.css(this,"position")=="static"){this.style.position="relative"}B.position="absolute";B.bottom=B.left=B.padding=B.margin="0";if(i){B.setExpression("width","this.parentNode.offsetWidth")}else{B.width="100%"}}else{if(!y&&c.browser.msie){if(c.css(this,"position")=="static"){this.style.position="relative"}B.position="absolute";B.top=B.left=B.right=B.padding=B.margin="0";if(i){L=g(this,"borderLeftWidth")+g(this,"borderRightWidth");B.setExpression("width","this.parentNode.offsetWidth - "+L+'+ "px"')}else{B.width="100%"}}else{B.position="relative";B.margin=!y?"-"+N.T+"px -"+N.R+"px "+(N.T-G)+"px -"+N.L+"px":(N.B-G)+"px -"+N.R+"px -"+N.B+"px -"+N.L+"px"}}for(J=0;J<G;J++){x=Math.max(0,f(r,J,G));M=H.cloneNode(false);M.style.borderWidth="0 "+(z[I+"R"]?x:0)+"px 0 "+(z[I+"L"]?x:0)+"px";y?O.appendChild(M):O.insertBefore(M,O.firstChild)}if(s&&c.support.boxModel){if(y&&l){continue}for(P in z){if(!z[P]){continue}if(y&&(P=="TL"||P=="TR")){continue}if(!y&&(P=="BL"||P=="BR")){continue}A={position:"absolute",border:"none",margin:0,padding:0,overflow:"hidden",backgroundColor:H.style.borderColor};t=c("<div/>").css(A).css({width:G+"px",height:"1px"});switch(P){case"TL":t.css({bottom:0,left:0});break;case"TR":t.css({bottom:0,right:0});break;case"BL":t.css({top:0,left:0});break;case"BR":t.css({top:0,right:0});break}O.appendChild(t[0]);var Q=c("<div/>").css(A).css({top:0,bottom:0,width:"1px",height:G+"px"});switch(P){case"TL":Q.css({left:G});break;case"TR":Q.css({right:G});break;case"BL":Q.css({left:G});break;case"BR":Q.css({right:G});break}O.appendChild(Q[0])}}}}})};c.fn.uncorner=function(){if(e||h||j){this.css(e?"border-radius":h?"-moz-border-radius":"-webkit-border-radius",0)}c("div.jquery-corner",this).remove();return this};c.fn.corner.defaults={useNative:true,metaAttr:"data-corner"}})(jQuery);


/*
 
 jQuery Tools 1.2.5 Tabs- The basics of UI design.

 NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.

 http://flowplayer.org/tools/tabs/

 Since: November 2008
 Date:    Wed Sep 22 06:02:10 2010 +0000 
*/
(function(c){function p(d,b,a){var e=this,l=d.add(this),h=d.find(a.tabs),i=b.jquery?b:d.children(b),j;h.length||(h=d.children());i.length||(i=d.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return e.click(n,g);if(f>n)return e.click(0,g)}if(!k.length){if(j>=0)return e;f=a.initialIndex;k=h.eq(f)}if(f===j)return e;
g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(e,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return e}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return e.click(j+1)},prev:function(){return e.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);
i.find("a[href^=#]").unbind("click.T");return e}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(e).bind(g,a[g]);e[g]=function(k){k&&c(e).bind(g,k);return e}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){e.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){e.click(c(this).attr("href"),f)});if(location.hash&&a.tabs=="a"&&d.find("[href="+location.hash+"]").length)e.click(location.hash);
else if(a.initialIndex===0||a.initialIndex>0)e.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.5"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(d,b){o[d]=b}};var o={"default":function(d,b){this.getPanes().hide().eq(d).show();b.call()},fade:function(d,b){var a=this.getConf(),e=a.fadeOutSpeed,l=this.getPanes();e?l.fadeOut(e):l.hide();l.eq(d).fadeIn(a.fadeInSpeed,b)},slide:function(d,
b){this.getPanes().slideUp(200);this.getPanes().eq(d).slideDown(400,b)},ajax:function(d,b){this.getPanes().eq(0).load(this.getTabs().eq(d).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(d,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(d).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(d,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b=
{onBeforeClick:b};b=c.extend({},c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),d,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);

(function($) {  
	$.fn.googleMap = function(options) {
		var defaults = {
			address: false,
			LatLng: [0, 0],
			zoom: 8, //higher number means zoom in further
			icon: false,
			alt: false,
			mapTypeId: google.maps.MapTypeId.ROADMAP 
			//mapTypeId: google.maps.MapTypeId.SATELLITE 
			//mapTypeId: google.maps.MapTypeId.HYBRID 
			//mapTypeId: google.maps.MapTypeId.TERRAIN 
		}
		var options = $.extend(defaults, options);
		return this.each(function() {
			var obj = $(this)[0];
			var mapLatLng = new google.maps.LatLng(options.LatLng[0],options.LatLng[1]);
			var mapOptions = {
				zoom: options.zoom,
				center: mapLatLng,
				mapTypeId:options.mapTypeId
			}
			var map = new google.maps.Map(obj,mapOptions);
			if(options.address){
				var geocoder = new google.maps.Geocoder();	
				geocoder.geocode( { 'address': options.address}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {
						map.setCenter(results[0].geometry.location);
						if(options.icon){
							var marker = new google.maps.Marker({
								map: map, 
								position: results[0].geometry.location,
								icon:options.icon
							})
						} else {
							var marker = new google.maps.Marker({
								map: map, 
								position: results[0].geometry.location
							});
						}
					} else if(status == google.maps.GeocoderStatus.ZERO_RESULTS) {
						if(options.alt) {
							$(obj).replaceWith("<div id='"+$(obj).attr("id")+"'><img src='"+options.alt+"' /></div>");
						}
						//alert("Geocode was not successful for the following reason: " + status);
					}
				});
			}
		});
	}
})(jQuery);


