/**Licensed Materials - Property of IBM.Symphony Website(c) Copyright IBM Corporation 2008 [2010].  All Rights Reserved.U.S. Government Users Restricted Rights:  Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.**//* ---------------------------------------------Global Symphony Website Javascript          All methods and variables inside the JS file should begin with SC_to avoid name collisions with other script code.--------------------------------------------- */function SC_SetCookie(cookiename, cookievalue){document.cookie = cookiename + "=" + escape(cookievalue)}function SC_resizeMain() {        var f = document.getElementById("mainFrame");        if (f) {                if (f.contentDocument) {                        //ff                        f.height = f.contentDocument.body.scrollHeight + 60;                }else if (f.document && f.document.body.scrollHeight) {                        //ie                        f.height        = mainFrame.document.body.scrollHeight + 60;                }        }}/* ---------------------------------------------------------- *//*  called by any Ajax code that updates the page    *//* This hook enables us to do anything necessary *//* to the page after Ajax code updates markup on the page. *//* ---------------------------------------------------------- */function SC_ajaxPageUpdateComplete() {	SC_setFooter();}/* ---------------------------------------------------------- *//*  For footer setting	          			                  *//* ---------------------------------------------------------- */function SC_setFooter(){	var windowHeight = 0;	if (typeof(window.innerHeight) == 'number') {		windowHeight = window.innerHeight;	} else {		if (document.documentElement && document.documentElement.clientHeight) {			windowHeight = document.documentElement.clientHeight;		} else {			if (document.body && document.body.clientHeight) {				windowHeight = document.body.clientHeight;			}		}	}	var footerContainer = document.getElementById("footerContainer")		if(document.body.clientHeight<windowHeight){		var bottomOffset = document.body.clientHeight-windowHeight				/* subtract this way so we intentionally get a negative value */		footerContainer.style.bottom=bottomOffset+"px"		footerContainer.style.position="static"	} else {				footerContainer.style.bottom="auto"		footerContainer.style.position="static"	}}function SC_fixPNGInIE(){	var userAgent = navigator.userAgent.toLowerCase();	var ie = (userAgent.indexOf('msie 6.0')!= -1 );	var filterID = "DXImageTransform.Microsoft.AlphaImageLoader";		if(ie){		for(var i=0;i<document.images.length;i++){			var image = document.images[i];			var namelc = image.src.toLowerCase();			if (namelc.indexOf(".png")!=-1){				var width = image.width;				var height = image.height;				image.runtimeStyle.filter = "progid:"+filterID+"(src='"+image.src+"', sizingMethod='scale')";				image.src="/software/lotus/symphony/theme/images/transparent.gif";				image.width=width;				image.height=height;							}		}	}}				/* ---------------------------------------------------------- *//*  Open demo 			          			                  *//* ---------------------------------------------------------- */function SC_opendemo(i) {                      var open_url = "";	   if(i==1)open_url="swf/we/DocumentFilePref/DocumentFilePref_viewlet_swf.html";	   else if(i==2)open_url="swf/we/DocumentsFrame/DocumentsFrame_viewlet_swf.html";	   else if(i==3)open_url="swf/pe/prezOverview/prezOverview_viewlet_swf.html";	   else if(i==4)open_url="swf/pe/prezFilePref/prezFilePref_viewlet_swf.html";	   else if(i==10)open_url="swf/pe/changeLayout/changeLayout_viewlet_swf.html";	   else if(i==5)open_url="swf/se/spreadshFilePref/spreadshFilePref_viewlet_swf.html";	   else if(i==0)open_url="swf/se/speadsheetNavigator/speadsheetNavigator_viewlet_swf.html";	   else if(i==9)open_url="swf/we/tableofcontents/tableofcontents_viewlet_swf.html";	   else if(i==6)open_url="tutorial/we/start_documents.htm";	   else if(i==7)open_url="tutorial/pe/start_presentations.htm";	   else if(i==8)open_url="tutorial/se/start_spreadsheets.htm";	   	   window.open(open_url,'','status=0,directories=0,resizable=0,toolbar=0,location=0,scrollbars=0');	  }function SC_opendemo_new(URL){       open_url=URL;       window.open(open_url,'','status=no,directories=no,resizable=yes,toolbar=no,location=no,scrollbars=no');}function SC_open_new(URL,width,height){       open_url=URL;       window.open(open_url,'','width='+width+',height='+height+',status=no,directories=no,resizable=yes,toolbar=no,location=no,scrollbars=no');}function SC_closewindow(){       window.close();}/* WARNING: we cannot proxy cancelPost variable until we find all use of it and change the calling code.var SC_cancelPost= false;*/var cancelPost= false;function SC_checkTags(){	/* WARNING: the cancelPost variable in the following line needs to be prefixed */    if (cancelPost) {        return true;    }    var hasError = false;    var tags = document.getElementById('tags-0');    if (typeof(tags) != "undefined" && trimString(tags.value) == '') {        var t = document.getElementById('post-error-table');        if (t) {            t.style.display = "block";            t = document.getElementById('post-error-tags');            if (t) {                t.style.display = "block";            }        }        hasError = true;    }    else {        var t = document.getElementById('post-error-tags');        if (t) {            t.style.display = "none";        }    }    //plugin title empty validation    var sub = document.getElementById('subject01');    if (typeof(sub) != "undefined" && trimString(sub.value) == '') {        var t = document.getElementById('post-error-table');        if (t) {            t.style.display = "block";            t = document.getElementById('post-error-subject');            if (t) {                t.style.display = "block";            }        }        hasError = true;    }    else {        var t = document.getElementById('post-error-subject');        if (t) {            t.style.display = "none";        }    }    //description large validation    var body = document.getElementById('textEditor');    if (typeof(body) != "undefined" && body.value.length == '') {        var t = document.getElementById('post-error-table');        if (t) {            t.style.display = "block";            t = document.getElementById('post-error-body');            if (t) {                t.style.display = "block";            }        }        hasError = true;    }    else {        var t = document.getElementById('post-error-body');        if (t) {            t.style.display = "none";        }    }    if (hasError) {      return false;    }    var t = document.getElementById('post-error-table');    if (t) {      t.style.display = "none";    }    return true;        }function SC_checkValid(){ var a = document.postform.body;  if(a.value.length > 10000) {  alert("The maximal length of message is 10000!");  return false; } return true;}function SC_getNameFromRecipient(recipient){	var name = "";	if (recipient!=null && recipient!="undefined"){		var index1 = -1;		index1 = recipient.indexOf(",");		if( index1 == -1)			index1 = recipient.indexOf("\n");		if( index1 == -1)			index1 = recipient.indexOf("\r");		var index2 = recipient.indexOf("<");		if( index2!= -1)		{			if(index1 == -1 || ( (index2 < index1) && (index1!=-1) ))			{				var name =SC_trim(recipient.substring(0,index2-1));			}		}	}		return name;}/* ---------------------------------------------------------- *//*  Utility  			        			                  *//* ---------------------------------------------------------- */function SC_getRadioValue(radiogroup){   if (radiogroup!=null && radiogroup!="undefined"){   		var numradios = radiogroup.length;		for (var i = 0; i < numradios; i++)	      	if (radiogroup[i].checked)	      	  return radiogroup[i].value;   }}function SC_trim(stringToTrim) {    if (stringToTrim!=null && stringToTrim!="undefined" && (typeof stringToTrim)=="string" )		return stringToTrim.replace(/^\s+|\s+$/g,"");	return "";}function SC_escapeHTML(text){	if (text!=null && text!="undefined"){		text=text.replace(/</g,"&lt;");		text=text.replace(/>/g,"&gt;");		}		return text;}function SC_checkLength(strTarget,length,prompt){	if (strTarget!=null){		if(strTarget.length > length){		  alert("The maximal length of "+prompt+" is "+ length +"!");		  return false;		 }	}	return true;}function SC_checkEmpty(strTarget,isPrompt){	if (strTarget!=null){		if(SC_trim(strTarget).length == 0 ){			if (isPrompt){			  alert("You can't leave this field blank!");		  	}		  	return false;		 }		 return true;	}	return false;}function SC_addSpamToURL(oldURL){	var spam = "symphony-vs-spam";	var reg = /.+\?\w+=\S*/;	var newURL="";	if(oldURL!=null && oldURL!="undefined" ){		if(oldURL.match(reg)){			newURL=oldURL+"&chk="+spam;		} else {			newURL=oldURL+"?chk="+spam;		}	}		return newURL;}function SC_textCounter(field,maxlimit) { 	if (field!=null && field.value.length > maxlimit)  		field.value = field.value.substring(0, maxlimit); } function SC_symphonyStyleTag(tag, ta) {     var end = 0;    var scrollTop = ta.scrollTop;        if (document.selection) {        if (document.selection.createRange().parentElement().tagName == 'TEXTAREA') {            var selected = document.selection.createRange().text;                        // now determine the cursor position            end = getSelectionRangeEnd(ta);                        // r is an array            var r = _markupText(selected, tag);             // update text            document.selection.createRange().text = r[0];                        // update end position            end += r[1];        }         else        {	        ta.value= ta.value + tag + tag;	        return;        }    }     else if (typeof(ta.selectionStart) != 'undefined' && typeof(ta.selectionEnd) != 'undefined') {        if (ta.selectionStart == ta.selectionEnd) {        	ta.value= ta.value + tag + tag;            return;        }        var selLength = ta.textLength;        var selStart = ta.selectionStart;        var selEnd = ta.selectionEnd;        if (selEnd == 1 || selEnd == 2) {            selEnd = selLength;        }        var s1 = (ta.value).substring(0, selStart);        var s2 = (ta.value).substring(selStart, selEnd);        var s3 = (ta.value).substring(selEnd, selLength);                // r is an array        var r = _markupText(s2, tag);         // update text        ta.value = s1 + r[0] + s3;                    // update end position        end = selEnd + r[1];    }     else {        return;    }        if (end > 0) {         setCaretTo(ta, end, scrollTop);     }}function SC_doSearchBoxCheckForEnter(navigateOnly, escapedCategoryInfo, event, textFieldId) {	if (event.keyCode == 13) {		event.returnValue = false;		SC_doSearchBox(navigateOnly, escapedCategoryInfo, textFieldId);	}}function SC_doSearchBox(navigateOnly, escapedCategoryInfo, textFieldId) {	var q = "";	if (null != textFieldId) {		var textField = document.getElementById(textFieldId);		if (null != textField) {			q = trim(textField.value);				}	}		var url = SC_buildSearchUrl(navigateOnly, q, escapedCategoryInfo);		window.location = url;	}function SC_doAdvancedSearch() {	var f = document.searchform;	var q = SC_trim( f.q.value );	var categoryIndex = f.restrict_by_category.selectedIndex	var escapedCategoryInfo = f.restrict_by_category.options[categoryIndex].value	var dateRangeValue = f.dateRange.options[f.dateRange.selectedIndex].value;	var dateRangeText = f.dateRange.options[f.dateRange.selectedIndex].text;	var userID = SC_trim( f.userID.value );	var resultsPerPage = f.numResults.options[f.numResults.selectedIndex].value;	var url = SC_buildSearchUrl(false, q, escapedCategoryInfo, dateRangeValue, dateRangeText, userID, resultsPerPage );		window.location = url;	}function SC_buildSearchUrl(navigateOnly, q, escapedCategoryInfo, dateRangeValue, dateRangeText, userID, resultsPerPage) {	var dbPath = "";	var dominoObject = "";	var searchAction = "";	var queryAddition = "";	var categoryInfo = decodeURIComponent(escapedCategoryInfo);		/* Parse the category info. Category info is of the format: "dbPath|dominoObject|searchAction|queryAddition" where			dbPath is the path to the database. If empty, it is the current database.			dominoObject is the name of the search view to use or the domain search form.				For domain search, this is normally left empty to use the default form for the database		searchAction is either SearchView or SearchDomain			queryAddition is text added to the query string to narrow the search scope	 */	parts = categoryInfo.split("|", 4);	if (parts.length >= 1) {		dbPath = parts[0];	}	if (parts.length >= 2) {		dominoObject = parts[1];	}	if (parts.length >= 3) {		searchAction = parts[2];	}	if (parts.length >= 4) {		queryAddition = parts[3];	}				url = "";	if (dbPath.length > 0) {		if (dbPath.substring(1,1) == "/") {			url += dbPath + "/";		} else {			url += "/" + dbPath + "/";		}	}	if (dominoObject.length > 0) {		// Don't start with a / so if dbPath is empty, the final URL is relative to the current database.		url += dominoObject;	}	if (searchAction.length > 0) {		url += "?" + searchAction;	} else {		url += "?SearchView";	// A search action of some type is required.	}	if (navigateOnly) {		url += "&NavOnly=1";	}			if (null != resultsPerPage && resultsPerPage.length > 0) {		url += "&Count="+resultsPerPage;	} else {		url += "&Count=15";	}	// now preserve the form input fields so we can show them again when the search results come back	if (null != q && q.length > 0 && q!="Search Buzz") {		url += "&q=" + encodeURIComponent(q);	}		if (null != categoryInfo && categoryInfo.length > 0) {		// Do not escape categoryInfo because it is already escaped in the values of the dropdown list.		url += "&ci=" + categoryInfo;	}		if (null != dateRangeValue && dateRangeValue.length > 0) {		url += "&drv=" + encodeURIComponent(dateRangeValue);	}		if (null != userID && userID.length > 0) {		url += "&uid=" + encodeURIComponent(userID);	}	return url;}function SC_getAdvancedSearchDocNumber( docNum ) {	var f = document.forms.searchform;	var currentPage = f.SearchCurrentPage.value;		var start = f.SearchStart.value;	if (null == docNum) {		globalSearch_currentResult = globalSearch_currentResult + 1;		docNum = globalSearch_currentResult;	}		if ( currentPage == "1" ) {		return docNum;	} else {		return +start + docNum - 1;	} }function SC_advancedSearchOnLoad( ) {			var f = document.forms.searchform;	if (null != globalSearch_qParameter) {		f.q.value = globalSearch_qParameter;	}	if (null != globalSearch_uidParameter) {		f.userID.value = globalSearch_uidParameter;	}		if (null != globalSearch_ciParameter) {		SC_selectDropdownByValue("restrict_by_category", globalSearch_ciParameter);	}	if (null != globalSearch_drvParameter) {		SC_selectDropdownByValue("daterange01", globalSearch_drvParameter);	}		if (null != globalSearch_countParameter) {		SC_selectDropdownByValue("numResults01", globalSearch_countParameter);	}	 }function SC_selectDropdownByValue(id, value) {	var dropdown = document.getElementById(id);	if (null != dropdown) {		for (i = 0; i < dropdown.options.length; i++) {			if (dropdown.options[i].value == value) {				dropdown.selectedIndex = i;				break;			}		}	}}
