//for ajax ================================
	
function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}

function Bamboo_Encode(s){
	if (typeof encodeURIComponent == "function") {
		// Use JavaScript built-in function
		// IE 5.5+ and Netscape 6+ and Mozilla
		return encodeURIComponent(s);
	} else {
		// Need to mimic the JavaScript version
		// Netscape 4 and IE 4 and IE 5.0
		return encodeURIComponentNew(s);
	}
}

function Bamboo_AddEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	} else {
		alert("Bamboo_AddEvent could not add event!");
	}
}

function Bamboo_GetXMLHttpRequest() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		if (window.Bamboo_XMLHttpRequestProgID) {
			return new ActiveXObject(window.Bamboo_XMLHttpRequestProgID);
		} else {
			var progIDs = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
			for (var i = 0; i < progIDs.length; ++i) {
				var progID = progIDs[i];
				try {
					var x = new ActiveXObject(progID);
					window.Bamboo_XMLHttpRequestProgID = progID;
					return x;
				} catch (e) {
				}
			}
		}
	}
	return null;
}

function Bamboo_CallBack(url, target, id, method, args, clientCallBack, clientCallBackArg, includeControlValuesWithCallBack, updatePageAfterCallBack) {
	if (window.Bamboo_PreCallBack) {
		var preCallBackResult = Bamboo_PreCallBack();
		if (!(typeof preCallBackResult == "undefined" || preCallBackResult)) {
			if (window.Bamboo_CallBackCancelled) {
				Bamboo_CallBackCancelled();
			}
			return null;
		}
	}
	var x = Bamboo_GetXMLHttpRequest();
	var result = null;
	if (!x) {
		result = { "value": null, "error": "NOXMLHTTP" };
		Bamboo_DebugError(result.error);
		if (window.Bamboo_Error) {
			Bamboo_Error(result);
		}
		if (clientCallBack) {
			clientCallBack(result, clientCallBackArg);
		}
		return result;
	}
	x.open("POST", url ? url : Bamboo_DefaultURL, clientCallBack ? true : false);
	x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
	x.setRequestHeader("Accept-Encoding", "gzip, deflate");
	if (clientCallBack) {
		x.onreadystatechange = function() {
			if (x.readyState != 4) {
				return;
			}
			Bamboo_DebugResponseText(x.responseText);
			result = Bamboo_GetResult(x);
			if (result.error) {
				Bamboo_DebugError(result.error);
				if (window.Bamboo_Error) {
					Bamboo_Error(result);
				}
			}
			if (updatePageAfterCallBack) {
				Bamboo_UpdatePage(result);
			}
			Bamboo_EvalClientSideScript(result);
			clientCallBack(result, clientCallBackArg);
			x = null;
			if (window.Bamboo_PostCallBack) {
				Bamboo_PostCallBack();
			}
		}
	}
    var encodedData = "";
    if (target == "Page") {
        encodedData += "&Bamboo_PageMethod=" + method;
    } else if (target == "MasterPage") {
        encodedData += "&Bamboo_MasterPageMethod=" + method;
    } else if (target == "Control") {
        encodedData += "&Bamboo_ControlID=" + id.split(":").join("_");
        encodedData += "&Bamboo_ControlMethod=" + method;
    }
	if (args) {
		for (var argsIndex = 0; argsIndex < args.length; ++argsIndex) {
			if (args[argsIndex] instanceof Array) {
				for (var i = 0; i < args[argsIndex].length; ++i) {
					encodedData += "&Bamboo_CallBackArgument" + argsIndex + "=" + Bamboo_Encode(args[argsIndex][i]);
				}
			} else {
				encodedData += "&Bamboo_CallBackArgument" + argsIndex + "=" + Bamboo_Encode(args[argsIndex]);
			}
		}
	}
	if (updatePageAfterCallBack) {
		encodedData += "&Bamboo_UpdatePage=true";
	}
	if (includeControlValuesWithCallBack) {
		var form = document.getElementById(Bamboo_FormID);
		if (form != null) {
			for (var elementIndex = 0; elementIndex < form.length; ++elementIndex) {
				var element = form.elements[elementIndex];
				if (element.name) {
					var elementValue = null;
					if (element.nodeName.toUpperCase() == "INPUT") {
						var inputType = element.getAttribute("type").toUpperCase();
						if (inputType == "TEXT" || inputType == "PASSWORD" || inputType == "HIDDEN") {
							elementValue = element.value;
						} else if (inputType == "CHECKBOX" || inputType == "RADIO") {
							if (element.checked) {
								elementValue = element.value;
							}
						}
					} else if (element.nodeName.toUpperCase() == "SELECT") {
						if (element.multiple) {
							elementValue = [];
							for (var i = 0; i < element.length; ++i) {
								if (element.options[i].selected) {
									elementValue.push(element.options[i].value);
								}
							}
						} else if (element.length == 0) {
						    elementValue = null;
						} else {
							elementValue = element.value;
						}
					} else if (element.nodeName.toUpperCase() == "TEXTAREA") {
						elementValue = element.value;
					}
					if (elementValue instanceof Array) {
						for (var i = 0; i < elementValue.length; ++i) {
							encodedData += "&" + element.name + "=" + Bamboo_Encode(elementValue[i]);
						}
					} else if (elementValue != null) {
						encodedData += "&" + element.name + "=" + Bamboo_Encode(elementValue);
					}
				}
			}
			// ASP.NET 1.1 won't fire any events if neither of the following
			// two parameters are not in the request so make sure they're
			// always in the request.
			if (typeof form.__VIEWSTATE == "undefined") {
				encodedData += "&__VIEWSTATE=";
			}
			if (typeof form.__EVENTTARGET == "undefined") {
				encodedData += "&__EVENTTARGET=";
			}
		}
	}
	Bamboo_DebugRequestText(encodedData.split("&").join("\n&"));
	x.send(encodedData);
	if (!clientCallBack) {
		Bamboo_DebugResponseText(x.responseText);
		result = Bamboo_GetResult(x);
		if (result.error) {
			Bamboo_DebugError(result.error);
			if (window.Bamboo_Error) {
				Bamboo_Error(result);
			}
		}
		if (updatePageAfterCallBack) {
			Bamboo_UpdatePage(result);
		}
		Bamboo_EvalClientSideScript(result);
		if (window.Bamboo_PostCallBack) {
			Bamboo_PostCallBack();
		}
	}
	return result;
}

function Bamboo_GetResult(x) {
	var result = { "value": null, "error": null };
	var responseText = x.responseText;
	try {
		result = eval("(" + responseText + ")");
	} catch (e) {
		if (responseText.length == 0) {
			result.error = "NORESPONSE";
		} else {
			result.error = "BADRESPONSE";
			result.responseText = responseText;
		}
	}
	return result;
}

function Bamboo_SetHiddenInputValue(form, name, value) {
    var input = null;
    if (form[name]) {
        input = form[name];
    } else {
        input = document.createElement("input");
        input.setAttribute("name", name);
        input.setAttribute("type", "hidden");
    }
    input.setAttribute("value", value);
    var parentElement = input.parentElement ? input.parentElement : input.parentNode;
    if (parentElement == null) {
        form.appendChild(input);
        form[name] = input;
    }
}

function Bamboo_RemoveHiddenInput(form, name) {
    var input = form[name];
    var parentElement = input.parentElement ? input.parentElement : input.parentNode;
    if (input && parentElement == form) {
        form[name] = null;
        form.removeChild(input);
    }
}

function Bamboo_FireEvent(eventTarget, eventArgument, clientCallBack, clientCallBackArg, includeControlValuesWithCallBack, updatePageAfterCallBack) {
	var form = document.getElementById(Bamboo_FormID);
	Bamboo_SetHiddenInputValue(form, "__EVENTTARGET", eventTarget);
	Bamboo_SetHiddenInputValue(form, "__EVENTARGUMENT", eventArgument);
	Bamboo_CallBack(null, null, null, null, null, clientCallBack, clientCallBackArg, includeControlValuesWithCallBack, updatePageAfterCallBack);
	form.__EVENTTARGET.value = "";
	form.__EVENTARGUMENT.value = "";
}

function Bamboo_UpdatePage(result) {
	var form = document.getElementById(Bamboo_FormID);
	if (result.viewState) {
		Bamboo_SetHiddenInputValue(form, "__VIEWSTATE", result.viewState);
	}
	if (result.viewStateEncrypted) {
		Bamboo_SetHiddenInputValue(form, "__VIEWSTATEENCRYPTED", result.viewStateEncrypted);
	}
	if (result.eventValidation) {
		Bamboo_SetHiddenInputValue(form, "__EVENTVALIDATION", result.eventValidation);
	}
	if (result.controls) {
		for (var controlID in result.controls) {
			var containerID = "Bamboo_" + controlID.split("$").join("_") + "__";
			var control = document.getElementById(containerID);
			if (control) {
				control.innerHTML = result.controls[controlID];
				if (result.controls[controlID] == "") {
					control.style.display = "none";
				} else {
					control.style.display = "block";
				}
			}
		}
	}
	if (result.pagescript) {
	    Bamboo_LoadPageScript(result, 0);
	}
}

// Load each script in order and wait for each one to load before proceeding
function Bamboo_LoadPageScript(result, index) {
    if (index < result.pagescript.length) {
		try {
		    var script = document.createElement('script');
		    script.type = 'text/javascript';
		    if (result.pagescript[index].indexOf('src=') == 0) {
		        script.src = result.pagescript[index].substring(4);
		    } else {
		        if (script.canHaveChildren ) {
		            script.appendChild(document.createTextNode(result.pagescript[index]));
		        } else {
		            script.text = result.pagescript[index];
		        }
		    }
	        document.getElementsByTagName('head')[0].appendChild(script);
	        if (typeof script.readyState != "undefined") {
	            script.onreadystatechange = function() {
	                if (script.readyState != "complete" && script.readyState != "loaded") {
	                    return;
	                } else {
	                    Bamboo_LoadPageScript(result, index + 1);
	                }
	            }
	        } else {
                Bamboo_LoadPageScript(result, index + 1);
	        }
		} catch (e) {
		    Bamboo_DebugError("Error adding page script to head. " + e.name + ": " + e.message);
		}
	}
}

function Bamboo_EvalClientSideScript(result) {
	if (result.script) {
		for (var i = 0; i < result.script.length; ++i) {
			try {
				eval(result.script[i]);
			} catch (e) {
				alert("Error evaluating client-side script!\n\nScript: " + result.script[i] + "\n\nException: " + e);
			}
		}
	}
}

function Bamboo_DebugRequestText(text) {
}

function Bamboo_DebugResponseText(text) {
}

function Bamboo_DebugError(text) {
}

//Fix for bug #1429412, "Reponse callback returns previous response after file push".
//see http://sourceforge.net/tracker/index.php?func=detail&aid=1429412&group_id=151897&atid=782464
function Bamboo_Clear__EVENTTARGET() {
	var form = document.getElementById(Bamboo_FormID);
	Bamboo_SetHiddenInputValue(form, "__EVENTTARGET", "");
}

function Bamboo_InvokePageMethod(methodName, args, clientCallBack, clientCallBackArg) {
	Bamboo_Clear__EVENTTARGET(); // fix for bug #1429412
    return Bamboo_CallBack(null, "Page", null, methodName, args, clientCallBack, clientCallBackArg, true, true);
}

function Bamboo_InvokeMasterPageMethod(methodName, args, clientCallBack, clientCallBackArg) {
	Bamboo_Clear__EVENTTARGET(); // fix for bug #1429412
    return Bamboo_CallBack(null, "MasterPage", null, methodName, args, clientCallBack, clientCallBackArg, true, true);
}

function Bamboo_InvokeControlMethod(id, methodName, args, clientCallBack, clientCallBackArg) {
	Bamboo_Clear__EVENTTARGET(); // fix for bug #1429412
    return Bamboo_CallBack(null, "Control", id, methodName, args, clientCallBack, clientCallBackArg, true, true);
}

function Bamboo_PreProcessCallBack(
    control,
    e,
    eventTarget,
    causesValidation, 
    validationGroup, 
    imageUrlDuringCallBack, 
    textDuringCallBack, 
    enabledDuringCallBack,
    preCallBackFunction,
    callBackCancelledFunction,
    preProcessOut
) {
	preProcessOut.Enabled = !control.disabled;
	var preCallBackResult = true;
	if (preCallBackFunction) {
		preCallBackResult = preCallBackFunction(control);
	}
	if (typeof preCallBackResult == "undefined" || preCallBackResult) {
		var valid = true;
		if (causesValidation && typeof Page_ClientValidate == "function") {
			valid = Page_ClientValidate(validationGroup);
		}
		if (valid) {
			var inputType = control.getAttribute("type");
			inputType = (inputType == null) ? '' : inputType.toUpperCase();
			if (inputType == "IMAGE" && e != null) {
                var form = document.getElementById(Bamboo_FormID);
                if (e.offsetX) {
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".x", e.offsetX);
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".y", e.offsetY);
                } else {
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".x", e.clientX - control.offsetLeft + 1);
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".y", e.clientY - control.offsetTop + 1);
                }
			}
			preProcessOut.OriginalText = control.innerHTML;
			if (imageUrlDuringCallBack || textDuringCallBack) {
			    if (control.nodeName.toUpperCase() == "INPUT") {
			        if (inputType == "CHECKBOX" || inputType == "RADIO" || inputType == "TEXT") {
			            preProcessOut.OriginalText = GetLabelText(control.id);
			            SetLabelText(control.id, textDuringCallBack);
			        } else if (inputType == "IMAGE") {
			            if (imageUrlDuringCallBack) {
			                preProcessOut.OriginalText = control.src;
			                control.src = imageUrlDuringCallBack;
			            } else {
			                preProcessOut.ParentElement = control.parentElement ? control.parentElement : control.parentNode;
			                if (preProcessOut.ParentElement) {
			                    preProcessOut.OriginalText = preProcessOut.ParentElement.innerHTML;
			                    preProcessOut.ParentElement.innerHTML = textDuringCallBack;
			                }
			            }
			        } else if (inputType == "SUBMIT") {
			            preProcessOut.OriginalText = control.value;
			            control.value = textDuringCallBack;
			        }
			    } else if (control.nodeName.toUpperCase() == "SELECT") {
			        preProcessOut.OriginalText = GetLabelText(control.id);
			        SetLabelText(control.id, textDuringCallBack);
			    } else {
				    control.innerHTML = textDuringCallBack;
				}
			}
			control.disabled = (typeof enabledDuringCallBack == "undefined") ? false : !enabledDuringCallBack;
			return true;
        } else {
            return false;
        }
	} else {
	    if (callBackCancelledFunction) {
		    callBackCancelledFunction(control);
		}
		return false;
	}
}

function Bamboo_PreProcessCallBackOut() {
    // Fields
    this.ParentElement = null;
    this.OriginalText = '';
    this.Enabled = true;
}

function Bamboo_PostProcessCallBack(
    result, 
    control,
    eventTarget, 
    clientCallBack, 
    clientCallBackArg, 
    imageUrlDuringCallBack, 
    textDuringCallBack, 
    postCallBackFunction, 
    preProcessOut
) {
    if (postCallBackFunction) {
        postCallBackFunction(control);
    }
	control.disabled = !preProcessOut.Enabled;
    var inputType = control.getAttribute("type");
    inputType = (inputType == null) ? '' : inputType.toUpperCase();
	if (inputType == "IMAGE") {
	    var form = document.getElementById(Bamboo_FormID);
        Bamboo_RemoveHiddenInput(form, eventTarget + ".x");
        Bamboo_RemoveHiddenInput(form, eventTarget + ".y");
	}
	if (imageUrlDuringCallBack || textDuringCallBack) {
	    if (control.nodeName.toUpperCase() == "INPUT") {
	        if (inputType == "CHECKBOX" || inputType == "RADIO" || inputType == "TEXT") {
	            SetLabelText(control.id, preProcessOut.OriginalText);
	        } else if (inputType == "IMAGE") {
	            if (imageUrlDuringCallBack) {
	                control.src = preProcessOut.OriginalText;
	            } else {
	                preProcessOut.ParentElement.innerHTML = preProcessOut.OriginalText;
	            }
	        } else if (inputType == "SUBMIT") {
	            control.value = preProcessOut.OriginalText;
	        }
	    } else if (control.nodeName.toUpperCase() == "SELECT") {
	        SetLabelText(control.id, preProcessOut.OriginalText);
	    } else {
	        control.innerHTML = preProcessOut.OriginalText;
	    }
	}
	if (clientCallBack) {
	    clientCallBack(result, clientCallBackArg);
	}
}

function Bamboo_FireCallBackEvent(
	control,
	e,
	eventTarget,
	eventArgument,
	causesValidation,
	validationGroup,
	imageUrlDuringCallBack,
	textDuringCallBack,
	enabledDuringCallBack,
	preCallBackFunction,
	postCallBackFunction,
	callBackCancelledFunction,
	includeControlValuesWithCallBack,
	updatePageAfterCallBack
) {
	var preProcessOut = new Bamboo_PreProcessCallBackOut();
	var preProcessResult = Bamboo_PreProcessCallBack(
	    control, 
	    e, 
	    eventTarget,
	    causesValidation, 
	    validationGroup, 
	    imageUrlDuringCallBack, 
	    textDuringCallBack, 
	    enabledDuringCallBack, 
	    preCallBackFunction, 
	    callBackCancelledFunction, 
	    preProcessOut
	);
    if (preProcessResult) {
	    Bamboo_FireEvent(
		    eventTarget,
		    eventArgument,
		    function(result) {
                Bamboo_PostProcessCallBack(
                    result, 
                    control, 
                    eventTarget,
                    null, 
                    null, 
                    imageUrlDuringCallBack, 
                    textDuringCallBack, 
                    postCallBackFunction, 
                    preProcessOut
                );
		    },
		    null,
		    includeControlValuesWithCallBack,
		    updatePageAfterCallBack
	    );
    }
}

function BambooListControl_OnClick(
    e,
	causesValidation,
	validationGroup,
	textDuringCallBack,
	enabledDuringCallBack,
	preCallBackFunction,
	postCallBackFunction,
	callBackCancelledFunction,
	includeControlValuesWithCallBack,
	updatePageAfterCallBack
) {
	var target = e.target || e.srcElement;
	if (target.nodeName.toUpperCase() == "LABEL" && target.htmlFor != '')
	    return;
	var eventTarget = target.id.split("_").join("$");
	Bamboo_FireCallBackEvent(
	    target, 
	    e,
	    eventTarget, 
	    '', 
	    causesValidation, 
	    validationGroup, 
	    '',
	    textDuringCallBack, 
	    enabledDuringCallBack, 
	    preCallBackFunction, 
	    postCallBackFunction, 
	    callBackCancelledFunction, 
	    true, 
	    true
	);
}

function GetLabelText(id) {
    var labels = document.getElementsByTagName('label');
    for (var i = 0; i < labels.length; i++) {
        if (labels[i].htmlFor == id) {
            return labels[i].innerHTML;
        }
    }
    return null;
}

function SetLabelText(id, text) {
    var labels = document.getElementsByTagName('label');
    for (var i = 0; i < labels.length; i++) {
        if (labels[i].htmlFor == id) {
            labels[i].innerHTML = text;
            return;
        }
    }
}

function Bamboo_SetCursor()
{
	document.body.style.cursor="wait";	
}
function Bamboo_RemoveCursor()
{
	document.body.style.cursor = "auto";	
}

var objCurrentWPID;
function Bamboo_SetImageSimpleSearch(currentWPID,urlImage,text1,text2) {
objCurrentWPID = currentWPID;
var objIDElementParent = objCurrentWPID+"_WaitingImage";
var objIDElementChild = objCurrentWPID+"_DivImgage";

var strTable = "<table BORDER='0px' cellspacing='0' cellpadding='0' style='width: 100%; height:20%; margin:0;'>";
    strTable +="<tr valign='middle'>";
    strTable +="<td class='ms-WPHeader' align='center' height='18px'>";
    //strTable +="<b>Please Wait</b></td>";
	strTable +="<b>" + text1 +"</b></td>";
	strTable +="</tr>";
	strTable +="<tr valign='middle' height='20'>";
    //strTable +="<td align='center' >Contacting Server.....</td>";
    strTable +="<td align='center' >" + text2 + "</td>";
	strTable +="</tr>";
	strTable +="<tr valign='top'>";
	strTable +="<td align='center'>";
	strTable +="<img src='"+urlImage+"/wait.gif'></img></td></tr></table>";
	
	var elementChild = document.createElement("DIV");
	elementChild.id = objIDElementChild;
	elementChild.style.zIndex = "1";
	elementChild.innerHTML = strTable;
	
	var ElementParent = document.getElementById(objIDElementParent);	
	elementChild.setAttribute("class","ms-main");
	elementChild.style.position = 'absolute';
	elementChild.style.backgroundColor= '#ffffff';
	elementChild.style.width = ElementParent.offsetWidth;
	elementChild.style.height = ElementParent.offsetHeight;	
	ElementParent.appendChild(elementChild);
	
	}
		
function Bamboo_RemoveImageSimpleSearch() {
	var objIDElementParent = objCurrentWPID+"_WaitingImage";
	var objIDElementChild = objCurrentWPID+"_DivImgage";
	var elementChild = document.getElementById(objIDElementChild);
	if(elementChild != null)
	{
		var ElementParent = document.getElementById(objIDElementParent);
		ElementParent.removeChild(elementChild);		
	}
	objCurrentWPID = "";
}

///////////////////////////////////////////////////////////////////////////////////
/*Show window CSS edit*/
///////////////////////////////////////////////////////////////////////////////////
function ShowPopupCss(idObjData,webPartName)
{ 
  
  try
  {
	var containID = idObjData;
	//NQ 09/14/2007 START 
	var objArguments = new Object();
	objArguments.containID = document.getElementById(containID).value;
	//NQ 09/14/2007 END
 
	var props = 'dialogHeight:512px; dialogWidth: 670px; edge: Raised; center: Yes; help: No; resizable: yes; status: No';
	var objReturn = window.showModalDialog(webPartName + "/Bamboo.PopupCss.html" ,objArguments, props);   
	if(objReturn)
		document.getElementById(containID).value = objReturn;
  }
  catch(ex)
  {}
  
}
///////////////////////////////////////////////////////////////////////////////////
/*Show window HTML edit*/
///////////////////////////////////////////////////////////////////////////////////
function ShowPopupHTML(idObjData, idObjDataDefault, objHtml, webPartName, idObjListFields, idCheckBoxKeywords)
{ 
 try
  {
	var containID = idObjDataDefault;
	var defaultHtml = "1";
	var objListField = document.getElementById(idObjListFields);
	var cbxKeywords = document.getElementById(idCheckBoxKeywords);
	
	if(document.getElementById(objHtml) != null)
	{
		if(document.getElementById(objHtml).value=="Custom")
		{
			defaultHtml = "0";
			containID = idObjData;
		} 
	}
	
	var objArguments = new Object();
	objArguments.containID = document.getElementById(containID).value;
	objArguments.defaultHtml = defaultHtml;
	objArguments.listField = objListField;
	objArguments.cbxKeywords = cbxKeywords;
	
  
	var props = 'dialogHeight:537px; dialogWidth: 690px; edge: Raised; center: Yes; help: No; resizable: yes; status: No';
	var objReturn = window.showModalDialog(webPartName + "/Bamboo.PopupHTML.html" ,objArguments, props);   
	if(objReturn)
		document.getElementById(containID).value = objReturn;
  }
  catch(ex)
  {}
  
}

//================================================= SNOW EFFECT ==========================================================


var snowStorm = null;
var imagePath = null; // relative path to snow images
var flakesMaxActive = 250;
function SnowStorm() {
  var s = this;
  var storm = this;
  this.timers = [];
  this.flakes = [];
  this.disabled = false;
  this.terrain = [];

  // User-configurable variables
  // ---------------------------

  var usePNG = true;
  var flakeTypes = 6;
  var flakesMax = 128;
  //var flakesMaxActive = 150;
  var vMax = 2.5;
  var flakeWidth = 5;
  var flakeHeight = 5;
  var flakeBottom = null; // Integer for fixed bottom, 0 or null for "full-screen" snow effect
  var snowCollect = true;
  var showStatus = true;

  // --- End of user section ---

  var isIE = (navigator.appName.toLowerCase().indexOf('internet explorer')+1);
  var isWin9X = (navigator.appVersion.toLowerCase().indexOf('windows 98')+1);
  var isOpera = (navigator.userAgent.toLowerCase().indexOf('opera ')+1 || navigator.userAgent.toLowerCase().indexOf('opera/')+1);
  if (isOpera) isIE = false; // Opera (which is sneaky, pretending to be IE by default)
  var screenX = null;
  var screenY = null;
  var scrollY = null;
  var vRndX = null;
  var vRndY = null;

  function rnd(n,min) {
    if (isNaN(min)) min = 0;
    return (Math.random()*n)+min;
  }

  this.randomizeWind = function() {
    vRndX = plusMinus(rnd(vMax,0.2));
    vRndY = rnd(vMax,0.2);
    if (this.flakes) {
      for (var i=0; i<this.flakes.length; i++) {
        if (this.flakes[i].active) this.flakes[i].setVelocities();
      }
    }
  }

  function plusMinus(n) {
    return (parseInt(rnd(2))==1?n*-1:n);
  }

  this.resizeHandler = function() {
    if (window.innerWidth || window.innerHeight) {
      screenX = window.innerWidth-(!isIE?24:2);
      screenY = (flakeBottom?flakeBottom:window.innerHeight);
    } else {
      screenX = (document.documentElement.clientWidth||document.body.clientWidth||document.body.scrollWidth)-(!isIE?8:0);
      screenY = flakeBottom?flakeBottom:(document.documentElement.clientHeight||document.body.clientHeight||document.body.scrollHeight);
    }
    s.scrollHandler();
  }

  this.scrollHandler = function() {
    // "attach" snowflakes to bottom of window if no absolute bottom value was given
    scrollY = (flakeBottom?0:parseInt(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop));
    if (isNaN(scrollY)) scrollY = 0; // Netscape 6 scroll fix
    if (!flakeBottom && s.flakes) {
      for (var i=0; i<s.flakes.length; i++) {
        if (s.flakes[i].active == 0) s.flakes[i].stick();
      }
    }
  }

  this.freeze = function() {
    // pause animation
    if (!s.disabled) {
      s.disabled = 1;
    } else {
      return false;
    }
    if (!isWin9X) {
      clearInterval(s.timers);
    } else {
      for (var i=0; i<s.timers.length; i++) {
        clearInterval(s.timers[i]);
      }
    }
  }

  this.resume = function() {
    if (s.disabled) {
       s.disabled = 0;
    } else {
      return false;
    }
    s.timerInit();
  }

  this.stop = function() {
    this.freeze();
    for (var i=0; i<this.flakes.length; i++) {
      this.flakes[i].o.style.display = 'none';
    }
    removeEventHandler(window,'scroll',this.scrollHandler,false);
    removeEventHandler(window,'resize',this.resizeHandler,false);
  }

  this.SnowFlake = function(parent,type,x,y) {
    var s = this;
    var storm = parent;
    this.type = type;
    this.x = x||parseInt(rnd(screenX-12));
    this.y = (!isNaN(y)?y:-12);
    this.vX = null;
    this.vY = null;
    this.vAmpTypes = [2.0,1.0,1.25,1.0,1.5,1.75]; // "amplification" for vX/vY (based on flake size/type)
    this.vAmp = this.vAmpTypes[this.type];

    this.active = 1;
    this.o = document.createElement('img');
    this.o.style.position = 'absolute';
    this.o.style.width = flakeWidth+'px';
    this.o.style.height = flakeHeight+'px';
    this.o.style.fontSize = '1px'; // so IE keeps proper size
    this.o.style.zIndex = 2;
    this.o.src = imagePath+this.type+(pngHandler.supported && usePNG?'.png':'.gif');
    document.body.appendChild(this.o);
    if (pngHandler.supported && usePNG) pngHandler.transform(this.o);

    this.refresh = function() {
      this.o.style.left = this.x+'px';
      this.o.style.top = this.y+'px';
    }

    this.stick = function() {
      s.o.style.top = (screenY+scrollY-flakeHeight-storm.terrain[Math.floor(this.x)])+'px';
      // called after relative left has been called
    }

    this.vCheck = function() {
      if (this.vX>=0 && this.vX<0.2) {
        this.vX = 0.2;
      } else if (this.vX<0 && this.vX>-0.2) {
        this.vX = -0.2;
      }
      if (this.vY>=0 && this.vY<0.2) {
        this.vY = 0.2;
      }
    }

    this.move = function() {
      this.x += this.vX;
      this.y += (this.vY*this.vAmp);
      this.refresh();

      if (this.vX && screenX-this.x<flakeWidth+this.vX) { // X-axis scroll check
        this.x = 0;
      } else if (this.vX<0 && this.x<0-flakeWidth) {
        this.x = screenX-flakeWidth; // flakeWidth;
      }
      var yDiff = screenY+scrollY-this.y-storm.terrain[Math.floor(this.x)];
      if (yDiff<flakeHeight) {
        this.active = 0;
        if (snowCollect) {
          var height = [0.75,1.5,0.75];
          for (var i=0; i<2; i++) {
            storm.terrain[Math.floor(this.x)+i+2] += height[i];
          }
        }
        this.o.style.left = ((this.x-(!isIE?flakeWidth:0))/screenX*100)+'%'; // set "relative" left (change with resize)
        if (!flakeBottom) {
          this.stick();
        }
      }
    }

    this.animate = function() {
      // main animation loop
      // move, check status, die etc.
      this.move();
    }

    this.setVelocities = function() {
      this.vX = vRndX+rnd(vMax*0.12,0.1);
      this.vY = vRndY+rnd(vMax*0.12,0.1);
    }

    this.recycle = function() {
      this.setVelocities();
      this.vCheck();
      this.x = parseInt(rnd(screenX-flakeWidth-1));
      this.y = parseInt(rnd(640)*-1)-flakeHeight;
      this.active = 1;
    }

    this.recycle(); // set up x/y coords etc.
    this.refresh();

  }

  this.snow = function() {
    var active = 0;
    var used = 0;
    var waiting = 0;
    for (var i=this.flakes.length-1; i>0; i--) {
      if (this.flakes[i].active == 1) {
        this.flakes[i].animate();
        active++;
      } else if (this.flakes[i].active == 0) {
        used++;
      } else {
        waiting++;
      }
    }
    if (snowCollect && !waiting) { // !active && !waiting
      // create another batch of snow
      this.createSnow(flakesMaxActive,true);
    }
    if (active<flakesMaxActive) {
      with (this.flakes[parseInt(rnd(this.flakes.length))]) {
        if (!snowCollect && active == 0) 
        {
          recycle();
        } 
        //else if (active == -1) 
        //{
         // active =1;
        //}
      }
    }
  }

  this.createSnow = function(limit,allowInactive) {
    if (showStatus) window.status = 'Creating snow...';
    for (var i=0; i<limit; i++) {
      this.flakes[this.flakes.length] = new this.SnowFlake(this,parseInt(rnd(flakeTypes)));
      if (allowInactive || i>flakesMaxActive) this.flakes[this.flakes.length-1].active = -1;
    }
    if (showStatus) window.status = '';
  }

  this.timerInit = function() {
    this.timers = (!isWin9X?setInterval("snowStorm.snow()",20):[setInterval("snowStorm.snow()",75),setInterval("snowStorm.snow()",25)]);
  }

  this.init = function() {
    for (var i=0; i<8192; i++) {
      this.terrain[i] = 0;
    }
    this.randomizeWind();
    this.createSnow(snowCollect?flakesMaxActive:flakesMaxActive*2); // create initial batch
    addEventHandler(window,'resize',this.resizeHandler,false);
    addEventHandler(window,'scroll',this.scrollHandler,false);
    // addEventHandler(window,'scroll',this.resume,false); // scroll does not cause window focus. (odd)
    // addEventHandler(window,'blur',this.freeze,false);
    // addEventHandler(window,'focus',this.resume,false);
    this.timerInit();
  }

  this.resizeHandler(); // get screen coordinates

  if (screenX && screenY && !this.disabled) {
    this.init();
  }
	
}

//function snowStormInit() 
//{
  //setTimeout("snowStorm = new SnowStorm()",500);
//}


function snowStormInit(path, flakesMax) 
{
  flakesMaxActive = (flakesMax*flakesMaxActive)/50;  
  imagePath = path;   
  setTimeout("snowStorm = new SnowStorm()",5000);
}


var addEventHandler = null;
var removeEventHandler = null;

function postLoadEvent(eventType) {
  // test for adding an event to the body (which has already loaded) - if so, fire immediately
  return ((eventType.toLowerCase().indexOf('load')>=0) && document.body);
}

function addEventHandlerDOM(o,eventType,eventHandler,eventBubble) {
  if (!postLoadEvent(eventType)) {
    o.addEventListener(eventType,eventHandler,eventBubble);
  } else {
    eventHandler();
  }
}

function removeEventHandlerDOM(o,eventType,eventHandler,eventBubble) {
  o.removeEventListener(eventType,eventHandler,eventBubble);
}
  
function addEventHandlerIE(o,eventType,eventHandler) { // IE workaround
  if (!eventType.indexOf('on')+1) eventType = 'on'+eventType;
  if (!postLoadEvent(eventType)) {
    o.attachEvent(eventType,eventHandler); // Note addition of "on" to event type
  } else {
    eventHandler();
  }
}
  
function removeEventHandlerIE(o,eventType,eventHandler) {
  if (!eventType.indexOf('on')+1) eventType = 'on'+eventType;
  o.detachEvent(eventType,eventHandler);
}

function addEventHandlerOpera(o,eventType,eventHandler,eventBubble) {
  if (!postLoadEvent(eventType)) {
    (o==window?document:o).addEventListener(eventType,eventHandler,eventBubble);
  } else {
    eventHandler();
  }
}

function removeEventHandlerOpera(o,eventType,eventHandler,eventBubble) {
  (o==window?document:o).removeEventListener(eventType,eventHandler,eventBubble);
}

if (navigator.userAgent.toLowerCase().indexOf('opera ')+1 || navigator.userAgent.toLowerCase().indexOf('opera/')+1) {
  // opera is dumb at times.
  addEventHandler = addEventHandlerOpera;
  removeEventHandler = removeEventHandlerOpera;
} else if (document.addEventListener) { // DOM event handler method
  addEventHandler = addEventHandlerDOM;
  removeEventHandler = removeEventHandlerDOM;
} else if (document.attachEvent) { // IE event handler method
  addEventHandler = addEventHandlerIE;
  removeEventHandler = removeEventHandlerIE;
} else { // Neither "DOM level 2" (?) methods supported
  addEventHandler = function(o,eventType,eventHandler,eventBubble) {
    o['on'+eventType] = eventHandler;
    // Multiple events could be added here via array etc.
  }
  removeEventHandler = function(o,eventType,eventHandler,eventBubble) {}
}



function PNGHandler() {
  var self = this;

  this.na = navigator.appName.toLowerCase();
  this.nv = navigator.appVersion.toLowerCase();
  this.isIE = this.na.indexOf('internet explorer')+1?1:0;
  this.isWin = this.nv.indexOf('windows')+1?1:0;
  this.isIEMac = (this.isIE&&!this.isWin);
  this.isIEWin = (this.isIE&&this.isWin);
  this.ver = this.isIE?parseFloat(this.nv.split('msie ')[1]):parseFloat(this.nv);
  this.isMac = this.nv.indexOf('mac')+1?1:0;
  this.isOpera = (navigator.userAgent.toLowerCase().indexOf('opera ')+1 || navigator.userAgent.toLowerCase().indexOf('opera/')+1);
  if (this.isOpera) this.isIE = false; // Opera filter catch (which is sneaky, pretending to be IE by default)
  this.filterID = 'DXImageTransform.Microsoft.AlphaImageLoader';
  this.supported = false;
  this.transform = self.doNothing;

  this.filterMethod = function(o) {
    // IE 5.5+ proprietary filter garbage (boo!)
    // Create new element based on old one. Doesn't seem to render properly otherwise (due to filter?)
    // use DOM "currentStyle" method, so rules inherited via CSS are picked up.
    if (o.nodeName != 'IMG') {
      var b = o.currentStyle.backgroundImage.toString(); // parse out background image URL
      o.style.backgroundImage = 'none';
      // Parse out background image URL from currentStyle.
      var i1 = b.indexOf('url("')+5;
      var newSrc = b.substr(i1,b.length-i1-2).replace('.gif','.png'); // find first instance of ") after (", chop from string
      o.style.writingMode = 'lr-tb'; // Has to be applied so filter "has layout" and is displayed. Seriously. Refer to http://msdn.microsoft.com/workshop/author/filter/reference/filters/alphaimageloader.asp?frame=true
      o.style.filter = "progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod='"+(o.className.indexOf('scale')+1?'scale':'crop')+"')";
    } else if (o.nodeName == 'IMG') {
      var newSrc = o.getAttribute('src').replace('.gif','.png');
      // apply filter
      o.src = 'image/none.gif'; // get rid of image
      o.style.filter = "progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod="+(o.className.indexOf('scale')+1?'scale':'crop')+"')";
      o.style.writingMode = 'lr-tb'; // Has to be applied so filter "has layout" and is displayed. Seriously. Refer to http://msdn.microsoft.com/workshop/author/filter/reference/filters/alphaimageloader.asp?frame=true
    }
  }

  this.pngMethod = function(o) {
    // Native transparency support. Easy to implement. (woo!)
    bgImage = this.getBackgroundImage(o);
    if (bgImage) {
      // set background image, replacing .gif
      o.style.backgroundImage = 'url('+bgImage.replace('.gif','.png')+')';
    } else if (o.nodeName == 'IMG') {
      o.src = o.src.replace('.gif','.png');
    } else if (!bgImage) {
      // no background image
    }
  }

  this.getBackgroundImage = function(o) {
    var b, i1; // background-related variables
    var bgUrl = null;
    if (o.nodeName != 'IMG' && !(this.isIE && this.isMac)) { // ie:mac PNG support broken for DIVs with PNG backgrounds
      if (document.defaultView) {
        if (document.defaultView.getComputedStyle) {
          b = document.defaultView.getComputedStyle(o,'').getPropertyValue('background-image');
          i1 = b.indexOf('url(')+4;
          bgUrl = b.substr(i1,b.length-i1-1);
        } else {
          // no computed style
          return false;
        }
      } else {
        // no default view
        return false;
      }
    }
    return bgUrl;
  }

  this.doNothing = function() {}
  
  this.supportTest = function() {
    // Determine method to use.
    // IE 5.5+/win32: filter

    if (this.isIE && this.isWin && this.ver >= 5.5) {
      // IE proprietary filter method (via DXFilter)
      self.transform = self.filterMethod;
    } else if (!this.isIE && this.ver < 5) {
      // No PNG support or broken support
      // Leave existing content as-is
      self.transform = null;
      return false;
    } else if (!this.isIE && this.ver >= 5 || (this.isIE && this.isMac && this.ver >= 5)) { // version 5+ browser (not IE), or IE:mac 5+
      self.transform = self.pngMethod;
    } else {
      // Presumably no PNG support. GIF used instead.
      self.transform = null;
      return false;
    }
    return true;
  }

  this.init = function() {
    this.supported = this.supportTest();
  }

}

function getElementsByClassName(className,oParent) {
  var doc = (oParent||document);
  var matches = [];
  var nodes = doc.all||doc.getElementsByTagName('*');
  for (var i=0; i<nodes.length; i++) {
    if (nodes[i].className == className || nodes[i].className.indexOf(className)+1 || nodes[i].className.indexOf(className+' ')+1 || nodes[i].className.indexOf(' '+className)+1) {
      matches[matches.length] = nodes[i];
    }
  }
  return matches; // kids, don't play with fire. ;)
}

// Instantiate and initialize PNG Handler

var pngHandler = new PNGHandler();

pngHandler.init();


//addEventHandler(window,'load',snowStormInit,false);


//===============================================RAIN EFFECT=====================================================

select = false;    // choose rain or select effect - false-rain;   true-select
selsnow = " ' "  // symbols for select & rain
selrain = " / "  
count = 200     // declare how many drops
drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()//visit http://www.geocities.com/mobinlodhia

if(select){sel = selsnow; speed=1; cross=10; drops=count}
else{sel = selrain; speed=100; drops=count; cross=9}
runx = -speed/cross; runy = speed; count = 0;

_count =0;
_exist_rain=false;
function rainstart(rainMax, clientID, clearTimeoutObj)
{
	var clearTimeRain = clientID + "_RainObj";
	temp = rainMax;
	temp_clientID =  clientID;	
	
     if(_exist_rain)
	 {	
        MultiRain(temp, temp_clientID, clearTimeoutObj, true, clearTimeRain);
	 }
     else
	 {
	    _exist_rain = true;	
	    MultiRain(temp, temp_clientID, clearTimeoutObj, false, clearTimeRain);	    			
	 }
}

function MultiRain(rainMax, clientID, clearTimeoutObj, exist, clearTimeRain)
{
	temp = rainMax;
	drops = temp*80/50;
	temp_clientID = clientID;			
	if(!exist)	
	{
        for(run = 0; run < drops; run++)
		{
	   	 document.getElementById("drop" + run).style.display = "block";
	   	 xx[run]+=runx;  yy[run]+=mv[run];
	    	hmm = Math.round(Math.random()*1);
		if(xx[run] < 0){xx[run] = maxx+10;}
		if(yy[run] > maxy){yy[run] = 10;}
		drop[run].left = xx[run]
		drop[run].top = yy[run]+document.body.scrollTop;
		}
		_count++;
		
		if(_count > 120)
		{	
			for(make = 0; make < drops; make++)
			{			
				document.getElementById("drop" + make).style.display = "none";			
        	}
	    	window.clearTimeout(clearTimeRain);
	        //InitialWidthZone(temp_clientID);		
           RunText(temp_clientID, clearTimeoutObj);        			    
		}
		else
		{	
			clearTimeRain = window.setTimeout(function()
       		 {
            	 MultiRain(temp, clientID, clearTimeoutObj, exist, clearTimeRain);
       		 }, 1);
		}
	}
	else
	{		
		if(_count > 120)
		{			
		   	window.clearTimeout(clearTimeRain);
	        //InitialWidthZone(temp_clientID);		
            RunText(temp_clientID, clearTimeoutObj);	
		}
		else
		{	
		   clearTimeRain = window.setTimeout(function()
       	    {
            	MultiRain(temp, clientID, clearTimeoutObj, exist, clearTimeRain);
       		}, 1);
		}		
	}		
}

/*
function rainstart(rainMax, clientID, clearTimeoutObj)
{
	temp = rainMax;
	drops = temp*80/50;
    for(run = 0; run < drops; run++)
	{
	    document.getElementById("drop" + run).style.display = "block";
	    xx[run]+=runx;  yy[run]+=mv[run];
	    hmm = Math.round(Math.random()*1);
		if(xx[run] < 0){xx[run] = maxx+10;}
		if(yy[run] > maxy){yy[run] = 10;}
		drop[run].left = xx[run]
		drop[run].top = yy[run]+document.body.scrollTop;
	}
	_count++;
    temp_clientID = clientID;
	if(_count > 120)
	{
		for(make = 0; make < drops; make++)
		{			
			document.getElementById("drop" + make).style.display = "none";			
        }	
	    window.clearTimeout(rain_time);
	    //InitialWidthZone(temp_clientID);
		window.setTimeout(function()
        {
            RunText(temp_clientID, clearTimeoutObj);
        }, 2000);  		    
	}
	else
	{			
		rain_time = window.setTimeout(function()
        {
            rainstart(temp, temp_clientID);
        }, 1);
	}
		
}
*/
if (document.all)
{
//drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()//visit http://www.geocities.com/mobinlodhia
ly = "document.all[\'"; st = "\'].style"
for(make = 0; make < drops; make++)
	{
	document.write('<div id="drop'+make+'" class=drop>'+sel+'</div>');
	drop[make] = eval(ly+'drop'+make+st);
	maxx = document.body.clientWidth-40
	maxy = document.body.clientHeight-40
	xx[make] = Math.random()*maxx;
	yy[make] = -100-Math.random()*maxy;
	drop[make].left = xx[make]
	drop[make].top = yy[make]
	mv[make] = (Math.random()*5)+speed/4;
	drop[make].fontSize = (Math.random()*10)+14;
		if(select)
		{
		col = 'white'
		}
			else{col = '#586b78'
			}
		drop[make].color = col;
	}
//window.onload=rainstart
}

//=======================================================RUN TEXT ON PAGE======================================================
var holidayWidth = 0;
function getStartZonePos(obj) 
{
    var curleft = 0;
    try
    {
        if (obj.offsetParent) 
        {
            curleft = obj.offsetLeft

            while (obj = obj.offsetParent) 
            {
                curleft += obj.offsetLeft
            }
        }
    }
    catch(e)
    {
        curleft = 0;
    }
    return curleft;
}
function InitialWidthZone(clientID)
{
    var obj = document.getElementById(clientID + "_bamboo_message_holiday");
    var myObj = obj.parentNode;
    holidayWidth = document.body.clientWidth - getStartZonePos(myObj);
}

function CountDown(numSeconds, clientID, clearTimeoutObj, clearTimeoutObjCntDwn)
{
    try
    {    
        numSeconds = parseInt(numSeconds);
        if (numSeconds > 0)
        {
            numSeconds  = numSeconds - 1;
            clearTimeoutObjCntDwn = window.setTimeout(function()
            {
                CountDown(numSeconds, clientID, clearTimeoutObj, clearTimeoutObjCntDwn);
            }, 1000);
        }
        else
        {   
            //InitialWidthZone(clientID); 
			window.clearTimeout(clearTimeoutObjCntDwn);
            RunText(clientID, clearTimeoutObj);
        }
    }
    catch(e)
    {
        displayErrors('CountDown:: ' + e.message);
    }
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function RunText(clientID, clearTimeoutObj)
{    
	try
    {
        var obj = document.getElementById(clientID + "_bamboo_message_holiday");
        if(obj != undefined && obj != null)
        {
            var X = parseInt(obj.style.right);
            
            //if(X < parseInt(holidayWidth + 400))
			if(X < parseInt(document.body.clientWidth))
            {
                obj.style.display = "block";
                obj.style.right = X+1+'pt';	          
            }
            else
            {
                obj.style.display = 'none';
	            window.clearTimeout(clearTimeoutObj);
            }
            clearTimeoutObj = window.setTimeout(function()
            {
                RunText(clientID, clearTimeoutObj);
            }, 2);
        }
	}
	catch(e)
	{
	    displayErrors('RunText::' + e.message);
	}
}


//=======================================================UPDATE EEVERY MINUTES======================================================
function LTrim(value) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
function RTrim(value) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
function Trim(value) {
	return LTrim(RTrim(value));
}
function getHours(dateTimeString)
{
    var h;
    if (dateTimeString.indexOf(":") != -1)
    {
        var temp = dateTimeString.split(':');
        if (isNaN(temp[0]))
        {
            temp = temp[0].split(' ');h = temp[temp.length-1];            
        }
        else
        {
            h = temp[0];
        }
        h = parseInt(h, 10);
    }
    return h;
}
function getMinutes(dateTimeString)
{
    var m;
    if (dateTimeString.indexOf(":") != -1)
    {
        var temp = dateTimeString.split(':');temp = temp[1].split(' ');m = parseInt(temp[0], 10);       
    }
    return m;
}
function getSeconds(dateTimeString)
{
    var s;
    if (dateTimeString.indexOf(":") != -1)
    {
        var temp = dateTimeString.split(':');
        if (temp.length > 2)
        {
            temp = temp[2].split(' ');s = parseInt(temp[0], 10);            
        }
    }
    return s;
}
function getMeridiem(dateTimeString)
{
    var meridiem;
    if ((dateTimeString.toUpperCase().indexOf(" AM") != -1) || (dateTimeString.toUpperCase().indexOf(" PM") != -1))
    {
        var temp = dateTimeString.split(' ');meridiem = temp[temp.length-1];        
    }
	if (meridiem == undefined)
	{
		meridiem = "";
	}    
    return meridiem;
}
function getDateString(dateTimeString)
{
    var resultString;
    if (dateTimeString.indexOf(":") != -1)
    {
        var tmp = dateTimeString.split(':');
        if (isNaN(tmp[0]))
        {
            var len = tmp[0].lastIndexOf(' ');resultString = tmp[0].substring(0, len);            
        }
        else
        {
            resultString = "";
        }
    }
    return resultString;
}
function getFullDateTimeFormat(dateString, hour, minute, second, meridiem)
{
    minute += 1;
    if (minute == 60)
    {
        hour = hour + 1;minute = 0;        
    }
    hour = (hour <= 9) ? ("0" + hour) : hour;
    minute = (minute <= 9) ? ("0" + minute) : minute;
    if (second != null)
    {
        second = (second <= 9) ? ("0" + second) : second;
        dateString += hour + ":" + minute + ":" + second + " " + meridiem;
    }
    else
    {
        dateString += hour + ":" + minute + " " + meridiem;
    }
    return Trim(dateString);
}
function updateDateTime(id, cnt)
{
    try
    {
        var updateEveryMinute;var nCount = parseInt(cnt, 10) + 30;var dateString;var dateTime;
        if (document.getElementById(id) != null)
        {
            dateTime = document.getElementById(id).innerText;  
            if(dateTime ==undefined)
            {
                dateTime = document.getElementById(id).textContent;  
            }      
            if (dateTime.indexOf(":") != -1)
            {
                if (nCount >= 60)
                {
                    nCount = 0;dateString = getDateString(dateTime);                        
                    if (dateString.length > 0)
                    {
                        dateString += " ";
                    }
                    var hour = getHours(dateTime);var minute = getMinutes(dateTime);var second = getSeconds(dateTime);var meridiem = getMeridiem(dateTime);
                    document.getElementById(id).innerText = getFullDateTimeFormat(dateString, hour, minute, second, meridiem);
                }
                updateEveryMinute = setTimeout(function()
                {
                    updateDateTime(id, nCount);
                }, 30000);                
            }
        }    
    }
    catch(e)
    {
        displayErrors('updateDateTime::' + e.message);
    }
}
function displayErrors(errorMessage)
{
    alert('Error::' + errorMessage);
}
function addOnLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
//----------------------------------------Bamboo Slider control----------------------------------------

function bambooMoveSlider(sliderId)
{
    var isMouseDown = false; 
    var level = 9;
    var currentPercent = 0;
    var controlSliderId = sliderId;
	var isIE = document.all;
	var scrollToolPane = 0;
	
    this.mousedown = function()
    {	
	    isMouseDown = true;	
		scrollToolPane = this.getPositionOfDIV();		
	    return false;		
    }	
    
    function findPos(obj) 
    {
        var curleft = 0;
        try
        {
            if (obj.offsetParent) 
            {
                curleft = obj.offsetLeft

                while (obj = obj.offsetParent) 
                {
                    curleft += obj.offsetLeft
                }
            }
        }
        catch(e)
        {
            curleft = 0;
        }
        return curleft;
    }
    
	function getPosScroll()
    {
        var posScrollBar = 0;
        if (isIE)
        {
            posScrollBar = document.body.scrollLeft;
        }
        else
        {
            posScrollBar = window.pageXOffset;
        }
        return posScrollBar;
    }
    
    this.mousemove = function()
    {	
        var myObj = document.getElementById(controlSliderId + 'sliderId');  
        
	    if (isMouseDown == true && myObj != null)
	    {
		    var obj = myObj.parentNode;
		    var evnt = window.event;
		    var myWidth = parseInt(obj.style.width.replace('px', ''));
		    var offset = obj.offsetLeft;    		
			var fpos = findPos(obj);
			
			if (((evnt.clientX + getPosScroll() + scrollToolPane) - (fpos + level)) <= 0)
			{
				currentPercent = 0;
				myObj.style.left = 0 + 'px';
			}
			else if (((evnt.clientX + getPosScroll() + scrollToolPane) - (fpos + myWidth)) >= 0)
			{
				currentPercent = 100;
				myObj.style.left = 90 + 'px';
			}
			else
		    {			
			    myObj.style.left = ((evnt.clientX + getPosScroll() + scrollToolPane) - (fpos + level))  + 'px';		
    			
			    var objNew = myObj;
	            var offsetNew = objNew.offsetLeft;
				currentPercent = (offsetNew + level);	
		    }		    
			document.getElementById(controlSliderId + 'positionSlider').innerText = currentPercent + '%';	
			document.getElementById(controlSliderId + '_HidderFieldId').value = currentPercent;
			return false;  
	    }
    }

    this.mouseup = function()
    {
	    if (isMouseDown) 
	    {
		    isMouseDown = false;		
        }
	    return false;
    }

    this.onSubSignClick = function(sliderId)
    {	
	    var obj = document.getElementById(sliderId);
	    var offset = obj.offsetLeft;
    	
	    //if (currentPercent >= (level + 1))
	    if (offset >= level)
	    {
	        currentPercent -= (level+1);
	        //var pos = (offset >= level) ? (offset - level) : (level - offset);
		    obj.style.left = (offset - level) + 'px';			
	    }
	    else
	    {
	        currentPercent = 0;
		    obj.style.left = 0 + 'px';		    
	    }
		document.getElementById(controlSliderId + 'positionSlider').innerText = currentPercent + '%';	    
	    document.getElementById(controlSliderId + '_HidderFieldId').value = currentPercent;		
    }    	

    this.onPlusSignClick = function(sliderId)
    {   
	    var obj = document.getElementById(sliderId);
	    var offset = obj.offsetLeft;
    	
	    //if ((currentPercent + (level + 1)) <= 100)
	    if ((offset + level) <= 90)
	    {
	        currentPercent += (level+1);
		    obj.style.left = (offset + level) + 'px';
	    }	
	    else
	    {
	        currentPercent = 100;
	        obj.style.left = 90 + 'px';
	    } 	
	    document.getElementById(controlSliderId + 'positionSlider').innerText = currentPercent + '%';	    			    
	    document.getElementById(controlSliderId + '_HidderFieldId').value = currentPercent;			    
    }
    
    this.restoreSliderValues = function()
    {
        currentPercent = parseInt(document.getElementById(controlSliderId + '_HidderFieldId').value);
        var obj = document.getElementById(controlSliderId + 'sliderId');
	    document.getElementById(controlSliderId + 'positionSlider').innerText = currentPercent + '%';
	    var pos = Math.round((currentPercent * 90)/100);
    
        obj.style.left = pos + 'px';        
    }
	
	this.getPositionOfDIV = function()
	{	
		var scrollToolPane = 0;
		var arrDIV = document.getElementsByTagName("DIV");
		var tmpObj = null;		
		for(var i = 0; i < arrDIV.length; i++)		
		{
		  var css = arrDIV[i].getAttribute('className');		 
		  var style = arrDIV[i].getAttribute('style');
		  if(css == "ms-ToolPaneBorder ms-ToolPaneBody" && style.cssText == "OVERFLOW: auto; WIDTH: 100%; HEIGHT: 100%")		  
		  {
		  	tmpObj = arrDIV[i];			
			break;
		  }
		}		
		if(tmpObj != null)
		{
			scrollToolPane = parseInt(tmpObj.scrollLeft);
		}
		return scrollToolPane;	
	}
    
    document.onmousemove = this.mousemove; 
    document.onmouseup = this.mouseup;    
}

