function triggerGAGoal(sGoalPath){
	trackPageView(sGoalPath);
}
function trackPageView(sPagePath){
	try{
		pageTracker._trackPageview(sPagePath);
	}catch(err){
		//alert('TrackPageview:\n'+err.description);
	}
}

function doOnPageLoad(){
	$(".defaultInputText").focus(function(srcc){if ($(this).val() == $(this)[0].title){$(this).removeClass("defaultInputTextActive");$(this).val("");}});
	$(".defaultInputText").blur(function(){if ($(this).val() == ""){$(this).addClass("defaultInputTextActive");$(this).val($(this)[0].title);}});
	$(".defaultInputText").blur();
	$(".clsFormWithDefault").submit(function(){$("input").each(function(){if($(this).val() == this.title){$(this).val("");}});$("textarea").each(function(){if($(this).val() == this.title){$(this).val("");}});});
	$.fn.setAllToMaxHeight = function(){return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );};
	$("div.unevenHeights").setAllToMaxHeight();
	
	// sort print links
	$(".printLink").click(function(){window.print();});
	
	// prep the lightbox galleries
	$('div.PopupImageGallery a').fancybox({'onStart':function(event){imageExpandedMain();}});
	
	$('div.PhotoContainer table td a[href$=".png"]').attr('rel', 'gallery');
	$('div.PhotoContainer table td a[href$=".png"]').fancybox({'onStart':function(event){imageExpandedGallery();}});
	
	$('div.PhotoContainer table td a[href$=".jpg"]').attr('rel', 'gallery');
	$('div.PhotoContainer table td a[href$=".jpg"]').fancybox({'onStart':function(event){imageExpandedGallery();}});
	
	// prep the fancybox video overlays
	$('a.fancyboxAboutAMS').fancybox({
		'width':890,
		'height':530,
		'autoScale':false,
		'transitionIn':'none',
		'transitionOut':'none',
		'type':'iframe',
		'onStart':function(event){aboutVideoPlayed();}
	});
	
	if (getParameterByName('playvideo') == '1'){$('a.fancyboxAboutAMS').trigger('click');}
	
	$('a[href$=".pdf"]').click(function(event){triggerGAGoal('/DownloadFile/PDF/');}); 
}
function submitSearch(){
	triggerGAGoal('/Search/Submitted/');
}
function imageExpandedMain(){
	triggerGAGoal('/ImageEnlarged/Main/');
}
function imageExpandedGallery(){
	triggerGAGoal('/ImageEnlarged/Gallery/');
}

function aboutVideoPlayed(){
	var sPageURL = window.location.href;
	if (sPageURL.indexOf('french') != -1){
		triggerGAGoal('/WatchAboutUsVideo/French/');
	}else if (sPageURL.indexOf('german') != -1){
		triggerGAGoal('/WatchAboutUsVideo/German/');
	}else{
		triggerGAGoal('/WatchAboutUsVideo/English/');
	}
}

function getParameterByName(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if( results == null ){
		return "";
	}else{
		return decodeURIComponent(results[1].replace(/\+/g, " "));
	}
}
