var _spOriginalFormAction;
var _spEscapedFormAction;
var _spFormOnSubmitCalled=false;
var _spBodyOnPageShowRegistered=false;
var _spBodyOnLoadFunctionNames;
if (_spBodyOnLoadFunctionNames==null)
{
	_spBodyOnLoadFunctionNames=new Array();
	_spBodyOnLoadFunctionNames.push("_spBodyOnLoad");
	_spBodyOnLoadFunctionNames.push("_spRestoreScrollForDiv_rscr");
}
var _spBodyOnPageShowRegistered=false;
function _spBodyOnLoadWrapper()
{
	if (!_spBodyOnPageShowRegistered &&
		typeof(browseris) !="undefined" &&
		!browseris.ie &&
		typeof(window.addEventListener)=='function')
	{
		window.addEventListener('pageshow', _spBodyOnPageShow, false);
		_spBodyOnPageShowRegistered=true;
	}
	if (_spOriginalFormAction==null)
	{
		if (document.forms.length > 0)
		{
			_spOriginalFormAction=document.forms[0].action;
			var url=window.location.href;
			var index=url.indexOf("://");
			if (index >=0)
			{
				var temp=url.substring(index+3);
				index=temp.indexOf("/");
				if (index >=0)
					url=temp.substring(index);
			}
			//_spEscapedFormAction=escapeUrlForCallback(url);
			//document.forms[0].action=_spEscapedFormAction;
		}
	}
	_spFormOnSubmitCalled=false;
	if (typeof(Sys) !="undefined" &&
		typeof(Sys.Net) !="undefined" &&
		typeof(Sys.Net.WebRequestManager) !="undefined")
	{
		Sys.Net.WebRequestManager.add_invokingRequest(_spResetFormOnSubmitCalledFlag);
	}
	ProcessDefaultOnLoad(_spBodyOnLoadFunctionNames);
}
var g_updateFormDigestPageLoaded=new Date();
function UpdateFormDigest(serverRelativeWebUrl, updateInterval)
{
	try
	{
		if ((g_updateFormDigestPageLoaded==null) || (typeof(g_updateFormDigestPageLoaded) !="object"))
		{
			return;
		}
		var now=new Date();
		if (now.getTime() - g_updateFormDigestPageLoaded.getTime() < updateInterval)
		{
			return;
		}
		if ((serverRelativeWebUrl==null) || (serverRelativeWebUrl.length <=0))
		{
			return;
		}
		var formDigestElement=document.getElementsByName("__REQUESTDIGEST")[0];
		if ((formDigestElement==null) || (formDigestElement.tagName.toLowerCase() !="input") || (formDigestElement.type.toLowerCase() !="hidden") ||
			(formDigestElement.value==null) || (formDigestElement.value.length <=0))
		{
			return;
		}
		var request=null;
		try
		{
			request=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (ex)
		{
			request=null;
		}
		if (request==null)
		{
			try
			{
				request=new XMLHttpRequest();
			}
			catch (ex)
			{
				request=null;
			}
		}
		if (request==null)
		{
			return;
		}
		request.open("POST", GetUrlFromWebUrlAndWebRelativeUrl(serverRelativeWebUrl, "_vti_bin/sites.asmx"), false);
		request.setRequestHeader("Content-Type", "text/xml");
		request.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetUpdatedFormDigest");
		request.send("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+			"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+			"  <soap:Body>"+			"    <GetUpdatedFormDigest xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />"+			"  </soap:Body>"+			"</soap:Envelope>");
		var responseText=request.responseText;
		if ((responseText==null) || (responseText.length <=0))
		{
			return;
		}
		var startTag='<GetUpdatedFormDigestResult>';
		var endTag='</GetUpdatedFormDigestResult>';
		var startTagIndex=responseText.indexOf(startTag);
		var endTagIndex=responseText.indexOf(endTag, startTagIndex+startTag.length);
		var newFormDigest=null;
		if ((startTagIndex >=0) && (endTagIndex > startTagIndex))
		{
			var newFormDigest=responseText.substring(startTagIndex+startTag.length, endTagIndex);
		}
		if ((newFormDigest==null) || (newFormDigest.length <=0))
		{
			return;
		}
		var oldValue=formDigestElement.value;
		formDigestElement.value=newFormDigest;
	}
	catch (ex)
	{
	}
}
function _spResetFormOnSubmitCalledFlag( sender,  e)
{
	_spFormOnSubmitCalled=false;
}
function _spBodyOnPageShow(evt)
{
	_spFormOnSubmitCalled=false;
}
var _spSuppressFormOnSubmitWrapper=false;
function _spFormOnSubmitWrapper()
{
	if (_spSuppressFormOnSubmitWrapper)
	{
		return true;
	}
	if (_spFormOnSubmitCalled)
	{
		return false;
	}
	if (typeof(_spFormOnSubmit)=="function")
	{
		var retval=_spFormOnSubmit();
		var testval=false;
		if (typeof(retval)==typeof(testval) && retval==testval)
		{
			return false;
		}
	}
	RestoreToOriginalFormAction();
	_spFormOnSubmitCalled=true;
	return true;
}
function RestoreToOriginalFormAction()
{
	if (_spOriginalFormAction !=null)
	{
		if (_spEscapedFormAction==document.forms[0].action)
		{
			document.forms[0].action=_spOriginalFormAction;
		}
		_spOriginalFormAction=null;
		_spEscapedFormAction=null;
	}
}
function RestoreToOriginalFormAction()
{
	if (_spOriginalFormAction !=null)
	{
		if (_spEscapedFormAction==document.forms[0].action)
		{
			document.forms[0].action=_spOriginalFormAction;
		}
		_spOriginalFormAction=null;
		_spEscapedFormAction=null;
	}
}


var UTF8_1ST_OF_2=0xc0   ;
var UTF8_1ST_OF_3=0xe0   ;
var UTF8_1ST_OF_4=0xf0   ;
var UTF8_TRAIL=0x80   ;
var HIGH_SURROGATE_BITS=0xD800 ;
var LOW_SURROGATE_BITS=0xDC00 ;
var SURROGATE_6_BIT=0xFC00 ;
var SURROGATE_ID_BITS=0xF800 ;
var SURROGATE_OFFSET=0x10000;
function ProcessDefaultOnLoad(onLoadFunctionNames)
{
	ProcessPNGImages();
	
	for (var i=0; i < onLoadFunctionNames.length; i++)
	{
		var expr="if(typeof("+onLoadFunctionNames[i]+")=='function'){"+onLoadFunctionNames[i]+"();}";
		eval(expr);
	}
	if (typeof(_spUseDefaultFocus)!="undefined")
		DefaultFocus();
}
function ProcessPNGImages()
{
	var useFilter=browseris.ie &&
				browseris.ie55up &&
				browseris.verIEFull < 7.0;
	if (g_PNGImageIds !=null && useFilter)
	{
		for (var i=0; i < g_PNGImageIds.length; i++)
		{
			var img=document.getElementById(g_PNGImageIds[i]);
			if (img !=null && g_PNGImageSources[i] !=null)
			{
				img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+g_PNGImageSources[i]+"),sizingMethod=scale);";
				img.src="/_layouts/images/blank.gif";
			}
		}
	}
}
var g_PNGImageIds;
var g_PNGImageSources;
function displayPNGImage(id,src,width,height,alt)
{
	if (g_PNGImageIds==null)
		g_PNGImageIds=new Array();
	if (g_PNGImageSources==null)
		g_PNGImageSources=new Array();
	var style=null;
	document.write("<IMG id='"+id+"' ");
	if (width && width > 0)
		document.write("width='"+width+"' ");
	if (height && height > 0)
		document.write("height='"+height+"' ");
	document.write("alt='"+alt+"' ");
	if (style)
		document.write("style='"+style+"' ");
	document.write(" src='"+src+"' />");
	g_PNGImageIds.push(id);
	g_PNGImageSources.push(src);
}
function Browseris () {
	var agt=navigator.userAgent.toLowerCase();
	this.osver=1.0;
	if (agt)
	{
		var stOSVer=agt.substring(agt.indexOf("windows ")+11);
		this.osver=parseFloat(stOSVer);
	}
	this.major=parseInt(navigator.appVersion);
	this.nav=((agt.indexOf('mozilla')!=-1)&&((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1)));
	this.nav6=this.nav && (this.major==5);
	this.nav6up=this.nav && (this.major >=5);
	this.nav7up=false;
	if (this.nav6up)
	{
		var navIdx=agt.indexOf("netscape/");
		if (navIdx >=0 )
			this.nav7up=parseInt(agt.substring(navIdx+9)) >=7;
	}
	this.ie=(agt.indexOf("msie")!=-1);
	this.aol=this.ie && agt.indexOf(" aol ")!=-1;
	if (this.ie)
		{
		var stIEVer=agt.substring(agt.indexOf("msie ")+5);
		this.iever=parseInt(stIEVer);
		this.verIEFull=parseFloat(stIEVer);
		}
	else
		this.iever=0;
	this.ie4up=this.ie && (this.major >=4);
	this.ie5up=this.ie && (this.iever >=5);
	this.ie55up=this.ie && (this.verIEFull >=5.5);
	this.ie6up=this.ie && (this.iever >=6);
	this.winnt=((agt.indexOf("winnt")!=-1)||(agt.indexOf("windows nt")!=-1));
	this.win32=((this.major >=4) && (navigator.platform=="Win32")) ||
		(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1);
	this.mac=(agt.indexOf("mac")!=-1);
	this.w3c=this.nav6up;
	this.safari=(agt.indexOf("safari")!=-1);
	this.safari125up=false;
	if (this.safari && this.major >=5)
	{
		var navIdx=agt.indexOf("safari/");
		if (navIdx >=0)
			this.safari125up=parseInt(agt.substring(navIdx+7)) >=125;
	}
}
var browseris=new Browseris();
var bis=browseris;

