/* click tracker - needs Google Analytics and jQuery JS */
$(document).ready(function(){
 if (typeof(_gat) == 'object') {
  $('a').each(function() {
   var uri = $(this).attr('href');
	if (uri) {
	   if (uri.match(/^mailto/i)) {
	    $(this).click(function() { ahTracker._trackEvent('mailto', 'click', document.domain + ' | ' + uri.substr(7));siteTracker._trackEvent('mailto', 'click', uri.substr(7));});
	   } else if (uri.match(/^https?:/i)) {
	    $(this).click(function() { ahTracker._trackEvent('external', 'click', document.domain + ' | ' + uri);siteTracker._trackEvent('external', 'click', uri);});
	   } else if (uri.match(/\.[a-z]{3}$/i) && ! uri.match(/\.(aspx?|html?)([\?#].*)?$/i)) {
	  	var filetype = uri.substr(uri.length-3)
	    $(this).click(function() { ahTracker._trackEvent('downloads', filetype.toUpperCase(), document.domain + ' | ' + uri);siteTracker._trackEvent('downloads', filetype.toUpperCase(), uri);});
		}
	}
  });
 }
});


var Sp	= {
	
	UI: {}
	
};

Sp.UI.Navigation = function() {
	
	var init	= function() {
		
		searchForm();
		replaceSubmits();
		enhanceCSS();
		lozengeLinks();
		imageBoxes();
		formBoxes();
		faqFormBoxes();
	}


	var searchForm	= function() {
		jQuery('#fKeys').focus(function(){
			if (this.value == this.defaultValue) this.value = '';
		}).blur(function(){
			if (this.value == '') this.value = this.defaultValue;
		}).keyup(function(e){
			e.preventDefault();
			var val	= $(this).val()
			if (val.length>3) search(val);
		});
	}
	
	
	var enhanceCSS	= function() {
		if ($.browser.msie) {
			$('#main .content h1 + p').addClass("intro");
			$('#main .content h2 + p').addClass("firstpara");
			$('#main .nav li:last-child').css('border-bottom', '1px solid #fff');
		}
	}
	
	
	
	var replaceSubmits	= function() {
		$('form input.replace').each(function(i, obj) {
			obj = $(obj);
			obj.hide()
			obj.after($('<button type="submit" class="replaced submit"><img src="/img/search-button.png" /></button>'));
			
		});
		
		
	}
	
	var lozengeLinks = function() {
		 settings = {
          tl: { radius: 8 },
          tr: { radius: 8 },
          bl: { radius: 8 },
          br: { radius: 8 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }

      var myBoxObject = new curvyCorners(settings, "link");
      myBoxObject.applyCornersToAll();
	}
	
	
	var imageBoxes = function() {
		 settings = {
          tl: { radius: 8 },
          tr: { radius: 8 },
          bl: { radius: 8 },
          br: { radius: 8 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }

      var myBoxObject = new curvyCorners(settings, "imagebox");
      myBoxObject.applyCornersToAll();
	}
	
	var formBoxes = function() {
		 settings = {
          tl: { radius: 12 },
          tr: { radius: 12 },
          bl: { radius: 12 },
          br: { radius: 12 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }

      var myBoxObject = new curvyCorners(settings, "formbox");
      myBoxObject.applyCornersToAll();
	}
	
	var faqFormBoxes = function() {
		 settings = {
          tl: { radius: 6 },
          tr: { radius: 6 },
          bl: { radius: 6 },
          br: { radius: 6 },
          antiAlias: true,
          autoPad: false,
          validTags: ["div"]
      }

      var myBoxObject = new curvyCorners(settings, "faqformbox");
      myBoxObject.applyCornersToAll();
	}

	return {
		init: init
	}

}();

jQuery(function($) { Sp.UI.Navigation.init(); });


