var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5_2  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.2") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5 && !is_ie5_2);
var is_ie7    = (is_ie && (agt.indexOf("msie 7.")!=-1) );	
var is_safari = (agt.indexOf("safari") != -1);

var notAllowedProfileChars = "<>";

	/*
	 * checks for empty string
	 */
	function et_g_isEmpty(s)
	{
		return ((s == null) || (s.length == 0));
	}
	
	function et_g_isInteger (s)
	{
		var i;
		for (i = 0; i < s.length; i++){
			// Check that current character is number.
			var c = s.charAt(i);
			if (!et_g_isDigit(c)) return false;
		}
		// All characters are numbers.
		return true;
	}
	// Returns true if character c is a digit
	// (0 .. 9).
	function et_g_isDigit (c)
	{
		return ((c >= "0") && (c <= "9"))
	}
	
	// Returns true if character c is a digit
	// (1 .. 9).
	function et_g_isNonZeroDigit (c)
	{
		return ((c > "0") && (c <= "9"))
	}
	
	function et_g_isNonZeroInteger(s)
	{
		var i;
		if(s.length==1){
			if(et_g_isNonZeroDigit (s)) return true;
			else return false;
		}
		for (i = 0; i < s.length; i++){
			// Check that current character is number.
			var c = s.charAt(i);
			if (!et_g_isInteger(c)) return false;
		}
		// All characters are numbers.
		return true;
	}
	
	
	/*
	 * checks for whitespace string
	 */
	function et_g_isWhitespace (s)
	{
		return (et_g_isEmpty(s) || et_g_reWhitespace.test(s));
	}
function getDataUsingAjax(id,params,className,methodName,pluginName)
	{
		var ajaxReader  = new WikiAjax(false);
		ajaxReader.setMethodTOPOST();
		var afterGettingDataFromAjax = new AfterGettingDataFromAjax(id);
		ajaxReader.setCallback(afterGettingDataFromAjax.process);
		
		var req = createRequest(createManagerMethod(methodName, params,className,pluginName));
		ajaxReader.addField("reqdata", req);
		ajaxReader.send();
	}
	
	function AfterGettingDataFromAjax( id )
	{
		this.id = id;
		this.process = process;
	
		function process( responseDOM, errorMessage, responseText )
		{
			var obj = parseResponse(responseDOM);
			if(obj == null)
			{
				alert(generalMsgLocalizer.getMessage("response_not_well"));
			}
			else
			{
				if(obj.statusCode == "200")
				{ 
					if(obj.output +"" != "")
					{
					
						document.getElementById(id).innerHTML = obj.output;			
							 JT_init();
					}
					
					
				}
				
			}
		}
	}
	var plugdivtarget;
	
	
	function AfterEditPluginProperties(currentTarget,plugDiv,macroId)
	{
		
		this.currentTarget = currentTarget;
		this.plugDiv = plugDiv;
		this.process = process;
	    this.macroId = macroId;
		function process( responseDOM, errorMessage, responseText )
		{
				
			var obj = parseResponse(responseDOM);
				
			if(obj == null)
			{
				alert(generalMsgLocalizer.getMessage("response_not_well"));
			}
			else
			{
				if(obj.statusCode == "200")
				{ 
					if(obj.output +"" != "")
					{
						var encodedMacroId = macroId.replace("$","_");
						encodedMacroId = encodedMacroId.replace("#","_");
						plugDiv.innerHTML = obj.output;	
					
						var projtitleid="#projectname"+encodedMacroId; 
						var pagetitleid="#title"+encodedMacroId;
						var attachtitleid="#attachtitle"+encodedMacroId;
						JT_init();
						$(document).ready(function() {
							
							var ac = $(projtitleid).autocomplete("autocomplete.jsp",{delay:10,minChars:2,matchSubset:1,matchContains:1,cacheLength:10,onItemSelect:selectItem,onFindValue:findValue,formatItem:formatItem,autoFill:true});
                            
                            if(ac[0])
                            	ac[0].autocompleter.setExtraParams({operation:"projectlist"});
						});
						
						$(document).ready(function() {
							var ac = $(pagetitleid).autocomplete("autocomplete.jsp",{delay:10,minChars:2,matchSubset:1,matchContains:1,cacheLength:10,onItemSelect:selectItem,onFindValue:findValue,formatItem:formatItem,autoFill:true});
                            if(ac[0])
                            	ac[0].autocompleter.setExtraParams({operation:"pagelist",macroId:encodedMacroId });
						});
						
						$(document).ready(function() {
							var ac = $(attachtitleid).autocomplete("autocomplete.jsp",{delay:10,minChars:2,matchSubset:1,matchContains:1,cacheLength:10,onItemSelect:selectItem,onFindValue:findValue,formatItem:formatItem,autoFill:true});
                            if(ac[0])
                            {
                            	var prjName = document.getElementById("projectname").value;
								var pageName = document.getElementById("editpage_title").value;
                           		ac[0].autocompleter.setExtraParams({operation:"attachlist",projectname:prjName,pagetitle:pageName });
                            }
						});
					}
					
				}
				
			}
		}
	}
	
	function findValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;

	//alert("The value you selected was: " + sValue);
}

function selectItem(li) {
	findValue(li);
}

function formatItem(row) {
	return row[0] ;
}
	
	
	
	
	function AfterInsertPluginProperties(plugDiv,macroId)
	{
		
		
		this.plugDiv = plugDiv;
		this.process = process;
	    this.macroId = macroId;
		function process( responseDOM, errorMessage, responseText )
		{
			
			var obj = parseResponse(responseDOM);
			if(obj == null)
			{
				alert(generalMsgLocalizer.getMessage("response_not_well"));
			}
			else
			{
				if(obj.statusCode == "200")
				{ 
					if(obj.output +"" != "")
					{
						var encodedMacroId = macroId.replace("$","_");
						encodedMacroId = encodedMacroId.replace("#","_");
						
						plugDiv.innerHTML = obj.output;	
						var projtitleid="#projectname"+encodedMacroId; 	
						var pagetitleid="#title"+encodedMacroId;
						var attachtitleid="#attachtitle"+encodedMacroId;
						JT_init();
						$(document).ready(function() {
							
							var ac = $(projtitleid).autocomplete("autocomplete.jsp",{delay:10,minChars:2,matchSubset:1,matchContains:1,cacheLength:10,onItemSelect:selectItem,onFindValue:findValue,formatItem:formatItem,autoFill:true});
                            if(ac[0])
                            	ac[0].autocompleter.setExtraParams({operation:"projectlist"});
						});
						
						$(document).ready(function() {
							var ac = $(pagetitleid).autocomplete("autocomplete.jsp",{delay:10,minChars:2,matchSubset:1,matchContains:1,cacheLength:10,onItemSelect:selectItem,onFindValue:findValue,formatItem:formatItem,autoFill:true});
                            if(ac[0])
                            	ac[0].autocompleter.setExtraParams({operation:"pagelist",macroId:encodedMacroId });
						});
						
						$(document).ready(function() {
							var ac = $(attachtitleid).autocomplete("autocomplete.jsp",{delay:10,minChars:2,matchSubset:1,matchContains:1,cacheLength:10,onItemSelect:selectItem,onFindValue:findValue,formatItem:formatItem,autoFill:true});
                            if(ac[0])
                            {
                            	var prjName = document.getElementById("projectname").value;
								var pageName = document.getElementById("editpage_title").value;
                           		ac[0].autocompleter.setExtraParams({operation:"attachlist",projectname:prjName,pagetitle:pageName });
                            }
						});
						
					}
					
				}
				
			}
		}
	}
	
	
	function insertPluginProps()
	{
		
		var pluginParameters = document.getElementById("hiddenplugin").value;

		var macroId = document.getElementById("macroid").value;
	
		var replaceString =macroId+"{";
		
		var arParameters = pluginParameters.split(",");
		var refString="";
		if(macroId == "$feed")
		{
			
			var paramValue = "";
			if(document.getElementById("listtype_feed") && document.getElementById("listtype_feed").value != "" && document.getElementById("listtype_feed").value != "none")
			{
				paramValue =  document.getElementById("listtype_feed").value;
				if(paramValue != "")
				{
					refString= refString+"listtype="+paramValue;				
				}
				if(document.getElementById("projectname_feed") && document.getElementById("projectname_feed").value != "")
				{
					paramValue =  document.getElementById("projectname_feed").value;
					if(paramValue != "")
					{
						refString= refString+":projectname="+paramValue;				
					}
				}
				if(document.getElementById("letter_feed") && document.getElementById("letter_feed").value != "")
				{
					paramValue =  document.getElementById("letter_feed").value;
					if(paramValue != "")
					{
						refString= refString+":letter="+paramValue;				
					}
				}
				if(document.getElementById("tag_feed") && document.getElementById("tag_feed").value != "")
				{
					paramValue =  document.getElementById("tag_feed").value;
					if(paramValue != "")
					{
						refString= refString+":tag="+paramValue;				
					}
				}
				if(document.getElementById("topic_feed") && document.getElementById("topic_feed").value != "")
				{
					paramValue =  document.getElementById("topic_feed").value;
					if(paramValue != "")
					{
						refString= refString+":topic="+paramValue;				
					}
				}
				if(document.getElementById("news_filter_feed") && document.getElementById("news_filter_feed").value != "")
				{
					paramValue =  document.getElementById("news_filter_feed").value;
					if(paramValue != "")
					{
						refString= refString+":news_filter="+paramValue;				
					}
				}
				if(document.getElementById("searchtext_feed") && document.getElementById("searchtext_feed").value != "")
				{
					paramValue =  document.getElementById("searchtext_feed").value;
					if(paramValue != "")
					{
						refString= refString+":searchtext="+paramValue;				
					}
				}
				if(document.getElementById("caption_feed") && document.getElementById("caption_feed").value != "")
				{
					paramValue =  document.getElementById("caption_feed").value;
					if(paramValue != "")
					{
						refString= refString+":caption="+paramValue;				
					}
				}
			}
		}
		for(var i=0;i<arParameters.length;i++)
		{
			if((arParameters[i]).length == 0)
			{
				continue;
			}
			var arParameter = (arParameters[i]).split(":");
			var plugParameterName = arParameter[0];
			var plugParameterId = arParameter[1];
			var isMandatory = arParameter[2];
			var param =document.getElementById(""+plugParameterId+"");
			var paramValue = document.getElementById(""+plugParameterId+"").value;
			if(param.type =="checkbox")
			{
				if(param.checked)
				{
					paramValue = "true";
				}
				else
				{
					paramValue = "false";
				}
			}
			paramValue = paramValue.replace(/</g,"&lt;");
			paramValue = paramValue.replace(/>/g,"&gt;");
			if(macroId == "$feed")
			{
				if(plugParameterId == "ref_feed")
				{
					if(paramValue.length == 0)
					{
						paramValue = refString;
					}
				}
			}
			if(paramValue.length > 0 || paramValue == "none")
			{
				replaceString = replaceString + " "+plugParameterName+"=\""+paramValue+"\"";
			}
			else
			{
				if(isMandatory == "true")
				{	
					alert("Mandatory");
					document.getElementById("errormessage").setAttribute("class","errormessage_visible");
					document.getElementById("errormessage").className = "errormessage_visible";
					(param.parentNode.parentNode).style.backgroundColor="#FFCCCC";
					return false;
				}
			}
		}
		replaceString = replaceString + "}";
		
		var doc = wys_editor._doc;
		wys_editor.focusEditor();
		var sel = wys_editor._getSelection();
		var range = wys_editor._createRange(sel);
		var wiki = doc.createElement("div");
		wiki.className="plugin";
		wiki.innerHTML=replaceString;
		if (HTMLArea.is_ie) {
			range.pasteHTML(wiki.outerHTML+"</br>");
			wys_editor.focusEditor();
		} else {
			wys_editor.insertNodeAtSelection(wiki);
			doc.createElement("br");
			//wiki.parentNode.insertBefore(doc.createElement("br"), wiki.nextSibling);
			wys_editor.focusEditor();	
			
		}
		disablePopup();
		var tableelem = document.getElementById("generatedpluginui");
		(tableelem.parentNode).removeChild(tableelem);
		/*
		//remove the elements from DOM so that XSSFilter doesn't process these temporary elements
		for(var i=0;i<arParameters.length;i++)
		{
			if((arParameters[i]).length == 0)
			{
				continue;
			}
			var arParameter = (arParameters[i]).split(":");
			var plugParameterName = arParameter[0];
			var plugParameterId = arParameter[1];
			var param =document.getElementById(""+plugParameterId+"");
			(param.parentNode).removeChild(param);
		}
		*/
		
	}
	
	function editPluginProps()
	{
		var pluginParameters = document.getElementById("hiddenplugin").value;

		var macroId = document.getElementById("macroid").value;
		//alert(macroId);
		var replaceString =macroId+"{";
		
		var arParameters = pluginParameters.split(",");
		var refString="";
			if(macroId == "$feed")
		{
			var paramValue = "";
			if(document.getElementById("listtype_feed") && document.getElementById("listtype_feed").value != "" && document.getElementById("listtype_feed").value != "none")
			{
				paramValue =  document.getElementById("listtype_feed").value;
				if(paramValue != "")
				{
					refString= refString+"listtype="+paramValue;				
				}
				if(document.getElementById("projectname_feed") && document.getElementById("projectname_feed").value != "")
				{
					paramValue =  document.getElementById("projectname_feed").value;
					if(paramValue != "")
					{
						refString= refString+":projectname="+paramValue;				
					}
				}
				if(document.getElementById("letter_feed") && document.getElementById("letter_feed").value != "")
				{
					paramValue =  document.getElementById("letter_feed").value;
					if(paramValue != "")
					{
						refString= refString+":letter="+paramValue;				
					}
				}
				if(document.getElementById("tag_feed") && document.getElementById("tag_feed").value != "")
				{
					paramValue =  document.getElementById("tag_feed").value;
					if(paramValue != "")
					{
						refString= refString+":tag="+paramValue;				
					}
				}
				if(document.getElementById("topic_feed") && document.getElementById("topic_feed").value != "")
				{
					paramValue =  document.getElementById("topic_feed").value;
					if(paramValue != "")
					{
						refString= refString+":topic="+paramValue;				
					}
				}
				if(document.getElementById("news_filter_feed") && document.getElementById("news_filter_feed").value != "")
				{
					paramValue =  document.getElementById("news_filter_feed").value;
					if(paramValue != "")
					{
						refString= refString+":news_filter="+paramValue;				
					}
				}
				if(document.getElementById("searchtext_feed") && document.getElementById("searchtext_feed").value != "")
				{
					paramValue =  document.getElementById("searchtext_feed").value;
					if(paramValue != "")
					{
						refString= refString+":searchtext="+paramValue;				
					}
				}
				if(document.getElementById("caption_feed") && document.getElementById("caption_feed").value != "")
				{
					paramValue =  document.getElementById("caption_feed").value;
					if(paramValue != "")
					{
						refString= refString+":caption="+paramValue;				
					}
				}
			}
		}
		
		for(var i=0;i<arParameters.length;i++)
		{
			if((arParameters[i]).length == 0)
			{
				continue;
			}
			var arParameter = (arParameters[i]).split(":");
			var plugParameterName = arParameter[0];
			var plugParameterId = arParameter[1];
			var isMandatory = arParameter[2];
			var param =document.getElementById(""+plugParameterId+"");
			var paramValue = document.getElementById(""+plugParameterId+"").value;
			if(param.type =="checkbox")
			{
				if(param.checked)
				{
					paramValue = "true";
				}
				else
				{
					paramValue = "false";
				}
			}
			
			paramValue = paramValue.replace(/</g,"&lt;");
			paramValue = paramValue.replace(/>/g,"&gt;");
			if(macroId == "$feed")
			{
				if(plugParameterId == "ref_feed")
				{
					if(paramValue.length == 0)
					{
						paramValue = refString;
					}
				}
			}
			if(paramValue.length > 0)
			{
				replaceString = replaceString + " "+plugParameterName+"=\""+paramValue+"\"";
			}
			else
			{
				if(isMandatory == "true")
				{	
					document.getElementById("errormessage").setAttribute("class","errormessage_visible");
					document.getElementById("errormessage").className = "errormessage_visible";
					(param.parentNode.parentNode).style.backgroundColor="#FFCCCC";
					return false;
				}
			}
			
		}
		
		replaceString = replaceString + "}";
		
		plugdivtarget.innerHTML=replaceString;
		disablePopup();
		var tableelem = document.getElementById("generatedpluginui");
		(tableelem.parentNode).removeChild(tableelem);
		/*
		//remove the elements from DOM so that XSSFilter doesn't process these temporary elements
		for(var i=0;i<arParameters.length;i++)
		{
			if((arParameters[i]).length == 0)
			{
				continue;
			}
			var arParameter = (arParameters[i]).split(":");
			var plugParameterName = arParameter[0];
			var plugParameterId = arParameter[1];
			var param =document.getElementById(""+plugParameterId+"");
			(param.parentNode).removeChild(param);
		}
		*/
	}
	
	function insertSpecificPlugin(macroId)
	{
		var doc = wys_editor._doc;
		wys_editor.focusEditor();
		var sel = wys_editor._getSelection();
		var range = wys_editor._createRange(sel);
		var wiki = doc.createElement("div");
		wiki.className="plugin";
		if(macroId == "$other")
		{
			wiki.innerHTML="Enter Plugin Here";
		}
		else if(macroId == "$cal{}")
		{
			wiki.innerHTML="$cal{month=\"\" year=\"\" view=\"full\" events=\"mm-dd-yyyy(time;event1|time2;event2|event3)\" }";
		}
		if (HTMLArea.is_ie) {
			range.pasteHTML(wiki.outerHTML+"<br/>");
			wys_editor.focusEditor();
		} else {
			wys_editor.insertNodeAtSelection(wiki);
			doc.createElement("br");
			//wiki.parentNode.insertBefore(doc.createElement("br"), wiki.nextSibling);
			wys_editor.focusEditor();	
			
		}	
		disablePopup();
	}
	
	function insertMiscPlugin(macroId)
	{
		var doc = wys_editor._doc;
		wys_editor.focusEditor();
		var sel = wys_editor._getSelection();
		var range = wys_editor._createRange(sel);
		var wiki = doc.createElement("div");
		wiki.className="plugin";
		wiki.innerHTML=macroId;
		if (HTMLArea.is_ie) {
			range.pasteHTML(wiki.outerHTML+"<br/>");
			wys_editor.focusEditor();
		} else {
			wys_editor.insertNodeAtSelection(wiki);
			doc.createElement("br");
			//wiki.parentNode.insertBefore(doc.createElement("br"), wiki.nextSibling);
			wys_editor.focusEditor();	
			
		}	
		disablePopup();
	}
	
	
	
	function cancelPluginProps()
	{
		disablePopup();
	}
	
	

	function showSmiley()
	{
		centerPopup();
		//load popup
		loadPopup();
		var propDiv = document.createElement('div');
		
		var plugDiv = document.getElementById("popupContact");

		var ajaxReader  = new WikiAjax();
		ajaxReader.setMethodTOPOST();
		//var reqURL = siteContext + "generateUI.jsp";
		//ajaxReader.setRequestURL(reqURL);
		var showSmileyCallBack = new ShowSmileyCallBack(plugDiv);
		ajaxReader.setCallback(showSmileyCallBack.process);
		var params = new Array();
		var req = createRequest(createManagerMethod("generateSmileyUI", params,"net.etouch.contmgmt.wiki.GenerateSmileyUI"));
		ajaxReader.addField("reqdata", req);
		ajaxReader.send();
		
	}
	
	function ShowSmileyCallBack(plugDiv)
	{
		this.plugDiv = plugDiv;
		this.process = process;
		
		function process( responseDOM, errorMessage, responseText )
		{
	
			var obj = parseResponse(responseDOM);
						
			if(obj == null)
			{
				alert(generalMsgLocalizer.getMessage("response_not_well"));
			}
			else
			{
				if(obj.statusCode == "200")
				{ 
					if(obj.output +"" != "")
					{
						plugDiv.innerHTML = obj.output;					
					}
					
				}
				
			}
		}
	}
	
	function InsertSmiley(url)
	{
		disablePopup();
		var doc = wys_editor._doc;
		var outparam = null;
		
		var img = doc.createElement("img");
		
		img.src = url;
		img.setAttribute("align","absmiddle");
		
		if (HTMLArea.is_ie) {
			var sel = wys_editor._getSelection();
	   		var range = wys_editor._createRange(sel);
			range.pasteHTML(img.outerHTML);
		} else {
			// insert the table
			wys_editor.insertNodeAtSelection(img);
		}
		
		wys_editor.focusEditor();
		
	}
	
	
	
	function RSSResponseHandler( id, uri )
	{
		this.id = id;
		this.uri = uri;
		this.process = process;
		
		function process( responseDOM, errorMessage, responseText )
		{
			if(errorMessage == null)
			{
				var channel = responseDOM.getElementsByTagName("channel")[0];
				if(channel==null)
				{
					channel = responseDOM.getElementsByTagName("feed")[0];
				}
				if(channel == null)
				{
					var obj = parseResponse(responseDOM);
					if(obj == null)
					{
						document.getElementById(id).innerHTML = generalMsgLocalizer.getMessage("response_not_well");
					}
					else if(typeof obj.output == "undefined")
					{
						document.getElementById(id).innerHTML = generalMsgLocalizer.getMessage("rss_resp_not_well");
					}
					else
					{
						document.getElementById(id).innerHTML = generalMsgLocalizer.getMessage("err_msg") + "["+ obj.statusMessage + "] " + obj.output;
					}
				}
				else
				{
					writeRSSDivContent(id, responseDOM);
				}
			}
		}
	}
	
	function writeRSSDivContent(id, responseDOM)
	{
		
		var channel 			= 	responseDOM.getElementsByTagName("channel")[0];
		if(channel == null)
		{
			channel 			= 	responseDOM.getElementsByTagName("feed")[0];
		}
		
		var channelTitle 		= 	getElementTextNS("", "title", channel, 0);
	
		var channelLink			=	getElementTextNS("", "link", channel, 0);
		var channelDescription	=	getElementTextNS("", "description", channel, 0);
		if(channelDescription==null)
		{
			channelDescription	=	getElementTextNS("", "tagline", channel, 0);
		}
		var channelPubDate		=	getElementTextNS("", "pubDate", channel, 0);
		if(channelPubDate==null)
		{
			channelPubDate		=	getElementTextNS("", "modified", channel, 0);
		}
		
		var channelImage 		= 	channel.getElementsByTagName("image")[0];
		var divTitle			=	document.getElementById(id).getAttribute("title");
		var showHeading			=	document.getElementById(id).getAttribute("show_heading");
		var showDate			=	document.getElementById(id).getAttribute("show_date");
		var showDesc			=	document.getElementById(id).getAttribute("show_desc");
		var showHeadingImage	=	document.getElementById(id).getAttribute("show_headingimage");
		var isinternalLink		=	document.getElementById(id).getAttribute("internal");
		
		var cols				=	document.getElementById(id).getAttribute("cols");
		var tbStyle				=	document.getElementById(id).getAttribute("table_style");
		var trStyle				=	document.getElementById(id).getAttribute("tr_style");
		var tdStyle				=	document.getElementById(id).getAttribute("td_style");
		var maxItemCount 		=	10000;
		var tablecols			=	1;
		
		if( document.getElementById(id).getAttribute("count") != null )
		{
			try
			{
				var cnt = parseInt(document.getElementById(id).getAttribute("count")); 
				if(cnt>0)
				{
					maxItemCount = cnt; 
				}
			}
			catch(err){}
		}
		if(tbStyle==null)
		{
			tbStyle = "border:0px;margin:0px;padding:0px";
		}
		if(tdStyle==null)
		{
			tdStyle = "padding:4px;";
		}
		if(trStyle==null)
		{
			trStyle = "";
		}
		var internalLink = false;
		if(isinternalLink!=null && isinternalLink=="true")
		{
			internalLink = true;
		}
		if( cols != null && !et_g_isWhitespace(cols))
		{
			try
			{
				if(parseInt(cols)>1)
				{
					tablecols = parseInt(cols); 
				}
			}
			catch(err){}
		}
		
		if( showHeadingImage==null || et_g_isWhitespace(showHeadingImage))
		{
			showHeadingImage = "true";
		}
		
		if( showHeading==null || et_g_isWhitespace(showHeading))
		{
			showHeading = "true";
		}
		
		if( showDate==null || et_g_isWhitespace(showDate) )
		{
			showDate = "true";
		}

		if( showDesc==null || et_g_isWhitespace(showDesc) )
		{
			showDesc = "true";
		}
		
		if( et_g_isWhitespace(divTitle) && !et_g_isWhitespace(channelTitle) )
		{
			divTitle	=	channelTitle;
		}
		
		var htmlArray = new Array();
		htmlArray.push("<table cellspacing='0' cellpadding='0' style=\""+tbStyle+"\" border='0'>");
		if( trim(showHeading.toLowerCase()) == "true")
		{
			try
			{
				if( showHeadingImage=="true" && channelImage != null )
				{
					htmlArray.push("<tr>");
					htmlArray.push("<td valign='top' class=\"rssheading\" colspan=\""+tablecols+"\">");
					var img = getElementTextNS("", "url", channelImage, 0);
					var imgtitle = getElementTextNS("", "title", channelImage, 0);
					var imglink = getElementTextNS("", "link", channelImage, 0);
					if(!et_g_isWhitespace(img) && !et_g_isWhitespace(imgtitle) && !et_g_isWhitespace(imglink))
					{
						var imgTag  = "<a href=\""+imglink+"\" "+(!internalLink?"target='_blank'":(parent?"target='_parent'":""))+">" + "<img align='absmiddle' border='0' src=\"" + img + "\" title=\"" + imgtitle + "\" alt=\"" + imgtitle + "\"" + "></a> ";
						htmlArray.push(imgTag);
					}
					htmlArray.push("</td>");
					htmlArray.push("</tr>");
				}
			}
			catch(err){}
			try
			{
				if( trim(showHeading.toLowerCase()) == "true" && trim != null && trim(divTitle) != "")
				{
					htmlArray.push("<tr>");
					htmlArray.push("<td valign='top' class=\"rssheading\" colspan=\""+tablecols+"\">");
					htmlArray.push("<a href=\""+channelLink+"\" "+(!internalLink?"target='_blank'":(parent?"target='_parent'":""))+">");
					htmlArray.push(divTitle);
					htmlArray.push("</a>");
					htmlArray.push("</td>");
					htmlArray.push("</tr>");
				}
			}
			catch(err){}
				
		}
		
		var items = channel.getElementsByTagName("item");
		if( items==null || items.length == 0 )
		{
			items = channel.getElementsByTagName("entry");
		}
		
		if(items != null)
		{
			var itemTitle = "";
			var itemLink = "";
			var itemDescription = "";
			var itemPubDate = "";
			var itemIcon ="";
			var itemIconAlt="";
			var itemProjectName="";
			var addDescription = (trim(showDesc.toLowerCase()) == "true");
			var addDate = (trim(showDate.toLowerCase()) == "true");
			htmlArray.push("<tr style=\""+trStyle+"\">");
			var colCounter = 1;
			var colWidth = 100/tablecols;
			if(items.length)
			{	
				for ( var i = 0; i < items.length; i++ ) 
				{
					if( i == maxItemCount )
					{
						break;
					}
					itemTitle 			= getElementTextNS("", "title", items[i], 0);
					itemLink 			= getElementTextNS("", "link", items[i], 0);
					itemDescription 	= getElementTextNS("", "description", items[i], 0);
					itemIcon 			= getElementTextNS("", "icon", items[i], 0);
					itemIconAlt 			= getElementTextNS("", "iconalt", items[i], 0);
					itemProjectName 			= getElementTextNS("", "projectname", items[i], 0);
					if(itemDescription==null)
					{
						itemDescription 	= getElementTextNS("", "content", items[i], 0);
					}
					itemPubDate 		= getElementTextNS("", "pubDate", items[i], 0);
					if(itemPubDate==null)
					{
						itemPubDate 		= getElementTextNS("", "modified", items[i], 0);
					}
					if(colCounter>tablecols)
					{
						htmlArray.push("</tr>");
						htmlArray.push("<tr style=\""+trStyle+"\">");
						colCounter = 1;
					}	
					htmlArray.push("<td valign='top' style=\""+tdStyle+"\" width='"+colWidth+"%'>");	
					
					htmlArray.push("<p class='rsslink'>");
					if(itemIcon != null && itemIcon !="")
					{
						if(itemIconAlt != null && itemIconAlt !="")
						{
							htmlArray.push("<img alt=\""+itemIconAlt+"\" title=\""+itemIconAlt+"\" src=\""+itemIcon+"\" align=\"absmiddle\" hspace=\"3\"/>");
						}
						else
						{
							htmlArray.push("<img alt=\""+itemIconAlt+"\" title=\""+itemIconAlt+"\" src=\""+itemIcon+"\" align=\"absmiddle\" hspace=\"3\"/>");
						}
					}
					htmlArray.push("<a href=\""+itemLink+"\" "+(!internalLink?"target='_blank'":(parent?"target='_parent'":"")) + ">");
					htmlArray.push(itemTitle);
					htmlArray.push("</a>");
					if(itemProjectName != "" && itemProjectName != "null" && typeof itemProjectName != "undefined")
					{
						htmlArray.push("&nbsp;<label style=\"text-align: left;\" class=\"homemodified_info\">["+itemProjectName+"]</label>");
					}
					htmlArray.push("</p>");
					htmlArray.push("<p class='rssdesc'>");
					if(addDescription && !et_g_isWhitespace(itemDescription))
					{
						htmlArray.push(itemDescription);
					}
					if(!et_g_isWhitespace(itemPubDate))
					{
						if( addDate )
						{
							if(!et_g_isWhitespace(itemDescription) && addDescription)
							{
								//htmlArray.push("<br clear=\"all\">");
							}
							htmlArray.push("<div class='rssdateinfo'>"+itemPubDate+"</div>");
						}
					}
					htmlArray.push("</p>");
					htmlArray.push("</td>");
					colCounter++;
				}
			}
			else
			{
				
				htmlArray.push("<tr style=\""+trStyle+"\">");
				htmlArray.push("<td valign='top'>");
				htmlArray.push(" No item found.");
				htmlArray.push("</td>");
				htmlArray.push("</tr>");
			}
			
			
			if(colCounter<tablecols)
			{
				for(var cCounter=0;cCounter<(tablecols-(colCounter-1));cCounter++)
				{
					htmlArray.push("<td>&nbsp;</td>");	
				}
			}
			htmlArray.push("</tr>");
		}
		
		htmlArray.push("</table>");
		document.getElementById(id).innerHTML = htmlArray.join("");
	}
	
	function changePointer(cursorType)
	{
		/*try
		{
			var length = document.all.length ;
			for (var j=0; j<length; j++)
			{
				try
				{
					document.all[j].style.cursor=cursorType;
					if(document.all[j].contentWindow)
					{
						document.all[j].contentWindow.document.body.style.cursor=cursorType;
					}
				}
				catch(err){}
			}
		}
		catch(err){}*/
		try
		{
			document.body.style.cursor=cursorType;
		}
		catch(err){}
	}	
	
	function getElementTextNS(prefix, local, parentElem, index) 
	{
	    var result = "";
	    /**
	     * for IE and with namespace....
	     result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
	    **/
	    try
		{
	        result = parentElem.getElementsByTagName(local)[index];
		    if (result) 
		    {
		        if (result.childNodes.length > 1) 
		        {
		            return result.childNodes[1].nodeValue;
		        } 
		        else 
		        {
		            return result.firstChild.nodeValue;    		
		        }
		    }
		}
	    catch(err){}
	}
		function trim(str)
	{
	    return str.replace(/^\s+/,'').replace(/\s+$/,'');
	}
	
	var generalMsgLocalizer = {
		getMessage: function(key, args) {
			var _result;
			try {
				_result = generalMsgs[key];
			} catch(err) {
			}
			if (typeof _result !="string") {
				_result = key;
			}
			if (typeof args != "undefined" && 
						(args.constructor.toString().indexOf("Array") != -1)) {
				for (var i=0; i< args.length; i++) {
					var regEx = new RegExp("\\{"+i+"\\}");
					_result = _result.replace(regEx,args[i])
				}
			}
			return _result;
		}
	};
	
	
	/*
	 * returns truncated text with ...
	 * eg: 'abcdefgh' for cnt = 7 gives out abcd... (text)
	 * html gives an a tag with title
	 */
	function getTruncatedString(data, cCnt, textOnly) 
	{
		var ret= "&nbsp;";
		if (textOnly) {
			ret = "";
		}
		if (data != null )
		{
			var dat = trim(data);
			if (dat.length > cCnt) {
				if (textOnly) {
					ret = (dat.substring(0, cCnt-3)+"...");
				} else {
					ret = "<a title=\"" + data + "\" alt=\"" + data + 
						"\" style=\"text-decoration:none\">" + dat.substring(0, cCnt-3) + 
						"..." +	"</a>";
				}
			}	else {
				ret = dat;
			}
		}
	  return ret;		
	}
	
	/*
	 * filepath: <context>/wikiwebdav/<session_id>/projid/pageid/libid
	 * type: 0- word, 1-excel, 2- powerpoint
	 */
	function openOfficeDocument(filepath, type) {
	  var officeApp, errMsg;
	  var showErr = false;
	  try {
	  	if (type == 0 ) { //word
				errMsg = generalMsgLocalizer.getMessage("msg_loadmsword_error");
				officeApp = new ActiveXObject("Word.Application");
				if (officeApp != null) {
					officeApp.Visible = true;
      		officeApp.Documents.Open(filepath);
				} else {
					showErr = true;
				}
	  	} else if (type == 1) { //excel
	  		 errMsg = generalMsgLocalizer.getMessage("msg_loadmsexcel_error");
	  		 officeApp = new ActiveXObject("Excel.Application");
	  		 if (officeApp != null) {
	  		 	officeApp.Visible = true;
	  		 	officeApp.Workbooks.Open(filepath);
	  		 } else {
	  		 	showErr = true;
	  		 }
	  	} else if (type == 2) { //powerpoint
	  		errMsg = generalMsgLocalizer.getMessage("msg_loadmsppt_error");
	  		officeApp = new ActiveXObject("PowerPoint.Application");
	  		if (officeApp != null) {
	  			officeApp.Visible = true;
	  			officeApp.Presentations.Open(filepath);
	  		} else {
	  			showErr = true;
	  		}
	  	}
	  } catch (e) {
			showErr = true;
	  }
	  if (showErr) {
	  	if (confirm(errMsg)) {
	  		showBrowserSecuritySettingsHelp();
	  	}
	  	return 0;
	  } else {
	  	return 1;
	  }
 }
 
 function showBrowserSecuritySettingsHelp()
 {
 		var bssHelpUrl = siteContext+"help/home/Editing Microsoft Word Excel or Powerpoint Attachments.html";
 		openPopup( (getAppPath() + '/wiki/help.jsp?sploc=' + URLEncode(bssHelpUrl)) , 800, 500, 
 											"eTouch_SamePageHelp") ;
 }

 var statusCheckers = new Array();
 
 function openOfficeDocumentWithStatusCheck(pageId, attachmentId, lockedStatus, filePath, type)
 {
	 if ( openOfficeDocument(filePath, type) == 1) {
		 
		 var lsChecker = findStatusChecker(attachmentId);
		 if (lsChecker == null) {
			 lsChecker = new lockStatusChecker(pageId, attachmentId, lockedStatus);
			 statusCheckers[statusCheckers.length]=lsChecker;
		 }
		 window.setTimeout("runLockStatusCheck("+attachmentId+")",3000);
	 }
 }
 
 function findStatusChecker(attachmentId)
 {
	 var retSChecker = null;
	 for (var i=0; i<statusCheckers.length; i++ ) {
		 if (statusCheckers[i].attachmentId == attachmentId) {
			 retSChecker = statusCheckers[i];
			 break;
		 }
	 }
	 return retSChecker;
 }
 
 function runLockStatusCheck(attachmentId)
 {
	 var lsChecker = findStatusChecker(attachmentId);
	 if (lsChecker != null) {
		 lsChecker.execute();
	 }
 }
 
 function lockStatusChecker(pageId, attachmentId, lockedStatus)
 {
	this.pageId = pageId;
	this.attachmentId = attachmentId;
	this.lockedStatus = lockedStatus;
	this.lsCheckprocess = function(responseDOM, errorMessage, responseText) {
		var obj = parseResponse(responseDOM);
		if(obj == null) {
			alert(generalMsgLocalizer.getMessage("response_not_well"));
		} else {
			if(obj.statusCode == "200") { 
				try{
					var retStatus = (trim(obj.output) == "true");
					if(retStatus != lockedStatus) {
						window.location.href=window.location.href;
					} 
				} catch(err) {
					alert(err);
				}
			}
		}// end else
		window.setTimeout("runLockStatusCheck("+attachmentId+")",5000);
	}// end process
	
	this.execute = function() {
		var attachStatusChecker  = new WikiAjax();
		attachStatusChecker.setMethodTOPOST();
		attachStatusChecker.setCallback(this.lsCheckprocess);
		var methodName = "isAttachmentLockedForEditing";
		var params = new Array();
		params[0] = new Object();
		params[0].type = "long"; 
		params[0].value = pageId;
		params[1] = new Object();
		params[1].type = "long";
		params[1].value = attachmentId;		
		var req = createRequest(createManagerMethod(methodName, params));
		attachStatusChecker.addField("reqdata", req);
		attachStatusChecker.send();
	}
	
 }// end lockStatusChecker
  
 function openOfficeDoc(pageId, attachmentId, attState, filePath, type)
 {
	var officeAjax  = new WikiAjax();
	officeAjax.setMethodTOPOST();
	var officeProcessor = new officeDocProcessor(pageId, attachmentId, attState, filePath,type);
	officeAjax.setCallback(officeProcessor.process);
	var methodName = "canOpenAttachmentForEditing";
	var params = new Array();
	params[0] = new Object();
	params[0].type = "long"; 
	params[0].value = attachmentId;
	params[1] = new Object();
	params[1].type = "long";
	params[1].value = pageId;
	
	//ajax call to check the status of attachment, true if locked and false if unlocked
	var req = createRequest(createManagerMethod(methodName, params));
	officeAjax.addField("reqdata", req);
	officeAjax.send();	 
 }
 
 /*
  * lockedStatus 0-not-locked, 1-locked
  */
 function officeDocProcessor(pageId, attachmentId, lockedStatus, filePath,type)
 {
	 this.pageId= pageId;
	 this.attachmentId = attachmentId;
	 this.lockedStatus = lockedStatus;
	 this.filePath = filePath;
	 this.type = type;
	 this.process = function (responseDOM, errorMessage, responseText) {
		var obj = parseResponse(responseDOM);
		if(obj == null) {
			alert(generalMsgLocalizer.getMessage("response_not_well"));
		} else {
			if(obj.statusCode == "200") { 
					var canOpenAttachment=obj.output;
					//attachment is not locked or attachment is locked by logged in user,then open file for editing
					if(canOpenAttachment=="true") {
						//calling js function to open MS Office file using WebDAV
						openOfficeDocumentWithStatusCheck(pageId, attachmentId, lockedStatus, filePath, type);
					} else {
						//if attachment is locked then other user cannot open file for editing
						alert(generalMsgLocalizer.getMessage("msg_attachment_locked_cannot_edit"));
						//reload the page to reflect the lock status;
						window.location.href=window.location.href;
					}
				}
		}// end else
	 }; //end process
 }
 
	//et_edd_anchorPosition(anchorname)
	//This function returns an object having .x and .y properties which are the coordinates
	//of the named anchor, relative to the page.
	function et_edd_anchorPosition(anchorname) 
	{
		// This function will return an Object with x and y properties
		var useWindow=false;
		var coordinates=new Object();
		var x=0,y=0;
		
		// Browser capability sniffing
		var use_gebi=false, use_css=false, use_layers=false;
		
		if (document.getElementById) 
		{ 
			use_gebi=true; 
		}
		else if (document.all) 
		{ 
			use_css=true; 
		}
		else if (document.layers) 
		{ 
			use_layers=true; 
		}
		
		// Logic to find position
	 	if (use_gebi && document.all) 
	 	{
			x=et_edd_anchorPosition_getPageOffsetLeft(document.all[anchorname]);
			y=et_edd_getPageOffsetTop(document.all[anchorname]);
		}
		else if (use_gebi) 
		{
			var o=document.getElementById(anchorname);
			x=et_edd_anchorPosition_getPageOffsetLeft(o);
			y=et_edd_getPageOffsetTop(o);
		}
	 	else if (use_css) 
	 	{
			x=et_edd_anchorPosition_getPageOffsetLeft(document.all[anchorname]);
			y=et_edd_getPageOffsetTop(document.all[anchorname]);
		}
		else if (use_layers) 
		{
			
			var found=0;
			
			for (var i=0; i<document.anchors.length; i++) 
			{
				if (document.anchors[i].name==anchorname) 
				{ 
					found=1; break; 
				}
			}
			if (found==0) 
			{
				coordinates.x=0; coordinates.y=0; return coordinates;
			}
			
			x=document.anchors[i].x;
			y=document.anchors[i].y;
		}
		else 
		{
			coordinates.x=0; coordinates.y=0; return coordinates;
		}
		
		coordinates.x=x;
		coordinates.y=y;
		
		return coordinates;
		
	}

	//et_edd_anchorWindowPosition(anchorname)
	//This function returns an object having .x and .y properties which are the coordinates
	//of the named anchor, relative to the window
	function et_edd_anchorWindowPosition(anchorname) 
	{
		
		var coordinates=et_edd_anchorPosition(anchorname);
		
		var x=0;
		var y=0;
		
		if (document.getElementById) 
		{
			if (isNaN(window.screenX)) 
			{
				x=coordinates.x-document.body.scrollLeft+window.screenLeft;
				y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
			else 
			{
				x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
				y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
		else if (document.all) 
		{
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
		else if (document.layers) 
		{
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
		coordinates.x=x;
		coordinates.y=y;
		return coordinates;
	}

	// Functions for IE to get position of an object
	function et_edd_anchorPosition_getPageOffsetLeft (el) 
	{
		
		var ol=el.offsetLeft;
		
		while ((el=el.offsetParent) != null) 
		{ 
			ol += el.offsetLeft - ( parseInt( el.scrollLeft ? el.scrollLeft : 0 ) ) ;
		}

		if (document.all || document.getElementById) 
		{
			ol=ol+document.body.scrollLeft;
		}
		else if (document.layers) 
		{
			ol=ol+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		}
		
		return ol;
	}
	
	function et_edd_getWindowOffsetLeft (el) 
	{
		return et_edd_anchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
	
	function et_edd_getPageOffsetTop (el) 
	{
		var ot=el.offsetTop;
		while((el=el.offsetParent) != null) 
		{ 
			ot += el.offsetTop - ( parseInt( el.scrollTop ? el.scrollTop : 0 ) ) ;
		}
		
		if (document.all || document.getElementById) 
		{
			ot=ot+document.body.scrollTop;
		}
		else if (document.layers) 
		{
			ot=ot+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
		return ot;
	}
	
	function et_edd_getWindowOffsetTop (el) 
	{
		return et_edd_getPageOffsetTop(el)-document.body.scrollTop;
	}

	function et_g_stopevents(e)
	{
		if(window.event)
			e = window.event;
		if(e)
		{
			e.cancelBubble = true;
			e.returnValue = false;
			if (e.stopPropagation)
			{
				e.stopPropagation();
				e.preventDefault();
				return false
			}
		}
	}


	function et_g_getAvailableWidth()
	{
		var x = 0;
		if (self.innerWidth) 
		{    // safari, netscape etc.... but not IE
			x = self.innerWidth;
		}
		else if (document.documentElement && document.documentElement.clientWidth) 
		{
			x = document.documentElement.clientWidth;
		}
		else if (document.body) 
		{
			x = document.body.clientWidth;
		}
		x = (x - et_fixedW);
		if((et_minW > 0) && (x < et_minW))
			x = et_minW;
		return x;
	}

	/*
	* returns available height for Body in the browser
	*/
	function et_g_getAvailableHeight()
	{
		var x = 0;
		if (self.innerHeight) 
		{    // safari, netscape etc.... but not IE
			x = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) 
		{
			x = document.documentElement.clientHeight;
		}
		else if (document.body) 
		{
			x = document.body.clientHeight;
		}
		x = (x - et_fixedH);
		if( (et_minH > 0) && (x < et_minH) )
			x = et_minH;
		return x;
	}

	function getIndexFromArray(arrayElems, searchStr) 
	{
	  var returnVal = -1;
	  for (i=0; i<arrayElems.length; i++) {
		 var elem = arrayElems[i];
		if (elem === searchStr) {
	        returnVal = i;
	        break;
	      }
	    }
	  return returnVal;
	}
	
	function isJsFileLoaded(jsFileName)
	{
		var returnVal = false;
		var scriptNodes = document.getElementsByTagName("script");
		for ( var i=0; i<scriptNodes.length; i++) {
			var scriptNode = scriptNodes[i];
			var srcAttr = scriptNode.getAttribute("src");
			if (srcAttr && srcAttr.indexOf(jsFileName) != -1) {
				returnVal = true;
				break;
			}
		}
		return returnVal;
	}
	
	function disableEnterKey(e)
	{
	     var key;
	     if(window.event)
	          key = window.event.keyCode;     //IE
	     else
	          key = e.which;     //firefox
	     if(key == 13)
	          return false;
	     else
	          return true;
	}
	
	function isValidProfileString(val)
	{
		var ret = true;
		for (var x=0; (val && x<val.length); x++) {
			if (notAllowedProfileChars.indexOf(val.charAt(x)) != -1) {
				ret = false;
				break;
			}
		}
		return ret;
	}
	var checkForDOM=document.getElementById?1:0,isIE=document.all?1:0,isNS4=navigator.appName=='Netscape'&&!checkForDOM?1:0,isOp=self.opera?1:0,isDyn=checkForDOM||isIE||isNS4;
	function getReferenceForSearchMenu (j,q){q=!q?document:q.navigator?q.document:q;return isIE?q.all[j]:checkForDOM?(q.getElementById?q:q.ownerDocument).getElementById(j):isNS4?q.layers[j]:null};
	function getStyleForSearchMenu(j,q){var r=getReferenceForSearchMenu (j,q);return r?isNS4?r:r.style:null};if(!self.LyrObject)var LyrObject=new Function('j','q','this.ref=getReferenceForSearchMenu (j,q);this.sty=getStyleForSearchMenu(j,q);return this');
	function getLayerForSearchMenu(j,q){return new LyrObject(j,q)};
	function LayerFunctionForSearchMenu(n,f){LyrObject.prototype[n]=new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){'+f+'}')};LayerFunctionForSearchMenu('x','if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)');LayerFunctionForSearchMenu('y','if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)');if(typeof addEvent!='function'){var addEvent=function(o,t,f,l){var d='addEventListener',n='on'+t,rO=o,rT=t,rF=f,rL=l;if(o[d]&&!l)return o[d](t,f,false);if(!o._evts)o._evts={};if(!o._evts[t]){o._evts[t]=o[n]?{b:o[n]}:{};o[n]=new Function('e','var r=true,o=this,a=o._evts["'+t+'"],i;for(i in a){o._f=a[i];r=o._f(e||window.event)!=false&&r;o._f=null}return r');if(t!='unload')addEvent(window,'unload',function(){removeEvent(rO,rT,rF,rL)})}if(!f._i)f._i=addEvent._i++;o._evts[t][f._i]=f};addEvent._i=1;var removeEvent=function(o,t,f,l){var d='removeEventListener';if(o[d]&&!l)return o[d](t,f,false);if(o._evts&&o._evts[t]&&f._i)delete o._evts[t][f._i]}}function SearchMenu(myName,nested,cssProp,cssVis,cssHid){this.myName=myName;this.nested=nested;this.cssProp=cssProp;this.cssVis=cssVis;this.cssHid=cssHid;this.cssLitClass='highlighted';this.menus={root:new SearchMenuNd('root',true,this)};this.menuToShow=[];this.mtsTimer=null;this.showDelay=0;this.switchDelay=125;this.hideDelay=500;this.showOnClick=0;this.hideOnClick=true;this.animInSpeed=0.2;this.animOutSpeed=0.2;this.animations=[]};SearchMenu.prototype.show=function(mN){with(this){menuToShow.length=arguments.length;for(var i=0;i<arguments.length;i++)menuToShow[i]=arguments[i];clearTimeout(mtsTimer);if(!nested)mtsTimer=setTimeout(myName+'.menus.root.over()',10)}};SearchMenu.prototype.hide=function(mN){with(this){clearTimeout(mtsTimer);if(menus[mN])menus[mN].out()}};SearchMenu.prototype.hideAll=function(){with(this){for(var s in menus)if(menus[s].visible&&!menus[s].isRoot)menus[s].hide(true)}};
	function SearchMenuNd(id,isRoot,obj){this.id=id;this.isRoot=isRoot;this.obj=obj;this.lyr=this.child=this.par=this.timer=this.visible=null;this.args=[];var node=this;this.over=function(evt){with(node)with(obj){if(isNS4&&evt&&lyr.ref)lyr.ref.routeEvent(evt);clearTimeout(timer);clearTimeout(mtsTimer);if(!isRoot&&!visible)node.show();if(menuToShow.length){var a=menuToShow,s=a[0];if(!menus[s]||!menus[s].lyr.ref)menus[s]=new SearchMenuNd(s,false,obj);var c=menus[s];if(c==node){menuToShow.length=0;return}clearTimeout(c.timer);if(c!=child&&c.lyr.ref){c.args.length=a.length;for(var i=0;i<a.length;i++)c.args[i]=a[i];var delay=child?switchDelay:showDelay;c.timer=setTimeout('with('+myName+'){menus["'+c.id+'"].par=menus["'+node.id+'"];menus["'+c.id+'"].show()}',delay?delay:1)}menuToShow.length=0}if(!nested&&par)par.over()}};this.out=function(evt){with(node)with(obj){if(isNS4&&evt&&lyr&&lyr.ref)lyr.ref.routeEvent(evt);clearTimeout(timer);if(!isRoot&&hideDelay>=0){timer=setTimeout(myName+'.menus["'+id+'"].hide()',hideDelay);if(!nested&&par)par.out()}}};if(this.id!='root')with(this)with(lyr=getLayerForSearchMenu(id))if(ref){if(isNS4)ref.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT);addEvent(ref,'mouseover',this.over);addEvent(ref,'mouseout',this.out);if(obj.nested){addEvent(ref,'focus',this.over);addEvent(ref,'click',this.over);addEvent(ref,'blur',this.out)}}};SearchMenuNd.prototype.show=function(forced){with(this)with(obj){if(!lyr||!lyr.ref)return;if(par){if(par.child&&par.child!=this)par.child.hide();par.child=this}var offR=args[1],offX=args[2],offY=args[3],lX=0,lY=0,doX=''+offX!='undefined',doY=''+offY!='undefined';if(self.page&&offR&&(doX||doY)){with(page.elmPos(offR,par.lyr?par.lyr.ref:0))lX=x,lY=y;if(doX)lyr.x(lX+eval(offX));if(doY)lyr.y(lY+eval(offY))}if(offR)lightParent(offR,1);visible=1;if(obj.onshow)obj.onshow(id);lyr.ref.parentNode.style.zIndex='2';setVis(1,forced)}};SearchMenuNd.prototype.hide=function(forced){with(this)with(obj){if(!lyr||!lyr.ref||!visible)return;if(isNS4&&self.isMouseInSMenu&&isMouseInSMenu(lyr.ref))return show();if(args[1])lightParent(args[1],0);if(child)child.hide();if(par&&par.child==this)par.child=null;if(lyr){visible=0;if(obj.onhide)obj.onhide(id);lyr.ref.parentNode.style.zIndex='1';setVis(0,forced)}}};SearchMenuNd.prototype.lightParent=function(elm,lit){with(this)with(obj){if(!cssLitClass||isNS4)return;if(lit)elm.className+=(elm.className?' ':'')+cssLitClass;else elm.className=elm.className.replace(new RegExp('(\\s*'+cssLitClass+')+$'),'')}};SearchMenuNd.prototype.setVis=function(sh,forced){with(this)with(obj){if(lyr.forced&&!forced)return;lyr.forced=forced;lyr.timer=lyr.timer||0;lyr.counter=lyr.counter||0;with(lyr){clearTimeout(timer);if(sh&&!counter)sty[cssProp]=cssVis;var speed=sh?animInSpeed:animOutSpeed;if(checkForDOM&&speed<1)for(var a=0;a<animations.length;a++)animations[a](ref,counter,sh);counter+=speed*(sh?1:-1);if(counter>1){counter=1;lyr.forced=false}else if(counter<0){counter=0;sty[cssProp]=cssHid;lyr.forced=false}else if(checkForDOM){timer=setTimeout(myName+'.menus["'+id+'"].setVis('+sh+','+forced+')',50)}}}};SearchMenu.animSwipeDown=function(ref,counter,show){if(show&&(counter==0)){ref._fsm_styT=ref.style.top;ref._fsm_styMT=ref.style.marginTop;ref._fsm_offT=ref.offsetTop||0}var cP=Math.pow(Math.sin(Math.PI*counter/2),0.75);var clipY=ref.offsetHeight*(1-cP);ref.style.clip=(counter==1?((window.opera||navigator.userAgent.indexOf('KHTML')>-1)?'':'rect(auto,auto,auto,auto)'):'rect('+clipY+'px,'+ref.offsetWidth+'px,'+ref.offsetHeight+'px,0)');if(counter==1||(counter<0.01&&!show)){ref.style.top=ref._fsm_styT;ref.style.marginTop=ref._fsm_styMT}else{ref.style.top=((0-clipY)+(ref._fsm_offT))+'px';ref.style.marginTop='0'}};SearchMenu.animFade=function(ref,counter,show){var done=(counter==1);if(ref.filters){var alpha=!done?' alpha(opacity='+parseInt(counter*100)+')':'';if(ref.style.filter.indexOf("alpha")==-1)ref.style.filter+=alpha;else ref.style.filter=ref.style.filter.replace(/\s*alpha\([^\)]*\)/i,alpha)}else ref.style.opacity=ref.style.MozOpacity=counter/1.001};SearchMenu.animClipDown=function(ref,counter,show){var cP=Math.pow(Math.sin(Math.PI*counter/2),0.75);ref.style.clip=(counter==1?((window.opera||navigator.userAgent.indexOf('KHTML')>-1)?'':'rect(auto,auto,auto,auto)'):'rect(0,'+ref.offsetWidth+'px,'+(ref.offsetHeight*cP)+'px,0)')};SearchMenu.prototype.activateMenu=function(id,subInd){with(this){if(!checkForDOM||!document.documentElement)return;var fsmFB=getReferenceForSearchMenu ('SearchMenu-fallback');if(fsmFB){fsmFB.rel='alternate stylesheet';fsmFB.disabled=true}var a,ul,li,parUL,mRoot=getReferenceForSearchMenu (id),nodes,count=1;var lists=mRoot.getElementsByTagName('ul');for(var i=0;i<lists.length;i++){li=ul=lists[i];while(li){if(li.nodeName.toLowerCase()=='li')break;li=li.parentNode}if(!li)continue;parUL=li;while(parUL){if(parUL.nodeName.toLowerCase()=='ul')break;parUL=parUL.parentNode}a=null;for(var j=0;j<li.childNodes.length;j++)if(li.childNodes[j].nodeName.toLowerCase()=='a')a=li.childNodes[j];if(!a)continue;var menuID=myName+'-id-'+count++;if(ul.id)menuID=ul.id;else ul.setAttribute('id',menuID);var sOC=(showOnClick==1&&li.parentNode==mRoot)||(showOnClick==2);var evtProp=navigator.userAgent.indexOf('Safari')>-1||isOp?'safRtnVal':'returnValue';var eShow=new Function('with('+myName+'){var s=menus["'+menuID+'"],pM=menus["'+parUL.id+'"];'+(sOC?'if((pM&&pM.child)||(s&&s.visible))':'')+' show("'+menuID+'",this)}');var eHide=new Function('e','if(e.'+evtProp+'!=false)'+myName+'.hide("'+menuID+'")');addEvent(a,'mouseover',eShow);addEvent(a,'focus',eShow);addEvent(a,'mouseout',eHide);addEvent(a,'blur',eHide);if(sOC)addEvent(a,'click',new Function('e',myName+'.show("'+menuID+'",this);if(e.cancelable&&e.preventDefault)e.preventDefault();e.'+evtProp+'=false;return false'));if(subInd)a.insertBefore(subInd.cloneNode(true),a.firstChild)}if(isIE&&!isOp){var aNodes=mRoot.getElementsByTagName('a');for(var i=0;i<aNodes.length;i++){addEvent(aNodes[i],'focus',new Function('e','var node=this.parentNode;while(node){if(node.onfocus)node.onfocus(e);node=node.parentNode}'));addEvent(aNodes[i],'blur',new Function('e','var node=this.parentNode;while(node){if(node.onblur)node.onblur(e);node=node.parentNode}'))}}if(hideOnClick)addEvent(mRoot,'click',new Function(myName+'.hideAll()'));menus[id]=new SearchMenuNd(id,true,this)}};var page={win:self,minW:0,minH:0,MS:isIE&&!isOp,db:document.compatMode&&document.compatMode.indexOf('CSS')>-1?'documentElement':'body'};page.elmPos=function(e,p){var x=0,y=0,w=p?p:this.win;e=e?(e.substr?(isNS4?w.document.anchors[e]:getReferenceForSearchMenu (e,w)):e):p;if(isNS4){if(e&&(e!=p)){x=e.x;y=e.y};if(p){x+=p.pageX;y+=p.pageY}}if(e&&this.MS&&navigator.platform.indexOf('Mac')>-1&&e.tagName=='A'){e.onfocus=new Function('with(event){self.tmpX=clientX-offsetX;self.tmpY=clientY-offsetY}');e.focus();x=tmpX;y=tmpY;e.blur()}else while(e){x+=e.offsetLeft;y+=e.offsetTop;e=e.offsetParent}return{x:x,y:y}};if(isNS4){var fsmMouseX,fsmMouseY,fsmOR=self.onresize,nsWinW=innerWidth,nsWinH=innerHeight;document.fsmMM=document.onmousemove;self.onresize=function(){if(fsmOR)fsmOR();if(nsWinW!=innerWidth||nsWinH!=innerHeight)location.reload()};document.captureEvents(Event.MOUSEMOVE);document.onmousemove=function(e){fsmMouseX=e.pageX;fsmMouseY=e.pageY;return document.fsmMM?document.fsmMM(e):document.routeEvent(e)};
	function isMouseInSMenu(sty){with(sty)return((fsmMouseX>left)&&(fsmMouseX<left+clip.width)&&(fsmMouseY>top)&&(fsmMouseY<top+clip.height))}}

	var divMenu = new SearchMenu('divMenu', false, 'visibility', 'visible', 'hidden');
	divMenu.cssLitClass = 'highlighted';
	divMenu.animInSpeed = 1;
	divMenu.animOutSpeed = 1;

	SearchMenu.prototype.ieSelBoxFixShow = function(mN) { with (this)
	{
	 var s = menus[mN];
	 if (!isIE || !window.createPopup) return;
	 if (navigator.userAgent.match(/MSIE ([\d\.]+)/) && parseFloat(RegExp.$1) > 6.5)
	  return;
	 if (!s.ifr)
	 {
	  s.ifr = document.createElement('iframe');
	  s.ifr.src = 'about:blank';
	  with (s.ifr.style)
	  {
	   position = 'absolute';
	   border = 'none';
	   filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
	  }
	  s.lyr.ref.parentNode.insertBefore(s.ifr, s.lyr.ref);
	 }
	 with (s.ifr.style)
	 {
	  left = s.lyr.ref.offsetLeft + 'px';
	  top = s.lyr.ref.offsetTop + 'px';
	  width = s.lyr.ref.offsetWidth + 'px';
	  height = s.lyr.ref.offsetHeight + 'px';
	  visibility = 'visible';
	 }
	}};
	SearchMenu.prototype.ieSelBoxFixHide = function(mN) { with (this)
	{
	 if (!isIE || !window.createPopup) return;
	 var s = menus[mN];
	 if (s.ifr) s.ifr.style.visibility = 'hidden';
	}};

	addEvent(divMenu, 'show', function(mN) { this.ieSelBoxFixShow(mN) }, 1);
	addEvent(divMenu, 'hide', function(mN) { this.ieSelBoxFixHide(mN) }, 1);	
	
	
	