if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}
$(function() { 
		// =========================================
		// Make external links open in a new window 
		// =========================================
		$('a[href^="http"]').not('[href*="' + location.host + '"]')
			.each(function() {
				var $this = $(this);
				var oldtitle = $this.attr("title");
				$this.attr({target: "_blank", title: (oldtitle.length) ? "Opens in a new window: " + oldtitle : "Opens in a new window"})
				.click(function(){ // Add Analytics tracking to external links
					if(_gaq) { _gaq.push(['_trackEvent', 'outgoing_links', this.href]); }
					}); // END Add Analytics tracking to external links
			 });
		
		// Add Analytics tracking to document links
		$('a[href$=".pdf"], a[href$=".doc"], a[href$=".xls"], a[href$=".ppt"], a[href$=".rtf"]').click(function(){ 
			if (_gaq) { _gaq.push(['_trackEvent', 'downloads', this.href]); }
			}); // END Add Analytics tracking to document links
	if( !Modernizr.inputtypes.date ) {
		Date.firstDayOfWeek = 0;
		$('input.date').datePicker().val(new Date().asString('mm/dd/yyyy'));
	}

	if( !Modernizr.input.placeholder ) {
		$('input[placeholder]').placeholder({blankSubmit:true});
	}
	
	$('form.validate').each(function(){
						$(this).validate();
									 });

	var $form = $('#contactus');

	$('.formtrigger').click(function(evt){
		evt.preventDefault();
		$form.slideUp('fast',function(){
			$form.detach();
			$form.appendTo('#footer .wrapper').slideDown();
			$('html,body').animate({scrollTop: $form.offset().top});
			$('#contactus #firstName').focus();
			$('#formType').val('General');

		});
	});
	$('.formReplace').click(function(evt){
		evt.preventDefault();
		var $this = $(this);
		$form.slideUp('fast', function(){
			$form.detach();
			$('.formReplace').show();
			$this.hide();
			$this.after($form);
			$form.slideDown();
			$('html,body').animate({scrollTop: $form.offset().top - 30});
			$('#contactus #firstName').focus();
			$('#formType').val($this.siblings('h2').text());
		});
	});
	$('.backToTop').click(function(evt){
		evt.preventDefault();
		$('.formReplace').show();
		$('#contactus:visible').slideUp();
		$('html,body').animate({scrollTop:100});
	});
});
