function ULSvwe(){var o=new Object;o.ULSTeamName="CMS";o.ULSFileName="SpellCheckEntirePage.js";return o;}
// _lcid="1033" _version="14.0.4750"
// _localBinding
// Version: "14.0.4750"
// Copyright (c) Microsoft Corporation.  All rights reserved.
// Copyright (c) Microsoft Corporation.  All rights reserved.
function jsonSerialize(obj)
{ULSvwe:;
	switch (typeof obj)
	{
		case "undefined":
			return "undefined";
			break;
		case "object":
			if (null==obj)
			{
				return "null";
			}
			else if (obj instanceof Array)
			{
				return jsonSerializeArray(obj);
			}
			else
			{
				return jsonSerializeObject(obj);
			}
			break;
		case "boolean":
			return obj.toString();
			break;
		case "number":
			return obj.toString();
			break;
		case "string":
			return "\""+obj.replace("\\", "\\\\").replace(/"/, "\\\"").replace("\b", "\\b").replace("\t", "\\t").replace("\n", "\\n").replace("\v", "\\v").replace("\f", "\\f").replace("\r", "\\r")+"\"";
			break;
		default:
			throw new Error("Can't serialize object of type "+typeof obj);
	}
}
function jsonSerializeArray(obj)
{ULSvwe:;
	var returnValue="[";
	var objLength=obj.length;
	var firstElement=true;
	for (var i=0; i < objLength;++i)
	{
		try
		{
			var serializedElement=jsonSerialize(obj[i]);
			if (!firstElement)
			{
				returnValue+=",";
			}
			returnValue+=serializedElement;
			firstElement=false;
		}
		catch (e) {  }
	}
	returnValue+="]";
	return returnValue;
}
function jsonSerializeObject(obj)
{ULSvwe:;
	var returnValue="{";
	var firstElement=true;
	for (prop in obj)
	{
		try
		{
			var serializedProp=jsonSerialize(prop);
			var serializedValue=jsonSerialize(obj[prop]);
			if (!firstElement)
			{
				returnValue+=",";
			}
			returnValue+=serializedProp;
			returnValue+=":";
			returnValue+=serializedValue;
			firstElement=false;
		}
		catch (e) {  }
	}
	returnValue+="}";
	return returnValue;
}
function jsonDeserialize(str)
{ULSvwe:;
	var result=new Object();
	var parsed=jsonDeserializePrefix(str, result);
	if (!parsed || (result.remain !=null && result.remain.length > 0))
	{
		throw new Error("Cannot deserialize this string");
	}
	return result.value;
}
function jsonDeserializePrefix(str, result)
{ULSvwe:;
	var re=new RegExp("^undefined(.*)");
	var reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=undefined;
		result.remain=reMatch[1];
		return true;
	}
	re=new RegExp("^null(.*)");
	reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=null;
		result.remain=reMatch[1];
		return true;
	}
	re=new RegExp("^true(.*)");
	reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=true;
		result.remain=reMatch[1];
		return true;
	}
	re=new RegExp("^false(.*)");
	reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=false;
		result.remain=reMatch[1];
		return true;
	}
	var num=parseFloat(str);
	if (!isNaN(num))
	{
		result.value=num;
		result.remain=str.slice(num.toString().length);
		return true;
	}
	re=new RegExp("^\"((?:(?:\\\\\")|(?:[^\"]))*)\"(.*)");
	reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=reMatch[1].replace("\\r", "\r").replace("\\f", "\f").replace("\\v", "\v").replace("\\n", "\n").replace("\\t", "\t").replace("\\b", "\b").replace("\\\"", "\"").replace("\\\\", "\\");
		result.remain=reMatch[2];
		return true;
	}
	re=new RegExp("^\\[(.*)");
	reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=new Array();
		strToParse=reMatch[1];
		do
		{
			if (strToParse.charAt(0)=="]")
			{
				result.remain=strToParse.slice(1);
				return true;
			}
			var tmp=new Object();
			var parsed=jsonDeserializePrefix(strToParse, tmp);
			if (parsed)
			{
				result.value.push(tmp.value);
				if (tmp.remain.charAt(0)==",")
				{
					strToParse=tmp.remain.slice(1);
				}
				else if (tmp.remain.charAt(0)=="]")
				{
					strToParse=tmp.remain;
				}
				else
				{
					parsed=false;
				}
			}
		} while (parsed);
		if (!parsed)
		{
			return false;
		}
	}
	re=new RegExp("^{(.*)");
	reMatch=re.exec(str);
	if (null !=reMatch)
	{
		result.value=new Object();
		strToParse=reMatch[1];
		do
		{
			if (strToParse.charAt(0)=="}")
			{
				result.remain=strToParse.slice(1);
				return true;
			}
			var tmp=new Object();
			var parsed=jsonDeserializePrefix(strToParse, tmp);
			if (parsed)
			{
				if ("string"==typeof tmp.value)
				{
					var propName=tmp.value;
				}
				else
				{
					return false;
				}
				if (tmp.remain.charAt(0)==":")
				{
					strToParse=tmp.remain.slice(1);
					parsed=jsonDeserializePrefix(strToParse, tmp);
					if (parsed)
					{
						result.value[propName]=tmp.value;
						if (tmp.remain.charAt(0)==",")
						{
							strToParse=tmp.remain.slice(1);
						}
						else if (tmp.remain.charAt(0)=="}")
						{
							strToParse=tmp.remain;
						}
						else
						{
							parsed=false;
						}
					}
				}
				else
				{
					parsed=false;
				}
			}
		} while (parsed);
		if (!parsed)
		{
			return false;
		}
	}
}
var L_SpellCheckerDialogWidth_TEXT="760px"; 
var L_SpellCheckerDialogHeight_TEXT="550px"; 
function SpellCheckEntirePage(webServiceUrl, dialogUrl, alertNoWebParts)
{ULSvwe:;
	SpellCheckEntirePageWithExplicitLanguage(webServiceUrl, dialogUrl, alertNoWebParts, L_Language_Text);
}
function SpellCheckEntirePageWithExplicitLanguage(webServiceUrl, dialogUrl, alertNoWebParts, language)
{ULSvwe:;
	if (null==document.getElementById("__spPickerHasReturnValue"))
	{
		var hasReturnValueElement=document.createElement("INPUT");
		hasReturnValueElement.type="hidden";
		hasReturnValueElement.id="__spPickerHasReturnValue";
		document.body.appendChild(hasReturnValueElement);
	}
	if (null==document.getElementById("__spPickerReturnValueHolder"))
	{
		var returnValueHolderElement=document.createElement("INPUT");
		returnValueHolderElement.type="hidden";
		returnValueHolderElement.id="__spPickerReturnValueHolder";
		document.body.appendChild(returnValueHolderElement);
	}
	var index;
	var spellableFields=new Array();
	var chunksToSpell=new Array();
	var elements=document.body.getElementsByTagName("*");
	for (index=0; index < elements.length;++index)
	{
		if (null !=elements[index].getAttribute("excludeFromSpellCheck"))
		{
			continue;
		}
		if (elements[index].tagName=="INPUT")
		{
			if ("text"==elements[index].type)
			{
				if ((null==elements[index].id || !elements[index].id.match("SearchBox")) && elements[index].value !="")
				{
					spellableFields[spellableFields.length]=elements[index];
					chunksToSpell[chunksToSpell.length]=new ChunkToSpell(elements[index].value,
									"text", elements[index].title, spellableFields.length - 1);
				}
			}
			else if ("hidden"==elements[index].type && elements[index].id.indexOf("RichHtmlField_hiddenDisplay") !=-1)
			{
				if ('undefined' !=typeof document.body.createTextRange)
				{
					var displayId=elements[index].id.replace("hiddenDisplay", "displayContent");
					var displayNode=document.getElementById(displayId);
					spellableFields[spellableFields.length]=displayNode;
					chunksToSpell[chunksToSpell.length]=new ChunkToSpell(displayNode.innerHTML,
									"html", elements[index].parentNode.title, spellableFields.length - 1);
				}
			}
		}
		else if (elements[index].tagName=="TEXTAREA")
		{
			var foundInlineHtmlEditor=false;
			if (null !=elements[index].id)
			{
				var strBaseElementID=elements[index].id.replace(/\$/g, "_");
				var docEditor=RTE_GetEditorDocument(strBaseElementID);
				if (null !=docEditor && docEditor.body.innerHTML !="")
				{
					foundInlineHtmlEditor=true;
					if ('undefined' !=typeof document.body.createTextRange)
					{
						spellableFields[spellableFields.length]=elements[index];
						chunksToSpell[chunksToSpell.length]=new ChunkToSpell(docEditor.body.innerHTML,
								"html", elements[index].title, spellableFields.length - 1);
					}
				}
			}
			if (false==foundInlineHtmlEditor && elements[index].value !="")
			{
				spellableFields[spellableFields.length]=elements[index];
				chunksToSpell[chunksToSpell.length]=new ChunkToSpell(elements[index].value,
							"text", elements[index].title, spellableFields.length - 1);
			}
		}
	}
	var features=SpellCheckerDialogFeaturesString();
	var args=new Object();
	args.chunks=chunksToSpell;
	args.lang=language;
	args.webServiceUrl=webServiceUrl;
	args.alertNoWebParts=alertNoWebParts;
	var callback=function(spelledChunks)
	{ULSvwe:;
		if (null==spelledChunks)
		{
			var hasReturnValueElement=document.getElementById("__spPickerHasReturnValue");
			var returnValueHolderElement=document.getElementById("__spPickerReturnValueHolder");
			if (null !=hasReturnValueElement && hasReturnValueElement.value=="1" && null !=returnValueHolderElement)
			{
				try
				{
					spelledChunks=jsonDeserialize(returnValueHolderElement.value);
				}
				catch (e) {}
			}
		}
		else if ("string"==typeof(spelledChunks))
		{
				try
				{
					spelledChunks=jsonDeserialize(spelledChunks);
				}
				catch (e) {}
		}
		if (null !=spelledChunks && "string" !=typeof(spelledChunks))
		{
			for (index=0; index < spelledChunks.length;++index)
			{
				if ("INPUT"==spellableFields[spelledChunks[index].Index].tagName)
				{
					if ("text"==spellableFields[spelledChunks[index].Index].type)
					{
						spellableFields[spelledChunks[index].Index].value=spelledChunks[index].Text;
					}
					else if ("hidden"==spellableFields[spelledChunks[index].Index].type)
					{
						if (typeof(RTE2_ReplaceContent) !="undefined")
						{
							RTE2_ReplaceContent(spellableFields[spelledChunks[index].Index].id, spelledChunks[index].Html);
						}
						else
						{
							spellableFields[spelledChunks[index].Index].innerHTML=spelledChunks[index].Html;
						}
					}
				}
				else if ("TEXTAREA"==spellableFields[spelledChunks[index].Index].tagName)
				{
					if (null !=spelledChunks[index].Text)
					{
						spellableFields[spelledChunks[index].Index].value=spelledChunks[index].Text;
					}
					else if (null !=spelledChunks[index].Html && null !=spellableFields[spelledChunks[index].Index].id)
					{
						var strBaseElementID=spellableFields[spelledChunks[index].Index].id.replace(/\$/g, "_");
						var docEditor=RTE_GetEditorDocument(strBaseElementID);
						docEditor.body.innerHTML=spelledChunks[index].Html;
					}
				}
				else if ("DIV"==spellableFields[spelledChunks[index].Index].tagName)
				{
					if (typeof(RTE2_ReplaceContent) !="undefined")
					{
						var strBaseElementID=spellableFields[spelledChunks[index].Index].id.replace("_displayContent", "");
						RTE2_ReplaceContent(strBaseElementID, spelledChunks[index].Html);
					}
					else
					{
						spellableFields[spelledChunks[index].Index].innerHTML=spelledChunks[index].Html;
					}
				}
			}
		}
	};
	commonShowModalDialog(dialogUrl, features, callback, args);
}
function ChunkToSpell(content, type, displayName, index)
{ULSvwe:;
	if ("text"==type)
	{
		this.Text=content;
		this.Html=null;
	}
	else
	{
		this.Text=null;
		this.Html=content;
	}
	this.DisplayName=displayName;
	this.Index=index;
}
function SpellCheckerDialogFeaturesString()
{ULSvwe:;
	return "dialogWidth:"+L_SpellCheckerDialogWidth_TEXT+";dialogHeight:"+L_SpellCheckerDialogHeight_TEXT+";status:no;resizable:yes;scroll:no";
}
if( typeof(Sys) !="undefined" && Sys && Sys.Application )
{
   Sys.Application.notifyScriptLoaded();
}
if (typeof(NotifyScriptLoadedAndExecuteWaitingJobs) !="undefined")
{
	NotifyScriptLoadedAndExecuteWaitingJobs("spellcheckentirepage.js");
}

