//called by defer script in header
//try{
//window.onbeforeunload=showLoadingLayer;
//}catch(x){}

function checkContains(strToCheck, strItemsToCheckFor){
	var aryItems = strItemsToCheckFor.toString().split(",");
	for(var i=0;i<aryItems.length;i++){
		if(strToCheck.indexOf(aryItems[i])!=-1){
			return true;
		}
	}
	return false;
}

//function adds call to function which sets image off animating after page has started unloading
function addAnLoadToLinks(){
	//add to anchors
	var e=document.getElementsByTagName("a");
	var thishref;
	for(var i=0;i<e.length;i++){
		if(!(e[i].disabled)){
			if(e[i].target!="_blank"){
				thishref=unescape(e[i].href);
				//if (e[i].id != "btnProceed") {
					if(!checkContains(thishref, ".reset(),Page_ClientValidate,setDate,showCalendar,calSelect,mailto:")){ //don't add to form reset buttons or items containing client side validation
						if(thishref.indexOf("javascript:")!=-1){
							e[i].href = thishref + ";anLoad();"
						}else{
							if(thishref!=""){
								e[i].href = "javascript:go('"+thishref+"');anLoad();";
							}
						}
					}
				//}
			}
		}
	}
	//add to onsubmit in forms
	var e=document.getElementsByTagName("form");
	var thishref;
	for(var i=0;i<e.length;i++){
		thisonsubmit=unescape(e[i].onsubmit);
		e[i].onsubmit = thisonsubmit + ";anLoad();"
	}
	/*
	// add to image and submit buttons
	var e=document.getElementsByTagName("input");
	var thishref;
	for(var i=0;i<e.length;i++){
		if(e[i].type=="image" || e[i].type=="submit"){
			if(e[i].onclick!=null && e[i].onclick!=""){
				thisonclick = unescape(e[i].onclick) + ";";
			}else{
				thisonclick = "";
			}
			e[i].onclick = thisonclick + "anLoad();"
		}
	}*/
}
try{
	var b1 = (document.getElementById("AuthoringPreviewAnchor")==null);
	var b2 = (document.getElementById("PresentationPreviewAnchor")==null);
	if(b1 && b2){
		addAnLoadToLinks();
	}
}catch(x){}