		
	var	displayX = -1 ;
	var	displayY = -1 ;
	
	var moveToX=-240;
	var moveToY=5;
	var iBeginAt = 0 ;
	var bDisplayWeekNumber = 1	;
	var bIsToday = 1;
	
	var strGuide = "Go To Current Month";
	var strToday = "Today is";
	var strWeek = "Weeks";
	
	var cssTodayStyle= "ms-WPHeader";
	var cssHeaderCalendar="ms-WPHeader";
	var cssTitleCalendar="ms-WPTitle";
	var cssBgCalendar="body-style";
	var cssWeekDateName="weekdateName";
	var cssSubTitle="ms-navheader";
	
	var strMonthLeftGuide = "Previous month. Hold mouse button to scroll automatically.";
	var strMonthRightGuide = "Next month. Hold mouse button to scroll automatically.";
	var mgsChooseMonth = "Choose a month.";
	var mgsChooseYear = "Choose a year.";
	var mgsChooseDay = "Choose [date] as date.";

	var	objCalendar, globalMonthObj, globalYearObj;
	var selectedValueMonth, selectedValueYear, selectedValueDate;
	var objSelectedMonth, objSelectedYear, objSelectedDate;
	var assignedMonthValue, assignedYearValue;
	var iChangeValueMonth, iChangeValueYear, iResetValueMonth, iResetValueYear;
	
	var desControl;
	
	var	strFormatDate, iBeginYear;

	var	isPostBack=false;
	var	isIE=document.all;
	var	myDoc=document.getElementById;

	var	docLayers=document.layers;
	var	dtNow =	new	Date();
	var	currentDate	 = dtNow.getDate();
	var	currentMonth = dtNow.getMonth();
	var	currentYear	 = dtNow.getYear();
			
	
	var	arrSourceImage = new Array("Bamboo_drop1.gif","Bamboo_drop2.gif","Bamboo_left1.gif","Bamboo_left2.gif","Bamboo_right1.gif","Bamboo_right2.gif");
	var	arrImages	= new Array();
	
	var objCallBackFunction = "";

	var bInvisible = false;
	
	function InvisibleElement( elmID, overDiv )
    {
      if( isIE )
      {
        for( i = 0; i < document.all.tags( elmID ).length; i++ )
        {
          obj = document.all.tags( elmID )[i];
          if( !obj || !obj.offsetParent )
          {
            continue;
          }
      
         
          objLeft   = obj.offsetLeft;
          objTop    = obj.offsetTop;
          objParent = obj.offsetParent;
          
          while( objParent.tagName.toUpperCase() != "BODY" )
          {
            objLeft  += objParent.offsetLeft;
            objTop   += objParent.offsetTop;
            objParent = objParent.offsetParent;
          }
      
          objHeight = obj.offsetHeight;
          objWidth = obj.offsetWidth;

          if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
          else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
          else if( overDiv.offsetTop >= ( objTop + objHeight ));
          else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
          else
          {
            obj.style.visibility = "hidden";
          }
        }
      }
    }
     // Written by Huu Khang
     function Bamboo_Show(obj,obj1,divid)
	{
		document.getElementById(obj).style.display="block";
		document.getElementById(obj1).style.display="none";
    }
    // Written by Huu Khang
    function Bamboo_PostBack(url,row,frm,obj)
	{
		document.forms[frm].action=url;
		document.getElementById(obj).value=row;
		document.forms[frm].submit();
	}
     function SetFocusRadio(idRadioDDL,idRdioTXT,isRadioDDLChecked)
	{
		objRDDL= document.getElementById(idRadioDDL);
		objRTXT= document.getElementById(idRdioTXT);
		if((objRDDL)&& (objRTXT))
		{
			objRDDL.checked=isRadioDDLChecked;
			objRTXT.checked=!isRadioDDLChecked;
		}
	}
	function SetFocusOneRadio(idRadio)
	{
		obj1RDDL= document.getElementById(idRadio);
		if(obj1RDDL)
		{
			obj1RDDL.checked=true;
		}
	}
    function DisplayElement( elmID )
    {
      if( isIE )
      {
        for( i = 0; i < document.all.tags( elmID ).length; i++ )
        {
          obj = document.all.tags( elmID )[i];
          
          if( !obj || !obj.offsetParent )
          {
            continue;
          }
          obj.style.visibility = "";
        }
      }
    }

	
	var iSundaysCount = 0
	var arrSundays = new Array()

	
	if (myDoc)
	{
		for	(i=0;i<arrSourceImage.length;i++)
		{
			arrImages[i] = new Image
			arrImages[i].src= arrImages + arrSourceImage[i]
		}
		/*
		document.write ("<div onclick='bInvisible=true' id='calendar'	class='div-style'><table width="+((bDisplayWeekNumber==1)?250:220)+" class='main-style'><tr class='"+ cssHeaderCalendar + "' ><td><table width='"+((bDisplayWeekNumber==1)?248:218)+"'><tr><td class='"+cssTitleCalendar+"'><B><span id='caption'></span></B></td><td align=right><a href='javascript:HideCalendar()'><IMG SRC='"+scrImageDir+"Bamboo_close.gif' WIDTH='15' HEIGHT='13' BORDER='0' ALT='Close the Calendar'></a></td></tr></table></td></tr><tr><td class='body-style'><span id='content'></span></td></tr>")
		if (bIsToday==1)
		{
			document.write ("<tr class='"+cssTodayStyle+"'><td><span id='lblToday'></span></td></tr>")
		}
		document.write ("</table></div><div id='selectMonth' class='div-style'></div><div id='selectYear' class='div-style'></div>");
	    */
	}

	var	monthName =	new	Array("January","February","March","April","May","June","July","August","September","October","November","December")
	if (iBeginAt==0)
	{
		dayName = new Array	("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
		arrDayFullNames=new Array	("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	}
	else
	{
		dayName = new Array	("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
		arrDayFullNames=new Array	("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
	}

	function splitImage(strSrcImage, strDesImage){
		if (isIE)	{ document.getElementById(strSrcImage).setAttribute("src",scrImageDir + strDesImage) }
	}

	function Initialize()	{

		if (!docLayers)
		{
			if (!isIE) { currentYear += 1900;	}
			objCalendar=(myDoc)?document.getElementById("calendar") : isIE? document.all.calendar : document.calendar;
			HideCalendar();

			globalMonthObj=(myDoc)?document.getElementById("selectMonth").style : isIE? document.all.selectMonth	: document.selectMonth;

			globalYearObj=(myDoc)?document.getElementById("selectYear").style : isIE? document.all.selectYear : document.selectYear;

			assignedMonthValue=false;
			assignedYearValue=false;

			if (bIsToday==1)
			{
				document.getElementById("lblToday").innerHTML =	strToday + " <a class='today-style' onmousemove='window.status=\""+strGuide+"\"' onmouseout='window.status=\"\"' title='"+strGuide+"' href='javascript:selectedValueMonth=currentMonth;selectedValueYear=currentYear;InitializeCalendar();'>"+arrDayFullNames[(dtNow.getDay()-iBeginAt==-1)?6:(dtNow.getDay()-iBeginAt)]+", " + currentDate + " " + monthName[currentMonth].substring(0,3)	+ "	" +	currentYear	+ "</a>";
			}

			sHTML1= "<span id='spanLeft'  class='title-control-normal-style' onmouseover='splitImage(\"changeLeft\",\"Bamboo_left2.gif\");this.className=\"title-control-select-style\";window.status=\""+strMonthLeftGuide+"\"' onclick='javascript:DescreaseMonth()' onmouseout='clearInterval(iChangeValueMonth);splitImage(\"changeLeft\",\"Bamboo_left1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onmousedown='clearTimeout(iResetValueMonth);iResetValueMonth=setTimeout(\"EventDecMonth()\",500)'	onmouseup='clearTimeout(iResetValueMonth);clearInterval(iChangeValueMonth)'>&nbsp<IMG id='changeLeft' SRC='"+scrImageDir+"Bamboo_left1.gif' width=10 height=11 BORDER=0>&nbsp</span>&nbsp;";
			sHTML1+="<span id='spanRight' class='title-control-normal-style' onmouseover='splitImage(\"changeRight\",\"Bamboo_right2.gif\");this.className=\"title-control-select-style\";window.status=\""+strMonthRightGuide+"\"' onmouseout='clearInterval(iChangeValueMonth);splitImage(\"changeRight\",\"Bamboo_right1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onclick='IncreaseMonth()' onmousedown='clearTimeout(iResetValueMonth);iResetValueMonth=setTimeout(\"EventIncMonth()\",500)'	onmouseup='clearTimeout(iResetValueMonth);clearInterval(iChangeValueMonth)'>&nbsp<IMG id='changeRight' SRC='"+scrImageDir+"Bamboo_right1.gif'	width=10 height=11 BORDER=0>&nbsp</span>&nbsp";
			sHTML1+="<span id='spanMonth' class='ms-vb2' onmouseover='splitImage(\"changeMonth\",\"Bamboo_drop2.gif\");this.className=\"ms-vb2\";window.status=\""+mgsChooseMonth+"\"' onmouseout='splitImage(\"changeMonth\",\"Bamboo_drop1.gif\");this.className=\"ms-vb2\";window.status=\"\"' onclick='ShowListMonth()'></span>&nbsp;";
			sHTML1+="<span id='spanYear'  class='ms-vb2' onmouseover='splitImage(\"changeYear\",\"Bamboo_drop2.gif\");this.className=\"ms-vb2\";window.status=\""+mgsChooseYear+"\"'	onmouseout='splitImage(\"changeYear\",\"Bamboo_drop1.gif\");this.className=\"ms-vb2\";window.status=\"\"'	onclick='DescreaseListYear()'></span>&nbsp;";
			
			document.getElementById("caption").innerHTML  =	sHTML1;

			isPostBack=true;
		}
	}

	function HideCalendar()	{
		if(objCalendar){
			objCalendar.style.visibility="hidden";
			if (globalMonthObj != null){globalMonthObj.visibility="hidden"}
			if (globalYearObj !=	null){globalYearObj.visibility="hidden"}

			DisplayElement( 'SELECT' );
			DisplayElement( 'APPLET' );
		}
	}
	

	function AddPrefixChar(num) {
		return (num	< 10)? '0' + num : num ;
	}

	function InitializeDate(d,m,y)
	{
		var	strTemp;
		strTemp = strFormatDate;
		strTemp = strTemp.replace("dd",AddPrefixChar(d));
		strTemp = strTemp.replace("mm",AddPrefixChar(m+1));
		strTemp = strTemp.replace("yyyy",y);
		return strTemp;
	}

	function ExitCalendar() {
		
		HideCalendar();
		desControl.value =	InitializeDate(selectedValueDate,selectedValueMonth,selectedValueYear)
	}

	/*** Month List	***/

	function EventDecMonth()
	{
		iChangeValueMonth=setInterval("DescreaseMonth()",50);
	}

	function EventIncMonth()
	{
		iChangeValueMonth=setInterval("IncreaseMonth()",50);
	}

	function IncreaseMonth () {
		selectedValueMonth++;
		if (selectedValueMonth>11) {
			selectedValueMonth=0;
			selectedValueYear++;
		}
		InitializeCalendar();
	}

	function DescreaseMonth () {
		selectedValueMonth--;
		if (selectedValueMonth<0) {
			selectedValueMonth=11;
			selectedValueYear--;
		}
		InitializeCalendar();
	}

	function InitializeMonth() {
		IncreaseListYear();
		if (!assignedMonthValue) {
			sHTML =	"";
			for	(i=0; i<12;	i++) {
				sName =	monthName[i];
				if (i==selectedValueMonth){
					sName =	"<B>" +	sName +	"</B>";
				}
				sHTML += "<tr><td id='m" + i + "' onmouseover='this.className=\"dropdown-select-style\"' onmouseout='this.className=\"dropdown-normal-style\"' onclick='assignedMonthValue=false;selectedValueMonth=" + i + ";InitializeCalendar();HideListMonth();event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>";
			}

			document.getElementById("selectMonth").innerHTML = "<table width=70	class='dropdown-style' cellspacing=0 onmouseover='clearTimeout(iResetValueMonth)'	onmouseout='clearTimeout(iResetValueMonth);iResetValueMonth=setTimeout(\"HideListMonth()\",100);event.cancelBubble=true'>" +	sHTML +	"</table>";

			assignedMonthValue=true;
		}
	}

	function ShowListMonth() {
		InitializeMonth();
		globalMonthObj.visibility = (myDoc||isIE)? "visible"	: "show";
		globalMonthObj.left = parseInt(objCalendar.style.left) + 50;
		globalMonthObj.top =	parseInt(objCalendar.style.top) + 26;
	}

	function HideListMonth()	{
		globalMonthObj.visibility= "hidden";
	}

	/*** Year Pulldown ***/

	function IncreaseYear() {
		for	(i=0; i<7; i++){
			newYear	= (i+iBeginYear)+1;
			if (newYear==selectedValueYear)
			{ txtYear =	"&nbsp;<B>"	+ newYear +	"</B>&nbsp;" }
			else
			{ txtYear =	"&nbsp;" + newYear + "&nbsp;" }
			document.getElementById("y"+i).innerHTML = txtYear;
		}
		iBeginYear ++;
		bInvisible=true;
	}

	function DescreaseYear() {
		for	(i=0; i<7; i++){
			newYear	= (i+iBeginYear)-1;
			if (newYear==selectedValueYear)
			{ txtYear =	"&nbsp;<B>"	+ newYear +	"</B>&nbsp;" ;}
			else
			{ txtYear =	"&nbsp;" + newYear + "&nbsp;" }
			document.getElementById("y"+i).innerHTML = txtYear;
		}
		iBeginYear --;
		bInvisible=true;
	}

	function ChooseYear(nYear) {
		selectedValueYear=parseInt(nYear+iBeginYear);
		assignedYearValue=false;
		InitializeCalendar();
		IncreaseListYear();
	}

	function InitializeYear() {
		HideListMonth();
		sHTML =	"";
		if (!assignedYearValue) {

			sHTML =	"<tr><td align='center'	onmouseover='this.className=\"dropdown-select-style\"' onmouseout='clearInterval(iChangeValueMonth);this.className=\"dropdown-normal-style\"' onmousedown='clearInterval(iChangeValueMonth);iChangeValueMonth=setInterval(\"DescreaseYear()\",30)' onmouseup='clearInterval(iChangeValueMonth)'>-</td></tr>";
			j =	0;
			iBeginYear =	selectedValueYear-3;
			for	(i=(selectedValueYear-3); i<=(selectedValueYear+3); i++) {
				sName =	i;
				if (i==selectedValueYear){
					sName =	"<B>" +	sName +	"</B>";
				}

				sHTML += "<tr><td id='y" + j + "' onmouseover='this.className=\"dropdown-select-style\"' onmouseout='this.className=\"dropdown-normal-style\"' onclick='ChooseYear("+j+");event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>";
				j ++;
			}

			sHTML += "<tr><td align='center' onmouseover='this.className=\"dropdown-select-style\"' onmouseout='clearInterval(iChangeValueYear);this.className=\"dropdown-normal-style\"' onmousedown='clearInterval(iChangeValueYear);iChangeValueYear=setInterval(\"IncreaseYear()\",30)'	onmouseup='clearInterval(iChangeValueYear)'>+</td></tr>";

			document.getElementById("selectYear").innerHTML	= "<table width=44 class='dropdown-style' onmouseover='clearTimeout(iResetValueYear)' onmouseout='clearTimeout(iResetValueYear);iResetValueYear=setTimeout(\"IncreaseListYear()\",100)' cellspacing=0>"	+ sHTML	+ "</table>";

			assignedYearValue	= true;
		}
	}

	function IncreaseListYear() {
		clearInterval(iChangeValueMonth);
		clearTimeout(iResetValueMonth);
		clearInterval(iChangeValueYear);
		clearTimeout(iResetValueYear);
		globalYearObj.visibility= "hidden";
	}

	function DescreaseListYear() {
		var	leftOffset;

		InitializeYear();
		globalYearObj.visibility	= (myDoc||isIE)? "visible" : "show";
		leftOffset = parseInt(objCalendar.style.left) + document.getElementById("spanYear").offsetLeft;
		if (isIE)
		{
			leftOffset += 6;
		}
		globalYearObj.left =	leftOffset;
		globalYearObj.top = parseInt(objCalendar.style.top) +	26;
	}

	/*** calendar ***/

	function GetWeekNumberOfMonth(dtNow)
    {
		Year = GetYear(dtNow);
		Month = dtNow.getMonth();
		Day = dtNow.getDate();
		now = Date.UTC(Year,Month,Day+1,0,0,0);
		var Firstday = new Date();
		Firstday.setYear(Year);
		Firstday.setMonth(0);
		Firstday.setDate(1);
		then = Date.UTC(Year,0,1,0,0,0);
		var Compensation = Firstday.getDay();
		if (Compensation > 3) Compensation -= 4;
		else Compensation += 3;
		NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
		return NumberOfWeek;
	}

	function GetYear(theDate)
	{
		x = theDate.getYear();
		var y = x % 100;
		y += (y < 38) ? 2000 : 1900;
		return y;
	}

	function InitializeCalendar () {
		var strMsgDate;
		var	dtBeginDate =	new	Date (selectedValueYear,selectedValueMonth,1);
		var	dtEndDate	= new Date (selectedValueYear,selectedValueMonth+1,1);
		dtEndDate	= new Date (dtEndDate	- (24*60*60*1000));
		iNumDatesInMonth = dtEndDate.getDate();

		iIndexDate	= 0;
		iDayPointer = dtBeginDate.getDay() - iBeginAt;
		
		if (iDayPointer<0)
		{
			iDayPointer = 6;
		}

		sHTML =	"<table	border=0 class='"+cssBgCalendar+"'><tr>";

		if (bDisplayWeekNumber==1)
		{
			sHTML += "<td width=27 class='"+cssWeekDateName+"' ><b>" + strWeek + "</b></td><td width=1 rowspan=7 class='weeknumber-div-style'><img src='"+scrImageDir+"divider.gif' width=1></td>";
		}

		for	(i=0; i<7; i++)	{
			sHTML += "<td width='27' align='right' class='"+cssWeekDateName+"' ><B>"+ dayName[i]+"</B></td>";
		}
		sHTML +="</tr><tr>";
		
		if (bDisplayWeekNumber==1)
		{
			sHTML += "<td align=right>" + GetWeekNumberOfMonth(dtBeginDate) + "&nbsp;</td>";
		}

		for	( var i=1; i<=iDayPointer;i++ )
		{
			sHTML += "<td>&nbsp;</td>";
		}
	
		for	( iIndexDate=1; iIndexDate<=iNumDatesInMonth; iIndexDate++ )
		{
			iDayPointer++;
			sHTML += "<td align=right>";

			var sStyle="normal-day-style"; 

			if ((iIndexDate==currentDate)&&(selectedValueMonth==currentMonth)&&(selectedValueYear==currentYear)) //dtNow
			{ sStyle = "current-day-style"; } 
			else if	(iDayPointer % 7 == (iBeginAt * -1) +1)
			{ sStyle = "end-of-weekday-style"; }

			
			if ((iIndexDate==objSelectedDate) &&	(selectedValueMonth==objSelectedMonth)	&& (selectedValueYear==objSelectedYear))
			{ sStyle += " selected-day-style"; }

			sHint = "";
			for (k=0;k<iSundaysCount;k++)
			{
				if ((parseInt(arrSundays[k].d)==iIndexDate)&&(parseInt(arrSundays[k].m)==(selectedValueMonth+1)))
				{
					if ((parseInt(arrSundays[k].y)==0)||((parseInt(arrSundays[k].y)==selectedValueYear)&&(parseInt(arrSundays[k].y)!=0)))
					{
						sStyle += " holiday-style";
						sHint+=sHint==""?arrSundays[k].desc:"\n"+arrSundays[k].desc;
					}
				}
			}

			var regexp= /\"/g;
			sHint=sHint.replace(regexp,"&quot;");

			strMsgDate = "onmousemove='window.status=\""+mgsChooseDay.replace("[date]",InitializeDate(iIndexDate,selectedValueMonth,selectedValueYear))+"\"' onmouseout='window.status=\"\"' ";

			sHTML += "<a class='"+sStyle+"' "+strMsgDate+" title=\"" + sHint + "\" href='javascript:selectedValueDate="+iIndexDate+";ExitCalendar();'>&nbsp;" + iIndexDate + "&nbsp;</a>";

			sHTML += "";
			if ((iDayPointer+iBeginAt) % 7 == iBeginAt) { 
				sHTML += "</tr><tr>" 
				if ((bDisplayWeekNumber==1)&&(iIndexDate<iNumDatesInMonth))
				{
					sHTML += "<td align=right class='"+cssWeekDateName+"'>" + (GetWeekNumberOfMonth(new Date(selectedValueYear,selectedValueMonth,iIndexDate+1))) + "&nbsp;</td>";
				}
			}
		}

		document.getElementById("content").innerHTML   = sHTML
		document.getElementById("spanMonth").innerHTML = "&nbsp;" +	monthName[selectedValueMonth] + "&nbsp;<IMG id='changeMonth' SRC='"+scrImageDir+"Bamboo_drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
		document.getElementById("spanYear").innerHTML =	"&nbsp;" + selectedValueYear	+ "&nbsp;<IMG id='changeYear' SRC='"+scrImageDir+"Bamboo_drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
	}
	
	
	function ShowCalendar(ctl,	ctl2, format, callbackFunction) {

		var	iLPosition=0;
		var	iTPosition=0;
		objCallBackFunction = callbackFunction;
		if (isPostBack)
		{
			if ( objCalendar.style.visibility ==	"hidden" ) {
				desControl	= ctl2;
				strFormatDate=format;

				chrCharFormat = " ";
				aFormat	= strFormatDate.split(chrCharFormat)
				if (aFormat.length<3)
				{
					chrCharFormat = "/";
					aFormat	= strFormatDate.split(chrCharFormat)
					if (aFormat.length<3)
					{
						chrCharFormat = ".";
						aFormat	= strFormatDate.split(chrCharFormat)
						if (aFormat.length<3)
						{
							chrCharFormat = "-";
							aFormat	= strFormatDate.split(chrCharFormat)
							if (aFormat.length<3)
							{
								
								chrCharFormat="";
							}
						}
					}
				}

				iAssignedChanged =	0;
				if ( chrCharFormat	!= "" )
				{
					// use user's date
					aData =	ctl2.value.split(chrCharFormat);

					for	(i=0;i<3;i++)
					{
						if ((aFormat[i]=="d") || (aFormat[i]=="dd"))
						{
							selectedValueDate = parseInt(aData[i], 10);
							iAssignedChanged ++;
						}
						else if	((aFormat[i]=="m") || (aFormat[i]=="mm"))
						{
							selectedValueMonth =	parseInt(aData[i], 10) - 1;
							iAssignedChanged ++;
						}
						else if	(aFormat[i]=="yyyy")
						{
							selectedValueYear = parseInt(aData[i], 10);
							iAssignedChanged ++;
						}
						else if	(aFormat[i]=="mmm")
						{
							for	(j=0; j<12;	j++)
							{
								if (aData[i]==monthName[j])
								{
									selectedValueMonth=j;
									iAssignedChanged ++;
								}
							}
						}
					}
				}

				if ((iAssignedChanged!=3)||isNaN(selectedValueDate)||isNaN(selectedValueMonth)||isNaN(selectedValueYear))
				{
					selectedValueDate = currentDate;
					selectedValueMonth =	currentMonth;
					selectedValueYear = currentYear;
				}

				objSelectedDate=selectedValueDate;
				objSelectedMonth=selectedValueMonth;
				objSelectedYear=selectedValueYear;

				aTag = ctl;
				do {
					aTag = aTag.offsetParent;
					iLPosition	+= aTag.offsetLeft;
					iTPosition += aTag.offsetTop;
				} while(aTag.tagName!="BODY");

				objCalendar.style.left = displayX==-1 ? ctl.offsetLeft	+ iLPosition+moveToX :	displayX;
				objCalendar.style.top = displayY==-1 ?	ctl.offsetTop +	iTPosition + ctl.offsetHeight+moveToY :	displayY;
				InitializeCalendar (1, selectedValueMonth, selectedValueYear);
				objCalendar.style.visibility=(myDoc||isIE)? "visible" : "show";
				
				InvisibleElement( 'SELECT', document.getElementById("calendar") );
				InvisibleElement( 'APPLET', document.getElementById("calendar") );		
				
			/*	var TopObject= parseInt(objCalendar.style.top) + parseInt(objCalendar.offsetHeight);
				var MainTopTotal= parseInt(window.document.body.scrollTop) +window.document.body.clientHeight;			
				if(TopObject>MainTopTotal)
				{
					if(isIE)
					objCalendar.style.top= TopObject - 350 ;
					else
					objCalendar.style.top= TopObject - 368 ;
					
				}
				else
				{
					if(!isIE)
					{
						objCalendar.style.top =parseInt(objCalendar.style.top)+ 5;
					}
				}
								
				
				if(parseInt(objCalendar.style.left)<parseInt(window.document.body.scrollLeft))
				{
					objCalendar.style.left=parseInt(window.document.body.scrollLeft) + 5;
				}	   */
					

				bInvisible = true;
			}
		}
		else
		{
			Initialize();
			ShowCalendar(ctl,	ctl2, format, callbackFunction)
		}
	}
	
	document.onclick = function HideAll () { 		
		if (!bInvisible)
		{
			HideCalendar();
		}
		bInvisible = false
	}
	
	
	function OnItem_Bamboo(elm)
	{
			if (!browseris.ie5up || !browseris.win32)
				return false;
			if (IsMenuOn())
			{
				StartDeferItem(elm);
				return false;
			}
			if (itemTable != null)
				OutItem();
			itemTable = elm;
			currentItemID = itemTable.ItemId;
			var createCtx = new Function("setupMenuContext(" + itemTable.CTXName + ");");
			itemTable.className="ms-selectedtitle";
			if (browseris.ie55up)
			{
				itemTable.onclick = CreateMenu;
			}
			else 
			{ 
				itemTable.onclick = EditMenuDefaultForOnclick;
			}
			titleRow = itemTable.children[0].children[0];
			i = 0;
			while (titleRow.children[i] != null)
				imageCell = titleRow.children[i++];
			downArrowText = L_Edit_Text;
			imageCell.children[0].src = "/_layouts/images/" + "downarrw.gif";
			imageCell.children[0].alt = downArrowText;
			imageCell.children[0].style.visibility = "visible";
			imageCell.style.visibility="visible";
			imageCell.className="ms-menuimagecell";
		return true;
	}
	
	function OutItem_Bamboo(elm)
	{
		itemTable = elm;
		if (!IsMenuOn() && itemTable != null)
		{
			itemTable.className="ms-unselectedtitle";
			if (imageCell != null)
			{
				imageCell.children[0].style.visibility="hidden";
				imageCell.style.visibility="hidden";
				imageCell.bgColor="";
			}
			resetExecutionState();
		}
	}
	
	function Bamboo_DeleteItem(DeleteURL,frm)
	{
		var L_Delete_text="Are you sure you want to delete this item?";
		if (confirm(L_Delete_text))
		{
			document.forms[frm].action=DeleteURL;
			document.forms[frm].submit();
		}
	}
	
	//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)
  {}
  
}
/* KB TreeView */
function CheckEmailAddress(textBoxID) 
{
	var email = document.getElementById(textBoxID);
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (!filter.test(email.value)) 
	{
		alert('Please provide a valid email address');
		email.focus;
		return false;
	}
}
function DisplayErrors(functionName, errorMessage)
{
   //alert(functionName + " Error:: " + errorMessage);
}
function IsBlank(val)
{
	if(val==null)
	{
		return true;
	}
	for(var i=0;i<val.length;i++)
	{
		if((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
		{
			return false;
		}
	}
	return true;
}
function StartWithZero(val)
{
	if (val.charAt(0) == '0')
	{
		if (IsValidInteger(val) > 0)
			return false;
		else
			return true;
	}
	else
		return false;
}
function IsValidInteger(val)
{
	var remain = val;
	for(var i = 0; i < val.length; i++)
	{
		if (val.charAt(i) == '0')
		{
			remain = val.substring(i+1, val.length);
			IsValidInteger(remain);
		}
		else
		{
			remain = val.substring(i, val.length);
			break;
		}
	}
	return remain;
}
function IsInteger(val)
{
	if (StartWithZero(val))
	{
		return false;
	}
	for(var i = 0; i < val.length; i++)
	{
		if(!IsDigit(val.charAt(i)))
		{
			return false;
		}
	}
	return true;
}
function IsDigit(num)
{	
	if(num.length > 1)
	{
		return false;
	}
	var string = "1234567890";
	if(string.indexOf(num) != -1)
	{
		return true;
	}
	return false;
}
function CheckRecordsOnPage(validatorID)
{
	try
	{
		var num = document.getElementById(validatorID).value;		
		if (!IsInteger(num))
		{
			alert("Sorry, Please enter a numeric value!");
			document.getElementById(validatorID).focus();
			document.getElementById(validatorID).select();
		}
		if (IsBlank(num))
		{
			alert("Sorry, Please enter the number of records to display!");
			document.getElementById(validatorID).focus();
			document.getElementById(validatorID).select();
		}
	}
	catch(ex)
	{
	    DisplayErrors("CheckRecordsOnPage::", ex.message);
	}
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
function CheckPortOnPage(validatorID)
{
	try
	{	    	
		var num = document.getElementById(validatorID).value;
		if(num.trim().length>0)		
		{
		    if (!IsInteger(num.trim()))
		    {
			    alert("Sorry, Please enter a numeric value!");
			    document.getElementById(validatorID).focus();
			    document.getElementById(validatorID).select();
		    }		    
		}
	}
	catch(ex)
	{
	    DisplayErrors("CheckPortOnPage::", ex.message);
	    document.getElementById(validatorID).focus();
	}
}
