/*
$.fn.search = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
$.easing['jswing'] = jQuery.easing['swing'];

$.extend( jQuery.easing,
{
	def: 'easeOutBack',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeOutBack: function (x, t, b, c, d, s) {
		//if (s == undefined) s = 1.70158;
		if (s == undefined) s = 0.8;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	}
});

function findexternalAndActiveLinks() {
	var thisDomain = window.location.host,
	thisPath = window.location.pathname;
	
	$("a").each(function (i) {

		if($(this).attr("href") == null || $(this).attr("href") == undefined)
		{
			return false;
		}

		if (($(this).attr("href").match("http") == "http") && ($(this).attr("href").match(thisDomain) != thisDomain)) {
			$(this).click(function(){
				this.target = "_blank";
			});
		}
		if (($(this).attr("href") == thisPath) || ($(this).attr("href") == thisPath+"#") || ($(this).attr("href") == thisPath+"/")) {
			$(this).addClass("linkOn");
		}

	});
}

$(document).ready(function(){

	findexternalAndActiveLinks();
	
	$("#mainNav li").hoverIntent({
		sensitivity: 1, 
      	interval: 50, 
      	over: function() {
        	$(this).children("ul").animate({
				"height": "toggle", "opacity": "toggle"
			}, 300).siblings("a").addClass("subnavParentOpen");
			$(this).children("a").addClass("active");
		}, 
      	timeout: 300, 
      	out: function() {
			$(this).children("ul").animate({
				"height": "toggle", "opacity": "toggle"
			}, 100).siblings("a").removeClass("subnavParentOpen");
			$(this).children("a").removeClass("active");
		}
	});
 
 	$("#mainNav ul li ul").each(function() {
 		var menuMinWidth = $(this).parent().width();
 		$(this).css({'min-width': menuMinWidth});
 	});
    
  	if ($.browser.win()) {
  		$("#mainNav").addClass("windowsOS");
  		}
  		
  	
  	$("#location-tab.normal-tab").hoverIntent({
 		sensitivity: 1, 
      	interval: 50, 
      	over: function () {
      			$(this).stop(true, true).animate({top:"103px"}, 300, 'easeOutBack');
      			}, 
      	timeout: 300, 
      	out: function () {
      				$(this).stop(true, true).animate({top:"-13px"}, 300, 'easeOutBack');
      			}
 	});
  	
	$("#location-tab.home-tab").hoverIntent({
 		sensitivity: 1, 
      	interval: 50, 
      	over: function () {
      			$(this).stop(true, true).animate({top:"80px"}, 300, 'easeOutBack');
      			}, 
      	timeout: 300, 
      	out: function () {
      				$(this).stop(true, true).animate({top:"-36px"}, 300, 'easeOutBack');
      			}
 	});
 	
 	$("#location-tab.totheclient-tab").hoverIntent({
 		sensitivity: 1, 
      	interval: 50, 
      	over: function () {
      			$(this).stop(true, true).animate({top:"283px"}, 300, 'easeOutBack');
      			}, 
      	timeout: 300, 
      	out: function () {
      				$(this).stop(true, true).animate({top:"169px"}, 300, 'easeOutBack');
      			}
 	});
 	
 	
 	

  	
});
