// Customizable variables
var DefaultDateFormat = 'MM/DD/YYYY'; // If no date format is supplied, this will be used instead
var HideWait = 2; // Number of seconds before the calendar will disappear
var Y2kPivotPoint = 76; // 2-digit years before this point will be created in the 21st century
var UnselectedMonthText = ''; // Text to display in the 1st month list item when the date isn't required
var FontSize = 11; // In pixels
var FontFamily = 'Tahoma';
var CellWidth = 18;
var CellHeight = 18;
var ImageURL = '/images/calenderIcon.png';
var NextURL = '/images/next.png';
var PrevURL = '/images/prev.png';
var BGImageURL= '/images/whitepixel.png';
var CalBGColor = 'white';
var TopRowBGColor = '#ECF1F9';
var DayBGColor = '#ECF1F9';
var DateName;
var tmpDT = new Date();
var curTime = getDblChar(tmpDT.getHours()) +  ":" + getDblChar(tmpDT.getMinutes()); // This variable will maintain the time picked in the clock
var globalDisTime = false; // This will maintain the status whether to display time or not
var selectedHour = getDblChar(tmpDT.getHours());   
var selectedMinute = getDblChar(tmpDT.getMinutes() - tmpDT.getMinutes()%5);
var currentDay;

// Global variables
var curDay;
var ObjName;
var ZCounter = 10;
var Today = new Date();
var WeekDays = new Array('S','M','T','W','T','F','S');
var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var MonthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var styleContent ="";

// Write out the stylesheet definition for the calendar
with (document) {
   styleContent ='<style>';
   styleContent+='td.calendarDateInput {letter-spacing:normal;line-height:normal;font-family:' + FontFamily + ',Sans-Serif;font-size:' + FontSize + 'px;}';
   styleContent+='select.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}';
   styleContent+='input.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}';
   styleContent+='</style>';
}

// Only allows certain keys to be used in the date field
function YearDigitsOnly(e) {
   var KeyCode = (e.keyCode) ? e.keyCode : e.which;
   return ((KeyCode == 8) // backspace
        || (KeyCode == 9) // tab
        || (KeyCode == 37) // left arrow
        || (KeyCode == 39) // right arrow
        || (KeyCode == 46) // delete
        || ((KeyCode > 47) && (KeyCode < 58)) // 0 - 9
   );
}

// Function to get the Hours and minutes with two characters
function getDblChar(val) {
   if(val.toString().length==1) {
      val = "0" + val;
      return val;
   }
   else return val;
}

// Gets the absolute pixel position of the supplied element
function GetTagPixels(StartTag, Direction) {
   var PixelAmt = (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop;
   while ((StartTag.tagName != 'BODY') && (StartTag.tagName != 'HTML')) {
      StartTag = StartTag.offsetParent;
      PixelAmt += (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop;
   }
   return PixelAmt;
}

// Is the specified select-list behind the calendar?
function BehindCal(SelectList, CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY) {
   var ListLeftX = GetTagPixels(SelectList, 'LEFT');
   var ListRightX = ListLeftX + SelectList.offsetWidth;
   var ListBottomY = ListTopY + SelectList.offsetHeight;
   return (((ListTopY < CalBottomY) && (ListBottomY > CalTopY)) && ((ListLeftX < CalRightX) && (ListRightX > CalLeftX)));
}

// For IE, hides any select-lists that are behind the calendar
function FixSelectLists(Over) {
   if (navigator.appName == 'Microsoft Internet Explorer') {
      var CalDiv = this.getCalendar();
      var CalLeftX = CalDiv.offsetLeft;
      var CalRightX = CalLeftX + CalDiv.offsetWidth;
      var CalTopY = CalDiv.offsetTop;
      var CalBottomY = CalTopY + (CellHeight * 9);
      var FoundCalInput = false;
      formLoop :
      for (var j=this.formNumber;j<document.forms.length;j++) {
      if(j != -1)
      {
         for (var i=0;i<document.forms[j].elements.length;i++) {
            if (document.forms[j].elements[i].type == 'string') {
               if ((document.forms[j].elements[i].type == 'hidden') && (document.forms[j].elements[i].name == this.hiddenFieldName)) {
                  FoundCalInput = true;
                  i += 3; // 3 elements between the 1st hidden field and the last year input field
               }
               if (FoundCalInput) {
                  if (document.forms[j].elements[i].type.substr(0,6) == 'select') {
                     ListTopY = GetTagPixels(document.forms[j].elements[i], 'TOP');
                     if (ListTopY < CalBottomY) {
                        if (BehindCal(document.forms[j].elements[i], CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY)) {
                          if(document.forms[j].elements[i].id == DateName + "_YearID")
									{
										document.forms[j].elements[i].style.visibility = (!Over) ? 'hidden' : 'visible';
									}
									if(!document.forms[j].elements[i].id == DateName + "_YearID")
									{
										document.forms[j].elements[i].style.visibility = (Over) ? 'hidden' : 'visible';
									}
                        }
                     }
                     else break formLoop;
                  }
               }
            }
         }
      }
    }
   }
}

// Displays a message in the status bar when hovering over the calendar days
function DayCellHover(Cell, Over, Color, HoveredDay) {
   Cell.style.backgroundColor = (Over) ? DayBGColor : Color;
   if (Over) {
      if ((this.yearValue == Today.getFullYear()) && (this.monthIndex == Today.getMonth()) && (HoveredDay == Today.getDate())) self.status = 'Click to select today';
      else {
         var Suffix = HoveredDay.toString();
         switch (Suffix.substr(Suffix.length - 1, 1)) {
            case '1' : Suffix += (HoveredDay == 11) ? 'th' : 'st'; break;
            case '2' : Suffix += (HoveredDay == 12) ? 'th' : 'nd'; break;
            case '3' : Suffix += (HoveredDay == 13) ? 'th' : 'rd'; break;
            default : Suffix += 'th'; break;
         }
         self.status = 'Click to select ' + this.monthName + ' ' + Suffix;
      }
   }
   else self.status = '';
   return true;
}

// Sets the form elements after a day has been picked from the calendar
function PickDisplayDay(ClickedDay) {
   this.show();
   var MonthList = this.getMonthList();
   var DayList = this.getDayList();
   var YearField = this.getYearField();
   FixDayList(DayList, GetDayCount(this.displayed.yearValue, this.displayed.monthIndex));
   // Select the month and day in the lists
   for (var i=0;i<MonthList.length;i++) {
      if (MonthList.options[i].value == this.displayed.monthIndex) MonthList.options[i].selected = true;
   }
   for (var j=1;j<=DayList.length;j++) {
      if (j == ClickedDay) DayList.options[j-1].selected = true;
   }
   this.setPicked(this.displayed.yearValue, this.displayed.monthIndex, ClickedDay);
   // Change the year, if necessary
   YearField.value = this.picked.yearPad;
   YearField.defaultValue = YearField.value;
}

// Builds the HTML for the calendar days
function BuildCalendarDays() {
var dayExceed=false;
   var Rows = 5;
   if (((this.displayed.dayCount == 31) && (this.displayed.firstDay > 4)) || ((this.displayed.dayCount == 30) && (this.displayed.firstDay == 6))) Rows = 6;
   else if ((this.displayed.dayCount == 28) && (this.displayed.firstDay == 0)) Rows = 4;
   var HTML = '<table width="' + (CellWidth * 7) + 'px" cellspacing="0" cellpadding="1" style="cursor:default;z-index:5000;">';
   for (var j=0;j<Rows;j++) {
      HTML += '<tr>';
      for (var i=1;i<=7;i++) {
         Day = (j * 7) + (i - this.displayed.firstDay);
         if ((Day >= 1) && (Day <= this.displayed.dayCount)) {
            if ((this.displayed.yearValue == this.picked.yearValue) && (this.displayed.monthIndex == this.picked.monthIndex) && (Day == this.picked.day)) {
               TextStyle = 'color:black;font-weight:bold;'
               currentDay=Day;
               BackColor = DayBGColor;
            }
            else {
               TextStyle = 'color:black;'
               BackColor = CalBGColor;
            }
            if ((this.displayed.yearValue == Today.getFullYear()) && (this.displayed.monthIndex == Today.getMonth()) && (Day == Today.getDate())) 
            {
					TextStyle += 'border:1px solid #a7c7e7;padding:0px;';
				}
				if((this.displayed.yearValue == Today.getFullYear()) && (this.displayed.monthIndex == Today.getMonth()) && (parseInt(Day - 1) == Today.getDate()))
				{
					dayExceed=true;
				}
				if(!dayExceed)
				{
					HTML += '<td align="center" class="calendarDateInput" style="cursor:default;height:' + CellHeight + 'px;width:' + CellWidth + 'px;' + TextStyle + ';background-color:' + BackColor + '" onClick="' + this.objName + '.pickDay(' + Day + ');' + this.objName + '.followUP();" onMouseOver="return ' + this.objName + '.displayed.dayHover(this,true,\'' + BackColor + '\',' + Day + ')" onMouseOut="return ' + this.objName + '.displayed.dayHover(this,false,\'white\')">' + Day + '</td>';
				}
				else
				{
					HTML += '<td align="center" class="calendarDateInput" style="cursor:default;height:' + CellHeight + 'px;width:' + CellWidth + 'px;' + TextStyle + ';background-color:#A5A5A5">' + Day + '</td>';
				}
         }
         else HTML += '<td class="calendarDateInput" style="height:' + CellHeight + 'px">&nbsp;</td>';
      }
      HTML += '</tr>';
   }
   return HTML += '</table>';
}

// It will record the change in the time select box
function Time_Change(val)
{
   if(this.globalDisTime)
   {
	  if (val=="get")
	  {
		 selectedHour = document.getElementById("Hour_ID").options[document.getElementById("Hour_ID").selectedIndex].value;   
		 selectedMinute = document.getElementById("Minute_ID").options[document.getElementById("Minute_ID").selectedIndex].value;
	  }
	  else	if (val=="set") // To set the time
	  {
		 document.getElementById("Hour_ID").value = selectedHour ;   
   		 document.getElementById("Minute_ID").value = selectedMinute;
	  }
	  curTime = selectedHour + ":" + selectedMinute;
   }
}

// Determines which century to use (20th or 21st) when dealing with 2-digit years
function GetGoodYear(YearDigits) {
   if (YearDigits.length == 4) return YearDigits;
   else {
      var Millennium = (YearDigits < Y2kPivotPoint) ? 2000 : 1900;
      return Millennium + parseInt(YearDigits,10);
   }
}

// Returns the number of days in a month (handles leap-years)
function GetDayCount(SomeYear, SomeMonth) {
   return ((SomeMonth == 1) && ((SomeYear % 400 == 0) || ((SomeYear % 4 == 0) && (SomeYear % 100 != 0)))) ? 29 : MonthDays[SomeMonth];
}

// Highlights the buttons
function VirtualButton(Cell, ButtonDown) {
   if (ButtonDown) {
      Cell.style.borderLeft = 'buttonshadow 1px solid';
      Cell.style.borderTop = 'buttonshadow 1px solid';
      Cell.style.borderBottom = 'buttonhighlight 1px solid';
      Cell.style.borderRight = 'buttonhighlight 1px solid';
   }
   else {
      Cell.style.borderLeft = 'buttonhighlight 1px solid';
      Cell.style.borderTop = 'buttonhighlight 1px solid';
      Cell.style.borderBottom = 'buttonshadow 1px solid';
      Cell.style.borderRight = 'buttonshadow 1px solid';
   }
}

// Mouse-over for the previous/next month buttons
function NeighborHover(Cell, Over, DateObj) {
   if (Over) {
      VirtualButton(Cell, false);
      self.status = 'Click to view ' + DateObj.fullName;
   }
   else {
      Cell.style.border = 'buttonface 1px solid';
      self.status = '';
   }
   return true;
}

// Adds/removes days from the day list, depending on the month/year
function FixDayList(DayList, NewDays) {
   var DayPick = DayList.selectedIndex + 1;
   if (NewDays != DayList.length) {
      var OldSize = DayList.length;
      for (var k=Math.min(NewDays,OldSize);k<Math.max(NewDays,OldSize);k++) {
         (k >= NewDays) ? DayList.options[NewDays] = null : DayList.options[k] = new Option(k+1, k+1);
      }
      DayPick = Math.min(DayPick, NewDays);
      DayList.options[DayPick-1].selected = true;
   }
   return DayPick;
}

// Resets the year to its previous valid value when something invalid is entered
function FixYearInput(YearField) {
   var YearRE = new RegExp('\\d{' + YearField.value.length + '}');
   if (!YearRE.test(YearField.selectedvalue)) YearField.value = YearField.value;
}

// Displays a message in the status bar when hovering over the calendar icon
function CalIconHover(Over) {
   var Message = (this.isShowing()) ? 'hide' : 'show';
   self.status = (Over) ? 'Click to ' + Message + ' the calendar' : '';
   return true;
}

// Starts the timer over from scratch
function CalTimerReset() {
   eval('clearTimeout(' + this.timerID + ')');
   eval(this.timerID + '=setTimeout(\'' + this.objName + '.show()\',' + (HideWait * 1000) + ')');
}

// The timer for the calendar
function DoTimer(CancelTimer) {
   if (CancelTimer) eval('clearTimeout(' + this.timerID + ')');
   else {
      eval(this.timerID + '=null');
      this.resetTimer();
   }
}

// Show or hide the calendar
function ShowCalendar() {
   if (this.isShowing()) {
	  
      var StopTimer = true;      
      var frameId=document.getElementById(this.hiddenFieldName + "_IFrame");
      frameId.style.visibility='hidden'; 
      //var position= getPosition(farmeLeft.id);    
      this.getCalendar().style.zIndex = --ZCounter;
      this.getCalendar().style.visibility = 'hidden';
      this.fixSelects(false);
   }
   else {
      var StopTimer = false;
      this.fixSelects(true);      
      this.getCalendar().style.zIndex = ++ZCounter;    
      var browsType=window.navigator.userAgent;
      document.getElementById(this.hiddenFieldName + "_IFrame").style.zIndex=0;  
      var frameId=document.getElementById(this.hiddenFieldName + "_IFrame");      
      if(browsType.indexOf("MSIE 6.0")>=0) {
		frameId.style.visibility='visible'; 
		var farmeLeft=document.getElementById(this.hiddenFieldName + "_ID").offsetLeft;
        var farmeTop=document.getElementById(this.hiddenFieldName + "_ID").offsetTop;
        frameId.style.left=farmeLeft;
        frameId.style.top=farmeTop;
      }      
      this.getCalendar().style.visibility = 'visible';
   }
   this.handleTimer(StopTimer);
   self.status = '';
}

// Hides the input elements when the "blank" month is selected
function SetElementStatus(Hide) {
   this.getDayList().style.visibility = (Hide) ? 'hidden' : 'visible';
   this.getYearField().style.visibility = (Hide) ? 'hidden' : 'visible';
   this.getCalendarLink().style.visibility = (Hide) ? 'hidden' : 'visible';
}

// Sets the date, based on the month selected
function CheckMonthChange(MonthList) {
   var DayList = this.getDayList();
   if (MonthList.options[MonthList.selectedIndex].value == '') {
      DayList.selectedIndex = 0;
      this.hideElements(true);
      this.setHidden('');
   }
   else {
      this.hideElements(false);
      if (this.isShowing()) {
         this.resetTimer(); // Gives the user more time to view the calendar with the newly-selected month
         this.getCalendar().style.zIndex = ++ZCounter; // Make sure this calendar is on top of any other calendars
      }
      var DayPick = FixDayList(DayList, GetDayCount(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value));
      this.setPicked(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value, DayPick);
   }
}

// Sets the date, based on the day selected
function CheckDayChange(DayList) {
   if (this.isShowing()) this.show();
   this.setPicked(this.picked.yearValue, this.picked.monthIndex, DayList.selectedIndex+1);
}

// Changes the date when a valid year has been entered
function CheckYearInput(YearField) {
   if ( (YearField.defaultValue != YearField.value)) {
      if (this.isShowing()) {
         this.resetTimer(); // Gives the user more time to view the calendar with the newly-entered year
         this.getCalendar().style.zIndex = ++ZCounter; // Make sure this calendar is on top of any other calendars
      }
      var NewYear = GetGoodYear(YearField.value);
      var MonthList = this.getMonthList();
      var NewDay = FixDayList(this.getDayList(), GetDayCount(NewYear, this.picked.monthIndex));
      this.setPicked(NewYear, this.picked.monthIndex, NewDay);
   }
}

// Holds characteristics about a date
function dateObject() {
   if (Function.call) { // Used when 'call' method of the Function object is supported
      var ParentObject = this;
      var ArgumentStart = 0;
   }
   else { // Used with 'call' method of the Function object is NOT supported
      var ParentObject = arguments[0];
      var ArgumentStart = 1;
   }
   ParentObject.date = (arguments.length == (ArgumentStart+1)) ? new Date(arguments[ArgumentStart+0]) : new Date(arguments[ArgumentStart+0], arguments[ArgumentStart+1], arguments[ArgumentStart+2]);
	ParentObject.yearValue = ParentObject.date.getFullYear();
   ParentObject.monthIndex = ParentObject.date.getMonth();
   ParentObject.monthName = MonthNames[ParentObject.monthIndex];
   ParentObject.fullName = ParentObject.monthName + ' ' + ParentObject.yearValue;
   ParentObject.day = ParentObject.date.getDate();
   ParentObject.dayCount = GetDayCount(ParentObject.yearValue, ParentObject.monthIndex);
   var FirstDate = new Date(ParentObject.yearValue, ParentObject.monthIndex, 1);
   ParentObject.firstDay = FirstDate.getDay();
}

// Keeps track of the date that goes into the hidden field
function storedMonthObject(DateFormat, DateYear, DateMonth, DateDay) {
   (Function.call) ? dateObject.call(this, DateYear, DateMonth, DateDay) : dateObject(this, DateYear, DateMonth, DateDay);
   this.yearPad = this.yearValue.toString();
   this.monthPad = (this.monthIndex < 9) ? '0' + String(this.monthIndex + 1) : this.monthIndex + 1;
   this.dayPad = (this.day < 10) ? '0' + this.day.toString() : this.day;
   this.monthShort = this.monthName.substr(0,3).toUpperCase();
   // Formats the year with 2 digits instead of 4
   if (DateFormat.indexOf('YYYY') == -1) this.yearPad = this.yearPad.substr(2);
   // Define the date-part delimiter
   if (DateFormat.indexOf('/') >= 0) var Delimiter = '/';
   else if (DateFormat.indexOf('-') >= 0) var Delimiter = '-';
   else var Delimiter = '';
   // Determine the order of the months and days
   if (/DD?.?((MON)|(MM?M?))/.test(DateFormat)) {
      this.formatted = this.dayPad + Delimiter;
      this.formatted += (RegExp.$1.length == 3) ? this.monthShort : this.monthPad;
   }
   else if (/((MON)|(MM?M?))?.?DD?/.test(DateFormat)) {
      this.formatted = (RegExp.$1.length == 3) ? this.monthShort : this.monthPad;
      this.formatted += Delimiter + this.dayPad;
   }
   // Either prepend or append the year to the formatted date
   this.formatted = (DateFormat.substr(0,2) == 'YY') ? this.yearPad + Delimiter + this.formatted : this.formatted + Delimiter + this.yearPad;
}

// Object for the current displayed month
function displayMonthObject(ParentObject, DateYear, DateMonth, DateDay) {
   (Function.call) ? dateObject.call(this, DateYear, DateMonth, DateDay) : dateObject(this, DateYear, DateMonth, DateDay);
   this.displayID = ParentObject.hiddenFieldName + '_Current_ID';
   this.getDisplay = new Function('return document.getElementById(this.displayID)');
   this.dayHover = DayCellHover;
   this.goCurrent = new Function(ParentObject.objName + '.getCalendar().style.zIndex=++ZCounter;' + ParentObject.objName + '.setDisplayed(Today.getFullYear(),Today.getMonth());');
   if (ParentObject.formNumber >= 0) this.getDisplay().innerHTML = this.fullName.substring(0,this.fullName.length-4);
}

// Object for the previous/next buttons
function neighborMonthObject(ParentObject, IDText, DateMS) {
     (Function.call) ? dateObject.call(this, DateMS) : dateObject(this, DateMS);
   this.buttonID = ParentObject.hiddenFieldName + '_' + IDText + '_ID';
   this.hover = new Function('C','O','NeighborHover(C,O,this)');
   this.getButton = new Function('return document.getElementById(this.buttonID)');
   this.go = new Function(ParentObject.objName + '.getCalendar().style.zIndex=++ZCounter;' + ParentObject.objName + '.setDisplayed(this.yearValue,this.monthIndex);');
   if (ParentObject.formNumber >= 0) this.getButton().title = this.monthName;
   
}

// Sets the currently-displayed month object
function SetDisplayedMonth(DispYear, DispMonth) {

		var TodayDate=new Date();
		var diffDays=days_between(TodayDate,new Date(parseInt(DispYear),parseInt(DispMonth),parseInt(curDay)));
		
		
		ChangeYear(DispYear,this.hiddenFieldName);
					
		this.displayed = new displayMonthObject(this, DispYear, DispMonth, 1);
		if(parseInt(diffDays) >= 0 && parseInt(diffDays) < 14667)
		{
			this.previous = new neighborMonthObject(this, 'Previous', this.displayed.date.getTime() - 86400000);
			this.next = new neighborMonthObject(this, 'Next', this.displayed.date.getTime() + (86400000 * (this.displayed.dayCount + 1)));
			this.picked.monthIndex = DispMonth;
		}
		else
		{
			this.displayed = new displayMonthObject(this, TodayDate.getFullYear(),TodayDate.getMonth(),TodayDate.getDay());
			ChangeYear(TodayDate.getFullYear());
			//this.previous = new neighborMonthObject(this, 'Previous', this.displayed.date.getTime() - 86400000);
			//this.next = new neighborMonthObject(this, 'Next', this.displayed.date.getTime() + (86400000 * (this.displayed.dayCount + 1)));
			this.picked.monthIndex = TodayDate.getMonth();
		}
		
		
		//if (this.formNumber >= 0) 
		if(this.getDayTable() != null)
		{
			 this.getDayTable().innerHTML="";
			 this.getDayTable().innerHTML = this.buildCalendar();
			 this.getMonthDisplay().innerHTML =  MonthNames[parseInt(this.picked.monthIndex)];
		}
}

// Sets the current selected date
function SetPickedMonth(PickedYear, PickedMonth, PickedDay) {
	
	//Loading Values for further.
	curDay=PickedDay;		
		
	this.picked = new storedMonthObject(this.format, PickedYear, PickedMonth, PickedDay);
	this.setHidden(this.picked.formatted);
	if(document.getElementById(ObjName+"_YearID"))
	{
		document.getElementById(ObjName+"_YearID").value=PickedYear;
	}
  var ele=document.getElementById(this.displayName);

/////////////////////////////////////// Display Date here //////////////////////////////////////////////////////

   if(ele!=null)
   { 
	   if(ele.tagName=='INPUT')
	   {
			document.getElementById(this.displayName).value=this.picked.formatted;
	   }
	   else
	   {
		   var TimeShow = (globalDisTime && this.displayName == "TZCSpanDate")? (" " + curTime):"";		 		   
		   if(this.displayName == "TZCSpanDate") 
		   {
			   var str = String(this.picked.formatted);
		 	   var dandt = new Date(str.substring(7,11),getMonthNum(str.substring(3,6))-1,str.substring(0,2));
			   document.getElementById(this.displayName).innerHTML=dandt.toDateString() + TimeShow;
			   cntPkdTime("Picked");
		   }
		   else
		   {
			   document.getElementById(this.displayName).innerHTML=this.picked.formatted + TimeShow;
			   if(this.displayName == "CalcDateL" || this.displayName == "ExDate1L" || this.displayName == "ExDate2L") CalculatorAjax();
		   }			 
	   }
	}
   this.setDisplayed(PickedYear, PickedMonth);
}

// The calendar object
function calendarObject(DateName, DateFormat, DefaultDate,DisplayName) {

   /* Properties */
   this.displayName=DisplayName;
   this.hiddenFieldName = DateName;
   ObjName = DateName;
   this.monthListID = DateName + '_Month_ID';
   this.dayListID = DateName + '_Day_ID';
   this.yearFieldID = DateName + '_Year_ID';
   this.monthDisplayID = DateName + '_Current_ID';
   this.calendarID = DateName + '_ID';
   this.dayTableID = DateName + '_DayTable_ID';
   this.calendarLinkID = this.calendarID + '_Link';
   this.timerID = this.calendarID + '_Timer';
   this.objName = DateName + '_Object';
   this.format = DateFormat;
   this.formNumber = -1;
   this.picked = null;
   this.displayed = null;
   this.previous = null;
   this.next = null;

   /* Methods */
   this.setPicked = SetPickedMonth;
   this.setDisplayed = SetDisplayedMonth;
   this.checkYear = CheckYearInput;
   this.fixYear = FixYearInput;
   this.changeMonth = CheckMonthChange;
   this.changeDay = CheckDayChange;
   this.resetTimer = CalTimerReset;
   this.hideElements = SetElementStatus;
   this.show = ShowCalendar;
   this.handleTimer = DoTimer;
   this.iconHover = CalIconHover;
   this.buildCalendar = BuildCalendarDays;
   this.pickDay = PickDisplayDay;
   this.fixSelects = FixSelectLists;
   this.setHidden = new Function('D','if (this.formNumber >= 0) this.getHiddenField().value=D');
   // Returns a reference to these elements
   
   this.getHiddenField = new Function('return document.forms[this.formNumber].elements[this.hiddenFieldName]');
   this.getMonthList = new Function('return document.getElementById(this.monthListID)');
   this.getDayList = new Function('return document.getElementById(this.dayListID)');
   this.getYearField = new Function('return document.getElementById(this.yearFieldID)');
   this.getCalendar = new Function('return document.getElementById(this.calendarID)');
   this.getDayTable = new Function('return document.getElementById(this.dayTableID)');
   this.getCalendarLink = new Function('return document.getElementById(this.calendarLinkID)');
   this.getMonthDisplay = new Function('return document.getElementById(this.monthDisplayID)');
   this.isShowing = new Function('return !(this.getCalendar().style.visibility != \'visible\')');
   
   this.followUP = new Function(typeof followUpMethod != "undefined"?followUpMethod:'');
   
   /* Constructor */
   // Functions used only by the constructor
   function getMonthIndex(MonthAbbr) { // Returns the index (0-11) of the supplied month abbreviation
      for (var MonPos=0;MonPos<MonthNames.length;MonPos++) {
         if (MonthNames[MonPos].substr(0,3).toUpperCase() == MonthAbbr.toUpperCase()) break;
      }
      return MonPos;
   }
   function SetGoodDate(CalObj, Notify) { // Notifies the user about their bad default date, and sets the current system date
      CalObj.setPicked(Today.getFullYear(), Today.getMonth(), Today.getDate());
      if (Notify) 
      {
        //alert('WARNING: The supplied date is not in valid \'' + DateFormat + '\' format: ' + DefaultDate + '.\nTherefore, the current system date will be used instead: ' + CalObj.picked.formatted);
      }
   }
   // Main part of the constructor
   if (DefaultDate != '') {
      if ((this.format == 'YYYYMMDD') && (/^(\d{4})(\d{2})(\d{2})$/.test(DefaultDate))) this.setPicked(RegExp.$1, parseInt(RegExp.$2,10)-1, RegExp.$3);
      else {
         // Get the year
         if ((this.format.substr(0,2) == 'YY') && (/^(\d{2,4})(-|\/)/.test(DefaultDate))) { // Year is at the beginning
            var YearPart = GetGoodYear(RegExp.$1);
            // Determine the order of the months and days
            if (/(-|\/)(\w{1,3})(-|\/)(\w{1,3})$/.test(DefaultDate)) {
               var MidPart = RegExp.$2;
               var EndPart = RegExp.$4;
               if (/D$/.test(this.format)) { // Ends with days
                  var DayPart = EndPart;
                  var MonthPart = MidPart;
               }
               else {
                  var DayPart = MidPart;
                  var MonthPart = EndPart;
               }
               MonthPart = (/\d{1,2}/i.test(MonthPart)) ? parseInt(MonthPart,10)-1 : getMonthIndex(MonthPart);
               this.setPicked(YearPart, MonthPart, DayPart);
            }
            else SetGoodDate(this, true);
         }
         else if (/(-|\/)(\d{2,4})$/.test(DefaultDate)) { // Year is at the end
            var YearPart = GetGoodYear(RegExp.$2);
            // Determine the order of the months and days
            if (/^(\w{1,3})(-|\/)(\w{1,3})(-|\/)/.test(DefaultDate)) {
               if (this.format.substr(0,1) == 'D') { // Starts with days
                  var DayPart = RegExp.$1;
                  var MonthPart = RegExp.$3;
               }
               else { // Starts with months
                  var MonthPart = RegExp.$1;
                  var DayPart = RegExp.$3;
               }
               MonthPart = (/\d{1,2}/i.test(MonthPart)) ? parseInt(MonthPart,10)-1 : getMonthIndex(MonthPart);
               this.setPicked(YearPart, MonthPart, DayPart);
            }
            else SetGoodDate(this, true);
         }
         else SetGoodDate(this, true);
      }
   }
}

// Main function that creates the form elements
function DateInput(DateName, Required, DateFormat,DisplayName, DefaultDate,DisplayTime) {  
	if(DateName == '')
	{
		DateName="Valid"+DisplayName;
	}    
   if(DisplayTime)
   {  
	  
	  this.globalDisTime=DisplayTime;
   }
   else
   {
	  this.globalDisTime=false;
   }
   
   var DateContent="";
   
   if (arguments.length == 0) DateContent+=('<span style="color:red;font-size:' + FontSize + 'px;font-family:' + FontFamily + ';">ERROR: Missing required parameter in call to \'DateInput\': [name of hidden date field].</span>');
   else {
      // Handle DateFormat
      if (arguments.length < 3) { // The format wasn't passed in, so use default
         DateFormat = DefaultDateFormat;
         if (arguments.length < 2) Required = false;
      }
      else if (/^(Y{2,4}(-|\/)?)?((MON)|(MM?M?)|(DD?))(-|\/)?((MON)|(MM?M?)|(DD?))((-|\/)Y{2,4})?$/i.test(DateFormat)) DateFormat = DateFormat.toUpperCase();
      else { // Passed-in DateFormat was invalid, use default format instead
         var AlertMessage = 'WARNING: The supplied date format for the \'' + DateName + '\' field is not valid: ' + DateFormat + '\nTherefore, the default date format will be used instead: ' + DefaultDateFormat;
         DateFormat = DefaultDateFormat;
         if (arguments.length == 4) { // DefaultDate was passed in with an invalid date format
            var CurrentDate = new storedMonthObject(DateFormat, Today.getFullYear(), Today.getMonth(), Today.getDate());
            AlertMessage += '\n\nThe supplied date (' + DefaultDate + ') cannot be interpreted with the invalid format.\nTherefore, the current system date will be used instead: ' + CurrentDate.formatted;
            DefaultDate = CurrentDate.formatted;
         }
         alert(AlertMessage);
      }
      // Define the current date if it wasn't set already
      if (!CurrentDate) var CurrentDate = new storedMonthObject(DateFormat, Today.getFullYear(), Today.getMonth(), Today.getDay());
      // Handle DefaultDate
      if (arguments.length < 4) { // The date wasn't passed in
         DefaultDate = (Required) ? CurrentDate.formatted : ''; // If required, use today's date
      }
      // Creates the calendar object!
      eval(DateName + '_Object=new calendarObject(\'' + DateName + '\',\'' + DateFormat + '\',\'' + DefaultDate +'\',\'' + DisplayName + '\')');
      // Determine initial viewable state of day, year, and calendar icon
      if ((Required) || (arguments.length == 4)) {
         var InitialStatus = '';
         var InitialDate = eval(DateName + '_Object.picked.formatted');
      }
      else {
         var InitialStatus = ' style="visibility:hidden"';
         var InitialDate = '';
         eval(DateName + '_Object.setPicked(' + Today.getFullYear() + ',' + Today.getMonth() + ',' + Today.getDay() + ')');
      }
      
		if(DefaultDate == '' || DefaultDate == '01-Jan-001')
      {
			var ele=document.getElementById(DisplayName);
			eval(DateName + '_Object.setPicked(' + Today.getFullYear() + ',' + Today.getMonth() + ',' + Today.getDay() + ')');
			if(ele!=null)
			{ 
				if(ele.tagName=='INPUT')
				{
					ele.value='';
				}
				else
				{
					ele.innerHTML='';
				}
			}
		}
      // Create the form elements
      
      with (document) {
			DateContent+='<input type="hidden" name="' + DateName + '" value="' + InitialDate + '">';
			
			// Find this form number
         for (var f=0;f<forms.length;f++) {
            for (var e=0;e<forms[f].elements.length;e++) {
               if (typeof forms[f].elements[e].type == 'string') {
                  if ((forms[f].elements[e].type == 'hidden') && (forms[f].elements[e].name == DateName)) {
                     eval(DateName + '_Object.formNumber='+f);
                     break;
                  }
               }
            }
         }
        DateContent +=' <iframe id="' + DateName +'_IFrame"  src="" frameborder="0" scrolling="no" style="width:' + parseInt(parseInt(CellWidth * 8)+2) + 'px;visibility:hidden;position:absolute;"></iframe>';
         DateContent+='<table cellpadding="0" cellspacing="2"><tr>' + String.fromCharCode(13) + '<td valign="middle" style="visibility:hidden; position:absolute;z-index:25000;" >';
         DateContent+='<select class="calendarDateInput" id="' + DateName + '_Month_ID" onChange="' + DateName + '_Object.changeMonth(this)">';
         if (!Required) {
            var NoneSelected = (DefaultDate == '') ? ' selected' : '';
            DateContent+='<option value=""' + NoneSelected + '>' + UnselectedMonthText + '</option>';
         }
         for (var i=0;i<12;i++) {
            MonthSelected = ((DefaultDate != '') && (eval(DateName + '_Object.picked.monthIndex') == i)) ? ' selected' : '';
            DateContent+='<option value="' + i + '"' + MonthSelected + '>' + MonthNames[i].substr(0,3) + '</option>';
         }
         DateContent+='</select>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '<td valign="middle" style="visibility:hidden; position:absolute;">';
         DateContent+='<select' + InitialStatus + ' class="calendarDateInput" id="' + DateName + '_Day_ID" onChange="' + DateName + '_Object.changeDay(this)">';
         for (var j=1;j<=eval(DateName + '_Object.picked.dayCount');j++) {
            DaySelected = ((DefaultDate != '') && (eval(DateName + '_Object.picked.day') == j)) ? ' selected' : '';
            DateContent+='<option' + DaySelected + '>' + j + '</option>';
         }
         DateContent+='</select>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '<td valign="middle" style="visibility:hidden; position:absolute;">';
         DateContent+='<input' + InitialStatus + ' class="calendarDateInput" type="text" id="' + DateName + '_Year_ID" size="' + eval(DateName + '_Object.picked.yearPad.length') + '" maxlength="' + eval(DateName + '_Object.picked.yearPad.length') + '" title="Year" value="' + eval(DateName + '_Object.picked.yearPad') + '" onKeyPress="return YearDigitsOnly(window.event)" onKeyUp="' + DateName + '_Object.checkYear(this)" onBlur="' + DateName + '_Object.fixYear(this)">';
         DateContent+='<td valign="middle">' + String.fromCharCode(13) + '<a' + InitialStatus + ' id="' + DateName + '_ID_Link" href="javascript:' + DateName + '_Object.show()" onMouseOver="return ' + DateName + '_Object.iconHover(true)" onMouseOut="return ' + DateName + '_Object.iconHover(false)"><img src="' + ImageURL + '" align="left" title="Calendar" border="0"></a>&nbsp;';
         DateContent+='<span id="' + DateName + '_ID" style="position:absolute;visibility:hidden;z-index:25000;width:' + (CellWidth * 8) + 'px;background-color:' + CalBGColor + ';border:1px solid #a7c7e7;" onMouseOver="' + DateName + '_Object.handleTimer(true)" onMouseOut="' + DateName + '_Object.handleTimer(false)">';
			
			var monName = MonthNames[parseInt(eval(DateName + '_Object.picked.monthPad'))-1];
         monName = (monName == null ? MonthNames[Today.getMonth()]:MonthNames[parseInt(eval(DateName + '_Object.picked.monthPad'))-1]) ;
         
         DateContent+='<table width="' + (CellWidth * 8) + 'px" cellspacing="0" cellpadding="1" style="background-color:white;z-index:25000;">' + String.fromCharCode(13) + '<tr style="background-color:' + TopRowBGColor + ';">';
         DateContent+='<td id="' + DateName + '_Previous_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:' + CellHeight + 'px" onClick="' + DateName + '_Object.previous.go();" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return ' + DateName + '_Object.previous.hover(this,true)" onMouseOut="return ' + DateName + '_Object.previous.hover(this,false)" title="' + eval(DateName + '_Object.previous.monthName') + '"><img src="' + PrevURL + '"></td>';
         DateContent+='<td style="cursor:pointer" align="center" class="calendarDateInput" style="height:' + CellHeight + 'px" colspan="5" onMouseOver="self.status=\'Click to view ' + CurrentDate.fullName + '\';return true;" onMouseOut="self.status=\'\';return true;" title="Show Current Month"><div><span id="' + DateName + '_Current_ID" onClick="' + DateName + '_Object.displayed.goCurrent();" style="font-size:9px;">' + monName + '</span>' + DisplayYear(DateName) +'</div></td>';
         DateContent+='<td id="' + DateName + '_Next_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:' + CellHeight + 'px" onClick="' + DateName + '_Object.next.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return ' + DateName + '_Object.next.hover(this,true)" onMouseOut="return ' + DateName + '_Object.next.hover(this,false)" title="' + eval(DateName + '_Object.next.monthName') + '"><img src="' + NextURL + '"></td></tr>' + String.fromCharCode(13) + '<tr>';
         for (var w=0;w<7;w++) DateContent+='<td width="' + CellWidth + 'px" align="center" class="calendarDateInput" style="height:' + CellHeight + 'px;width:' + CellWidth + 'px;font-weight:bold;border-top:1px solid #a7c7e7;border-bottom:1px solid #a7c7e7;">' + WeekDays[w] + '</td>';
         DateContent+='</tr>' + String.fromCharCode(13) + '</table>' + String.fromCharCode(13) + '<span id="' + DateName + '_DayTable_ID">' + eval(DateName + '_Object.buildCalendar()') + '</span>';
         //DateContent+=(String.fromCharCode(13) + '</span>');
         
         if(this.globalDisTime)
		 {  
			var HTML1='';
		   HTML1 = '<span class="calendarDateInput"><table cellspacing="0" border="0" cellpadding="1"><tr><td style="text-align:right;">Time</td><td style="text-align:left;"><select id="Hour_ID" style="font-size:9px; height:15px; width:40px;" onChange=Time_Change("get");>';
		   for(h=0;h<24;h++)
		   {
				if(selectedHour==h)
					HTML1 += '<option value="' + getDblChar(h) + '" selected>'+ getDblChar(h) + '</option>';
				else
					HTML1 += '<option value="' + getDblChar(h) + '">'+ getDblChar(h) + '</option>';
		   }   
		   HTML1 += '</select>';
            
		   HTML1 += '<strong>:</strong><select id="Minute_ID" style="font-size:9px; height:15px; width:40px;" onChange=Time_Change("get");>';
		   for(h=0;h<60;h=h+5)
		   {
				if(selectedMinute==h)
					HTML1 += '<option value="' + getDblChar(h) + '" selected>'+ getDblChar(h) + '</option>';
				else
					HTML1 += '<option value="' + getDblChar(h) + '">'+ getDblChar(h) + '</option>';
		   }   
		   HTML1 += '</select></td><td><button id="Go" onClick="return goBtnClick()"><span class="buttonLeft"><span class="buttonRight">Go</span></span></button></td></tr></table></span>';

		   DateContent+=HTML1;
		 }
		 
		 DateContent+='</td></span></td>' + String.fromCharCode(13) + '</tr>';
		 
		
         // Completion of calander
         DateContent+=String.fromCharCode(13) + '</table></div>';
         
         DateContent+='<script>Time_Change("set");</script>';
        
      }
   }
   return DateContent+styleContent;
}


function displayFrame(varl)
{
	//alert(varl);
	var frameid=document.getElementById(varl + '_IFrame');	
	var testVar=document.getElementById(varl + '_ID');
	//iframevar.style.left= testVar.style.left;

}
function DisplayYear(dn)
{
	var ObjName=dn;
	var YrContent="";
	var yrVal=eval(dn + '_Object.picked.yearPad');
	var curYear;
	if(yrVal != '')
	{
		curYear=yrVal
	}
	else
	{
		curYear = Today.getFullYear();
	}
	YrContent += '<select id="'+ dn +'_YearID" title="Select Year" style="font-size:9px; height:15px; width:48px;" onchange="' + dn + '_Object.checkYear(this)">';
	for (var i=curYear-40; i<= curYear; i++)
	{
		if(i == curYear)
		{
			YrContent += '<option value="' + i + '" selected>' + i + '</option>';
		}
		else
		{
			YrContent += '<option value="' + i + '">' + i + '</option>';
		}
	}
	YrContent+='</select>';
	return YrContent;

}
function ChangeYear(yearVal,dn)
{
	if(document.getElementById(dn + "_YearID"))
	{
		document.getElementById(dn + "_YearID").value=yearVal;	
	}
}

function days_between(date1, date2) {

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();
    var date2_ms = date2.getTime();

    // Calculate the difference in milliseconds
    var difference_ms = date1_ms - date2_ms;
    
    // Convert back to days and return
    return Math.round(difference_ms/ONE_DAY);

}

function goBtnClick(){
orderDT_Object.pickDay(currentDay);
return false;
}var userId = GetCookie("TN_UserId");
var univCode=GetCookie("TN_Holding");
/* Menu bar */
function SetActiveMenu() 
{
    var url = document.URL;
    var divMain = $("mainMenu");
    if(divMain)
    {
        for(var i=0; i<divMain.childNodes.length; i++)
        {
            if(divMain.childNodes[i].href)
            {
					var urlTempPath = url.substring(0, url.indexOf(".aspx"));
					if(urlTempPath == "" && url.indexOf(".aspx") < 0) {
						 urlTempPath = url;
					}
                var urlPath = urlTempPath.substring(0,urlTempPath.lastIndexOf("/")+1);
                var hrefPath = divMain.childNodes[i].href.substring(0, divMain.childNodes[i].href.lastIndexOf("/")+1);
                if(url.indexOf("/Home.aspx") >= 0 && url.indexOf("/Login.aspx") < 0)
                {
						urlPath += "Investments/";
                }
                
                var divId = divMain.childNodes[i].id;
                var subMenu = $("sub"+divId);
                if(subMenu)
                {
						 var child = subMenu;
						 var displayChild = child.style;
						 if(!child.style)
						 {
							displayChild = child;
						 }
						 if(hrefPath.toUpperCase() == urlPath.toUpperCase() || IsUrlBelongsToMenu(divMain.childNodes[i], urlPath))
						 {
							divMain.childNodes[i].className = "selected";

							displayChild.display = "block";
							var currSub = $("currSubmenu");
							if(currSub)
							{
								currSub.value = child.id;
								var secondLvl = child.getElementsByTagName("LI");
								var selSecondLvl = 0;
								if(default2ndLevel != '')
								{
									var lvl2 = $(default2ndLevel)
									if(lvl2)
									{
										lvl2.className += " selected";
									}
								}
								else
								{
									for(var k=0;k<secondLvl.length;k++)
									{
										if(secondLvl[k])
										{
											var anchor = secondLvl[k].getElementsByTagName("A");
											for(var l=0;l<secondLvl.length;l++)
											{
												if(typeof(anchor[l])!='undefined' && (url.toUpperCase().indexOf(anchor[l].href.toUpperCase())>=0) )
												{
													anchor[0].className += " selected";
													selSecondLvl = 1;
													break;
												}
											}
											if(selSecondLvl == 1)
												break;
										}
									}
								}
							}
						 }
						 else
						 {
							  displayChild.display = "none";
						 }
                }
            }
        }
    }
}

function IsUrlBelongsToMenu(menu, urlPath)
{
    if(menu.id.toUpperCase() == "TOOLS")
    {
        if(urlPath.toUpperCase().indexOf("/PSCAN") >= 0 
        || urlPath.toUpperCase().indexOf("/RSS") >= 0)
        {
            return true;
        }
    }
    if(menu.id.toUpperCase() == "INVESTMENTS")
    {
        if(urlPath.toUpperCase().indexOf("/FACTSHEETS") >= 0
			|| urlPath.toUpperCase().indexOf("/GENERAL") >= 0
			|| urlPath.toUpperCase().indexOf("/INVESTMENTS") >= 0)
        {
            return true;
        }
    }   
    if(menu.id.toUpperCase() == "EDUCATION")
    {
        if(urlPath.toUpperCase().indexOf("/GLOSSARIES") >= 0
        	|| urlPath.toUpperCase().indexOf("/MASTERCLASS") >= 0)
        {
            return true;
        }
    }   
    return false;
}

function portSubmit(page)
{
    document.masterForm.action=page;
    document.masterForm.submit();
}
	 
function ChangeCurrency(currency)
{
    SetCookie("TN_Currency", currency, 123231);
    document.masterForm.submit();
}

function SetActiveCurrency(currency)
{
 if(emailSiteCode!="TNUK")
 {
    var srcFile = "";
    var mnuSrc = "";
    var title = "";
    switch(currency.toUpperCase())
    {
        case "LOCAL":
        case "":
            srcFile = "currencyMaster";
            mnuSrc = "Local";
            title = "Fund Currency";
            break;
        case "GB":
        case "GBP":
            srcFile = "currencyPound";
            mnuSrc = "Pound";
            title = "UK Pound";
            break;
        case "US":
        case "USD":
            srcFile = "currencyDollar";
            mnuSrc = "Dollar";
            title = "US Dollar";
            break;
        case "EU":
        case "EUR":
            srcFile = "currencyEuro";
            mnuSrc = "Euro";
            title = "Euro Currency";
            break;
        case "HK":
        case "HKD":
            srcFile = "currencyEuro";
            mnuSrc = "HKDollar";
            title = "HK Dollar";
            break;   
        case "SG":
        case "SGD":
            srcFile = "currencySG";
            mnuSrc = "SGDollar";
            title = "SG Dollar";
            break;  
        case "IN":
        case "INR":
            srcFile = "currencyRupees";
            mnuSrc = "Rupees";
            title = "IN Rupee";
            break; 
    }
    var leftCurrentCurr = $('currentCurrency');
    if(leftCurrentCurr)
    {
		leftCurrentCurr.src = "/images/"+srcFile+".png";
		leftCurrentCurr.title = title;
    }
    var mnuCurrentCurr = $('mnuCurrentCurrency');
    if(mnuCurrentCurr)
    {
		mnuCurrentCurr.src = "/images/curMenu/"+mnuSrc+"Icon.png";
		mnuCurrentCurr.title = title;
		var rdo = $("rdo"+mnuSrc);
		if(rdo)
		{
			rdo.checked = true;
		}
    }
   }
}

function LaunchPop(urlpop, width, height)
{
	newWindow = window.open(urlpop,"popup","scrollbars,height="+height+",width="+width+",location=0,status=0");
	newWindow.focus();
}


/* * *		Factsheet Functions     * * */

function GroupFile()
{
    var mngCode = $('managerCode').value
    var universeCode = $('universeCode').value
    document.location = "GroupFactSheet.aspx?managerCode=" + mngCode + "&univ="+universeCode;
}

function FSPageTransistion()
{
	var pagetype = getQueryValue("pagetype");
	pagetype = pagetype.toUpperCase();
    $('tab2').className = (pagetype == 'PERFORMANCE' ? 'selected' : '');
    $('tab3').className = (pagetype == 'RATIOS' ? 'selected' : '');
    $('tab4').className = (pagetype == 'PORTFOLIOBREAKDOWN' ? 'selected' : '');
    $('tab5').className = (pagetype == 'DIVIDENDS' ? 'selected' : '');
    $('tab6').className = (pagetype == 'MGMTINFO' ? 'selected' : '');
    if(SiteCode=='TNUK')
    {
        $('tab7').className = (pagetype == 'WRAPPER' ? 'selected' : '');
    }
    $('tab1').className = (pagetype != 'PERFORMANCE' && pagetype != 'RATIOS' && pagetype != 'PORTFOLIOBREAKDOWN' && pagetype != 'DIVIDENDS' && pagetype != 'MGMTINFO'&& pagetype != 'WRAPPER') ? 'selected' : '';
}
function ITFSPageTransistion()
{
	var pagetype = getQueryValue("pagetype");
	pagetype = pagetype.toUpperCase();
    if($('tab2'))$('tab2').className = (pagetype == 'PERFORMANCE' ? 'selected' : '');  
    if($('tab3'))$('tab3').className = (pagetype == 'DIVIDENDS' ? 'selected' : '');
    if($('tab4'))$('tab4').className = (pagetype == 'PORTFOLIOBREAKDOWN' ? 'selected' : '');
    if($('tab5'))$('tab5').className = (pagetype == 'ANALYSIS' ? 'selected' : '');
    if($('tab6'))$('tab6').className = (pagetype == 'LIFE' ? 'selected' : '');
    if($('tab7'))$('tab7').className = (pagetype == 'PENSION' ? 'selected' : '');    
    if($('tab1'))$('tab1').className = (pagetype != 'PERFORMANCE' && pagetype != 'RATIOS'&& pagetype != 'ANALYSIS' && pagetype != 'PORTFOLIOBREAKDOWN' && pagetype != 'DIVIDENDS' && pagetype != 'MGMTINFO' && pagetype != 'PENSION' && pagetype != 'LIFE') ? 'selected' : '';
}

function CFPPageTransistion()
{
	var pagetype = getQueryValue("pagetype");
	pagetype = pagetype.toUpperCase();
    if($('tab2'))$('tab2').className = (pagetype == 'VIEW' ? 'selected' : '');  
    if($('tab1'))$('tab1').className = (pagetype != 'VIEW') ? 'selected' : '';
}

function ChangeSpan(typeCode, unitname, benchmarkcode, benchmarkname)
{
	var imgChart = $("chartImg");
	var timeSpan = $("timeSpan");
	if(imgChart)
	{
		imgChart.src = "ChartBuilder.aspx?chart=3&typeCode="+typeCode+"&unitname="+unitname+"&benchmarkcode="+benchmarkcode+"&benchmarkname="+benchmarkname+"&span="+timeSpan.value+"&w=375&h=240";
	}
}

function ChangeSpanValue(typeCode, unitname, benchmarkcode, benchmarkname)
{
	var imgChart = $("fundChart");
	var timeSpan = $("chartperiod");
	if(imgChart)
	{
		imgChart.src = "/Factsheets/ChartBuilder.aspx?chart=3&typeCode="+typeCode+"&unitname="+unitname+"&benchmarkcode="+benchmarkcode+"&benchmarkname="+benchmarkname+"&span="+timeSpan.value+"&h=210&w=310";
	}
}
function ChangeSpanWidth(typeCode, unitname, benchmarkcode, benchmarkname,width)
{
	var imgChart = $("fundChart");
	var timeSpan = $("chartperiod");
	if(imgChart)
	{
		imgChart.src = "/Factsheets/ChartBuilder.aspx?chart=3&typeCode="+typeCode+"&unitname="+unitname+"&benchmarkcode="+benchmarkcode+"&benchmarkname="+benchmarkname+"&span="+timeSpan.value+"&h=250&w="+width;
	}
}
function ChangeDiscPreSpan(unitcode,span)
{
  var imgChart = $("Img6");
  if(span!="" && imgChart)
  {
  imgChart.src = "/Webservices/Charting.asmx/GetDiscountPremiumChart?width=650&height=250&unitCode="+unitcode+"&span="+span;
  }
}
function ChangeUnit(code)
{
	$("citicode").value = code;
	document.masterForm.submit();
}


function getOptionIndex(selectCtrlID, value) 
{
	var select = $(selectCtrlID);
	for (var i = 0; i < select.options.length; i++) {
	  if (select.options[i].value == value) 
		return i;
	}
	return -1;
}

function LoadSectorsByAssetClass(univ, assetClassCtrl)
{
 var universe=univ;
 if(assetClassCtrl)
 {
	 var assetClass = assetClassCtrl.options[assetClassCtrl.selectedIndex].text;

	 // Loading Sectors
	 var Sector=TrustnetX.Controls.CustomisedTable.LoadSectorsByAssetClass(universe, assetClass);
	 Sector=Sector.value;
	 var sectorDDCtrl=$(ctrlId+"_"+"Sector");
	 if(sectorDDCtrl)
	 {
		 var initialOptionText = sectorDDCtrl.options[0].text;
		 var initialOptionValue = sectorDDCtrl.options[0].value;
	 
		 sectorDDCtrl.options.length=0;
		 var optionElement=document.createElement("option");
		 optionElement.text = initialOptionText;
		 optionElement.value = initialOptionValue;
		 sectorDDCtrl.options.add(optionElement);
		 if(Sector)
		 {
			 for(i=0;i<Sector.length;i++)
			 {
				optionElement=document.createElement("option");
				optionElement.text=Sector[i].SectorName;
				optionElement.value=Sector[i].SectorClassCode;
				sectorDDCtrl.options.add(optionElement);
			 }
		 }
	}
 }
}

function GetSectorsIfValid(univ, sectorDDId, selectedValue)
{
	var hdnSectorValid = $('hdnTQSectUnAvail');
	if(hdnSectorValid) {
		var sectorUnAvailArr = hdnSectorValid.value.split(',');
		if(IsStringFoundInArray(sectorUnAvailArr, univ)) {
			$(sectorDDId).value = "";
			$(sectorDDId).disabled = true;
			$('TQCrownRating').value = "";
			$('TQCrownRating').disabled = true;
		}
		else {
			LoadSectorsByUniv(univ, sectorDDId, selectedValue);
			$('TQCrownRating').disabled = false;
		}
		//Universe Value Assigned while selecting radio button in TopQuartile Page
	    univValue=univ;
	}
}

function AssetSectorChange(univCode)
{
   var assetClassCtrl = $(ctrlId+"_AssetClass");
	if(assetClassCtrl)
	{
		var sectorDD = $(ctrlId+"_Sector");
		
		
		LoadSectorsByAssetClass(univCode, assetClassCtrl);
		var hdnsector = $(ctrlId+"_CurrentSector");
		
		if(sectorDD && hdnsector) {
			for (i=0; i < sectorDD.options.length; i++){  
				if(sectorDD.options[i].value == hdnsector.value) {
					sectorDD.selectedIndex = i;
				}
			}
		}
	}
}

function DeHighlightRows(typecodes)
{
	var cookieType = Mode;
	var basketOverriden = false;
	 var overrideBasketElem = $('overrideBasketCookie');
	 if(overrideBasketElem) {
		if(overrideBasketElem.value != "") {
			basketCookieName = overrideBasketElem.value;
			basketOverriden = true;
		}
	 }
   var Title="basket";    
	 switch(cookieType.toUpperCase())
	 {
		   case "PORT":
			  Title="Portfolio '"+portName+"'"
			  break;
		   case "WATCH":
			  Title="Watchlist";
			  break;
		   default:
			  if(basketOverriden){
				 Title=basketCookieName;
			  }
			  else {
				 Title="basket";
			  }
			  break;
	 } 
    var elements = document.getElementsByTagName("TR");
    var typecodeArr = typecodes.split(',');
    for(var i=0;i<elements.length;i++)
	{
	    if(IsStringFoundInArray(typecodeArr, elements[i].id))
	    {
			var imgTags = elements[i].getElementsByTagName('IMG');
			for(var j=0;j<imgTags.length;j++)
			{
				if(imgTags[j].src.indexOf("/icons/removeIco.png") >= 0)
				{
					imgTags[j].src = "/icons/icon_plus.png";					
					imgTags[j].title = "add to "+Title;
					imgTags[j].width = "16";
					imgTags[j].height = "15";
				}
			}
	      elements[i].className = elements[i].className.replace("selected", "");
	    }
	}
	elements = document.getElementsByTagName("DIV");
	for(var i=0;i<elements.length;i++)
	{
	    if(IsStringFoundInArray(typecodeArr, elements[i].id))
	    {
			var imgTag = $("Img-"+elements[i].id);
			if(imgTag)
			{
				if(imgTag.src.indexOf("/icons/removeIco.png") >= 0)
				{
					imgTag.src = "/icons/icon_plus.png";
					imgTag.title = "add to "+Title;
					imgTag.width = "16";
					imgTag.height = "15";
				}
			}
			var divTag = $("span-"+elements[i].id);
			if(divTag)
			{
			    if(divTag.innerHTML.indexOf('equity') > 0)
			    {
			        divTag.innerHTML = "Add this equity to basket";
			    }
			    else
			    {
				    divTag.innerHTML = "Add this unit to basket";
				}
			}
			elements[i].className = elements[i].className.replace("bold", "");
	    }
	}
}

function retainSelectedVal(typeCode)
{
	var value = GetCookie("TN_RetainSelected");
//	if(value=='')
//	{
//	value = GetCookie("shortlisted");
//	}
	var spliter =((value != '')?',':'');
	value +=  spliter + typeCode;
	SetCookie("TN_RetainSelected", value);
}
	 

function DeleteFromShortlist(typecode, cookieName)
{
	 var value = GetCookie(cookieName);
//	 if(value=='' && cookieName=="TN_RetainSelected")
//	 {
//	  value = GetCookie("shortlisted")	
//	 }
	 var newShortList = '';
	 var spliter ='';

	var farray = new Array();
	farray = value.split(',');
	for(var i=0; i< farray.length; i++)
	{
		if(farray[i] != typecode)
		{
			 newShortList += spliter + farray[i];
			 spliter = ',';
		}
	}   
	if(cookieName=="TN_RetainSelected")
	{
    SetCookie(cookieName, newShortList);
    }else{
     SetCookie(cookieName, newShortList, 123231);
    }
}


function DeleteFromDB(typecode, TypeCodes)
{
	 var value = TypeCodes;
	 var newShortList = '';
	 var spliter ='';

	var farray = new Array();
	farray = value.split(',');	
	for(var i=0; i< farray.length; i++)
	{
		if(farray[i] != typecode)
		{
			 newShortList += spliter + farray[i];
			 spliter = ',';
		}
	}   
   
   PorttypeCodes=newShortList;   
   WatchtypeCodes=newShortList;
}


function SetCookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : ";path=/" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

/// To Get specified Cookie value
function GetCookie(name) 
{
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return '';
    if (start == -1) return '';
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

// this deletes the cookie when called
function DeleteCookie(name, path, domain)
{
   if (GetCookie(name))
   {
      document.cookie = name + "=" + 
         (path ? ";path=" + path : ";path=/") +
         (domain ? ";domain=" + domain : "") +
         ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
   } 
}

// Function to set the selected values in dropdown.
function setSelect(sbox, value) {
	if(sbox != null && sbox.options != null)
	{
		for (i = 0 ; i < sbox.options.length; i++) {
			if (sbox.options[i].value == value) {
				sbox.selectedIndex = i;
				return;
			}
		}
	}
}

function IsStringFoundInArray(array, stringValue)
{
    var found = false;
    if(stringValue != '')
    {
		 for(var i=0; i< array.length; i++)
		 {
			  if(array[i] == stringValue)
			  {
					found = true;
					break;
			  }
		 }
	 }
    return found;
}

function HideTooltip()
{
    $("Popup_Sortlist").style.display="none";
}

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}


/// To get querystring value from url
function getQueryValue(name) 
{
	var url = document.URL;
	i = url.indexOf(name += '=')
	j = url.indexOf('&', i);
	if(-1 == j) 
	{
		j = url.length;
	}
	if(-1 != i) 
	{
		return url.substring(i + name.length, j);
	}
	else
	{
		return '';
	}
}



//Function for Fund Comaprision page


function checkTypeCode(url,min, max, parameters)
{
//	var typeCode=GetCookie("TN_RetainSelected");
//	var SortListedtypeCode=GetCookie("shortlisted");
//	if(typeCode=='')
//	{
//	typeCode=SortListedtypeCode;
//	SetCookie("TN_RetainSelected", SortListedtypeCode);
//	}
	
	
	var typeCode=GetCookie("TN_RetainSelected");
	var element = document.getElementsByName("ckShortList");
	if(typeCode=='' && element.length==0)
	{
	    typeCode = GetCookie("shortlisted");
	     SetCookie("TN_RetainSelected", typeCode);
	}    
    
	var SortListedtypeCode = GetCookie("shortlisted");
	if(SortListedtypeCode=='')typeCode='';
	
	if(SortListedtypeCode!='')
	{
	var length = 0; 
	if(typeCode == null || typeCode == '')
	{
		//alert('No funds selected for comparison to add funds go to performance page and click the green color plus button.');
		var imageUrl='<img src="images/icon_plus.png"/>';
		alert('Select 2 or more funds for fund comparison. Add funds in Basket using "Green Plus Icon" wherever you see it next to a fund.');
	}
	else
	{
			var farray = new Array();
			farray = typeCode.split(',');
			length = farray.length;
			if(length<2)
			{
				//alert('Atleast select 2 funds for comparison to add funds go to performance page and click the green color plus button.');
				alert('Select 2 or more funds for fund comparison. Add funds in Basket using "Green Plus Icon" wherever you see it next to a fund.');
			}
			if(length>4)
			{
				alert('Selected funds should be less than or equal to 4');
				document.masterForm.action="/Tools/Tools.aspx";
				//document.masterForm.submit();
			}
			if(length>=min && length<=max){
				document.masterForm.action=url;
				document.masterForm.submit();
			}
	}
	}else
	{
		//alert('No Funds in Basket. To add funds in Basket using "Green Plus Icon" wherever you see it next to a fund.');
		alert('There are no funds in your basket. To add funds to your basket use the "Green Plus Icon" wherever you see it next to a fund.');
	}
}

// Function to trim the given string
function TrimAString(str)
{ 
	while(str.charAt(0) == (" "))		
	{ str = str.substring(1);	}
	
	while(str.charAt(str.length-1) == " " )
	{ str = str.substring(0,str.length-1);	}

	return str;
}

//Check Registor Details
function CheckDetails(chk)
{
	
    var userName,userPwd,userPwd2     
    Password=$("Password");
    userPwd2=$("userPwd2");      
	var Email=$("EmailAddress");  	 
	var elements=document.getElementsByName('Register'); 	
	var  values="";
	var keys="";
	var ids="";	
	var err="You must enter values for mandatory (*) fields.";		 
	if(elements.length!=0)
	{
		for(var i=0;i<elements.length;i++)
		{	 	       
			if(elements[i].tagName=="INPUT")
			{
				if(elements[i].value=="")
				{		
					var idName="span"+elements[i].id;														  
					$(idName).style.visibility="visible"; 		
					$("errMsg").innerHTML=err;
					ids="error";  					    
				}
			   else
			   {
					if(elements[i].type=="text")
					{
						values +=elements[i].value+",";	
						keys+=elements[i].id+",";			 				    
						$("span"+elements[i].id).style.visibility="hidden"; 
					}    
				}	
			}
		
			if(elements[i].tagName=="SELECT")
			{
				var rowEle = document.getElementById("tbl" + elements[i].id);
				if(rowEle.style.display!='none')
				{	 
					if(elements[i].options[elements[i].selectedIndex].value=="" && elements[i].id != "")
					{	
						var Expatriot=$("Expatriate");	
						if(Expatriot!=null)
						{	
							if(Expatriot.value=="Yes")
							{
								$("span"+elements[i].id).style.visibility="visible"; 
								$("errMsg").innerHTML=err;		     
								ids="error";
							}
							else
							{				 
								if(elements[i].id!='Country of residence')
								{
									$("span"+elements[i].id).style.visibility="visible"; 
									$("errMsg").innerHTML=err;		     
									ids="error";
								}
							}				   
						}
						else
						{
							$("span"+elements[i].id).style.visibility="visible"; 
							$("errMsg").innerHTML=err;		     
							ids="error";
						}
					}
					else
					{
						if(elements[i].id=='Referred by')
						{
							var optionVal = elements[i].options[elements[i].selectedIndex].value;
							if(optionVal=='Others')
							{
								var eleRefByOthersTxt = $('ReferredByOthers');
								if(eleRefByOthersTxt)
								{
									values = values + eleRefByOthersTxt.value + ",";
								}
								else
								{
									values = values + optionVal + ",";
								}
							}
							else
							{
								values = values + optionVal + ",";
							}
						}
						else
						{
							values=values+elements[i].options[elements[i].selectedIndex].value+",";
						}
						
						keys+=elements[i].id+",";
						$("span"+elements[i].id).style.visibility="hidden";
					}
				}
			}
			 //$("values").value=values;	
			 //$("keys").value=keys;
		}
		if($("TrustnetResearch"))
		{
			if($("TrustnetResearch").checked==true)
			{
				values += "1,";
				keys += "Trustnet Research,";
			}
			else
			{
				values += "0,";
				keys += "Trustnet Research,";
			}
		}
			
		if($("TrustnetUpdates"))
		{
			if($("TrustnetUpdates").checked==true)
			{
				values += "1,";
				keys += "Trustnet Updates,";
			}
			else
			{
				values += "0,";
				keys += "Trustnet Updates,";
			}
		}
		
		$("values").value=values;	
		$("keys").value=keys;
	}
	  
	if(Email.value=="")
	{
		$("spanEmail").style.visibility="visible";
		$("errMsg").innerHTML=err;
		ids="error";   
	}
	else
	{
		if(validateEmail(Email)==false)
		{
			ids="error";
			Email.value=Email.value
			//err="** Invalid E-mail ID"
			$("errMsg").innerHTML=err;
			$("EmailAddress").focus();
		}
		else
		{
			$("spanEmail").style.visibility="hidden";
		}
	}
	if(Password.value=="" && chk=="add")
	{
		$("spanPassword").style.visibility="visible";
		$("errMsg").innerHTML=err;
		ids="error";   
	}
	else
	{
		if(Password.value!=userPwd2.value)
		{
			ids="error";  
		   $("errMsg").innerHTML="Password and Confirm password should be same.";
		   $("spanuserPwd2").style.visibility="visible"; 
		   $("userPwd2").focus();
		}
		else
		{
			$("spanuserPwd2").style.visibility="hidden";
		}
		$("spanPassword").style.visibility="hidden";
	}
	if(chk=="add" && ids=="")
	{	    
		document.masterForm.submit();
	}
	else if(chk!="add" && ids=="")
	{
		document.masterForm.action="/Tools/Profile.aspx?type=1&boolLogin=register"
	   document.masterForm.submit();
	}
}

function CheckReferredByValue(refByVal)
{
	var eleRefByRow = $('ReferredByOthersRow');
	
	if(refByVal=='Others')
	{
		eleRefByRow.style.display='block';
	}
	else
	{
		eleRefByRow.style.display='none';
	}
}

function LoadCountry()
	{
	var Expatriot=$("Expatriate");
	
	if(Expatriot!=null)
	{	
	if(Expatriot.value=="Yes")
	{	
	$("tblCountry of residence").style.visibility="visible";
	$("tblCountry of residence").style.display="";	
	}else{
	$("tblCountry of residence").style.visibility="hidden";
	$("tblCountry of residence").style.display="none";
	$("tblCountry of residence").style.position="relative";
	}
	}
}

//Check Email ID
function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   $("errMsg").innerHTML="** Invalid E-mail ID";
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   $("errMsg").innerHTML="** Invalid E-mail ID";
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    $("errMsg").innerHTML="** Invalid E-mail ID";
		    return false
		}
		if (str.indexOf(at,(lat+1))!=-1){
		    $("errMsg").innerHTML="** Invalid E-mail ID";
		    return false
		 }
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    $("errMsg").innerHTML="** Invalid E-mail ID";
		    return false
		 }
		if (str.indexOf(dot,(lat+2))==-1){
		    $("errMsg").innerHTML="** Invalid E-mail ID";
		    return false
		 }		
		 if (str.indexOf(" ")!=-1){
		    $("errMsg").innerHTML="** Invalid E-mail ID";
		    return false
		 }
 		 return true					
}
	
//Check Login Details
function  CheckLogin()
{
     var Email,userPwd
     Email=$("EmailAddress").value;     
     userPwd=$("userPwd").value;     
     if(Email=="" && userPwd=="")
         {
            $("errMsg").innerHTML="Please type your e-mail address and Password";
            $("EmailAddress").focus();
            return false;
         }
     else if(Email=="")
         {
            $("errMsg").innerHTML="Please type your e-mail address";
            $("Email").focus();
            return false;
         }
     else if(userPwd==""){
            $("errMsg").innerHTML="Please type your Password";
            $("userPwd").focus();
            return false;
        }
     else if (validateEmail($("EmailAddress"))==false){     
		    Email=""
		    $("EmailAddress").focus();
		    return false;
	     }	    
	 else{
	 //   document.masterForm.action="PortfolioLogin.aspx?requiredLogin=true";
        document.masterForm.submit();         
        }
}

//Load Change Event
function onChange(){
	  document.masterForm.submit(); 
}

//Change Holding Link
function addHold()
{
if(code!=''){
 document.masterForm.action="/Investments/Perf.aspx?univ=E"
 document.masterForm.submit();
 }
}
  
//Get All Valution Totals And quantity
function addItems(page,val)
{
  var elements=document.getElementsByName("quantity");
  var elementPD=document.getElementsByName("PD");
  var elementBalance=document.getElementsByName("balance");  
  var elementRename=document.getElementsByTagName("INPUT");
  var quantity="";
  var balance="";  
  var elementCost=document.getElementsByName("Cost");
  var cost="";
  var err="";
  var PDCost="";
  var spliter="";
  var names="";
  var rdnCid="";
  var cName="";
for(var i=0;i<elementRename.length;i++)
{

    if(elementRename[i].name=="Rename")
    {         
    cName=elementRename[i].value;
    names=names+cName.replace(",","#@#")+",";
    rdnCid=rdnCid+elementRename[i].id+",";       
    }
} 

  

 for(var i=0;i<elementBalance.length;i++)
  { 
  
    if (elementBalance[i].value == "")
	{	
		elementBalance[i].select();
		elementBalance[i].focus();
		err="error";
		return false;	
	}
    if (chkNumeric(elementBalance[i]) == false)
	{	
		elementBalance[i].select();
		elementBalance[i].focus();
		err="error";	
		return false;
	}
	if(i==(elementBalance.length-1))
	{
	balance+=elementBalance[i].value;
	}else{
    balance+=elementBalance[i].value+",";
   }
 }
 
  
 
 $("hdnBalance").value=balance;
 if($("hdnRenames"))$("hdnRenames").value=names;
 if($("rdnCid"))$("rdnCid").value=rdnCid;  

 if(err=="")
 {
   if(val=="y"){
    document.masterForm.action=page+"?type=1";
   }else{
   document.masterForm.action=page;
 }
 document.masterForm.submit();
 }
}
    
//Key Press Event
function onSearchKeyPress(e, str) {
	var key;
	if (window.event) {
		key = window.event.keyCode; //ie
	}
	else {
		key = e.which; //ff
	}
	if (key == 13) {	
	   if(str.id=="EmailAddress" || str.id=="userPwd"){
	   CheckLogin();
	   }
//	   else if(str.id=="txtPassword")
//	   {
//	   CheckUser(); 
//	   }
	   else 
	   {
	    return false;
	   }
	}
}

//Key Press Event for simple text search
function onSearchTextKeyPress(e,keyword) 
{
    var key;
     
    if (window.event) {
        key = window.event.keyCode; //ie
    }
    else {
        key = e.which; //ff
    }
    if (key == 13) { 
       if((keyword.id=="strText" && keyword.value!="")||(keyword.id=="keyword" && keyword.value!=""))searchSubmit(keyword.value);else return false;
       
    }
 }
        
 //submit to simple text search        
 function searchSubmit(keyword)
 {
	if(keyword != "" && keyword.length >=3)
	{
		var scope = $('scope');
		var searchArticles = $('rdoArticles');
		var pageNo="";
		if(document.getElementById('PageNo'))
			pageNo="&PageNo="+ document.getElementById('PageNo').value

		if(!ValidateString(keyword))
		{
			alert('Invalid input, please provide valid input.');
			return false;
		}
		if(typeof(scope)!='undefined' && scope != null && typeof(searchArticles)!='undefined')
		{
			if(searchArticles.checked)
			{
				window.location='/Tools/Search.aspx?keyword='+URLencode(keyword)+'&scope='+ URLencode(scope.value) +'&on=a'+pageNo;
			}
			else
			{
				window.location='/Tools/Search.aspx?keyword='+URLencode(keyword)+'&scope='+scope.value+'&on=f';
			}
		}
		else if(typeof(scope)!='undefined' && scope != null)
		{
			window.location='/Tools/Search.aspx?keyword='+URLencode(keyword)+'&scope='+scope.value;
		}
		else
		{
			window.location='/Tools/Search.aspx?keyword='+URLencode(keyword);
		}
	}
	else
	{
		alert("Value should not be empty and should be more than four letters");
		return false;
	}
 }
 
 function ValidateString(n)
 {
	if(n.indexOf("&#") > -1 || n.indexOf("<") > -1 || n.indexOf("!") > -1 || n.indexOf("/") > -1 || n.indexOf("__") > -1)
	{
		return false;
	}
	return true;
 }
 
 function URLencode(n)
 {
	var encoded = "";
	
	var len=n.length;
	for(;;)
	{
		n=n.replace('%25','%');
		n=n.replace('%20',' ');
		if(n.length == len)
		{
			break;
		}
		else
		{
			len=n.length;
		}
	}
	
	n=n.replace("%2520"," ");
	n=n.replace("%20"," ");
    var HEX = "0123456789ABCDEF";
    var UNSAFECHARS = '<>"#%{}|^~[];/?:@=&\'';

    for (var i = 0; i < n.length; i++ ) {

    	var ch = n.charAt(i);

    	if (ch == " ") {
		encoded += "+";	// x-www-urlencoded, rather than %20
    	}
    	else if (UNSAFECHARS.indexOf(ch) != -1) {
			var charCode = ch.charCodeAt(0);
			encoded += "%";
            encoded += HEX.charAt((charCode >> 4) & 0xF);
            encoded += HEX.charAt(charCode & 0xF);
			}
		else{
			//it�s safe
			encoded += ch;
    	}
    } // for
   
    return encoded;
}
 
 function NumericCount(id,e)
 {
 var keycode= (e.keyCode) ? e.keyCode : e.which;
 if((keycode>= 48 && keycode<=57 ))
 {
 var value= id.value.split("."); 
 if(value[0].length>12)
 {
 return false;
 }
 }
 return true;
 }
 
 // print any page

 function printMe() 
 { 

   var windowWidth='850';

   var windowHeight='850';

   

    var centerWidth = (window.screen.width - windowWidth) / 2;

    var centerHeight = (window.screen.height - windowHeight) / 2;

    

    var url="";

    if(window.location.href.indexOf('?')>-1)
    {
        url=window.location.href+"&print=true";

    }
    else
    {
        url=window.location.href+"?print=true";

    }

     $('masterForm').action=url;
     $('masterForm').target="_blank";

     $('masterForm').submit();
     
     $('masterForm').action="";
     $('masterForm').target="";


   // newWindow = window.open(url, 'Print', 'scrollbars=1,resizable=1,width=' + windowWidth + ',height=' + windowHeight + ',left=' + centerWidth + ',top=' + centerHeight);
   //newWindow.focus(); 
   

    return;

  }

    



    function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func; 
	  } else { 
	    window.onload = function() { 
	      oldonload(); 
	      func(); 
        } 
	  } 
	} 
	 
 //print this popup page
  function printThis()
  {
	  var portControl= document.getElementById('selectPortfolio');
	  if(portControl)
	  {
		 var w =portControl.selectedIndex;	   
		 var pName=portControl.options[w].text;  	  
		 var pText=document.getElementById("PortText");
		 if(pText)pText.innerHTML="<b>Portfolio Name : "+pName+"</b>";		 
	  }
	  for(var i = 0; (linkelement = document.getElementsByTagName("link")[i]); i++)
      { 
        if(linkelement.getAttribute("rel").indexOf("style") != -1 &&  linkelement.media == "print")
        { linkelement.media='All';
        }
      }

      var topMnu = $('topBG');
      if (topMnu) {

        var currency=$("mnuCurrentCurrency");
        
        var logo=null;
        
        if(logoName!=null&&logoName!='')
        {
            logo=document.createElement("IMG");
            logo.alt=emailSiteName;
            logo.title=emailSiteName;
            logo.border="0";
            logo.src="/images/"+logoName;
            
            if(emailSiteCode=="TNO")
            {
                logo.style.width="189px";
                logo.style.height="108px";
            }
            else if(emailSiteCode=="TNHK")
            {
                logo.style.width="220px";
                logo.style.height="91px";
            }
            else if(emailSiteCode=="TNIN")
            {
                logo.style.width="217px";
                logo.style.height="85px";
            }
            else if(emailSiteCode=="TNSG")
            {
                logo.style.width="223px";
                logo.style.height="82px";
            }
            else if(emailSiteCode=="TNUK")
            {
                logo.style.width="172px";
                logo.style.height="50px";
            }
            else if(emailSiteCode=="TNME")
            {
                logo.style.width="136px";
                logo.style.height="100px";
            }            
        }
        else
        {
          logo=document.createTextNode('  ');             
        }

        //TNHK_Logo.png
        //TN_Global.jpg
        
        var logoDiv=document.createElement("DIV");
        logoDiv.appendChild(logo);
        logoDiv.className='headerLogoPrint';        
        topMnu.style.display = 'none';
        
			var main = $('main');
			var footer = $('footer');
			var headDiv = document.createElement("DIV");
			
			
			//******************************************
			// Code for UK print preview starts here
			//******************************************
			if(emailSiteCode=="TNUK")
			{
				var userId=GetCookie("TN_UserId");
				/*
					ifIFA				-	False
					isWhileLable	-	True i.e., domain name other than www.trustnet.com
				*/
				if(isIFAUser == 0 && isWhiteLabel=="Yes" && isUniqueLogo=="No")
				{
					var ifaLogo=null;
					ifaLogo=document.createElement("IMG");
					ifaLogo.alt="";
					ifaLogo.title="";
					ifaLogo.border="0";
					ifaLogo.src="/images/" + wlLogoName;
					
					var oTbl=document.createElement("Table");
					var oTR= oTbl.insertRow(0);
					var oTDL= oTR.insertCell(0);
					var oTDR= oTR.insertCell(1);
					oTDL.style.width=ifaLogo.style.width;
					oTDL.appendChild(ifaLogo);
					
					var tnLogo=document.createElement("IMG");
					tnLogo.alt=emailSiteName;
					tnLogo.title=emailSiteName;
					tnLogo.border="0";
					tnLogo.src="/images/TN_Logo.png";
					
					var tnLogoDiv=document.createElement("DIV");
					tnLogoDiv.style.width="100%";
					tnLogoDiv.style.styleFloat="right";
					tnLogoDiv.style.cssFloat="right";
					tnLogoDiv.style.textAlign="right";
					tnLogoDiv.appendChild(tnLogo);
					
					oTDR.appendChild(tnLogoDiv);
               oTDR.style.textAlign="right";
					oTDR.style.styleFloat="right";
					
					if(!$('rightColumnHome') && !(document.URL.indexOf("/Factsheet.aspx?")>0) && !(document.URL.indexOf("/Tools.aspx")>0))
					{
						headDiv.style.width="980px";
						main.style.width="980px";
						if (footer) 
						{
							footer.style.width="980px";
						}
					}
					else
					{
						if (footer) 
						{
							if($('rightColumnHome')) footer.className = 'footerPrint';
							else footer.className = 'footerPrintBig';
						}
					}
					headDiv.appendChild(oTbl);
				}
				/* 
					UserId			-	Exist
					isIFA				-	True
					IFAFile			-	Exist
					isWhiteLabel	-	No i.e., the domain name is www.trustnet.com
				*/
				else if(userId != "" && isIFAUser == 1 && isIFAFileExist == "Yes")
				{
					var ifaLogo=null;
					ifaLogo=document.createElement("IMG");
					ifaLogo.alt="";
					ifaLogo.title="";
					ifaLogo.border="0";
					ifaLogo.src="/Tools/LogoBuilder.aspx?UserId=" +	userId;

					var oTbl=document.createElement("Table");
					var oTR= oTbl.insertRow(0);
					var oTDL= oTR.insertCell(0);
					var oTDM= oTR.insertCell(1);
					var oTDR= oTR.insertCell(2);
					var dt = new Date();
					//oTDL.style.width="210px";
					oTDL.style.width=ifaLogo.style.width;
					oTDL.appendChild(ifaLogo);
					oTDM.innerHTML=dt.toDateString() + "<br />" + ifaUserName + "<br />" + ifaUserEmail;
					logoDiv.style.width="100%";
					logoDiv.style.styleFloat="right";
					logoDiv.style.cssFloat="right";
					logoDiv.style.textAlign="right";					
					oTDR.appendChild(logoDiv);
               oTDR.style.textAlign="right";
					oTDR.style.styleFloat="right";
               
               if(!$('rightColumnHome') && !(document.URL.indexOf("/Factsheet.aspx?")>0) && !(document.URL.indexOf("/Tools.aspx")>0))
					{
						headDiv.style.width="980px";
						main.style.width="980px";
						if (footer) 
						{
							footer.style.width="980px";
						}
					}
					else
					{
						if (footer) 
						{
							if($('rightColumnHome')) footer.className = 'footerPrint';
							else footer.className = 'footerPrintBig';
						}
					}
					headDiv.appendChild(oTbl);
				}
				else
				{
					headDiv.appendChild(logoDiv);
					if (footer) 
					{
						if($('rightColumnHome')) footer.className = 'footerPrint';
						else footer.className = 'footerPrintBig';
					}
				}
			}
			else
			{
				headDiv.appendChild(logoDiv);				
				if (footer) 
				{
					if($('rightColumnHome')) footer.className = 'footerPrint';
					else footer.className = 'footerPrintBig';
				}
			}
			//******************************************
			// Code for UK print preview ends here
			//******************************************
        
        // Currency Div starts here        
        var curr='';        
        if(currency!=null)
        { 
			curr=currency.title;
        }
         
        var currImg='';
        var currImgWidth='66px';
        var currImgHeight='71px';
        
 
        switch(curr)
        {
            case 'Fund Currency': currImg='fundCurForPrint.jpg'; break;
            case 'UK Pound': currImg='poundForPrint.jpg'; break;
            case 'Euro Currency': currImg='euroForPrint.jpg'; break;
            case 'US Dollar': currImg='dollarForPrint.jpg'; break;
            case 'HK Dollar': currImg='HKDollarForPrint.jpg'; currImgHeight='64px'; break;
            case 'SG Dollar': currImg='SGDollarForPrint.jpg'; currImgHeight='64px'; break;
            default : currImg=''; break;
        }     
            
            var txtCurrDiv=document.createElement("DIV");
            var txtCurr=document.createElement("H1");
            
            var printCurr=null;
            
            if(currImg!='')
            {
                printCurr=document.createElement("IMG");
                printCurr.title=curr;
                printCurr.border="0";
                printCurr.src="/images/"+currImg;
                printCurr.style.width=currImgWidth;
                printCurr.style.height=currImgHeight;
                
                txtCurr.appendChild(document.createTextNode('All Performance figures are rebased to '+curr+'  '));
            }
            else
            {
                printCurr=document.createTextNode('  ');
                txtCurr.appendChild(document.createTextNode('  '));
            }
            
            txtCurrDiv.appendChild(txtCurr);
            txtCurrDiv.className='headerCurrPrintText';
            
           
            var currDiv=document.createElement("DIV");
            
            var currPrintDiv=document.createElement("DIV");
            currPrintDiv.className='headerCurrPrint';
            currPrintDiv.appendChild(printCurr);
            currDiv.appendChild(currPrintDiv);
            
            currDiv.appendChild(txtCurrDiv);
            currDiv.className='headerCurr';
            
            if(currImg=='')
            {   currDiv.style.height='58px';
            }
            
            if(emailSiteCode!="TNUK")
            {
					headDiv.appendChild(currDiv);    
				}
          // Currency Div ends here
        
           if($('rightColumnHome'))headDiv.className='headerPrint';
           else headDiv.className='headerPrintBig';
         
           main.insertBefore(headDiv,$('leftNav'));
           
           if($('ChartingMain')&&window.navigator.userAgent.indexOf("IE")==-1)
           {    main.insertBefore($('ChartingMain'),$('leftNav'));
           }
      }

        var leftColn = $('leftColumn');
        if (leftColn) {
            leftColn.style.display = 'none';
        }

		var quickSearch = $('QuickSearchStyle');
		if(quickSearch){
			quickSearch.style.display = 'none';
		}
        
        var articleRating=$('articleRating');
        if(articleRating)
        {
            articleRating.style.display='none';
        }
        
        var articleComment=$('articleComment');
        if(articleComment)
        {
            articleComment.style.display='none';
        }
        
        var rightColn = $('rightColumnHome');
        if (rightColn) {
            rightColn.style.display = 'none';
        }

        if($("userTypePopUp")) {
            closeInvestorSelector();
        }

        var topSearch=$("topSearchRow");
        if(topSearch) {
            topSearch.style.display = 'none';
        }

        var mainDiv=$('MainDiv');
        if(mainDiv){   
			mainDiv.style.display='none';
        }

      var calc=$('Calculator');
      if(calc) {   calc.style.display='none'; }

      var modeWindowDiv=$('ModeWindowDiv');
      if(modeWindowDiv) {
          modeWindowDiv.style.display='none';
      }

      var exRateCalc=$('ExRateCalc')
      if(exRateCalc) {
          exRateCalc.style.display='none';
      }

      var col=getElementsByClassName("rightColumnBig");
      if(col) {
        for(var i=0;i<col.length;i++) {
           if(col[i].style){ 
				col[i].style.display = 'none';
           }
        }
    }

   

    if (window.print) 
    { 
        if($('ChartingMain'))
        {
          if($('ChartImg').complete)
          {  
            window.print();
          }
          else
          {
              $('ChartImg').onload=function()
              {
                window.print();
              };
          
          }
            
        }
        else
        {  window.print();
         }   
    }
    
 }              
     

  //Get elements by class name  
  function getElementsByClassName(classname, node) 
  {

     if(!node)
     { node = document.getElementsByTagName("body")[0];

      }

     var a = [];

     var re = new RegExp('\\b' + classname + '\\b');

     if(node)
     {
         var els = node.getElementsByTagName("*");

         for(var i=0,j=els.length; i<j; i++)
         { 
           if(re.test(els[i].className))
           { a.push(els[i]);

           }

         }

     }

     return a;
  }
  

  if(getQueryValue('print')=='true')
  { 
      addLoadEvent(printThis); 
   }
 



//Check Numeric Values
function chkNumeric(objName)
{
	var checkOK = "0123456789. ";
	checkOK=checkOK;
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";

    var counter=0;
	for (i = 0;  i < checkStr.value.length;  i++)
	{
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
		
		if (ch == '.' )
		{
		 counter++;
		}
	}
	if(counter>1)
	{
	allValid = false;
	}
	if (!allValid)
	{	
		//alertsay = "Please enter only numeric values"
		//alertsay = alertsay +" in the "+ checkStr.name + " field."
		//alert(alertsay);
		return (false);
	}
}

function chkNumericMinus(objName)
{
	var checkOK = "0123456789.- ";	
	checkOK=checkOK;
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
   


   var counter=0;
    var counter1=0;
	for (i = 0;  i < checkStr.value.length;  i++)
	{
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		if (ch != ",")
		allNum += ch;
		if (ch == '-')
		{
		counter++;
		}
		if (ch == '.'  )
		{
		counter1++;
		}
	}
	if(counter>1)
	{
	allValid = false;
	}
	if(counter1>1)
	{
	allValid = false;
	}
	if (!allValid)
	{	
		alertsay = "Please enter only numeric values"
		//alertsay = alertsay +" in the "+ checkStr.name + " field."
		alert(alertsay);
		return (false);
	}
}


//Check Numeric Values
function chkNumericPercent(objName)
{
	var checkOK = "0123456789.% ";
	checkOK=checkOK;
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
    var counter=0;
       var counter1=0;
	for (i = 0;  i < checkStr.value.length;  i++)
	{
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
		if (ch == '%')
		{
		counter++;
		}
		if(ch == '.')
		{
		counter1++;
		}
	}
	if(counter>1)
	{
	allValid = false;
	}
	if(counter1>1)
	{
	allValid = false;
	}
	if (!allValid)
	{	
		alertsay = "Please enter only numeric values"
		//alertsay = alertsay +" in the "+ checkStr.name + " field."
		alert(alertsay);
		return (false);
	}
}

//Loading Shortlisted Values.
 function GetShortlistedItems()
 {
	var shortListedItems= new Array();
	var value = GetCookie("shortlisted");
	var cookieType = Mode;
	if($("NoOfShortListedItems")!=null)
	{
		if(value!=""){
		shortListedItems=value.split(',');		
		$("NoOfShortListedItems").innerHTML="("+shortListedItems.length+")";		
		}else{
		$("NoOfShortListedItems").innerHTML="(0)";	
		}
	}
	
 }
 
	
// Function will be triggred when any changes happened to the User Controls.
// Controls include Sector analysis, Top Risers and Fallers, Top Rated Fund and Sector Correlation
function onControlChange(ctrlName, universeCode, durationCode, previousUniverse, sortOrder, ddID)	{

		var eleFilterCode = $("hdn" + ctrlName + "FilterCode");
		var elePreviousUniv = $("hdn" + ctrlName + "PreviousUniverse");
		var eleUnivCode = $("hdn" + ctrlName + "UniverseCode");
		var eleDurationCode = $("hdn" + ctrlName + "DurationCode");
		var eleScroll = $("hdn" + ctrlName + "Scroll");
		var eleSortOrder = $("hdn" + ctrlName + "SortOrder");
		var eleYearCode = $("hdn" + ctrlName + "YearCode");		
		var eleCode = $("hdn" + ctrlName + "Code");	
		
		if(ctrlName!='SA') { 
		   if($(ddID) != null) {
			  eleFilterCode.value = $(ddID).value;		
		   }
		}
		else {
		   eleFilterCode.value = "";
		}
		if(ctrlName=='FM')
		{
		 eleCode.value=universeCode;
		}
		if(elePreviousUniv) {
			elePreviousUniv.value = previousUniverse;
		}
		
		if(eleUnivCode) {
			eleUnivCode.value = universeCode;
		}
		
		if(eleDurationCode) {
			eleDurationCode.value = durationCode;
		}
		
		if(eleScroll) {
			eleScroll.value = "1";			
		}	
		if(ctrlName=='SQ') { 	
		if(eleYearCode)
		{
		eleYearCode.value = durationCode;
		}
		}
		if(ctrlName!='TRF')	{
			if(eleSortOrder) 
			   eleSortOrder.value = sortOrder;		
		}
		var url = RemoveQueryString("ctr",document.URL)
		if(url.indexOf('?') > 0) {
			url += '&ctr='+ctrlName;
		}
		else {
			url += '?ctr='+ctrlName;
		}
		document.forms[0].action = url;
		document.forms[0].submit();
}

function RemoveQueryString(inpQueryStr,docUrl) {
	var index	 = docUrl.indexOf('?');
	var queryStr = (index != -1) ? docUrl.substring(docUrl.indexOf('?')+1) : '';
	var queryArr = queryStr.split('&');
	
	var url = docUrl.substring(0, (index == -1) ? docUrl.length : index);
	for(var i=0; i<queryArr.length; i++) {
		var qryParam = queryArr[i].split('=');
		if (qryParam[0] != inpQueryStr && qryParam[0] != '') {
			url += (url.indexOf('?') > 0) ? '&' + queryArr[i] : '?'+queryArr[i];
		}
	}
	return url;
}

/* * * * * * * * * Script for the page ShortList.ascx starts here * * * * * * * * */
var typeCodes = "";
var typeCodesNew = "";

// Function to clear all
function clearAll() {
	if($("emptyBasket")!=null && $("basketList")!=null ){
	$("emptyBasket").style.display = "block";
	$("basketList").style.display = "none";
	}
	var typecodes = GetCookie("shortlisted");
	DeHighlightRows(typecodes);
	DeleteCookie("shortlisted");
	DeleteCookie("TN_RetainSelected");
	GetShortlistedItems();
	return false;
}

//Function DeleteShortList
function delFromShortList(rowId, typecode) {
	removeRow(rowId, typecode);
	DeleteFromShortlist(typecode, "shortlisted");
	var valueNew = GetCookie("shortlisted");
		  GetShortlistedItems();
	DeleteFromShortlist(typecode, "TN_RetainSelected");
	
} 

//function to select all or deselect all
function selectChkbox(value) {
	var element = document.getElementsByName("ckShortList");
	var length = element.length;
	var selected = "";
	var spliter = "";
	
	for(var i=0; i < length; i++) {
		
		if(element[i].id != "ckShortList")
		{
			element[i].checked = value;
			selected += spliter + element[i].id;
			spliter = ",";
		}
	}
	
	if(value) {
		SetCookie("TN_RetainSelected", selected);
	} else {
		SetCookie("TN_RetainSelected", "");
	}
	return false;
}

// Function to remove row
function removeRow(rowId, typecode) {
	var elements = $("tableShortList");
	var len = elements.rows.length;
	var fundCount = 1;
	var unitCount = 0;
	
	for(var i = 0; i < len; i++) {
		
		currRow = elements.rows[i];
		
		if( currRow.id == rowId) 
		{
			currRow.style.display = "none";
			
			if(currRow.cells[1].id == "ckShortList" )
			{
				currCell = currRow.cells[1];
				checkBox =   currCell.getElementsByTagName("INPUT"); 
				var checkBoxId = checkBox[0].id;
				DeleteFromShortlist(checkBoxId, "TN_RetainSelected");
				DeleteFromShortlist(checkBoxId, "shortlisted");
				var valueNew = GetCookie("shortlisted");
				GetShortlistedItems();
				
			}
			
			
		}
		else if(currRow.cells[0].id == "fundCount" && currRow.style.display != "none" ) 
		{
			currRow.cells[0].innerHTML = fundCount + ".";
			fundCount++;
		} 
		else if(currRow.cells[1].id == "ckShortList"  && currRow.style.display != "none" ) 
		{
			unitCount++;	

		}
	}

	if(fundCount == 1) {
		clearAll();
	} else {
	
		var varUnit = (unitCount == 1)?"unit":"units";
		var varFund = (fundCount == 2)?"fund":"funds";
		$("showCount").innerHTML = "Showing " + unitCount +" " + varUnit + " of " + (fundCount - 1) + " "+ varFund;
	}
}

// Function for Next Page. 
	function showNextHome(page, Max, Min, title, parameters)
	{
		
		 typeCodes = GetCookie("TN_RetainSelected");
		 if(typeCodes=='')
		 {
		  typeCodes = GetCookie("shortlisted");
		 }
		 typeCodeArray=typeCodes.split(',');

		 if(typeCodeArray.length>=Min && typeCodeArray[0]!="")
		 {
			if((typeCodeArray.length>Max))
			{
				alert("You cant carry more than "+ Max +" values to "+ title);
			}
			else
			{
				window.location = page + "?typeCode=" + typeCodes + parameters;
			}
		 }
		 else
		 {
			if(title=="Multiplot" && Min<=1)
			{
			   window.location = page + "?typeCode=NUKX";
			}
			else
			{
			   //alert('No Funds in Basket. To add funds in Basket using "Green Plus Icon" wherever you see it next to a fund.');
			   alert('There are no funds in your basket. To add funds to your basket use the "Green Plus Icon" wherever you see it next to a fund.');
			}
		 }
	}
	
// Function for Next Page. 
function showNext(page, Max, Min, title, parameters) {

	typeCodes = shortList();
	var codes = GetCookie("shortlisted");
	var userId=GetCookie("TN_UserId");
	if(codes=='')typeCodes='';
	if(title=='DirectPortfolio')
	{
	typeCodes=codes;
	}
	if(codes == "" && title=='Portfolio' && userId=="")
	{	    
	    window.location ='/Tools/Portfolio/PortfolioLogin.aspx';
	}
	else if(codes != "" || title =="Multiplot") {	
		if(minValidation(Min)) {
			if(!maxValidate(Max)) {
				alert("You cant carry more than " + Max + " values to " + title);
			}
			window.location = page + "?typeCode=" + typeCodesNew + parameters;
		}
		else 
		{
			if(Min != 0)
			{			
				alert("You need atleast " + Min + " funds to see " + title);
			}
			else
			{
				window.location = page;
			}
		}
	} else {	
		//alert('No Funds in Basket. To add funds in Basket using "Green Plus Icon" wherever you see it next to a fund.');
		alert('There are no funds in your basket. To add funds to your basket use the "Green Plus Icon" wherever you see it next to a fund.');
	}
}

// Function for maxmum count validation
function maxValidate(count) {
	var typeCode = typeCodes.split(",");
	var len = typeCode.length;
	typeCodesNew  = "";
	var spliter = "";
	if(len > count) {
		for(var i = 0; i < count; i++) {
			typeCodesNew += spliter + typeCode[i];
			spliter = ",";
		}
		return false;
	} else {
		typeCodesNew = typeCode;
		return true;
	}
}

// Function for Minimum validation
function minValidation(count) {

	var typeCode = typeCodes.split(",");
	var len = typeCode.length;
	if(len < count || typeCodes == "") {
		return false;
	}
	
	return true;
}

// Getting the Selected Checkbox in ',' Separated Pair.
function shortList() {
	var element = document.getElementsByName("ckShortList");
	var typeCodes = "";
	var spliter = "";
	var len = element.length;
	for(var i=0; i< len; i++) {
		if(element[i].checked) {
			typeCodes += spliter + element[i].id;
			spliter = ",";
		}
	}
//	if(typeCodes=='' && element.length==0)
//	{
//	 typeCodes=GetCookie("shortlisted");   
//	}
	return typeCodes;
}

// Function to stored the selected checkbox values
// To retain.
function retainSelected(checked, typeCode) {
	var value = GetCookie("TN_RetainSelected");
	//if(value=='')value = GetCookie("shortlisted");
	var spliter =((value != "")?",":"");

	if(checked == true) {
		value +=  spliter + typeCode;
	} else {
		spliter = "";
		var typeCodes = new Array();
		typeCodes = value.split(",");
		var newCodes = "";
		for(var i = 0; i < typeCodes.length; i++) {
			if(typeCodes[i] != typeCode) {
				newCodes  +=  spliter + typeCodes[i];
				spliter = ",";
			}
		}
		value = newCodes;
	}

	SetCookie("TN_RetainSelected", value);
}

function Login()
{
	var userId=GetCookie("TN_UserId");
	if(userId == "") {			
		document.masterForm.action="/Tools/Portfolio/PortfolioLogin.aspx";
		document.masterForm.submit();
	}else{	
		document.masterForm.action="/Tools/Portfolio/PortfolioLogin.aspx?ch_logon=1";
		document.masterForm.submit();
	}
}

/* * * * * * * * * Script for the page ShortList.ascx ends here * * * * * * * * */

/* * * * * * * * * Script for User Pop-up starts here * * * * * * * * */

function setUser(selectedUT, page) {
	UpdateUserCookieByIPFn(selectedUT);
   SetCookie("invtype_client", selectedUT, 365);
	SetCookie("invtype", selectedUT, 365);
	$("invtype").value = selectedUT;
	closeInvestorSelector();
}

function UpdateUserCookieByIPFn(cookieVal)
{
	UpdateUserCookieByIPinDB('','invtype',cookieVal);
}

function closeInvestorSelector() {
	$("userTypePopUp").style.visibility = "hidden";
	$("investorSelectorIFrame").style.visibility = "hidden";
	return void(0);
}

function setTopPosition() {
	var elementTop = document.documentElement.scrollTop + (document.documentElement.clientHeight / 4);
	var elementLeft = document.documentElement.scrollLeft + (document.documentElement.clientWidth / 4) - 40;

	if (navigator.appName.indexOf("Microsoft") == -1) {
		$("userTypePopUp").style.top = elementTop + "px";
		$("investorSelectorIFrame").style.top = elementTop + "px";
		
		$("userTypePopUp").style.left = elementLeft + "px";
		$("investorSelectorIFrame").style.left = elementLeft + "px";
	} else {
		$("userTypePopUp").style.top = elementTop;
		$("investorSelectorIFrame").style.top = elementTop;
		
		$("userTypePopUp").style.left = elementLeft;
		$("investorSelectorIFrame").style.left = elementLeft;
	}
	
	if($("userTypePopUp").style.visibility == "visible") {
		setTimeout("setTopPosition()", 10);
	}
}

/* * * * * * * * * Script for User Pop-up ends here * * * * * * * * */

    
    // Customized go to page function
	function GoToPage(ctrlId, pageNo)
	{
		if($(ctrlId+"_pageNo"))
		{
			$(ctrlId+"_pageNo").value = pageNo;
		}
		document.masterForm.submit();
	}
	
	// Customized table sort function
	function Sort(ctrlId, sortedColumn)
    {
		 var isSameColumn = 0;
		 var columnEleID = $(ctrlId+"_sortedColumn");
	    if(columnEleID)
	    {
			 if(columnEleID.value == sortedColumn)
				isSameColumn=1;
		    columnEleID.value = sortedColumn;
	    }
	    var element = $(ctrlId+"_sortedDirection");
	    if(element)
	    {
			 var oppValue = (element.value.toUpperCase() == "ASC") ? "Desc" : "Asc";
		    element.value = (isSameColumn==1) ? oppValue : element.value;
	    }
	    //GoToPage(ctrlId,1);
	    SubmitControl(ctrlId)
    }
    
    function Sort(ctrlId, sortedColumn, defaultSortDirection)
    {
		 var isSameColumn = 0;
		 var columnEleID = $(ctrlId+"_sortedColumn");
	    if(columnEleID)
	    {
			 if(columnEleID.value == sortedColumn)
				isSameColumn=1;
		    columnEleID.value = sortedColumn;
	    }
	    var element = $(ctrlId+"_sortedDirection");
	    if(element)
	    {
			 var oppValue = (element.value.toUpperCase() == "ASC") ? "Desc" : "Asc";
			 defaultSortDirection = (typeof(defaultSortDirection)=='undefined') ? element.value : defaultSortDirection;
		    element.value = (isSameColumn==1) ? oppValue : defaultSortDirection;
	    }
	    //GoToPage(ctrlId,1);
	    SubmitControl(ctrlId)
    }
	
	// Filter submit
	function SubmitControl(ctrlId)
	{
		var index	 = document.URL.indexOf('?');
		var queryStr = (index != -1) ? document.URL.substring(document.URL.indexOf('?')+1) : '';
		var queryArr = queryStr.split("&");
		var url = document.URL.substring(0, (index == -1) ? document.URL.length : index);
		for(var i=0; i<queryArr.length; i++)
		{
			var qryParam = queryArr[i].split("=");
			var selectCtrls = $(ctrlId+"_selectCtrls");
			if(selectCtrls && qryParam[0] != ctrlId+"_sortedColumn" && qryParam[0] != ctrlId+"_sortedDirection" && qryParam[0] != "AddnFlt" && qryParam[0] != "Pf_Geoarea")
			{
				var pageCtrl = ctrlId+"_pageNo";
				if(selectCtrls.value.indexOf(qryParam[0]) < 0 && qryParam[0].toUpperCase() != pageCtrl.toUpperCase())
				{
					url += (url.indexOf("?") >= 0) ? "&" + queryArr[i] : "?"+queryArr[i];
				}
			}
			if(qryParam[0] == "AddnFlt")
			{
				var addnFilterQry = '';
				var addnQuery = qryParam[1].split("+AND+")
				for(var j=0;j<addnQuery.length;j++)
				{
					if( (addnQuery[j].indexOf('Fund.AssetClass')<0 && addnQuery[j].indexOf('Fund.FundInvestmentFocusList.InvestmentFocus')<0) )
					{
						addnFilterQry = (addnFilterQry.length > 0) ? '+AND+'+addnQuery[j] : addnQuery[j];
					}
				}
				url += (url.indexOf("?") >= 0) ? "&AddnFlt="+addnFilterQry : "?AddnFlt="+addnFilterQry;
			}
		}
		//$(ctrlId+"_pageNo").value=1;
		var selectFlt;
		var filters = $(ctrlId+'_selectCtrls');
		if(filters)
		{ 
			selectFlt = filters.value.split(',');
			for(var i=0;i<selectFlt.length;i++)
			{
				var selectCtrl = $(selectFlt[i]);
				if(selectCtrl && selectCtrl.value != "")
				{
					var textvalue = selectCtrl.id+"="+selectCtrl.value;
					url += (url.indexOf("?") >= 0) ? "&" + textvalue : "?"+textvalue;
				}
			}
		}
		var sort = $(ctrlId+'_sortedColumn')
		if(sort)
		{
			var textvalue = sort.id+"="+sort.value;
			url += (url.indexOf("?") >= 0) ? "&" + textvalue : "?"+textvalue;
		}
		sort = $(ctrlId+'_sortedDirection')
		if(sort)
		{
			var textvalue = sort.id+"="+sort.value;
			url += (url.indexOf("?") >= 0) ? "&" + textvalue : "?"+textvalue;
		}
		//window.location = url;
		
		//Code add for take hidden field values while submit page instead of window.location
        document.masterForm.action = url;
        document.masterForm.submit();
	}

	
   //change tab for factsheets	
   function ChangeTab(tab, page, tabCode)
   {
       $('pageno').value = page;
       $('CurrTab').value = tab;
       $('tabCode').value = tabCode;
       
       document.masterForm.submit();
   } 
   
    
    //Top Search dropdown change event
    function LoadGroupList() 
    {
      var universe = $("universe").options[$("universe").selectedIndex].value;
      
           
      document.forms[0].submit();
     }
	
    //Top Search goto Group Factsheet page
    function postGroup() 
    {
        var universe = $("universe").options[$("universe").selectedIndex].value;
        var group = $("group").options[$("group").selectedIndex].value;
        var URL = "/Factsheets/GroupFactSheet.aspx?managerCode="+group + "&univ=" + universe;
      
        document.location.href =URL;
        
    }
    
    //LoginControl in menubar
    
    
    
function AddDynamicInput()
{
	if($('divPass').innerHTML=="Password" && $('divUser').innerHTML=="Username/email")
	{

	$('ctl00_MenubarHome_beforeLoginRowhidden').style.display='block';
	$('ctl00_MenubarHome_beforeLoginRow1').style.display='none';
	   if(document.all)
	   {
	   $('txtUser').className='menuinputIE';
	   $('txtPass').className='menuinputIE';
	   if(window.navigator.userAgent.indexOf("MSIE 6.0")>=0)
	   {
	   currencyMenu.style.width='269px';
	   currencyMenu.style.height='56px';
	   currencyMenu.style.overflow='hidden';
	   }
	  
	   }
	   $('txtUser').focus();
	   
	}
}

function checkkey(txt,e)
{
    if(txt.id=="txtUser" || txt.id=="txtPass")
    {
    if(e.keyCode==13)
    {
      if(LoginCheckMenu())
       return true;
       else
       return false;
    }
    }
    else
    {
    return false;
    }
}
function CheckEmailAscii(objEmail,eMailEvent)
{
    if(objEmail.id=="txtForgotEmail")
    {	
	    if(eMailEvent.keyCode==13)
	    {			
		    CheckEmailEmpty();		
	    }
		    return true;		
    }
    return false;
}
function CheckEmailEmpty()
{	
	var emailId=$('txtForgotEmail');
	   if(emailId.value==null || emailId.value=="")
		{
			alert('Please Enter your Email ID(username)');
			emailId.focus();
			return false; 
		}  
		else if (echeck(emailId.value)==false){
			emailId.value="";
			emailId.focus();
			return false
		} 
		else
		{		
		document.masterForm.action='/Tools/Portfolio/ForgotPassword.aspx?flag=forgot';
		document.masterForm.submit(); 	 	
		}
}
//Script for forgotten Details
function checkForgottemEmail(objEmail,eMailEvent)
{	
	if(objEmail.id=="txtForgotEmail")
	{	
		if(eMailEvent.keyCode==13)
		{			
			sendEmail();		
		}			
	}
}
function sendEmail()
{	
	var emailId=$('txtForgotEmail');
	if(emailId.value==null || emailId.value=="")
		{
			alert('Please Enter your Email ID');
			emailId.focus();
			return false; 
		}   
		if (echeck(emailId.value)==false){
			emailId.value="";
			emailId.focus();
			return false
		}
		else
		{		
		document.masterForm.action='/Tools/Portfolio/ForgotPassword.aspx?flag=forgot';
		document.forms[0].submit(); 		
		}
}
//End of Script
function validateEmail(field)
{
var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
str = field.value;
if(str!=null){
       if(SiteCode=='TNUK')
       {
         return true;
       } 
      else if(str.match(emailRegEx))
       {
         return true;
       }
      else
       {
       alert('Please enter a valid email address.');
       field.focus();
       return false;
       }
  }
}

function LoginCheckMenu()
{

if($('ctl00_MenubarHome_beforeLoginRowhidden').style.display=='block')
{
var user=$('txtUser');
var pass=$('txtPass');
if(user.value!="")
{
   if(validateEmail(user))
   {
    if(pass.value!="")
    {
    $('boolLogin').value="login";
    document.masterForm.submit();
    }
    else
    {
     pass.focus();
     alert("Enter password");
     return false;
    }
   }
}
else
{
alert("Enter UserName");
user.focus();
return false;
}
}
//else
//{
//alert("Enter your email");
//return false;
//}

}
function LogoutMenu()
{
$('boolLogin').value="logout";
document.masterForm.submit();
}

function findiframeposition()
{
	if(window.navigator.userAgent.indexOf("MSIE 6.0")>=0)
	{
	  var position=getPosition("setperf");
	   //alert(position.x);
	   var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	   var st1 = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
	   if(position.x<927)
	   {
			if($("loginSubmenu"))
			{
				loginSubmenu.style.left=position.x-6;
				loginSubmenu.style.top=position.y+29;
				$('CurrencyMenuFrame').style.left=position.x-6;
			}
	   }
	   else
	   {
			if($("loginSubmenu"))
			{
				loginSubmenu.style.left='922px';
				$('CurrencyMenuFrame').style.left='922px';
				loginSubmenu.style.top='216px';
			}
	   }
	}
} 
function changestyle()
{

	var logged=$('boolLogin').value;
	var hidCount=0;
	var browsertype=window.navigator.userAgent;
	if(window.isOpera)
	{
	  $('txtUser').style.marginLeft='7px';
	  $('txtUser').style.border='0px';
	  $('txtPass').style.marginLeft='7px';
	  $('txtPass').style.border='0px';
	}
	var pos=getPosition("setperf"); 
	var top=document.body.clientTop?document.body.clientTop:0;
	top=top+parseInt(pos.y)+18;
	 if(browsertype.indexOf("Safari")>=0)
	 {
	 $('tdEmailL').style.width='70px';
	 $('tdEmailL').style.border='0px';
	 
	 }
      if(browsertype.indexOf("MSIE 6.0")>=0){
      currencyMenu.style.width="253px";
      $('subMenu').style.width="680px";}
       if(logged=="login")
          {
			if(document.all || browsertype.indexOf("Safari")>=0 )
			{
			   if($('loginSubmenuList'))
			   {
					var len=$('loginSubmenuList').children.length;
					for(i=1;i<=len;i++)
					{
					 var listid="listdynamic"+i;
					 var listElement = $(listid);
					 if(listElement)
						listElement.className=listElement.className+"IE";
					}
			   }

			  if(browsertype.indexOf("MSIE 7.0")>=0)
			  {
				 if($('CurrencyMenuFrame'))
				 {
					 if(emailSiteCode!="TNUK")
					 {
					  $('mnuCurrentCurrency').style.paddingBottom='2px';
					 }
					 var position=getPosition("CurrencyMenuFrame");
					 $('CurrencyMenuFrame').style.top=position.y-4;
					 $('CurrencyMenuFrame').style.left=position.x+8;
			    }
			  }     
			   if(browsertype.indexOf("MSIE 6.0")>=0)
			   {   
			   var position=getPosition("CurrencyMenuFrame");
			   
			   if($("loginSubmenu"))
				{
					loginSubmenu.style.left=position.x;
					loginSubmenu.style.top=position.y+8;
	//			   if(emailSiteCode=="TNME")
	//			   {
	//			   loginSubmenu.style.left=position.x+20;
	//			   loginSubmenu.style.top=position.y+10;
					loginSubmenu.style.marginTop="-14px";
					loginSubmenu.style.marginLeft="3px";
	//			   }
					currencyMenu.style.width="253px";
					$('subMenu').style.width="680px";
					$('CurrencyMenuFrame').style.top=position.y;
					$('CurrencyMenuFrame').style.width="253px";
					loginSubmenu.style.width="187px";
					loginSubmenu.style.styleFloat="none";
					loginSubmenu.style.zIndex="99999";
					loginSubmenu.style.position="absolute";
					loginSubmenuList.style.marginRight="0px";
					loginSubmenuList.style.styleFloat="none";
			   }
			   for(i=1;i<=len;i++)
			   {
			    var listid="listdynamic"+i;
			    var listElement = $(listid);
			      if(listElement)
			       {
					listElement.style.marginLeft="-15px";
					listElement.style.width="160px";
				   }
			   }
			    
			   } 	
			}
			else
			{ 
			  
			  $('mnuCurrentCurrency').style.paddingBottom='2px'; 
			  if($('CurrencyMenuFrame'))
				$('CurrencyMenuFrame').style.top=top+19+"px";
			  
			}
         }
}
function CreateIframe()
{
         if(window.navigator.userAgent.indexOf("MSIE 6.0")>=0)
         {
            var objcurrencyMenu=$('currencyMenu');
			var ele = document.createElement('iframe');
			ele.tabIndex = '-1';
			ele.src = 'javascript:false;';
			objcurrencyMenu.appendChild(ele);
			ele.style.top="198px";
			ele.style.height="198px";
			ele.style.width="184px";
			ele.style.marginRight="100px";
			ele.style.left="922px";
			ele.style.position="absolute";
			ele.style.className='mainLoginDiv';
			}	
}
function RemoveIframe()
{  
   if(window.navigator.userAgent.indexOf("MSIE 6.0")>=0)
         {
        var objcurrencyMenu=$('currencyMenu');
        var layers = objcurrencyMenu.getElementsByTagName('iframe');
	     while(layers.length > 0)
	      {
		layers[0].parentNode.removeChild(layers[0]);
	      }
	     }
}

//End of login menu control


//Basket Box

function AddToWatchList(typecode)
{
		//var value = GetCookie(userId+"watch");	
		var count=$("NoOfWatchlistItems");		
        var isCodeRemoved = false;       
		 if(WatchtypeCodes != "")
		 {
		  var farray = new Array();
		  farray = WatchtypeCodes.split(',');		  
        if(!IsStringFoundInArray(farray, typecode))
        {
            WatchtypeCodes += ","+typecode;      
        }
        else
        {
			DeleteFromShortlist(typecode, userValue+"watch");
			DeleteFromDB(typecode,WatchtypeCodes);
			//SetCookie(userId+"watch",WatchtypeCodes,123231);
			//DeleteFromShortlist(typecode, "TN_RetainSelected");			
			isCodeRemoved = true;
        }
    }
    else
    {
        WatchtypeCodes = typecode;    
    }
    if(!isCodeRemoved)
    {
		SetCookie(userValue+"watch", WatchtypeCodes, 123231);		
		AddWatchlistFundDisplay(userValue,univValue,typecode,SiteCode);
		count.innerHTML=parseInt(count.innerHTML)+1;
	    //retainSelectedVal(typecode);
    BasketPopup('visible',typecode,'Watchlist');	
    }
    else
    {	
        RemoveWatchlistFundDisplay(userValue,typecode,SiteCode);
        DeHighlightRows(typecode);        
        count.innerHTML=parseInt(count.innerHTML)-1;	
        if($('curPopup')!=null)
		{
			   var currentPopup=$('curPopup').value;
			  var basket= $('BasketPopup'+currentPopup)
			  if(basket!=null)
			  {
			   basket.style.visibility='hidden';
			   $("BasketPopupFrame").style.visibility='hidden';  
			  }	
		}
    }	
	HighLightSelectedRows();
}
	 
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return  scrOfY ;
} 

function AddToPortfolio(typecode)
{
	   //var value = GetCookie(userId+"portfolio"); 
	  // value=PorttypeCodes;
	   var count=$("NoOfPortfolioItems");		    
       var isCodeRemoved = false;     
	   if(PorttypeCodes != "")
	   {
        var farray = new Array();
        farray = PorttypeCodes.split(',');     
		
        if(!IsStringFoundInArray(farray, typecode))
        {
            PorttypeCodes += ","+typecode;            	            
           
        }
        else
        {    	
			DeleteFromShortlist(typecode, userValue+"portfolio");	
			DeleteFromDB(typecode,PorttypeCodes);
			//SetCookie(userId+"portfolio",PorttypeCodes,123231);
			//DeleteFromShortlist(typecode, userId+"portfolio");
			isCodeRemoved = true;
        }
    }
    else
    {				
        PorttypeCodes = typecode;                      
    }
    if(!isCodeRemoved)
    {	  
      AddPortfolioFundDisplay(pId,userValue,univValue,typecode);
	  SetCookie(userValue+"portfolio", PorttypeCodes, 123231);		 
	  count.innerHTML=parseInt(count.innerHTML)+1;
	  BasketPopup('visible',typecode,'Portfolio',portNameLong);	    
    }
    else
    {   
      RemovePortfolioFundDisplay(pId,userValue,typecode); 
	  DeHighlightRows(typecode);
	  count.innerHTML=parseInt(count.innerHTML)-1;
	   if($('curPopup')!=null)
	   {
	       var currentPopup=$('curPopup').value;
		   var basket= $('BasketPopup'+currentPopup)
		   if(basket!=null)
		   {
		    basket.style.visibility='hidden';
		    $("BasketPopupFrame").style.visibility='hidden';  
	    }
		}
    }
	HighLightSelectedRows();
}
	 

function clearPortfolio()
{	
   var typecodes = GetCookie(userValue+"portfolio");  
   DeHighlightRows(typecodes);
   DeleteCookie(userValue+"portfolio");	
   GetPortfolioItems(userValue+'portfolio');	
}
	 
	
function clearWatchlist()
 {	   
	var typecodes = GetCookie(userValue+"watch");
	var ele=$("WatchlistbasketBox");
    ele.style.display="none";
	DeHighlightRows(typecodes);
	DeleteCookie(userValue+"watch");	
	GetPortfolioItems(userValue+'watch');				
 }
	 
	 //Loading Shortlisted Values.
 function GetPortfolioItems(cookie)
 {
	var shortListedItems= new Array();
	var value = GetCookie(cookie);	
	if(cookie==userValue+"watch"){		
      $("NoOfWatchlistItems").innerHTML="(0)";	
    }else{
     $("NoOfPortfolioItems").innerHTML="(0)";	
    }
 }
 
	 // Function for Next Page. 
function showNextPortfolio(page,cookie,Max, Min, title, parameters)
{

	//typeCodes = shortList();
	typeCodes = GetCookie(userId+cookie);		
	if(typeCodes != "" || title =="Multiplot") {	
		 if(minValidation(Min)) {
			if(!maxValidate(Max)) {
				alert("You cant carry more than " + Max + " values to " + title);
			}
			//if(title!='DirectPortfolio')
			//{			
			//DeleteCookie(cookie);
				
		    SetCookie("TN_Mode", "General", 123231);
		    SetCookie(userId+cookie, "", 123231);
		     
			document.masterForm.action = page + "?typeCode=" + typeCodes + parameters;
			document.masterForm.submit();
		}
		else 
		{
			if(Min != 0)
			{			
				alert("You need atleast " + Min + " funds to see " + title);
			}
			else
			{
				window.location = page;
			}
		}
	} else {
		//alert('No Funds in Basket. To add funds in Basket using "Green Plus Icon" wherever you see it next to a fund.');
		alert('There are no funds in your basket. To add funds to your basket use the "Green Plus Icon" wherever you see it next to a fund.');
	}
}

function clearBasket()
{
	   clearAll();
	   return;
}

//function OpenMode()
//{
//  var wnd = $("ModebasketDiv");		  
//  var postion=getPosition("BasketHead");	
//  wnd.style.position="absolute";
//  wnd.style.display = "block";
//  wnd.style.visibility = "visible";	  	  
//  //clearTimeout(CTO);
////  CTO = setTimeout("Hide()",5000);	  
//  var left=postion.x+133+"px";
//  wnd.style.left =left;
//  wnd.style.top =postion.y+13+"px";	   			
//  if($("hdnmode")!=null)
//  {	
//	var id=$("hdnmode").value;	
//	var rdoMode = $(id);
//	if(rdoMode)
//	  rdoMode.checked=true;
//  }  
//}
//function ModeShade(ctl)
//{
//	ctl.style.background="#a7c7e7";
//}

//// Remove Shading while Cursor Out for mode window.
//function ModeReShade(ctl)
//{
//	ctl.style.background="";
//}

function AutoHide(e)
{

                var logged=$('boolLogin').value;
                if(logged=="login")
                {
                 
					if(document.all)
					{
					   if(event.srcElement.tagName!="HTML")
					   {
					   if(event.srcElement.parentElement!=null){
						var tagn=event.srcElement.parentElement.id;
						      
							  if(event.srcElement.id=="setperf" || event.srcElement.id=="loginSubmenu" ||tagn=="loginSubmenu" || tagn=="loginSubmenuList" ||tagn=="listdynamic1" ||tagn=="listdynamic2" ||tagn=="listdynamic3" 
							   || tagn=="listdynamic4" || tagn=="listdynamic5" ||tagn=="rdofundCurrency" ||tagn=="rdopoundCurrency" ||tagn=="rdoeuroCurrency" ||tagn=="rdodollarCurrency" ||tagn=="rdoHKDCurrency" ||tagn=="rdoSGDCurrency" ||tagn=="rdorupeesCurrency"
							  ||event.srcElement.id=="rdoHKDollar"||event.srcElement.id=="rdoSGDollar" ||event.srcElement.id=="rdoLocal" ||event.srcElement.id=="rdoLocal" ||event.srcElement.id=="rdoDollar" || event.srcElement.id=="rdoEuro"||event.srcElement.id=="rdoPound" ||event.srcElement.id=="rdoRupees" )
								{
								 
								  $('loginSubmenu').style.display='block';$('CurrencyMenuFrame').style.visibility='visible';
								 findiframeposition();
								}
								else
								{
								
								try
								{
								$('loginSubmenu').style.display='none';$('CurrencyMenuFrame').style.visibility='hidden';
								}
								catch(e)
								{
								}
								}
							}
						}
					}
				}				
// var postion=getPosition("userLeftBox");	
// var left=postion.x+125;
// 
// var top=postion.y-20;
// var x=0;
// var y=0;
// var y1=getScrollXY();	 
// if (IE) { // grab the x-y pos.s if browser is IE
//   x = event.clientX;
//   y = event.clientY+y1;
// }
// else {  // grab the x-y pos.s if browser is NS
//   x = e.pageX;
//   y = e.pageY;
// }
// 

// if(x<(left) ||  x>(left+140) ) 
// {
// Hide();
// }
// if( y<(top) || y>(top+110))
// {
// Hide();
// }
}

function ChangeModeBasket()
{   
	 var element=document.getElementsByName("BMode");
	 var value="";
	 for(var i=0;i<element.length;i++){   
	   if(element[i].checked){
		  value=element[i].value;   		  
		  $("hdnmode").value=element[i].id;		  		 
	   }
    }     
	 SetCookie("TN_Mode", value, 123231);
	 document.masterForm.submit();
}
	 
function CloseMode()
{
 SetCookie("TN_Mode", "General");
 document.masterForm.submit();
}	 

function Hide()
{
	 var wnds = $("ModebasketDiv");	 
	 wnds.style.visibility = "hidden";
}	


function DiplayBasket()
{
   var mode = GetCookie("TN_Mode");
   if(mode == "")
   {
	SetCookie("TN_Mode", "General", 123231);
   }
	if($("NoOfShortListedItems")!=null){		
        var value = GetCookie("shortlisted");
		var farray = new Array();
		farray = value.split(',');	
		if(value!="")
		{	
		$("NoOfShortListedItems").innerHTML="("+farray.length+")";     
		}else{
		$("NoOfShortListedItems").innerHTML="(0)";  
		}
	 }      
    
}

//Portfolio

function MatrixChange()
{
	$("hdnRow").value=$("Row").value;
	$("hdnColumn").value=$("Column").value;		 
	document.masterForm.submit();		 
}		 
function deleteReport(portID,delReport,delFrequency)
{
	$("delportID").value=portID;
	$("delReport").value=delReport;
	$("delFrequency").value=delFrequency;
	document.masterForm.submit(); 
}	
function onChangeFund(page)
{

var elementValue=document.getElementsByName("value");
var element=$("Currency");
var elementFund=document.getElementsByName("selectFunds");
var elementAlert=document.getElementsByName("selectAlerts");
var elementprice=document.getElementsByName("pricevalue");

var values="";
var valuepercent="";
var valuesPrice="";
var alerts="";
var typeCodes="";
var Currency;
for(var i=0;i<elementValue.length;i++)
{
	if (chkNumericMinus(elementValue[i]) == false || elementValue[i].value=="" )
	{
		 return false;
	}
	else{
		 if(i==(elementValue.length-1))
		 {
		 values+=elementValue[i].value;
		 }else{
		 values+=elementValue[i].value+",";
		 }
   }
}

for(var i=0;i<elementprice.length;i++)
{
   if (chkNumericMinus(elementprice[i]) == false || elementprice[i].value=="")
	{
		 return false;
	}
	else{
		 if(i==(elementprice.length-1))
		 {
		 valuesPrice+=elementprice[i].value;
		 }else{
		 valuesPrice+=elementprice[i].value+",";
		 }
   }
}


for(var i=0;i<elementFund.length;i++)
{
   if(i==(elementFund.length-1))
   {
   typeCodes+=elementFund[i].options[elementFund[i].selectedIndex].value;
   }else{
   typeCodes+=elementFund[i].options[elementFund[i].selectedIndex].value+",";
   }
}

for(var i=0;i<elementAlert.length;i++)
{
   if(i==(elementAlert.length-1))
   {
   alerts+=elementAlert[i].options[elementAlert[i].selectedIndex].value;
   }else{
   alerts+=elementAlert[i].options[elementAlert[i].selectedIndex].value+",";
   }
}
   $("alert").value=alerts;
   if(element)Currency=element.options[element.selectedIndex].value;
   $("values").value=values;
   $("pricevalues").value=valuesPrice;
   $("hdnCurrency").value=Currency;
   $("typecode").value=typeCodes;

   if(page=='add')
   {
   document.masterForm.action="portfoliosAlert.aspx?type=1"
   }
   else if(page=='addprice'){
   document.masterForm.action="portfoliosAlert.aspx?type=2"
   }
   document.masterForm.submit();
   }

function delFundsList(hdnDelete1)
{
  var confirmmessage = "Are you sure you want to delete?";
  var cancelmessage = "Action Cancelled";
  if (confirm(confirmmessage)) {
  $("hdnDelete").value=hdnDelete1;
  document.masterForm.submit(); 
  }
}

function delFundPriceList(hdnDelete)
{
  $("priceDelete").value=hdnDelete;
  document.masterForm.submit(); 
}

function onChangeValue()
{
  var valuePercent=document.getElementsByName("valuePercents");  
	if (chkNumericPercent(valuePercent[0]) == false)
	   {
		 return false;
	   }
	else{
		  var value=valuePercent[0].value.split("%");		  		  		  
		  var currentValue=$("CurrentValue").innerHTML.replace(',','');  
		  var condition=$("selectType");
		  var result=parseInt(+(parseFloat(value)* parseFloat(currentValue))/100);
				if(value!=""){  
		  if(condition.value=='>=')
		  {  
		  $("value").value=CORE((parseFloat(currentValue)+result),2);
		  }else{
		  $("value").value=CORE((parseFloat(currentValue)-result),2);
		  }		  
       }
     }
}
 
function onChangePriceValue()
{
  var valuePercent=document.getElementsByName("pricePercentValues");  
  var condition=document.getElementsByName("selectCondition");
  var pricevalue=document.getElementsByName("pricevalue");
 // var Totalvalue=document.getElementsByName("PriceTotalValue");
   
  for(var i=0;i<valuePercent.length;i++)
   {
	if (chkNumericPercent(valuePercent[i]) == false)
	   {
		 return false;
	   }
    else{ 
		  var value=valuePercent[i].value.split("%");
		  var currentValue= $("Curr"+i).innerHTML.replace(',','');    
		  var result=parseInt((parseFloat(value)* parseFloat(currentValue))/100);
		  if(value!="")
		  {  
		  if(condition[i].value=='>=')
		  {
		  pricevalue[i].value=CORE((parseFloat(currentValue)+result),2);
		  }else{  
			   pricevalue[i].value=CORE((parseFloat(currentValue)-result),2);
		  }
          }
        }
   }
} 
	 
function onChangeFundAlert(page)
{
var element=document.getElementsByName("selectFunds");
var elementAlert=document.getElementsByName("selectAlerts");
var elementValue=document.getElementsByName("value");
var typeCodes="";
var alerts="";
var values="";
   for(var i=0;i<element.length;i++)
   {
	   if(i==(element.length-1))
	   {
	   typeCodes+=element[i].options[element[i].selectedIndex].value;
	   }else{
	   typeCodes+=element[i].options[element[i].selectedIndex].value+",";
	   }
   }
   for(var i=0;i<elementAlert.length;i++)
   {
	  if(i==(elementAlert.length-1))
	  {
	  alerts+=elementAlert[i].options[elementAlert[i].selectedIndex].value;
	  }else{
	  alerts+=elementAlert[i].options[elementAlert[i].selectedIndex].value+",";
	  }
   }
   for(var i=0;i<elementValue.length;i++)
   {
   if (chkNumericMinus(elementValue[i]) == false || elementValue[i].value=="" )
	{
		 return false;
	}
	else{
	  if(i==(elementValue.length-1))
	  {
	  values+=elementValue[i].value;
	  }else{
	  values+=elementValue[i].value+",";
	  }
	  }
   }
   $("values").value=values;
   $("typecode").value=typeCodes;
   $("alert").value=alerts;
   if(page=='add')
   {
   document.masterForm.action="alerts.aspx?type=1"
   }
   document.masterForm.submit();
}

function delFundPriceListAlert(hdnDelete)
{
  $("priceDelete").value=hdnDelete;
  document.masterForm.submit(); 
}

function onChangePriceValueAlert()
{
  var valuePercent=document.getElementsByName("pricePercentValues");  
  var condition=document.getElementsByName("selectType");
  var pricevalue=document.getElementsByName("value");
  //var Totalvalue=document.getElementsByName("PriceTotalValue");
   
  for(var i=0;i<valuePercent.length;i++)
   {
	  if (chkNumericPercent(valuePercent[i]) == false)
	  {
	   return false;
	  }
	  else
	  { 
		var value=valuePercent[i].value.split("%");
		var currentValue=$("Curr"+i).innerHTML.replace(',','');    
		var result=((parseFloat(value)* parseFloat(currentValue))/100);  
		if(value!="")
		{
		  if(condition[i].value=='>=')
		  {
		  var target=parseFloat(currentValue)+result;
		  pricevalue[i].value=CORE(target,2);
		  }else{  
		  var target=parseFloat(currentValue)-result;
		  pricevalue[i].value=CORE(target,2);
		  }
	     }
	   }
    }
}
  
  function CORE(X, N) { // X to String with N decimal places
  var int = Math.floor(X), frc = ((X-int)+1.0) * Math.pow(10, N)
  frc = String(IntFrc(frc,N)) // Put chosen rounding algorithm here
  return (int + +(frc.charAt(0)=="2")) + '.' + frc.substring(1)
   }

function IntFrc(frc,CaseNo) { // often for X > -0.5e-N
  with (Math) switch (CaseNo) {
    case 0 : // Trunc
      return floor(frc)
    case 1 : // Round
      return round(frc)
    case 2 : // Alternate Round
      if (frc%1 >= 0.5) frc++ ; return frc | 0
    case 3 : // Simple Bankers'
      return frc%1 != 0.5 ? round(frc) : 2*round(frc/2)
    case 4 : // Better Bankers'
      return NearHalf(frc) ? 2*round(frc/2) : round(frc)
    case 5 : // Double-round
      if (NearHalf(frc)) frc = round(2*frc)/2 ; return round(frc)
    case 6 : // Ceil
      return ceil(frc)
    case 7 : // Statistical
      return (frc + random()) | 0
    default : return " TypeError" } }


  
function getPosition(elementId)
 {
   var element = $(elementId);
   var left = 0;
   var top = 0;
   var width = 0; 
   var height = 0;
     
   if (element != null)
   {
       // Try because sometimes errors on offsetParent after DOM changes.
       try
       {
            width= element.offsetWidth;
            height= element.offsetHeight;
            while (element.offsetParent)              {
               // While we haven't got the top element in the DOM hierarchy
               // Add the offsetLeft
               left += element.offsetLeft;
               // If my parent scrolls, then subtract the left scroll position
               if (element.offsetParent.scrollLeft) {left -= element.offsetParent.scrollLeft; }               
               // Add the offsetTop
               top += element.offsetTop;
               // If my parent scrolls, then subtract the top scroll position
               if (element.offsetParent.scrollTop) { top -= element.offsetParent.scrollTop; }
               // Grab
               element = element.offsetParent;
              }
       }

       catch (e)
       {
              // Do nothing
       }
	
	  // Add the top element left offset and the windows left scroll and subtract the body's client left position.
	 left += element.offsetLeft + document.body.scrollLeft - (document.body.clientLeft?document.body.clientLeft:0);



	 // Add the top element topoffset and the windows topscroll and subtract the body's client top position.

	 top += element.offsetTop + document.body.scrollTop - (document.body.clientTop?document.body.clientTop:0);
	 
	  }

   return {x:left, y:top , w:width , h:height};
 }
 
 
 // Function to load sectors based on universe and assetclass
function qsLoadSector(val)
{		
   var selUnivEleID = $("qsUniverseDD");
   var assetClassCtrl = $("qsAssetClassDD");
   
   // Skip this code when both the element doesn't exit
   if(assetClassCtrl && selUnivEleID)
   {
	  // Assigning values of the dropdown boxes to a local variable
	  var assetClass = assetClassCtrl.options[assetClassCtrl.selectedIndex].text;
	  var universe=selUnivEleID[selUnivEleID.selectedIndex].value;
	  var isSecRequired = universe.substring(universe.toString().indexOf(":")+1,universe.toString().length);
	  universe=universe.substring(0,universe.toString().indexOf(":"));
	  var sectorDDCtrl=$("qsSectorsDD");
	  
	  if(isSecRequired=="True")
	  {
		 // To Load Sectors in a local variable using Ajax Pro Method
		 var Sector=TrustnetX.Controls.QSearch.LoadSectorsByAssetClass(universe, assetClass);	  
		 Sector=Sector.value;		 
   	  
		 // Skip this code when this element doesn't exit	  
		 if(sectorDDCtrl)
		 {
			sectorDDCtrl.disabled=false;
			sectorDDCtrl.options.length=0;
			var optionElement=document.createElement("option");
			optionElement.text="All Sectors";
			optionElement.value="";
			sectorDDCtrl.options.add(optionElement);
   		 
			// Skip this code when Sector array is null
			if(Sector)
			{
			   // Loop to add all the Sectors in Sector Dropdown box
			   for(i=0;i<Sector.length;i++)
			   {
				  if(Sector[i]!=null) {
					 optionElement=document.createElement("option");
					 optionElement.text=Sector[i].SectorName;
					 optionElement.value=Sector[i].SectorClassCode;
					 sectorDDCtrl.options.add(optionElement);
				  }
			   }
			}
		 }
	  }
	  else
	  {
		 sectorDDCtrl.value="";
		 sectorDDCtrl.disabled=true;		 
	  }
	  
	  // To load managers based on universe
	  if(val=="univ")
	  {	  
		 qsLoadManangers(universe);
		 qsLoadDomiciles(universe);
	  }
   }
}   


// Function to load Managers based on the universe code
function qsLoadManangers(univ)
{
   var universe=univ;
   
   // Skip this code when this element doesn't exit   
   if($("qsManagerDD"))
   {
	  // To Load Manager in a local variable using Ajax Pro Method
	  var Manager=TrustnetX.Controls.QSearch.LoadManagersByUniverse(universe);
	  Manager=Manager.value;
	  
	  // If no manager loaded then skip
	  if(Manager!=null)
	  {		 
		 var selectmanagers=$("qsManagerDD");
		 selectmanagers.options.length=0;
		 var ele=document.createElement("option");
		 ele.text= "All Managers";
		 ele.value="";
		 selectmanagers.options.add(ele);
		 
		 // Loop to add all Managers in the Manager Dropdown box
		 for(i=0;i<Manager.length;i++)
		 {
			if(Manager[i]!=null){
			   var ele=document.createElement("option");
			   ele.text=Manager[i].ManagerName;
			   ele.value=Manager[i].ManagerCode;
			   selectmanagers.options.add(ele);
			}
		 }
	  } 
   }       
}


// Function to load Domicile based on the universe code
function qsLoadDomiciles(univ)
{
   var universe=univ;
   
   // Skip this code when this element doesn't exit   
   if($("qsDomicileDD"))
   {
	  // To Load Domicile in a local variable using Ajax Pro Method
	  var Domicile=TrustnetX.Controls.QSearch.LoadDomocilesByUniverse(universe);
	  Domicile=Domicile.value;
	  
	  // If no Domicile loaded then skip
	  if(Domicile!=null)
	  {		 
		 var selectdomicile=$("qsDomicileDD");
		 selectdomicile.options.length=0;
		 var ele=document.createElement("option");
		 ele.text= "All Domiciles";
		 ele.value="";
		 selectdomicile.options.add(ele);
		 
		 // Loop to add all Domicile in the Domicile Dropdown box
		 for(i=0;i<Domicile.length;i++)
		 {
			var ele=document.createElement("option");
			ele.text=Domicile[i].DomicileName;
			ele.value=Domicile[i].DomicileCode;
			selectdomicile.options.add(ele);
		 }
	  } 
   }       
}


// Function executes when Go button in the quick search is click
function qsGoButton_Click()
{
   // Assigning the elements in the local variable
   var selUnivEleID = $("qsUniverseDD");
   var selACEleID = $("qsAssetClassDD");
   var selSectorEleID = $("qsSectorsDD");
   var selDomicileEleID = $("qsDomicileDD");
   var selManagerEleID = $("qsManagerDD");
   
   
   // Skip this code when both the element doesn't exit
   if(selUnivEleID)
   {
	  // Extracting universe code from universe dropdown
	  var universe=selUnivEleID[selUnivEleID.selectedIndex].value;
	  universe=universe.substring(0,universe.toString().indexOf(":"));
	  
		var qsURL = "/Investments/Perf.aspx?univ=" + universe + "&";
		qsURL += UpdateQSQryStr("Pf_AssetClass",selACEleID[selACEleID.selectedIndex].value);
		qsURL += UpdateQSQryStr("Pf_Sector",selSectorEleID[selSectorEleID.selectedIndex].value);
		qsURL += UpdateQSQryStr("Pf_Domicile",selDomicileEleID[selDomicileEleID.selectedIndex].value);
		qsURL += UpdateQSQryStr("Pf_Manager",selManagerEleID[selManagerEleID.selectedIndex].value);
		qsURL = qsURL.substring(0,qsURL.toString().length-1);
	  
	   window.location = qsURL;
	  // Assigning the values of the dropdown box to the hidden variables 
	  /*$("Pf_AssetClass").value=selACEleID[selACEleID.selectedIndex].value;
	  $("Pf_Sector").value=selSectorEleID[selSectorEleID.selectedIndex].value;
	  $("Pf_Domicile").value=selDomicileEleID[selDomicileEleID.selectedIndex].value;
	  $("Pf_Manager").value=selManagerEleID[selManagerEleID.selectedIndex].value;

	  // Submitting the form using Post method
	  document.forms[0].action="/Investments/Perf.aspx?univ=" + universe;
	  document.forms[0].submit();*/
   }
}

// To update quicksearch querystring parameters
function UpdateQSQryStr(str,val)
{
	if(val=="")
	{
		return "";
	}
	else
	{
		return str + "=" + val + "&";
	}
}


/// Checking the control for checkbox
function IsCheckBox(chk)
{
    return (chk.type == 'checkbox');
}

/// Checking the control for radio button
function IsRadio(chk)
{
   return (chk.type == 'radio');
}

function LoadSectorsByUniv(univ, sectorDDId, selectedValue)
{
	// To Load Sectors for universe using Ajax Pro Method
	var Sectors=TrustnetX.Tools.TopQuartiles.LoadSectorsByUniv(univ);	  
	Sectors = Sectors.value;
	var sectorDD = $(sectorDDId);
	if(sectorDD)
	{
		sectorDD.disabled=false;
		sectorDD.options.length=0;
		var optionElement=document.createElement("option");
		optionElement.text="All Sectors";
		optionElement.value="";
		sectorDD.options.add(optionElement);
	 
		// Skip this code when Sector array is null
		if(Sectors)
		{
		   // Loop to add all the Sectors in Sector Dropdown box
		   var selectedIndex = 0;
		   for(i=0;i<Sectors.length;i++)
		   {
			  if(Sectors[i]!=null) {
				 optionElement=document.createElement("option");
				 optionElement.text=Sectors[i].SectorName;
				 optionElement.value=Sectors[i].SectorClassCode;
				 sectorDD.options.add(optionElement);
				 if(Sectors[i].SectorClassCode == selectedValue)
					selectedIndex = i;
			  }
		   }
		   if(selectedValue!="")
		   sectorDD.value = selectedValue;
		}
	}
}
function btnTQSearch_Click()
{
	var sectorDD = $('TQSector');
	var crownDD = $('TQCrownRating');
	var loadUnits = $('hdnTQLoadUnits');
	loadUnits.value = 1;
	if(sectorDD)
	{
		$('hdnTQSector').value = sectorDD.options[sectorDD.selectedIndex].value;
	}
	if(crownDD)
	{
		$('hdnTQCrownRating').value = crownDD.options[crownDD.selectedIndex].value;
	}
	SelectTopQuartileColumns();
}
function SelectTopQuartileColumns()
{
    var radioIds = "";
    var columnIds = "";
    var isOthrThanMandatorySel = false;
    var elements = document.getElementsByTagName("INPUT");
    var univCode="";
	for(var i=0;i<elements.length;i++)
    {
       if(IsCheckBox(elements[i]))
	    {
	        if(elements[i].checked == true)
	        {
	            columnIds += (columnIds.length > 0) ? ","+elements[i].id : elements[i].id;
	        }
	    }
	    if(IsRadio(elements[i]))
	    {
	        if(elements[i].checked == true)
	        {
	            if(elements[i].name.indexOf("FundRadio")>=0)
	            {
	            radioIds += (radioIds.length > 0) ? ","+elements[i].id : elements[i].id;
	            univCode=$(elements[i].id).value;
	            }
	            if(elements[i].name.indexOf("radioquartile")>=0)
	            {
	            radioIds += (radioIds.length > 0) ? ","+elements[i].id : elements[i].id;
	            }
	        }
	    }
	}
	if($('TQCrownRating').value == "")
	{
		columnIds = columnIds.replace("Crown","");
	}
	else
	{
		columnIds += (columnIds.length > 0) ? ",Crown" : "Crown";
	}
	
	SetCookie("CustTopQuartile_CC_"+univCode+"_"+requestFile, columnIds,123231);
	document.masterForm.RadioColumns.value=radioIds;
	document.masterForm.submit();
 }

	
/**************** Key Asset control ****************/	
function loadIndicesKAC()
{
    var indicesName = ["SBWGU","Citi World Government Bond Index- all maturities",
					"CRSHDG","Credit Suisse Tremont Hedge Fund Index",
					"ASX","FTSE All Share",
					"LIB3MGBP","LIBOR GBP 3m",
					"M990100","MSCI THE WORLD INDEX",
					"M891800","MSCI EM (EMERGING MARKETS)",
					"IPDAP","IPD UK all property"];
					
    var assetClass = $('keyAssetClass').value.replace('@GB','');
    for(i=0; i<indicesName.length; i=i+2)
    {
	  if (indicesName[i]==assetClass)
	  {
		 $('spanIndicesName').innerHTML = indicesName[i+1];
	  }
    }
}

function changeSpanKeyAsset(){ 
	
    var assetClass = $('keyAssetClass').value;
    var assetSpan = $('keyAssetSpan').value;	 
	$('hdnassetClass').value=$('keyAssetClass').value;
	$('hdnkeyAssetSpan').value=$('keyAssetSpan').value;	
	var imageSource = "/Tools/ChartBuilder.aspx?width=320&height=122&color=CE1010&codes=N" + assetClass + "&span=" + assetSpan;
	var imgObj = $("keyAssetChart");
	if (imgObj) {
		imgObj.src = imageSource;
	}	
	loadIndicesKAC();
}
/************** End Key Asset control ******************/

/************** Start of Index Performance control ******************/
function IndexPerfChange(){
	
	// Declaring shortname for required elements
	var eSelectIP = document.getElementById('IndexPerfDD');
	var eSelectSpan = document.getElementById('IndexPerfSpan');
	var eSpanIPName = document.getElementById('spnIndexPerfName');
	var eImageChart = document.getElementById('IndexPerfChart');		
	
	var span = eSelectSpan.value;
	var indexCode = eSelectIP.value;
	var indexName = eSelectIP.options[eSelectIP.selectedIndex].text;
	eSpanIPName.innerHTML = indexName;
	eImageChart.src = "/Tools/ChartBuilder.aspx?width=320&height=122&color=CE1010&codes=N" + indexCode + "&span=" + span;
}
/************** End of Index Performance control ******************/



/************** Foreign Exchange control ******************/

var curTitleArray = new Array();
var newCurCookie = new Array();
var arrGICookie = new Array();	    		
var curCookie = GetCookie("TN_ForEx");	
newCurCookie = curCookie.split(',');
arrGICookie = GetCookie("TN_GIBar").split(',');
var curDirectionStatus = "Up";

function assignCURTypeCode(typecode) {
	curTitleArray = typecode.split(',');
}
    
// Function to display or hide Global Indices Popup
function getCurPopup(val) {
  if(val=="True") {
	 $("curPopup").style.visibility='visible';
	 $("curIFrame").style.visibility='visible';
  }
  else if(val=="False") {
	 $("curPopup").style.visibility='hidden';
	 $("curIFrame").style.visibility='hidden';
	 updateCur_Cookie();
	 document.forms[0].submit(); 
  }
  else {
	 $("curPopup").style.visibility='hidden';
	 $("curIFrame").style.visibility='hidden';		 
  }
}

// Function to update Foreign Exchange cookie values
function updateCur_Cookie() {
  var prevCookie = GetCookie("TN_ForEx");	  

  if(prevCookie==null) {
	 SetCookie("TN_ForEx", null, 123231);
  }
  else {		 
	 var k=0;
	 var newCookieValue='';
	 for(j=0;j<curTitleArray.length;j++) {	
		if($(curTitleArray[j] + "_Chk")) {		
			if($(curTitleArray[j] + "_Chk").checked) {
				if(k>0) { 
				  newCookieValue += ","; 
				}
				newCookieValue += curTitleArray[j];
				k++;
			}
		}			
	 }
	 SetCookie("TN_ForEx", newCookieValue, 123231);		 
  }	 
}

// It will change the charts based on the time span
function changeCurrencyChart(val) {	  
  for(i=0;i<newCurCookie.length;i++) {
	 var curAry = new Array();
	 //curAry = newCurCookie[i].split('/');
	 curAry = newCurCookie[i].split(':');
	 var imgObj = $(newCurCookie[i]);
	 if(imgObj)	 {
		imgObj.src = "/Currencies/chartbuilder.aspx?height=110&width=145&hide=1&format=NoCopyright&yformat=0.0&xformat=MMM yy&color=" + strFEBMColorCode + "&currency1=" + curAry[0] + "&currency2=" + curAry[1] + "&span=" + val;
	 }
  }	  
} 

// On Clicking the chart it will navigate to charting page
function onCurClick(Title) {	  	  
  var sel = $("CurrencySpanVal")[$("CurrencySpanVal").selectedIndex].value;
  var curAry = new Array();
  //curAry = Title.split('/');
  curAry = Title.split(':');
  window.location="/Currencies/CurrencyHistory.aspx?SourceT=" + curAry[0] + curAry[1] + "&spanddl=" + sel;		 		 
} 

// It will decide to display or hide the outer border
function updateCurOuterDiv() {
  var eleOuterDiv = $("curOuterDiv");
  var eleInnerDiv = $("curInnerDiv");
  var eleScrollUp = $("curScrollUp");
  var eleScrollDown = $("curScrollDown");
  
  if (newCurCookie.length > 5-arrGICookie.length)
  {
	 var ht =  5 - arrGICookie.length;
	 if(newCurCookie.length>1) {
		eleOuterDiv.style.border = 'solid 1px #A7C7E7';
		eleOuterDiv.style.height = ((ht<=0)?imgHeight:ht*imgHeight) + "px" ;
		eleScrollDown.style.visibility='visible';
		eleScrollUp.style.visibility='visible';
		moveCurChart(true);
	 }
	 else {
		eleOuterDiv.style.border = 'none 0px white';
		eleOuterDiv.style.height = imgHeight + "px";
		eleScrollDown.style.visibility='hidden';
		eleScrollUp.style.visibility='hidden';		 
		moveCurChart(false);
	 }
  }
  else
  {
	 eleOuterDiv.style.border = 'none 0px white';
	 eleOuterDiv.style.height = eleInnerDiv.getElementsByTagName('img').length * imgHeight + "px";
	 eleScrollDown.style.visibility='hidden';
	 eleScrollUp.style.visibility='hidden';
	 moveCurChart(false);
  }
}	   
	
// It will execute when up and down scrolls clicked based on the parameter passed
function curScroll(direction, state) { 	  
  if(state=="Start" && direction=='') {		 
	 direction=curDirectionStatus;
  }
  else if(direction!='') {
	 curDirectionStatus = direction;
  }
  $("hdnCurDirection").value = direction;
}

// Function to keep the charts moving always
function moveCurChart(srlval) {
  var eleHdn = $("hdnCurDirection");
  var eleInnerDiv = $("curInnerDiv");
  var inEleHeight = newCurCookie.length * imgHeight;
  var jump = 5;
  var scrollFETimer = 0;	  
  	  
  if(eleHdn.value=="Up") {
	 for(i=0;i<newCurCookie.length;i++) {
		var eleChart = $(newCurCookie[i] + "_div");
		if(eleChart){
			var chartHeight = eleChart.style.top;
			chartHeight = parseInt(chartHeight.replace('px','')) - parseInt(jump);
			eleChart.style.top = chartHeight + "px";
			if(chartHeight<-imgHeight) {
			   eleChart.style.top = parseInt(inEleHeight) - parseInt(imgHeight) + "px";
			}
		}
	 }
  }
  else if(eleHdn.value=="Down") {		 
	 for(i=0;i<newCurCookie.length;i++) {
		var eleChart = $(newCurCookie[i] + "_div");
		if(eleChart){
			var chartHeight = eleChart.style.top;
			chartHeight = parseInt(chartHeight.replace('px','')) + parseInt(jump);
			eleChart.style.top = chartHeight + "px";
			if(chartHeight > (parseInt(inEleHeight) - parseInt(imgHeight))) {
			   eleChart.style.top = -(parseInt(imgHeight)) + "px";			   
			}
		}
	 }  
  }
  if(srlval) {
	scrollFETimer = setTimeout('moveCurChart(true)',300);
  }
  else {
	clearTimeout(scrollFETimer);
  }
}
/************** End Foreign Exchange control ******************/


/************** Advertisement Script ******************/

function OAS_NORMAL(pos){
	document.write(OAS_NORMAL_STR(pos))	
}

function OAS_NORMAL_STR(pos){
	var str = "";
	str += ('<a href="'+OAS_url+'click_nx.ads\/'+OAS_sitepage+'\/1'+OAS_rns+'@'+OAS_listpos+'!'+pos+OAS_query+'" rel="external">');
	str += ('<img src="'+OAS_url+'adstream_nx.ads\/'+OAS_sitepage+'\/1'+OAS_rns+'@'+OAS_listpos+'!'+pos+OAS_query+'" alt="advert" \/><\/a>');
	return str;
}

function OAS_AD(pos){
	if(OAS_listpos!=''){
		if (OAS_version>=11 && typeof(OAS_RICH_STR)!='undefined'){
			var width = 730;
			var height = 92;
			var nocomment = "";
			nocomment = "&nocomment=1";

			switch(pos) {
				case "Top":
					width = 728; height = 90;
					break;
				case "Top2":
					width = 120; height = 60;
					break;
				case "Right":
					width = 140; height = 840;
					break;
				case "Position1":
					width = 300; height = 250;
					break;
				case "Top3":
					width = 150; height = 30;
					break;
				case "x03":
					width = 5; height = 5;
					break;
				case "BottomLeft":
					width = 155; height = 470;
					break;
				case "Left1":
					width = 155; height = 160;
					break;
					
			}
			var str = OAS_RICH_STR(pos);
			if (str) {
				document.write('<iframe style="width: '+width+'px;height: '+height+'px; padding: 0" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" src="\/functions\/IframeAd.aspx?pos='+pos+nocomment+'"><\/iframe>')
			}
		}
		else if (OAS_version>=11 && typeof(OAS_RICH)!='undefined'){
			OAS_RICH(pos);
		}
		else{
			OAS_NORMAL(pos);
		}
	}
}

function OAS_AD_STR(pos){
	if(OAS_listpos!=''){
		if (OAS_version>=11 && typeof(OAS_RICH_STR)!='undefined'){
			return OAS_RICH_STR(pos);
		}else{
			return OAS_NORMAL_STR(pos);
		}
	}
}

function advPosition() {
	if(OAS_listpos!=''){
		OAS_version=11;
		if(navigator.userAgent.indexOf('Mozilla/3')!=-1){
			OAS_version=10;
		}else{
			var surl = OAS_url+'adstream_mjx.ads\/'+OAS_sitepage+'\/1'+OAS_rns+'@'+OAS_listpos+OAS_query;

			if (iframead) {
				document.write('<sc'+'ript language="javascript1.1" src="\/functions/OasStr.aspx?adstr='+escape(surl)+'"><\/scr'+'ipt>');
			}
			else {
				document.write('<sc'+'ript language="javascript1.1" src="'+surl+'"><\/scr'+'ipt>');
			}		
		}
	}
}

/************** End of Advertisement script *********/
// Function to load sectors based on universe and assetclass
function qsNewLoadSector(val)
{		
  
   var selUnivEleID = $("qsUniverseDD");
   var assetClassCtrl = $("qsAssetClassDD");
   
   // Skip this code when both the element doesn't exit
   if(assetClassCtrl && selUnivEleID)
   {
	  // Assigning values of the dropdown boxes to a local variable
	  var assetClass = assetClassCtrl.options[assetClassCtrl.selectedIndex].value;
	  var universe=selUnivEleID[selUnivEleID.selectedIndex].value;
	  var isSecRequired = universe.substring(universe.toString().indexOf(":")+1,universe.toString().length);
	  universe=universe.substring(0,universe.toString().indexOf(":"));
	  var sectorDDCtrl=$("qsSectorsDD");
	  
	  if(isSecRequired=="True")
	  {
		 if(val=='univ')
		 {
		  LoadFilterBusObjectLoad('Sectors',universe,'LoadByUniverse',universe,'Name','SectorClassCode','','Name asc');
		 }
		 else
		 {
		 LoadSectorByAssetClassLoad(assetClass,universe,'Name','SectorClassCode',null,'Name asc');	
		 }
		 
	  }
	  else
	  {
		 sectorDDCtrl.value="";
		 sectorDDCtrl.disabled=true;		 
	  }
	  if(val=="univ")
	  {	  
		 
		   LoadFilterBusObjectLoad('Managers',universe,'LoadByUniverse',"'"+universe+"'",'Name','ManagerCode','','Name asc');
		   LoadFilterBusObjectLoad('Domiciles',universe,'LoadByUniverse',"'"+universe+"'",'DomicileName','DomicileCode','','DomicileName asc');
		
	  }
   }
}   

 

/////////////////////// ***************************** Dragging Object ******************************** //////////////////

///Drag Object.
// This will Drag object corresponding to the Cursor Movement.
function $(v) 
{ 
	return(document.getElementById(v)); 
}

function agent(v) 
{ 
	return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); 
}

function xy(e,v) 
{ 
	return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX)); 
} 

function dragOBJ(d,e,ifid,trid) 
{ 	
	function drag(e) 
	{ 
		if(!stop) 
		{ 
			d.style.top=(tX=xy(e,1)+oY-eY+'px'); 
			d.style.left=(tY=xy(e)+oX-eX+'px'); 
			ifid.style.top=(tX=xy(e,1)+oY-eY+'px'); 
			ifid.style.left=(tY=xy(e)+oX-eX+'px');
			
			StableHeader(trid);
		} 
	} 	
	var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop; 	
	document.onmousemove=drag; document.onmouseup=function()
	{ 
		stop=1; 
		StableHeader(trid);
		document.onmousemove=''; 
		document.onmouseup=''; 
	}; 
}


function StableHeader(titleEle)
{
	if(titleEle)
	{
		//var titleEle = $("CalcTitleTR");
		titleEle.style.background="url(/Images/bgMainMenuActive.gif)  repeat-x";
		titleEle.style.cursor='move'; 
	}
}


// This function is to enable and display popup window
function enablePopup(id) {	
	switch (id)
	{
		case "FooterTZCDiv":
			if(!$("TimeZoneDiv")) {
				CalDayLightTimeLoad();
				$("FooterTZCDiv").innerHTML=loadTimeZoneConverter();
			}
			showTZC();
			break;
		case "FooterMailDiv":
			if(!$("MailDiv")) {
				$("FooterMailDiv").innerHTML=EmailContent();				
			}
			showMailDiv('logDiv');
			// $("txtTo").value="[enter the email address of the person you'd like to send this page to]";
         $("txtComment").value="[I thought you might interested in this page]";             
			break;
		case "FooterCalDiv":
			if(!$("CalcMainDiv")) {
				$("FooterCalDiv").innerHTML=CalculatorContent();
			}
			ShowCalc();
			break;
		default:				
	}       
}

/////////////////////// ------------------------------------------------------------------------------ ////////////////////

function LoadPresetColumns(columnIds)
{
	SetCookie(ctrlId+ "_CC_"+cust_universe+"_"+requestfile, columnIds, 11111);
	document.masterForm.submit();
}


function postValues(ctrl,tabName,duration)
{
  var tab=$("ffcType");
  var dur=$("ffcDuration");
  tab.value=tabName;
  dur.value=duration;
  
  document.forms[0].submit();
  
}

function changeValues(ctrl,tabName,duration)
{
  var chart=$("chartFeatured");
  var dur=$("ffcDuration");
  
  
  var span=36;
  if(duration=='36M')
  {
   span=36;
  }
  else if(duration=='12M')
  {
   span=12;
  }
  else if(duration=='60M')
  {
   span=60;
  }
  
  
 if(ctrl=='ffc')
 {
    chart.src='/Tools/ChartBuilder.aspx?width=320&height=122&codes=FITWTAN&span='+span+'&color=CE1010';
    
    var list_item=$('ffc_li_'+duration);
    
    if(list_item)
    {
        list_item.className='selected';

        switch(duration)
        {
          case '12M':  
          $('ffc_li_36M').className='';
          $('ffc_li_60M').className='';
          break;
          
          case '60M':  
          $('ffc_li_12M').className='';
          $('ffc_li_36M').className='';
          break;
          
          default:  
          $('ffc_li_12M').className='';
          $('ffc_li_60M').className='';
          break;
        
        }

    } 
  
  }
  
}

function OnSplitViewChange(val)
{
$('hdnView').value=val;
document.masterForm.submit();
}
function OpenSplitCapital(val)
{
SetCookie("SCA_CC_T_SplitCapitalAnalytics",val,123231);
window.open("/Investments/SplitCapitalAnalytics.aspx?univ=T","_self");
}

function ToolDiscPerf(univ)
{
SetCookie('Pf_CC_'+univ+'_perf','Fundname,P0t12m,P12t24m,P24t36m,P36t48m,P48t60m','11111');
document.masterForm.action='/Investments/Perf.aspx?univ='+univ+'';
document.masterForm.submit();
}
function btnSubmit_Click()
{
	if($('txtEmailAddress').value!="")
	{
		if(validateEmail($('txtEmailAddress')))
		{
		document.masterForm.submit();
		}
	}
	else
	{
	alert("Please enter your email address");
	$('txtEmailAddress').focus();
	}
}
function leftNavHide(id) 
{

 var value=GetCookie('LeftNav');
 
 if ($(id).style.display == 'none')
 {   
    var farray = new Array();
	farray = value.split(',');           
	if(!IsStringFoundInArray(farray, id))
	{
	 value += ","+id;	
	}
	else
	{
	 DeleteFromShortlist(id,'LeftNav');
	 value=GetCookie('LeftNav');
	}
	SetCookie('LeftNav',value,123231);
	$(id).style.display = 'block';	 
	$('btn' + id).src = '/images/icon_hide.png';
 } 
 else 
 {
	DeleteFromShortlist(id,'LeftNav');
	value=GetCookie('LeftNav');
	SetCookie('LeftNav',value,12345);
	$(id).style.display = 'none';	  
	$('btn' + id).src = '/images/icon_view.png';
 }
 return false;
}

function ShowAllLefNav()
{
   var value=GetCookie('LeftNav');
   var farray = new Array();
   farray = value.split(',');
   //alert(value);
   for(var i=0;i<farray.length;i++)
   {
	  if(farray[i]!='')
	  {
		if ($(farray[i]).style.display == 'none')
		{
		$(farray[i]).style.display = 'block';	 
		$('btn' + farray[i]).src = '/images/icon_hide.png';
		} 
		else 
		{
		$(farray[i]).style.display = 'none';	  
		$('btn' + farray[i]).src = '/images/icon_view.png';
		}
	  }
   }
}

function GoToPerf(id)
{
 var univ=$(id).value;
 if(univ == "VCT")
 {
	window.open("/Investments/VCTPerf.aspx","_self");
 }
 else
 {
	window.open("/Investments/Perf.aspx?univ="+univ+"","_self");
 }
}

////////////////////////////////// Functions for Basket in checkstatus control ////////////////

	 function ShowBasketHelp(DivID)
		{
			$(DivID).style.visibility="visible";
			$(DivID).style.zIndex = "2000";
			MinimizeBasketHelpWindow('BasketHelpContent');
			return false;
		}
		
		function HideBasketHelp(DivID)
		{
			$(DivID).style.visibility="hidden";
			$('BasketHelpContent').style.visibility="hidden";
		}
		
		//Minimize Window is the function to Minimise Currency Gadjet Window.
		//To Minimise Current Window to Bottom.
		function MinimizeBasketHelpWindow(divID)
		{
			//Code here for Minimising Div.
			if($(divID).style.visibility == 'visible')
			{
				$(divID).style.visibility = 'hidden';
				$("BasketMinimizeL").innerHTML = "<img src='/images/shape_square.png' style='border:#FFFFFF solid 1px; height:16px;' alt='Maximize' />";
				$("BasketMinimizeL").style.verticalAlign = "bottom";
				$("BasketMinimizeL").title ="Maximize";
				$("HelpBasket").style.height = '21px';
			}
			else
			{
				$(divID).style.visibility = 'visible';
				$("BasketMinimizeL").innerHTML = "&nbsp;_&nbsp;";
				$("BasketMinimizeL").style.border="0px";
				$("BasketMinimizeL").title = "Minimize";
				$("HelpBasket").style.height = '';
			}
			
		}

		//Make shading while Cursor Moves.

		function Shade(ctl)
		{
			ctl.style.background="#1A5083";
		}

		// Remove Shading while Cursor Out.
		function RShade(ctl)
		{
			ctl.style.background="";
		}
		
////////////////////// Menu bar input controls ////////////////////////////

function SetAutoComplete(ctrlid, on_off) {
	if($(ctrlid))
	{
		var f = $(ctrlid);
		f.setAttribute("autocomplete", on_off);
	}
} 
 function save()
    {
    var element=document.getElementsByName("Default");   
    var elementRename=document.getElementsByTagName("INPUT"); 
    var elementCurrency=document.getElementsByName("changeCurrency");   
    var names="";
    var rdnPid="";
    var msg="";
    var CurrencyPid="";
    for(var i=0;i<element.length;i++){
    if(element[i].type=="radio"){    
    if(element[i].checked){
    $("rdnDefault").value=element[i].id;   
    }else{  
    msg++;
    }    
    }
    }
     for(var i=0;i<elementRename.length;i++){
    if(elementRename[i].name=="Rename"){              
    names=names+elementRename[i].value+",";
    rdnPid=rdnPid+elementRename[i].id+",";       
    } 
    }     
    for(var i=0;i<elementCurrency.length;i++){   
    CurrencyPid=CurrencyPid+elementCurrency[i].id+",";
    }
    $("hdnRenames").value=names;
    $("rdnPid").value=rdnPid; 
    $("CurrencyPid").value=CurrencyPid;  
      
    if((msg+1)!=element.length){
    alert('Please select Default Portfolio');  
    }else{
	  document.masterForm.action="ManagePortfolio.aspx";
     document.masterForm.submit();
    }
    }
  function delFundsList1(rdnDelDefault)
  {
  $("rdnDelDefault").value=rdnDelDefault;
  document.masterForm.submit(); 
  }
  function addReport(portID)
  {
  $("portID").value=portID;
  document.masterForm.submit(); 
  }
 
  
 function editFundsList(editText,id,idL)
  {  
  if(document.getElementById(idL)!=null){
   var editElement=$(editText);  
   var editLink =$(idL);      
   var ele=document.createElement("input");
   ele.setAttribute("id", id);
   ele.setAttribute("name", "Rename");  
   ele.onchange=function(){ loadCashValue(id,id,'Rename Cash');};
   //"javascript:loadCashValue('"+id+"'); PortfolioPopup('visible','curr"+id+"');"
   //editText.appendChild(ele);
   editLink.parentNode.replaceChild(ele, editLink);
   ele.focus();
   }   
  } 
  
  
  function loadResult(univ)
  {  
    var typecodes=document.getElementsByName("selectFunds");
    var typeCode="";
    var splitter="";
   for(var i=0;i<typecodes.length;i++)
   { 
   typeCode=typeCode+splitter+typecodes[i].value;
   splitter=",";
   }

   var Result=TrustnetX.Portfolio.PortfoliosAlert.LoadResult(typeCode,univ);
  
	  if(Result!=null)
	  {					 
			 //var Prcies=document.getElementsByName("Curr");			  
			 Result=Result.value;  	
	 		 for(var i=0;i<typecodes.length;i++)
			 {
			 for(var j=0;j<Result.length;j++)
			 {			 
			 if(typecodes[i].value!="" && Result[j].typeCode==typecodes[i].value){			 			 
			 var selectPrice=$("alert"+i);
			 selectPrice.options.length=0;
			 //selectPrice[count].value=Result[count].Name;
			  var ele=document.createElement("option");
			  ele.text=Result[j].Name;
			  ele.value=Result[j].Name;
			  selectPrice.options.add(ele);	
			  if(univ=="T")
			  {
			  var ele=document.createElement("option");			  
			  ele.text="Discount";
			  ele.value="Discount";
			  selectPrice.options.add(ele);
			  var ele1=document.createElement("option");		
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  }
			  else if(univ=="Warrants")
			  {
			  var ele=document.createElement("option");			  
			  ele.text="Discount";
			  ele.value="Discount";
			  selectPrice.options.add(ele);
			  var ele1=document.createElement("option");		
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  } 
			  else if(univ=="Equities")
			  {			 
			  var ele1=document.createElement("option");		
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  }
			  else
			  {			 
			  if(Result[j].Name=="Bid")
			  {
			  var ele=document.createElement("option");
			  ele.text="Offer";
			  ele.value="Offer";
			  selectPrice.options.add(ele);
			  var ele1=document.createElement("option");
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  }			  
			  else if(Result[j].Name=="Mid")
			  {
			  var ele=document.createElement("option");			 
			  ele.text="% Pricechange";
			  ele.value="% Pricechange";
			  selectPrice.options.add(ele);
			  }		
			  }	  
			  $("Curr"+i).innerHTML=Result[j].Price;
			  selectPrice.value=Result[j].Name;			 
			 
			  }	
			  }	
		   }
	   }        
      }
      
   function loadPriceResult()
   {
    var typecodes=document.getElementsByName("selectFunds");
    var typeCode="";
    var splitter="";
   for(var i=0;i<typecodes.length;i++)
   { 
   typeCode=typeCode+splitter+typecodes[i].value;
   splitter=",";
   }
   var count=0;
   var selectPrice=document.getElementsByName("selectAlerts"); 
    for(var j=0;j<selectPrice.length;j++)
	{	
	if(selectPrice[j].value!="" && typecodes[j].value!=""){		  
	  var Result=TrustnetX.Portfolio.PortfoliosAlert.LoadPriceResult(typecodes[j].value,selectPrice[j].value);    
	  if(Result!=null)
	  {			 
			  Result=Result.value; 				
			  //selectPrice[j].value=selectPrice[j].value;		  		  
			  document.getElementById("Curr"+j).innerHTML=Result[0].Price;			 
			  count++
		 	
		}	   }  
	   }      
      }
      
function loadWatchResult(univ)
   {
    var typecodes=document.getElementsByName("selectFunds");
    var typeCode="";
    var splitter="";
   for(var i=0;i<typecodes.length;i++)
   { 
   typeCode=typeCode+splitter+typecodes[i].value;
   splitter=",";
   }
   var Result=TrustnetX.Alerts.LoadResult(typeCode,univ);   
	  if(Result!=null)
	  {					 
			 //var Prcies=document.getElementsByName("Curr");			  
			 Result=Result.value;  	
	 		 for(var i=0;i<typecodes.length;i++)
			 {
			 for(var j=0;j<Result.length;j++)
			 {			 
			 if(typecodes[i].value!="" && Result[j].typeCode==typecodes[i].value){			 			 
			 var selectPrice=$("alert"+i);
			 selectPrice.options.length=0;
			 //selectPrice[count].value=Result[count].Name;
			  var ele=document.createElement("option");
			  ele.text=Result[j].Name;
			  ele.value=Result[j].Name;
			  selectPrice.options.add(ele);	
			  if(univ=="T")
			  {
			  var ele=document.createElement("option");			  
			  ele.text="Discount";
			  ele.value="Discount";
			  selectPrice.options.add(ele);
			  var ele1=document.createElement("option");		
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  }
			  else if(univ=="Warrants")
			  {
			  var ele=document.createElement("option");			  
			  ele.text="Discount";
			  ele.value="Discount";
			  selectPrice.options.add(ele);
			  var ele1=document.createElement("option");		
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  } 
			  else if(univ=="Equities")
			  {			 
			  var ele1=document.createElement("option");		
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  }
			  else
			  {			 
			  if(Result[j].Name=="Bid")
			  {
			  var ele=document.createElement("option");
			  ele.text="Offer";
			  ele.value="Offer";
			  selectPrice.options.add(ele);
			  var ele1=document.createElement("option");
			  ele1.text="% Pricechange";
			  ele1.value="% Pricechange";
			  selectPrice.options.add(ele1);
			  }			  
			  else if(Result[j].Name=="Mid")
			  {
			  var ele=document.createElement("option");			 
			  ele.text="% Pricechange";
			  ele.value="% Pricechange";
			  selectPrice.options.add(ele);
			  }		
			  }	  
			  $("Curr"+i).innerHTML=Result[j].Price;
			  selectPrice.value=Result[j].Name;			 
			 
			  }	
			  }	
		   }
	   }    
      }
      
  function loadWatchPriceResult()
  {
    var typecodes=document.getElementsByName("selectFunds");
    var typeCode="";
    var splitter="";
    for(var i=0;i<typecodes.length;i++)
    { 
    typeCode=typeCode+splitter+typecodes[i].value;
    splitter=",";
    }
   var count=0;
   var selectPrice=document.getElementsByName("selectAlerts"); 
   for(var j=0;j<selectPrice.length;j++)
	{	
		 if(selectPrice[j].value!="" && typecodes[j].value!="")
		 {		  
			   var Result=TrustnetX.Alerts.LoadPriceResult(typecodes[j].value,selectPrice[j].value);    
			   if(Result!=null)
			   {			 
				   Result=Result.value; 				
				  // selectPrice[j].value=selectPrice[j].value;		  		  
				   $("Curr"+j).innerHTML=Result[0].Price;			 
				   count++
         		 	
			   }
		}   
	}      
 }

function HideMenu(e,listid,parent)
{
	var tagn=(document.all)?event.srcElement.parentElement.id:e.target.parentNode.id;
	var tagid=(document.all)?event.srcElement.id:e.target.id;
	tagid=tagid==""?tagn:tagid;
	var flag=false;
	var x =  $(listid).childNodes;
	for(var i = 0; i < x.length;i++)
	{
	var tab = x[i];
	var ang = tab.childNodes;
		if(tagid==(ang.id)&& ang.id!="")
		{
		flag=true;
		break;
		}
		for(var d = 0;d<ang.length;d++)
		{
		var chi = ang[d];
			if(tagid==(chi.id) && chi.id!="")
			{
			flag=true;
			break;
			}

		}
	}
	if(flag==true || tagid==parent )
	{
	 $(listid).style.display='block';
	}
	else
	{
	 $(listid).style.display='none';
	}
}

function Navigate(id,scope,type)
{
	var val=$(id).value;

	if($('scope'))
	{
		if($(scope))
		{
			$('scope').value=$(scope).value;
		}
		else
		{
			$('scope').value="all";
		}
	}
	$(type).checked=true;
	searchSubmit($(id).value);
	return true;
}

function OnSearchEnter(e,id,scope,type)
{
	if(e.keyCode == 13)
	{
		Navigate(id,scope,type)
	}
}

function SetSelectedValue()
{
	var browserVersion=navigator.userAgent;
    
   var keyDD=document.getElementById('keyStrategyDD');
   var selValue=document.getElementById('keyStrategyLbl').innerHTML.toLowerCase(); 
	selValue=selValue.replace('-',' ');
	for(i=0;i<keyDD.length;i++)
	{
		if(keyDD.options[i].text.toLowerCase()==selValue)
		{
			keyDD.selectedIndex=i
		}
	}
}

/*  Smart navigation  */
function SmartScroller_GetCoords() {
	var scrollX, scrollY;
	if (document.all) {
		if (!document.documentElement.scrollLeft)
			scrollX = document.body.scrollLeft;
		else
			scrollX = document.documentElement.scrollLeft;
		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop; 
	}
	else {
		scrollX = window.pageXOffset; scrollY = window.pageYOffset; 
	}
	 $('scrollLeft').value = scrollX;
	 $('scrollTop').value = scrollY;
}

function SmartScroller_Scroll() {
	var x =  $('scrollLeft').value;
	var y =  $('scrollTop').value;
	window.scrollTo(x, y); 
}

/*  End smart navigation  */

function ChangeFontSize(divName, size) 
{
   var eleContent =  $(divName);
   if(eleContent)
   {
		eleContent.style.fontSize = size;
   }
}

function BasketPopup(visibleType,typeCode,popupType,portfolioName)
{
    if(typeCode!=null && typeCode!='')
    {
        FundByType(typeCode);
    }
    if(visibleType=="visible")
    {
        $("FooterBasketDiv").innerHTML=BasketPopupContent(getPosition(typeCode),popupType,typeCode,portfolioName);
        $('curPopup').value=typeCode;
        setTimeout("CloseBasket('"+typeCode+"')",4000);
    }
    else
    {
        CloseBasket(typeCode);
    }
}

function SetBasketVisibility(r)
{
    var row = $("td_TypeName");
    if(row && r!=null)
    {
        row.innerHTML =r.FundName;
    }
}


function CloseBasket(typeCode)
{
    if($('isBasketClose')!=null && $('isBasketClose').value=='true')
    {
       if($("BasketPopup"+typeCode+"")!=null)
       { 
        $("BasketPopup"+typeCode+"").style.visibility='hidden';  
        $("BasketPopupFrame").style.visibility='hidden';  
       }
    }
}

function ClosePortfolio(id)
{
    if($('isPortfolioClose')!=null && $('isPortfolioClose').value=='true')
    {
       if($("PortfolioPopup"+id+"")!=null)
       { 
        $("PortfolioPopup"+id+"").style.visibility='hidden';  
        $("PortfolioPopupFrame").style.visibility='hidden';  
       }
    }
}

//Region for Article Comment and Recpatcha functions

function ChangeRecaptchaImg()
{
 var recapImgDiv =  $('recaptcha_image');
 recapImgDiv.style.width = "250px";
 var recapEle = recapImgDiv.getElementsByTagName('IMG');
 for(var l=0;l<recapEle.length;l++)
 {
    if(typeof(recapEle[l])!='undefined')
    {
	    recapEle[l].style.width = "250px";
    }
 }
}
function ChangeCaptchaMode()
{
 var label = $("lblResponse");
 var recapMode =  $('Captchamode');
 if(recapMode.src.indexOf('recaptcha_volume') != -1)
 {
     Recaptcha.switch_type("audio");
     recapMode.src = "/icons/recaptcha_text.jpg";
     if(label) label.innerHTML = "Enter the eight numbers: ";
 }
 else
 {
     Recaptcha.switch_type("image");
     recapMode.src = "/icons/recaptcha_volume.jpg";
     if(label) label.innerHTML = "Enter either word above: ";
 }
}

function getCommentValue(id)
{
  var userId=GetCookie("TN_UserId")             
  if(userId=='')
  {
     ShowLogInDiv();
  }
  else
  {
	 var comment= $(id).value;
	 var maxValue=2000; 				    
	 comment= comment.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');						     
	 if(comment.length>maxValue)
	 {
		  alert('Too much data in the text box!you can enter upto 2000 characters');
		  return false;
	 }
	 else
	 {
		  comment= encodeMyHtml(comment); 
		  //document.getElementById(id).value=''; 			        		    
		  if(comment!="")
		  {	        
			  //Recaptcha.ajax_verify(validateCaptcha);
			  
			  var response = Recaptcha.get_response();
			  var challenge = Recaptcha.get_challenge();
			  var isValidCaptcha = TrustnetX.Controls.ArticleComment.ValidateRecaptcha(RequestIp, challenge, response, MachineLocation);
			  isValidCaptcha = isValidCaptcha.value;
			  if(isValidCaptcha.indexOf("true") != -1)
			  {
				   $(id).value=''; 								  
				   $('commentText').value=comment; 				    
				  var url=document.URL;
				  if(url.indexOf('#') != -1)
				  {
						url=url.substring(0,url.indexOf('#'));
				  }
				  url=url+'&sValue=1';
				  
			    //Check Comment Alert
			    if(document.getElementById('commentAlert').checked)
                {
                    document.getElementById('mailAlert').value=true;      
                }
                else
                {
                    document.getElementById('mailAlert').value=false;      
                }
				document.masterForm.action=url;
				document.masterForm.submit();
			  }
			  else
			  {
						 alert('The security code you entered did not match. Please try again.');
					Recaptcha.reload();
					 $('recaptcha_error').style.display = 'block';
			  }
		  }else
		  {
			  alert('Please enter the comment');				
		  }	
		}
  }
}
   			    	
function encodeMyHtml(comment) {
	contents=new String(comment);
	contents=contents.replace(/</g,'&lt;');
	contents=contents.replace(/>/g,'&gt;');            
	return contents;
} 

function validateCaptcha(data)
{
  if (data['is_correct']) 
  { 
  alert("correct");
  } 
  else 
  { 
     alert('The security code you entered did not match. Please try again.'); 
     Recaptcha.reload('r'); 
     return false; 
  } 
}

//  Function to show Alias Name information box
function ShowAliasNameInformation(DivID)
{    if($(DivID).style.visibility=='hidden')
     {
	     $(DivID).style.visibility="visible";
	     $("AliasNameIFrame").style.visibility="visible";
	     $(DivID).style.zIndex = "2000";
	 }else
	 {
	     $(DivID).style.visibility="hidden";
	     $("AliasNameIFrame").style.visibility="hidden";	    
	 }
	return false;
}

//  Function to hide Alias Name information box		
function HideAliasNameInformation(DivID)
{
	 $(DivID).style.visibility="hidden";
	 $("AliasNameIFrame").style.visibility="hidden";	
}


//Function to create Login div while posting comment
function CreateLogInDiv()
{  
    var refUrl=referUrl;      
    refUrl =refUrl.replace('&','%26');               
    var strDiv="";   
    strDiv+='<div style="visibility:hidden;width:390px;left:450px;Z-index=1000;position: absolute;height:auto;background-color:#fff;" id="loginDiv" >';   
    strDiv+='<table cellpadding="0" cellspacing="0" style="border:solid 1px #5A8FBC;background-color:#fff;">';
    strDiv+='<tr style="height: 23px; cursor:move;  background: url(/images/bgMainMenuActive.gif) repeat-x;"><td style="width: 100%;text-align: left; border-bottom: solid 1px #a7c7e7;padding-left: 6px;color:#fff;"><b>Login</b></td><td align="right" style="border-bottom: solid 1px #a7c7e7;padding-right:6px;"><a href="javascript:ClosLogDiv();" alt="close" style="color:#fff;">&nbsp;<b>X</b>&nbsp;</a></td></tr>';
    strDiv+='<tr>';
    strDiv+='<td align="center" colspan="2" style="padding:3px;"><img src="/images/Login_image.png" alt="Lock" /></td></tr>';
    strDiv+='<tr><td colspan="2" style="font-size:15px;padding-bottom:10px;color:#1A5083;" align="center"><b>Sorry, you must be logged in to use this feature</b></td></tr>';
     strDiv+='<tr><td style="padding-left:40px; width:190px;"><table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:30%"><img src="/images/icon_lock.png" alt="login" /></td><td style="width:50%"><span style="font-weight:bold;color:#1A5083;font-size:14px;float:left"><a href="/Tools/Portfolio/PortfolioLogin.aspx?url='+refUrl+'">Login</a></span></td></tr></table></td>';
    strDiv+='<td style="padding-right:40px;width:190px;"><table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:30%"><img src="/images/Register.png" alt="register" /></td><td style="width:50%"><span style="font-weight:bold;color:#1A5083;font-size:14px;"><a href="/Tools/Portfolio/PortfolioRegister.aspx">Register</a></span></td></tr></table></td></tr>';        
     strDiv+='</table>';     
     strDiv+='</div>';
     return strDiv;   
}

//Functio to close the Login Div
function ClosLogDiv()
{
      $('loginDiv').style.visibility='hidden';
}

//Display LoginDiv While unlogged user posting comment
function ShowLogInDiv()
{
    var pos;
    var top;
    var left;
    var browserName=window.navigator.userAgent;
    pos=getPosition("readerimg");
    if(pos.x==0 && pos.y==0)
    {
        pos=getPosition("txtComment");
        top=parseInt(pos.y);
        left=parseInt(pos.x);
          $("FooterMailDiv").innerHTML=CreateLogInDiv();
        if(browserName.indexOf("MSIE 7.0")>=0)
        {	
	        $('loginDiv').style.top=top;
	         $('loginDiv').style.left=left+60;				    
        }else if(browserName.indexOf("MSIE 6.0")>=0) 
        {
	         $('loginDiv').style.top=top+10;			    	 
	         $('loginDiv').style.left=left+60;
        } else
        {
	        $('loginDiv').style.top=(top+10)+"px";
	        $('loginDiv').style.left=(left+60)+"px";			  
        }
        
    }else
    {
        top=parseInt(pos.y);
        left=parseInt(pos.x);
          $("FooterMailDiv").innerHTML=CreateLogInDiv();
        if(browserName.indexOf("MSIE 7.0")>=0)
        {	
	        $('loginDiv').style.top=top+50;
	         $('loginDiv').style.left=left-150;				    
        }else if(browserName.indexOf("MSIE 6.0")>=0) 
        {
	         $('loginDiv').style.top=top+50;			    	 
	         $('loginDiv').style.left=left-150;
        } else
        {
	        $('loginDiv').style.top=(top+50)+"px";
	        $('loginDiv').style.left=(left-150)+"px";			  
        }
    }       
    $('loginDiv').style.visibility='visible';   
}

//Function for Feedback div in LPwrapper control
function CreateFeedBackDiv()
{
    var divHtml='<div id="feedbackDiv" style="visibility:hidden;left:632px;top:681px;Z-index=1000;position: absolute;width:150px;background-color:#A50500;">';
    divHtml+='<table border="0" cellpadding="2" cellspacing="0">';
    divHtml+='<tr><td style="padding-left:25px;font-weight:bold;"><a href="javascript:SendFeedBack(\'A\');" style="color:#FFFFFF;">Very useful</a></td></tr>';
    divHtml+='<tr><td style="padding-left:25px;font-weight:bold;"><a href="javascript:SendFeedBack(\'B\');" style="color:#FFFFFF;">Quite useful</a></td></tr>';
    divHtml+='<tr><td style="padding-left:25px;font-weight:bold;"><a href="javascript:SendFeedBack(\'C\');" style="color:#FFFFFF;">I`m indifferent</a></td></tr>';
    divHtml+='<tr><td style="padding-left:25px;font-weight:bold;"><a href="javascript:SendFeedBack(\'D\');" style="color:#FFFFFF;">Not very useful</a></td></tr>';
    divHtml+='<tr><td style="padding-left:25px;font-weight:bold;"><a href="javascript:SendFeedBack(\'E\');" style="color:#FFFFFF;">Useless</a></td></tr>';
    divHtml+='</table></div>';
    
    return divHtml;
}

 function SendFeedBack(rateValue)
{
   var upDateStatus=TrustnetX.Controls.TNUK.LPWrapperControl.UpDateFeedBack(feedBackUserId,rateValue,ipAddress);				    				    
   if(upDateStatus)
   {
      $('feedbackDiv').style.visibility='hidden';      
      $('feedback').style.display='none';
      $('feedReply').style.display='block';
   }
}

function ShowFeedBackDiv()
{    
    if($('feedbackDiv')==null)
    {
        $("FooterMailDiv").innerHTML=CreateFeedBackDiv();
    }
     if($('feedbackDiv').style.visibility=='hidden')
      {        
        var pos;
        var top;
        var left;
        var browserName=window.navigator.userAgent;
       
        pos=getPosition("feedback");
        top=parseInt(pos.y);
        left=parseInt(pos.x);          
        if(browserName.indexOf("MSIE 7.0")>=0)
        {	
            $('feedbackDiv').style.top=top+20;
            $('feedbackDiv').style.left=left+3;				    
        }else if(browserName.indexOf("MSIE 6.0")>=0) 
        {
             $('feedbackDiv').style.top=top+20;			    	 
             $('feedbackDiv').style.left=left+3;
        } else
        {
            $('feedbackDiv').style.top=top+20+"px";
            $('feedbackDiv').style.left=left+3+"px";			  
        }   
        $('feedbackDiv').style.visibility='visible';
      }else if($('feedbackDiv').style.visibility='visible')
      {
         $('feedbackDiv').style.visibility='hidden';
      }    
}

function CloseFeedBackDiv()
{
    if($('feedbackDiv').style.visibility='visible')
      {
         $('feedbackDiv').style.visibility='hidden';
      }    
}

//Function to create popup div for hints
function CreatePopUpDiv(divId)
{   
    var displayText=""; 
    var displayTitle="";          
    if(divId=="peerDiv")
    {
        displayText="For every fund managed by a fund manager, we take its sector average, and combine them over the periods that each of the funds has been managed. The calculation is achieved by constructing an artificial portfolio, as if you had bought and sold all of the sector averages relating to the manager`s funds during the period he/she has managed them. The weighting of each sector relating to each fund is equal, but is halved if the related fund is co-managed. Any periods where we have no record of fund manager performance is treated as a flat period.";
        displayTitle="Peer group composite";
    }else if(divId=="verdictDiv")
    {
        displayText="The Trustnet Verdict is a programmatically driven word generator which uses a number of key quantitive variables to create a verdict. As with the Alpha Manager Ratings, the variables are - alpha over the manager&lsquo;s career, length of track record, outperformance over a number of periods, and performance in up- and down-markets. Note that the periods used may not exactly correspond to the calendar annual periods shown in the Factsheet. The Verdict is entirely mechanical and quant-driven, so does not represent any judgment or opinion or recommendation on Trustnet&lsquo;s part.";
        displayTitle="Trustnet verdict";
    }else if(divId=="alphaRollingDiv")
    {
        displayText="Why do we use Alpha? Because alpha is what a fund manager generates over and above the market returns, once the market effects on performance have been removed. It reflects the ability of the manager to stockpick.";
        displayTitle="Rolling Alpha Quartile";
    }else if(divId=="contributionChartDiv")
    {
        displayText="Contribution tells you the amount of performance contribution each holding has made to the overall portfolio performance, over a given time period. This contribution is determined by the performance of the fund and the weight of the fund in the portfolio.";
        displayTitle="Contribution chart";
    }else if(divId=="houseStyleDiv")
    {
        displayText="To what extent are the fund managers at this group free to run money without restriction from position limits, risk or other top down controls.";
        displayTitle="House style";
    }
    
    var strDiv="";   
    strDiv+='<div style="visibility:hidden;width:390px;left:450px;Z-index=1500;position: absolute;height:auto;background-color:#fff;" id="'+divId+'" >';   
    strDiv+='<table cellpadding="0" cellspacing="0" style="border:solid 1px #5A8FBC;background-color:#fff;">';
    strDiv+='<tr style="height: 23px; cursor:move;  background: url(/images/bgMainMenuActive.gif) repeat-x;"><td style="width: 100%;text-align: left; border-bottom: solid 1px #a7c7e7;padding-left: 6px;color:#fff;"><b>'+displayTitle+'</b></td><td align="right" style="border-bottom: solid 1px #a7c7e7;padding-right:6px;"><a href="javascript:ClosPopUpDiv(\''+divId+'\');" alt="close" style="color:#fff;">&nbsp;<b>X</b>&nbsp;</a></td></tr>';
    strDiv+='<tr>';
     strDiv+='<td style="padding-left:5px;">'+displayText+'</td></tr>';
     strDiv+='</table>';     
     strDiv+='</div>';     
     return strDiv;   
}

//Display popup div for hints
function ShowPopUpDiv(id,divId)
{
    var pos;
    var top;
    var left;
    var browserName=window.navigator.userAgent;
    pos=getPosition(id);
    if(pos.x==0 && pos.y==0)
    {
        pos=getPosition("txtComment");
        top=parseInt(pos.y);
        left=parseInt(pos.x);
          $("FooterMailDiv").innerHTML=CreatePopUpDiv(divId);
        if(browserName.indexOf("MSIE 7.0")>=0)
        {	
	        $(divId).style.top=top;
	         $(divId).style.left=left;				    
        }else if(browserName.indexOf("MSIE 6.0")>=0) 
        {
	         $(divId).style.top=top;			    	 
	         $(divId).style.left=left;
        } else
        {
	        $(divId).style.top=top+"px";
	        $(divId).style.left=left+"px";			  
        }
        
    }else
    {
        top=parseInt(pos.y);
        left=parseInt(pos.x);
          $("FooterMailDiv").innerHTML=CreatePopUpDiv(divId);
        if(browserName.indexOf("MSIE 7.0")>=0)
        {	
	        $(divId).style.top=top;
	         $(divId).style.left=left;				    
        }else if(browserName.indexOf("MSIE 6.0")>=0) 
        {
	         $(divId).style.top=top;			    	 
	         $(divId).style.left=left;
        } else
        {
	        $(divId).style.top=top+"px";
	        $(divId).style.left=left+"px";			  
        }
    }       
    $(divId).style.visibility='visible';   
}

//Function to close the Popup Div
function ClosPopUpDiv(divId)
{
     $(divId).style.visibility='hidden';
}

function PortfolioPopupContent(pos,id,dispText)
{
    var backUrl='';
    var posTop=pos.y;
    var posLeft=pos.x+pos.w+5;
    var windowWidth=window.innerWidth;
    var windowHeight=window.innerHeight;
    if(windowWidth==null || windowWidth==0)
    {
        windowWidth=document.documentElement.clientWidth;
    }
    if(windowHeight==null || windowHeight==0)
    {
        windowHeight=document.documentElement.clientHeight;
    }
    if((posLeft+99)>windowWidth)
    {
        posLeft=posLeft-125;
    }
    posLeft=posLeft-80;
    posTop=posTop+25;
    var popupContent='<iframe id="PortfolioPopupFrame" src="" height="40" frameborder="0" scrolling="no" style="z-index:2000;width: 99px;  visibility: visible;position: absolute; top: '+posTop+'px; left: '+posLeft+'px;" ></iframe>';
    popupContent+='<div id="PortfolioPopup'+id+'" name="PortfolioPopup" style="z-index:2000;visibility: visible; background-repeat: repeat-y; background-image: url(/Images/table_middle_transparent.gif); top: '+posTop+'px; position: absolute; width: 99px; left: '+posLeft+'px;" onmouseover="javascript:$(\'isPortfolioClose\').value=\'false\';" onmouseout="javascript:$(\'isPortfolioClose\').value=\'true\';setTimeout(\'CloseBasket(\\\''+id+'\\\')\',2000); ">';
    popupContent+='<div style="background-image: url(/Images/table_top_transparant1.gif); background-repeat: no-repeat; background-position: left top;width:99px;">';
    popupContent+='<div style="padding:  0px 0px 0px 0px; background-image: url(/Images/table_bottom_transparent1.gif); background-repeat: no-repeat; background-position: left bottom;width:99px;">'
    popupContent+='<table cellpadding="0" cellspacing="0" border="0" width="100%">';
    popupContent+='<tbody>';
    popupContent+='<tr style="height: 10px;">';
    popupContent+='<td style="padding-left: 6px; border-bottom: #a7c7e7 1px solid; text-align: left">';
    popupContent+='<b style="color:#006BBC; font-size:12px;">'+dispText+'</b>';
    popupContent+='</td>';
    popupContent+='<td align="right" style="padding-right: 4px; padding-left: 0px; padding-bottom: 0px; margin: 5px 0px; width: 20%; padding-top: 0px; border-bottom: #a7c7e7 1px solid; text-align: right">';
    popupContent+='<b onclick="javascript:$(\'isPortfolioClose\').value=\'true\';ClosePortfolio(\''+id+'\');" title="Close" id="BCloseL" style="cursor: pointer; font-size: 16px; color: #006BBC;">X</b>';    
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='<tr height="20">';
    popupContent+='<td colspan="2" align="center" id="">';
    
    popupContent+='<b><span id="td_TypeName">Saved</span></b><br/>';
    popupContent+='</td>';
    popupContent+='</tr>';        
    popupContent+='</tbody>';
    popupContent+='</table>';
    popupContent+='<input type="hidden" id="isPortfolioClose" name="isBasketClose" value="true" />';
    
    popupContent+='</div>';
    popupContent+='</div>';
    popupContent+='</div>';
    return popupContent;    
}


function PortfolioPopup(visibleType,id,dispText)
{    
    if(visibleType=="visible")
    {
        $("FooterPortfolioDiv").innerHTML=PortfolioPopupContent(getPosition(id),id,dispText);        
        setTimeout("ClosePortfolio('"+id+"')",2000);
    }
    else
    {
        ClosePortfolio(id);
    }
}


function UpdateFundList(id,univ,isCost,text,eleId,dispText)
   { 	
    var typecode=id.substring(4,id.length);  
     clearInterval(x);
	var quantity= $("quantity"+typecode).value;
	var rowGuid= $("quantity"+typecode).name.replace("Quantity","");
	
	//var pid=port.value;	
	var CostValue= $("PD"+typecode);
	var pCost=CostValue.value;
	var fundcurrency= $("curr"+typecode).innerHTML;
	var currency='GBP';
	var hdnCost= $("hdnPD"+typecode).value;
	
	if(quantity=='')quantity=0;	
	if(pCost=='')pCost=0;	
	 var costV='';
	 if(isCost==1)
	 {
	 costV='1';
	 }
	 else
	 {
	  costV='0';
	 }
	 var pDate='';
	 if( $("cost"+typecode+"_"+univ))
	 {
	  pDate= $("cost"+typecode+"_"+univ).value;		 
	 }	

	 var isValid=true;
	 if(chkNumeric(CostValue) == false || chkNumeric( $("quantity"+typecode))==false)
	 {
	  quantity='0'
	  pCost ='0';
	  isValid=false;
	 }
	  if(quantity=='.')
	  {
	  quantity='0'
	  isValid=false;
	  }
	  if(CostValue.value=='.')
	  {	   	  
	   	  pCost ='0';
	   	  isValid=false;
	  }	  
	 
	if(isValid)
	{
	 PortfolioUpdateFundList(typecode,pDate,quantity,fundcurrency,currency,costV,pCost,rowGuid,port,userValue);  
	}
	PortfolioPopup('visible',eleId,dispText);
	//document.getElementById("update"+typecode).style.display="none";
	$("tr"+typecode).className= $("tr"+typecode).className.replace("Red");
	clearInterval(x);
}

function UpdateCashList(id,eleId,dispText)
{
  var typecode=id;
  window.clearInterval(x);
  var quantity= $("balance"+typecode).value;
  //var rowGuid=document.getElementById("quantity"+typecode).name.replace("Quantity","");	
  //var pid=port.value;	
  var name='';
  if( $(typecode)) name= $(typecode).value;
  if(name=='') name= $('name'+typecode).innerHTML;	
  var isValid=true;
  if(chkNumeric( $("balance"+typecode)) == false || quantity=='.' )
  {
  quantity='0'	  
  isValid=false;
  }
  if(isValid)
  {
	var fundcurrency= $("curr"+typecode).options[ $("curr"+typecode).selectedIndex].text;
	var AccType= $("acc"+typecode).options[ $("acc"+typecode).selectedIndex].text;
	var currency='GBP';
    CashUpdateList(typecode,quantity,fundcurrency,currency,AccType,name,port,userValue); 				
  }	 
   PortfolioPopup('visible',eleId,"Cash");
  // document.getElementById("update"+typecode).style.display="none";
   $("tr"+typecode).className= $("tr"+typecode).className.replace("Red");
   window.clearInterval(x);
}

function Doc_Resize()
{
	placeAdPositions();
	PlaceRegisterScreen();
}
	
function PlaceRegisterScreen()
{
	if($('regBlock'))
	{
		var isMainDiv = 0;
		var pos = getPosition('main');
		var top = parseInt(pos.y);
		var left = parseInt(pos.x) + 160;
		var width = overlayWidth;

		if($('QuickSearchStyle')) { top += 90; }
      
      var regBlockStyle = ($('regBlock').style) ? $('regBlock').style : $('regBlock');
		regBlockStyle.left = left + "px";
		regBlockStyle.top = top + "px";
		
		if($('contentPage'))
			regBlockStyle.height = $('contentPage').offsetHeight + "px";
		if($('main'))
			regBlockStyle.height = $('main').offsetHeight + "px";
		
		var regScreenStyle = ($('regScreen').style) ? $('regScreen').style : $('regScreen');
		regScreenStyle.left = left + "px";
		regScreenStyle.top = (top + 55) + "px";
		
		if(width != '' && width != '0')
		{
			regBlockStyle.width = width + "px";
			regScreenStyle.width = width + "px";
		}
	}
}

function getIEVersion()
{
   var rv = -1; // Return value assumes failure.
   if (navigator.appName == 'Microsoft Internet Explorer')
   {
      var ua = navigator.userAgent;
      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
      if (re.exec(ua) != null)
         rv = parseFloat( RegExp.$1 );
   }
   return rv;
}


function moveAdToPositionX(pos) {
   var box = "adPos_" + pos;
   var container = "adContainer_" + pos;
   var src = $(container);
   var dest = $(box);
   if(src && dest) {
		src.style.width = dest.offsetWidth;
		src.style.textAlign = (pos == "Top") ? "Right" : (pos == "Top3" ? "Center" : "");
		src.style.display = "inline";
		src.className="noPrint";
		if(pos == "Position1") {
			dest.style.width=src.offsetWidth+"px";
			dest.style.width="300px";
			
		}
        
        var ver = getIEVersion();
        if ( ver<= -1 || ver>= 8.0 )
        {
            var position = getPosition(box);
	        src.style.position = "absolute";
	        src.style.left = parseInt(position.x)+"px";
	        var top= parseInt(position.y);
	        if(pos=="TopRight")
	        {
	            top+=50;
	        }
	        src.style.top = top+"px";
            dest.style.height = src.offsetHeight+"px";
        }
        
        dest.replaceChild(src,dest.childNodes[0]);
		var eyeDiv = $("eyeDiv");
		if(eyeDiv){
			eyeDiv.className += eyeDiv.className.indexOf("noPrint") >= 0 ? "" : "noPrint";			
		}
   }
}

function moveAdPos(pos,box,container) {
   var src = $(container);
   var dest = $(box);
      
   if(src && dest) {
      var position = getPosition(box);
      src.style.left = parseInt(position.x)+"px";
          var top=parseInt(position.y);
	        if(pos=="TopRight")
	        {
	            top+=50;
	        }
      src.style.top = top+"px";
      dest.style.height = src.offsetHeight+"px";
      if(pos == "Position1") {
	        dest.style.width=src.offsetWidth+"px";
	        dest.style.width="300px";
	        
      }      
   }
}

function placeAdPositions() {
	if(OAS_listpos && OAS_listpos != "") {
		var arrAdPos = new Array()
		arrAdPos = OAS_listpos.split(',');
		for(var i=0; i<arrAdPos.length; i++) {
			var pos = arrAdPos[i];
			if(pos != "") {
				moveAdPos(pos,"adPos_" + pos,"adContainer_" + pos);
			}
		}
	}
}

function floatingAds(div, position) {
	div.style.left = parseInt(position.x)+"px";
	div.style.top = parseInt(position.y)+"px";
}


/************** Tabbed basket popup function starts here ***************/

function AddFundToBasket(typecode)
{
	var basketCookieName = "shortlisted";
	var basketOverriden = false;
	var overrideBasketElem = $('overrideBasketCookie');

	if(overrideBasketElem && overrideBasketElem.value != "") 
	{
		basketCookieName = overrideBasketElem.value;
		basketOverriden = true;
	}

   var value = GetCookie(basketCookieName);
	var count=$("NoOfShortListedItems");
	var isCodeRemoved = false;
	   
   if(value != "")
   {
	   var farray = new Array();
	   farray = value.split(',');

	   if(!IsStringFoundInArray(farray, typecode))
	   {
		  value += ","+typecode;			
		  if(count!=null && !basketOverriden){
			count.innerHTML="("+((parseInt(farray.length))+1)+")";              
		  }
	   }
	   else
	   {
		   DeleteFromShortlist(typecode, basketCookieName);
		   if(!basketOverriden){
				DeleteFromShortlist(typecode, "TN_RetainSelected");
			}
		   value = GetCookie(basketCookieName);			
		   if((farray.length-1)!=0){
				if(count!=null && !basketOverriden){
					count.innerHTML="("+(farray.length-1)+")";	
				}		   
		   }
		   else{
				if(count!=null && !basketOverriden){
					count.innerHTML="(0)";
				}
		   }
		   isCodeRemoved = true;
	   }
   }
   else
   {
	   value = typecode;
	   if(count != null && !basketOverriden){
			count.innerHTML="(1)";
	   }
   }
   
   if(!isCodeRemoved)
   {
	   SetCookie(basketCookieName, value, 123231);
	   retainSelectedVal(typecode);
   }
   else
   {
	   DeHighlightRows(typecode);
   }
   	
	HighLightSelectedRows();
}

function AddFundToPortfolio(typecode,addOrRemoveFund)
{
   var count=$("NoOfPortfolioItems");

	var eleBasketPId = $('basketDD');
	var selectBoxPId = $('basketDD') ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
	var isCodeRemoved = false;
	if(selectBoxPId=='') selectBoxPId=pId;
	if(addOrRemoveFund=='add')
	{
		PorttypeCodes += (PorttypeCodes != "") ? ","+typecode : typecode;
		AddPortfolioFundDisplay(selectBoxPId,userValue,univValue,typecode);
		SetCookie(userValue+"portfolio", PorttypeCodes, 123231);
		if(count && selectBoxPId==pId)
			count.innerHTML=parseInt(count.innerHTML)+1;
	}
	else if(addOrRemoveFund=='remove')
	{
		DeleteFromShortlist(typecode, userValue+"portfolio");	
		DeleteFromDB(typecode,PorttypeCodes);
		RemovePortfolioFundDisplay(selectBoxPId,userValue,typecode);
		if(count && selectBoxPId==pId)
			count.innerHTML=parseInt(count.innerHTML)-1;
	}
	HighLightSelectedRows();
}

function AddFundToWatchList(typecode,addOrRemoveFund)
{
	var count=$("NoOfWatchlistItems");
	if(addOrRemoveFund=='add')
	{
		WatchtypeCodes += (WatchtypeCodes != "") ? ","+typecode : typecode;
		SetCookie(userValue+"watch", WatchtypeCodes, 123231);		
		AddWatchlistFundDisplay(userValue,univValue,typecode,SiteCode);
		if(count)
			count.innerHTML=parseInt(count.innerHTML)+1;
	}
	else if(addOrRemoveFund=='remove')
	{
		DeleteFromShortlist(typecode, userValue+"watch");
		DeleteFromDB(typecode,WatchtypeCodes);
		RemoveWatchlistFundDisplay(userValue,typecode,SiteCode);
		if(count)
			count.innerHTML=parseInt(count.innerHTML)-1;
	}
	HighLightSelectedRows();
}

function HighLightSelectedRows()
{
	var basketCookieName = "shortlisted";
	var basketOverriden = false;
	var overrideBasketElem = $('overrideBasketCookie');

	if(overrideBasketElem) 
	{
		if(overrideBasketElem.value != "") 
		{
			basketCookieName = overrideBasketElem.value;
			basketOverriden = true;
		}
	}
	
	var typecodelist = GetCookie(basketCookieName);
	if(userId!='')
	{
		if(Mode.toUpperCase()=='PORT')
		{
			typecodelist = ',' + GetCookie(userId+"portfolio") + ',' + PorttypeCodes;
		}
		else if(Mode.toUpperCase()=='WATCH')
		{
			typecodelist = ',' + GetCookie(userId+"watch") + ',' + WatchtypeCodes;
		}
	}
	
	HighLightRows(typecodelist);
}

function CheckAndReturnUniv(paramUniv)
{
	var retUniv='';	
	if(paramUniv!='' && paramUniv.length>0)
	{
		var alphane = paramUniv;
		for(var j=0; j<alphane.length; j++)
		{
			var alphaa = alphane.charAt(j);
			var hh = alphaa.charCodeAt(0);
			if((hh > 64 && hh<91) || (hh > 96 && hh<123))
			{
				retUniv+=alphaa;
			}
 		}
	}
	return retUniv;
}

var PopUpTypeCode='';
var IsTypeCodeInPort=false;
function AddtoShortlist(typeCode)
{
	//PortfolioByUserId(userId);
	
	// This code is to set univValue in search page
	var docURL = document.URL;
	if(univValue=='' && docURL.toLowerCase().indexOf('search.aspx')>0)
	{
		var rowElement = $(typeCode);
		if(rowElement)
		{
			var rowInnerHTML = rowElement.innerHTML;
			var currentOccurance = rowInnerHTML.indexOf('univ=');
			var tempUniv = rowInnerHTML.substring(currentOccurance+5, currentOccurance+7);
			univValue=CheckAndReturnUniv(tempUniv);
		}	
	}
	
	// Common variables for all basket function 
	PopUpTypeCode = typeCode;
	IsTypeCodeInPort=false;
	
	var basketCookieName = "shortlisted";
	var basketOverriden = false;
	var overrideBasketElem = $('overrideBasketCookie');

	if(overrideBasketElem) 
	{
		if(overrideBasketElem.value != "") 
		{
			basketCookieName = overrideBasketElem.value;
			basketOverriden = true;
		}
	}
	
	var portvalue=Mode.toUpperCase();
   var value = GetCookie(basketCookieName);
	var count=$("NoOfShortListedItems");	

	if(portvalue == "PORT")
	{	
		IsTypeCodeInPort=CheckForPortTypeCode(typeCode);
		if(pId!='')
		{	
			if(IsTypeCodeInPort)
			{
				AddFundToPortfolio(typeCode,'remove');
				DisplayBasketPopUp(typeCode,'p','visible');
				ChangePortfolioRow('remove');
			}
			else
			{
				AddFundToPortfolio(typeCode,'add');
				DisplayBasketPopUp(typeCode,'p','visible');
				ChangePortfolioRow('add');
			}
		}
		else
		{	
			DisplayBasketPopUp(typeCode,'p','visible');
		}
   }
	else if(portvalue == "WATCH")
	{
		 if(!IsCodeExistInShortlist(typeCode, userId+'watch'))
		 {
			AddFundToWatchList(typeCode,'add');
	 		//ChangeBasketButtonCaption('watchlist',typeCode,'remove');
		 }
		 else
		 {	
			AddFundToWatchList(typeCode,'remove');
			//ChangeBasketButtonCaption('watchlist',typeCode,'add');
		 }		
		
		//ChangeBasketButtonCaption('watchlist',typeCode,'remove');
		DisplayBasketPopUp(typeCode,'w','visible');
	}
   else
   {
		AddFundToBasket(typeCode);
		DisplayBasketPopUp(typeCode,portvalue=='PRODUCTSEARCH'? 'ps' : 's','visible');
   }
   HighLightSelectedRows(portvalue);
}

function CheckForPortTypeCode(typeCode)
{
	return PorttypeCodes.indexOf(typeCode)>=0 ? true : false;
}

function DisplayBasketPopUp(typeCode, popupType, visibleType)
{		
   if(typeCode!=null && typeCode!='')
   {
       FundByType(typeCode);
   }
    
	if(visibleType=="visible")
   {
		$("FooterBasketDiv").innerHTML=BasketPopupContent(getPosition(typeCode),popupType,typeCode);
      $('curPopup').value=typeCode;
      
      // loading portfolio using webservice for basket dropdown
		PortfolioByUserId(userId);
      
      // Setting default tab
      switch(Mode.toUpperCase())
      {
			case "PORT":
			ChangeBasketTab('Portfolio',typeCode);
			break;
			
			case "WATCH":
			ChangeBasketTab('Watchlist',typeCode);
			break;
			
			default:
			ChangeBasketTab('Basket',typeCode);
			break;      
      }
      //ChangeBasketTab('Basket',typeCode);
				
      //setTimeout("CloseBasket('"+typeCode+"')",4000);
    }
    else
    {
        CloseBasket(typeCode);
    }
}

function CheckForPortfolioRow(lValue)
{
	var portfolioDD=$("basketDD");
	var portfolioRow1 = $("trSelectRow1");
	var portfolioRow2 = $("trSelectRow2");
	var portfolioRow3 = $("trSelectRow3");
	var portfolioRow4 = $("trSelectRow4");	
	
	if(portfolioDD && portfolioDD.options != null && portfolioDD.options[0]!=null &&  portfolioDD.options[0].value!='' && portfolioDD.options[0].text!='Select')
	{
		if(portfolioRow1)
			portfolioRow1.style.display='block';
		if(portfolioRow2)
			portfolioRow2.style.display='block';
		if(portfolioRow3)
			portfolioRow3.style.display='none';
		if(portfolioRow4)
			portfolioRow4.style.display='none';
	}
	else if(typeof(lValue)!='undefined' && lValue=='ws')
	{
		if(portfolioRow1)
			portfolioRow1.style.display='none';
		if(portfolioRow2)
			portfolioRow2.style.display='none';
		if(portfolioRow3)
			portfolioRow3.style.display='block';
		if(portfolioRow4)
			portfolioRow4.style.display='none';
	}
	
//	var selectBoxPId = $('basketDD') ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
//	if(selectBoxPId!='' && lValue=='ws')
//	{
//		CheckTypeCodeInPortfolio(selectBoxPId,PopUpTypeCode);
//		//PopUpTypeCode='';
//	}
}

function IsCodeExistInShortlist(typeCode, cookieName)
{
   var value = GetCookie(cookieName);
	if(value!=null && value!='' && value.indexOf(typeCode)>=0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ChangeBasketButtonCaption(tabName, typeCode, displayStatus)
{
	switch(tabName)
	{
		case 'basket':
		case 'product':
			var eleAddRow = $('basketAddRow');
			var eleRemoveRow = $('basketRemoveRow');
	
			if(displayStatus=='add')
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			else if(displayStatus=='remove')
			{
				eleRemoveRow.style.display='block';
				eleAddRow.style.display='none';	
			}
			else
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			break;
		case 'portfolio':
			var elePortfolioAddRow = $('portfolioAddRow');
			var elePortfolioRemoveRow = $('portfolioRemoveRow');
			if(displayStatus=='remove')
			{	
				if(elePortfolioAddRow)
					elePortfolioAddRow.style.display='none';
				if(elePortfolioRemoveRow)
					elePortfolioRemoveRow.style.display='block';
			}
			else
			{
				if(elePortfolioAddRow)
					elePortfolioAddRow.style.display='block';
				if(elePortfolioRemoveRow)
					elePortfolioRemoveRow.style.display='none';	
			}
		case 'watchlist':
			var eleAddRow = $('watchlistAddRow');
			var eleRemoveRow = $('watchlistRemoveRow');
	
			if(displayStatus=='add')
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			else if(displayStatus=='remove')
			{
				eleRemoveRow.style.display='block';
				eleAddRow.style.display='none';	
			}
			else
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			break;
		default:
			break;
	}
}

function ChangePortfolioRow(updateStatus)
{
	var elePortfolioAddRow = $('portfolioAddRow');	
	var elePortfolioRemoveRow = $('portfolioRemoveRow');
	var elePortfolioCancelRow = $('portfolioCancelRow');
	
	if(updateStatus=='add')
	{
		elePortfolioAddRow.style.display='none';
		elePortfolioCancelRow.style.display='none';
		elePortfolioRemoveRow.style.display='block';

	}
	else if(updateStatus=='remove')
	{
		elePortfolioRemoveRow.style.display='none';
		elePortfolioCancelRow.style.display='none';
		elePortfolioAddRow.style.display='block';		
	}
	else if(updateStatus=='add multiple')
	{
		elePortfolioCancelRow.style.display='block';
		elePortfolioAddRow.style.display='none';
		elePortfolioRemoveRow.style.display='none';
	}
}

function IsTypeCodeInPortfolio(r)
{
	var elePortfolioAddRow = $('portfolioAddRow');
	var elePortfolioRemoveRow = $('portfolioRemoveRow');
	if(r)
	{	
		if(elePortfolioAddRow)
			elePortfolioAddRow.style.display='none';
		if(elePortfolioRemoveRow)
			elePortfolioRemoveRow.style.display='block';
	}
	else
	{
		if(elePortfolioAddRow)
			elePortfolioAddRow.style.display='block';
		if(elePortfolioRemoveRow)
			elePortfolioRemoveRow.style.display='none';	
	}
	IsTypeCodeInPort=r;
}

function HighLightRows(typecodes)
{
	var basketOverriden = false;
	var overrideBasketElem = $('overrideBasketCookie');
	if(overrideBasketElem) {
		if(overrideBasketElem.value != "") {
			basketCookieName = overrideBasketElem.value;
			basketOverriden = true;
		}
	}
	if(typecodes != "")
	{	
	   var Title="basket";    
		var elements = document.getElementsByTagName("TR");
		var typecodeArr = typecodes.split(',');

		for(var i=0;i<elements.length;i++)
		{
			if(!IsStringFoundInArray(typecodeArr, elements[i].id) && (elements[i].className.indexOf("selected") >= 0))
			{
				elements[i].className = elements[i].className.replace("selected","");
				var imgTags = elements[i].getElementsByTagName('IMG');
				for(var j=0;j<imgTags.length;j++)
				{
					if(imgTags[j].src.indexOf("/icons/removeIco.png") >= 0)
					{
						imgTags[j].src = "/icons/icon_plus.png";
						imgTags[j].title = "add to "+Title;
						imgTags[j].width = "16";
						imgTags[j].height = "15";
					}
				}
			}
			if(IsStringFoundInArray(typecodeArr, elements[i].id) && elements[i].className.indexOf(" selected") < 0)
			{
				var imgTags = elements[i].getElementsByTagName('IMG');
				for(var j=0;j<imgTags.length;j++)
				{
					if(imgTags[j].src.indexOf("/icons/icon_plus.png") >= 0)
					{
						imgTags[j].src = "/icons/removeIco.png";
						imgTags[j].title = "remove from "+Title;
						imgTags[j].width = "14";
						imgTags[j].height = "14";
					}
				}
				elements[i].className += " selected";
			}
		}
		elements = document.getElementsByTagName("DIV");
		for(var i=0;i<elements.length;i++)
		{
			if(!IsStringFoundInArray(typecodeArr, elements[i].id) && (elements[i].className.indexOf("bold") >= 0))
			{
				elements[i].className = elements[i].className.replace("bold","");
				var imgTag = $("Img-"+elements[i].id);
				if(imgTag)
				{
					if(imgTag.src.indexOf("/icons/removeIco.png") >= 0)
					{
						imgTag.src = "/icons/icon_plus.png";
						imgTag.title = "add to "+Title;
						imgTag.width = "16";
						imgTag.height = "15";
					}
				}
				var divTag = $("span-"+elements[i].id);
				if(divTag)
				{
				    if(divTag.innerHTML.indexOf('equity') > 0)
				    {
				        divTag.innerHTML = "Add this equity from basket";
				    }
				    else
				    {
					    divTag.innerHTML = "Add this unit to basket";
					}
				}
			}
			if(IsStringFoundInArray(typecodeArr, elements[i].id) && elements[i].className.indexOf(" bold") < 0)
			{
				var imgTag = $("Img-"+elements[i].id);
				if(imgTag)
				{
					if(imgTag.src.indexOf("/icons/icon_plus.png") >= 0)
					{
						imgTag.src = "/icons/removeIco.png";
						imgTag.title = "remove from "+Title;
						imgTag.width = "14";
						imgTag.height = "14";
					}
				}
				var divTag = $("span-"+elements[i].id);
				if(divTag)
				{
				    if(divTag.innerHTML.indexOf('equity') > 0)
				    {
				        divTag.innerHTML = "Remove this equity from basket";
				    }
				    else
				    {
					    divTag.innerHTML = "Remove this unit from basket";
					}
				}
				elements[i].className += " bold";
			}
		}
	}
}

function BasketPopupContent(pos,popupType,typeCode)
{
    var posTop=pos.y;
    var posLeft=pos.x+pos.w+5;
    var windowWidth=window.innerWidth;
    var windowHeight=window.innerHeight;

    if(windowWidth==null || windowWidth==0)
    {
        windowWidth=document.documentElement.clientWidth;
    }

    if(windowHeight==null || windowHeight==0)
    {
        windowHeight=document.documentElement.clientHeight;
    }

    if((posLeft+220)>windowWidth)
    {
        posLeft=posLeft-245;
    }
        
    var popupContent='<iframe id="BasketPopupFrame" src="" height="100" frameborder="0" scrolling="no" style="z-index:2000;width: 220px;  visibility: visible;position: absolute; top: '+posTop+'px; left: '+posLeft+'px;" ></iframe>';
    //popupContent+='<div id="BasketPopup'+typeCode+'" name="BasketPopup" style="z-index:2000;visibility: visible; background-repeat: repeat-y; background-image: url(/Images/newBasketMiddle.gif); top: '+posTop+'px; position: absolute; width: 220px; left: '+posLeft+'px;" onmouseover="javascript:$(\'isBasketClose\').value=\'false\';" onmouseout="javascript:$(\'isBasketClose\').value=\'true\';setTimeout(\'CloseBasket(\\\''+typeCode+'\\\')\',4000);">';
    popupContent+='<div id="BasketPopup'+typeCode+'" name="BasketPopup" style="z-index:2000;visibility: visible; background-repeat: repeat-y; background-image: url(/Images/newBasketMiddle.gif); top: '+posTop+'px; position: absolute; width: 220px; left: '+posLeft+'px;" onmouseover="javascript:$(\'isBasketClose\').value=\'false\';">';
    popupContent+='<div style="background-image: url(/Images/newBasketTop.gif); background-repeat: no-repeat; background-position: left top;">';
    popupContent+='<div style="padding:  0px 16px 20px 10px; ">'
    popupContent+='<table cellpadding="0" cellspacing="0" border="0" width="100%">';
    popupContent+='<tbody>';
    popupContent+='<tr style="height: 23px;">';
    popupContent+='<td style="padding-left: 6px; border-bottom: #a7c7e7 1px solid;" colspan="3">';
    popupContent+='<b style="color:#006BBC; font-size:12px;float:left; valign=\'middle\'">Add to</b>';
    popupContent+='<b onclick="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" title="Close" id="BCloseL" style="cursor: pointer; font-size: 16px; color: #006BBC;float:right">X</b>';    
    popupContent+='</td>';
    popupContent+='</tr>';
        
    if(userId!='')
    {
		 if (popupType=='ps')
		 {	
			popupContent+='<tr height="20" align="center" style="cursor:pointer;">';
			popupContent+='<td id="tabBasket" style="border-bottom: #a7c7e7 1px solid;border-right: #a7c7e7 1px solid;">';
			popupContent+='<b onclick="javascript:ChangeBasketTab(\'Basket\',\''+typeCode+'\');">Product</b>';
			popupContent+='</td>';
		 }
		 else
		 {
		 	popupContent+='<tr height="20" align="center" style="cursor:pointer;">';
			popupContent+='<td id="tabBasket" style="border-bottom: #a7c7e7 1px solid;border-right: #a7c7e7 1px solid;">';
			popupContent+='<b onclick="javascript:ChangeBasketTab(\'Basket\',\''+typeCode+'\');">Basket</b>';
			popupContent+='</td>';		 
		 }
		 popupContent+='<td id="tabPortfolio" style="border-bottom: #a7c7e7 1px solid;border-right: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Portfolio\',\''+typeCode+'\');">Portfolio</b>';
		 popupContent+='</td>';
		 popupContent+='<td id="tabWatchlist" style="border-bottom: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Watchlist\',\''+typeCode+'\');">Watchlist</b>';
		 popupContent+='</td>';
		 popupContent+='</tr>';
    }
    else
    {
		 popupContent+='<tr height="20" align="center" style="cursor:pointer;">';
		 popupContent+='<td id="tabBasket" style="border-bottom: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Basket\',\''+typeCode+'\');">Basket</b>';
		 popupContent+='</td>';
		 popupContent+='<td id="tabPortfolio" style="border-bottom: #a7c7e7 1px solid;">  ';		 
		 popupContent+='</td>';
		 popupContent+='<td id="tabWatchlist" style="border-bottom: #a7c7e7 1px solid;">    ';
		 popupContent+='</td>';
		 popupContent+='</tr>';
    }
    
    popupContent+='<tr height="25">';
    popupContent+='<td colspan="3" align="center" style="vertical-align:bottom;">';
    popupContent+='<b><span id="td_TypeName">Loading..</span></b>';
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='<tr>';
    popupContent+='<td colspan="3" align="center">';
    
    // Basket tab content starts here
    popupContent+='<table id="tblBasket"  style="display: block;">';
    popupContent+='<tr>';
    popupContent+='<td>';
    //popupContent+=portName;
    popupContent+=' ';
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='<tr height="20" align="center" >';
    popupContent+='<td align="center" style="text-align:centre;">';

	 if (popupType=='ps')
	 {	
		popupContent+='<div id=\'basketAddRow\' style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToBasket(\''+typeCode+'\',\'add\');UpdateBasket();ChangeBasketButtonCaption(\'product\',\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Add</b></a>';
		popupContent+='&nbsp;			             &nbsp;';
		popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</div>';
		
		popupContent+='<div id=\'basketRemoveRow\' style="width: 100%;display: none;">';
		popupContent+='<a id=\'basketAddlink\' name=\'basketAddlink\' href="javascript:AddFundToBasket(\''+typeCode+'\');ChangeBasketButtonCaption(\'product\',\''+typeCode+'\',\'add\');" style="text-decoration: underline;"><b>Remove</b></a>';
		popupContent+='&nbsp;			             &nbsp;';
		popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</div>';
	 }
	 else
	 {
		 //popupContent+='<td align="center" style="text-align:centre;">';
		 popupContent+='<div id=\'basketAddRow\' style="width: 100%;display: none;">';
		 popupContent+='<a id=\'basketAddlink\' name=\'basketAddlink\' href="javascript:AddFundToBasket(\''+typeCode+'\');ChangeBasketButtonCaption(\'basket\',\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Add</b></a>';
		 popupContent+='&nbsp;			             &nbsp;';
		 popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		 popupContent+='</div>';
			
		 popupContent+='<div id=\'basketRemoveRow\' style="width: 100%;display: none;">';
		 popupContent+='<a id=\'basketAddlink\' name=\'basketAddlink\' href="javascript:AddFundToBasket(\''+typeCode+'\');ChangeBasketButtonCaption(\'basket\',\''+typeCode+'\',\'add\');" style="text-decoration: underline;"><b>Remove</b></a>';
		 popupContent+='&nbsp;			             &nbsp;';
		 popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		 popupContent+='</div>';
		 //popupContent+='</td>';
	 }
	     
    popupContent+='</td>';
    popupContent+='</tr>';
    
    popupContent+='<tr height="20">';
	 popupContent+='<td align="center">';
    popupContent+='<a href="/Tools/Tools.aspx" style="text-decoration: underline;"><b>Back to Tools</b></a>';    
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='</table>';

	 // Portfolio tab content starts here
	 popupContent+='<table id="tblPortfolio"  style="height: 60px; display: none;">';

	 // If portfolio exist display the below two rows
	 popupContent+='<tr id=\'trSelectRow1\' style="display: none;">';
	 popupContent+='<td>';
	 popupContent += '<select id="basketDD" name="basketDD" style="width:144px;" onchange="javascript:ChangeBasketTab(\'Portfolio\',\''+typeCode+'\');"><option value="">Select</option></select>';
	 popupContent+='</td>';
	 popupContent+='</tr>';

 
	 if (popupType=='ProductSearch')
	 {
	 	popupContent+='<tr id=\'trSelectRow2\' height="20" style="display: none;">';
		popupContent+='<td align="center">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'add\');UpdateBasket();$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</td>';
		popupContent+='</tr>';
	 }
	 else
	 {
	 	popupContent+='<tr id=\'trSelectRow2\' height="20" style="display: none;">';
		popupContent+='<td align="center">';
		//	Add and Cancel button
		popupContent+='<div id=\'portfolioAddRow\'  style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'add\');ChangePortfolioRow(\'add\');" style="text-decoration: underline;"><b>Add</b></a>';
		popupContent+='&nbsp;                  &nbsp;';
		popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</div>';
		//	Remove and Add multiple button 
		popupContent+='<div id=\'portfolioRemoveRow\'  style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'remove\');ChangePortfolioRow(\'remove\');" style="text-decoration: underline;"><b>Remove</b></a>';
		popupContent+='&nbsp;                  &nbsp;';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'add\');ChangePortfolioRow(\'add multiple\');" style="text-decoration: underline;"><b>Add Multiple</b></a>';
		popupContent+='</div>';
		// Remove and Cancel button
		popupContent+='<div id=\'portfolioCancelRow\'  style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'remove\');ChangePortfolioRow(\'remove\');" style="text-decoration: underline;"><b>Remove</b></a>';
		popupContent+='&nbsp;                  &nbsp;';
		popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</div>';
		popupContent+='</td>';
		popupContent+='</tr>';
	 }
	
   // If no portfolio exist display this block.
	popupContent+='<tr id=\'trSelectRow3\' height="20"  style="display: none;" >';
	popupContent+='<td align="center">';
	popupContent+='No portfolio exist. <a href="/Tools/Portfolio/ManagePortfolio.aspx" style="text-decoration: underline;">Click here</a> to create a new portfolio.';
	popupContent+='</td>';
	popupContent+='</tr>';

	popupContent+='<tr id=\'trSelectRow4\' height="20"  style="display: block;" >';
	popupContent+='<td align="center">';
	popupContent+='Loading Portfolio...';
	popupContent+='</td>';
	popupContent+='</tr>';
		 
	popupContent+='<tr height="20">';
	popupContent+='<td align="center">';
   popupContent+='<a href="/Tools/Portfolio/Valuation.aspx" style="text-decoration: underline;"><b>Back to Portfolio</b></a>';    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='</table>';
    
   // Watchlist tab content starts here
   popupContent+='<table id="tblWatchlist"  style="display: none;">';
   popupContent+='<tr>';
   popupContent+='<td> ';
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='<tr height="20">';
   popupContent+='<td align="center">';

   popupContent+='<div id=\'watchlistAddRow\' style="width: 100%;display: none;">';
   popupContent+='<a id=\'watchListAddLink\' href="javascript:AddFundToWatchList(\''+typeCode+'\',\'add\');ChangeBasketButtonCaption(\'watchlist\',\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Add</b></a>';
   popupContent+='&nbsp;			             &nbsp;';
	popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
   popupContent+='</div>';
    
   popupContent+='<div id=\'watchlistRemoveRow\' style="width: 100%;display: none;">';
   popupContent+='<a id=\'watchListAddLink\' href="javascript:AddFundToWatchList(\''+typeCode+'\',\'remove\');ChangeBasketButtonCaption(\'watchlist\',\''+typeCode+'\',\'add\');" style="text-decoration: underline;"><b>Remove</b></a>';
   popupContent+='&nbsp;			             &nbsp;';
	popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
   popupContent+='</div>';
    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='<tr height="20">';
   popupContent+='<td align="center">';
   popupContent+='<a href="/Tools/Portfolio/Watchlist.aspx" style="text-decoration: underline;"><b>Back to Watchlist</b></a>';    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='</table>';

    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='</tbody>';
   popupContent+='</table>';
   popupContent+='<input type="hidden" id="isBasketClose" name="isBasketClose" value="true" />';
   popupContent+='<input type="hidden" id="curPopup" name="curPopup" value="" />';
   popupContent+='</div>';
   popupContent+='</div>';
   popupContent+='<div>';
   popupContent+='<table border="0" cellspacing="0" cellpadding="0" style="width:217px;margin-bottom:-2px;">';
   popupContent+='<tr>';
   popupContent+='<td>';
   popupContent+='<img src="/images/invesco_ad_curve_bottom.gif" alt="" style="width:217px;"/>';
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='<tr>';
   popupContent+='<td>';
   popupContent+='<h3 style="width:216px;margin:0px;background-image: url(/Images/invesco_ad_heading_bg.gif);background-repeat: repeat-x; background-position: left top;text-align:center;color:white;font-size:14px;padding-top:2px;padding-bottom:2px;">Visit <a style="color:white;font-size:14px;" href="/General/Redirect.aspx?url=http%3A%2F%2Fbs.serving-sys.com%2FBurstingPipe%2FadServer.bs%3Fcn%3Dtf%26c%3D20%26mc%3Dclick%26pli%3D1618089%26PluID%3D0%26ord%3D%25%25REALRAND%25%25" target="_blank">microsite</a> to view funds<br/> in this sector</h3>';
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='<tr>';
   popupContent+='<td>';
   popupContent+='<a href="/General/Redirect.aspx?url=http%3A%2F%2Fbs.serving-sys.com%2FBurstingPipe%2FadServer.bs%3Fcn%3Dtf%26c%3D20%26mc%3Dclick%26pli%3D1618083%26PluID%3D0%26ord%3D%25%25REALRAND%25%25" target="_blank"><img src="/images/invesco_ad.png" alt="" /></a>';
   popupContent+='</td>';
   popupContent+='</tr>';  
      
   popupContent+='</table>';
   popupContent+='</div>';
   popupContent+='</div>';
   return popupContent;
}

function ChangeBasketTab(type,typeCode)
{
    if(type=='ProductSearch')
    {
       type='Basket'; 
    }
    
    var types=new Array('Basket','Portfolio','Watchlist');
    for(var i=0;i<3;i++)
    {
         var tblElement=document.getElementById('tbl'+types[i]);
         var tabElement=document.getElementById('tab'+types[i]);
         if(type==types[i])
         {
            tblElement.style.display='block';
            tabElement.style.color='#006BBC';
         }
         else
         {
            tblElement.style.display='none';
            tabElement.style.color='#000000';
         }
    }
    
	 if(type=='Portfolio')
    {
		if(Mode.toUpperCase()!='PORT')
		{
			CheckForPortfolioRow();
		}
			//SelectCurrentPortfolio();
			var selectBoxPId = $('basketDD') && $('basketDD').selectedIndex!=-1 ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
			if(selectBoxPId!='')
				CheckTypeCodeInPortfolio(selectBoxPId,typeCode);
		
    }
    
    if(type=='Basket')
    {
		var basketCookieName='shortlisted';
		var basketOverriden = false;
		var overrideBasketElem = $('overrideBasketCookie');
		if(overrideBasketElem) {
			if(overrideBasketElem.value != "") {
				basketCookieName = overrideBasketElem.value;
				basketOverriden = true;
			}
		}
		
		if(basketCookieName=='productSearch')
		{
			if(!IsCodeExistInShortlist(typeCode,basketCookieName))
			{
				ChangeBasketButtonCaption('product',typeCode,'add');
			}
			else
			{
				ChangeBasketButtonCaption('product',typeCode,'remove');
			}
		}
		else
		{
			if(!IsCodeExistInShortlist(typeCode,'shortlisted'))
			{
				ChangeBasketButtonCaption('basket',typeCode,'add');
			}
			else
			{
				ChangeBasketButtonCaption('basket',typeCode,'remove');
			}
		}
    }
    if(type=='Watchlist')
    {
		 if(!IsCodeExistInShortlist(typeCode, userId+'watch'))
		 {
	 		ChangeBasketButtonCaption('watchlist',typeCode,'add');
		 }
		 else
		 {	
			ChangeBasketButtonCaption('watchlist',typeCode,'remove');
		 }	
	 }
}

// Webservice method
function PopulateBasketPortfolio(UserPortfolio)
{
	if(UserPortfolio!=null && UserPortfolio!='')
   {
		var portfolioDD=$("basketDD");
           
		// Skip this code when this element doesn't exit	  
		if(portfolioDD)
		{
			portfolioDD.options.length=0;

			for(i=0;i<UserPortfolio.length;i++)
			{
				if(UserPortfolio[i]!=null) 
				{
					var optionElement=document.createElement("option");				 
					if(typeof UserPortfolio[i].PortfolioName !='undefined')
					{
					   if(UserPortfolio[i].PortfolioName!=null && UserPortfolio[i].PortfolioName!='')
						{
							optionElement.text=UserPortfolio[i].PortfolioName;
							optionElement.value=UserPortfolio[i].PortfolioId;
							portfolioDD.options.add(optionElement);
						}
					}
				}
			}
			if(Mode.toUpperCase()=='PORT')
			{
				//CheckForPortfolioRow('ws');
				SelectCurrentPortfolio();
				var selectBoxPId = $('basketDD') ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
				if(selectBoxPId!='')
				{
					//CheckTypeCodeInPortfolio(selectBoxPId,PopUpTypeCode);
					PopUpTypeCode='';
					//CheckTypeCodeInPortfolio(selectBoxPId,'');
				}
			}
		}
		CheckForPortfolioRow('ws');
		//SelectCurrentPortfolio();
	}
}

function SelectCurrentPortfolio()
{
	var elePortDropDown = $('basketDD');
	if(elePortDropDown && pId!='')
	{
		for(i=0;i<elePortDropDown.options.length;i++) 
		{
			if(elePortDropDown.options[i].value==pId) 
			{
				elePortDropDown.options[i].selected = 'selected';
				break;				   
			}
		} 
	}
}

function GetInvCookie(name) {

    if(document.cookie.length==0)
    {   return '';
    } 
    
    var a=document.cookie.match('(^|;) ?'+name+'=([^;]*)(;|$)'); 
    if(a){
    return (unescape(a[2]));
    } 
    else {
    return '';
    } 
}

/********************ContactUs Email*************************/

function RequireCountry()
	{
		if(document.getElementById("CountryCB").value == "Other")
		{
			document.getElementById("CountryT").style.visibility="Visible";
		}
		else	
		{
			document.getElementById("CountryT").style.visibility="hidden";
		}
	}
	function SendContactEmail()
	{		
	    var logUserName=$('logeduserName').value;
	    var commentValue=$('CommentsTA').value;
	    commentValue=commentValue.LTrim();
	    commentValue=commentValue.RTrim();
	    var commnetText=Encodehtml(commentValue);
	    var countryName=$('countryName').value;
        var investorType=$('investorName').value;  
        if(investorType=='')
        {
           investorType=$('investorType').value; 
        } 
        var referedUrl=$('referedUrl').value;   
        var userAgent=navigator.userAgent;
	    var cookieValue=document.cookie;	
	    var designSource=$("mailtemplate").innerHTML;
	    var telePhone = $("Telephone").value;
	    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    var email;
	    var uName;
	    if(logUserName=='')
	    {
	        email=$('EmailT').value; 
	        uName=$('NameT').value; 
	        uName=uName.LTrim();
	        uName=uName.RTrim();
	        	    
	        if(email=='')
	        {
	            $('emailId').style.visibility='visible'; 
	            $('mandatory').style.visibility='visible'; 	              
	        }else
	        {	                	                
	                if(!email.match(emailRegEx))
	                {
	                    $('emailId').style.visibility='visible';
	                     $('mandatory').style.visibility='visible'; 
	                    alert('Enter vallid email');
	                    return false;
	                }
	                else
	                {
	                    $('emailId').style.visibility='hidden';
	                     $('mandatory').style.visibility='hidden'; 
	                }
	        }
	        if(countryName=='')
	        {
	            $('country').style.visibility='visible'; 
	            $('mandatory').style.visibility='visible'; 
	            return false;
	            
	        }else
	        {
	            $('country').style.visibility='hidden'; 
	            $('mandatory').style.visibility='hidden';
	        }
	      }
	      else
	      {
	         uName=logUserName;         
	         email=$('userEmail').value;  
	      }  
            if(commnetText=='')
	        {		    			
		        alert("Please enter your comment");			
		        return false;
	        }
	        else if(commnetText.length>4000)
	        {
	            alert("your comment limit is 4000 characters");
		        return false;
	        }
		    else
		    {				
			    $("SendT").value="1";
			    
			    $("btnSend").className = 'buttonNone';			    
			    $('sendStatus').style.visibility='visible'; 
			    $('CommentsTA').value='';
		        $('Telephone').value=''; 			          
		        $('sendStatus').innerHTML="Your feedback has been sent to our email address helpdesk@financialexpress.net";			    			    
		       TrustnetX.About.Contact.SendFeedBackMail(uName,email,countryName,investorType,commnetText,referedUrl,userAgent,cookieValue,telePhone,CallBack);			                    			        
		    }    	
	}
	
	function CallBack(res)
	{
	
	}
	
//	function EnableDisableElement(chValue,elementIds)
//	{
//	    var elementArray=new Array();
//	     elementArray=elementIds.split(',');
//	     for(var i=0;i<elementArray.length;i++)
//	     {
//	        var visibleStatus='hidden';	        
//	        if(chValue=='')
//	        {
//	            visibleStatus='visible';
//	            
//	            if(i>0 && i==elementArray.length-1)
//	            return false;
//	        }
//	        	        
//	        $(elementArray[i]).style.visibility=visibleStatus;
//	     } 
//	}
	
	function ValidateComments(str) {
       if(!ValidateString(str))
		{
			alert('Invalid input, please provide valid input.');
			return false;
		}
		return true;
	} 
     
     function  GetOptionValue(selectId)
     {
         if(document.getElementById(selectId) != null) {
            if(selectId=='countryresidence')
            {               
              document.getElementById('countryName').value=document.getElementById(selectId).value;                
            }else if(selectId=='investorType')
            {
                document.getElementById('investorName').value=document.getElementById(selectId).value;
            }            
         }
     }   
     function Encodehtml(text) {
        
        var textneu = text.replace(/&/g,"&amp;");
        textneu = textneu.replace(/</g,"&lt;");
        textneu = textneu.replace(/>/g,"&gt;");
        textneu = textneu.replace(/\r\n/g,"<br>");
        textneu = textneu.replace(/\n/g,"<br>");
        textneu = textneu.replace(/\r/g,"<br>");
        return(textneu);
    }  
    
       
 // trim blank space at the beginning
 String.prototype.LTrim = function()
 {
 return this.replace(/(^\s*)/g, "");
 }
  
 // trim blank space at the end
 String.prototype.RTrim = function()
 {
 return this.replace(/(\s*$)/g, "");}
 
 //Portfolio Focus function
 function FocusElement(id)
 {
    var idValue=$(id).value;
    if(idValue==0)
    {
       //$(id).select();
       $(id).value='';
    }else
    {
        $(id).focus();
    }    
}       

/************************End contactUs*****************************/

/************************ START POLL ******************************/


function  ShowHidePoll()
{    
    var choiceId=getCheckedValue(document.forms['masterForm'].elements['btnRadio']);
    if(choiceId=='')
    {
        alert('Please choose any one choice');
    }
    else if(pollEnable==1)
    {
       pollEnable=0;
      document.body.style.cursor = 'wait';
      $('pollImg').style.cursor = 'wait';
          var pws = new PortfolioWebService();
          pws.UpdatePollChoice(GetUpdateValues,QuestionId,choiceId);
       SetCookie("TN_Poll", QuestionId,1232);
    }
}
function GetUpdateValues(result)
{
document.body.style.cursor = 'default';
$('pollImg').style.cursor = 'default';
pollChoice=result;	   
var pollString='';
var totalVotes=0;
$('AfterPoll').innerHTML='';

for(i=0;i<pollChoice.length;i++)
{
   totalVotes+=pollChoice[i].SuggestedTotal;   
}	  

if($('AfterPoll').firstChild!=null)
{
    $('AfterPoll').firstChild.nodeValue = '';
}

outerTable=document.createElement("table"); 
outerTable.setAttribute("border","0");
outerTable.setAttribute("cellpadding","0");
outerTable.setAttribute("cellspacing","0");

outerTablebody = document.createElement("tbody");
outerCurrent_row = document.createElement("tr");                
outerCurrent_cell = document.createElement("td");
//outerCurrent_cell.setAttribute("style","padding-right:3px;");

for(i=0;i<pollChoice.length;i++)
{	       
var suggestTotal=pollChoice[i].SuggestedTotal;
var percentage=(suggestTotal/totalVotes)*100;
var imgWidth=(90*suggestTotal)/totalVotes;
var noOfVotes='';

    if(suggestTotal==0){
        imgWidth=0;
        noOfVotes='Nil';
    }else{
        if(suggestTotal>1){noOfVotes=suggestTotal+' votes';}
        else{noOfVotes=suggestTotal+' vote';}
    }
    	    
    myTable=document.createElement("table"); 
    myTable.setAttribute("border","0");
    myTable.setAttribute("cellpadding","0");
    myTable.setAttribute("cellspacing","0");
    
    mytablebody = document.createElement("tbody"); 	                  
    mycurrent_row = document.createElement("tr");                
    mycurrent_cell = document.createElement("td");
    mycurrent_cell.setAttribute("style","padding-left:5px;");
    
    myDiv=document.createElement("div");                
    myDiv.setAttribute("title",noOfVotes);
    if(imgWidth==0){
        myDiv.setAttribute("style","float:left;");               
    }else{
        myDiv.setAttribute("class","pollDiv");
        myDiv.setAttribute("style","width:"+imgWidth+"px;");               
    }
    mycurrent_cell.appendChild(myDiv); 
    
    mySpan=document.createElement("div");
    var roundValue=''+Math.round(percentage)+'%';
    currenttext = document.createTextNode(roundValue);
    mySpan.appendChild(currenttext);
    mySpan.setAttribute("style","padding-left:5px;color:#000000;font-weight:bold;");               
    mycurrent_cell.appendChild(mySpan);                 
                                                                                                                         
    mycurrent_row.appendChild(mycurrent_cell);  
    mytablebody.appendChild(mycurrent_row);

    mycurrent_row1 = document.createElement("tr");
    mycurrent_cell1 = document.createElement("td");
    mycurrent_cell1.setAttribute("class","smallTxt");                   
    currenttext = document.createTextNode(pollChoice[i].ChoiceText);
    mycurrent_cell1.appendChild(currenttext);   
    mycurrent_row1.appendChild(mycurrent_cell1);                                                
    mytablebody.appendChild(mycurrent_row1);    
    myTable.appendChild(mytablebody);
    
    outerCurrent_cell.appendChild(myTable);
    
    borderDiv=document.createElement("div");
    borderDiv.setAttribute("class","topbottomBorder");
    outerCurrent_cell.appendChild(borderDiv);
    
    outerCurrent_row.appendChild(outerCurrent_cell);
    outerTablebody.appendChild(outerCurrent_row);
    outerTable.appendChild(outerTablebody);
    
}	   	             
    total_row=document.createElement("tr");
    total_cell=document.createElement("td");
    total_cell.setAttribute("style","font-weight:bold;padding-left:5px;");
    var totalText='';
    if(totalVotes>0 && totalVotes==1)
    {
        totalText=totalVotes+' vote';
    }else if(totalVotes>0 && totalVotes>1)
    {
        totalText=totalVotes+' votes';
    }
    totalText = document.createTextNode(totalText);
    total_cell.appendChild(totalText);  
    total_row.appendChild(total_cell); 
    outerTablebody.appendChild(total_row);
    outerTable.appendChild(outerTablebody);
    
    OuterBorderDiv=document.createElement("div");
    OuterBorderDiv.setAttribute("class","topbottomBorder");     
    
    $('AfterPoll').appendChild(OuterBorderDiv);
    $('AfterPoll').appendChild(outerTable);
        	    	    	   
    $('BeforePoll').className='displayNone';
    $('AfterPoll').className='displayBlock';
}

function getCheckedValue(radioObj) {
    if(!radioObj)
	    return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
	    if(radioObj.checked)
		    return radioObj.value;
	    else
		    return "";
    for(var i = 0; i < radioLength; i++) {
	    if(radioObj[i].checked) {
		    return radioObj[i].value;
	    }
    }
    return "";
}

/************************ END POLL ********************************/

function OpenResearchPage(paramArticleId){
	window.location = "/News/Research.aspx?id=" + paramArticleId;
}

function ChangeHoverRegion(ele, action) {	
	ele.style.backgroundColor = (action=='in') ? '#ecf1f9' : '#FFFFFF';
}

/********************* ANNUITY SEARCH *******************************/
function AssignSpouseGender(genderId){
    var element=$(genderId);
    var spouseGender='Female';
    var gender=element.options[element.selectedIndex].value;
    if(gender=='F'){
        spouseGender='Male';}	        
    $('lblGender').innerHTML=spouseGender;	     
}
	    
function EnableJoint(id){
    var enable=$(id).checked;
    if(enable){
        $('SpouseDetail').style.display='block';	            
    }else{
        $('SpouseDetail').style.display='none';            	            
    }
}
	    
function SearchAnnuity(){	    
    var leadGender=$('ddlGender').options[$('ddlGender').selectedIndex].value;       
    var leadAge=$('txtLeadAge').value;
    var profit=$('ddlProfit').value;
     if(profit=='')
    profit=$('ddlProfit').options[$('ddlProfit').selectedIndex].value;
    
    var product=$('ddlProduct').value;
    if(product=='')
    product=$('ddlProduct').options[$('ddlProduct').selectedIndex].value;
    
    var isJoint=$('ckJoint').checked;
    var spouseAge='';
    var reduction='';
    var impairment=$('ddlImpairment').value;
    if(impairment=='')
    impairment=$('ddlImpairment').options[$('ddlImpairment').selectedIndex].value;
    
    var escalation=$('ddlEscalation').value;
    if(escalation=='')
    escalation=$('ddlEscalation').options[$('ddlEscalation').selectedIndex].value;
    
    var guarantee=$('ddlGuarantee').value;
    if(guarantee=='')
    guarantee=$('ddlGuarantee').options[$('ddlGuarantee').selectedIndex].value;
    
    var purchaseprice=$('txtPurchasePrice').value;	        	        	        
   	        	        
    if(isJoint)
    {
        spouseAge=$('txtSpouseAge').value; 
        reduction=$('ddlReduction').value; 
        
        if(reduction=='')
            reduction=$('ddlReduction').options[$('ddlReduction').selectedIndex].value;
            
        if(spouseAge<35 || spouseAge>90 || isNaN(spouseAge) || spouseAge=='')
        {
            alert('Your spouse age should be in 35 to 90');  
            $('txtSpouseAge').focus();
         }
        else if(leadAge<35 || leadAge>90 || leadAge=='' || isNaN(leadAge))
        {
            alert('Your age should be in 35 to 90');  
            $('txtLeadAge').focus();
        }
        else if(purchaseprice=='' || purchaseprice<5000 || purchaseprice>999999 || isNaN(purchaseprice))
        {
            alert('Purchase price should be in range from 5000 to 999999');  
             $('txtPurchasePrice').focus();
        }
        else
        {                 
            var url=document.URL;   
            if(url.indexOf("?")>0){
                url=url.substring(0,url.indexOf("?"));  
            }                    
            url+="?lGender="+leadGender+"&lAge="+leadAge+"&profit="+profit+"&product="+product+"&joint="+isJoint+"&sAge="+spouseAge+"&reduction="+reduction+"&impair="+impairment+"&escalation="+escalation+"&guarantee="+guarantee+"&pPrice="+purchaseprice;                                              
            document.masterForm.action=url+"&search=1";
            document.masterForm.submit();
         }
    }else{	            
        if(leadAge<35 || leadAge>90 || leadAge=='' || isNaN(leadAge)){
            alert('Your age should be in 35 to 90');  
            $('txtLeadAge').focus();
         }
        else if(purchaseprice=='' || purchaseprice<5000 || purchaseprice>999999 || isNaN(purchaseprice)){
            alert('Purchase price should be in 5000 to 999999');  
            $('txtPurchasePrice').focus();
        }
        else{	                
            var url=document.URL;   
            if(url.indexOf("?")>0)
            {
                url=url.substring(0,url.indexOf("?"));                          
            }     
            url+="?lGender="+leadGender+"&lAge="+leadAge+"&profit="+profit+"&product="+product+"&joint="+isJoint+"&sAge="+spouseAge+"&reduction="+reduction+"&impair="+impairment+"&escalation="+escalation+"&guarantee="+guarantee+"&pPrice="+purchaseprice;                       
            document.masterForm.action=url+"&search=1";
            document.masterForm.submit();	           	           	        	        
        }
    }
}
/********************* END ANNUITY SEARCH *******************************/



/***********************PRINT ICON ON FACTSHEET************************/
 
 function ShowPrintIcon()
 {
 var userId=GetCookie("TN_UserId")             
  if(userId=='')
  {
     var pos;
    var top;
    var left;
    var browserName=window.navigator.userAgent;
    pos=getPosition("printIcon");            
    top=parseInt(pos.y);
    left=parseInt(pos.x);
      $("FooterMailDiv").innerHTML=CreateLogInDiv();
    if(browserName.indexOf("MSIE 7.0")>=0)
    {	
        $('loginDiv').style.top=top;
         $('loginDiv').style.left=left;				    
    }else if(browserName.indexOf("MSIE 6.0")>=0) 
    {
         $('loginDiv').style.top=top+10;			    	 
         $('loginDiv').style.left=left;
    } else
    {
        $('loginDiv').style.top=(top+10)+"px";
        $('loginDiv').style.left=(left)+"px";			  
    }
            
    $('loginDiv').style.visibility='visible';
  }
  else
  {
        var url=document.URL;   
        url+=(url.indexOf("?")>0)?"&print=true":"?print=true"       
        document.masterForm.action=url;
        document.masterForm.submit();	  
            
  }
}
/***********************END******************************************/


/************* Tabbed basket popup function ends here *************/

/************* New approach basket code starts here	**************/

/*
var PopUpTypeCode='';
var PopUpSelecteTab='General';
//var IsTypeCodeInPort=false;
function AddtoShortlist(typeCode)
{
	// This code is to set univValue in search.aspx page
	var docURL = document.URL;
	if(univValue=='' && docURL.toLowerCase().indexOf('search.aspx')>0)
	{
		var rowElement = $(typeCode);
		if(rowElement)
		{
			var rowInnerHTML = rowElement.innerHTML;
			var currentOccurance = rowInnerHTML.indexOf('univ=');
			var tempUniv = rowInnerHTML.substring(currentOccurance+5, currentOccurance+7);
			univValue=CheckAndReturnUniv(tempUniv);
		}
	}

	// Common variables for all basket function 
	PopUpTypeCode = typeCode;
	
	var eleWatchlistDetails = $('completeWatchlistDetail');
	if(eleWatchlistDetails && eleWatchlistDetails.value=='')
	{
		WatchlistByUserId(userId);
	}
	
	var elePortfolioDetails = $('completePortfolioDetail');			
	if(elePortfolioDetails && elePortfolioDetails.value=='')
	{
		PortfolioByUserId(userId);
	}
	
	var portvalue=GetSelectedBasketTab();
	switch(portvalue)
	{
		case "PORT":
			if(pId!='' && !IsTypeCodeInHdnPortfolio(pId,typeCode))
			{
				AddFundToPortfolio(typeCode,'add');
			}
			else if(pId!='' && IsTypeCodeInHdnPortfolio(pId,typeCode))
			{
				AddFundToPortfolio(typeCode,'remove');
			}
			DisplayBasketPopUp(typeCode,'p','visible');
			HighLightSelectedRows('PORT');
			break;
			
		case "WATCH":
			AddFundToWatchList(typeCode, !IsTypeCodeInHdnWatchList(typeCode) && WatchtypeCodes.indexOf(typeCode)<0 ?  'add': 'remove');
			DisplayBasketPopUp(typeCode,'w','visible');
			HighLightSelectedRows('WATCH');
			break;
			
		default:
			AddFundToBasket(typeCode);
			DisplayBasketPopUp(typeCode,'s','visible');
			HighLightSelectedRows('GENERAL');
			break;
	}
}

function GetSelectedBasketTab()
{
	var selectedTab='GENERAL';
	var basketCookieValue = GetCookie("TN_Mode").toUpperCase();
	if(basketCookieValue!='' && basketCookieValue!=null)
	{
		if(basketCookieValue=='PORT')
		{
			var portCookieValue = GetCookie("TN_Portfolio");
			
			if(portCookieValue!='' && portCookieValue!=null)
			{
				pId=portCookieValue;
			}
		}
		else
		{
			pId='';
		}
		selectedTab=basketCookieValue;
	}
	return selectedTab;
}

function SetDefaultBasketTab(basketValue)
{	
	if(basketValue=='PORT')
	{
		var selectBoxPId = $('basketDD') ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
		if(selectBoxPId!='')
		{
			SetCookie("TN_Portfolio", selectBoxPId);
		}
	}
	SetCookie("TN_Mode", basketValue);
}

function IsTypeCodeInHdnPortfolio(paramPortId, typeCode)
{
	var portRowValue = GetHdnPortfolioRowById(paramPortId);
	var portTCode = GetHdnPortfolioValue(portRowValue, 'typecodes');
	return (portTCode!='' && typeof(portTCode)!='undefined' && portTCode.indexOf(typeCode)>=0) ? true : false;
}

function IsDuplicateTypeCodeInHdnPort(paramPortId, typeCode)
{
	var noOfOccurance = 0;
	var portRowValue = GetHdnPortfolioRowById(paramPortId);
	var portTCode = GetHdnPortfolioValue(portRowValue, 'typecodes');
	
	if (portTCode!='' && typeof(portTCode)!='undefined' && portTCode.indexOf(typeCode)>=0)
	{	
		var codeArray = portTCode.split('~');
		for(cnt=0; cnt<codeArray.length; cnt++)
		{
			if(codeArray[cnt]!='' && codeArray[cnt]==typeCode)
			{
				noOfOccurance++;
			}
		}
	}

	return (noOfOccurance>1) ? true : false;
}

function IsPortfolioExist()
{
	var elePortfolioDetails = $('completePortfolioDetail');
	var portStatus = false;
		
	if(elePortfolioDetails && elePortfolioDetails.value!='')
	{
		var portList = elePortfolioDetails.value.split(',');
		for(i=0; i<portList.length; i++)
		{
			var tempPortId = GetHdnPortfolioValue(portList[i],'id');
			if(tempPortId != '')
			{
				portStatus=true;
				break;
			}
		}
	}
	return portStatus;
}

function GetHdnPortfolioValue(paramPortRow, rValue)
{
	var portDetail = paramPortRow.split('|');
	var returnValue = '';
	
	if(portDetail.length>0)
	{
		switch(rValue)
		{
			case 'id':
				returnValue = portDetail[0];	// Portfolio Id from hidden variable
				break;
			case 'name':
				returnValue = portDetail[1];	// Portfolio Name from hidden variable
				break;
			case 'typecodes':
				returnValue = portDetail[2];	// Portfolio Typecodes from hidden variable
				break;
			default:
				var rowCodes = portDetail[2].split('~');
				var typeCodeCount = 0;
				for(codeCnt=0; codeCnt<rowCodes.length; codeCnt++)
				{
					if(rowCodes[codeCnt]!='')
						typeCodeCount++;
				}
				returnValue = typeCodeCount;	// Portfolio Count from hidden variable
				break;
		}
	}
	return returnValue;
}

function GetHdnPortfolioRowById(paramPortId)
{
	var elePortfolioDetails = $('completePortfolioDetail');
	var rowValue = '';
		
	if(elePortfolioDetails && elePortfolioDetails.value!='')
	{
		var portList = elePortfolioDetails.value.split(',');
		for(i=0; i<portList.length; i++)
		{
			if(portList[i].indexOf(paramPortId)>=0)
			{
				rowValue=portList[i];
				break;
			}
		}
	}
	return rowValue;
}

function AddTypeCodeInHdnPortfolio(paramPortId, typeCode)
{
	var elePortfolioDetails = $('completePortfolioDetail');
	var tempPortDetails = '';
	
	if(elePortfolioDetails && elePortfolioDetails.value!='')
	{
		var portList = elePortfolioDetails.value.split(',');
		for(i=0; i<portList.length; i++)
		{
			var tempPortId = GetHdnPortfolioValue(portList[i],'id');
			if(tempPortId == paramPortId)
			{
				var tempPortName = GetHdnPortfolioValue(portList[i],'name');
				var tempPortCodes = GetHdnPortfolioValue(portList[i],'typecodes');
				tempPortCodes += '~' + typeCode;
				var tempPortCount = GetHdnPortfolioValue(portList[i],'count');
				tempPortCount++;
				tempPortDetails += tempPortId + '|' + tempPortName + '|' + tempPortCodes + '|' + tempPortCount + ',';
			}
			else if(tempPortId != '')
			{
				tempPortDetails += portList[i] + ',';
			}
		}
	}
	elePortfolioDetails.value = tempPortDetails;
}

function DeleteTypeCodeFromHdnPortfolio(paramPortId, typeCode)
{
	var elePortfolioDetails = $('completePortfolioDetail');
	var tempPortDetails = '';
	
	if(elePortfolioDetails && elePortfolioDetails.value!='')
	{
		var portList = elePortfolioDetails.value.split(',');
		for(i=0; i<portList.length; i++)
		{
			var tempPortId = GetHdnPortfolioValue(portList[i],'id');
			if(tempPortId == paramPortId)
			{
				var tempPortName = GetHdnPortfolioValue(portList[i],'name');
				var tempPortCodes = GetHdnPortfolioValue(portList[i],'typecodes');				
				//var indexCount = tempPortCodes.indexOf(typeCode);
				tempPortCodes = RemoveSubstring(tempPortCodes, typeCode);
				var tempPortCount = GetHdnPortfolioValue(tempPortId + '|' + tempPortName + '|' + tempPortCodes + '|','count');
				//if(indexCount>=0)
				//	tempPortCount--;
				tempPortDetails += tempPortId + '|' + tempPortName + '|' + tempPortCodes + '|' + tempPortCount + ',';
			}
			else if(tempPortId != '')
			{
				tempPortDetails += portList[i] + ',';
			}
		}
	}
	elePortfolioDetails.value = tempPortDetails;
}

function RemoveSubstring(s, t) 
{
  var indexCount = s.indexOf(t);
  var returnValue = "";
  if (indexCount == -1) return s;
  returnValue += s.substring(0,indexCount) + RemoveSubstring(s.substring(indexCount + t.length), t);
  return returnValue;
}

function PopulateBasketPortfolio(val)
{
	var elePortfolioDetails = $('completePortfolioDetail');
	var portfolioDD=$("basketDD");
	
	if(elePortfolioDetails && val!='' && portfolioDD)
	{
		elePortfolioDetails.value = val;
		var portList = elePortfolioDetails.value.split(',');
		
		if(portList!='' && portList!=null)
			portfolioDD.options.length=0;
		
		for(i=0; i<portList.length; i++)
		{
			var tempPortId = GetHdnPortfolioValue(portList[i],'id');
			var tempPortName = GetHdnPortfolioValue(portList[i],'name');
			
			if(tempPortId!='' && tempPortName!='')
			{
				var optionElement=document.createElement("option");
				optionElement.text=tempPortName;
				optionElement.value=tempPortId;
				portfolioDD.options.add(optionElement);				
			}
			tempPortId = tempPortName = '';
		}
	}
	CheckForPortfolioRow();
	SelectCurrentPortfolio();
	PortfolioSelectOnChange(PopUpTypeCode);
	
//	if(GetSelectedBasketTab()=='PORT')
//		HighLightSelectedRows('PORT');
}

function LoadHiddenWatchList(wListVal)
{	
	var eleWatchlistDetails = $('completeWatchlistDetail');
	if(eleWatchlistDetails)
	{
		eleWatchlistDetails.value = wListVal;
	}
	UpdateWatchlistCount();
	
//	if(GetSelectedBasketTab()=='WATCH')
//		HighLightSelectedRows('WATCH');
}

function SelectCurrentPortfolio()
{
	var elePortDropDown = $('basketDD');
	if(elePortDropDown && pId!='')
	{
		for(i=0;i<elePortDropDown.options.length;i++) 
		{
			if(elePortDropDown.options[i].value==pId) 
			{
				elePortDropDown.options[i].selected = 'selected';
				break;				   
			}
		} 
	}
}

function DisplayBasketPopUp(typeCode, popupType, visibleType)
{		
   if(typeCode!=null && typeCode!='')
   {
       FundByType(typeCode);
   }
    
	if(visibleType=="visible")
   {
		$("FooterBasketDiv").innerHTML=BasketPopupContent(getPosition(typeCode),popupType,typeCode);
      $('curPopup').value=typeCode;
      
      // loading portfolio using webservice for basket dropdown
      var elePortfolioDetails = $('completePortfolioDetail');
      if(elePortfolioDetails && elePortfolioDetails.value=='')
      {
			PortfolioByUserId(userId,typeCode);
		}
		
		var eleWatchlistDetails = $('completeWatchlistDetail');
		if(eleWatchlistDetails && eleWatchlistDetails.value=='')
		{
			WatchlistByUserId(userId);
		}
      
      // Setting default tab
      switch(popupType)
      {
			case "p":
			ChangeBasketTab('Portfolio',typeCode);
			break;
			
			case "w":
			ChangeBasketTab('Watchlist',typeCode);
			break;
			
			default:
			ChangeBasketTab('Basket',typeCode);
			break;
      }
      //setTimeout("CloseBasket('"+typeCode+"')",4000);
    }
    else
    {
        CloseBasket(typeCode);
    }
}


function ChangeBasketTab(type,typeCode)
{
    var types=new Array('Basket','Portfolio','Watchlist');
    for(var i=0;i<3;i++)
    {
         var tblElement=document.getElementById('tbl'+types[i]);
         var tabElement=document.getElementById('tab'+types[i]);
         var divElement=document.getElementById('div'+types[i]+'Default');
         
         if(type==types[i])
         {
            tblElement.style.display='block';
            tabElement.style.color='#006BBC';
            divElement.style.display='block';
         }
         else
         {
            tblElement.style.display='none';
            tabElement.style.color='#000000';
            divElement.style.display='none';
         }
    }
    
    switch(type)
    {
		case 'Portfolio':			
			var elePortfolioDetails = $('completePortfolioDetail');
			PopulateBasketPortfolio(elePortfolioDetails.value);
			HighLightSelectedRows('PORT');
			break;
			
		case 'Watchlist':
			var eleWatchlistDetails = $('completeWatchlistDetail');
			if(eleWatchlistDetails && eleWatchlistDetails.value=='')
			{
				WatchlistByUserId(userId);
			}
			
			if(!IsTypeCodeInHdnWatchList(typeCode))
			{
				ChangeBasketButtonCaption('watchlist',typeCode,'add');
			}
			else
			{
				ChangeBasketButtonCaption('watchlist',typeCode,'remove');
			}
			UpdateWatchlistCount();
			HighLightSelectedRows('WATCH');
			break;
			
		case 'Basket':
			if(!IsCodeExistInShortlist(typeCode,'shortlisted'))
			{
				ChangeBasketButtonCaption('basket',typeCode,'add');
			}
			else
			{
				ChangeBasketButtonCaption('basket',typeCode,'remove');
			}
			HighLightSelectedRows('GENERAL');
			break;
    }
}
 
function IsTypeCodeInHdnWatchList(paramTypeCode)
{
	var codeStatus = false;
	var eleWatchlistDetails = $('completeWatchlistDetail');
	if(eleWatchlistDetails && eleWatchlistDetails.value!='' && eleWatchlistDetails.value!=null && eleWatchlistDetails.value.indexOf(paramTypeCode)>=0)
	{
		codeStatus = true;
	}
	return codeStatus;
}

function PortfolioSelectOnChange(typeCode)
{
	var selectBoxPId = $('basketDD') ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
	if(selectBoxPId!='')
	{
		ChangeBasketButtonCaption('portfolio',typeCode, (IsTypeCodeInHdnPortfolio(selectBoxPId,typeCode)) ? 'add' : 'remove');
		UpdateBasketPortCount(selectBoxPId);
	}
}

function UpdateBasketPortCount(paramPortId)
{
	var eleSpanCount = $('spanPortCount');		
	if(eleSpanCount && paramPortId!='')
	{
		eleSpanCount.innerHTML = ' &nbsp; ' + GetHdnPortfolioValue(GetHdnPortfolioRowById(paramPortId), 'count');
	}
	else if(eleSpanCount)
	{
		eleSpanCount.innerHTML = '';
	}
}


function BasketPopupContent(pos,popupType,typeCode)
{
    var posTop=pos.y;
    var posLeft=pos.x+pos.w+5;
    var windowWidth=window.innerWidth;
    var windowHeight=window.innerHeight;

    if(windowWidth==null || windowWidth==0)
    {
        windowWidth=document.documentElement.clientWidth;
    }

    if(windowHeight==null || windowHeight==0)
    {
        windowHeight=document.documentElement.clientHeight;
    }

    if((posLeft+220)>windowWidth)
    {
        posLeft=posLeft-245;
    }
        
    var popupContent='<iframe id="BasketPopupFrame" src="" height="100" frameborder="0" scrolling="no" style="z-index:2000;width: 220px;  visibility: visible;position: absolute; top: '+posTop+'px; left: '+posLeft+'px;" ></iframe>';
    popupContent+='<div id="BasketPopup'+typeCode+'" name="BasketPopup" style="z-index:2000;visibility: visible; background-repeat: repeat-y; background-image: url(/Images/newBasketMiddle.gif); top: '+posTop+'px; position: absolute; width: 220px; left: '+posLeft+'px;" onmouseover="javascript:$(\'isBasketClose\').value=\'false\';" onmouseout="javascript:$(\'isBasketClose\').value=\'true\';">';
    popupContent+='<div style="background-image: url(/Images/newBasketTop.gif); background-repeat: no-repeat; background-position: left top;">';
    popupContent+='<div style="padding:  0px 16px 20px 10px; background-image: url(/Images/newBasketBottom.gif); background-repeat: no-repeat; background-position: left bottom;">'
    popupContent+='<table cellpadding="0" cellspacing="0" border="0" width="100%">';
    popupContent+='<tbody>';
    popupContent+='<tr style="height: 23px;">';
    popupContent+='<td style="padding-left: 6px; border-bottom: #a7c7e7 1px solid;" colspan="3">';
    popupContent+='<b style="color:#006BBC; font-size:12px;float:left; valign=\'middle\'">Add to</b>';
    popupContent+='<b onclick="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" title="Close" id="BCloseL" style="cursor: pointer; font-size: 16px; color: #006BBC;float:right">X</b>';    
    popupContent+='</td>';
    popupContent+='</tr>';
        
    if(userId!='')
    {
		 popupContent+='<tr height="20" align="center" style="cursor:pointer;">';
		 popupContent+='<td id="tabBasket" style="border-bottom: #a7c7e7 1px solid;border-right: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Basket\',\''+typeCode+'\');">Basket</b>';
		 popupContent+='</td>';
		 popupContent+='<td id="tabPortfolio" style="border-bottom: #a7c7e7 1px solid;border-right: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Portfolio\',\''+typeCode+'\');">Portfolio</b>';
		 popupContent+='</td>';
		 popupContent+='<td id="tabWatchlist" style="border-bottom: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Watchlist\',\''+typeCode+'\');">Watchlist</b>';
		 popupContent+='</td>';
		 popupContent+='</tr>';
		 
		 // set selection mode
		 popupContent+='<tr align="center" style="padding-bottom:4px;">';		 
		 popupContent+='<td align="center" colspan="3">';
		 popupContent+='<div id="divBasketDefault" style="width: 100%; display: none;"><a href="javascript:SetDefaultBasketTab(\'GENERAL\');" style="text-decoration: underline;">Set as default selection mode</a>&nbsp;<span style="cursor:hand;color:blue;" title="By default holdings will be added directly on the first click"><b>?</b></span></div>';
		 popupContent+='<div id="divPortfolioDefault" style="width: 100%; display: none;"><a href="javascript:SetDefaultBasketTab(\'PORT\');" style="text-decoration: underline;">Set as default selection mode</a>&nbsp;<span style="cursor:hand;color:blue;" title="By default holdings will be added directly on the first click"><b>?</b></span></div>';
		 popupContent+='<div id="divWatchlistDefault" style="width: 100%; display: none;"><a href="javascript:SetDefaultBasketTab(\'WATCH\');" style="text-decoration: underline;">Set as default selection mode</a>&nbsp;<span style="cursor:hand;color:blue;" title="By default holdings will be added directly on the first click"><b>?</b></span></div>';
		 popupContent+='</td>';
		 popupContent+='</tr>';
    }
    else
    {
		 popupContent+='<tr height="20" align="center" style="cursor:pointer;">';
		 popupContent+='<td id="tabBasket" style="border-bottom: #a7c7e7 1px solid;">';
		 popupContent+='<b onclick="javascript:ChangeBasketTab(\'Basket\',\''+typeCode+'\');">Basket</b>';
		 popupContent+='</td>';
		 popupContent+='<td id="tabPortfolio" style="border-bottom: #a7c7e7 1px solid;">  ';		 
		 popupContent+='</td>';
		 popupContent+='<td id="tabWatchlist" style="border-bottom: #a7c7e7 1px solid;">    ';
		 popupContent+='</td>';
		 popupContent+='</tr>';
    }
    
    popupContent+='<tr height="25">';
    popupContent+='<td colspan="3" align="center" style="vertical-align:bottom;">';
    popupContent+='<b><span id="td_TypeName">Loading..</span></b>';
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='<tr>';
    popupContent+='<td colspan="3" align="center">';
    
    // Basket tab content starts here
    popupContent+='<table id="tblBasket"  style="display: block;">';
    popupContent+='<tr>';
    popupContent+='<td>';
    //popupContent+=portName;
    popupContent+=' ';
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='<tr height="20" align="center" >';
    popupContent+='<td align="center" style="text-align:centre;">';

	 popupContent+='<div id=\'basketAddRow\' style="width: 100%;display: none;">';
	 popupContent+='<a id=\'basketAddlink\' name=\'basketAddlink\' href="javascript:AddFundToBasket(\''+typeCode+'\');ChangeBasketButtonCaption(\'basket\',\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Add</b></a>';
	 popupContent+='&nbsp;			             &nbsp;';
	 popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
	 popupContent+='</div>';
		
	 popupContent+='<div id=\'basketRemoveRow\' style="width: 100%;display: none;">';
	 popupContent+='<a id=\'basketAddlink\' name=\'basketAddlink\' href="javascript:AddFundToBasket(\''+typeCode+'\');ChangeBasketButtonCaption(\'basket\',\''+typeCode+'\',\'add\');" style="text-decoration: underline;"><b>Remove</b></a>';
	 popupContent+='&nbsp;			             &nbsp;';
	 popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
	 popupContent+='</div>';
	     
    popupContent+='</td>';
    popupContent+='</tr>';
    
    popupContent+='<tr height="20">';
	 popupContent+='<td align="center">';
    popupContent+='<a href="/Tools/Tools.aspx" style="text-decoration: underline;"><b>Back to Tools</b></a>';    
    popupContent+='</td>';
    popupContent+='</tr>';
    popupContent+='</table>';

	 // Portfolio tab content starts here
	 popupContent+='<table id="tblPortfolio"  style="height: 80px; display: none;">';

	 // If portfolio exist display the below two rows
	 popupContent+='<tr id=\'trSelectRow1\' style="display: none;">';
	 popupContent+='<td>';
	 popupContent += '<select id="basketDD" name="basketDD" style="width:144px;" onchange="javascript:PortfolioSelectOnChange(\''+typeCode+'\');HighLightSelectedRows(\'PORT\');"><option value="" selected>Select</option></select>';
	 //popupContent+='<span id=\'spanPortCount\'></span>';	 
	 popupContent+='</td>';
	 popupContent+='</tr>';

 
//	 if (popupType=='ProductSearch')
//	 {
//	 	popupContent+='<tr id=\'trSelectRow2\' height="20" style="display: none;">';
//		popupContent+='<td align="center">';
//		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'add\');UpdateBasket();$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
//		popupContent+='</td>';
//		popupContent+='</tr>';
//	 }
//	 else
//	 {
	 	popupContent+='<tr id=\'trSelectRow2\' height="30" style="display: none;">';
		popupContent+='<td align="center">';
		popupContent+='No. of Holdings: <span id=\'spanPortCount\'></span>';
		popupContent+='<br/>';
		//	Add and Cancel button
		popupContent+='<div id=\'portfolioAddRow\'  style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'add\');" style="text-decoration: underline;"><b>Add</b></a>';
		popupContent+='&nbsp;                  &nbsp;';
		popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</div>';
		//	Remove and Add multiple button 
		popupContent+='<div id=\'portfolioRemoveRow\'  style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Remove</b></a>';
		popupContent+='&nbsp;                  &nbsp;';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'add multiple\');" style="text-decoration: underline;"><b>Add Multiple</b></a>';
		popupContent+='</div>';
		// Remove and Cancel button
		popupContent+='<div id=\'portfolioCancelRow\'  style="width: 100%;display: none;">';
		popupContent+='<a href="javascript:AddFundToPortfolio(\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Remove</b></a>';
		popupContent+='&nbsp;                  &nbsp;';
		popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
		popupContent+='</div>';		
		popupContent+='</td>';
		popupContent+='</tr>';

//	 }
	
   // If no portfolio exist display this block.
	popupContent+='<tr id=\'trSelectRow3\' height="20"  style="display: none;" >';
	popupContent+='<td align="center">';
	popupContent+='No portfolio exist. <a href="/Tools/Portfolio/ManagePortfolio.aspx" style="text-decoration: underline;">Click here</a> to create a new portfolio.';
	popupContent+='</td>';
	popupContent+='</tr>';
		 
	popupContent+='<tr height="20">';
	popupContent+='<td align="center">';
   popupContent+='<a href="/Tools/Portfolio/Valuation.aspx" style="text-decoration: underline;"><b>Back to Portfolio</b></a>';    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='</table>';
    
   // Watchlist tab content starts here
   popupContent+='<table id="tblWatchlist"  style="display: none;">';
   popupContent+='<tr>';
   popupContent+='<td> ';
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='<tr height="20">';
   popupContent+='<td align="center">';
   popupContent+='No. of Holdings: <span id=\'spanWatchListCount\'></span>';
	popupContent+='<br/>';

   popupContent+='<div id=\'watchlistAddRow\' style="width: 100%;display: none;">';
   popupContent+='<a id=\'watchListAddLink\' href="javascript:AddFundToWatchList(\''+typeCode+'\',\'add\');ChangeBasketButtonCaption(\'watchlist\',\''+typeCode+'\',\'remove\');" style="text-decoration: underline;"><b>Add</b></a>';
   popupContent+='&nbsp;			             &nbsp;';
	popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
   popupContent+='</div>';
    
   popupContent+='<div id=\'watchlistRemoveRow\' style="width: 100%;display: none;">';
   popupContent+='<a id=\'watchListAddLink\' href="javascript:AddFundToWatchList(\''+typeCode+'\',\'remove\');ChangeBasketButtonCaption(\'watchlist\',\''+typeCode+'\',\'add\');" style="text-decoration: underline;"><b>Remove</b></a>';
   popupContent+='&nbsp;			             &nbsp;';
	popupContent+='<a href="javascript:$(\'isBasketClose\').value=\'true\';CloseBasket(\''+typeCode+'\');" style="text-decoration: underline;"><b>Cancel</b></a>';
   popupContent+='</div>';
    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='<tr height="20">';
   popupContent+='<td align="center">';
   popupContent+='<a href="/Tools/Portfolio/Watchlist.aspx" style="text-decoration: underline;"><b>Back to Watchlist</b></a>';    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='</table>';

    
   popupContent+='</td>';
   popupContent+='</tr>';
   popupContent+='</tbody>';
   popupContent+='</table>';
   popupContent+='<input type="hidden" id="isBasketClose" name="isBasketClose" value="true" />';
   popupContent+='<input type="hidden" id="curPopup" name="curPopup" value="" />';
   popupContent+='</div>';
   popupContent+='</div>';
   popupContent+='</div>';
   return popupContent;
}

function ReplaceAllStrInst( str, replacements ) 
{
    for ( i = 0; i < replacements.length; i++ ) 
    {
        var idx = str.indexOf( replacements[i][0] );
        while ( idx > -1 ) 
        {
            str = str.replace( replacements[i][0], replacements[i][1] ); 
            idx = str.indexOf( replacements[i][0] );
        }
    }
    return str;
}

function HighLightSelectedRows(highlightType)
{
	var typecodelist='';
	var codeType = (typeof(highlightType)=='undefined') ? Mode.toUpperCase():highlightType;
	
	switch(codeType)
	{
		case "WATCH":
			var eleWatchlistDetails = $('completeWatchlistDetail');
			if(eleWatchlistDetails && eleWatchlistDetails.value !='')
			{
				typecodelist=eleWatchlistDetails.value;
			}
			else
			{
				typecodelist = WatchtypeCodes;
			}
			break;
		case "PORT":
			var eleBasketPId = $('basketDD');
			var selectBoxPId = eleBasketPId ? eleBasketPId.options[eleBasketPId.selectedIndex].value : '';
			if(selectBoxPId!=null && selectBoxPId!='')
			{	
				typecodelist = ReplaceAllStrInst(GetHdnPortfolioValue(GetHdnPortfolioRowById(selectBoxPId), 'typecodes'), [["~", ","]] );
			}
			else
			{
				typecodelist =PorttypeCodes;
			}
			break;
		default:
			typecodelist = GetCookie("shortlisted");
			break;
	}
	HighLightRows(typecodelist);
}

function HighLightRows(typecodes)
{
	var basketOverriden = false;
	var overrideBasketElem = $('overrideBasketCookie');
	if(overrideBasketElem) {
		if(overrideBasketElem.value != "") {
			basketCookieName = overrideBasketElem.value;
			basketOverriden = true;
		}
	}
	if(typecodes != "")
	{	
	   var Title="basket";    
		var elements = document.getElementsByTagName("TR");
		var typecodeArr = typecodes.split(',');

		for(var i=0;i<elements.length;i++)
		{
			if(!IsStringFoundInArray(typecodeArr, elements[i].id) && (elements[i].className.indexOf("selected") >= 0))
			{
				elements[i].className = elements[i].className.replace("selected","");
				var imgTags = elements[i].getElementsByTagName('IMG');
				for(var j=0;j<imgTags.length;j++)
				{
					if(imgTags[j].src.indexOf("/icons/removeIco.png") >= 0)
					{
						imgTags[j].src = "/icons/icon_plus.png";
						imgTags[j].title = "add to "+Title;
						imgTags[j].width = "16";
						imgTags[j].height = "15";
					}
				}
			}
			if(IsStringFoundInArray(typecodeArr, elements[i].id) && elements[i].className.indexOf(" selected") < 0)
			{
				var imgTags = elements[i].getElementsByTagName('IMG');
				for(var j=0;j<imgTags.length;j++)
				{
					if(imgTags[j].src.indexOf("/icons/icon_plus.png") >= 0)
					{
						imgTags[j].src = "/icons/removeIco.png";
						imgTags[j].title = "remove from "+Title;
						imgTags[j].width = "14";
						imgTags[j].height = "14";
					}
				}
				elements[i].className += " selected";
			}
		}
		elements = document.getElementsByTagName("DIV");
		for(var i=0;i<elements.length;i++)
		{
			if(!IsStringFoundInArray(typecodeArr, elements[i].id) && (elements[i].className.indexOf("bold") >= 0))
			{
				elements[i].className = elements[i].className.replace("bold","");
				var imgTag = $("Img-"+elements[i].id);
				if(imgTag)
				{
					if(imgTag.src.indexOf("/icons/removeIco.png") >= 0)
					{
						imgTag.src = "/icons/icon_plus.png";
						imgTag.title = "add to "+Title;
						imgTag.width = "16";
						imgTag.height = "15";
					}
				}
				var divTag = $("span-"+elements[i].id);
				if(divTag)
				{
				    if(divTag.innerHTML.indexOf('equity') > 0)
				    {
				        divTag.innerHTML = "Add this equity from basket";
				    }
				    else
				    {
					    divTag.innerHTML = "Add this unit to basket";
					}
				}
			}
			if(IsStringFoundInArray(typecodeArr, elements[i].id) && elements[i].className.indexOf(" bold") < 0)
			{
				var imgTag = $("Img-"+elements[i].id);
				if(imgTag)
				{
					if(imgTag.src.indexOf("/icons/icon_plus.png") >= 0)
					{
						imgTag.src = "/icons/removeIco.png";
						imgTag.title = "remove from "+Title;
						imgTag.width = "14";
						imgTag.height = "14";
					}
				}
				var divTag = $("span-"+elements[i].id);
				if(divTag)
				{
				    if(divTag.innerHTML.indexOf('equity') > 0)
				    {
				        divTag.innerHTML = "Remove this equity from basket";
				    }
				    else
				    {
					    divTag.innerHTML = "Remove this unit from basket";
					}
				}
				elements[i].className += " bold";
			}
		}
	}
}

function ChangeBasketButtonCaption(tabName, typeCode, displayStatus)
{
	switch(tabName)
	{
		case 'basket':
			var eleAddRow = $('basketAddRow');
			var eleRemoveRow = $('basketRemoveRow');
	
			if(displayStatus=='add')
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			else if(displayStatus=='remove')
			{
				eleRemoveRow.style.display='block';
				eleAddRow.style.display='none';	
			}
			else
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			break;
		case 'portfolio':
			var elePortfolioAddRow = $('portfolioAddRow');
			var elePortfolioRemoveRow = $('portfolioRemoveRow');
			if(displayStatus=='add')
			{	
				if(elePortfolioAddRow)
					elePortfolioAddRow.style.display='none';
				if(elePortfolioRemoveRow)
					elePortfolioRemoveRow.style.display='block';
			}
			else
			{
				if(elePortfolioAddRow)
					elePortfolioAddRow.style.display='block';
				if(elePortfolioRemoveRow)
					elePortfolioRemoveRow.style.display='none';	
			}
			break;
		case 'watchlist':
			var eleAddRow = $('watchlistAddRow');
			var eleRemoveRow = $('watchlistRemoveRow');
	
			if(displayStatus=='add')
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			else if(displayStatus=='remove')
			{
				eleRemoveRow.style.display='block';
				eleAddRow.style.display='none';	
			}
			else
			{
				eleAddRow.style.display='block';
				eleRemoveRow.style.display='none';
			}
			break;
	}
}

function CheckForPortfolioRow()
{
	var portfolioDD=$("basketDD");
	var portfolioRow1 = $("trSelectRow1");
	var portfolioRow2 = $("trSelectRow2");
	var portfolioRow3 = $("trSelectRow3");

	if(IsPortfolioExist())
	{
		if(portfolioRow1)
			portfolioRow1.style.display='block';
		if(portfolioRow2)
			portfolioRow2.style.display='block';
		if(portfolioRow3)
			portfolioRow3.style.display='none';
	}
	else
	{
		if(portfolioRow1)
			portfolioRow1.style.display='none';
		if(portfolioRow2)
			portfolioRow2.style.display='none';
		if(portfolioRow3)
			portfolioRow3.style.display='block';
	}
}


function IsCodeExistInShortlist(typeCode, cookieName)
{
   var value = GetCookie(cookieName);
	if(value!=null && value!='' && value.indexOf(typeCode)>=0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function AddFundToBasket(typecode)
{
	var basketCookieName = "shortlisted";
	var basketOverriden = false;
	var overrideBasketElem = $('overrideBasketCookie');

	if(overrideBasketElem && overrideBasketElem.value != "") 
	{
		basketCookieName = overrideBasketElem.value;
		basketOverriden = true;
	}

   var value = GetCookie(basketCookieName);
	var count=$("NoOfShortListedItems");
	var isCodeRemoved = false;
	   
   if(value != "")
   {
	   var farray = new Array();
	   farray = value.split(',');

	   if(!IsStringFoundInArray(farray, typecode))
	   {
		  value += ","+typecode;			
		  if(count!=null && !basketOverriden){
			count.innerHTML="("+((parseInt(farray.length))+1)+")";              
		  }
	   }
	   else
	   {
		   DeleteFromShortlist(typecode, basketCookieName);
		   if(!basketOverriden){
				DeleteFromShortlist(typecode, "TN_RetainSelected");
			}
		   value = GetCookie(basketCookieName);			
		   if((farray.length-1)!=0){
				if(count!=null && !basketOverriden){
					count.innerHTML="("+(farray.length-1)+")";	
				}		   
		   }
		   else{
				if(count!=null && !basketOverriden){
					count.innerHTML="(0)";
				}
		   }
		   isCodeRemoved = true;
	   }
   }
   else
   {
	   value = typecode;
	   if(count != null && !basketOverriden){
			count.innerHTML="(1)";
	   }
   }
   
   if(!isCodeRemoved)
   {
	   SetCookie(basketCookieName, value, 123231);
	   retainSelectedVal(typecode);
   }
   else
   {
	   DeHighlightRows(typecode);
   }
   	
	//HighLightSelectedRows();
	HighLightSelectedRows('GENERAL');
}

function UpdateWatchlistTypeCode(parmTypeCode, updateStatus)
{
	var eleWatchlistDetails = $('completeWatchlistDetail');
	if(eleWatchlistDetails)
	{
		if(updateStatus=='remove')
		{
			eleWatchlistDetails.value = RemoveSubstring(eleWatchlistDetails.value, parmTypeCode);
		}
		else
		{
			eleWatchlistDetails.value += ',' + parmTypeCode;
		}
	}
	UpdateWatchlistCount();
}

function UpdateWatchlistCount()
{
	var watchlistCount=0;
	var eleWatchlistDetails = $('completeWatchlistDetail');
	if(eleWatchlistDetails)
	{
		var wListCodes = eleWatchlistDetails.value.split(',');
		if(wListCodes!=null && wListCodes.length)
		{
			for(lCnt=0;lCnt<wListCodes.length;lCnt++)
			{
				if(wListCodes[lCnt]!='')
				{
					watchlistCount++;
				}
			}
		}
	}
	var eleWatchHolding = $('spanWatchListCount');
	if(eleWatchHolding)
	{
		eleWatchHolding.innerHTML=watchlistCount;
	}
		
	var eleLeftNavWatchCnt = $('NoOfWatchlistItems');
	if(eleLeftNavWatchCnt)
	{
		eleLeftNavWatchCnt.innerHTML=watchlistCount;
	}
	//return watchlistCount;
}


function AddFundToPortfolio(typecode,addOrRemoveFund)
{
   var count=$("NoOfPortfolioItems");

	var eleBasketPId = $('basketDD');
	var selectBoxPId = $('basketDD') ? $('basketDD').options[$('basketDD').selectedIndex].value : '';
	var isCodeRemoved = false;
	
	if(addOrRemoveFund=='add' || addOrRemoveFund=='add multiple')
	{
		PorttypeCodes += (PorttypeCodes != "") ? ","+typecode : typecode;
		AddPortfolioFundDisplay(selectBoxPId,userValue,univValue,typecode);
		SetCookie(userValue+"portfolio", PorttypeCodes, 123231);
		if(count && selectBoxPId==pId)
			count.innerHTML=parseInt(count.innerHTML)+1;
		// Adding typecode in hidden variable
		AddTypeCodeInHdnPortfolio(selectBoxPId, typecode);
		ChangePortfolioRow(addOrRemoveFund=='add'? 'add' : 'add multiple');
	}
	else if(addOrRemoveFund=='remove')
	{
		// Condition to check for duplicate occurance		
		if(IsDuplicateTypeCodeInHdnPort(selectBoxPId,typecode))
		{	
			var statusMsg='This portfolio contain dupulicate of this holding. Do you want to delete it individually?';
			if(confirm(statusMsg))
			{
				SubmitFormThroughBasket('/Tools/Portfolio/Valuation.aspx?selectPortfolio='+selectBoxPId);
			}
		}
		else
		{
			DeleteFromShortlist(typecode, userValue+"portfolio");	
			DeleteFromDB(typecode,PorttypeCodes);
			RemovePortfolioFundDisplay(selectBoxPId,userValue,typecode);
			if(count && selectBoxPId==pId)
				count.innerHTML=parseInt(count.innerHTML)-1;
			// Delete typecode from hidden variable
			DeleteTypeCodeFromHdnPortfolio(selectBoxPId, typecode);
			ChangePortfolioRow('remove');
		}
	}
	UpdateBasketPortCount(selectBoxPId);
	HighLightSelectedRows('PORT');
}

function SubmitFormThroughBasket(page)
{
    document.masterForm.action=page;
    document.masterForm.submit();
}


function AddFundToWatchList(typecode,addOrRemoveFund)
{
	var count=$("NoOfWatchlistItems");
	if(addOrRemoveFund=='add')
	{
		WatchtypeCodes += (WatchtypeCodes != "") ? ","+typecode : typecode;
		SetCookie(userValue+"watch", WatchtypeCodes, 123231);		
		AddWatchlistFundDisplay(userValue,univValue,typecode,SiteCode);
		if(count)
			count.innerHTML=parseInt(count.innerHTML)+1;
		UpdateWatchlistTypeCode(typecode,'add');
	}
	else if(addOrRemoveFund=='remove')
	{
		DeleteFromShortlist(typecode, userValue+"watch");
		DeleteFromDB(typecode,WatchtypeCodes);
		RemoveWatchlistFundDisplay(userValue,typecode,SiteCode);
		if(count)
			count.innerHTML=parseInt(count.innerHTML)-1;
		UpdateWatchlistTypeCode(typecode,'remove');
	}
	HighLightSelectedRows('WATCH');
}


function ChangePortfolioRow(updateStatus)
{
	var elePortfolioAddRow = $('portfolioAddRow');	
	var elePortfolioRemoveRow = $('portfolioRemoveRow');
	var elePortfolioCancelRow = $('portfolioCancelRow');
	//var eleNoOfHoldingsRow = $('noOfHoldingsRow');
	
	if(elePortfolioAddRow && elePortfolioCancelRow && elePortfolioRemoveRow)
	{
		if(updateStatus=='add')
		{
			elePortfolioAddRow.style.display='none';
			elePortfolioCancelRow.style.display='none';
			elePortfolioRemoveRow.style.display='block';
		}
		else if(updateStatus=='remove')
		{
			elePortfolioRemoveRow.style.display='none';
			elePortfolioCancelRow.style.display='none';
			elePortfolioAddRow.style.display='block';		
		}
		else if(updateStatus=='add multiple')
		{
			elePortfolioCancelRow.style.display='block';
			elePortfolioAddRow.style.display='none';
			elePortfolioRemoveRow.style.display='none';
		}
	}
}
*/
/************* New approach basket code ends here	**************/

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
function EmailContent()
{
	var strBuilder="";		
	strBuilder+='<iframe id="MailIFrame" onload="DisableSelectMail(\'MailIFrame\');" src="" frameborder="0" scrolling="no" style="width:600px;position: absolute;visibility: hidden; top: 203px;left: 505px;border: solid 1px #red;height:170px;"></iframe>'; 		
	strBuilder += '<div id="MailDiv"   onmousedown=EmailZindex(); style="width: 600px;Z-index=1000; position: absolute; visibility: hidden; top: 203px;left: 505px; border: solid 2px #a7c7e7;" >';
	strBuilder += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
	strBuilder += '<tr id="trHeadMail" title="Email - Double Click here to Minimize/Expand this window" style="height: 23px; cursor:move;  background: url(/images/bgMainMenuActive.gif) repeat-x;" onmousedown="dragMailBox(document.getElementById(\'MailDiv\'),event,document.getElementById(\'MailIFrame\')); return false;" ondblclick="">';
	strBuilder += '<td id="idSelect" style="width: 35%;text-align: left; border-bottom: solid 1px #a7c7e7;padding-left: 6px;">';
	strBuilder += '<b style="color:White; font-size:12px;">Send this link to a friend</b></td>';
	strBuilder += '<td style="text-align: right;width: 65%; padding: 0px 0px 0px 0px;margin: 5px 0px 5px 0px; border-bottom: solid 1px #a7c7e7;">';
	strBuilder += '<b id="idMin" style="cursor:pointer; font-size:16px; color:White;" title ="Minimize" onmouseover="ShadeMail(this)" onmouseout="RShadeMail(this)" onclick="MinimizeMailWindow(\'Email\');">';
	strBuilder += '&nbsp;_&nbsp;';
	strBuilder += '</b> <img id="idMax" src="/images/shape_square.png" title="Maximize" alt="Maximize" style="display:none;vertical-align:middle;border:solid 1px white;width:12px;height:12pxcursor:hand;cursor:pointer;" onclick="MinimizeMailWindow(\'Email\');"/>';
	strBuilder += '<b style="cursor:pointer; vertical-align:middle; font-size:16px; color:White;" id="CloseL" title="Close" onmouseover="ShadeMail(this)" onmouseout="RShadeMail(this)" onclick="HideDiv();">';
	strBuilder += '&nbsp;X&nbsp;';
	strBuilder += '</b></td></tr></table>';
	strBuilder += '<div id="Email" style="visibility:hidden; background-color:White;">';
	strBuilder+='<table border="0" cellpadding="0" celspacing="0">'; 
	strBuilder +='<tr>';
	strBuilder +='<td style="width:150px;text-align:right;padding-right:5px;vertical-align:top;color:#2F6496;">'; 
	strBuilder+='<b>Send To:</b>';
	strBuilder+='</td>';
	strBuilder +='<td>';
	strBuilder+='<input type="text" id="txtTo" name="txtTo" value="" style="width:450px;height:16px;"/>';  
	strBuilder+='</td>';
	strBuilder +='</tr>';
	strBuilder+='<tr>'; 
	strBuilder +='<td style="text-align:right;padding-right:5px;vertical-align:top;color:#2F6496;">';
	strBuilder +='<b>Comment :</b>'; 
	strBuilder+='</td>';
	strBuilder +='<td>';
	strBuilder+='<textarea id="txtComment" name="txtComment" value="" style="width:450px;height:80px;"></textarea>';  
	strBuilder+='</td>';
	strBuilder +='</tr>';
	strBuilder +='<tr>';
	strBuilder +='<td colspan="2" align="center">';
	strBuilder +='<button id="button" style="width:90px;cursor:hand;BORDER:0px; background-color: #fff;" onclick="javascript:PopupMail();return false;"><span style="DISPLAY: block; PADDING-LEFT: 4px;COLOR:#fff; FONT-WEIGHT: bold; BACKGROUND: url(/images/buttonBlue.png) no-repeat left 0px; LINE-HEIGHT: 17px; HEIGHT: 19px"><span id="emailright" style="PADDING-RIGHT: 4px; DISPLAY: block; FONT-WEIGHT: bold; BACKGROUND: url(/images/buttonBlue.png) no-repeat right 0px; LINE-HEIGHT: 17px; HEIGHT: 19px; TEXT-ALIGN: center;COLOR:#fff;">Send mail</span></span></button>';
	strBuilder +='</td>';
	strBuilder +='</tr>';
	strBuilder += '</table>';	
	strBuilder += '</div>';	
	strBuilder += '</div>';	
	return strBuilder;
}

function EmailZindex()
{	
	var id=document.getElementById('MailDiv');	
	var eid=document.getElementById('TimeZoneDiv');	
	var cid=document.getElementById('CalcMainDiv');	
	document.getElementById('trHeadMail').style.background="url(/images/bgMainMenuActive.gif) repeat-x";	
	if(eid)eid.style.zIndex="100";
	if(cid)cid.style.zIndex="100";	
	if(id)id.style.zIndex="2000";	
	document.getElementById('trHeadMail').style.background="url(/images/bgMainMenuActive.gif) repeat-x";	
}

var userEmailId=GetCookie("TN_UserId");
function showMailDiv(idValue)
{	
	//document.getElementById("EmailDiv").innerHTML = EmailContent();
			
	if(userEmailId!='')
	{
		var browsertype=window.navigator.userAgent;
		if(idValue!='shareDiv')
		{		
		var pos;
		if($('setperf')==null)
		{
		pos=getPosition("setprofile");
		}
		else
		{
		 pos=getPosition("setperf"); 
		}
		var top=document.body.clientTop?document.body.clientTop:0;
		top=top+parseInt(pos.y)+22;
		if(browsertype.indexOf("MSIE 7.0")>=0)
		{	
			document.getElementById('MailDiv').style.top=top;
			document.getElementById('MailIFrame').style.top=top;
		}else if(browsertype.indexOf("MSIE 6.0")>=0) 
		{
			 document.getElementById('MailDiv').style.top=top-71;
			 document.getElementById('MailIFrame').style.top=top-71;	 
		} else
		{
			document.getElementById('MailDiv').style.top=top+"px";
			document.getElementById('MailIFrame').style.top=top+"px";
		}
		document.getElementById('MailDiv').style.visibility='visible';
		document.getElementById('Email').style.visibility='visible';
		document.getElementById('MailIFrame').style.visibility='';	
		document.getElementById('MailIFrame').style.height='170px';
		document.getElementById('MailDiv').style.left='505px';
		document.getElementById('MailIFrame').style.left='505px';
		document.getElementById('MailDiv').style.zIndex="1000";				
		document.getElementById("MailDiv").style.height = '170px';
		document.getElementById("Email").style.height = '146px';				
		document.getElementById("idMin").style.display = '';
		document.getElementById("idMax").style.display = 'none';	
		EmailZindex();
		document.getElementById('trHeadMail').style.background="url(/images/bgMainMenuActive.gif) repeat-x";
		}else if(idValue=='shareDiv')
		{
			var pos;
			pos=getPosition("shareDiv");
			var top=document.body.clientTop?document.body.clientTop:0;
			top=top+parseInt(pos.y)+32;
			$("FooterMailDiv").innerHTML=EmailContent();
			if(browsertype.indexOf("MSIE 7.0")>=0)
			{	
				document.getElementById('MailDiv').style.top=top;
				document.getElementById('MailIFrame').style.top=top;
			}else if(browsertype.indexOf("MSIE 6.0")>=0) 
			{
				 document.getElementById('MailDiv').style.top=top-71;
				 document.getElementById('MailIFrame').style.top=top-71;	 
			} else
			{
				document.getElementById('MailDiv').style.top=top+"px";
				document.getElementById('MailIFrame').style.top=top+"px";
			}
			document.getElementById('MailDiv').style.visibility='visible';
			document.getElementById('Email').style.visibility='visible';
			document.getElementById('MailIFrame').style.visibility='';	
			document.getElementById('MailIFrame').style.height='170px';
			document.getElementById('MailDiv').style.left='300px';
			document.getElementById('MailIFrame').style.left='300px';
			document.getElementById('MailDiv').style.zIndex="1000";				
			document.getElementById("MailDiv").style.height = '170px';
			document.getElementById("Email").style.height = '146px';				
			document.getElementById("idMin").style.display = '';
			document.getElementById("idMax").style.display = 'none';	
			EmailZindex();
			document.getElementById('trHeadMail').style.background="url(/images/bgMainMenuActive.gif) repeat-x";	
		}		
	}else
	{
		alert('Please Login');
	}
}

function HideDiv()
{
	document.getElementById('MailDiv').style.visibility='hidden';
	document.getElementById('Email').style.visibility='hidden';
	document.getElementById('MailIFrame').style.visibility='hidden';
}

function DisableSelectMail(id) 
{	
	document.getElementById(id).onselectstart = function() {return false;} // ie
	document.getElementById(id).onmousedown = function() {return false;} // mozilla
	
}
function getValues()
{
	var recepient=document.getElementById('txtTo').value;
	var comment=document.getElementById('txtComment').value;
	var url=location.href;	
}


//Global Variables for Email.
var AgainOpn=false;
var strMemory="0";
var PrimaryNo=parseFloat("0");
var CurrentOpn="";
var OpnSelected=false;

//Minimize Window is the function to Minimise Currency Gadjet Window.
//To Minimise Current Window to Bottom.
//<params> Div Id  </params>
function MinimizeMailWindow(divID)
{
	//Code here for Minimising Div.
	if(document.getElementById(divID).style.visibility == 'visible')
	{	
		document.getElementById(divID).style.visibility = 'hidden';
		document.getElementById("MailDiv").style.height = '21px';		
		document.getElementById("Email").style.height = '21px';		
		document.getElementById("MailIFrame").style.height = '21px';
		document.getElementById("idMin").style.display = 'none';
		document.getElementById("idMax").style.display = '';			
	}
	else
	{
		document.getElementById(divID).style.visibility = 'visible';
		document.getElementById("MailDiv").style.height = '170px';
		document.getElementById("Email").style.height = '146px';		
		document.getElementById("MailIFrame").style.height = '170px';
		document.getElementById("idMin").style.display = '';
		document.getElementById("idMax").style.display = 'none';								
	}	
}

///Drag Object.
// This will Drag object corresponding to the Cursor Movement.
function $(s) 
{ 
	return(document.getElementById(s)); 
}

function Mailagent(s) 
{ 
	return(Math.max(navigator.userAgent.toLowerCase().indexOf(s),0)); 
}

function xy(e,s) 
{ 
	return(s?(Mailagent('msie')?event.clientY+document.body.scrollTop:e.pageY):(Mailagent('msie')?event.clientX+document.body.scrollTop:e.pageX)); 
} 
//document.getElementById('trHeadMail');
function dragMailBox(d,e,ifid) 
{ 		
	function drag(e) 
	{ 
		document.getElementById('trHeadMail').style.background="url(/images/bgMainMenuActive.gif) repeat-x";
		if(!stop) 
		{ 
			d.style.top=(tX=xy(e,1)+oY-eY+'px'); 
			d.style.left=(tY=xy(e)+oX-eX+'px'); 
			ifid.style.top=(tX=xy(e,1)+oY-eY+'px'); 
			ifid.style.left=(tY=xy(e)+oX-eX+'px'); 
			//alert(document.getElementById('MailDiv').style.top+','+document.getElementById('MailDiv').style.left);
			//controlDrag(d,ifid);
		} 
	} 	
	var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop; 	
	document.onmousemove=drag; document.onmouseup=function()
	{ 
		stop=0; 
		document.getElementById('trHeadMail').style.background="url(/images/bgMainMenuActive.gif) repeat-x";
		document.onmousemove=''; 
		document.onmouseup=''; 
	}; 
}

//Make shading while Cursor Moves.

function ShadeMail(ctl)
{
	ctl.style.background="#1A5083";
}

// Remove Shading while Cursor Out.
function RShadeMail(ctl)
{
	ctl.style.background="";	
}

function PopupMail()
{				
	if(ValidateForm()==true){
	var to=document.getElementById('txtTo').value; 
	var Message=document.getElementById('txtComment').value; 
	var url=location.href; 
	var logUserName=document.getElementById('logeduserName').value;
	
	var test=FinancialExpress.EmailComponent.EmailCreator.sendPopupMail(to,Message,url,logUserName,emailSiteCode+','+emailSitemailid+','+emailDomain+','+emailSiteName+','+siteUserEmail);	
	document.getElementById('txtTo').value=''; 
	document.getElementById('txtComment').value=''; 
	document.getElementById('MailDiv').style.visibility='hidden';
	document.getElementById('Email').style.visibility='hidden';	
	document.getElementById('MailIFrame').style.visibility='hidden';	
	}
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

	 if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}

	 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}

	 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }

	 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		if(str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
 		 return true
	}
	function ValidateForm(){	
	if(document.getElementById('MailDiv').style.visibility=="visible")
	{
		var emailID=document.getElementById('txtTo');			
		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email ID")
			emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
		return true
	}
 }
 


function controlDrag(d,ifid)
{			
	var totalLeft=parseInt(d.style.left.replace('px',''))+600;	
	var totalTop=parseInt(d.style.top.replace('px',''))+d.style.height.replace('px','');		
	var pageWidth =window.screen.width;		
	var pageHeight=window.screen.height;
	
	if(totalLeft>(pageWidth-1))
	{	
		if(d.style.top.replace('px','')<0 || (d.style.top<"0px"))
		{			
			if (navigator.appName.indexOf("Microsoft") == -1) {
				d.style.left=pageWidth-605+"px";
				ifid.style.left=pageWidth-605+"px";
			}							
				d.style.left=pageWidth-605;
				ifid.style.left=pageWidth-605;
				
			d.style.top=0;
			ifid.style.top=0;
			if (navigator.appName.indexOf("Microsoft") == -1) {
			 d.style.top=0+"px";
			 ifid.style.top=0+"px";			
			 }
		}else if(totalTop>(pageHeight))
		{
			if (navigator.appName.indexOf("Microsoft") == -1) {
				d.style.left=pageWidth-605+"px";
				ifid.style.left=pageWidth-605+"px";
			}							
				d.style.left=pageWidth-605;
				ifid.style.left=pageWidth-605;
			if (navigator.appName.indexOf("Microsoft") == -1) {
				var topmoz=pageHeight -d.style.height.replace('px','');
				d.style.top=topmoz+"px";
				ifid.style.top=topmoz+"px";
			}
			d.style.top=pageHeight-d.style.height.replace('px','');	
			ifid.style.top=pageHeight-d.style.height.replace('px','');				 
		}else
		{
			if (navigator.appName.indexOf("Microsoft") == -1) {
				d.style.left=pageWidth-605+"px";
				ifid.style.left=pageWidth-605+"px";
			}							
			d.style.left=pageWidth-605;
			ifid.style.left=pageWidth-605;		
		}
	}	
	else if(d.style.left.replace('px','')<0|| (d.style.left<'0px'))
	{	
		if(d.style.top.replace('px','')<0 || (d.style.top<"0px"))
		{					
			d.style.left=0;	
			ifid.style.left=0;	
			if (navigator.appName.indexOf("Microsoft") == -1) {
			 d.style.left=0+"px";
			 ifid.style.left=0+"px";
			}	
			d.style.top=0;
			ifid.style.top=0;
			if (navigator.appName.indexOf("Microsoft") == -1) {
			 d.style.top=0+"px";
			 ifid.style.top=0+"px";
			 }
		}else if(totalTop>(pageHeight))
		{
			d.style.left=0;	
			ifid.style.left=0;	
			if (navigator.appName.indexOf("Microsoft") == -1) {
			 d.style.left=0+"px";
			 ifid.style.left=0+"px";
			}	
			if (navigator.appName.indexOf("Microsoft") == -1) {
				var topmoz=pageHeight -d.style.height.replace('px','');
			d.style.top=topmoz+"px";
			ifid.style.top=topmoz+"px";
			}
			d.style.top=pageHeight-d.style.height.replace('px','');			
			ifid.style.top=pageHeight-d.style.height.replace('px','');			
		}
		else
		{						
			d.style.left=0;
			ifid.style.left=0;	
			if (navigator.appName.indexOf("Microsoft") == -1) {
			 d.style.left=0+"px";
			 ifid.style.left=0+"px";
			}	
		}			
	}	
	else if(totalTop>(pageHeight))
	{					
		if (navigator.appName.indexOf("Microsoft") == -1) {
			var topmoz=pageHeight -d.style.height.replace('px','');
			d.style.top=topmoz+"px";
			ifid.style.top=topmoz+"px";
		}
		d.style.top=pageHeight-d.style.height.replace('px','');
		ifid.style.top=pageHeight-d.style.height.replace('px','');		
	}	
	else if(d.style.top.replace('px','')<0 || (d.style.top<"0px"))
	{
		d.style.top=0;
		ifid.style.top=0;
		if (navigator.appName.indexOf("Microsoft") == -1) {
		 d.style.top=0+"px";
		 ifid.style.top=0+"px";
		}	
	}				
}
/************************************************* Gadget Content *****************************************************************/
/**********************************************************************************************************************************/

//Global Variable for clearing timeout...
var CTO;
function CalculatorContent()
{
	var strBuilder="";
	
	strBuilder+='<iframe id="CalcIFrame" src="" frameborder="0" scrolling="no" style="width:278px;position: absolute;visibility: hidden; top: 203px;left: 830px;height:253px;"></iframe>'; 		
	strBuilder += '<div id="CalcMainDiv" onload="DisableSelect();AlignSettingsCalc();CalcForeScreen();" onclick="CalcForeScreen();" style="width: 276px; position: absolute; background-color:white; visibility:hidden; top: 203px;left: 830px; border: solid 2px #a7c7e7;height:250px;" >';
	strBuilder += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
	strBuilder += '<tr id="CalcTitleTR" title="Currency Gadget - Double Click here to Minimize/Expand CalculatorDiv" style="height: 23px; cursor:move; background: url(/images/bgMainMenuActive.gif) repeat-x;" onmousedown="dragOBJ(document.getElementById(\'CalcMainDiv\'),event,document.getElementById(\'CalcIFrame\'),document.getElementById(\'CalcTitleTR\')); return false;" ondblclick="MinimizeCalcWindow(\'CalculatorDiv\');">';
	strBuilder += '<td style="width: 55%;text-align: left; border-bottom: solid 1px #a7c7e7;padding-left: 6px;">';
	strBuilder += '<b style="color:White; font-size:12px;">Currency Gadget</b></td>';
	strBuilder += '<td style="text-align: right;width: 65%; padding: 0px 0px 0px 0px;margin: 5px 0px 5px 0px; border-bottom: solid 1px #a7c7e7;">';
	strBuilder += '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
	strBuilder += '<td style="width:55%;">&nbsp;</td>';
	strBuilder += '<td style="cursor:pointer;width:15%;" title="Select your Mode of Operation" onmouseover="Shade(this)" onmouseout="RShade(this)" onclick="ShowMW()">';
	strBuilder += '&nbsp;<img alt="Select your Mode of Operation" src="/images/mode.gif"> &nbsp;';
	strBuilder += '</td>';
	strBuilder += '<td id="CMinimizeL" style="cursor:pointer; width:15%; font-weight:bold; font-size:16px; color:White;" title ="Minimize" onmouseover="Shade(this)" onmouseout="RShade(this)" onclick="MinimizeCalcWindow(\'CalculatorDiv\');">';
	strBuilder += '&nbsp;_&nbsp;';
	strBuilder += '</td> ';
	strBuilder += '<td style="cursor:pointer; font-weight:bold; width:15%; font-size:16px; color:White;" id="CloseL" title="Close" onmouseover="Shade(this)" onmouseout="RShade(this)" onclick="CloseCalc();">';
	strBuilder += '&nbsp;X&nbsp;';
	strBuilder += '</td></tr></table></td></tr></table>';
	
	//Creating Mode Menu
	strBuilder += '<div id="ModeWindowDiv" style="width:100px; position:absolute; display:block; background:white; visibility:hidden;">';
	strBuilder += '<table cellpadding="0" cellspacing="0" width="100%" style="background-color: #ECF1F9; display:block; border:1px solid #1A5083;">';
	strBuilder += '<tr><td onmouseover="MShade(this)"onmouseout="MRShade(this)"><input type="radio" id="StandardC" checked="checked" name="Mode" style="border:0px;width:15px;" value="SC" onclick="HideMW();ChangeMode();" />';
	strBuilder += '</td><td style="vertical-align:middle;" ><label for="StandardC">Standard Calc </label> </td> </tr>';
	strBuilder += '<tr><td onmouseover="MShade(this)" onmouseout="MRShade(this)"><input type="radio" id="ExchangeC" name="Mode" style="border:0px;width:15px;" value="EC" onclick="HideMW();ChangeMode();" />';
	strBuilder += '</td><td style="vertical-align:middle;" ><label for="ExchangeC">Exchange Calc </label> </td> </tr>';
	strBuilder += '</table></div>';
	
	//Creating Exchange Rate Calc
	strBuilder += '<div id="ExRateCalc" style="padding-right:1px;width:274px;background-color:white; visibility:hidden;position:absolute;padding-bottom:5px;">';
	strBuilder += '<table id="ExRateTable" cellpadding="0" cellspacing="0" width="100%" style="padding-top:5px;">'
	strBuilder += '<tr>';
	strBuilder += '<td colspan="5" style="padding-left:7px;">';
	strBuilder += '<input type="text" id="ExRateInputT" style="width:260px;text-align:right;" value="0" onkeypress="InitializeInput(this);return OnlyNumbers(event);" onkeyup="return CheckNull(event)" />';
	strBuilder += '</td></tr>';
	strBuilder += '<tr><td colspan="5" style="height:11px;"></td></tr>';
	strBuilder += '<tr>';
	strBuilder += '<td style="padding-left:7px;width:20%;">From</td>';
	strBuilder += '<td style="width:25%;">';
	strBuilder += '<span id="ExDate1L"></span>';
	strBuilder += '</td>';
	strBuilder += '<td style="width:10%;valign:middle;">';
	//strBuilder += '<script language="javascript" type="text/javascript">';
	strBuilder += DateInput('ExDate1T', true, 'DD-MON-YYYY','ExDate1L',TodayDate(),false);
	//strBuilder += '</script>';
	strBuilder += '</td>';
	strBuilder += '<td style="width:28%">';
	strBuilder += '<select id="ExFromDDL" name="ExFromDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
						}
	strBuilder += '</select>';
	strBuilder += '</td>';
	strBuilder += '<td style="valign:bottom;text-align:left; width:17%;" title="Use this value for Calculation">';
	strBuilder += '<Button style="width:40px;" onclick="MovetoSTD();return false;"><span class="buttonLeft"  ><span class="buttonRight">Use</span></span></Button>';
	strBuilder += '</td></tr>';
	strBuilder += '<tr><td colspan="5" style="height:3px;"></td></tr>';
	strBuilder += '<tr>';
	strBuilder += '<td style="padding-left:7px;">To</td>';
	strBuilder += '<td>';
	strBuilder += '<span id="ExDate2L"></span>';
	strBuilder += '</td>';
	strBuilder += '<td style="valign:middle;">';
//	strBuilder += '<script language="javascript" type="text/javascript">';
	strBuilder += DateInput('ExDate2T', true, 'DD-MON-YYYY','ExDate2L',TodayDate(),false);
	//strBuilder += '</script>';
	strBuilder += '</td>';
	strBuilder += '<td>';
	strBuilder += '<select id="ExToDDL" name="ExToDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
						}
	strBuilder += '</select>';
	strBuilder += '</td>';
	strBuilder += '<td></td>';
	strBuilder += '</tr>';
	strBuilder += '<tr><td colspan="5" style="padding-left:7px;">';
	strBuilder += '<span id="ExResultL" style="color:black;"></span>';
	strBuilder += '</tr>';
	strBuilder += '</table>';
	strBuilder += '</div>';
	
	/////////////////////////////////////////ExRate Mode End here ////////////////////////////////
	
	////////////////////////////////////////CalculatorDiv Content here //////////////////////////////
	
	strBuilder += '<div id="CalculatorDiv" style="visibility:hidden; background-color:White; width:274px; padding-right:2px;">';
	strBuilder += '<table cellpadding="0" style="padding-top: 5px; width:100%">';
	strBuilder += '<tr>';
	strBuilder += '<td colspan="2" style="width:190px;padding: 5px 0px 0px 8px;">';
	strBuilder += '<input type="text" name="CalcInputT" id="CalcInputT" style="width: 179px; text-align: right; cursor:text;" value="0" ';
	strBuilder += 'onSelectStart="return false;" onmousedown="return false;" tabindex="0"';
	strBuilder += ' onkeypress="InitializeInput(this);return OnlyNumbers(event);" onkeyup="return CheckNull(event)" />';
	strBuilder += '</td>';
	strBuilder += '<td style="padding: 5px 0px 0px 0px;width:80px;">';
	strBuilder += '<select id="FromDDL" name="FromDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
						}
	strBuilder += '</select>';
	strBuilder += '</td>';
	strBuilder += '</tr>';
	strBuilder += '<tr><td colspan="2" style="width:190px;padding-left: 8px;">';
//	strBuilder += '<select id="FromDDL" name="FromDDL" style="height: 18px;" onchange="CalculatorAjax();">';
//	strBuilder += '<option value="" selected="selected">Currency</option>';
//				for(var i=0;i<selectedCurrencies.length;i++)
//				{
//					strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
//				}
//	strBuilder += '</select>';
//<!--A Textbox to display Exchange Rate value. Read only. -->
	strBuilder += '<input type="text" name="ExRateT" id="ExRateT" value="0" title="Click here to Get this Value for Calculation" style="width: 179px; text-align: right;" readonly="readonly" onclick="ExNo()" />';
	strBuilder += '</td><td style="width:80px;">';
	strBuilder += '<select id="ToDDL" name="ToDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += "<option value=" + selectedCurrencies[i] + ">" + selectedCurrencies[i] + "</option>";
						}
	strBuilder += '</select></td>';
	strBuilder += '</tr>';
	strBuilder += '<td colspan="3" style="margin:0px 0px 0px 0px; height:12px; padding: 0px 0px 0px 0px;">';
	strBuilder += '<span id="CalcResultL" style="color:Red; height:10px; padding-left:5px; font-size:10px; ">&nbsp;</span>';
	strBuilder += '</td></tr>';
//	strBuilder += '<tr><td colspan="3">';
//	strBuilder += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
//	strBuilder += '<tr><td valign="middle" style="width: 23%;"></td>';
//	strBuilder += '<td style="width: 5%; text-align: left;"></td><td style="width: 22%"></td>';
//	strBuilder += '<td style="width: 50%; text-align: right;">';
//	strBuilder += '<table cellpadding="0" cellspacing="0" border="0">';
//	strBuilder += '<tr align="right"><td style="text-align: right; width: 25%;"></td>';
//	strBuilder += '<td style="text-align: right; width: 25%;"></td><td style="text-align: right; width: 25%;"></td>';
//	strBuilder += '<td style="text-align: right; width: 25%;"></td></tr></table>';
//	strBuilder += '</td></tr></table></td></tr>';
	strBuilder += '<tr>';
	strBuilder += '<td colspan="3" style="text-align: right; padding-bottom: 3px;">';
	strBuilder += '<table cellpadding="2" cellspacing="2" border="0" width="100%" align="center" id="ContentTable">';
	strBuilder += '<tr>';
	strBuilder += '<td colspan="2" style="width: 23%; text-align: left;">';
		//<!-- Display Date Here -->
	strBuilder += '<span id="CalcDateL" style="padding-left:4px;"></span>';
	
	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%; padding-left:5px;">';
	//strBuilder += '<script language="javascript" type="text/javascript">';
	strBuilder +=  DateInput('GadgetDate', true, 'DD-MON-YYYY','CalcDateL',TodayDate(),false);
	//strBuilder += '</script>';
	strBuilder += '</td>';
	
	//strBuilder += '<td style="width: 11.5%;"></td>';
//	strBuilder += '<td style="width: 11.5%;">';
//	strBuilder += '<span class="buttonLeft" title="Factorial" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'NFACT\',\'1\')"><span class="buttonRight">n! </span></span>';
//	strBuilder += '</td><td style="width: 11.5%;">';
//	strBuilder += '<span class="buttonLeft" title="Mod Of" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MOD\',\'2\')"><span class="buttonRight">Mod </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%" title="Percentage">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PERCENT\',\'3\');return false;"><span class="buttonLeft"><span class="buttonRight">% </span></span></Button>';
	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%" title="Backspace">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'BS\',\'0\');return false;"><span class="buttonLeft"  ><span class="buttonRight">BS </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="Clear">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'CLEAR\',\'0\');return false;"><span class="buttonLeft" ><span class="buttonRight">C </span></span></Button>';
	strBuilder += '</td></tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power Y" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XPY\',\'2\')"><span class="buttonRight">X^Y </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Clear">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MC\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">MC </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 7">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'7\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">7 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 8" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'8\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">8 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 9">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'9\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">9 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Change Number\'s Sign">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PM\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight"> &plusmn; </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="1 Divided by X">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'1/X\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">1/X </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="Square Root" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'SQRT\',\'1\')"><span class="buttonRight">SQRT </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power 4" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XP4\',\'1\')"><span class="buttonRight">X^4 </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Store" > ';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MS\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">MS </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 4">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'4\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">4 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 5" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'5\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">5 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 6" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'6\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">6 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Addition" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'ADD\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight">+ </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="Multiplication" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MUL\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight">&times; </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="Percentage" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PERCENT\',\'2\')"><span class="buttonRight">% </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power 3" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XP3\',\'1\')"><span class="buttonRight">X^3 </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Recall" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MR\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">MR </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 1" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'1\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">1 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 2" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'2\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">2 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 3">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'3\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">3 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Subtraction">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'SUB\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight">- </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="Division">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'DIV\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight"> &divide; </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="Log of" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'LOG\',\'1\')"><span class="buttonRight">Log </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power 2" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XP2\',\'1\')"><span class="buttonRight">X^2 </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Plus">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MP\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">M+ </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 0">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'0\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">0 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 00">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'00\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">00 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 000">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'000\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">000 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Decimal Point">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'DOT\',\'0\');return false;"><span class="buttonLeft"  ><span class="buttonRight">. </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="View Result">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'=\',\'0\');return false;"><span class="buttonLeft"  ><span class="buttonRight">= </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="PI Value" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PI\',\'1\')"><span class="buttonRight">PI </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr></table>';
	strBuilder += '</td></tr></table>';
	strBuilder += '</td> </tr> </table>';
	strBuilder += '</div>';
	strBuilder += '</div>';
	
	return strBuilder;
}

function TodayDate()
{
	var today=new Date();
	return today.getDay()+ "-" + today.getMonth()-1 + "-" + today.getFullYear();
}

function ShowCalc()
{
	
	document.getElementById("CalcIFrame").style.visibility = 'visible';
	document.getElementById('CalcIFrame').style.height="251px";
	document.getElementById('CalcIFrame').style.top="218px";
	document.getElementById('CalcIFrame').style.left="830px";
	document.getElementById('CalcMainDiv').style.visibility='visible';
	document.getElementById('CalcMainDiv').style.top="218px";
	document.getElementById('CalcMainDiv').style.left="830px";
	
	if(document.getElementById("StandardC").checked)
		document.getElementById('CalculatorDiv').style.visibility='visible';
	else
		document.getElementById('ExRateCalc').style.visibility='hidden';
	
	ChangeMode();

	CalcForeScreen();
	StableHeader(document.getElementById('CalcTitleTR'));
}

//Getting window in to front than others.
function CalcForeScreen()
{	
	if(!document.all)
	{
		document.getElementById('ContentTable').style.height="150px";
	}
	document.getElementById('CalcIFrame').style.height=parseInt(document.getElementById("CalcMainDiv").style.height.replace("px",""))+2+"px";
	var eid=document.getElementById('MailDiv');	
	var id=document.getElementById('TimeZoneDiv');	
	var cid=document.getElementById('CalcMainDiv');
	
	cid.style.zIndex="2000";	
	if(eid){eid.style.zIndex="100";}	
	if(id){ id.style.zIndex="100";TZCTitleMouseOver();}
}

function CloseCalc()
{
	document.getElementById('CalcMainDiv').style.visibility='hidden';
	document.getElementById('CalcIFrame').style.visibility='hidden';
	document.getElementById('CalculatorDiv').style.visibility='hidden';
	document.getElementById('ModeWindowDiv').style.visibility='hidden';
	document.getElementById('ExRateCalc').style.visibility='hidden';
	
	if(GadgetDate_Object.isShowing())
	{
		GadgetDate_Object.show();
	}
	if(ExDate1T_Object.isShowing())
	{
		ExDate1T_Object.show();
	}
	if(ExDate2T_Object.isShowing())
	{
		ExDate2T_Object.show();
	}
}

function DisableSelect() 
{
	document.onselectstart = function() {return false;} // ie
	document.onmousedown = function() {return false;} // mozilla
}

function AlignSettingsCalc()
{
	if (!document.all)
	{
		document.getElementById("FromDDL").style.height="16px";
		document.getElementById("ToDDL").style.height="16px";
		document.getElementById("CalcInputT").style.width ="179px";
		document.getElementById("ExRateT").style.width ="179px";
	}
}

function HideMW()
{
	//setTimeout('document.getElementById("ModeWindowDiv").style.visibility="hidden"',3000);
	document.getElementById("ModeWindowDiv").style.visibility="hidden";
}

function ShowMW()
{
	var wnd = document.getElementById("ModeWindowDiv");
	wnd.style.visibility = "visible";
	wnd.style.zIndex="3010";
	clearTimeout(CTO);
	CTO = setTimeout("HideMW()",5000);
	
	var versionInfo=navigator.appVersion;
	
	//Checking version 6.0
	if(versionInfo.substring(22,25) == "6.0")
	{
		wnd.style.left = "95px";
	}
	else
	{
		wnd.style.left = "175px";
	}
	
	wnd.style.top = "25px";	
}

function ChangeMode()
{
	if(document.getElementById("StandardC").checked)
	{
		document.getElementById("CalculatorDiv").style.visibility = 'visible';
	
		document.getElementById("ModeWindowDiv").style.visibility='hidden';
		document.getElementById("CalculatorDiv").style.position = 'relative';
		document.getElementById("ExRateCalc").style.position='absolute';
		document.getElementById("ExRateCalc").style.visibility='hidden';
		document.getElementById("CalcMainDiv").style.height = '250px';
	}
	else
	{
		document.getElementById("ExRateCalc").style.visibility = 'visible';
	
		document.getElementById("ModeWindowDiv").style.visibility='hidden';
		document.getElementById("CalculatorDiv").style.position = 'absolute';
		document.getElementById("CalculatorDiv").style.visibility='hidden';
		document.getElementById("ExRateCalc").style.position='relative';
		document.getElementById("CalcMainDiv").style.height = '157px';
	}
	CalcForeScreen();
	document.getElementById("CMinimizeL").innerHTML = "&nbsp;_&nbsp;";
	document.getElementById("CMinimizeL").style.border="0px";
	document.getElementById("CMinimizeL").title = "Minimize";
}

//Make Shading while Cursor Moves over mode window..
function MShade(ctl)
{
	ctl.style.background="#a7c7e7";
}

// Remove Shading while Cursor Out for mode window.
function MRShade(ctl)
{
	ctl.style.background="";
}

//Load values to text box while click in value received.
function MovetoEx(val)
{
	document.getElementById("ExRateInputT").value = val;
}

//Function for Use button. This will swap mode and place the value in Standar mode for calculation.
function MovetoSTD()
{
	document.getElementById("StandardC").checked=true;
	ChangeMode();
	document.getElementById("CalcInputT").value=document.getElementById("ExRateInputT").value
}

/*****************************************************************************************************************************************/


/// Main functions to Execute Currency Gadjet with content..
/*
* Developed for Fedby Information Services.
*
*
*/
//Global Variables for Currencies.
//Hardcoded Value to Display selected Currencies.
var selectedCurrencies= new Array("EUR", "GBP", "CHF", "USD", "AUD", "CAD", "HKD", "INR", "JPY", "SAR", "SGD", "ZAR", "SEK", "AED" );
var CurrencyName=new Array("Euro",
									"Great Britain Pounds",
									"Swiss Franc",
									"United States of America Dollars",
									"Australian Dollar",
									"Canadian Dollar",
									"Hong Kong Dollars",
									"Indian Rupee",
									"Japan, Yen",
									"Saudi Riyal",
									"Singapore Dollar",
									"South African Rand",
									"Sweden Kronor",
									"United Arab Emirates Dirham");	
																			
//Global Variables for CalculatorDiv.
var AgainOpn=false;
var newOpn = false;
var strMemory="0";
var PrimaryNo=parseFloat("0");
var SecondNo=parseFloat("0");
var ThirdNo=parseFloat("0");
var CurrentOpn="";
var OpnSelected=false;
var againEqual=false;

//Minimize Window is the function to Minimise Currency Gadjet Window.
//To Minimise Current Window to Bottom.
//<params> Div Id  </params>
function MinimizeCalcWindow(divID)
{
	//Code here for Minimising Div.
	if(document.getElementById("StandardC").checked)
	{
		if(document.getElementById(divID).style.visibility == 'visible')
		{
			document.getElementById(divID).style.visibility = 'hidden';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '21px';
			document.getElementById("CMinimizeL").innerHTML = "<img src='/images/shape_square.png' style='border:#FFFFFF solid 1px; height:11px;' alt='Maximize'/>&nbsp;";
			document.getElementById("CMinimizeL").style.verticalAlign = "middle";
			document.getElementById("CMinimizeL").title ="Maximize";
		}
		else
		{
			document.getElementById(divID).style.visibility = 'visible';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '250px';
			document.getElementById("CMinimizeL").innerHTML = "&nbsp;_&nbsp;";
			document.getElementById("CMinimizeL").style.verticalAlign = "bottom";
			document.getElementById("CMinimizeL").style.border="0px";
			document.getElementById("CMinimizeL").title = "Minimize";
		}
	}
	else
	{
		if(document.getElementById("ExRateCalc").style.visibility == 'visible')
		{
			document.getElementById("ExRateCalc").style.visibility = 'hidden';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '21px';
			document.getElementById("CMinimizeL").innerHTML = "<img src='/images/shape_square.png' style='border:#FFFFFF solid 1px; height:16px;' alt='Maximize'/>";
			document.getElementById("CMinimizeL").style.verticalAlign = "bottom";
			document.getElementById("CMinimizeL").title ="Maximize";
		}
		else
		{
			document.getElementById("ExRateCalc").style.visibility = 'visible';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '174px';
			document.getElementById("CMinimizeL").innerHTML = "&nbsp;_&nbsp;";
			document.getElementById("CMinimizeL").style.border="0px";
			document.getElementById("CMinimizeL").title = "Minimize";
		}
	}
	CalcForeScreen();
}

//Make shading while Cursor Moves.

function Shade(ctl)
{
	ctl.style.background="#1A5083";
}

// Remove Shading while Cursor Out.
function RShade(ctl)
{
	ctl.style.background="";
}

//Ajax Function Starting Here....

function CalculatorAjax()
{
	var xmlHttp;
	var dispContent;
	try
	  {  
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	  }
	  catch (e)
	  {  // Internet Explorer  
		  try
			 {    
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
			 }
			catch (e)
			{    
				try
				{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
				catch (e)
				{      
					alert("Your browser does not support AJAX!");      
					return false;     
				}    
			}		
		}
	  xmlHttp.onreadystatechange=function()
	  {
		 if(xmlHttp.readyState==4)
		 {
			var result=xmlHttp.responseText;
			var splitResult=new Array();
			
			if(document.getElementById("StandardC").checked)
			{
				splitResult=result.split(",");

				if(!isNaN(Math.round(splitResult[0] * 10000)/10000))
				{
					if(document.getElementById("CalcInputT").value != "" && document.getElementById("CalcInputT").value != "0")
					{
						document.getElementById("ExRateT").value= parseFloat(document.getElementById("CalcInputT").value) * Math.round(splitResult[0] * 10000)/10000;
					}
					else
					{
						document.getElementById("ExRateT").value= Math.round(splitResult[0] * 10000)/10000;
					}
						
				 dispContent="Rate of " + document.getElementById("ToDDL").value + " vs One " + document.getElementById("FromDDL").value + " is :" + Math.round(splitResult[0] * 10000)/10000;
				 	 							 
				  document.getElementById("CalcResultL").style.color="black";
				  document.getElementById("CalcResultL").innerHTML=dispContent;
				}
				else
					document.getElementById("ExRateT").value="Not Available!";
					
				if(splitResult[1] == "1")
				{
					document.getElementById("CalcDateL").style.color="red";
					document.getElementById("CalcDateL").innerHTML="<Marquee scrolldelay=150> History applicable for Past Dates only, so today date Considered. </Marquee>";
					document.getElementById("CalcDateL").style.color="#000000";
				}
			}
			else
			{
				splitResult=result.split(",");
				clearTimeout(CTO);
				document.getElementById("ExResultL").innerHTML=splitResult[0];
				
				if(!isNaN(parseFloat(splitResult[1])))
					document.getElementById("ExRateInputT").value=splitResult[1];
				else
					document.getElementById("ExRateInputT").value="Not Available!";
			}
		 }
	  }
		if(document.getElementById("StandardC").checked)
  		{
  			 if(document.getElementById("FromDDL") && document.getElementById("ToDDL"))
  			 {
  				 if(document.getElementById("FromDDL").value != "" && document.getElementById("ToDDL").value != "")
				 {
					  if(CheckCurrency())
					  {
  							if(document.getElementById("FromDDL").value == "AED" || document.getElementById("ToDDL").value == "AED")
							  {
								  document.getElementById("CalcResultL").innerHTML="Currently this Currency type is Not Available!";
								  document.getElementById("ExRateT").value="0";
								  xmlHttp=false;
							  }
							  else
							  {
  								  document.getElementById("ExRateT").value="Loading......";
  								  document.getElementById("CalcResultL").innerHTML="";
  								  xmlHttp.open("POST","/Tools/GetForExRate.aspx",true);
								  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
								  xmlHttp.send(getQueryString());
								  document.getElementById("CalcResultL").style.color="#000000";
								  document.getElementById("CalcResultL").innerHTML="Click this, to do Calculations with it <b>^</b>";
								  setTimeout('DisplayCurrencyName(document.getElementById("FromDDL"),document.getElementById("ToDDL"))',2000);
								  CTO=setTimeout('document.getElementById("CalcResultL").innerHTML="";document.getElementById("CalcResultL").style.color="red"',5000);
							
							  }
						
					  }
					  else
					  {
						  document.getElementById("CalcResultL").style.color = "red";
						  clearTimeout(CTO);
						  document.getElementById("CalcResultL").innerHTML="Selected Currencies are Same!";
						  document.getElementById("ExRateT").value="0";
						  xmlHttp=false;
					  }
				 }
				 else 
				 {	
						DisplayCurrencyName(document.getElementById("FromDDL"),document.getElementById("ToDDL"));
				}
			}
		}
		else
		{
			if(document.getElementById("ExFromDDL") && document.getElementById("ExToDDL"))
			 {	
				if(document.getElementById("ExFromDDL").value != "" && document.getElementById("ExToDDL").value != "")
				 {
					  if(CheckCurrency())
					  {
						  if(document.getElementById("ExFromDDL").value == "AED" || document.getElementById("ExToDDL").value == "AED")
						  {
							  document.getElementById("ExResultL").innerHTML="Currently this Currency type is Not Available!";
							  xmlHttp=false;
						  }
						  else
						  {
							  document.getElementById("ExResultL").style.color = "black";
							  document.getElementById("ExResultL").innerHTML="Loading....";
							  document.getElementById("CalcResultL").innerHTML="";
							  xmlHttp.open("POST","/Tools/GetForExRate.aspx",true);
							  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
							  xmlHttp.send(getQueryString());
						  }
						}
					  else
					  {
						  document.getElementById("ExResultL").style.color = "red";
						  document.getElementById("ExResultL").innerHTML="Selected Currencies are Same!";
						  xmlHttp=false;
					  }
				 }
				 else 
				 {	
						DisplayCurrencyName(document.getElementById("ExFromDDL"),document.getElementById("ExToDDL"));
						CTO=setTimeout('document.getElementById("ExResultL").innerHTML="";',5000);
				 }
			}
		}
  }
 
 function DisplayCurrencyName(ctl,ctl1)
 {
	var curr1="",curr2="";
	
	for(var i=0; i < selectedCurrencies.length ; i++)
	{
		if(ctl.value == selectedCurrencies[i])
		{
			curr1=CurrencyName[i];
		}
		if(ctl1.value == selectedCurrencies[i])
		{
			curr2=CurrencyName[i];
		}
	}
	if(document.getElementById("StandardC").checked)
	{
		document.getElementById("CalcResultL").style.color="#000000";
		document.getElementById("CalcResultL").innerHTML=curr1;
		if(curr1 == "" || curr2 == "")
		 document.getElementById("CalcResultL").innerHTML=curr1 + curr2 
		else
		 document.getElementById("CalcResultL").innerHTML=curr1 + ", " + curr2;
	}
	else
	{
		document.getElementById("ExResultL").style.color="#000000";
		document.getElementById("ExResultL").innerHTML=curr1;
		if(curr1 == "" || curr2 == "")
		 document.getElementById("ExResultL").innerHTML=curr1 + curr2 
		else
		 document.getElementById("ExResultL").innerHTML=curr1 + ", " + curr2;
	}
 } 	
 
 function ExNo()
 {
	if(document.getElementById("ExRateT").value != "0" && ! isNaN(document.getElementById("ExRateT").value))
	{
		document.getElementById("CalcInputT").value=document.getElementById("ExRateT").value;
	}
 } 
 
 function CheckCurrency()
 {
	var returnVal=false;
	var fromC=document.getElementById("FromDDL").value;
	var toC=document.getElementById("ToDDL").value;
	var ExfromC=document.getElementById("ExFromDDL").value;
	var ExtoC=document.getElementById("ExToDDL").value;
	
	if(fromC != toC && document.getElementById("StandardC").checked)
	{
		returnVal=true;
	}
	if(ExfromC != ExtoC)
	{
		returnVal=true;
	}
	
	return returnVal;
 }
  
  function getQueryString()
  {
	 
		var strPass="";
		
		if(document.getElementById("StandardC").checked)
		{
			strPass="FromDDL=" + document.getElementById("FromDDL").value;
			strPass+="&ToDDL="+document.getElementById("ToDDL").value;
			strPass += "&GivenDate1=" + document.getElementById("CalcDateL").innerHTML;
			strPass += "&Mode=0";
		}
		else
		{
			strPass="FromDDL=" + document.getElementById("ExFromDDL").value;
			strPass+="&ToDDL="+document.getElementById("ExToDDL").value;
			strPass += "&GivenDate1=" + document.getElementById("ExDate1L").innerHTML;
			strPass += "&GivenDate2=" + document.getElementById("ExDate2L").innerHTML;
			strPass += "&Mode=1";
		}
		
		return strPass;
	
  }
  
 function OnlyNumbers(e)
 {
	var keycode= (e.keyCode) ? e.keyCode : e.which;
	
	if(keycode==27)
	{
		document.getElementById("CalcInputT").value="0";
		return true;
	}
	if(keycode==8 || keycode==9 || keycode==37 || keycode==46 || (keycode>= 48 && keycode<=57))
	{
		if(keycode==46 && !CheckDot())
		{
			return true;
		}
		else if(keycode >= 48 && keycode <=57)
		{
			InitializeInput(document.getElementById('CalcInputT'));
			CalcOperation(String.fromCharCode(keycode),'0');
			return false;
		}
		else
		{
			return false;
		}
	}
	else if(keycode==43)
	{
		//Addition operation
		CalcOperation("ADD",2); 
		return false;	
	}
	else if(keycode==45)
	{
		//Multiplication operation
		CalcOperation("SUB",2);
		return false;	 	
	}
	else if(keycode==42)
	{
		//Multiplication operation
		CalcOperation("MUL",2); 
		return false;		
	}
	else if(keycode==47)
	{
		//Division operation
		CalcOperation("DIV",2); 
		return false;		
	}
	else if(keycode==61 || keycode == 13)
	{
		//Either Enter or Equal to Pressed, View Result operation
		CalcOperation("=",1); 
		return false;		
	}
	else
	{
		return false;
	}
 }

 function InitializeInput(InputCtl)
 {
	if(InputCtl.value == "0")
	{
		InputCtl.value="";		
	}
	else if(InputCtl.value == "Infinity" || InputCtl.value == "NaN")
	{
		OpnSelected=false;
		CurrentOpn="";
		newOpn=true;
	}
	else if(InputCtl.value=="")
	{
		InputCtl.value="0";
	}
 }


function CalcOperation(opn,key)
{
	ctl=document.getElementById("CalcInputT");
	
	if(opn != "=")
	{
		if(key != "3" && key != "1")
		{
			againEqual = false;
		}
		if (key == "2")
		{
			if(OpnSelected)
			{ 
				if(!newOpn)
				{
					DoOperation(ctl,CurrentOpn);
					PrimaryNo=parseFloat(ctl.value);
					CurrentOpn = opn;
				}
				else
				{
					PrimaryNo=parseFloat(ctl.value);
					CurrentOpn=opn;
				}
				newOpn = true;
			}
			else
			{
				OpnSelected=true;
				newOpn=true;
				PrimaryNo=parseFloat(ctl.value);
				CurrentOpn=opn;
			}
		}
		else if(key == "1")
		{
			DoOperation(ctl,opn);
			if(opn != "PM")
			{
				newOpn = true;
			}
		}
		else if(key == "0")
		{
			if(ctl.value == "Infinity" || ctl.value == "NaN")
			{
				InitializeInput(ctl);
			}
			if(opn != "BS")
			{	
				if(newOpn)
				{
					ctl.value="0";
					newOpn=false;
				}
			}
			DoOperation(ctl,opn);
		}
		else if(key == "3")
		{
			if(OpnSelected)
			{
				DoOperation(ctl,opn);
			}
			else if(againEqual)
			{
				PrimaryNo=parseFloat(ctl.value);
				DoOperation(ctl,opn);
				ThirdNo=parseFloat(ctl.value);
				OpnSelected=false;
				newOpn=true;
			}
			else
			{
				ctl.value= "0";
			}
		}
	}
	else
	{
		if(!againEqual)
			SecondNo=parseFloat(ctl.value);
		
		if(ThirdNo != 0)
		{
			SecondNo=ThirdNo;
			ThirdNo=parseFloat("0");
		}
		
		DoOperation(ctl,CurrentOpn);
		
		if(!againEqual)
			againEqual = true;
			
		OpnSelected=false;
		newOpn=true;
		
		PrimaryNo=SecondNo;
	}
}

function DoOperation(control,COpn)
{
	document.getElementById("CalcResultL").style.color = "black";
	switch(COpn)
	{
		case "XPY":
			control.value=Math.pow(PrimaryNo,ctl.value);
			break;
		case "XP4":
			control.value=Math.pow(PrimaryNo,4);
			AgainOpn=true;
			break;
		case "XP3":
			control.value=Math.pow(PrimaryNo,3);
			AgainOpn=true;
			break;
		case "XP2":
			control.value=Math.pow(PrimaryNo,2);
			AgainOpn=true;
			break;
		case "MC":
			strMemory ="0";
			AgainOpn=true;
			break;
		case "MS":
			strMemory=control.value;
			AgainOpn=true;
			break;
		case "MR":
			control.value=strMemory;
			AgainOpn=true;
			break;
		case "MP":
			strMemory = parseFloat(strMemory)+parseFloat(control.value);
			AgainOpn=true;
			break;
		case "7":
			InitializeInput(control);
			control.value=control.value + "7";
			break;
		case "4":
			InitializeInput(control);
			control.value=control.value + "4";
			break;
		case "1":
			InitializeInput(control);
			control.value=control.value + "1";
			break;
		case "0":
			AddZero(control,"0");
			break;
		case "8":
			InitializeInput(control);
			control.value=control.value + "8";
			break;
		case "5":
			InitializeInput(control);
			control.value=control.value + "5";
			break;
		case "2":
			InitializeInput(control);
			control.value=control.value + "2";
			break;
		case "00":
			AddZero(control,"00");
			break;
		case "NFACT":
			control.value=NFactorial(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "9":
			InitializeInput(control);
			control.value=control.value + "9";
			break;
		case "6":
			InitializeInput(control);
			control.value=control.value + "6";
			break;
		case "3":
			InitializeInput(control);
			control.value=control.value + "3";
			break;
		case "000":
			AddZero(control,"000");
			break;
		case "MOD":
			control.value=Mod(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "PM":
			if(parseFloat(control.value) > 0)
			{
				var temp=parseFloat(control.value);
				temp=temp - (temp * 2);
				control.value=temp;
			}
			else if(parseFloat(control.value) < 0)
			{
				var temp=parseFloat(control.value);
				temp=(-temp * 2)+ temp;
				control.value=temp;
			}
			else
			{
				control.value="0";
			}
			break;
		case "ADD":
			control.value = PrimaryNo + parseFloat(control.value);
			break;
		case "SUB":
			if(!againEqual)
				control.value = PrimaryNo - parseFloat(control.value);
			else
				control.value = parseFloat(control.value) - PrimaryNo  ;
			break;
		case "DOT":
			if(!CheckDot())
				control.value=control.value + ".";
			break;
		case "BS":
			if(!OpnSelected)
			{
				BackSpace(control);
			}
			document.getElementById("CalcResultL").innerHTML = "";
			break;
		case "DIV":
			if(!againEqual)
				control.value = parseFloat(PrimaryNo / control.value);
			else
				control.value = parseFloat(control.value /PrimaryNo );
			break;
		case "MUL":
			sc=parseFloat(control.value);
			control.value = PrimaryNo * parseFloat(control.value);
			break;
		case "1/X":
			control.value=(1/parseFloat(control.value));
			AgainOpn=true;
			break;
		case "CLEAR":
			ClearTextField();
			document.getElementById("CalcResultL").innerHTML = "";
			break;
		case "SQRT":
			control.value=Math.sqrt(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "PERCENT":
			sc=parseFloat(control.value);
			control.value=Percentage(PrimaryNo, parseFloat(control.value));
			break;
		case "LOG":
			control.value=Math.log(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "PI":
			control.value=Math.PI;
			break;
	}
}

function ClearTextField()
{
	CurrentOpn="";
	PrimaryNo=parseFloat("0");
	SecondNo=parseFloat("0");
	ThirdNo=parseFloat("0");
	OpnSelected=false;
	CurrentOpn="";
	newOpn=true;
	document.getElementById("CalcInputT").value="0";
	document.getElementById("ExRateInputT").value="0";
	document.getElementById("ExRateT").value="0";
	document.getElementById("FromDDL").value="";
	document.getElementById("ToDDL").value="";
	document.getElementById("ExFromDDL").value="";
	document.getElementById("ExToDDL").value="";
}

function BackSpace(control)
{
	if(control.value != "Infinity")
	{
		control.value=control.value.substring(0,control.value.length-1);
		if(control.value.length <=0)
			control.value="0";
	}
	else
	{
		control.value = "0";
	}
}

function AddZero(control,val)
{
	if(CheckDot() || (parseFloat(control.value) != 0) )
		control.value = control.value + val;
}

function NFactorial (n)
{ 
    if(n==0) return(1);

    return (n * NFactorial (n-1) );
}

function Mod(n)
{
	return (PrimaryNo - (parseInt(PrimaryNo / n) * parseInt(n)));
}

function Percentage(a,b)
{
	var temp;
	temp = parseFloat(a/100);
	temp = temp * b;
	return temp;
}

function CheckDot()
{
	var temp=document.getElementById("CalcInputT").value;
		for(var i=0; i<temp.length; i++)
		{
			if(temp.substring(i,i+1) == ".")
			{
				return true;
			}
		}
		return false;
}

function CheckNull(e)
{
	if(e.keyCode == 46 || e.keyCode == 8)
	{
		var temp=document.getElementById("CalcInputT");
		if(temp.value.length == 0)
		{
			temp.value="0";
			return false;
		}
		return true; 
	}
}


/***************************************/
/*		Time Zone Converter			   */
/***************************************/

var oldSTD = new Date();
var TZ = oldSTD.getTimezoneOffset();
var TZCDisplayStatus=false;
var monthList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var pickedTimeStatus = "CT";  // It holds two values CT - Current Time, PT - Preset Time
var statusTimer=0;			  // To maintain the status to display current time and preset time
var std;					  // Global variable to get Server Time and Date
var GlobalCurrentCountry = "";
var GlobalSpecificCountry = "";
var initiateControl=false;


// An array object consist of all the Countries in this world
// with their respective differenct from utc timings
var countries;
var dayLightDatas=null;

function LoadDayLightData(r)
{
dayLightDatas=r.DayLightDatas;
}

function CheckDayLight(stardardname)
{
if(dayLightDatas!=null)
{
 for(i=0;i<dayLightDatas.length;i++)
 {
 if(dayLightDatas[i].Name==stardardname)
  return dayLightDatas[i].IsDayLight;
 }
}
 return false;
}

// Function will load the coordinates of all the countries in the worldmap				   
function loadAreaCoords() {
	// Countries
	document.getElementById("Afghanistan").coords="341,133,339,137,337,139,334,139,332,142,329,142,328,142,328,139,326,136,327,134,329,134,331,133,334,131,337,131,340,131,341,131";
	document.getElementById("Albania").coords="269,125,267,122,267,119,270,120";
	document.getElementById("Algeria").coords="249,157,243,153,234,148,230,146,231,142,239,141,240,137,242,133,249,131,256,131,254,133,254,138,257,144,257,149,258,153,253,155,249,157";
	document.getElementById("Andorra").coords="250,115,251,118,253,116,252,115";
	document.getElementById("Angola").coords="272,208,265,209,262,209,258,208,259,205,262,202,262,199,260,196,259,192,264,192,267,195,273,195,274,199,274,201,275,201,273,204,273,208,272,209";
	document.getElementById("Antigua and Barbuda").coords="156,161,156,163,157,162,157,160";
	document.getElementById("Argentina").coords="150,269,146,268,143,264,141,260,143,255,143,250,144,244,145,237,145,231,146,224,149,222,149,218,153,214,159,218,163,222,164,224,163,229,162,233,164,237,164,240,160,242,156,243,156,244,154,243,153,247,154,247,152,251,150,252,149,254,152,256,149,259,147,262,148,266,150,268";
	document.getElementById("Armenia").coords="299,122,303,125,301,126,299,125,299,124";
	// Australian
	document.getElementById("Australian Capital Territory - Canberra").coords="450,238,447,235,450,233,451,236";
	document.getElementById("New South Wales - Sydney").coords="451,234,450,232,448,234,447,236,443,235,440,234,439,232,439,228,439,226,442,226,447,227,452,229,455,229,453,233,452,234";
	document.getElementById("Northern Territory - Darwin").coords="421,205,421,212,421,213,421,221,425,221,432,221,434,221,434,213,433,208,432,206,431,203,431,202,429,202,425,201";
	document.getElementById("Queensland - Brisbane").coords="455,227,453,229,449,226,443,225,440,225,439,225,438,221,435,220,435,214,434,211,433,209,433,208,437,209,438,208,438,202,439,199,440,199,442,204,445,209,448,213,453,219,455,224,454,227,453,230";
	document.getElementById("South Australia - Adelaide").coords="437,239,437,234,438,232,439,226,438,222,437,221,428,222,421,222,421,229,426,231,431,234,433,236,437,238,437,240";
	document.getElementById("Tasmania - Hobart").coords="448,245,444,245,443,246,445,250,448,250,447,250";
	document.getElementById("Victoria - Melbourne").coords="438,241,441,240,444,240,446,242,449,239,449,238,446,236,441,236,439,233,437,235,436,239,437,240";
	document.getElementById("Western Australia - Perth").coords="420,230,420,205,416,206,411,210,406,213,402,215,400,218,401,227,402,234,404,236,409,233,412,234,417,232,419,231";
	// Countries
	document.getElementById("Austria").coords="251,111,252,113,254,113,253,111,252,110";
	document.getElementById("Azerbaijan").coords="309,127,313,127,314,126,314,124,309,125,309,123,307,124,307,128,308,129";
	document.getElementById("Bahamas").coords="135,147,135,150,137,151,138,150,136,148";
	document.getElementById("Bahrain").coords="309,145,309,147,312,148,313,148,312,145";
	document.getElementById("Bangladesh").coords="366,153,368,153,369,150,368,150,366,149,365,148,365,150,365,152,365,153";
	document.getElementById("Barbados").coords="159,165,161,166,160,167,159,166";
	document.getElementById("Belarus").coords="275,105,279,104,282,106,286,105,287,103,286,100,284,98,282,98,280,97,278,100,276,103";
	document.getElementById("Belize").coords="120,159,119,161,122,163,122,160,121,158";
	document.getElementById("Belgium").coords="248,105,246,105,247,109,251,110,251,108,250,107";
	document.getElementById("Benin").coords="239,177,239,172,240,171,241,174,242,179,240,179";
	document.getElementById("Bermuda").coords="152,135,152,138,153,140,155,139,155,137";
	document.getElementById("Bhutan").coords="369,148,365,146,367,142,371,143,372,143";
	document.getElementById("Bolivia").coords="150,215,149,215,147,211,147,208,148,204,148,201,149,198,150,198,153,201,158,202,161,204,163,208,163,211,158,212,157,215,157,216,153,215,151,215";
	document.getElementById("Botswana").coords="282,216,278,220,275,221,273,222,270,222,270,218,271,215,272,212,272,210,276,209,277,209,279,213,282,215,282,216";
	document.getElementById("Bosnia and Herzegovina").coords="268,117,266,120,265,120,264,117,266,116";
	// Brazil Cities
	document.getElementById("Amazonas - Manaus").coords="148,195,157,194,167,191,172,187,172,184,172,179,166,177,161,175,156,173,151,170,148,170,146,168,144,169,142,172,142,174,146,175,149,175,150,178,150,181,150,183,147,183,147,185,145,190,148,192,149,195";
	document.getElementById("Bahia - Salvador").coords="190,201,181,197,172,198,172,207,170,209,173,213,174,217,181,218,186,216,187,212,189,207";
	document.getElementById("Distrito Federal - Brasilia").coords="172,198,171,193,171,190,168,190,163,193,155,195,151,195,150,195,151,199,156,202,162,204,165,209,164,210,162,212,159,212,157,214,159,218,165,214,170,212,170,211,171,207,171,202,171,198";
	document.getElementById("Pernambuco - Recife").coords="191,200,191,201,190,201,186,199,182,196,178,197,173,198,172,196,171,190,172,186,174,184,181,186,187,188,193,191,197,194,194,198,191,200,190,202";
	document.getElementById("Rio de Janeiro - Rio de Janeiro").coords="177,219,174,217,172,214,170,212,165,215,171,223,175,226,175,225,175,220";
	document.getElementById("Sao Paulo - Sao Paulo").coords="173,226,172,229,169,234,166,236,164,235,163,231,163,228,165,225,164,224,162,220,160,218,163,216,164,215,169,222,173,224,173,227";
	// Countries
	document.getElementById("Brunei").coords="392,174,392,179,395,178,395,175,394,175";
	document.getElementById("Bulgaria").coords="275,125,279,124,282,124,282,122,279,120,275,121,274,123";
	document.getElementById("Burkina Faso").coords="262,169,260,173,257,173,251,168,253,166,261,166,262,168";
	document.getElementById("Burundi").coords="284,186,283,187,283,189,285,191,286,189,286,188";
	document.getElementById("Cambodia").coords="387,170,389,167,391,165,390,163,386,163,384,164,384,167,384,168";
	document.getElementById("Cameroon").coords="253,178,255,174,258,177,257,181,255,180";
	// Canada Cities
	document.getElementById("Alberta - Calgary").coords="89,110,84,110,82,110,81,106,76,102,90,102,89,109";
	document.getElementById("Alberta - Edmonton").coords="89,102,80,102,76,102,75,99,74,95,77,95,77,89,91,89,90,101,89,101";
	document.getElementById("British Columbia - Vancouver").coords="82,110,72,111,67,107,63,102,63,98,60,95,57,90,72,89,76,90,76,94,73,94,72,99,76,104,79,107";
	document.getElementById("Manitoba - Winnipeg").coords="90,109,98,110,108,110,115,101,115,95,111,92,110,91,103,89,96,89,91,89,90,98";
	document.getElementById("Newfoundland and Labrador - St. John's").coords="177,107,169,104,164,104,162,101,157,102,160,109,161,116,163,119,168,118,171,113,167,110,165,107,169,106,171,109,176,109";
	document.getElementById("Northwest Territories - Yellowknife").coords="112,91,115,95,110,91,101,89,94,89,90,89,78,89,70,89,63,84,57,75,53,71,53,69,64,67,67,66,71,68,76,68,83,72,88,72,93,73,92,71,83,70,81,68,79,62,78,58,75,64,70,63,68,61,69,53,75,48,87,43,91,43,91,46,85,46,83,49,90,52,91,48,96,51,99,53,97,55,84,55,77,51,73,51,72,55,80,55,88,60,94,62,93,57,98,56,99,64,103,66,103,69,98,70,99,71,104,71,106,69,109,67,109,64,105,62,100,60,102,57,108,56,105,54,100,52,98,50,95,47,96,44,95,40,99,40,105,44,106,43,107,42,110,40,110,37,114,34,125,31,125,54,124,67,126,77,127,81,125,83,121,82,115,82,112,88,112,91";
	document.getElementById("Nova Scotia - Halifax").coords="169,117,167,115,163,116,165,120,168,120";
	document.getElementById("Ontario - Ottawa").coords="117,97,114,102,110,109,113,111,118,113,123,111,130,114,139,115,133,109,131,106,128,104,129,102,129,100,124,99,120,96";
	document.getElementById("Ontario - Toronto").coords="133,118,138,117,138,115,133,114,128,113,123,112,125,116,133,118";
	document.getElementById("Quebec - Quebec").coords="155,108,155,110,150,109,144,114,144,117,139,114,132,108,131,106,134,105,132,99,137,97,134,93,134,85,134,82,127,85,126,81,126,72,124,56,125,38,125,31,138,29,151,29,159,32,151,36,141,43,136,47,134,50,132,52,137,59,146,65,150,67,151,70,156,73,158,75,156,78,154,81,154,86,154,91,161,98,165,101,167,103,161,108,157,109,153,108";
	document.getElementById("Saskatchewan - Regina").coords="97,90,97,105,97,111,91,109,90,104,90,91,91,87,96,90";
	document.getElementById("Yukon Territory - Whitehorse").coords="48,89,58,91,69,89,62,83,58,77,54,73,51,69,47,68,48,88";
	// Countries
	document.getElementById("Cape Verde").coords="210,163,213,160,212,158,208,159,206,161,208,164";
	document.getElementById("Central African Republic").coords="264,180,268,179,275,177,280,177,277,174,273,170,273,169,271,173,268,173,263,175";
	document.getElementById("Chad").coords="274,170,270,173,265,176,263,174,262,171,261,166,261,163,263,159,262,153,261,152,267,151,275,156,276,160,274,164";
	document.getElementById("Chile").coords="140,260,141,255,143,251,143,245,143,240,145,234,145,228,145,225,148,221,148,216,146,212,146,208,144,215,144,222,143,230,141,238,140,244,140,252";
	document.getElementById("China").coords="408,147,406,150,403,152,398,152,396,153,393,154,391,153,391,152,387,151,384,152,383,153,380,152,380,147,380,145,376,142,371,142,369,142,365,142,365,145,361,143,360,141,354,140,353,138,354,134,354,132,351,132,349,132,348,129,345,128,345,126,350,125,356,121,355,118,360,115,365,111,373,108,378,110,380,108,380,103,380,101,377,101,378,96,379,95,383,95,389,91,389,90,389,86,392,83,393,81,394,88,395,91,398,93,401,91,402,89,406,92,404,95,402,98,402,102,397,104,397,105,392,105,391,110,394,111,397,110,403,110,406,110,409,108,412,105,413,104,418,107,422,113,426,114,427,114,423,120,418,123,413,125,411,123,410,124,408,126,405,126,404,128,406,130,408,132,406,134,408,136,408,138,405,139,402,139,405,141,409,142,410,143,408,146";
	document.getElementById("Colombia").coords="134,183,138,184,143,186,144,188,145,186,145,183,149,182,149,180,147,177,142,174,140,172,140,169,138,170,136,173,136,176,135,180";
	document.getElementById("Comoros").coords="302,199,302,202,308,202,310,200,309,198,302,199";
	document.getElementById("Congo").coords="284,195,282,202,275,201,274,197,273,195,267,194,264,191,259,188,259,187,263,182,264,181,278,176,285,178,285,181,284,183,282,184,282,187,284,185,285,188";
	document.getElementById("Costa Rica").coords="122,174,124,175,127,172,128,170,124,169,121,171";
	document.getElementById("Cote d'Ivoire").coords="234,179,238,177,238,173,234,172,230,172,230,178";
	document.getElementById("Croatia").coords="266,108,264,111,267,110";
	document.getElementById("Cuba").coords="137,154,132,152,128,152,126,153,137,156,138,157";
	document.getElementById("Cyprus").coords="287,133,282,133,281,135,286,135";
	document.getElementById("Czech Republic").coords="262,107,259,107,261,110,263,110";
	document.getElementById("Denmark").coords="257,94,253,97,256,102,260,101,260,99";
	document.getElementById("Djibouti").coords="305,168,302,169,306,171";
	document.getElementById("Dominica").coords="157,162,156,164,158,166";
	document.getElementById("Dominican Republic").coords="147,156,146,156,150,160,150,157";
	document.getElementById("East Timor").coords="419,194,414,197,419,199,421,199";
	document.getElementById("Ecuador").coords="131,190,133,192,136,188,139,186,134,183,132,184,130,187";
	document.getElementById("Egypt").coords="278,153,284,152,288,153,289,154,292,151,288,146,286,142,285,139,284,141,281,140,277,139,277,144";
	document.getElementById("El Salvador").coords="118,164,116,164,116,166,119,166";
	document.getElementById("Equatorial Guinea").coords="257,183,255,185,257,186,257,185";
	document.getElementById("Eritrea").coords="293,164,296,164,299,164,301,166,299,163,296,160,295,159,294,160";
	document.getElementById("Estonia").coords="276,93,280,93,280,92,280,90,276,90,275,91";
	document.getElementById("Ethiopia").coords="292,178,296,179,300,179,305,176,308,173,305,172,301,168,299,165,295,165,293,165,290,170,290,173,288,174,291,177";
	document.getElementById("Fijii").coords="486,206,485,210,491,213,492,208,490,206";
	document.getElementById("Finland").coords="277,77,275,81,272,82,272,86,273,90,278,89,284,87,287,84,284,80,284,73,282,71,283,68,280,66,277,69,275,69,272,68,273,71,275,73,275,75";
	document.getElementById("France").coords="253,120,250,121,247,121,247,123,245,123,241,121,240,116,239,113,235,111,243,110,247,106,249,105,255,112,253,118";
	document.getElementById("French Guiana").coords="170,177,167,177,166,180,166,184,172,184,173,180";
	document.getElementById("Gabon").coords="257,189,259,187,258,185,255,185,254,184";
	document.getElementById("The Gambia").coords="219,164,215,164,214,167,219,167,219,165";
	document.getElementById("Germany").coords="253,108,254,113,256,113,260,115,260,111,258,106,260,104,263,105,261,102,258,101,254,101,253,102,252,106";
	document.getElementById("Georgia").coords="297,119,302,123,305,123,308,123,307,121,301,119";
	document.getElementById("Ghana").coords="243,175,242,175,240,173,243,172,244,172,244,176";
	document.getElementById("Greece").coords="276,130,275,128,274,127,273,124,270,124,270,126,270,129,272,131";
	//Greenland Cities
	document.getElementById("Danmarkshavn").coords="217,56,213,54,211,50,212,46,214,44,219,42,219,46,219,53,219,55";
	document.getElementById("Greenland - Nuuk").coords="187,78,186,80,185,83,184,88,183,91,178,89,172,86,169,80,168,74,169,70,172,72,171,69,168,69,166,68,167,64,168,63,165,63,163,54,159,52,154,50,151,47,147,43,148,42,152,41,153,39,149,39,148,37,155,35,163,32,172,32,179,29,190,27,200,26,210,29,216,32,222,32,227,33,224,36,216,41,216,42,212,46,211,50,214,55,212,55,205,55,202,62,202,66,202,67,208,67,211,67,208,70,203,71,198,72,196,75,195,75,192,77,189,78";
	document.getElementById("Scoresbysund").coords="215,62,215,65,212,68,210,67,204,67,202,67,202,61,203,57,205,55,210,55,215,55,217,53,219,53,219,55,216,57,213,60,213,61";
	document.getElementById("Thule").coords="155,51,151,47,148,43,142,42,141,45,143,50,151,53";
	// Countries
	document.getElementById("Grenada").coords="157,164,156,168,161,167,159,164";
	document.getElementById("Guatemala").coords="120,168,121,165,119,164,115,162,111,163,116,166,116,168";
	document.getElementById("Guinea").coords="256,184,257,183,257,181,255,181,255,183";
	document.getElementById("Guyana").coords="164,175,160,176,160,178,164,176,163,173";
	document.getElementById("Haiti").coords="142,156,138,159,141,159,144,159,143,157";
	document.getElementById("Holy See (Vatican City)").coords="254,127,257,127,256,124,255,121,254,121,252,125,253,128";
	document.getElementById("Honduras").coords="121,164,126,165,126,163,124,160,121,160,120,160,118,162";
	document.getElementById("Hong Kong").coords="403,152,399,152,399,156,402,158";
	document.getElementById("Hungary").coords="270,112,267,110,265,113,267,115,270,114";
	document.getElementById("Iceland").coords="210,80,214,83,220,83,226,79,224,75,220,74,212,75,209,77";
	document.getElementById("India").coords="348,173,346,171,346,166,343,162,341,158,341,154,339,156,337,153,336,151,337,150,340,150,339,148,338,146,339,145,342,144,344,142,346,138,344,136,345,134,347,135,350,133,352,133,351,138,351,139,354,142,358,143,361,145,363,146,363,150,364,154,361,156,356,160,354,161,352,163,352,169,350,172";
	// Indonesia Cities
	document.getElementById("Bali - Denpasar").coords="402,196,401,194,399,194,396,195,397,198,401,198";
	document.getElementById("Java - Bandung").coords="390,196,392,194,393,193,390,193,388,193,389,195";
	document.getElementById("Java - Jakarta").coords="391,194,391,196,394,195,394,194,393,192,393,193,392,193,391,193";
	document.getElementById("Java - Surabaya").coords="396,193,394,194,392,196,395,196,396,195,397,193";
	document.getElementById("Kalimantan - Balikpapan").coords="395,188,397,189,400,189,402,187,402,184,399,182,397,182,394,183,392,183,393,185";
	document.getElementById("Papua - Jayapura").coords="407,180,405,178,406,176,408,177";
	document.getElementById("Sulawesi - Manado").coords="388,194,384,190,381,187,378,182,376,179,373,177,380,176,389,187,391,190,389,193";
	// Countries
	document.getElementById("Iran").coords="328,149,323,148,320,146,317,146,313,144,310,142,309,139,307,137,306,135,306,133,304,131,304,129,304,127,307,129,308,128,310,128,312,131,314,131,318,131,320,130,324,130,326,132,325,136,327,141,327,142,328,145,329,147";
	document.getElementById("Iraq").coords="297,138,300,139,305,144,308,144,309,141,306,138,306,134,305,133,304,131,302,131,300,132,300,134,298,135,297,136";
	document.getElementById("Israel").coords="291,135,291,139,293,138,292,136";
	document.getElementById("Italy").coords="264,126,263,125,260,123,257,121,255,120,253,119,251,119,252,116,254,114,257,114,262,114,262,116,259,116,260,118,260,120,263,120,264,122,267,123,267,125,267,127,267,129,265,130,264,131,263,131,261,131,259,131,259,129,262,129,264,128,265,126,263,125";
	document.getElementById("Jamaica").coords="135,159,133,159,133,161,136,161,137,160";
	document.getElementById("Japan").coords="439,116,441,118,442,120,443,118,445,120,445,121,443,122,441,122,439,123,438,123,439,124,440,128,439,130,438,133,438,136,435,136,436,139,433,140,432,138,432,136,430,136,429,137,427,138,426,138,425,140,425,143,425,147,423,149,421,149,418,151,415,150,416,148,419,148,420,146,422,143,423,141,423,139,423,137,420,137,421,135,423,134,425,134,429,132,431,131,433,128,435,127,435,125,435,122,435,120,436,120,438,119,438,117,439,117,440,116,441,117";
	document.getElementById("Jordan").coords="291,143,292,143,294,142,295,141,296,140,297,138,296,137,294,136,292,136,291,138,291,140,291,142";
	document.getElementById("Kazakhstan").coords="341,99,341,101,343,102,347,103,348,102,350,102,351,104,353,106,356,107,358,107,360,108,362,109,363,111,362,112,362,115,359,114,357,115,356,117,354,117,354,118,354,121,351,121,347,121,343,121,341,121,339,123,337,123,337,124,335,124,335,122,335,121,333,120,330,119,328,119,326,118,326,117,326,116,328,115,328,114,331,114,332,113,333,111,332,110,329,110,330,108,329,106,327,106,327,105,328,104,328,103,328,102,328,101,330,101,333,101,335,101,336,101,337,99,339,98,340,98";
	document.getElementById("Kenya").coords="297,191,296,189,294,189,292,188,290,188,290,186,290,185,290,183,291,182,290,180,290,179,291,178,293,178,294,178,295,179,297,180,298,180,299,180,300,182,300,184,299,186,299,187,298,189,298,190,296,191,296,190";
	document.getElementById("Korea, North").coords="415,125,415,128,416,130,418,128,421,127,421,124,422,123,423,121,420,121,417,123,415,125,414,126";
	document.getElementById("Korea, South").coords="417,137,417,133,419,129,420,128,422,131,422,134,420,136,419,136";
	document.getElementById("Kuwait").coords="307,143,308,145,311,144,310,142,308,142,306,143,306,144";
	document.getElementById("Kyrgyzstan").coords="352,121,348,122,345,121,341,121,340,122,338,124,337,125,341,126,346,126,349,124,353,123,354,123";
	document.getElementById("Laos").coords="382,156,382,159,383,160,386,159,390,162,390,164,391,166,393,164,391,162,388,159,387,155,384,155";
	document.getElementById("Latvia").coords="280,97,276,97,275,95,277,94,281,94,281,95";
	document.getElementById("Lebanon").coords="290,136,291,136,292,136,293,135,293,134,292,134,289,134";
	document.getElementById("Lesotho").coords="282,225,281,225,280,226,280,227,281,229,284,228,284,226";
	document.getElementById("Liberia").coords="232,179,232,177,231,176,230,175,228,176,228,177";
	document.getElementById("Libya").coords="256,143,256,141,257,139,258,137,259,136,265,140,269,141,271,140,271,137,274,137,277,140,277,156,275,157,272,155,268,154,266,152,263,152,260,152,258,150,257,148,256,144,256,142";
	document.getElementById("Lithuania").coords="272,98,275,99,278,99,279,97,275,96,274,96,272,95,271,95";
	document.getElementById("Luxembourg").coords="249,109,248,110,248,111,251,111,251,109";
	document.getElementById("Macao").coords="399,154,399,153,397,153,396,153,396,154,398,154";
	document.getElementById("Macedonia").coords="273,124,273,125,274,126,275,125";
	document.getElementById("Malawi").coords="291,204,291,201,290,200,289,201,289,203,288,203,288,207,290,210,292,209";
	document.getElementById("Malaysia").coords="384,181,386,181,386,179,385,178,383,176,382,175,381,175,380,176";
	document.getElementById("Maldives").coords="344,186,345,185,345,181,345,177,344,175,343,174,342,180,343,184,343,186";
	document.getElementById("Mali").coords="247,162,243,163,241,164,240,165,237,165,236,167,235,169,233,171,231,169,231,168,228,167,227,165,227,163,230,163,232,161,234,159,233,157,234,154,231,154,229,155,228,154,229,151,231,149,232,147,234,147,236,149,239,151,242,154,244,154,246,157,248,160,247,162,246,162";
	document.getElementById("Malta").coords="264,132,265,132,265,135,264,133,265,133";
	document.getElementById("Marshall Islands").coords="478,180,479,178,480,177,484,177,487,178,492,177,491,175,490,173,489,173,486,172,482,172,478,171,476,172,475,168,473,166,471,166,469,167,469,169,470,172,470,175,474,175,475,178,477,178";
	document.getElementById("Mauritania").coords="232,147,231,146,229,146,228,149,226,150,224,150,222,152,220,153,219,156,221,158,220,161,219,164,222,164,224,163,227,164,230,163,232,162,234,159,233,158,233,156,234,154,230,154,228,154,229,151,230,150,232,148,233,146,232,146,231,146";
	document.getElementById("Mauritius").coords="321,211,323,211,324,212,324,215,323,215,321,213,321,212";
	document.getElementById("Micronesia").coords="432,169,437,169,441,171,445,171,449,170,454,170,456,171,456,175,456,177,455,177,453,176,452,175,451,174,449,173,447,175,446,176,444,176,442,176,439,176,440,176,439,175,438,175,436,174,435,174,434,174,432,172,432,170";
	document.getElementById("Moldova").coords="284,116,286,116,287,115,286,114,285,113,284,113,283,112,282,112,282,113,281,114,281,115,281,117,283,117";
	document.getElementById("Monaco").coords="252,121,254,119,253,118,251,119,251,118,251,120";
	document.getElementById("Mongolia").coords="364,111,368,115,371,119,381,121,390,123,398,120,405,116,408,114,404,113,403,112,403,109,396,110,391,110,389,108,381,109,376,110,372,108,369,108,366,110";
	document.getElementById("Morocco").coords="225,144,228,145,230,145,231,142,235,141,238,140,240,138,240,134,240,133,235,133,232,135,230,137,229,138,229,141,229,143,227,144,226,144";
	// Mexico City
	document.getElementById("Aguascalientes - Aguascalientes").coords="100,154,102,154,102,153,101,152,99,152";
	document.getElementById("Baja California - Mexicali").coords="85,146,87,149,89,152,90,152,92,151,89,147,88,145,87,144,87,143,85,139,83,138,80,139,82,144,85,147,87,149";
	document.getElementById("Federal District - Mexico City").coords="106,157,104,157,104,159,106,159";
	document.getElementById("Guerrero - Acapulco").coords="108,162,108,160,107,159,106,159,103,159,102,158,100,159,103,161,106,162";
	document.getElementById("Jalisco - Guadalajara").coords="99,159,101,159,101,158,102,157,103,156,102,155,101,155,98,154,97,155,96,155,96,157";
	document.getElementById("Sinaloa - Mazatlan").coords="92,149,94,151,96,155,99,153,98,151,103,150,106,149,104,147,102,143,100,143,97,143,94,139,90,139,87,140,86,140";
	document.getElementById("Veracruz - Veracruz").coords="114,163,107,162,107,159,105,156,101,153,95,151,91,147,87,142,86,140,90,139,96,141,101,143,105,145,108,148,108,156,113,160,116,155,121,154,124,154,122,160,125,162,121,163,114,164,108,163,105,162,100,158,97,156,96,154,102,154,102,158,105,159,108,161";
	// Countries
	document.getElementById("Mozambique").coords="298,200,297,200,295,201,295,203,293,203,291,204,291,207,292,208,290,209,289,210,288,210,288,214,287,216,287,219,287,220,289,220,291,220,292,217,291,213,292,211,295,210,298,211,299,207,299,204,299,200";
	document.getElementById("Myanmar (Burma)").coords="377,161,375,163,374,163,373,159,372,157,370,156,372,152,374,149,376,146,377,146,378,145,380,146,380,151,380,155,381,156,378,158,378,160";
	document.getElementById("Namibia").coords="265,224,267,225,269,226,270,225,269,221,270,217,270,214,271,210,272,208,268,208,263,209,260,208,259,208,260,212,262,216,264,221,264,225,265,226,265,225";
	document.getElementById("Nauru").coords="476,185,475,184,473,185,473,187,477,186,477,185";
	document.getElementById("Nepal").coords="354,140,353,142,354,145,359,145,363,146,364,144,361,143,360,141,356,141";
	document.getElementById("Netherlands").coords="248,105,249,107,251,107,252,105,251,102,249,102";
	// New Zealand Cities
	document.getElementById("Auckland").coords="474,254,473,253,473,251,477,249,481,246,481,244,485,245,485,247,481,251,479,255,475,256";
	document.getElementById("Chatham Island").coords="495,251,498,251,499,250,498,248,494,248";
	document.getElementById("Wellington").coords="483,242,485,246,487,243,490,242,490,239,485,237,483,234,481,233";
	// Countries
	document.getElementById("Nicaragua").coords="126,164,126,165,123,164,122,164,121,166,122,167,124,169,127,167,127,164";
	document.getElementById("Niger").coords="249,164,252,164,257,165,261,165,264,160,264,157,262,154,260,152,259,151,254,154,251,157,248,158,248,163";
	document.getElementById("Nigeria").coords="251,178,252,178,253,176,254,174,258,175,259,175,259,173,255,171,251,169,251,168,251,165,249,164,246,166,246,170,246,174,249,177,252,179";
	document.getElementById("Norway").coords="252,93,254,93,255,92,257,91,259,91,259,89,259,85,259,81,261,80,263,78,265,74,269,71,272,70,272,68,276,69,279,67,282,67,284,67,285,65,280,64,275,64,270,67,265,69,261,74,257,81,253,83,250,85,249,89,250,91,251,93,254,93";
	document.getElementById("Oman").coords="316,161,318,161,322,158,325,155,326,153,323,151,320,149,317,149,316,150,313,150,315,152,318,153,319,154,319,156,317,157,314,157,315,160";
	document.getElementById("Panama").coords="127,172,128,175,131,174,133,173,135,175,136,172,135,171,133,171,130,172,127,171";
	document.getElementById("Peru").coords="145,211,146,207,147,201,145,199,140,197,144,190,144,188,143,186,138,186,133,190,133,191,130,190,130,194,134,196,136,203,140,208,145,210";
	document.getElementById("Pakistan").coords="335,150,338,150,341,150,339,146,341,144,344,142,346,138,344,136,345,133,350,134,348,131,345,129,342,131,341,134,340,136,337,139,334,142,332,142,328,141,328,143,329,146,327,148,328,149,332,149,335,149";
	document.getElementById("Papua New Guinea").coords="439,198,442,195,446,197,448,199,452,200,452,198,448,196,451,194,454,192,457,192,454,189,452,188,450,188,452,190,452,192,447,192,446,190,443,190,439,188,438,187,438,198";
	document.getElementById("Palau").coords="429,173,425,174,423,175,425,181,427,183,427,177,430,175";
	document.getElementById("Poland").coords="263,104,265,107,267,109,272,111,277,109,275,105,276,101,271,101,271,98,267,99,262,101,262,102";
	// Poland Cities
	document.getElementById("Azores").coords="231,123,230,124,230,126,231,127,232,126,233,124,231,122";
	document.getElementById("Lisbon").coords="232,131,233,129,232,127,229,126,230,129,230,131";
	// Countries
	document.getElementById("Qatar").coords="314,148,312,148,313,151,316,150,317,148";
	document.getElementById("Romania").coords="271,116,272,119,273,119,273,121,279,119,282,121,282,119,283,117,280,117,275,116,272,116";
	// Russian Cities
	document.getElementById("Anadyr").coords="503,79,503,81,501,81,498,79,495,77,493,76,493,78,493,79,488,80,491,81,492,83,492,85,486,85,481,89,477,90,474,89,471,90,470,88,470,83,468,84,468,81,469,79,464,77,462,75,461,71,465,72,468,71,468,68,474,67,480,70,480,67,487,67,494,70,501,73,506,75,507,78,503,77,503,80";
	document.getElementById("Chelyabinsk").coords="366,108,368,108,371,107,375,108,377,110,379,108,379,105,380,103,379,102,376,101,376,100,375,98,368,102,366,105";
	document.getElementById("Kamchatka").coords="460,107,465,103,469,96,471,89,470,84,464,90,460,94,458,97,458,105";
	document.getElementById("Russia-Kazan").coords="297,119,295,118,295,116,296,114,298,112,297,109,292,107,291,105,296,106,299,106,302,105,301,101,308,100,314,100,309,101,310,102,316,100,314,104,310,107,308,108,307,112,310,115,308,117,309,122,309,123,306,119,299,118,296,118,295,118";
	document.getElementById("Krasnoyarsk").coords="379,93,377,96,376,99,374,98,370,100,366,103,365,106,361,102,360,97,354,96,351,95,348,95,347,92,348,90,350,88,356,88,361,87,361,84,362,79,359,75,357,73,357,70,354,69,352,67,355,66,354,64,352,61,352,58,356,62,354,57,360,58,363,55,367,52,375,52,382,49,384,47,387,45,391,47,392,49,397,49,401,50,399,54,398,56,392,58,396,59,397,62,398,64,394,67,396,67,391,67,390,73,390,79,391,82,394,82,389,86,387,89,388,90,386,92,385,91,384,92,381,93,378,94";
	document.getElementById("Magadan").coords="467,87,464,86,462,85,459,88,458,89,458,91,455,92,452,91,449,91,447,91,447,88,443,86,444,84,438,82,437,76,436,72,440,67,440,62,444,59,453,62,460,66,463,64,469,68,468,71,462,71,461,73,463,78,467,79,468,83,467,86";
	document.getElementById("Moscow").coords="287,101,288,104,290,106,299,107,301,106,301,100,306,100,311,100,314,100,316,100,315,97,312,97,309,96,307,96,307,93,305,91,289,94,283,95,282,97,286,100";
	document.getElementById("Murmansk").coords="295,81,287,83,284,80,284,76,284,73,281,70,283,67,291,68,298,70,300,76,297,76,293,76,289,74,287,74,291,77,291,80,294,81";
	document.getElementById("Novgorod").coords="291,81,296,88,298,92,304,91,308,92,307,87,309,86,311,90,316,88,324,86,324,83,326,79,331,75,335,73,333,69,327,67,324,67,321,64,321,60,324,55,332,52,338,50,337,47,330,48,322,52,316,58,315,63,317,65,321,65,323,66,326,68,325,71,316,70,309,73,311,67,309,69,303,69,302,73,305,76,302,75,299,75,297,77,298,80,295,78,291,77";
	document.getElementById("Novosibirsk").coords="350,102,355,106,360,108,362,110,366,110,368,108,364,104,361,99,359,96,352,96,347,99,348,101";
	document.getElementById("Omsk").coords="339,98,341,101,344,102,348,102,347,99,352,96,345,93,341,92,339,93,339,96";
	document.getElementById("Perm").coords="327,107,321,108,315,106,314,105,316,98,317,95,316,90,315,88,320,87,324,86,328,86,335,92,340,95,339,98,336,100,330,100,327,100,326,103";
	document.getElementById("Saint-Petersburg").coords="280,96,281,90,284,87,287,82,292,82,296,88,298,92,293,93,285,94,282,95";
	document.getElementById("Samara").coords="309,102,310,100,315,99,316,100,315,105,310,106,309,104";
	document.getElementById("Ufa").coords="317,108,313,106,311,107,307,110,310,113,317,114,316,116,312,119,317,122,320,122,320,116,325,117,329,113,331,113,329,109,327,107,321,107,315,107,315,106";
	document.getElementById("Vladivostok").coords="446,91,441,91,437,94,432,99,434,101,437,101,441,102,444,111,443,115,441,116,438,114,438,107,439,105,437,112,433,118,430,121,427,121,424,120,424,117,429,114,425,113,424,110,425,106,427,102,424,102,423,100,424,96,425,91,425,87,427,86,425,82,423,77,419,76,418,73,417,69,426,68,427,67,425,64,425,61,431,64,437,60,436,58,436,56,431,53,431,52,434,50,438,51,443,50,444,52,442,54,437,54,437,56,442,57,443,60,440,63,438,65,440,68,437,71,436,72,437,83,443,84,446,85";   
	document.getElementById("Yakutsk").coords="423,112,419,108,415,104,412,104,408,109,398,110,392,110,392,107,396,104,403,100,403,96,406,91,401,87,398,91,394,90,392,81,391,78,390,70,391,64,397,64,396,58,397,55,406,57,411,59,416,56,423,60,426,65,427,68,421,69,418,72,425,78,426,83,427,86,425,93,425,98,424,99,425,103,429,102,428,105,425,109,423,110";
	document.getElementById("Yekaterinburg").coords="326,85,325,80,332,75,335,71,334,69,337,70,339,68,336,66,337,62,340,58,344,61,344,66,343,72,340,75,342,76,348,73,348,69,345,68,345,63,346,61,351,61,352,60,353,62,355,65,353,65,352,69,357,71,357,75,362,79,361,87,354,88,349,88,346,91,342,92,339,93,338,95,330,88,331,88,325,84";
	// Countries
	document.getElementById("Rwanda").coords="284,184,282,184,282,187,283,186,285,186,285,185";
	document.getElementById("St. Kitts and Nevis").coords="158,160,154,160,156,163,157,162";
	document.getElementById("Saint Lucia").coords="159,164,157,163,155,165,159,165";
	document.getElementById("St. Vincent & the Grenadines").coords="160,163,158,161,157,160,160,161,159,162";
	document.getElementById("Samoa").coords="506,201,502,201,502,204,507,204";
	document.getElementById("San Marino").coords="259,117,259,119,261,120,261,118";
	document.getElementById("Sao Tome and Principe").coords="250,185,252,184,250,181";
	document.getElementById("Saudi Arabia").coords="301,160,306,161,310,160,316,157,319,155,318,152,310,148,309,145,310,143,306,143,303,141,299,138,297,138,295,141,293,144,292,144,295,150,297,156,302,160";
	document.getElementById("Senegal").coords="219,163,222,163,226,163,223,161,221,159,219,161";
	document.getElementById("Serbia and Montenegro").coords="271,120,273,120,277,118,276,117,275,116,272,116,269,116,270,119,270,121";
	document.getElementById("Seychelles").coords="307,196,306,196,306,198,309,198,309,197";
	document.getElementById("Sierra Leone").coords="224,174,228,174,228,171,227,170,224,170";
	document.getElementById("Singapore").coords="387,183,387,182,386,181,385,183";
	document.getElementById("Slovakia").coords="264,114,261,114,261,111,264,110,265,112";
	document.getElementById("Slovenia").coords="262,116,264,114,262,113,260,114,262,115";
	document.getElementById("Solomon Islands").coords="461,194,458,193,458,195,460,198,462,196";
	document.getElementById("Somalia").coords="302,184,300,187,299,187,299,182,297,179,303,177,307,173,306,172,303,170,310,169,314,167,314,172,311,177,311,180,308,181,304,183,301,187,300,188,299,187";
	document.getElementById("South Africa").coords="281,225,284,226,285,228,287,226,287,225,285,223,284,221,287,221,288,220,286,218,286,216,283,215,281,215,280,218,277,220,274,221,271,222,269,221,270,224,269,225,267,224,265,225,267,230,268,234,271,234,278,235,281,233,284,230,286,228,284,227,281,228,280,228,279,226,281,224";
	document.getElementById("Spain").coords="233,131,232,128,232,126,233,124,232,122,230,123,230,119,237,119,242,120,248,122,248,124,246,125,244,125,243,128,242,131,239,132,236,133,233,131,232,131";
	document.getElementById("Sri Lanka").coords="355,176,356,175,355,172,354,170,353,170,352,172,352,176,354,177";
	document.getElementById("Sudan").coords="278,175,282,178,286,179,290,179,292,178,290,176,289,174,288,173,289,169,292,166,293,161,295,159,295,157,293,152,292,151,290,153,289,154,286,152,282,152,278,152,277,154,277,156,276,157,275,161,274,164,273,168,275,170,279,175,281,177";
	document.getElementById("Suriname").coords="169,176,170,180,166,182,163,178,166,176";
	document.getElementById("Swaziland").coords="287,221,286,220,284,221,286,223,289,224,288,222";
	document.getElementById("Sweden").coords="258,91,259,95,260,98,263,98,266,96,265,92,268,91,269,90,267,88,267,85,270,83,272,80,273,79,276,77,275,73,273,71,271,70,267,72,264,76,263,79,261,82,258,82,259,87,258,90,258,93";
	document.getElementById("Switzerland").coords="254,113,252,111,250,111,252,114,251,116";
	document.getElementById("Syria").coords="293,135,296,137,298,135,300,133,300,131,296,131,293,133";
	document.getElementById("Taiwan").coords="410,149,408,151,408,154,410,156,412,153,413,150";
	document.getElementById("Tajikistan").coords="334,131,337,130,341,130,343,131,345,129,346,128,345,127,345,126,339,126,337,126,335,127";
	document.getElementById("Tanzania").coords="297,198,295,201,293,200,294,202,292,203,290,199,287,196,285,194,282,191,285,189,288,188,294,187,297,191,297,196";
	document.getElementById("Togo").coords="242,177,241,175,243,174,244,174,243,176";
	document.getElementById("Thailand").coords="382,167,386,167,388,166,388,162,386,160,384,160,384,164";
	document.getElementById("Trinidad and Tobago").coords="154,170,157,171,158,169,154,168";
	document.getElementById("Tunisia").coords="256,130,254,132,254,137,255,140,258,137,259,134,258,131";
	document.getElementById("Turkey").coords="300,130,302,130,303,130,303,128,303,126,301,125,298,125,293,124,290,123,285,124,281,125,278,127,280,131,282,133,288,131,293,131,292,135,293,132,297,131,300,131";
	document.getElementById("Turkmenistan").coords="318,130,322,129,326,131,325,135,329,134,333,132,334,129,332,127,325,123,323,122,319,123,316,125,316,127,317,129";
	document.getElementById("Tuvalu").coords="495,203,492,204,491,207,494,208,497,205,496,203";
	document.getElementById("Uganda").coords="286,187,287,185,290,184,290,182,290,179,288,178,285,180,285,182,284,184";
	document.getElementById("Ukraine").coords="287,115,288,117,291,118,294,117,291,116,293,114,296,113,297,111,297,109,293,108,290,106,288,104,287,103,284,106,281,105,278,104,275,105,276,107,275,109,275,112,279,112,281,113,282,111,285,113";
	document.getElementById("United Arab Emirates").coords="305,171,310,171,313,168,307,169,305,169";
	// U.K Cities   
	document.getElementById("England - London").coords="241,101,239,101,238,101,239,105,242,106,244,106,246,105,246,103,243,102,242,101";
	document.getElementById("Gibraltar - Gibraltar").coords="234,105,234,103,235,103,235,105";
	document.getElementById("Northern Ireland - Belfast").coords="233,93,236,97,237,100,234,104,234,107,230,107,226,105,224,102,228,100,233,100,233,97";
	document.getElementById("Scotland - Glasgow").coords="242,101,239,101,236,100,234,100,233,98,233,94,231,94,232,92,236,92,239,90,241,87,242,88,240,91,239,94,241,95,242,97,242,99,245,102";
	document.getElementById("Wales - Cardiff").coords="235,109,238,109,241,108,245,108,246,107,245,105,243,106,239,106,238,104,238,102,235,103,235,107";
	// U.S Cities
	document.getElementById("Alabama - Montgomery").coords="122,141,122,140,121,139,121,138,121,136,122,135,124,135,125,135,127,135,127,136,126,137,126,139,126,140,126,141,125,142,124,142,124,141";
	document.getElementById("Alaska - Anchorage").coords="47,68,47,90,42,90,35,91,30,97,20,100,10,104,10,102,24,94,25,93,18,93,18,90,16,91,11,90,11,89,14,88,13,88,13,85,14,83,18,82,20,82,19,81,18,80,16,81,14,81,12,80,11,79,9,78,10,77,13,76,14,75,16,75,16,76,18,76,18,75,16,75,15,74,14,73,13,72,11,72,11,70,13,70,14,69,17,68,17,66,19,65,22,64,25,64,28,63,29,64,33,64,33,65,36,65,41,66,43,66,47,67";
	document.getElementById("Arizona - Phoenix").coords="92,139,92,136,92,131,86,130,85,131,84,133,84,135,84,138,85,138,87,139,90,139,89,139";
	document.getElementById("Arkansas - Little Rock").coords="116,135,116,129,111,130,111,134,115,135";
	document.getElementById("California - Los Angeles").coords="71,122,80,123,85,124,85,130,84,135,82,138,80,138,77,136,74,132,71,127,71,126";
	document.getElementById("Colorado - Denver").coords="104,127,97,127,98,133,104,133";
	document.getElementById("Connecticut - Hartford").coords="147,119,147,118,146,116,150,115,151,118";
	document.getElementById("Delaware - Dover").coords="137,127,137,131,139,129,139,125,137,125";
	document.getElementById("District of Columbia - Washington DC").coords="137,131,134,129,133,130,135,133";
	document.getElementById("Florida - Miami").coords="125,141,127,143,130,143,129,139,125,140";
	document.getElementById("Florida - Orlando").coords="128,143,128,145,130,149,131,150,131,149,132,149,131,144,131,142,129,142";
	document.getElementById("Georgia - Atlanta").coords="126,135,130,135,132,136,131,141,130,142,129,141,129,139,126,140";
	document.getElementById("Hawaii - Honolulu").coords="30,152,27,151,25,152,26,154,24,153,22,152,21,153,21,155,21,156,15,156,15,161,22,160,24,160,24,157,25,157,25,156,27,156,27,159,28,159,29,161,32,161,32,159,29,159,29,155,30,153";
	document.getElementById("Idaho - Boise").coords="85,110,84,114,83,119,83,120,87,121,89,123,92,122,94,118,90,116,86,115";
	document.getElementById("Illinois - Chicago").coords="121,126,120,119,116,119,116,123,116,125,117,125,118,125";
	document.getElementById("Indiana - Indianapolis").coords="121,123,123,122,127,125,124,128,120,127";
	document.getElementById("Iowa - Des Moines").coords="113,120,114,121,116,120,116,118,115,116,111,117";
	document.getElementById("Kansas - Topeka").coords="107,120,103,120,103,123,107,125,112,125,110,120";
	document.getElementById("Kentucky - Louisville").coords="123,128,121,130,127,132,131,130,128,125";
	document.getElementById("Louisiana - New Orleans").coords="119,142,117,138,113,139,110,140,111,142";
	document.getElementById("Maine - Augusta").coords="151,116,149,115,147,112,151,109,154,112,155,115";
	document.getElementById("Mariana Islands - Guam").coords="442,164,443,167,444,169,448,169,448,166,446,165,445,161,446,157,445,154,442,154,441,156,443,158,443,161,443,163";
	document.getElementById("Maryland - Baltimore").coords="146,124,145,125,144,124,144,123";
	document.getElementById("Massachusetts - Boston").coords="145,120,144,120,144,119,146,119";
	document.getElementById("Michigan - Detroit").coords="125,123,127,122,128,122,128,120,127,121,126,119,127,118,126,117,125,116,125,118,123,118,123,120,123,121,123,122";
	document.getElementById("Minnesota - Minneapolis").coords="116,113,115,112,111,110,109,113,110,116,113,116,115,116,115,114,116,114,115,114";
	document.getElementById("Mississippi - Jackson").coords="122,140,121,136,117,133,115,134,116,137,118,140,119,141,122,141";
	document.getElementById("Missouri - St. Louis").coords="113,129,116,129,117,126,117,125,116,124,115,121,114,120,112,122,112,124,110,126,110,129,110,130,112,130,113,129,114,129";
	document.getElementById("Montana - Billings").coords="105,117,95,119,87,116,83,113,80,110,89,109,99,110,105,115,107,118,106,118,106,117";
	document.getElementById("Nebraska - Lincoln").coords="103,117,105,117,110,116,111,118,111,122,109,120,103,120,103,119,103,118";
	document.getElementById("Nevada - Las Vegas").coords="100,130,91,130,84,129,81,123,79,120,82,117,91,124,95,118,104,118,104,126,97,128";
	document.getElementById("New Hampshire - Concord").coords="147,113,148,114,149,115,147,116,145,116,146,115,146,114,146,113,147,113,147,115";
	document.getElementById("New Jersey - Newark").coords="144,120,143,121,144,122,144,123";
	document.getElementById("New Mexico - Albuquerque").coords="91,130,97,130,100,138,96,141,94,139,91,139,92,138";
	document.getElementById("New York - New York").coords="138,119,138,118,143,117,143,122,141,122,137,122,137,120";
	document.getElementById("North Carolina - Raleigh").coords="134,135,137,134,138,133,138,131,137,131,135,132,134,132,131,132,129,133,131,134";
	document.getElementById("North Dakota - Bismarck").coords="95,110,95,115,100,115,102,115,101,111,101,110";
	document.getElementById("Ohio - Columbus").coords="128,123,127,121,125,123,127,126,131,127,134,125,133,123,130,124,129,123,129,122";
	document.getElementById("Oklahoma - Oklahoma City").coords="111,134,107,134,104,132,104,128,104,125,105,124,108,125,110,124,109,127,110,130";
	document.getElementById("Oregon - Salem").coords="71,116,79,117,83,118,83,120,87,122,89,122,86,123,80,123,71,122,70,122";
	document.getElementById("Pennsylvania - Philadelphia").coords="133,125,131,127,130,128,132,130,135,127,137,125,140,125,144,123,143,122,137,122,136,121,133,121,133,123,134,124";
	document.getElementById("Rhode Island - Providence").coords="150,118,144,124,133,120,137,117,144,115,148,115";
	document.getElementById("South Carolina - Columbia").coords="132,137,132,135,129,135,126,135,123,135,125,131,127,132,129,130,130,130,130,131,129,133,134,135,132,137,130,136,130,135";
	document.getElementById("South Dakota - Sioux Falls").coords="95,115,95,118,102,118,102,114";
	document.getElementById("Tennessee - Nashville").coords="122,135,120,133,120,131,121,130,126,132,123,135";
	document.getElementById("Texas - Dallas").coords="106,148,103,145,102,142,97,143,96,141,100,138,98,132,104,133,106,133,113,135,116,137,116,138,110,140,111,142,110,144,108,146,108,147";
	document.getElementById("Utah - Salt Lake City").coords="94,124,97,127,103,126,104,124,103,122,103,118,97,118,94,118,92,122,90,123,89,123";
	document.getElementById("Vermont - Montpelier").coords="139,118,136,118,138,116,139,114,142,116";
	document.getElementById("Virginia - Richmond").coords="138,133,136,128,131,123,136,119,144,117,146,122,143,125";
	document.getElementById("Washington - Seattle").coords="71,115,82,117,84,116,84,110,74,110,69,111";
	document.getElementById("Wisconsin - Madison").coords="124,117,120,120,114,116,105,116,100,111,99,109,112,109,123,115,126,112,139,114,139,118,130,121,124,117,121,120,115,116,116,113,120,113";
	document.getElementById("Wyoming - Cheyenne").coords="88,122,90,116,94,118,91,124";
	// Countries
	document.getElementById("Uruguay").coords="166,235,162,234,162,229,164,227,169,230,169,233,166,236";
	document.getElementById("Uzbekistan").coords="320,122,325,122,333,128,334,129,338,130,337,124,333,120,328,119,325,117,320,116";
	document.getElementById("Venezuela").coords="150,182,153,182,153,179,158,178,158,173,156,172,150,169,146,168,142,168,141,171,143,175,148,176,148,181";
	document.getElementById("Vietnam").coords="389,172,387,170,387,169,393,164,391,161,390,160,393,160,398,163,395,168,391,170,388,172";
	document.getElementById("Western Sahara").coords="220,152,225,150,230,146,228,142,222,147,219,150";
	document.getElementById("Yemen").coords="302,161,305,161,310,160,314,158,316,162,313,164,309,166,304,167,302,168,301,166,301,161";
	document.getElementById("Zambia").coords="280,210,276,209,273,208,272,205,273,201,278,201,282,201,282,196,285,195,289,198,290,201,288,204,283,207,279,210";
	document.getElementById("Zimbabwe").coords="286,216,280,215,278,211,281,209,284,205,289,207,289,213";
}

localDateTime();
function localDateTime()
{  
	std = new Date();
	if(TZCDisplayStatus)
		setTimeout("localDateTime()", 1000);
}	


// Country Object 
function Country(country,obj,standardName,capital) {
	this.country = country;
	this.offset = obj;
	this.standardName=standardName;
	this.capital = capital;	
}


// City Object 
function City(city, offset,standardName,capital) {
	this.city = city;
	this.offset = offset;
	this.standardName=standardName;
	this.capital = capital;		  
}

function GetStandardName(city){
	for(x=0;x<countries.length;x++) {
		if(isArray(countries[x].offset)) {
			for(y=0;y<countries[x].offset.length;y++) {
				if(countries[x].offset[y].city==city) {					
					return countries[x].offset[y].standardName;
				}
			}
		}
		else {
			if(countries[x].country == city) {
	  			return countries[x].standardName;
			}
		}
	}
}


// Load all the countries form the array list to the 
// respective combo box
function loadCountry()  {
         
         
       
		countries = new Array (                             	
new Country("Afghanistan","+4.50", "Afghanistan Standard Time", "Kabul"), 	
new Country("Albania","+1", "Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"), 	
new Country("Algeria","+1", "",""), 	
new Country("Andorra","+1", "Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"), 	
new Country("Angola","+1", "",""), 	
new Country("Antigua and Barbuda","-4", "",""), 	
new Country("Argentina","-3", "SA Eastern Standard Time","Buenos Aires, Georgetown"), 	
new Country("Armenia","+4", "Caucasus Standard Time","Baku, Tbilisi, Yerevan"), 	
new Country("Australia", new Array( 	
	new City("Australian Capital Territory - Canberra", "+10","AUS Eastern Standard Time",""), 
	new City("New South Wales - Sydney","+10","AUS Eastern Standard Time",""), 
	new City("Northern Territory - Darwin","+9.50","AUS Central Standard Time","Darwin"), 
	new City("Queensland - Brisbane", "+10","E. Australia Standard Time","Brisbane"), 
	new City("South Australia - Adelaide", "+10.50","Cen. Australia Standard Time","Adelaide"), 
	new City("Tasmania - Hobart", "+10","Tasmania Standard Time","Hobart"), 
	new City("Victoria - Melbourne", "+10","AUS Eastern Standard Time","Canberra, Melbourne, Sydney"), 
	new City("Western Australia - Perth", "+8","W. Australia Standard Time","Perth"))), 
new Country("Austria","+1","W. Europe Standard Time","Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"), 	
new Country("Azerbaijan","+4","Azerbaijan Standard Time","Baku"),	
new Country("Bahamas","-5","NoOption",""), 	
new Country("Bahrain","+3","NoOption",""), 	
new Country("Bangladesh","+6","Central Asia Standard Time","Astana, Dhaka"), 	
new Country("Barbados","-4","",""), 	
new Country("Belarus","+2","E. Europe Standard Time","Minsk"), 	
new Country("Belize","-6","",""), 	
new Country("Belgium","+1","Romance Standard Time","Brussels, Copenhagen, Madrid, Paris"), 	
new Country("Benin","+1","",""), 	
new Country("Bermuda", "-4","NoOption",""), 	
new Country("Bhutan","+6","",""), 	
new Country("Bolivia","-4","",""), 	
new Country("Botswana","+2","",""), 	
new Country("Bosnia and Herzegovina","+1","Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"), 	
new Country("Brazil", new Array( 	
	new City("Amazonas - Manaus", "-4","Central Brazilian Standard Time","Manaus"), 
	new City("Bahia - Salvador", "-3","",""), 
	new City("Distrito Federal - Brasilia", "-2","E. South America Standard Time","Brasilia"), 
	new City("Pernambuco - Recife", "-3","",""), 
	new City("Rio de Janeiro - Rio de Janeiro", "-2","NoOption",""), 
	new City("Sao Paulo - Sao Paulo","-2","NoOption",""))), 
new Country("Brunei", "+8","",""), 	
new Country("Bulgaria", "+2","FLE Standard Time","Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"), 	
new Country("Burkina Faso","0","",""), 	
new Country("Burundi", "+2","",""),	
new Country("Cambodia", "+7","",""),	
new Country("Cameroon", "+1","",""), 	
new Country("Canada", new Array( 	
	new City("Alberta - Calgary","-7","Mountain Standard Time","Mountain Time (US & Canada)"),  
	new City("Alberta - Edmonton","-7","Mountain Standard Time","Mountain Time (US & Canada)"), 
	new City("British Columbia - Vancouver","-8","Pacific Standard Time","Pacific Time (US & Canada); Tijuana"), 
	new City("Manitoba - Winnipeg","-6","Central Standard Time","Central Time (US and Canada)"), 
	new City("Newfoundland and Labrador - St. John's","-3.50","Newfoundland Standard Time","Newfoundland and Labrador"), 
	new City("Northwest Territories - Yellowknife","-7","Mountain Standard Time","Mountain Time (US & Canada)"), 
	new City("Nova Scotia - Halifax","-4","Atlantic Standard Time","Atlantic Time (Canada)"), 
	new City("Ontario - Ottawa","-5","Eastern Standard Time","Eastern Time (US and Canada)"), 
	new City("Ontario - Toronto","-5","Eastern Standard Time","Eastern Time (US and Canada)"), 
	new City("Quebec - Montreal","-5","Eastern Standard Time","Eastern Time (US and Canada)"), 
	new City("Quebec - Quebec","-5","Eastern Standard Time","Eastern Time (US and Canada)"), 
	new City("Saskatchewan - Regina","-6","Central Standard Time","Central Time (US and Canada)"), 
	new City("Yukon Territory - Whitehorse","-8","Pacific Standard Time","Pacific Time (US & Canada); Tijuana"))), 
new Country("Cape Verde","+1","",""), 	
new Country("Central African Republic", "+1","",""), 	
new Country("Chad", "+1","",""), 	
new Country("Chile", "-4","Pacific SA Standard Time","Santiago"), 	
new Country("China", "+8","China Standard Time","Beijing, Chongqing, Hong Kong SAR, Urumqi"),
new Country("Colombia", "-5","SA Pacific Standard Time","Bogota, Lima, Quito"), 
new Country("Comoros", "+3","",""), 
new Country("Congo", "+1","",""), 
new Country("Costa Rica", "-6","",""), 
new Country("Cote d'Ivoire", "0","",""), 
new Country("Croatia", "+1","Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"), 
new Country("Cuba", "-5","NoOption",""), 
new Country("Cyprus", "+2","NoOption",""), 
new Country("Czech Republic","+1","Central Europe Standard Time","Belgrade, Bratislava, Budapest, Ljubljana, Prague"),
new Country("Denmark", "+1","Romance Standard Time","Brussels, Copenhagen, Madrid, Paris"), 
new Country("Djibouti", "+3","",""), 
new Country("Dominica", "-4","",""), 
new Country("Dominican Republic","-4","",""),
new Country("East Timor", "+9","",""), 
new Country("Ecuador", "-5","SA Pacific Standard Time","Bogota, Lima, Quito"), 
new Country("Egypt", "+2","Egypt Standard Time","Cairo"), 
new Country("El Salvador","-6","",""), 
new Country("Equatorial Guinea", "+1","",""), 
new Country("Eritrea", "+3","",""), 
new Country("Estonia", "+2","FLE Standard Time","Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"), 
new Country("Ethiopia","+3","",""),
new Country("Fijii", "+12","",""), 
new Country("Finland", "+2","FLE Standard Time","Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"), 
new Country("France", "+1","Romance Standard Time","Brussels, Copenhagen, Madrid, Paris"), 
new Country("French Guiana", "-3","",""),
new Country("Gabon", "+1","",""), 
new Country("The Gambia", "0","",""), 
new Country("Germany", "+1","W. Europe Standard Time","Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"), 
new Country("Georgia", "+4","Caucasus Standard Time","Baku, Tbilisi, Yerevan"), 
new Country("Ghana", "0","",""), 
new Country("Greece", "+2","GTB Standard Time","Athens, Bucharest, Istanbul"),
new Country("Greenland", new Array( 		 
	new City("Danmarkshavn", "0","NoOption",""), 	
	new City("Greenland - Nuuk", "-3","NoOption",""),	
	new City("Scoresbysund", "-1","NoOption",""), 	
	new City("Thule", "-4","NoOption",""))),  	
new Country("Grenada", "-4","",""), 		
new Country("Guatemala", "-6","",""), 		
new Country("Guinea", "0","",""), 		
new Country("Guyana", "-4","SA Eastern Standard Time","Buenos Aires, Georgetown"),		
new Country("Haiti", "-5","",""), 		
new Country("Holy See (Vatican City)", "+1","NoOption",""), 		
new Country("Honduras", "-6","",""), 		
new Country("Hong Kong", "+8","China Standard Time","Beijing, Chongqing, Hong Kong SAR, Urumqi"), 		
new Country("Hungary", "+1","Central Europe Standard Time","Belgrade, Bratislava, Budapest, Ljubljana, Prague"),		
new Country("Iceland", "0","",""), 		
new Country("India", "+5.5","India Standard Time","Chennai, Kolkata, Mumbai, New Delhi"), 		
new Country("Indonesia", new Array( 	
	new City("Bali - Denpasar", "+8","",""), 
	new City("Java - Bandung", "+7","SE Asia Standard Time","Bangkok, Hanoi, Jakarta"), 
	new City("Java - Jakarta", "+7","SE Asia Standard Time","Bangkok, Hanoi, Jakarta"), 
	new City("Java - Surabaya", "+7","SE Asia Standard Time","Bangkok, Hanoi, Jakarta"), 
	new City("Kalimantan - Balikpapan", "+8","",""), 
	new City("Papua - Jayapura", "+9","",""), 
	new City("Sulawesi - Manado", "+8","",""))), 
new Country("Iran", "+3.50","Iran Standard Time","Tehran"), 	
new Country("Iraq", "+3","Arabic Standard Time","Baghdad"), 	
new Country("Ireland", "0","GMT Standard Time","Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London"), 	
new Country("Israel", "+2","Israel Standard Time","Jerusalem"), 	
new Country("Italy", "+1","W. Europe Standard Time","Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"),	
new Country("Jamaica", "-5","",""), 	
new Country("Japan", "+9","Tokyo Standard Time","Osaka, Sapporo, Tokyo"), 	
new Country("Jordan", "+2","NoOption",""),	
new Country("Kazakhstan", "+6","N. Central Asia Standard Time","Almaty, Novosibirsk"), 
new Country("Kenya", "+3","E. Africa Standard Time","Nairobi"), 
new Country("Korea, North", "+9","Korea Standard Time","Seoul"), 
new Country("Korea, South", "+9","Korea Standard Time","Seoul"), 
new Country("Kuwait", "+3","Arab Standard Time","Kuwait, Riyadh"), 
new Country("Kyrgyzstan", "+6","",""),
new Country("Laos", "+7","",""), 
new Country("Latvia", "+2","FLE Standard Time","Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"), 
new Country("Lebanon", "+2","NoOption",""), 
new Country("Lesotho", "+2","",""), 
new Country("Liberia", "0","Greenwich Standard Time","Casablanca, Monrovia"), 
new Country("Libya", "+2","",""), 
new Country("Lithuania", "+2","FLE Standard Time","Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"), 
new Country("Luxembourg", "+1","Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"),
new Country("Macao", "+8","",""), 
new Country("Macedonia", "+1","Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"), 
new Country("Malawi", "+2","",""), 	
new Country("Malaysia", "+8","Singapore Standard Time","Kuala Lumpur, Singapore"), 	
new Country("Maldives", "+5","",""), 	
new Country("Mali", "0","",""), 	
new Country("Malta", "+1","NoOption",""), 	
new Country("Marshall Islands", "+12","",""), 	
new Country("Mauritania", "0","",""), 	
new Country("Mauritius", "+4","",""), 	
new Country("Micronesia", "+11","",""), 	
new Country("Moldova", "+2","NoOption",""), 	
new Country("Monaco", "+1","NoOption",""), 	
new Country("Mongolia", "+8","North Asia East Standard Time","Irkutsk, Ulaanbaatar"), 	
new Country("Morocco", "0","Greenwich Standard Time","Casablanca, Monrovia"), 	
new Country("Mexico", new Array( 	
	new City("Aguascalientes - Aguascalientes", "-6","Central Standard Time (Mexico)","Guadalajara, Mexico City, Monterrey"), 
	new City("Baja California - Mexicali", "-8","Pacific Standard Time","Pacific Time (US and Canada); Tijuana") ,
	new City("Federal District - Mexico City", "-6","Central Standard Time (Mexico)","Guadalajara, Mexico City, Monterrey"), 
	new City("Guerrero - Acapulco", "-6","Central Standard Time (Mexico)","Guadalajara, Mexico City, Monterrey"), 
	new City("Jalisco - Guadalajara", "-6","Central Standard Time (Mexico)","Guadalajara, Mexico City, Monterrey"), 
	new City("Sinaloa - Mazatlan", "-7","Mountain Standard Time (Mexico)","Chihuahua, La Paz, Mazatlan"), 
	new City("Veracruz - Veracruz", "-6","Central Standard Time (Mexico)","Guadalajara, Mexico City, Monterrey"))),  
new Country("Mozambique", "+2","",""), 	
new Country("Myanmar (Burma)", "+6.50","Myanmar Standard Time","Yangon (Rangoon)"),	
new Country("Namibia", "+2","Namibia Standard Time","Windhoek"), 	
new Country("Nauru", "+12","",""), 	
new Country("Nepal", "+5.75","Nepal Standard Time","Kathmandu"), 	
new Country("Netherlands", "+1","W. Europe Standard Time","Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"), 	
new Country("New Zealand", new Array( 	
	new City("Auckland", "+13","New Zealand Standard Time","Auckland, Wellington"), 
	new City("Chatham Island", "+13.75","New Zealand Standard Time","Auckland, Wellington"), 
	new City("Wellington", "+13","New Zealand Standard Time","Auckland, Wellington"))), 
new Country("Nicaragua", "-6","",""), 	
new Country("Niger", "+1","",""), 	
new Country("Nigeria", "+1","",""), 	
new Country("Norway", "+1","NoOption",""),	
new Country("Oman", "+4","Arabian Standard Time","Abu Dhabi, Muscat"),	
new Country("Panama", "-5","",""), 	
new Country("Peru", "-5","SA Pacific Standard Time","Bogota, Lima, Quito"), 	
new Country("Pakistan", "+5","West Asia Standard Time","Islamabad, Karachi, Tashkent"), 	
new Country("Papua New Guinea", "+10","West Pacific Standard Time","Guam, Port Moresby"), 	
new Country("Palau", "+9","",""), 	
new Country("Poland", "+1","Central European Standard Time","Sarajevo, Skopje, Warsaw, Zagreb"), 	
new Country("Portugal", new Array( 	
	new City("Azores", "-1","Azores Standard Time","Azores"), 
	new City("Lisbon", "0","GMT Standard Time","Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London"))), 
new Country("Qatar", "+3","",""),	
new Country("Romania", "+2","GTB Standard Time","Athens, Bucharest, Istanbul"), 	
new Country("Russia", new Array( 	
	new City("Anadyr", "+12","Fiji Standard Time","Fiji Islands, Kamchatka, Marshall Islands"), 		
	new City("Chelyabinsk", "+5","N. Central Asia Standard Time","Almaty, Novosibirsk"), 		
	new City("Kamchatka", "+12","Fiji Standard Time","Fiji Islands, Kamchatka, Marshall Islands"), 		
	new City("Russia-Kazan", "+3","Russian Standard Time","Moscow, St. Petersburg, Volgograd"), 		
	new City("Krasnoyarsk", "+7","N. Central Asia Standard Time","Almaty, Novosibirsk"), 		
	new City("Magadan", "+11","Central Pacific Standard Time","Magadan, Solomon Islands, New Caledonia"),		
	new City("Moscow", "+3","Russian Standard Time","Moscow, St. Petersburg, Volgograd"), 		
	new City("Murmansk", "+3","Russian Standard Time","Moscow, St. Petersburg, Volgograd"), 		
	new City("Novgorod", "+3","Russian Standard Time","Moscow, St. Petersburg, Volgograd"), 		
	new City("Novosibirsk", "+6","N. Central Asia Standard Time","Almaty, Novosibirsk"), 		
	new City("Omsk", "+6","N. Central Asia Standard Time","Almaty, Novosibirsk"), 		
	new City("Perm", "+5","N. Central Asia Standard Time","Almaty, Novosibirsk"), 		
	new City("Saint-Petersburg", "+3","Russian Standard Time","Moscow, St. Petersburg, Volgograd"), 		
	new City("Samara", "+4","Russian Standard Time","Moscow, St. Petersburg, Volgograd"), 		  
	new City("Ufa", "+5","N. Central Asia Standard Time","Almaty, Novosibirsk"), 		
	new City("Vladivostok", "+10","Vladivostok Standard Time","Vladivostok"),		
	new City("Yakutsk", "+9","Yakutsk Standard Time","Yakutsk"), 
	new City("Yekaterinburg", "+5","N. Central Asia Standard Time","Almaty, Novosibirsk"))), 
new Country("Rwanda", "+2","",""),	
new Country("St. Kitts and Nevis", "-4","",""), 	
new Country("Saint Lucia", "-4","",""), 	
new Country("St. Vincent & the Grenadines", "-4","",""), 	
new Country("Samoa", "-11","","Apia"), 	
new Country("San Marino", "+1","NoOption",""), 	
new Country("Sao Tome and Principe", "0","",""), 	
new Country("Saudi Arabia", "+3","Arab Standard Time","Riyadh"), 	
new Country("Senegal", "0","",""), 	
new Country("Serbia and Montenegro", "+1","Central Europe Standard Time","Belgrade"), 	
new Country("Seychelles", "+4","","Victoria"), 	
new Country("Sierra Leone", "0","","Freetown"), 	
new Country("Singapore", "+8","Singapore Standard Time","Singapore"), 	
new Country("Slovakia", "+1","Central Europe Standard Time","Bratislava"), 	
new Country("Slovenia", "+1","Central Europe Standard Time","Ljubljana"), 
new Country("Solomon Islands", "+11","","Honiara"), 
new Country("Somalia", "+3","","Mogadishu"), 
new Country("South Africa", "+2","","Johannesburg"), 
new Country("Spain", "+1","Romance Standard Time","Madrid"), 
new Country("Sri Lanka", "+5.50","","Colombo"), 
new Country("Sudan", "+3","","Khartoum"), 
new Country("Suriname", "-3","","Paramaribo"), 
new Country("Swaziland", "+2","","Mbabane"), 
new Country("Sweden", "+1","W. Europe Standard Time","Stockholm"), 
new Country("Switzerland", "+1","NoOption","Geneva"), 
new Country("Syria", "+2","NoOption","Damascus"),
new Country("Taiwan", "+8","Taipei Standard Time","Taipei"), 
new Country("Tajikistan", "+5","","Dushanbe"), 
new Country("Tanzania", "+3","",""), 
new Country("Togo", "0","","Lome"), 
new Country("Thailand", "+7","SE Asia Standard Time","Bangkok"), 		
new Country("Trinidad and Tobago", "-4","",""), 		
new Country("Tunisia", "+1","NoOption","Tunis"), 		
new Country("Turkey", "+2","GTB Standard Time","Istanbul"), 		
new Country("Turkmenistan", "+5","","Ashgabat"), 		
new Country("Tuvalu", "+12","","Funafuti"),		
new Country("Uganda", "+3","","Kampala"), 		
new Country("Ukraine", "+2","NoOption","Kyiv"), 		
new Country("United Arab Emirates", "+4","Arabian Standard Time","Abu Dhabi"), 		
new Country("U.K.", new Array( 		   
	new City("England - London", "0","GMT Standard Time","London"), 	
	new City("Gibraltar - Gibraltar", "+1","GMT Standard Time","Dublin, Edinburgh, Lisbon, London"), 	
	new City("Northern Ireland - Belfast", "0","GMT Standard Time","Dublin, Edinburgh, Lisbon, London"), 	
	new City("Scotland - Glasgow", "0","GMT Standard Time","Dublin, Edinburgh, Lisbon, London"), 	
	new City("Wales - Cardiff", "0","GMT Standard Time","Dublin, Edinburgh, Lisbon, London"))), 	
new Country("U.S.A.", new Array( 		
	new City("Alabama - Montgomery", "-6","Central America Standard Time",""), 
	new City("Alaska - Anchorage", "-9","Alaskan Standard Time","Alaska"), 
	new City("Arizona - Phoenix", "-7","US Mountain Standard Time","Arizona"), 
	new City("Arkansas - Little Rock", "-6","Central America Standard Time",""), 
	new City("California - Los Angeles", "-8","Pacific Standard Time",""), 
	new City("Colorado - Denver", "-7","US Mountain Standard Time",""), 
	new City("Connecticut - Hartford", "-5","US Eastern Standard Time",""), 
	new City("Delaware - Dover", "-5","US Eastern Standard Time",""), 
	new City("District of Columbia - Washington DC", "-5","US Eastern Standard Time",""), 
	new City("Florida - Miami", "-5","US Eastern Standard Time",""), 
	new City("Florida - Orlando", "-5","US Eastern Standard Time",""), 
	new City("Georgia - Atlanta", "-5","US Eastern Standard Time",""), 
	new City("Hawaii - Honolulu", "-10","Hawaiian Standard Time","Hawaii"), 
	new City("Idaho - Boise", "-7","US Mountain Standard Time",""), 
	new City("Illinois - Chicago", "-6","Central America Standard Time",""), 
	new City("Indiana - Indianapolis", "-5","US Eastern Standard Time","Indiana (East)"), 
	new City("Iowa - Des Moines", "-6","Central America Standard Time",""), 
	new City("Kansas - Topeka", "-6","Central America Standard Time",""), 
	new City("Kentucky - Louisville", "-5","US Eastern Standard Time",""), 
	new City("Louisiana - New Orleans", "-6","Central America Standard Time",""), 
	new City("Maine - Augusta", "-5","US Eastern Standard Time",""), 
	new City("Mariana Islands - Guam", "+10","",""), 
	new City("Maryland - Baltimore", "-5","US Eastern Standard Time",""), 
	new City("Massachusetts - Boston", "-5","US Eastern Standard Time",""), 
	new City("Michigan - Detroit", "-5","US Eastern Standard Time",""), 
	new City("Minnesota - Minneapolis", "-6","Central America Standard Time",""), 
	new City("Mississippi - Jackson", "-6","Central America Standard Time",""), 
	new City("Missouri - St. Louis", "-6","Central America Standard Time",""), 
	new City("Montana - Billings", "-7","US Mountain Standard Time",""), 
	new City("Nebraska - Lincoln", "-6","Central America Standard Time",""), 
	new City("Nevada - Las Vegas", "-8","Pacific Standard Time",""), 
	new City("New Hampshire - Concord", "-5","US Eastern Standard Time",""), 
	new City("New Jersey - Newark", "-5","US Eastern Standard Time",""), 
	new City("New Mexico - Albuquerque", "-7","Central Standard Time (Mexico)","Mexico City"), 
	new City("New York - New York", "-5","US Eastern Standard Time",""), 
	new City("North Carolina - Raleigh", "-5","US Eastern Standard Time",""), 
	new City("North Dakota - Bismarck", "-6","Central America Standard Time",""), 
	new City("Ohio - Columbus", "-5","US Eastern Standard Time",""), 
	new City("Oklahoma - Oklahoma City", "-6","Central America Standard Time",""), 
	new City("Oregon - Salem", "-8","Pacific Standard Time",""), 
	new City("Pennsylvania - Philadelphia", "-5","US Eastern Standard Time",""), 
	new City("Rhode Island - Providence", "-5","US Eastern Standard Time",""), 
	new City("South Carolina - Columbia", "-5","US Eastern Standard Time",""), 
	new City("South Dakota - Sioux Falls", "-6","Central America Standard Time",""), 
	new City("Tennessee - Nashville", "-6","Central America Standard Time",""), 
	new City("Texas - Dallas", "-6","Central America Standard Time",""), 
	new City("Utah - Salt Lake City", "-7","US Mountain Standard Time",""), 
	new City("Vermont - Montpelier", "-5","US Eastern Standard Time",""), 
	new City("Virginia - Richmond", "-5","US Eastern Standard Time",""), 
	new City("Washington - Seattle", "-8","Pacific Standard Time",""), 
	new City("Wisconsin - Madison", "-6","Central America Standard Time",""), 
	new City("Wyoming - Cheyenne", "-7","US Mountain Standard Time",""))),  
new Country("Uruguay", "-2","NoOption",""), 	
new Country("Uzbekistan", "+5","West Asia Standard Time","Tashkent"),	
new Country("Venezuela", "-4.50","SA Western Standard Time","Caracas"), 	
new Country("Vietnam", "+7","SE Asia Standard Time","Hanoi"),	
new Country("Western Sahara", "0","",""),	
new Country("Yemen", "+3","",""),	
new Country("Zambia", "+2","","Lusaka"), 	
new Country("Zimbabwe", "+2","South Africa Standard Time","Harare")
);	

		
	var optn;
	for(var i=0; i < countries.length; i++)	{		 
		cntoptn = document.createElement("OPTION");	 // For Current Combo Box
		spcoptn = document.createElement("OPTION");	 // For Specific Combo Box
		cntoptn.text = countries[i].country;
		spcoptn.text = countries[i].country;
		if(isArray(countries[i].offset)) {
			cntoptn.value = "A";
			spcoptn.value = "A";
		}
		else {
			cntoptn.value = countries[i].offset;
			spcoptn.value = countries[i].offset;
		}
		document.getElementById("currentCountriesList").options.add(cntoptn);
		document.getElementById("specificCountriesList").options.add(spcoptn);
	}
	cntPkdTime("CurrentTime");	
}

// Function to display the Current Time on the TZC
function cntPkdTime(val)
{
	var localD = new Date();
	if(val=="CurrentTime") {
		pickedTimeStatus = "CT";
		document.getElementById("dateStatusTZC").innerHTML = "Current Time :";
		utc = std.getTime() - (TZ * 60000);	     
		localND = new Date(utc + (3600000*(localD.getTimezoneOffset()/60)));	  	
		if(document.getElementById("TZCmainTable").style.visibility != 'hidden') {
			toggleLayer("TZCSpanDate", 'true');
		}
		document.getElementById("TZCSpanDate").innerHTML = localND.toDateString() + " " + getTwoChars(localND.getHours()) + ":" + getTwoChars(localND.getMinutes()) + ":" + getTwoChars(localND.getSeconds());
		if(statusTimer==0) {
			clearTimeout(statusTimer);
			changeCurrentTime();
			changeSpecificTime();
		}
		statusTimer = setTimeout("cntPkdTime('CurrentTime');changeCurrentTime();changeSpecificTime();",1000);		    	  	  	  
		toggleLayer("ResetCurrent", 'false');
	}
	else {
		clearTimeout(statusTimer);
		statusTimer=0;
		document.getElementById("dateStatusTZC").innerHTML = "Preset Time";
		toggleLayer("TZCSpanDate", 'false');	  	  
		toggleLayer("ResetCurrent", 'true');	  

		pickedTimeStatus = "PT";	  	  
		changeCurrentTime();
		changeSpecificTime();
	}
}


// Clears the City combo box
function clearCity(cmbbox) {
	var cityCombo = document.getElementById(cmbbox + "CityList");	  
	for (i=cityCombo.options.length-1;i>=0;i--) {		
		cityCombo.remove(i);
	}		
}


// Load the current city combobox if city is available for that country 
function loadCurrentCity() {
	clearCity('current');
	var optn;
	var countryName = document.getElementById("currentCountriesList").options[document.getElementById("currentCountriesList").selectedIndex].text;
	var value = document.getElementById("currentCountriesList").options[document.getElementById("currentCountriesList").selectedIndex].value;
	var selIndex = document.getElementById("currentCountriesList").selectedIndex-1;
	if(value!="XXX") { 
		if(isArray(countries[selIndex].offset))	{
			GlobalCurrentCountry = countryName; 
			toggleLayer("currentCityDiv", 'true');			
			for(var x=0; x<countries[selIndex].offset.length ; x++) {						   		
				optn = document.createElement("OPTION");		 
				optn.text = countries[selIndex].offset[x].city;
				optn.value = countries[selIndex].offset[x].offset;
				document.getElementById("currentCityList").options.add(optn);
			}
			document.getElementById("hdnCurrentCity").value = countries[selIndex].offset[0].city;
			document.getElementById("hdnCurrentTimeSpan").value = countries[selIndex].offset[0].offset;
			changeCurrentTime();	 
			changeSpecificTime(); 
		}
		else {
			GlobalCurrentCountry = "C";		 
			calcTime('currentCountriesList');
			toggleLayer("currentCityDiv", 'false');
		}
	}
	else {
		GlobalCurrentCountry = "C";	  
		calcTime('currentCountriesList');
		toggleLayer("currentCityDiv", 'false');
	}	  
}


// Load the specific city combo box if city is available for that country
function loadSpecificCity() {
	clearCity('specific');
	var optn;
	var countryName = document.getElementById("specificCountriesList").options[document.getElementById("specificCountriesList").selectedIndex].text;
	var value = document.getElementById("specificCountriesList").options[document.getElementById("specificCountriesList").selectedIndex].value;
	var selIndex = document.getElementById("specificCountriesList").selectedIndex-1;
	var cntOffset = document.getElementById("hdnCurrentTimeSpan").value;
	if(value!="XXX" && cntOffset!="XXX") {
		//toggleLayer("displayTxtBox", (cntOffset!="")?'true':'false');
		if(isArray(countries[selIndex].offset))	{
			GlobalSpecificCountry = countryName;
			toggleLayer("specificCityDiv", 'true');	   
			for(var x=0; x<countries[selIndex].offset.length ; x++)	{			   		
				optn = document.createElement("OPTION");		 
				optn.text = countries[selIndex].offset[x].city;
				optn.value = countries[selIndex].offset[x].offset;
				document.getElementById("specificCityList").options.add(optn);
			}
			document.getElementById("hdnSpecificCity").value = countries[selIndex].offset[0].city;
			document.getElementById("hdnSpecificTimeSpan").value = countries[selIndex].offset[0].offset;			
			changeSpecificTime();	  
		}
		else {  	
			GlobalSpecificCountry="C";
			calcTime('specificCountriesList');
			toggleLayer("specificCityDiv", 'false');
		}	   
	}
	else {
		GlobalSpecificCountry="C";
		toggleLayer("specificCityDiv", 'false');
		calcTime('specificCountriesList');
	}	
}


  
// Function to change current time based on the values from the hidden variable
function changeCurrentTime() {
	var city = document.getElementById("hdnCurrentCity").value;
	var offset;
	var temp=GetStandardName(city);
	if(temp!='NoOption')
	{
	 if(CheckDayLight(GetStandardName(city)))
	   offset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":parseInt(document.getElementById("hdnCurrentTimeSpan").value)+1;
	 else
	   offset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":document.getElementById("hdnCurrentTimeSpan").value;
	}
	else if(temp=="")
	{
	 offset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":document.getElementById("hdnCurrentTimeSpan").value;
	}
	else
	{
	 offset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":parseInt(document.getElementById("hdnCurrentTimeSpan").value)+1;
	}

	var mySpanCity = document.getElementById("spnDisplayCurrentCity");	  
	var mySpanTime = document.getElementById("spnDisplayCurrentTime");	


	var spanTime = document.getElementById("TZCSpanDate").innerHTML;
	tp = new Date(spanTime);

	if(offset=="XXX") {
		if(pickedTimeStatus=="CT") {
			mySpanCity.innerHTML="";
			mySpanTime.innerHTML="";    
		}
		else {
			mySpanCity.innerHTML=formatDateTime(tp);
			mySpanTime.innerHTML=getTwoChars(tp.getHours()) + ":" + getTwoChars(tp.getMinutes());
		}
	}
	else {
		// If current time is selected then
		if (pickedTimeStatus=="CT") {
			utc = tp.getTime() + (TZ * 60000);	   
			nd = new Date(utc + (3600000*offset));	   
			mySpanCity.innerHTML=formatDateTime(nd);
			mySpanTime.innerHTML=getTwoChars(nd.getHours()) + ":" + getTwoChars(nd.getMinutes()) + ":" + getTwoChars(nd.getSeconds());
		}
		else {
			mySpanCity.innerHTML=formatDateTime(tp);
			mySpanTime.innerHTML=getTwoChars(tp.getHours()) + ":" + getTwoChars(tp.getMinutes());
		}
	}
	//setTimeout("changeCurrentTime()", 1000);
}


// Function to change specific time based on the values from the hidden variable
function changeSpecificTime() {

	var currentCity = document.getElementById("hdnCurrentCity").value;
	
	var currentOffset;// = (document.getElementById("hdnCurrentTimeSpan").value=="")?"XXX":document.getElementById("hdnCurrentTimeSpan").value;
	var temp=GetStandardName(currentCity);
	if(temp!='NoOption')
	{
	 if(CheckDayLight(GetStandardName(currentCity)))
	   currentOffset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":parseInt(document.getElementById("hdnCurrentTimeSpan").value)+1;
	 else
	   currentOffset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":document.getElementById("hdnCurrentTimeSpan").value;
	}
	else if(temp=="")
	{
	 currentOffset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":document.getElementById("hdnCurrentTimeSpan").value;
	}
	else
	{
	 currentOffset = (document.getElementById("hdnCurrentTimeSpan").value)==""?"XXX":parseInt(document.getElementById("hdnCurrentTimeSpan").value)+1;
	}
	
	// This code is for specific city and offset
	var specificCity = document.getElementById("hdnSpecificCity").value;
	var specificOffset; //= (document.getElementById("hdnSpecificTimeSpan").value=="")?"XXX":document.getElementById("hdnSpecificTimeSpan").value;
	var speTemp=GetStandardName(currentCity);
	if(speTemp!='NoOption')
	{
	 if(CheckDayLight(GetStandardName(specificCity)))
	   specificOffset = (document.getElementById("hdnSpecificTimeSpan").value)==""?"XXX":parseInt(document.getElementById("hdnSpecificTimeSpan").value)+1;
	 else
	   specificOffset = (document.getElementById("hdnSpecificTimeSpan").value)==""?"XXX":document.getElementById("hdnSpecificTimeSpan").value;
	}
	else if(speTemp=="")
	{
	 specificOffset = (document.getElementById("hdnSpecificTimeSpan").value)==""?"XXX":document.getElementById("hdnSpecificTimeSpan").value;
	}
	else
	{
	 specificOffset = (document.getElementById("hdnSpecificTimeSpan").value)==""?"XXX":parseInt(document.getElementById("hdnSpecificTimeSpan").value)+1;
	}
	
	var mySpanTimeTo = document.getElementById("spnSpecificTimeTo");

	if(currentOffset!="XXX" && specificOffset!="XXX") {	   
		myDate = (pickedTimeStatus=="CT") ? new Date(document.getElementById("spnDisplayCurrentCity").innerHTML + " " + document.getElementById("spnDisplayCurrentTime").innerHTML) : new Date(document.getElementById("TZCSpanDate").innerHTML) ;	   	 
		myUTC = myDate.getTime() - (currentOffset * 3600000);		 
		newDate = new Date(myUTC + (3600000*specificOffset));
		var secds = (pickedTimeStatus=="CT") ? ":" + getTwoChars(newDate.getSeconds()) : "";
		mySpanTimeTo.innerHTML = formatDateTime(newDate) + "<br/><strong style='font-size:24px;'>" + getTwoChars(newDate.getHours()) + ":" + getTwoChars(newDate.getMinutes()) + secds + "</strong>";
	}
	else {
		mySpanTimeTo.innerHTML = "";	
	}
	//setTimeout("changeSpecificTime()", 1000);	
}


// Function will assign the values of the country and to the respective hidden variable 
function calcTime(strName) {
	if(strName == "currentCountriesList"){
		document.getElementById("hdnCurrentCity").value = document.getElementById("currentCountriesList").options[document.getElementById("currentCountriesList").selectedIndex].text;
		document.getElementById("hdnCurrentTimeSpan").value =  document.getElementById("currentCountriesList").options[document.getElementById("currentCountriesList").selectedIndex].value;	   	   
		changeCurrentTime();	   
	}
	else if (strName == "currentCityList") {
		document.getElementById("hdnCurrentCity").value = document.getElementById("currentCityList").options[document.getElementById("currentCityList").selectedIndex].text;
		document.getElementById("hdnCurrentTimeSpan").value =  document.getElementById("currentCityList").options[document.getElementById("currentCityList").selectedIndex].value;
		changeCurrentTime();
	}
	else if (strName == "specificCountriesList") {
		document.getElementById("hdnSpecificCity").value = document.getElementById("specificCountriesList").options[document.getElementById("specificCountriesList").selectedIndex].text;
		document.getElementById("hdnSpecificTimeSpan").value =  document.getElementById("specificCountriesList").options[document.getElementById("specificCountriesList").selectedIndex].value;	   
	}
	else if (strName == "specificCityList") {
		document.getElementById("hdnSpecificCity").value = document.getElementById("specificCityList").options[document.getElementById("specificCityList").selectedIndex].text;
		document.getElementById("hdnSpecificTimeSpan").value =  document.getElementById("specificCityList").options[document.getElementById("specificCityList").selectedIndex].value;
	}	
	changeSpecificTime();
} 


// Object used to hide and display elements on the webpage
function toggleLayer(whichLayer, show) {  
	if(show=="false")
		document.getElementById(whichLayer).style.visibility="hidden";
	else if(show == "true")
		document.getElementById(whichLayer).style.visibility="visible";
}


// Function which wil return the formated date and time
function formatDateTime(val) {
	inDate = new Date(val);
	var weekDaysList = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
	var monthFullList = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; 
	var formatedDate = inDate.toDateString();
	formatedDate = weekDaysList[inDate.getDay()] + " " + monthFullList[inDate.getMonth()] + " " + inDate.getDate() + " " + inDate.getFullYear();
	return formatedDate;
}


// Function to get the Hours and minutes with two characters
function getTwoChars(val) {
	if(val.toString().length==1) {
		val = "0" + val;
		return val;
	}
	else return val;
}


// Function to check the parameter obj is an array or not 	  
function isArray(obj) {
	return (obj.constructor.toString().indexOf("Array") != -1);
}


// Function to return the Month in numbers
function getMonthNum(mName) {
	for(var i=0; i<monthList.length; i++) {
		if(mName==monthList[i].toUpperCase()) {
			return (i+1);
			break;
		}
	}
}


// Function to return the Name of the Month
function getMonthName(mNum) {
	for(var i=0; i<monthList.length; i++) {
		if(mNum==i) {
			return (monthList[i].toUpperCase());
			break;
		}
	}
}

 
/**************************************************************************/
/* Below are the functions related to the Map and the Time zone Converter */
/**************************************************************************/

// Object to check which mouse button is clicked 
function checkClick(status,id) {	
	if(status.indexOf("|") > -1) {
		status = status.replace("|", " ");
	}
	var div = document.getElementById(id);
	div.onmousedown = function (e) {
			var rightclick;
			if (!e) {
				var e = window.event;
			}
			if (e.which) {
				rightclick = (e.which == 3);			
			}
			else if (e.button) { 
				rightclick = (e.button == 2);			
			}
			if (rightclick) {
				GlobalSpecificCountry=status;
				assignValues(status,id,"R");	
			}
			else {
				GlobalCurrentCountry=status;
				assignValues(status,id,"L");
			}  
			return false;
		};	
}


// Object used to load the respective values in to the combobox
function assignValues(status,id,click) {
	status = status.replace("&nbsp;", " ");
	if(click=='L') {       // Current hidden variables
		crntbox = document.getElementById("currentCountriesList");
		crntcitybox = document.getElementById("currentCityList");
		for(x=0;x<crntbox.options.length;x++) {
			if (status=="C") {  // If the input is country
				if(crntbox.options[x].text==id) {
					crntbox.options[x].selected = 'selected';
					loadCurrentCity();
					break;				   
				}			   
			}  
			else {			  // If the input is City
				if (crntbox.options[x].text==status) {
					crntbox.options[x].selected = 'selected';				  
					clearCity('current');
					var optn;
					var countryName = document.getElementById("currentCountriesList").options[document.getElementById("currentCountriesList").selectedIndex].text;
					var value = document.getElementById("currentCountriesList").options[document.getElementById("currentCountriesList").selectedIndex].value;
					var selIndex = document.getElementById("currentCountriesList").selectedIndex-1;
					if(isArray(countries[selIndex].offset))	{
						toggleLayer("currentCityDiv", 'true');			
						for(var x=0; x<countries[selIndex].offset.length ; x++) {			   		
							optn = document.createElement("OPTION");		 
							optn.text = countries[selIndex].offset[x].city;
							optn.value = countries[selIndex].offset[x].offset;
							document.getElementById("currentCityList").options.add(optn);
						}
						for(y=0;y<crntcitybox.options.length;y++) {
							if(crntcitybox.options[y].text==id)	{
								crntcitybox.options[y].selected = 'selected';
								document.getElementById("hdnCurrentCity").value = countries[selIndex].offset[y].city;
								document.getElementById("hdnCurrentTimeSpan").value = countries[selIndex].offset[y].offset;					 
								changeCurrentTime();
								changeSpecificTime();
								break;
							}
						}
					}
					break;				  
				}		
			}
		}
    }
	else {              // Specific hidden variables
		spfcbox = document.getElementById("specificCountriesList");
		spfccitybox = document.getElementById("specificCityList");      
		for(x=0;x<spfcbox.options.length;x++) { 
			if (status=="C") {  // If the input is country
				if(spfcbox.options[x].text==id) {
					spfcbox.options[x].selected = 'selected';
					loadSpecificCity();
					break;
				}
			}
			else {			   // If the input city 
				if (spfcbox.options[x].text==status) {				  
					spfcbox.options[x].selected = 'selected';				  
					clearCity('specific');
					var optn;
					var countryName = document.getElementById("specificCountriesList").options[document.getElementById("specificCountriesList").selectedIndex].text;
					var value = document.getElementById("specificCountriesList").options[document.getElementById("specificCountriesList").selectedIndex].value;
					var selIndex = document.getElementById("specificCountriesList").selectedIndex-1;
					if(isArray(countries[selIndex].offset))	{
						toggleLayer("specificCityDiv", 'true');
						//toggleLayer("displayTxtBox", 'true');			
						for(var x=0; x<countries[selIndex].offset.length ; x++) {			   		
							optn = document.createElement("OPTION");		 
							optn.text = countries[selIndex].offset[x].city;
							optn.value = countries[selIndex].offset[x].offset;
							document.getElementById("specificCityList").options.add(optn);
						}
						for(y=0;y<spfccitybox.options.length;y++) {
							if(spfccitybox.options[y].text==id)	{
								spfccitybox.options[y].selected = 'selected';
								document.getElementById("hdnSpecificCity").value = countries[selIndex].offset[y].city;
								document.getElementById("hdnSpecificTimeSpan").value = countries[selIndex].offset[y].offset;					 
								changeSpecificTime();
								break;
							}
						}
					}
					break;
				}
			}
		} 
	}
}


// Function to display the Name of the Country
// when mouse move over it
function displayId(id) {
	document.getElementById(id).alt=id;
	document.getElementById(id).title=id;   
}


// Function related to dragOBJTZC
function $(v) { 
	return(document.getElementById(v)); 
}

 
// Function related to dragOBJTZC
function TZCagent(v) { 
	return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); 
}

// Function related to dragOBJTZC 
function xy(e,v) { 
	return(v?(TZCagent('msie')?event.clientY+document.body.scrollTop:e.pageY):(TZCagent('msie')?event.clientX+document.body.scrollTop:e.pageX)); 
}


// Function to drag an object
function dragOBJTZC(d,e,ifid) {
	function drag(e) {						
		if(!stop) { 
			d.style.top=(tX=xy(e,1)+oY-eY+'px'); 
			d.style.left=(tY=xy(e)+oX-eX+'px');
			ifid.style.top=(tX=xy(e,1)+oY-eY+'px'); 
			ifid.style.left=(tY=xy(e)+oX-eX+'px');
			TZCTitleMouseOver();
		} 
	}     	
	var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop;	
	document.onmousemove=drag;
	document.onmouseup=function() {  
				stop=1;
				TZCTitleMouseOver();
				document.onmousemove=''; 
				document.onmouseup='';
			}; 			
}

function TZCTitleMouseOver() {
	var titleEle = document.getElementById("trTZCTitle");
	var title2Ele = document.getElementById("trTZCTitle2");
	titleEle.style.background="url(/Images/bgMainMenuActive.gif)  repeat-x";
	title2Ele.style.background="url(/Images/bgMainMenuActive.gif)  repeat-x"; 
	titleEle.style.cursor='move'; 
}

// Shade while cursor present inside this element
function TZCShade(ctl) {
	ctl.style.background="#1A5083";
}

// Remove Shading while Cursor Out.
function TZCRShade(ctl) {
	ctl.style.background="";
}

// This function will minimize the Time Zone Converter Control
function MinimizeTZCControl(divID) {
	if(document.getElementById(divID).style.visibility == 'visible') {
		document.getElementById(divID).style.visibility = 'hidden';
		document.getElementById("TZCmainTable").style.visibility = 'hidden';		
		document.getElementById("TimeZoneDiv").style.height = '23px';		
		document.getElementById("content").style.display = 'none';	
		document.getElementById("TZCIFrame").style.height = '24px';		
		document.getElementById("TZCMinimizeL").innerHTML="<img src='/images/shape_square.png'  title='Maximize' alt='Maximize' style='vertical-align:middle; border:solid 1px white; width:12px; height:12px; cursor:hand; cursor:pointer;' />";
		document.getElementById("TZCMinimizeL").alt="Maximize";
		document.getElementById("TZCMinimizeL").title="Maximize";
		toggleLayer("currentCityDiv", 'false');
		toggleLayer("specificCityDiv", 'false');
		toggleLayer("ResetCurrent", 'false');
		toggleLayer("TZCSpanDate", 'false');		    
	}
	else {
		document.getElementById(divID).style.visibility = 'visible';
		document.getElementById("TimeZoneDiv").style.height = '483px';
		document.getElementById("content").style.display = 'block';	
		document.getElementById("TZCIFrame").style.height = '483px';
		document.getElementById("TZCMinimizeL").innerHTML=" _ ";
		document.getElementById("TZCMinimizeL").title="Minimize";
		document.getElementById("TZCMinimizeL").alt="Minimize";
		toggleLayer("ResetCurrent", pickedTimeStatus=="CT"?'false':'true');
		toggleLayer("TZCSpanDate", pickedTimeStatus=="CT"?'true':'false');	
		assignValues(GlobalCurrentCountry,document.getElementById("hdnCurrentCity").value,"L");
		assignValues(GlobalSpecificCountry,document.getElementById("hdnSpecificCity").value,"R");
	}
}


// This function is to close the Time zone converter control
function CloseTZC() {
	document.getElementById("TimeZoneDiv").style.visibility = 'hidden';
	document.getElementById("TZCmainTable").style.visibility = 'hidden';
	document.getElementById("TZCIFrame").style.visibility = 'hidden';
	toggleLayer("TZCSpanDate", 'false');
	toggleLayer("currentCityDiv", 'false');
	toggleLayer("specificCityDiv", 'false');
	/*document.getElementById("hdnCurrentCity").value="XXX";
	document.getElementById("hdnCurrentTimeSpan").value="";
	document.getElementById("hdnSpecificCity").value="XXX";
	document.getElementById("hdnSpecificTimeSpan").value="";*/
	TZCDisplayStatus=false;
	document.getElementById("TZCSpanDate").innerHTML="";	
	var cookieValue = document.getElementById("hdnCurrentCity").value + "#" + GlobalCurrentCountry + "#" + document.getElementById("hdnSpecificCity").value + "#" + GlobalSpecificCountry;	
	SetCookie("TNO_TimeZone", cookieValue, 123231);
}


// Function to show the Time Zone converter infront
function showTZC() {
	TZCDisplayStatus=true;
	localDateTime();
	if(initiateControl==false)
	{
		loadCountry();
		loadAreaCoords();
		initiateControl=true;
	}
	SetTZCCookie();
	assignValues(GlobalCurrentCountry,document.getElementById("hdnCurrentCity").value,"L");
	assignValues(GlobalSpecificCountry,document.getElementById("hdnSpecificCity").value,"R");
	
	var loginTZCheck=GetCookie("TN_UserId");
	if(loginTZCheck!='') {
		var browsertype=window.navigator.userAgent;
		var pos=getPosition("setperf"); 
		var top=document.body.clientTop?document.body.clientTop:0;
		top=top+parseInt(pos.y)+22;		
		if(browsertype.indexOf("MSIE 7.0")>=0)	{	
			document.getElementById('TimeZoneDiv').style.top=top;
			document.getElementById('TZCIFrame').style.top=top;
		}
		else if(browsertype.indexOf("MSIE 6.0")>=0) {
			 document.getElementById('TimeZoneDiv').style.top=top-71;
			 document.getElementById('TZCIFrame').style.top=top-71;	 
		} 
		else {
			document.getElementById('TimeZoneDiv').style.top=top+"px";
			document.getElementById('TZCIFrame').style.top=top+"px";
		}
	}
	else {
		document.getElementById("TZCIFrame").style.top = '220px';
		document.getElementById("TimeZoneDiv").style.top = '220px';
	}
	document.getElementById("TimeZoneDiv").style.visibility='visible';
	document.getElementById("TimeZoneDiv").style.height = '483px';
	document.getElementById("TZCIFrame").style.height = '483px';
	document.getElementById("TZCmainTable").style.visibility = 'visible';
	document.getElementById("TZCIFrame").style.visibility = 'visible';
	document.getElementById("content").style.display = 'block';
	document.getElementById("TZCMinimizeL").innerHTML=" _ ";
	document.getElementById("TZCMinimizeL").title="Minimize";
	document.getElementById("TZCMinimizeL").alt="Minimize"; 
	document.getElementById("TimeZoneDiv").style.zIndex = '100';
	//document.getElementById("TZCIFrame").style.top = '203px';
	document.getElementById("TZCIFrame").style.left = '575px';
	//document.getElementById("TimeZoneDiv").style.top = '203px';
	document.getElementById("TimeZoneDiv").style.left = '575px';
	d=new Date();
	var str=d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear(); 	
	document.getElementById("TZCCalenderDisp").innerHTML=DateInput("orderDT", true, "DD-MON-YYYY","TZCSpanDate",str,true);
	if(pickedTimeStatus!="CT"){cntPkdTime("CurrentTime");}	
	TZCZindex();
	TZCTitleMouseOver(); 	
}

// function to set the cookie values to global and hidden variables
function SetTZCCookie(){
	var cookie = GetCookie("TNO_TimeZone");
	if(cookie!='') {
		//alert(GetCookie("TNO_TimeZone"));
		var cookieVal = new Array();
		cookieVal = cookie.split('#');
		document.getElementById("hdnCurrentCity").value = cookieVal[0];
		GlobalCurrentCountry = cookieVal[1];
		document.getElementById("hdnSpecificCity").value = cookieVal[2];	
		GlobalSpecificCountry = cookieVal[3];
	}
}


// Function to disable selected iframe Time zone converter
function DisableSelectTZC(id) {	
	document.getElementById(id).onselectstart = function() {return false;} // ie
	document.getElementById(id).onmousedown = function() {return false;} // mozilla
}

function TZCZindex() {	
	var eid=document.getElementById('MailDiv');	
	var id=document.getElementById('TimeZoneDiv');	
	var cid=document.getElementById('CalcMainDiv');	
	if(id)id.style.zIndex="2000";	
	if(eid)eid.style.zIndex="100";
	if(cid)cid.style.zIndex="100";		
}

// Code to Draw the Time zone converter 
function loadTimeZoneConverter() {
	var strBuilder="";

	strBuilder='<input type="hidden" id="hdnCurrentCity" value="" />';
	strBuilder+='<input type="hidden" id="hdnCurrentTimeSpan" value="" />';
	strBuilder+='<input type="hidden" id="hdnSpecificCity" value="" />';
	strBuilder+='<input type="hidden" id="hdnSpecificTimeSpan" value="" />';

	strBuilder+='<iframe id="TZCIFrame" onload=DisableSelectTZC(\'TZCIFrame\'); src="" frameborder="0" scrolling="no" style="width:530px; text-align:center; visibility:hidden; position:absolute;height:483px;top:203px; left:575px; border:solid 1px White;"></iframe>';
	strBuilder+='<div id="TimeZoneDiv" onmousedown=TZCZindex(); style="width:530px; height:483px;  top:203px; left:575px; z-index=0; position:absolute; border:solid 2px #a7c7e7;  background-color:#F5F8FB; visibility:hidden;">';
	strBuilder+='<table cellpadding="0" cellspacing="0" width="520px" style="border:solid 0px #a7c7e7;">';
	strBuilder+='<tr id="trTZCTitle" style="background:url(/Images/bgMainMenuActive.gif)  repeat-x; cursor:move; width:100%; height:23px;" onmouseover=TZCTitleMouseOver(); onmousedown=dragOBJTZC(document.getElementById(\"TimeZoneDiv\"),event,document.getElementById(\"TZCIFrame\")); return false; ondblclick=MinimizeTZCControl(\"TZCmainTable\"); >';
	strBuilder+='<th style="text-align:left;"><b style="color:White; font-size:12px;">&nbsp;&nbsp;Time Zone Converter</b></th>';
	strBuilder+='<th style="text-align:right; color:White;">';
	strBuilder+='<span id="TZCMinimizeL" style="cursor:pointer; font-size:16px; color:White;" title="Minimize" onmouseover=TZCShade(this) onmouseout=TZCRShade(this) onclick=MinimizeTZCControl(\"TZCmainTable\"); onmouseover=TZCShade(this)>&nbsp;_&nbsp;</span>';
	strBuilder+='<span id="CloseL"  style="cursor:pointer; font-size:16px; color:White;" title="Close" onmouseover=TZCShade(this) onmouseout=TZCRShade(this) onclick="CloseTZC();"><b style="color:White; font-size:16px;">&nbsp;X&nbsp;</b></span>';
	strBuilder+='</th>';
	strBuilder+='</tr>';
	strBuilder+='</table><div id=content style="width:530px; z-index=-1; visibility:hidden; position:absolute; background-color:#F5F8FB;height: 440px;">';

	strBuilder+='<table id="TZCmainTable" cellpadding="0" cellspacing="0" width="520px" style="visibility:hidden;">';
	strBuilder+='<tr>';
	strBuilder+='<td style="padding:0px 0px 0px 0px; text-align:center;" colspan="2">';
	strBuilder+='<img src="/Images/TimeZone520x300.png" border="0px" style="border:none 0px 0px;" oncontextmenu="return false;" width="520px" height="300px" usemap="#planet" alt="Left click to set Location 1 and right click to set location 2" title="Left click to set Location 1 and right click to set location 2"/>';
	strBuilder+='<map id="planet" name="planet">';

	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id);checkClick("C",this.id); id="Afghanistan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Albania"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Algeria"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Andorra"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Angola"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Antigua and Barbuda"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Argentina"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Armenia"  href="#_0" />';
	strBuilder+='<!-- Australian Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="Australian Capital Territory - Canberra"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="New South Wales - Sydney"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="Northern Territory - Darwin"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="Queensland - Brisbane"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="South Australia - Adelaide"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="Tasmania - Hobart"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="Victoria - Melbourne"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Australia",this.id); id="Western Australia - Perth"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Austria"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Azerbaijan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bahamas"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bahrain"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bangladesh"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Barbados"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Belarus"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Belize"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Belgium"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Benin"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bermuda"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bhutan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bolivia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Botswana"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bosnia and Herzegovina"  href="#_0" />';
	strBuilder+='<!-- Brazil Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Brazil",this.id); id="Amazonas - Manaus"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Brazil",this.id); id="Bahia - Salvador"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Brazil",this.id); id="Distrito Federal - Brasilia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Brazil",this.id); id="Pernambuco - Recife"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Brazil",this.id); id="Rio de Janeiro - Rio de Janeiro"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Brazil",this.id); id="Sao Paulo - Sao Paulo"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Brunei"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Bulgaria"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Burkina Faso"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Burundi"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Cambodia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Cameroon"  href="#_0" />';
	strBuilder+='<!-- Canada Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Alberta - Calgary"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Alberta - Edmonton"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="British Columbia - Vancouver"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Manitoba - Winnipeg"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Newfoundland and Labrador - St. John' + "'" + 's" href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Northwest Territories - Yellowknife"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Nova Scotia - Halifax"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Ontario - Ottawa"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Ontario - Toronto"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Quebec - Quebec"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Saskatchewan - Regina"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Canada",this.id); id="Yukon Territory - Whitehorse"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Cape Verde"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Central African Republic"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Chad"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Chile"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="China"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Colombia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Comoros"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Congo"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Costa Rica"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Cote d' + "'" + 'Ivoire"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Croatia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Cuba"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Cyprus"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Czech Republic"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Denmark"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Djibouti"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Dominica"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Dominican Republic"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="East Timor"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Ecuador"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Egypt"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="El Salvador"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Equatorial Guinea"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Eritrea"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Estonia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Ethiopia"  href="#_0" />';				  			
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Fijii"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Finland"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="France"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="French Guiana"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Gabon"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="The Gambia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Germany"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Georgia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Ghana"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Greece"  href="#_0" />';
	strBuilder+='<!-- Greenland Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Greenland",this.id); id="Danmarkshavn"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Greenland",this.id); id="Greenland - Nuuk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Greenland",this.id); id="Scoresbysund"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Greenland",this.id); id="Thule"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Grenada"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Guatemala"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Guinea"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Guyana"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Haiti"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Holy See (Vatican City)"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Honduras"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Hong Kong"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Hungary"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Iceland"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="India"  href="#_0" />';
	strBuilder+='<!-- Indonesia Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Bali - Denpasar"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Java - Bandung"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Java - Jakarta"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Java - Surabaya"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Kalimantan - Balikpapan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Papua - Jayapura"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Indonesia",this.id); id="Sulawesi - Manado"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Iran"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Iraq"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Israel"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Italy"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Jamaica"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Japan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Jordan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Kazakhstan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Kenya"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Korea, North"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Korea, South"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Kuwait"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Kyrgyzstan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Laos"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Latvia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Lebanon"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Lesotho"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Liberia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Libya"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Lithuania"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Luxembourg"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Macao"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Macedonia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Malawi"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Malaysia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Maldives"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Mali"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Malta"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Marshall Islands"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Mauritania"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Mauritius"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Micronesia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Moldova"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Monaco"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Mongolia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Morocco"  href="#_0" />';
	strBuilder+='<!-- Mexico City -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Aguascalientes - Aguascalientes"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Baja California - Mexicali"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Federal District - Mexico City"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Guerrero - Acapulco"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Jalisco - Guadalajara"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Sinaloa - Mazatlan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Mexico",this.id); id="Veracruz - Veracruz"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Mozambique"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Myanmar (Burma)"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Namibia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Nauru"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Nepal"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Netherlands"  href="#_0" />';
	strBuilder+='<!-- New Zealand Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("New|Zealand",this.id); id="Auckland"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("New|Zealand",this.id); id="Chatham Island"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("New|Zealand",this.id); id="Wellington"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Nicaragua"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Niger"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Nigeria"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Norway"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Oman"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Panama"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Peru"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Pakistan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Papua New Guinea"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Palau"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Poland"  href="#_0" />';
	strBuilder+='<!-- Portugal Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Portugal",this.id); id="Azores"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Portugal",this.id); id="Lisbon"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Qatar"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Romania"  href="#_0" />';
	strBuilder+='<!-- Russian Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Anadyr"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Chelyabinsk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Kamchatka"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Russia-Kazan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Krasnoyarsk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Magadan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Moscow"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Murmansk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Novgorod"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Novosibirsk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Omsk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Perm"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Saint-Petersburg"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Samara"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Ufa"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Vladivostok"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Yakutsk"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("Russia",this.id); id="Yekaterinburg"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Rwanda"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="St. Kitts and Nevis"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Saint Lucia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="St. Vincent & the Grenadines"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Samoa"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="San Marino"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Sao Tome and Principe"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Saudi Arabia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Senegal"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Serbia and Montenegro"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Seychelles"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Sierra Leone"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Singapore"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Slovakia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Slovenia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Solomon Islands"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Somalia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="South Africa"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Spain"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Sri Lanka"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Sudan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Suriname"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Swaziland"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Sweden"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Switzerland"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Syria"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Taiwan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Tajikistan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Tanzania"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Togo"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Thailand"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Trinidad and Tobago"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Tunisia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Turkey"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Turkmenistan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Tuvalu"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Uganda"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Ukraine"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="United Arab Emirates"  href="#_0" />';
	strBuilder+='<!-- U.K. Cities -->';   
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.K.",this.id); id="England - London"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.K.",this.id); id="Gibraltar - Gibraltar"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.K.",this.id); id="Northern Ireland - Belfast"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.K.",this.id); id="Scotland - Glasgow"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.K.",this.id); id="Wales - Cardiff"  href="#_0" />';
	strBuilder+='<!-- U.S.A. Cities -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Alabama - Montgomery"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Alaska - Anchorage"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Arizona - Phoenix"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Arkansas - Little Rock"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="California - Los Angeles"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Colorado - Denver"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Connecticut - Hartford"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Delaware - Dover"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="District of Columbia - Washington DC"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Florida - Miami"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Florida - Orlando"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Georgia - Atlanta"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Hawaii - Honolulu"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Idaho - Boise"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Illinois - Chicago"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Indiana - Indianapolis"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Iowa - Des Moines"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Kansas - Topeka"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Kentucky - Louisville"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Louisiana - New Orleans"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Maine - Augusta"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Mariana Islands - Guam"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Maryland - Baltimore"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Massachusetts - Boston"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Michigan - Detroit"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Minnesota - Minneapolis"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Mississippi - Jackson"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Missouri - St. Louis"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Montana - Billings"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Nebraska - Lincoln"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Nevada - Las Vegas"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="New Hampshire - Concord"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="New Jersey - Newark"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="New Mexico - Albuquerque"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="New York - New York"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="North Carolina - Raleigh"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="North Dakota - Bismarck"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Ohio - Columbus"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Oklahoma - Oklahoma City"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Oregon - Salem"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Pennsylvania - Philadelphia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Rhode Island - Providence"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="South Carolina - Columbia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="South Dakota - Sioux Falls"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Tennessee - Nashville"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Texas - Dallas"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Utah - Salt Lake City"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Vermont - Montpelier"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Virginia - Richmond"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Washington - Seattle"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Wisconsin - Madison"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("U.S.A.",this.id); id="Wyoming - Cheyenne"  href="#_0" />';
	strBuilder+='<!-- Countries -->';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Uruguay"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Uzbekistan"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Venezuela"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Vietnam"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Western Sahara"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Yemen"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Zambia"  href="#_0" />';
	strBuilder+='<area shape="poly" oncontextmenu="return false;" onmouseover=displayId(this.id);checkClick("C",this.id); id="Zimbabwe"  href="#_0" />';
	strBuilder+='</map>';	
	strBuilder+='</td>';
	strBuilder+='</tr>';

	strBuilder+='<tr id="trTZCTitle2" style=" background:url(/Images/bgMainMenuActive.gif) repeat-x; width:100%; height=20px;">';
	strBuilder+='<th style="text-align:center; color:White; width:50%"><b style="color:White; font-size:12px;">Location 1</b></th>';
	strBuilder+='<th style="text-align:center; color:White; width:50%"><b style="color:White; font-size:12px;">Location 2</b></th>';
	strBuilder+='</tr>';

	strBuilder+='<tr style="width:520px;">';

	strBuilder+='<td style="text-align:center;" valign="top" colspan="2">';
	strBuilder+='<table cellspacing="0" cellpadding="0" border="0" style="width:520px; background-color:#F5F8FB;">';
	strBuilder+='<tr style="height:23px;  padding:2px 0px 0px 0px; background-color:#F5F8FB;">';
	strBuilder+='<td style="width:30px; background-color:#F5F8FB;"></td>';
	strBuilder+='<td style="text-align:left; width:220px; background-color:#F5F8FB;">';
	//strBuilder+='<div style="background-color:#F5F8FB;" id="TZCCalenderDisp"><script type="text/javascript">d=new Date();var str=d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear(); DateInput("orderDT", true, "DD-MON-YYYY","TZCSpanDate",str,true)</script></div>';   
	strBuilder+='<div style="background-color:#F5F8FB;" id="TZCCalenderDisp"></div>';   
	strBuilder+='<span id="TZCSpanDate" style="font-family:Arial, Helvetica, sans-serif; background-color:#F5F8FB; width:160px; position:absolute; left:130px; top:323px;"></span>';
	strBuilder+='<span id="dateStatusTZC" style="font-family:Arial, Helvetica, sans-serif;  background-color:#F5F8FB; position:absolute; left:55px; top:323px;">Current Time :</span>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:20px;"></td>';
	strBuilder+='<td style="width:220px; text-align:right; float:right; padding:2px 0px 0px 0px;">';
	strBuilder+='<div style="background-color:#F5F8FB; position:absolute; left:430px; top:323px; width:70px;"><a id="ResetCurrent" name="ResetCurrent" href=javascript:cntPkdTime("CurrentTime");>Current Time</a></div>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:30px;"></td>';
	strBuilder+='</tr>';

	strBuilder+='<tr style="height:25px;">';
	strBuilder+='<td style="width:30px;"><strong style="font-size:16px;"></strong> </td>';
	strBuilder+='<td style="text-align:center; width:220px;">';
	strBuilder+='<select id="currentCountriesList" name="currentCountriesList" onchange="loadCurrentCity();" style="width:220px;">';
	strBuilder+='<option value="XXX">Select Country</option>';
	strBuilder+='</select>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:20px;"></td>';
	strBuilder+='<td style="text-align:center; width:220px;">';
	strBuilder+='<select id="specificCountriesList" name="specificCountriesList" onchange="loadSpecificCity();" style="width:220px;">';
	strBuilder+='<option value="XXX">Select Country</option>';
	strBuilder+='</select>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:30px;"></td>';
	strBuilder+='</tr>';

	strBuilder+='<tr style="height:21px;">';
	strBuilder+='<td style="width:30px;"></td>';
	strBuilder+='<td id="currentCityDiv" style="height:21px; width:220px; text-align:center; visibility:hidden;">';
	strBuilder+='<select id="currentCityList" name="currentCityList" onchange=calcTime("currentCityList"); style="width:220px;">';
	strBuilder+='<option value="XXX">Select City</option>';
	strBuilder+='</select>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:20px;"></td>';
	strBuilder+='<td id="specificCityDiv" style="height:21px; width:220px; text-align:center; visibility:hidden;">';
	strBuilder+='<select style="width:220px;" id="specificCityList" name="specificCityList" onchange=calcTime("specificCityList");>';
	strBuilder+='<option value="XXX">Select City</option>';
	strBuilder+='</select>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:30px;"></td>';
	strBuilder+='</tr>';
	strBuilder+='<tr style="height:60px;">';
	strBuilder+='<td style="width:30px;"></td>';
	strBuilder+='<td style="width:220px;">';
	strBuilder+='<div>';
	strBuilder+='<span style="padding:5px 0px 0px 0px;" id="spnDisplayCurrentCity"></span>';
	strBuilder+='<br/>';
	strBuilder+='<strong style="font-size:24px;">';					  
	strBuilder+='<span id="spnDisplayCurrentTime"></span>';
	strBuilder+='</strong>';							  
	strBuilder+='</div>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:20px;"></td> ';
	strBuilder+='<td style="text-align:center; width:220px;">';
	strBuilder+='<span id="spnSpecificTimeTo"></span>';

	strBuilder+='<span id="spnSpecificCityFrom"></span>';
	strBuilder+='<span id="spnSpecificTimeFrom"></span>';
	strBuilder+='<span id="spnSpecificCityTo"></span>';
	strBuilder+='</td>';
	strBuilder+='<td style="width:30px;"></td>';
	strBuilder+='</tr>';				 					 
	strBuilder+='</table>';
	strBuilder+='</td>';	   
	strBuilder+='</tr>';
	strBuilder+='</table>';
	strBuilder+='</div></div>';
	
	//strBuilder+='<script type="text/javascript">loadCountry();loadAreaCoords();</script>';

	return strBuilder;
}

/* SpryMenuBar.js - Revision: Spry Preview Release 1.4 */

// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//   * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//   * Neither the name of Adobe Systems Incorporated nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

/*******************************************************************************

 SpryMenuBar.js
 This file handles the JavaScript for Spry Menu Bar.  You should have no need
 to edit this file.  Some highlights of the MenuBar object is that timers are
 used to keep submenus from showing up until the user has hovered over the parent
 menu item for some time, as well as a timer for when they leave a submenu to keep
 showing that submenu until the timer fires.

 *******************************************************************************/

var Spry;
if(!Spry)
{
	Spry = {};
}
if(!Spry.Widget)
{
	Spry.Widget = {};
}

// Constructor for Menu Bar
// element should be an ID of an unordered list (<ul> tag)
// preloadImage1 and preloadImage2 are images for the rollover state of a menu
Spry.Widget.MenuBar = function(element, opts)
{
	this.init(element, opts);
};

Spry.Widget.MenuBar.prototype.init = function(element, opts)
{
	this.element = this.getElement(element);

	// represents the current (sub)menu we are operating on
	this.currMenu = null;

	var isie = (typeof document.all != 'undefined' && typeof window.opera == 'undefined' && navigator.vendor != 'KDE');
	if(typeof document.getElementById == 'undefined' || (navigator.vendor == 'Apple Computer, Inc.' && typeof window.XMLHttpRequest == 'undefined') || (isie && typeof document.uniqueID == 'undefined'))
	{
		// bail on older unsupported browsers
		return;
	}

	// load hover images now
	if(opts)
	{
		for(var k in opts)
		{
			var rollover = new Image;
			rollover.src = opts[k];
		}
	}

	if(this.element)
	{
		this.currMenu = this.element;
		var items = this.element.getElementsByTagName('li');
		for(var i=0; i<items.length; i++)
		{
			this.initialize(items[i], element, isie);
			if(isie)
			{
				this.addClassName(items[i], "MenuBarItemIE");
				items[i].style.position = "static";
			}
		}
		if(isie)
		{
			if(this.hasClassName(this.element, "MenuBarVertical"))
			{
				this.element.style.position = "relative";
			}
			var linkitems = this.element.getElementsByTagName('a');
			for(var i=0; i<linkitems.length; i++)
			{
				linkitems[i].style.position = "relative";
			}
		}
	}
};

Spry.Widget.MenuBar.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};

Spry.Widget.MenuBar.prototype.hasClassName = function(ele, className)
{
	if (!ele || !className || !ele.className || ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)
	{
		return false;
	}
	return true;
};

Spry.Widget.MenuBar.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || this.hasClassName(ele, className))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.MenuBar.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || !this.hasClassName(ele, className))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

// addEventListener for Menu Bar
// attach an event to a tag without creating obtrusive HTML code
Spry.Widget.MenuBar.prototype.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
		{
			element.addEventListener(eventType, handler, capture);
		}
		else if (element.attachEvent)
		{
			element.attachEvent('on' + eventType, handler);
		}
	}
	catch (e) {}
};

// createIframeLayer for Menu Bar
// creates an IFRAME underneath a menu so that it will show above form controls and ActiveX
Spry.Widget.MenuBar.prototype.createIframeLayer = function(menu)
{
	var layer = document.createElement('iframe');
	layer.tabIndex = '-1';
	layer.src = 'javascript:false;';
	menu.parentNode.appendChild(layer);
	
	layer.style.left = menu.offsetLeft + 'px';
	layer.style.top = menu.offsetTop + 'px';
	layer.style.width = menu.offsetWidth + 'px';
	layer.style.height = menu.offsetHeight + 'px';
};

// removeIframeLayer for Menu Bar
// removes an IFRAME underneath a menu to reveal any form controls and ActiveX
Spry.Widget.MenuBar.prototype.removeIframeLayer =  function(menu)
{
	var layers = menu.parentNode.getElementsByTagName('iframe');
	while(layers.length > 0)
	{
		layers[0].parentNode.removeChild(layers[0]);
	}
};

// clearMenus for Menu Bar
// root is the top level unordered list (<ul> tag)
Spry.Widget.MenuBar.prototype.clearMenus = function(root)
{
	var menus = root.getElementsByTagName('ul');
	for(var i=0; i<menus.length; i++)
	{
		this.hideSubmenu(menus[i]);
	}
	this.removeClassName(this.element, "MenuBarActive");
};

// bubbledTextEvent for Menu Bar
// identify bubbled up text events in Safari so we can ignore them
Spry.Widget.MenuBar.prototype.bubbledTextEvent = function()
{
	return (navigator.vendor == 'Apple Computer, Inc.' && (event.target == event.relatedTarget.parentNode || (event.eventPhase == 3 && event.target.parentNode == event.relatedTarget)));
};

// showSubmenu for Menu Bar
// set the proper CSS class on this menu to show it
Spry.Widget.MenuBar.prototype.showSubmenu = function(menu)
{
	if(this.currMenu)
	{
		this.clearMenus(this.currMenu);
		this.currMenu = null;
	}
	
	if(menu)
	{
		this.addClassName(menu, "MenuBarSubmenuVisible");
		if(window.navigator.userAgent.indexOf("MSIE 6.0")>=0)
		{
			if(typeof document.all != 'undefined' && typeof window.opera == 'undefined' && navigator.vendor != 'KDE')
			{
				if(!this.hasClassName(this.element, "MenuBarHorizontal") || menu.parentNode.parentNode != this.element)
				{
					menu.style.top = menu.parentNode.offsetTop + 'px';
				}
			}
			if(typeof document.uniqueID != "undefined")
			{
				this.createIframeLayer(menu);
			}
        }
	}
	this.addClassName(this.element, "MenuBarActive");
};

// hideSubmenu for Menu Bar
// remove the proper CSS class on this menu to hide it
Spry.Widget.MenuBar.prototype.hideSubmenu = function(menu)
{
	if(menu)
	{
		this.removeClassName(menu, "MenuBarSubmenuVisible");
		if(typeof document.all != 'undefined' && typeof window.opera == 'undefined' && navigator.vendor != 'KDE')
		{
			menu.style.top = '';
			menu.style.left = '';
		}
		this.removeIframeLayer(menu);
	}
};

// initialize for Menu Bar
// create event listeners for the Menu Bar widget so we can properly
// show and hide submenus
Spry.Widget.MenuBar.prototype.initialize = function(listitem, element, isie)
{
	var opentime, closetime;
	var link = listitem.getElementsByTagName('a')[0];
	var submenus = listitem.getElementsByTagName('ul');
	var menu = (submenus.length > 0 ? submenus[0] : null);

	var hasSubMenu = false;
	if(menu)
	{
		this.addClassName(link, "MenuBarItemSubmenu");
		hasSubMenu = true;
	}

	if(!isie)
	{
		// define a simple function that comes standard in IE to determine
		// if a node is within another node
		listitem.contains = function(testNode)
		{
			// this refers to the list item
			if(testNode == null)
			{
				return false;
			}
			if(testNode == this)
			{
				return true;
			}
			else
			{
				return this.contains(testNode.parentNode);
			}
		};
	}
	
	// need to save this for scope further down
	var self = this;

	this.addEventListener(listitem, 'mouseover', function(e)
	{
		if(self.bubbledTextEvent())
		{
			// ignore bubbled text events
			return;
		}
		clearTimeout(closetime);
		if(self.currMenu == listitem)
		{
			self.currMenu = null;
		}
		// show menu highlighting
		self.addClassName(link, hasSubMenu ? "MenuBarItemSubmenuHover" : "MenuBarItemHover");
		if(menu && !self.hasClassName(menu, "MenuBarSubmenuVisible"))
		{
			opentime = window.setTimeout(function(){self.showSubmenu(menu);}, 0.01);
		}
	}, false);

	this.addEventListener(listitem, 'mouseout', function(e)
	{
		if(self.bubbledTextEvent())
		{
			// ignore bubbled text events
			return;
		}

		var related = (typeof e.relatedTarget != 'undefined' ? e.relatedTarget : e.toElement);
		if(!listitem.contains(related))
		{
			clearTimeout(opentime);
			self.currMenu = listitem;

			// remove menu highlighting
			self.removeClassName(link, hasSubMenu ? "MenuBarItemSubmenuHover" : "MenuBarItemHover");
			if(menu)
			{
				closetime = window.setTimeout(function(){self.hideSubmenu(menu);}, 80);
			}
		}
	}, false);
};

function AutoSuggest(elem,chkRadio)
{
    this.debug=false;
    
    this.searchType = "";
    this.suggestType="";
    this.suggestDivID = "";
    this.hiddenID="";
    this.enabledRadio=chkRadio;
	this.listClick=null; 
	
	var me = this;

	this.elem = elem;

	this.suggestion = new suggestions();
	
	this.inputText = null; 

	this.highlighted = -1;
	 
	this.requesting=false; 
	this.submission_state=false;
	this.div = (this.suggestDivID=="")?$("autosuggest"):$(this.suggestDivID);
    
	var TAB = 9;
	var ESC = 27;
	var KEYUP = 38;
	var KEYLEFT = 37;
	var KEYRIGHT = 39;
	var KEYDN = 40;
	var ENTER = 13;
    var SHIFT = 16;
	
	elem.setAttribute("autocomplete","off");
    
	if(!elem.id)
	{
		var id = "autosuggest" + idCounter;
		idCounter++;

		elem.id = id;
	}


    elem.onkeypress = function(ev)
	{
	 
		var key = me.getKeyCode(ev);

		switch(key)
		{
			case ENTER: 	
			me.cancelEvent(ev);
			return false;
			break;
		}
	}
	
    elem.onblur = function(ev)
	{
	    if(this.value == '' && typeof  me.defaultText !='undefined') 
	    { 
	        this.value = me.defaultText; 
	        
	        if(me.hiddenID && typeof me.hiddenID !='undefined')
	        {
	          $(me.hiddenID).value='';
	           
	           if(me.searchType=='sector')
			   {
				   $(me.includeSectorID).style.visibility='hidden';
			    }
	        }
	    }
	    
	   // me.blurTimeout(1000);   
	   
	}
	

	elem.onkeydown = function(ev)
	{
		var key = me.getKeyCode(ev);

		switch(key)
		{
			case TAB:
			
			if(me.highlighted > -1)
            {  
                if(me.suggestType=="hidden")
                {
			        $(me.hiddenID).value=me.suggestion.list[me.highlighted].Code;
				    me.elem.value=me.suggestion.list[me.highlighted].Name;
				}
				else
				{
			        me.useSuggestion();
			    }
			}
			
			break;

			case ESC:
			if(!me.requesting)
			{   me.hideDiv();
			  
			}
			me.cancelEvent(ev);
			break;

			case KEYUP:
			if (me.highlighted > -1)
			{
				me.highlighted--;
			}
			me.changeHighlight(key);
			break;

			case KEYDN:
			
			if (me.highlighted < (me.suggestion.list.length - 1))
			{
				me.highlighted++;			
    
			}
			
			me.changeHighlight(key);
			
			break;
			 
			case ENTER:
			
			if(me.highlighted > -1)
            {  
                if(me.suggestType!="hidden")
                {        
                     if(typeof me.controlType!='undefined' && me.controlType=="listbox")
	                 {  me.elem.value=me.suggestion.list[me.highlighted].Name;
	                 }
	                    
	                    
				     if(me.searchType.toUpperCase() == "MANAGER") 
				     {   
					    GotoManagerFactsheet(me.suggestion.list[me.highlighted].Code,me.suggestion.list[me.highlighted].Univ);
				     }
				     else if(me.searchType.toUpperCase() == "GROUP") 
				     {
					    GotoGroupFactsheet(me.suggestion.list[me.highlighted].Code,me.suggestion.list[me.highlighted].Univ);
				     }
				     else 
				     {
					    GotoFundFactsheet(me.suggestion.list[me.highlighted].Code,me.suggestion.list[me.highlighted].Univ);
				     }
				      me.submission_state=true;
				 }
				 else
				 {
				    $(me.hiddenID).value=me.suggestion.list[me.highlighted].Code;
				    me.elem.value=me.suggestion.list[me.highlighted].Name;
				    
				    if(me.searchType=='sector')
				    {
				        $(me.includeSectorID).style.visibility='';
				        $(me.bindedHidMgr).value='';
				        $(me.bindedTxtMgr).value='Enter manager name';
				    }
				 }
				 			    
			    me.hideDiv();
			   
            }
            else if(elem.value.length>0&&me.suggestType!="hidden"&&me.controlType!="listbox")
            { 
                var txtSearch=escape(me.elem.value.urlEncode());
                
                if(!ValidateString(txtSearch))
		        {		         
			        alert('Invalid input, please provide valid input.');
			        return false;
		        }
		        else
		        {
                    searchSubmit(txtSearch);
                    me.submission_state=true;
                }
            }
           
            me.cancelEvent(ev);
            
            break;
		}
	};
	
 

	elem.onkeyup = function(ev) 
	{
		var key = me.getKeyCode(ev);
		if(this.enabledRadio==null || this.enabledRadio.checked)
		{
		    switch(key)
		    {
		        case TAB:
		        case ESC:
		        case KEYUP:
		        case KEYDN:
		        case KEYRIGHT:
		        case KEYLEFT:
		        case SHIFT:
		        case ENTER:
		            return;
    		
		        default:
               
			        if (!me.requesting&&this.value != me.inputText && (this.value.length > 2||(this.value.length>0&&me.controlType=='listbox')))
			        {
        	               	
			               if(typeof me.listClick == 'object' && me.searchType=='fund')
			               {
			                    if(me.searchType=="fund" && $(me.hiddenGroupID).value=="")
                                {
                                    alert("Please select a group");
                                    return;
                                }
                                
			                    me.inputText = this.value;
			                    var temp=me.searchType;                                
                                
                                if(!me.hiddenGroupID || $(me.hiddenGroupID).value=="")
                                {            
                                    me.searchType="fundbyuniverse";   
                                    me.requesting=true;         
                                    me.swiftLoad(me.inputText);
                                }
                                else
                                {
                                    me.searchType="fundbygroup";   
                                    me.requesting=true;         
                                    me.swiftLoad($(me.hiddenGroupID).value+'||'+me.inputText);
                                }                            
                                
                                me.searchType=temp;
                            }
                            else if(typeof me.listClick == 'object' && me.searchType=='manager' && me.hiddenSectorID && $(me.hiddenSectorID).value!="" )			           
                            {
                                 me.inputText = this.value;
			                     var temp=me.searchType;                                                                
                                 me.searchType="managerbysector";   
                                 me.requesting=true;         
                                 me.swiftLoad($(me.hiddenSectorID).value+'||'+me.inputText);
                                 me.searchType=temp;
                            }
                            else
                            {
                               me.inputText = this.value;
        		               me.requesting=true;
			                   me.swiftLoad(me.inputText);	
                            }
			               
			               	             
    		       
			        }
			        else if(!me.requesting&&this.value == me.inputText && (this.value.length > 2||(this.value.length>0&&me.controlType=='listbox')))
			        {
			            me.showDiv();
			        }
			        else
			        {
			            if(this.value.length<3)
			            { 
			                me.suggestion.keyword='';
			                me.suggestion.list.length=0;
			            }
    			       
				        me.hideDiv();
			        }
		        }
		   }
	};
	
    this.clickTimeout=function(ms,keyword)
	{
	    var _self = this;
	    
	    if(keyword=='')
        {   
            setTimeout(function(ms){_self.clickShow(keyword);}, ms);       
        }
        else
        {
            setTimeout(function(ms){_self.clickShowManager(keyword);}, ms);       
        }
    
	};
	
	this.clickShow=function(keyword)
	{ 
	    me.requesting=true;
        me.swiftLoad(keyword);
     }
    
    this.clickShowManager=function(keyword)
	{ 
	    var temp=me.searchType;
	    me.searchType="managerbysector"; 
	    me.requesting=true;
        me.swiftLoad(keyword);
        me.searchType=temp;
        
     }
          
	
	this.setListButton=function(obj)
	{
	 
        me.listClick=obj;
        me.listClick.onclick=function(ev)
        {
            //setTimeout("$('" + me.elem.id + "').value='loading...';",0);
            me.elem.value='loading...';      
            me.clickTimeout(100,'');                  
            //alert(me.elem.value);
            
        }
        
      }
      
    this.setGroupListButton=function(obj)
	{
	 
        this.listClick=obj;
        this.listClick.onclick=function(ev)
        { 
            if(me.searchType=="fund" && $(me.hiddenGroupID).value=="")
            {
                alert("Please select a group");
                return;
            }
            
            var temp=me.searchType;
            me.elem.value='loading...';
            
            if($(me.hiddenGroupID).value=="")
            {            
                me.searchType="fundbyuniverse";   
                me.requesting=true;         
                me.swiftLoad('xxx');
            }
            else
            {
                me.searchType="fundbygroup";   
                me.requesting=true;         
                me.swiftLoad($(me.hiddenGroupID).value);
            }
            
            
            me.searchType=temp;
            me.cancelEvent(ev);
        }
        
        this.listClick.onkeydown = function(ev)
	    {
		    var key = me.getKeyCode(ev);

		    switch(key)
		    {
			    case ESC:
			    if(!me.requesting)
			    {   me.hideDiv();
    			  
			    }
			    me.cancelEvent(ev);
			    break;
		    }
		}	
    }
      
    this.setSectorListButton=function(obj)
	{
	 
        this.listClick=obj;
        this.listClick.onclick=function(ev)
        { 
            
            me.elem.value='loading...';
            
            if($(me.hiddenSectorID).value!="")
            {     
                me.clickTimeout(100,$(me.hiddenSectorID).value);      
            }
            else
            {              
                me.clickTimeout(100,'');      
            }            
            
         
        }
        
        this.listClick.onkeydown = function(ev)
	    {
		    var key = me.getKeyCode(ev);

		    switch(key)
		    {
			    case ESC:
			    if(!me.requesting)
			    {   me.hideDiv();
    			  
			    }
			    me.cancelEvent(ev);
			    break;
		    }
		}	
    }  
      
    this.swiftLoad=function(txt)
    {
     
        var a=document.createElement("script");
        a.setAttribute("id","sugg_funds");
        var searchQuery = (me.searchType != "") ? "&type="+me.searchType : "";
        a.src="/Tools/Suggest.aspx?q="+encodeURIComponent(txt)+searchQuery;
        var b=$("sugg_funds"),d=document.getElementsByTagName("head")[0];
        if(b)d.removeChild(b);
        d.appendChild(a);
        me.requestLoadTimeout(50);
    }
  
    this.requestLoadTimeout=function(ms)
	{
	    var _self = this;
        var t=setTimeout(function(ms){_self.requestLoadTimeout(ms);}, ms);
        
        if(typeof sF=='object')
        {  
           me.doSuggestion(sF);
           clearTimeout(t);         
        }
    
	};
	
	this.requestTimeout=function(ms,txt)
	{
	
	  if(!me.submission_state)
	  {
	      var _self = this;
          setTimeout(function(ms){_self.deferRequest(''+txt+'');}, ms);
       }
	};
     
     
    this.deferRequest=function(txt)
    {
       if(!me.requesting&&me.inputText==txt)
       {  
           if(!me.submission_state)
           {                
               me.requesting=true;               
               me.swiftLoad(me.inputText);
    		}    
		}	
    };
    
    this.doSuggestion=function(res)
    {
        me.requesting=false;
        
        var result=[];
        
        if(typeof res == 'object')
        {   result=res;
        
        }
        else
        {
          if(me.debug)
          { 
            alert('response not in correct format ');
            
          }
          return;
        }  
       
        
        me.suggestion.list=result.slice();
		me.suggestion.keyword=me.inputText;
		
		delete sF;
		 
		
		if(!me.submission_state && me.suggestion.list.length>0&&(me.enabledRadio==null || me.enabledRadio.checked))
		{   
		    me.createDiv();
		    me.positionDiv();
		    me.showDiv();
		    
		    if(me.elem.value=='loading...')
            {   setTimeout("$('" + me.elem.id + "').value='';",0);
                me.elem.value='';
            }
		}
		else
	    {   
		    me.hideDiv();
	    }

        
        
    };

  
  
	this.blurTimeout=function(ms)
	{	
	    var _self = this;
        setTimeout(function(ms){_self.hideDiv();}, ms);
      
	};
      
 
	this.useSuggestion = function()
	{
		if (this.highlighted > -1)
		{
		    this.elem.value = this.suggestion.list[this.highlighted].Name;
			this.hideDiv();
			setTimeout("$('" + this.elem.id + "').focus()",0);
		}
	};


	this.showDiv = function()
	{
		this.div.style.display = 'block';
	};


	this.hideDiv = function()
	{
		this.div.style.display = 'none';
		this.highlighted = -1;
	};

	  
    this.changeHighlight = function()
    {
        if(typeof me.controlType!='undefined' && me.controlType=="listbox")
	    {   
	         var lis = this.div.getElementsByTagName('SELECT');
	         if(lis.length>0)
	         {  
                 for(var i=0;i<lis[0].options.length;i++)
                 {
                     var li = lis[0].options[i];
                     
                     if (this.highlighted == i)
                     {  
                        li.selected=true; 
                                          
                     }
                     else
                     {
                        li.selected=false;
                     }
                  }  
              }
	    }
	    else
	    {
             var lis = this.div.getElementsByTagName('LI');
             for(var i=0;i<lis.length;i++)
             {
                var li = lis[i];
     
                 if (this.highlighted == i)
                 {                
                    li.className = "selected";
                    
                    if(i>18)
                    {   
                        this.div.scrollTop=i*10;
                    }
                    else
                    {   
                        this.div.scrollTop=0;  
                    }
                 }
                 else
                 {
                    li.className = "";
                 }
             }
         }
     };

	this.positionDiv = function()
	{
		var el = this.elem;
		var x = 0;
		var y = el.offsetHeight;
	
		while (el.offsetParent && el.tagName.toUpperCase() != 'BODY')
		{
			x += el.offsetLeft;
			y += el.offsetTop;
			el = el.offsetParent;
		}

		x += el.offsetLeft;
		y += el.offsetTop;

  
		this.div.style.left = x + 'px';
		this.div.style.top = y + 'px';
	};   
    
    
	this.createDiv = function()
	{
		var ul = document.createElement('ul');
      	this.div = (this.suggestDivID=="")?$("autosuggest"):$(this.suggestDivID);
        
        var selectList=null; 
        if(typeof me.controlType!='undefined' && me.controlType=="listbox")
	    {
	    
	        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	        { 
                var ieversion=new Number(RegExp.$1) 
                if (ieversion<7)
                {
                    selectList=document.createElement('<select multiple=\"multiple\"></select>');    
                }
                else
                {
                    selectList=document.createElement('SELECT');    
                }
      
             }
             else
             {
                selectList=document.createElement('SELECT');    
             }
	    
            //alert('its a list');
           //selectList=document.createElement('SELECT');    
           //selectList.setAttribute("type","select-multiple");
           
           if(me.suggestion.list.length>15)
           { selectList.setAttribute("size","15");
           }
           else
           { selectList.setAttribute("size",me.suggestion.list.length);
           }
           selectList.setAttribute("multiple","true");
            //alert(selectList.type);
            
           	selectList.onkeydown = function(ev)
	        {
		        var key = me.getKeyCode(ev);

		        switch(key)
		        {
			        case TAB:me.hideDiv(); break;
			     }
			} 
            
           selectList.onchange = function(ev)
           {
                if(this.selectedIndex>-1)
                {
                      me.highlighted=this.selectedIndex;
                      var code=this.options[this.selectedIndex].value;
                      var name=this.options[this.selectedIndex].text;
                      var univ='U';
                      
                      
                          if(me.suggestType!="hidden")
	                      {   me.elem.value=name;
	                            if(me.searchType.toUpperCase() == "MANAGER") {
        			                
			                        window.location="/Managers/ManagerFactsheet.aspx?personCode="+code+"&univ="+univ;
	                            }
	                            else if(me.searchType.toUpperCase() == "GROUP") {
			                        window.location="/Factsheets/ManagerGroup.aspx?managerCode="+code+"&univ="+univ;
	                            }
	                            else {
			                        window.location="/Factsheets/Factsheet.aspx?fundCode="+code+"&univ="+univ;
	                            }
	                        }
	                        else
	                        {
	                            $(me.hiddenID).value=code;
	                            me.elem.value=name;
	                            $(me.div.id).style.display='none';		
	                 
	                            if(me.searchType=='sector')
				                {
				                    $(me.includeSectorID).style.visibility='';
				                    $(me.bindedHidMgr).value='';
				                    $(me.bindedTxtMgr).value='Enter manager name';
				                }	            
            			        
	                         }
                    } 
               
              } //end onchange event
              
//        selectList.onmouseover = function(ev)
//		{
//		    //alert(window.event.fromElement.tagName);
//		    var target = me.getEventSource(ev);		    
//		    //alert(target.tagName);
//            while (target.parentNode && target.tagName.toUpperCase() != 'OPTION')
//	        {
//		        target = target.parentNode;
//	        }
//		
//	        var lis = me.div.getElementsByTagName('OPTION');    			
//	        
//	        for (i in lis)
//	        {
//		        var li = lis[i];
//		        if(li == target)
//		        {
//			        me.highlighted = i;
//			        break;
//		        }
//		        
//	        }	        
//	        
//	        me.changeHighlight();
//     
//		 }//end onmouseover event
              
              
        }//end if list control
        

	    for (var j=0;j<me.suggestion.list.length;j++)
		{   
		    var word = me.suggestion.list[j].Name;
		    var code = me.suggestion.list[j].Code;
		    var univ = me.suggestion.list[j].Univ;
		    
	        if(typeof word=='string')
	        {
	        
	            if(typeof me.controlType =='undefined')
	            {    
			        var li = document.createElement('li');
			        var a = document.createElement('a');
			        li.setAttribute('id',this.div.id+'_li_'+j);
            
			        if(this.suggestType!="hidden")
			        {
			            if(me.searchType.toUpperCase() == "MANAGER") {
					        a.href="/Managers/ManagerFactsheet.aspx?personCode="+code+"&univ="+univ;
			            }
			            else if(me.searchType.toUpperCase() == "GROUP") {
					        a.href="/Factsheets/ManagerGroup.aspx?managerCode="+code+"&univ="+univ;
			            }
			            else {
					        a.href="/Factsheets/Factsheet.aspx?fundCode="+code+"&univ="+univ;
			            }
			        }
			        else
			        {
			            a.href="javascript:$('"+this.hiddenID+"').value='"+code+"';$('"+this.elem.id+"').value='"+word+"';$('"+this.div.id+"').style.display='none';void(0);";
    			        
			         }
    			   
			        var rSpan = document.createElement('div');
    			    
			        rSpan.className='rSpan';
			        rSpan.innerHTML=word;
    			    
    		        a.appendChild(rSpan);
    			    
			        li.appendChild(a);
        	    
//        	        li.appendChild(rSpan);
        	        
			        if (me.highlighted == j)
			        {
				        li.className = "selected";
			        }
        	
			        ul.appendChild(li);
			    }
			    else if(me.controlType=="listbox")
			    {
			        //inside loop
			        var item=new Option(word,code);		        
	                //item.attachEvent('onmouseover',function(){alert('d');}); 
			        selectList.options.add(item);
					
			    
			    }
			}//end if word
			
		}//end for
		
		if(typeof me.controlType!='undefined' && me.controlType=="listbox")
	    {
	        this.div.replaceChild(selectList,this.div.childNodes[0]);	        
	        me.highlighted=-1;
         }
        else
        {	
		    this.div.replaceChild(ul,this.div.childNodes[0]);
		}      

		
		
        this.div.onblur = function(ev)
	    {
	        me.blurTimeout(100);   
    	   
	    }

        document.onclick=function(e)
        {               
            var e=e? e : window.event;
            var ref=e.target? e.target : e.srcElement;

            if(ref!=me.listClick)
            { 
                if(me.elem.value == '' && typeof  me.defaultText !='undefined'&& ref!=me.elem) 
	            { 
	                me.elem.value = me.defaultText; 
	                
	                if(me.hiddenID && typeof me.hiddenID !='undefined')
	                {
	                    $(me.hiddenID).value='';
	                    
	                     if(me.searchType=='sector')
				         {
				            $(me.includeSectorID).style.visibility='hidden';
				            
				         }
	                }
	            }
                me.hideDiv();
              
             }
           
        } 
        
        document.onkeypress=function(e)
        {               
            
           	var key = null;
           	
           	if(e)			//Moz
		    {
			    key= e.keyCode;
		    }
		    if(window.event)	//IE
		    {
			    key=window.event.keyCode;
		    }
				
           	switch(key)
		    {   case ESC:
		        if(me.elem.value == '' && typeof  me.defaultText !='undefined') 
	            { 
	                me.elem.value = me.defaultText; 
	                
	                if(me.hiddenID && typeof me.hiddenID !='undefined')
	                {
	                    $(me.hiddenID).value='';
	                     if(me.searchType=='sector')
				         {
				            $(me.includeSectorID).style.visibility='hidden';
				         }
	                }
	            }
		        me.hideDiv();
		        break;
		    }
        }    

        
    	
	
		ul.onmouseover = function(ev)
		{
		    var target = me.getEventSource(ev);
		    
		    try
		    {  		    
                while (target.parentNode && target.tagName.toUpperCase() != 'LI')
	            {
		            target = target.parentNode;
	            }
    		        
	            var lis = me.div.getElementsByTagName('LI');    			
    	
	            for (var i=0;i<lis.length;i++)
	            {
		            var li = lis[i];
		            if(li == target)
		            {
			            me.highlighted = i;
			            break;
		            }
	            }
		        
	            me.changeHighlight();  		       
	            
	         }
	         catch(e)
	         {}
		};


//		ul.onclick = function(ev)
//		{
		
//			me.useSuggestion();
//			
//		
//			searchSubmit(escape(me.elem.value.urlEncode()));
//			me.submission_state=true;
//			
//			me.hideDiv();
//			me.cancelEvent(ev);
//			return false;
//		};
	
		this.div.className="suggestion_list";
		this.div.style.position = 'absolute';
		this.div.style.zIndex = 100;
		
		if(me.suggestion.list.length>18&&me.controlType!="listbox")
		{
		    this.div.className += " suggestScroll";
		}
		else
		{
		    this.div.className += " suggestNoscroll";
		}

	};

	this.mouseOverTimeout=function(ms)
	{	
	    var _self = this;
        setTimeout
        (
            function(ms)
            {             
               _self.changeHighlight();
            }
         , ms);
      
	}; 

	this.getKeyCode = function(ev)
	{
		if(ev)			//Moz
		{
			return ev.keyCode;
		}
		if(window.event)	//IE
		{
			return window.event.keyCode;
		}
	};

	this.getEventSource = function(ev)
	{
		if(ev)			//Moz
		{
			return ev.target;
		}
	
		if(window.event)	//IE
		{
			return window.event.srcElement;
		}
	};

	this.cancelEvent = function(ev)
	{
		if(ev)			//Moz
		{
			ev.preventDefault();
			ev.stopPropagation();
		}
		if(window.event)	//IE
		{
			window.event.returnValue = false;
			event.cancel = true;
		}
	}
	
	function suggestions()
	{
	   this.list=[];
	   this.keyword='';
	}	   
	
}

	
	
	
 String.prototype.urlEncode = function () 
 {
        var text = this.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < text.length; n++) {

            var c = text.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
  }

function GotoFundFactsheet(fundCode,univCode)
{
   if(fundCode!=""&&univCode!="")
   { 
     window.location="/Factsheets/Factsheet.aspx?fundCode="+fundCode+"&univ="+univCode;
   }
}

function GotoManagerFactsheet(personCode,univCode)
{   
   if(personCode!="")
   {
     window.location="/Managers/ManagerFactsheet.aspx?personCode="+personCode+"&univ="+univCode;
     
   }
   
   
}

function GotoGroupFactsheet(managerCode,univCode)
{
   if(managerCode!="")
   {
     window.location="/Factsheets/ManagerGroup.aspx?managerCode="+managerCode+"&univ="+univCode;
   }
}


var idCounter = 0;

/*###################################################################

Revision history:

Date      | By | Description
----------+----+------------------------------------------
14-Mar-07   RP   Created.

####################################################################*/

//####################################################################
// These variables can safely be modified by client scripts as required
//####################################################################

// if true, helpful debug alerts will be be displayed.
var DebugAlert = false; 

// notifies every time a web service is executed. DebugAlert must be true.
var DebugAlertOnWebServiceExec = false; 

// notifies what parameters are used for a web service. Both above variables must be true.
var DebugAlertShowParamsOnExec = false;

// if true, alerts will be sent to a DIV element rather than the alert box.
var UseDebugPanel = true;

// If true, then no style data will be allocated to the DebugPanel. UseDebugPanel must be set to true.
// This means the client should define CSS class definitions for div.DebugPanel, div.DebugEntry, div.DebugHeading
var DebugPanelUseCustomStyle = false; 



//####################################################################
// ChartingWebService definition and methods
//####################################################################
function ChartingWebService()
{
	 this.WebServiceUrl ='http://'+serverName+'/WebServices/charting.asmx';
}
function TNXWebService()
{
	 this.WebServiceUrl ='http://'+serverName+'/WebServices/BusinessObjLoader.asmx';
}
function PortfolioWebService()
{
	 this.WebServiceUrl ='http://'+serverName+'/WebServices/BusinessObjLoader.asmx';
}
function LoadSectorQs(r)
{
 	LoadOptionList(r, 'qsSectorsDD', 'Sectors');
}
function LoadDomicilesQs(r)
{
 	LoadOptionList(r, 'qsDomicileDD', 'Domiciles');
}
function LoadManagersQs(r)
{
 	LoadOptionList(r, 'qsManagerDD', 'Managers');
}

function LoadFilterBusObjectLoad(busCollObjName,univCode,loadMethod,param,nameProperty,codeProperty,filter,sort)
{
var pws = new PortfolioWebService();
if(busCollObjName=="Sectors")
pws.LoadFilterBusObjects(LoadSectorQs,busCollObjName,univCode,loadMethod,param,nameProperty,codeProperty,filter,sort);
if(busCollObjName=="Domiciles")
pws.LoadBusObjAdoQS(LoadDomicilesQs,busCollObjName,univCode,nameProperty,codeProperty,filter,sort);
if(busCollObjName=="Managers")
pws.LoadFilterBusObjects(LoadManagersQs,busCollObjName,univCode,loadMethod,param,nameProperty,codeProperty,filter,sort);
}

function CalDayLightTimeLoad()
{
var pws = new PortfolioWebService();
pws.CalDayLightTime(LoadDayLightData);
}

function LoadSectorByAssetClassLoad(assetClassCode,univCode,nameProperty,codeProperty,filter,sort)
{
var pws = new PortfolioWebService();
pws.LoadSectorByAssetClassQs(LoadSectorQs,assetClassCode,univCode,nameProperty,codeProperty,filter,sort);
}

function AddPortfolioFundDisplay(portfolioId, userId, univCode, typeCode)
{
var pws = new PortfolioWebService();
pws.AddPortfolioFund(UserCount,portfolioId, userId, univCode, typeCode);
}

function PortfolioUpdateFundList(typecode,pDate,quantity,fundcurrency,currency,costV,pCost,rowGuid,port,userId)
{
var pws = new PortfolioWebService();
pws.UpdatePortfolioFund(UserCount,typecode,pDate,quantity,fundcurrency,currency,costV,pCost,rowGuid,port,userId);
}

 
function CashUpdateList(typecode,quantity,fundcurrency,currency,AccType,name,port,userId)
{
var pws = new PortfolioWebService();
pws.UpdateCash(UserCount,typecode,quantity,fundcurrency,currency,AccType,name,port,userId);
}

function AddPortfolioFundDisplay(portfolioId, userId, univCode, typeCode)
{
var pws = new PortfolioWebService();
pws.AddPortfolioFund(UserCount,portfolioId, userId, univCode, typeCode);
}

function RemovePortfolioFundDisplay(portfolioId, userId,typeCode)
{
var pws = new PortfolioWebService();
pws.RemovePortfolioFund(UserCount,portfolioId, userId, typeCode);
}

function AddWatchlistFundDisplay(userId, univCode, typeCode,SiteCode)
{
var pws = new PortfolioWebService();
pws.AddWatchlistFund(UserCount,userId, univCode, typeCode,SiteCode);
}

function RemoveWatchlistFundDisplay(userId, univCode, typeCode,SiteCode)
{
var pws = new PortfolioWebService();
pws.RemoveWatchlistFund(UserCount,userId, univCode, typeCode,SiteCode);
}

function CheckLoginUserDetails(email,password)
{
var pws = new PortfolioWebService();
pws.CheckUserLogIn(UserDetails,email, password);
}

function UserDetails(r)
{
    if(r!="0")
    {
		if(allowPop && allowPop == "true")
		{
			window.open('http://www.trustnet.com/?uId='+r,'_blank');
		}
	   else
	   {
			window.location.href = "/?uId="+r;
	   }
    }else
    {
        alert("!Invalid UserDetails");
    }
}

function FundByType(typeCode)
{
var pws = new PortfolioWebService();
pws.LoadFundByType(SetBasketVisibility,typeCode);
}

function CheckTypeCodeInPortfolio(portfolioId, typeCode)
{
var pws = new PortfolioWebService();
pws.IsTypeCodeExistInPortfolio(IsTypeCodeInPortfolio,portfolioId, typeCode);
}


function PortfolioByUserId(userId)
{
var pws = new PortfolioWebService();
pws.LoadPortfolioByUserId(PopulateBasketPortfolio,userId);
}

function WatchlistByUserId(userId)
{
var pws = new PortfolioWebService();
pws.LoadWatchlistByUserId(LoadHiddenWatchList,userId);
}

function FundByTypeCode(typeCode)
{
var pws = new PortfolioWebService();
pws.LoadFundByTypes(SetProdSearchBaseket,typeCode);
 
}

function UpdateUserCookieByIPinDB(userId,cookieName,cookieValue)
{
	var pws = new PortfolioWebService();
	pws.UpdateUserCookieDB(UpdateUserCookieByIPFn,userId,cookieName,cookieValue);
}

function SectorsByAssetClassQS(universe, filter)
{
    var pws = new PortfolioWebService();
    pws.LoadSectorsByAssetClassQS(PopulateSectors,universe, filter);

}

function AssetClassByUniverseQS(universe )
{
    var pws = new PortfolioWebService();
    pws.LoadAssetClassByUniverseQS(PopulateAssetClass,universe );

}

function ManagersByUniverseQS(universe )
{
    var pws = new PortfolioWebService();
    pws.LoadManagersByUniverseQS(PopulateManager,universe);

}

function DomicilesByUniverseQS(universe )
{
    var pws = new PortfolioWebService();
    pws.LoadDomicilesByUniverseQS(PopulateDomiciles,universe );

}

function GeoareaByUniverseQS(universe )
{
    var pws = new PortfolioWebService();
    pws.LoadGeoareaByUniverseQS(PopulateGeoarea,universe );

}

function VCTQSObjects(delegate,universe, filter)
{
    var pws = new PortfolioWebService();
    pws.LoadVCTQSObjects(delegate,universe, filter);

}

function SPSFObjects(delegate,universe, filter)
{
    var pws = new PortfolioWebService();
    pws.LoadSPSFManagers(delegate,universe, filter);
}



function UserCount(r)
{   
   return r;
}

function ManagersByUniverseSF(universe)
{
    var pws = new PortfolioWebService();
    pws.LoadManagersByUniverseSF(PopulateManagerSF,universe);

}


PortfolioWebService.prototype.LoadSectorsByAssetClassQS=function(delegateFunc,universe, filter)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);
    p.Add('assetClassName',filter);
    this.Invoke('LoadSectorsByAssetClassQS', p,delegateFunc);
}

PortfolioWebService.prototype.LoadAssetClassByUniverseQS=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);    
    this.Invoke('LoadAssetClassByUniverseQS', p,delegateFunc);
}

TNXWebService.prototype.LoadSectorsByUniverse=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('busCollObjName','Sector');
    p.Add('univCode',universe);
    p.Add('nameProperty','NameLong');
    p.Add('codeProperty','SectorClassCode');
    p.Add('filter','');
    p.Add('sort','NameLong');
    this.Invoke('LoadBusObjAdo', p,delegateFunc);
}


PortfolioWebService.prototype.UpdatePollChoice=function(delegateFunc,pollId,pollChoiceId)
{
    var p = new WSParameters();
    p.Add('pollId',pollId);
    p.Add('pollChoiceId',pollChoiceId);   
    this.Invoke('UpdatePollChoice', p,delegateFunc);
}

PortfolioWebService.prototype.LoadManagersByUniverseQS=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);
    p.Add('includeAll',false);
    this.Invoke('LoadManagersByUniverseQS', p,delegateFunc);
}

PortfolioWebService.prototype.LoadDomicilesByUniverseQS=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);    
    this.Invoke('LoadDomicilesByUniverseQS', p,delegateFunc);
}

PortfolioWebService.prototype.LoadGeoareaByUniverseQS=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);    
    this.Invoke('LoadGeoareaByUniverseQS', p,delegateFunc);
}



PortfolioWebService.prototype.LoadVCTQSObjects=function(delegateFunc,universe, filter)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);
    p.Add('returnValue',filter);
    this.Invoke('LoadVCTQSObjects', p,delegateFunc);
}

PortfolioWebService.prototype.LoadSPSFManagers=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);
    this.Invoke('LoadSPSFManagers', p,delegateFunc);
}

PortfolioWebService.prototype.LoadManagersByUniverseSF=function(delegateFunc,universe)
{
    var p = new WSParameters();
    p.Add('universeCode',universe);
    p.Add('includeAll',true);
    this.Invoke('LoadManagersByUniverseQS', p,delegateFunc);
}

ChartingWebService.prototype.LoadPerformance = function(delegateFunc, typeCodes, periodType, priceType, methodType, sort, filter)
{
	var p = new WSParameters();

	if (periodType == null) periodType = '';
	if (priceType == null) priceType = 'TR';
	if (methodType == null) methodType = 1;

	p.Add('TypeCodes', typeCodes);
	p.Add('PeriodType', periodType);
	p.Add('PriceType', priceType);
	p.Add('MethodType', methodType);
	
	this.AddStdParams(p, sort, filter);
	this.Invoke('Performance', p, delegateFunc);
}

PortfolioWebService.prototype.AddPortfolioFund= function(delegateFunc,portfolioId, userId, univCode, typeCode)
{
	var p = new WSParameters();

	p.Add('portfolioId', portfolioId);
	p.Add('userId', userId);
	p.Add('univCode', univCode);
	p.Add('typeCode', typeCode);
	this.Invoke('AddPortfolio', p,delegateFunc);
}

PortfolioWebService.prototype.UpdatePortfolioFund= function(delegateFunc,typecode,pDate,quantity,fundcurrency,currency,costV,pCost,rowGuid,port,userId)
{
	var p = new WSParameters();

	p.Add('typecode', typecode);
	p.Add('purchaseDate', pDate);
	p.Add('Quantity', quantity);
	p.Add('fundCurrency', fundcurrency);	
	p.Add('Currency', currency);
	p.Add('isCost', costV);
	p.Add('pCost', pCost);
	p.Add('rowGuid', rowGuid);
	p.Add('pid', port);
	p.Add('userid', userId);
	this.Invoke('UpdatePortfolioFund', p,delegateFunc);
}

PortfolioWebService.prototype.UpdateCash= function(delegateFunc,typecode,quantity,fundcurrency,currency,AccType,name,port,userId)
{
	var p = new WSParameters();
	p.Add('cid', typecode);	
	p.Add('Quantity', quantity);
	p.Add('fundCurrency', fundcurrency);
	p.Add('Currency', currency);
	p.Add('accType', AccType);
	p.Add('accName', name);	
	p.Add('pid', port);
	p.Add('userid', userId);
	this.Invoke('UpdateCash', p,delegateFunc);
}

PortfolioWebService.prototype.CheckUserLogIn=function (delegateFunc,emailId,password)
{
    var p = new WSParameters();
    p.Add('emailId',emailId);
    p.Add('password',password);
    this.Invoke('CheckUserLogIn',p,delegateFunc);
//    var pws = new PortfolioWebService();
//    pws.CheckUserLogIn(emailId,password);
} 

PortfolioWebService.prototype.CalDayLightTime= function(delegateFunc)
{
	var p = new WSParameters();

    this.Invoke('CalCulateDayLightTime',p,delegateFunc);
}
PortfolioWebService.prototype.LoadFilterBusObjects= function(delegateFunc,busCollObjName,univCode,loadMethod,param,nameProperty,codeProperty,filter,sort)
{
	var p = new WSParameters();

    if (param == null) param = '';
    if (filter == null) filter = '';
    
	p.Add('busCollObjName', busCollObjName);
	p.Add('univCode', univCode);
	p.Add('loadMethod', loadMethod);
	p.Add('parameter', param);
	p.Add('nameProperty', nameProperty);
	p.Add('codeProperty', codeProperty);
	p.Add('filter', filter);
	p.Add('sort', sort);
	this.Invoke('LoadFilterBusObject', p,delegateFunc);
}
PortfolioWebService.prototype.LoadFilterBusObjectByUnivGroup= function(delegateFunc,busCollObjName,univGroupCode,parameterType,parameterValue,filter)
{
	var p = new WSParameters();

	if (filter == null) filter = '';
   if (parameterType == null) parameterType = '';
   if (parameterValue == null) parameterValue = '';
    
	p.Add('busCollObjName', busCollObjName);
	p.Add('univGroupCode', univGroupCode);
	p.Add('parameterType', parameterType);
	p.Add('parameterValue', parameterValue);
	p.Add('filter', filter);
	this.Invoke('LoadFilterBusObjectByUnivGroup', p,delegateFunc);
}

PortfolioWebService.prototype.LoadChartFilterBusObjectByUnivGroup= function(delegateFunc,busCollObjName,univGroupCode,parameterType,parameterValue,filter)
{
	var p = new WSParameters();

	if (filter == null) filter = '';
   if (parameterType == null) parameterType = '';
   if (parameterValue == null) parameterValue = '';
    
	p.Add('busCollObjName', busCollObjName);
	p.Add('univGroupCode', univGroupCode);
	p.Add('parameterType', parameterType);
	p.Add('parameterValue', parameterValue);
	p.Add('filter', filter);
	this.Invoke('LoadChartFilterBusObjectByUnivGroup', p,delegateFunc);
}

PortfolioWebService.prototype.LoadBusObjAdoQS= function(delegateFunc,busCollObjName,univCode,nameProperty,codeProperty,filter,sort)
{
	var p = new WSParameters();

    if (filter == null) filter = '';
    
	p.Add('busCollObjName', busCollObjName);
	p.Add('univCode', univCode);
	p.Add('nameProperty', nameProperty);
	p.Add('codeProperty', codeProperty);
	p.Add('filter', filter);
	p.Add('sort', sort);
	this.Invoke('LoadBusObjAdo', p,delegateFunc);
}
PortfolioWebService.prototype.LoadSectorByAssetClassQs= function(delegateFunc,assetClassCode,univCode,nameProperty,codeProperty,filter,sort)
{
	var p = new WSParameters();

    if (assetClassCode == null) assetClassCode = '';
    if (filter == null) filter = '';
    
	p.Add('assetClassCode', assetClassCode);
	p.Add('univCode', univCode);
	p.Add('nameProperty', nameProperty);
	p.Add('codeProperty', codeProperty);
	p.Add('filter', filter);
	p.Add('sort', sort);
	this.Invoke('LoadSectorByAssetClass', p,delegateFunc);
}

PortfolioWebService.prototype.RemovePortfolioFund= function(delegateFunc,portfolioId, userId,  typeCode)
{
	var p = new WSParameters();

	p.Add('portfolioId', portfolioId);
	p.Add('userId', userId);	
	p.Add('typeCode', typeCode);

	this.Invoke('RemovePortfolio', p,delegateFunc);
}

PortfolioWebService.prototype.AddWatchlistFund= function(delegateFunc,userId,univCode,typeCode)
{
	var p = new WSParameters();
	p.Add('userId', userId);	
	p.Add('univCode', univCode);
	p.Add('typeCode', typeCode);   
	p.Add('SiteCode', SiteCode);
	this.Invoke('AddWatchlist', p,delegateFunc);
}

PortfolioWebService.prototype.RemoveWatchlistFund= function(delegateFunc,userId,  typeCode,SiteCode)
{
	var p = new WSParameters();
	
	p.Add('userId', userId);	
	p.Add('typeCode', typeCode);
    p.Add('SiteCode', SiteCode);

	this.Invoke('RemoveWatchlist', p,delegateFunc);
}

PortfolioWebService.prototype.LoadManagerPersons= function(delegateFunc,univCode,loadBy,parameter,nameProperty,codeProperty,filter,sort)
{
	var p = new WSParameters();
	if (parameter == null) return;
	if (filter == null) filter = '';
    
	p.Add('univCode', univCode);
	p.Add('loadMethod', loadBy);
	p.Add('parameter', parameter);
	p.Add('nameProperty', nameProperty);
	p.Add('codeProperty', codeProperty);
	p.Add('filter', filter);
	p.Add('sort', sort);
	this.Invoke('LoadManagerPersons', p,delegateFunc);
}

PortfolioWebService.prototype.LoadFundByType=function(delegateFunc,typeCode)
{
    var p = new WSParameters();
    p.Add('typeCode',typeCode);
    this.Invoke('LoadFundByTypeCode', p,delegateFunc);
}
PortfolioWebService.prototype.LoadPortfolioByUserId=function(delegateFunc,userId)
{
    var p = new WSParameters();
    p.Add('userId',userId);
    this.Invoke('LoadPortfolioByUserId', p,delegateFunc);
}

PortfolioWebService.prototype.LoadWatchlistByUserId=function(delegateFunc,userId)
{
    var p = new WSParameters();
    p.Add('userId',userId);
    this.Invoke('LoadWatchlistByUserId', p,delegateFunc);
}

PortfolioWebService.prototype.IsTypeCodeExistInPortfolio=function(delegateFunc,portfolioId,typeCode)
{
    var p = new WSParameters();
    p.Add('portfolioId',portfolioId);
    p.Add('typeCode',typeCode);
    this.Invoke('IsTypeCodeExistInPortfolio', p,delegateFunc);
}

PortfolioWebService.prototype.LoadFundByTypes=function(delegateFunc,typeCode)
{
    var p = new WSParameters();
    p.Add('typeCode',typeCode);
    this.Invoke('LoadFundByTypeCodes', p,delegateFunc);
}

PortfolioWebService.prototype.UpdateUserCookieDB=function(delegateFunc,userId,cookieName,cookieValue)
{
    var p = new WSParameters();
    p.Add('userId',userId);
    p.Add('cookieName',cookieName);
    p.Add('cookieValue',cookieValue);
    this.Invoke('UpdateUserCookie', p,delegateFunc);
}

// Parameters are as follows:
//   calcType .......... one from [MinMax, MinMean]
//   statisticalType ... e.g. Alpha, Beta, etc.
//   period ............ period over which to make calculations, in months.
//   offset ............ how many months ago should the latest data point be?
//   step .............. in months (interval between data points).
//   number ............ number of data points to return.
//
// Example:
//   LoadRollingDiscreteRange(null, 'MinMax', 'FFISS', 'NASX', 'Alpha', 36, 0, 1, 12)
ChartingWebService.prototype.LoadRollingDiscreteRange = function(delegateFunc, calcType, typeCodes, benchmarkCode, statisticalType, period, offset, step, number)
{
	var p = new WSParameters();

	p.Add('CalcType', typeCodes);
	p.Add('TypeCodes', typeCodes);
	p.Add('BenchmarkCode', benchmarkCode);
	p.Add('StatisticalType', statisticalType);
	p.Add('Period', period);
	p.Add('Offset', offset);
	p.Add('Step', step);
	p.Add('Number', number);

	this.Invoke('GetRollingDiscrete', p, delegateFunc);
}


// Parameters are as follows:
//   statisticalType ... e.g. Alpha, Beta, etc.
//   period ............ period over which to make calculations, in months.
//   offset ............ how many months ago should the latest data point be?
//   step .............. in months (interval between data points).
//   number ............ number of data points to return.
//
// Example:
//   LoadRollingDiscrete(null, 'FFISS', 'NASX', 'Alpha', 36, 0, 1, 12)
ChartingWebService.prototype.LoadRollingDiscrete = function(delegateFunc, typeCodes, benchmarkCode, statisticalType, period, offset, step, number)
{
	var p = new WSParameters();

	p.Add('TypeCodes', typeCodes);
	p.Add('BenchmarkCode', benchmarkCode);
	p.Add('StatisticalType', statisticalType);
	p.Add('Period', period);
	p.Add('Offset', offset);
	p.Add('Step', step);
	p.Add('Number', number);

	this.Invoke('GetRollingDiscrete', p, delegateFunc);
}


ChartingWebService.prototype.LoadEquities = function(delegateFunc, sort, filter)
{
	var p = new WSParameters();
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Equities', p, delegateFunc);
}

ChartingWebService.prototype.LoadInstruments = function(delegateFunc, typeCodes, sort, filter)
{
	var p = new WSParameters();
	p.Add('TypeCodes', typeCodes);
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Instruments', p, delegateFunc);
}

ChartingWebService.prototype.LoadUnitsByManagerCode = function(delegateFunc, categories, managerCodes, sort, filter)
{
	var p = new WSParameters();
	p.Add('Categories', categories);
	p.Add('ManagerCodes', managerCodes);
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Units_ByManagerCode', p, delegateFunc);
}

ChartingWebService.prototype.LoadUnitsBySectorClassCode = function(delegateFunc, categories, sectorClassCodes, sort, filter)
{
	var p = new WSParameters();
	p.Add('Categories', categories);
	p.Add('SectorClassCodes', sectorClassCodes);
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Units_BySectorClassCode', p, delegateFunc);
}

ChartingWebService.prototype.LoadUnitsByFundCode = function(delegateFunc, fundCodes, sort, filter)
{
	var p = new WSParameters();
	p.Add('FundCodes', fundCodes);
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Units_ByFundCode', p, delegateFunc);
}

ChartingWebService.prototype.LoadFundsByManagerCode = function(delegateFunc, categories, managerCodes, sort, filter)
{
	var p = new WSParameters();
	p.Add('Categories', categories);
	p.Add('ManagerCodes', managerCodes);
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Funds_ByManagerCode', p, delegateFunc);
}

ChartingWebService.prototype.LoadFundsBySectorClassCode = function(delegateFunc, categories, sectorClassCodes, sort, filter)
{
	var p = new WSParameters();
	p.Add('Categories', categories);
	p.Add('SectorClassCodes', sectorClassCodes);
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Funds_BySectorClassCode', p, delegateFunc);
}

ChartingWebService.prototype.LoadManagers = function(delegateFunc, categories, sort, filter)
{
	var p = new WSParameters();
	
	if (filter == null) filter = '';
	if (sort == null) sort = 'Name';

	// Due to case-sensitivity, and the fact that the Managers method has different case 
	// parameters from the standard, it has to be done the long way.
	p.Add('categories', categories);
	p.Add('pageNo', 1);
	p.Add('pageSize', 0);
	p.Add('filter', filter);
	p.Add('sort', sort);

	this.Invoke('Managers', p, delegateFunc);
}

ChartingWebService.prototype.LoadSectors = function(delegateFunc, categories, officialSectors, sort, filter)
{
	var p = new WSParameters();
	var webMethod = officialSectors ? 'OfficialSectors' : 'Sectors';
	if (sort == null) sort = 'Name';
	if (officialSectors != true)
	{
		officialSectors = false;
	}
	p.Add('Categories', categories);
	this.AddStdParams(p, sort, filter);
	this.Invoke(webMethod, p, delegateFunc);
}

ChartingWebService.prototype.LoadIndices = function(delegateFunc, sort, filter)
{
	var p = new WSParameters();
	if (sort == null) sort = 'Name';
	this.AddStdParams(p, sort, filter);
	this.Invoke('Indices', p, delegateFunc);
}

// This method has not been tested.
ChartingWebService.prototype.LoadStochasticFanByAssetCodes = function(delegateFunc, assetCodes, percentiles, timePeriods, allowForInflation)
{
	var p = new WSParameters();
	p.Add('assetCodes', assetCodes);
	p.Add('percentiles', percentiles);
	p.Add('timePeriods', timePeriods);
	p.Add('allowForInflation', allowForInflation);
	this.Invoke('GetStochasticFan_ByAssetCodes', p, delegateFunc);
}

// This method has not been tested.
ChartingWebService.prototype.LoadStochasticFanByTypeCodes = function(delegateFunc, typeCodes, percentiles, timePeriods, allowForInflation)
{
	var p = new WSParameters();
	p.Add('typeCodes', typeCodes);
	p.Add('percentiles', percentiles);
	p.Add('timePeriods', timePeriods);
	p.Add('allowForInflation', allowForInflation);
	this.Invoke('GetStochasticFan_ByTypeCodes', p, delegateFunc);
}

ChartingWebService.prototype.AddStdParams = function(p, sort, filter)
{
	if (filter == null) filter = '';
	if (sort == null) sort = '';
	p.Add('PageNo', 1);
	p.Add('PageSize', 0);
	p.Add('Filter', filter);
	p.Add('Sort', sort);
}

ChartingWebService.prototype.Invoke = function(webMethod, params, delegateFunc)
{
	if (delegateFunc == null) 
	{
		delegateFunc = LoadServiceTest;
		if (webMethod.indexOf('GetRollingDiscrete') == 0)
		{
			delegateFunc = LoadServiceTestString;
		}
	}
	Debug(params.Length == 0, 'Invoke method: params is empty for method "' + webMethod + '"');
	if (DebugAlertOnWebServiceExec)
	{
		var msg = 'Executing ' + webMethod + ' method';
		if (DebugAlertShowParamsOnExec)
		{
			msg += ' with parameters:\n' + params.ToString();
		}
		Debug(true, msg);
	}

	try
	{
		SOAPClient.invoke(this.WebServiceUrl, webMethod, params.ToSoap(), true, delegateFunc);
	}
	catch (ex)
	{
		Debug(true, 'Error invoking web service.\nUrl: ' + this.WebServiceUrl + '\nMethod: ' + webMethod + '\nParameters: ' + params.ToString() + '\nException: ' + ex);
	}
}

PortfolioWebService.prototype.Invoke = function(webMethod, params, delegateFunc)
{

	Debug(params.Length == 0, 'Invoke method: params is empty for method "' + webMethod + '"');
	if (DebugAlertOnWebServiceExec)
	{
		var msg = 'Executing ' + webMethod + ' method';
		if (DebugAlertShowParamsOnExec)
		{
			msg += ' with parameters:\n' + params.ToString();
		}
		Debug(true, msg);
	}

	try
	{
		SOAPClient.invoke(this.WebServiceUrl, webMethod, params.ToSoap(), true, delegateFunc);
	}
	catch (ex)
	{
		Debug(true, 'Error invoking web service.\nUrl: ' + this.WebServiceUrl + '\nMethod: ' + webMethod + '\nParameters: ' + params.ToString() + '\nException: ' + ex);
	}
}

//####################################################################
// Parameters collection
//####################################################################
function WSParameters()
{
	this.names = new Array();
	this.values = new Array();
}

WSParameters.prototype.Add = function(name, value)
{
	this.names[this.names.length] = name;
	this.values[this.values.length] = value;
}

WSParameters.prototype.Length = function()
{
	return this.names.length;
}

WSParameters.prototype.ToString = function(separator)
{
	var res = '', sep = '';
	if (separator == null) separator = '\n';
	for (var i = 0; i < this.names.length; i++)
	{
		res += sep + this.names[i] + '="' + this.values[i] + '"';
		sep = separator;
	}
	return res;
}

WSParameters.prototype.ToSoap = function()
{
	var p = new SOAPClientParameters();
	for (var i = 0; i <this.names.length; i++)
	{
		p.add(this.names[i], this.values[i]);
	}
	return p;
}

//####################################################################
// Helper functions below this point 
//####################################################################

function GetElementById(id, msgOnFail)
{
	if (msgOnFail == null) msgOnFail = true;
	var element = document.getElementById(id);
	Debug(element == null && msgOnFail, "Unable to locate element with id='" + id + "'");
	return element;
}


// This method can be safely run in client scripts. 
// Use instead of alert(message).
function Debug(condition, message)
{
	var href = document.location.href.toLowerCase();
	var urlDebug = href.indexOf('debugalert=1') > -1 || href.indexOf('debugalert=y') > -1;

	if (!(condition && (DebugAlert || urlDebug))) return;

	var div = null;	
	var doAlert = true;

	if (UseDebugPanel)
	{
		try
		{
			div = GetDebugPanel(); // this may fail if the document hasn't loaded fully.
			doAlert = false;
		}
		catch (e) { }
	}
	
	if (!doAlert)
	{
		div.Write(message);
	}
	else
	{
		alert(message);
	}
}

// This function is used to populate drop-down boxes.
// Parameters:
//   xmlResult ....... the parameter result from the web service.
//   selectControl ... either the id of an element in the document or the element itselft. Must be a <SELECT>.
//   itemPlural ...... a string denoting the type of item, e.g. 'funds', 'indices', etc.
function LoadOptionList(xmlResult, selectControl, itemPlural)
{
	var data = null;
	var sc = selectControl;
	
	if (sc != null && sc.options == null)
	{
		sc = GetElementById(sc);
	}

	sc.options.length = 0;

	if (xmlResult == null || xmlResult.Items == null)
	{
		return;
	}
	
	data = xmlResult.Items;
    if(selectControl.indexOf("qs")>=0)
	sc.options.add(new Option("All "+itemPlural,''), 0);
	else
	InfoFirstItem(sc, data.length, itemPlural);
	for (var i = 0; i < data.length; i++)
	{
		sc.options.add(new Option(data[i].Name, data[i].Code), sc.options.length);
	}
}

// This function can be over-ridden with a custom function as required.
function InfoFirstItem(selectControl, itemCount, itemPlural)
{
	var text = null;
	if (itemCount > 1)
	{
		text = itemCount + " " + itemPlural + " found...";
	}
	else if (itemCount < 1)
	{
		text = "0 " + itemPlural + " found!";
	}
	
	if (text != null)
	{
		selectControl.options.add(new Option(text, ""), 0)
	}
}

//####################################################################
// Test functions below this point
//####################################################################

// Used to test web service result set when result is not a string.
// If the delegate provided by a service is set to null, then either this function or the one below
// will be called. Ensure that DebugAlert is set to true to get a result.
function LoadServiceTest(r)
{
	Debug(r == null, 'LoadServiceTest: parameter "r" was unexpectedly null');
	var data = r.Items;
	if (data == null) data = r.PerfItems;
	Debug(data == null, 'LoadServiceTest: parameter "r" does not contain required property. Must contain either "Items" or "PerfItems".');
	Debug(true, 'LoadServiceTest: data.length is ' + data.length);
}

// Used to test web service result set when result is a string.
function LoadServiceTestString(r)
{
	Debug(r == null, 'LoadServiceTest: parameter "r" was unexpectedly null');
	Debug(true, 'LoadServiceTestString:\n' + r);
}

function TestSuite()
{
	var cws = new ChartingWebService();
	
	Debug(true, 'Tests are asynchronous and may not appear in order.');
	
	Debug(true, 'Testing LoadPerformance...');
	cws.LoadPerformance(null, 'FFISS,FTSENVA');
	
	Debug(true, 'Testing LoadInstruments...');
	cws.LoadInstruments(null, 'FFISS,FTSENVA');
	
	Debug(true, 'Testing LoadUnitsBySectorClassCode...');
	cws.LoadUnitsBySectorClassCode(null, 'OIC', 'U:UG');
	
	Debug(true, 'Testing LoadPerformance...');
	cws.LoadUnitsByManagerCode(null, 'OIC', 'FIDE');
	
	Debug(true, 'Testing LoadSectors...');
	cws.LoadSectors(null, 'OIC', false);

	Debug(true, 'Testing LoadSectors...');
	cws.LoadSectors(null, 'OIC', true);
	
	Debug(true, 'Testing LoadRollingDiscrete...');
	cws.LoadRollingDiscrete(null, 'FFISS', 'NASX', 'Alpha', 36, 0, 1, 12);
	
	Debug(true, 'Testing LoadRollingDiscreteRange...');
	cws.LoadRollingDiscreteRange(null, 'MinMax', 'FFISS', 'NASX', 'Alpha', 36, 0, 1, 12)
	
	Debug(true, 'Testing LoadEquities...');
	cws.LoadEquities(null, "Code LIKE 'EE%' OR Code LIKE 'F%'");
	
	Debug(true, 'Testing LoadIndices...');
	cws.LoadIndices(null, "Source='FTET' OR Source='FTVU' OR Source='MISC'");
}

//####################################################################
// Functions and methods below should not be called directly by client scripts.
// They are called via the Debug function as required.
//####################################################################

function GetDebugPanel()
{
	var div = document.getElementById('DebugPanel');
	if (div == null) 
	{
		div = new DebugPanel();
	}
	else
	{
		div = div.PanelRef;
	}
	return div;
}


function DebugPanel()
{
	var body = document.getElementsByTagName('BODY')[0];
	var div = document.createElement('DIV');
	var hdgStyle = ''
	
	div.id = 'DebugPanel';
	div.className = 'DebugPanel';
	if (!DebugPanelUseCustomStyle)
	{
		div.style.position = 'absolute';
		div.style.width = '350px';
		div.style.left = (document.body.clientWidth - 370) + 'px';
		div.style.top = '20px';
		div.style.fontFamily = 'Arial, Verdana, Sans-Serif';
		div.style.fontSize = '12px';
		div.style.display = 'block';
		div.style.border = 'solid 1px black';
		div.style.backgroundColor = '#E0E0FF';
		div.style.padding = '2px';
		hdgStyle = ' style="font-weight:bold; border-bottom: solid 1px black;"'
	}
	div.innerHTML = '<div class="DebugHeading"' + hdgStyle + '>Debug Window</div>';
	
	body.insertBefore(div, null);	
	
	this.Div = div;
	div.PanelRef = this;
}


DebugPanel.prototype.Write = function(message)
{
	var div = document.createElement('DIV');
	this.Div.insertBefore(div, null);
	div.className = 'DebugEntry';
	if (!DebugPanelUseCustomStyle)
	{
		div.style.borderBottom = 'solid 1px black';
	}
	div.innerText = message;
}

//#################################################################### 
/*****************************************************************************\

 Javascript "SOAP Client" library

 @version: 1.5 - 2006.05.23
 @author: Alan Machado
 @description: Major modifications and buffering to increase performance. Also allow for wsdl attributes
               
 @author: Matteo Casati - http://www.guru4.net/

\*****************************************************************************/

function StringBuffer() { 
   this.buffer = []; 
 } 

 StringBuffer.prototype.append = function append(str) { 
 
   this.buffer[this.buffer.length] = str; 
   return this; 
 }; 

 StringBuffer.prototype.toString = function toString() { 
   return this.buffer.join(""); 
 }; 
 
  StringBuffer.prototype.clear = function clear() { 
   this.buffer.length = 0; 
   return this.buffer
 }; 

function SOAPClientParameters()
{
	var _pl = new Array();
	var _buf = new StringBuffer();
	this.add = function(name, value) 
	{
		_pl[name] = value; 
		return this; 
	}
	
	this.toXml = function(wsdl)
	{
		_buf.clear();
		for(var p in _pl)
			if (p.substring(0,1) != "_")
				_buf.append(SOAPClientParameters._serialize(p,_pl[p],wsdl));
		return _buf.toString();	
	}
}

SOAPClientParameters._serialize = function(parentName, o,wsdl)
{
    var _buf = new StringBuffer();
    var isAttributes = false;
    
    switch(typeof(o))
    {
		  case "undefined":
				o = "";
        case "string":
            _buf.append(o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")); break;
        case "number":
        case "boolean":
            _buf.append(o.toString()); break;
        case "object":
            // Date
            if(o.constructor.toString().indexOf("function Date()") > -1)
            {
                var year = o.getFullYear().toString();
                var month = (o.getMonth() + 1).toString(); month = (month.length == 1) ? "0" + month : month;
                var date = o.getDate().toString(); date = (date.length == 1) ? "0" + date : date;
                var hours = o.getHours().toString(); hours = (hours.length == 1) ? "0" + hours : hours;
                var minutes = o.getMinutes().toString(); minutes = (minutes.length == 1) ? "0" + minutes : minutes;
                var seconds = o.getSeconds().toString(); seconds = (seconds.length == 1) ? "0" + seconds : seconds;
                var milliseconds = o.getMilliseconds().toString();
                var tzminutes = Math.abs(o.getTimezoneOffset());
                var tzhours = 0;
                while(tzminutes >= 60)
                {
                    tzhours++;
                    tzminutes -= 60;
                }
                tzminutes = (tzminutes.toString().length == 1) ? "0" + tzminutes.toString() : tzminutes.toString();
                tzhours = (tzhours.toString().length == 1) ? "0" + tzhours.toString() : tzhours.toString();
                var timezone = ((o.getTimezoneOffset() < 0) ? "+" : "-") + tzhours + ":" + tzminutes;
                _buf.append(year + "-" + month + "-" + date + "T" + hours + ":" + minutes + ":" + seconds + "." + milliseconds + timezone);
            }
            // Array
            else if(o.constructor.toString().indexOf("function Array()") > -1)
            {
                for(var p in o)
                {
                    if(!isNaN(p))   // linear array
                    {
                        (/function\s+(\w*)\s*\(/ig).exec(o[p].constructor.toString());
                        var type = RegExp.$1;
                        switch(type)
                        {
                            case "":
                                type = typeof(o[p]);
                            case "String":
                                type = "string"; break;
                            case "Number":
                                type = "int"; break;
                            case "Boolean":
                                type = "bool"; break;
                            case "Date":
                                type = "DateTime"; break;
                        }
                        _buf.append(SOAPClientParameters._serialize(type,o[p],wsdl));
                    }
                    else    // associative array
                        _buf.append(SOAPClientParameters._serialize(p,o[p],wsdl));
                }
            }
            // Object or custom function
            else
            {
				 	 str = ""
                for(var p in o)
                {
						if (p.substring(0,1) != "_")
						{
							if (SOAPClient._isAttributeTypeWsdl(p,wsdl))
							{
								isAttributes = true;
								_buf.append(p + "=\"" + SOAPClientParameters._serialize("",o[p],wsdl) + "\" ")
							}
							else
							{
								_buf.append(SOAPClientParameters._serialize(p,o[p],wsdl))
							}                
						}
					 }
				}	
            break;
        default:
				return "";
            //throw new Error(500, "SOAPClientParameters: type '" + typeof(o) + "' is not supported");
    }

	if (parentName == "") return _buf.toString();
	
	return addNodeStr(parentName,_buf.toString(),isAttributes);
}


function addNodeStr(elname,str,attributes)
{
	if (attributes == true)
		return "<" + elname + " " + str +  " />"
	else
		return "<" + elname + ">" + str + "</" + elname + ">"
}


function SOAPClient() {}

SOAPClient.invoke = function(url, method, parameters, async, callback)
{
	if(async)
		SOAPClient._loadWsdl(url, method, parameters, async, callback);
	else
		return SOAPClient._loadWsdl(url, method, parameters, async, callback);
}

// private: wsdl cache
SOAPClient_cacheWsdl = new Array();

// private: invoke async
SOAPClient._loadWsdl = function(url, method, parameters, async, callback)
{
	// load from cache?
	var wsdl = SOAPClient_cacheWsdl[url];
	if(wsdl + "" != "" && wsdl + "" != "undefined")
		return SOAPClient._sendSoapRequest(url, method, parameters, async, callback, wsdl);
	// get wsdl
	var xmlHttp = SOAPClient._getXmlHttp();
	xmlHttp.open("GET", url + "?wsdl", async);
	if(async) 
	{
		xmlHttp.onreadystatechange = function() 
		{
			if(xmlHttp.readyState == 4)
				SOAPClient._onLoadWsdl(url, method, parameters, async, callback, xmlHttp);
		}
	}
	xmlHttp.send(null);
	if (!async)
		return SOAPClient._onLoadWsdl(url, method, parameters, async, callback, xmlHttp);
}
SOAPClient._onLoadWsdl = function(url, method, parameters, async, callback, req)
{
	var wsdl = req.responseXML;
	SOAPClient_cacheWsdl[url] = wsdl;	// save a copy in cache
	return SOAPClient._sendSoapRequest(url, method, parameters, async, callback, wsdl);
}
SOAPClient._sendSoapRequest = function(url, method, parameters, async, callback, wsdl)
{
	// get namespace
	var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;
	// build SOAP request

	var sr = 
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
				"<soap:Envelope " +
				"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
				"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
				"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
				"<soap:Body>" +
				"<" + method + " xmlns=\"" + ns + "\">" +
				parameters.toXml(wsdl) +
				"</" + method + "></soap:Body></soap:Envelope>";
	// send request

	var xmlHttp = SOAPClient._getXmlHttp();
	xmlHttp.open("POST", url, async);
	var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + method;
	xmlHttp.setRequestHeader("SOAPAction", soapaction);
	xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	if(async) 
	{
		xmlHttp.onreadystatechange = function() 
		{
			if(xmlHttp.readyState == 4)
				SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
		}
	}
	xmlHttp.send(sr);
	if (!async)
		return SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
}
SOAPClient._onSendSoapRequest = function(method, async, callback, wsdl, req)
{
	var o = null;
	var nd = SOAPClient._getElementsByTagName(req.responseXML, method + "Result");
	if(nd.length == 0)
	{
		if(req.responseXML.getElementsByTagName("faultcode").length > 0)
			throw new Error(500, req.responseXML.getElementsByTagName("faultstring")[0].childNodes[0].nodeValue);
	}
	else
		o = SOAPClient._soapresult2object(nd[0], wsdl);
	if(callback)
		callback(o, req.responseXML);
	if(!async)
		return o;		
}

// private: utils
SOAPClient._getElementsByTagName = function(document, tagName)
{
	try
	{
		// trying to get node omitting any namespaces (latest versions of MSXML.XMLDocument)
		return document.selectNodes(".//*[local-name()=\""+ tagName +"\"]");
	}
	catch (ex) {}
	// old XML parser support
	return document.getElementsByTagName(tagName);
}

SOAPClient._soapresult2object = function(node, wsdl)
{
	return SOAPClient._node2object(node, wsdl);
}
SOAPClient._node2object = function(node, wsdl)
{
 // var obj = new Object()

/* Node Types
	ELEMENT_NODE = 1 
	ATTRIBUTE_NODE = 2 
	TEXT_NODE = 3 
	CDATA_SECTION_NODE = 4 
	ENTITY_REFERENCE_NODE = 5 
	ENTITY_NODE = 6 
	PROCESSING_INSTRUCTION_NODE = 7 
	COMMENT_NODE = 8 
	DOCUMENT_NODE = 9 
	DOCUMENT_TYPE_NODE = 10 
	DOCUMENT_FRAGMENT_NODE = 11 
	NOTATION_NODE = 12 
*/
	// null node
	if(node == null)
		return null;
	if(node.nodeType == 2) 
		return SOAPClient._extractValue(node.nodeName,node.nodeValue, wsdl);
	if(node.nodeType == 3 || node.nodeType == 4)
	{
		return SOAPClient._extractValue(node.parentNode.nodeName,node.nodeValue, wsdl);
	}
	
	var obj = eval("new function "+node.nodeName+"(){}");
		
	// leaf node
	if (node.childNodes.length == 1 && (node.childNodes[0].nodeType == 3 || node.childNodes[0].nodeType == 4))
		obj = SOAPClient._node2object(node.childNodes[0], wsdl);
		
	var isarray = SOAPClient._getDataTypeFromWsdl(node.nodeName, wsdl).toLowerCase().indexOf("arrayof") != -1;
	// object node
	if(!isarray)
	{
		for(var i = 0; i < node.childNodes.length; i++)
		{
			var p = SOAPClient._node2object(node.childNodes[i], wsdl);
			obj[node.childNodes[i].nodeName] = p;
		}

	}
	// list node
	else
	{
		// create node ref
		var arr = new Array();
		for(var i = 0; i < node.childNodes.length; i++)
			arr[arr.length] = SOAPClient._node2object(node.childNodes[i], wsdl);
		return arr;
	}
			// attributes and no text
	if(node.attributes != null)
	{
		for(var i = 0; i < node.attributes.length; i++)
		{
			var p = SOAPClient._node2object(node.attributes[i], wsdl);
			obj[node.attributes[i].nodeName] = p;
		}
	}
	return obj;
}


SOAPClient._extractValue = function(nodeName,nodeValue, wsdl)
{
	var value = nodeValue;
	switch(SOAPClient._getDataTypeFromWsdl(nodeName, wsdl).toLowerCase())
	{
		default:
		case "s:string":			
			return (value != null) ? value + "" : "";
		case "s:boolean":
			return value+"" == "true";
		case "s:int":
		case "s:long":
			return (value != null) ? parseInt(value + "", 10) : 0;
		case "s:double":
			return (value != null) ? parseFloat(value + "") : 0;
		case "s:datetime":
			if(value == null)
				return null;
			else
			{
				value = value + "";
				value = value.substring(0, value.lastIndexOf("."));
				value = value.replace(/T/gi," ");
				value = value.replace(/-/gi,"/");
				var d = new Date();
				d.setTime(Date.parse(value));										
				return d;				
			}
	}
}

var wsdlNodeBuff = []
SOAPClient._getDataTypeFromWsdl = function(elementname, wsdl)
{
   if (wsdlNodeBuff[elementname] == null)
   {
		wsdlNodeBuff[elementname] = getWsdlNode(elementname,wsdl)
	}
	
	node = wsdlNodeBuff[elementname]

	if (node == null)
	{
		return "";
	}

	type = node.attributes.getNamedItem("type").nodeValue; // IE
	if (type == "")
		type = node.attributes["type"].value; // MOZ
	return type
	
}

SOAPClient._isAttributeTypeWsdl = function(elementname, wsdl)
{
   if (wsdlNodeBuff[elementname] == null)
   {
		wsdlNodeBuff[elementname] = getWsdlNode(elementname,wsdl)
	}
	
	node = wsdlNodeBuff[elementname]

	if (node == null)
	{
		return false;
	}

	return (node.nodeName.indexOf("attribute") >= 0); 
	
}

function getWsdlNode(elementname, wsdl)
{
		
	var el = wsdl.getElementsByTagName("s:element");	// IE
	if(el.length == 0)
	{
		el = wsdl.getElementsByTagName("element");	// MOZ
	}
	
	var result;
	for(var i = 0; i < el.length; i++)
	{
		if(isRequiredWsdl(el[i],elementname))
			return el[i];
	}

	var el = wsdl.getElementsByTagName("s:attribute");	// IE
	if(el.length == 0)
		el = wsdl.getElementsByTagName("attribute");	// MOZ
	
	for(var i = 0; i < el.length; i++)
	{
		if(isRequiredWsdl(el[i],elementname))
			return el[i];
	}
	
	return null;	
	
}

function isRequiredWsdl(el,elname)
{
	if(el.attributes["name"] + "" == "undefined")	// IE
	{
		if(el.attributes.getNamedItem("name") != null && el.attributes.getNamedItem("name").nodeValue == elname && el.attributes.getNamedItem("type") != null) 
		{
			return  true;
		}
	}
	else // MOZ
	{
		if(el.attributes["name"] != null && el.attributes["name"].value == elname && el.attributes["type"] != null)
		{
			return true;
		}
	}
	return false;
}

function IsRequiredElement(el,elname)
{
	if(el.attributes["name"] + "" == "undefined")	// IE
	{
		if(el.attributes.getNamedItem("name") != null && el.attributes.getNamedItem("name").nodeValue == elname && el.attributes.getNamedItem("type") != null) 
		{
			return  el.attributes.getNamedItem("type").nodeValue;
		}
	}
	else // moz
	{
		if(el.attributes["name"] != null && el.attributes["name"].value == elname && el.attributes["type"] != null)
		{
			return el.attributes["type"].value;
		}
	}
	
	return "";
}

// private: xmlhttp factory
SOAPClient._getXmlHttp = function() 
{
	try
	{
		if(window.XMLHttpRequest) 
		{
			var req = new XMLHttpRequest();
			// some versions of Moz do not support the readyState property and the onreadystate event so we patch it!
			if(req.readyState == null) 
			{
				req.readyState = 1;
				req.addEventListener("load", 
									function() 
									{
										req.readyState = 4;
										if(typeof req.onreadystatechange == "function")
											req.onreadystatechange();
									},
									false);
			}
			return req;
		}
		if(window.ActiveXObject) 
			return new ActiveXObject(SOAPClient._getXmlHttpProgID());
	}
	catch (ex) {}
	throw new Error("Your browser does not support XmlHttp objects");
}
SOAPClient._getXmlHttpProgID = function()
{
	if(SOAPClient._getXmlHttpProgID.progid)
		return SOAPClient._getXmlHttpProgID.progid;
	var progids = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
	var o;
	for(var i = 0; i < progids.length; i++)
	{
		try
		{
			o = new ActiveXObject(progids[i]);
			return SOAPClient._getXmlHttpProgID.progid = progids[i];
		}
		catch (ex) {};
	}
	throw new Error("Could not find an installed XML parser");
}

 
 //Start DrawMap
 function RenderMapArea(siteid,span)
   {
    var areaArray=[];
    var areaName=[];
    span=span.replace('m','');
   if(siteid=="TNO")
   {
   //Array For storing area tag coordinates	
 
    areaArray[0]="72,97.25,72.75,96.75,73.5,95.75,74.5,95,74.75,94,75.25,93,75.5,92.25,76.5,91.25,77,90.5,78,89.75,78,88.5,78.75,87.5,78.75,86,78.5,85.5,78.25,84.75,77.75,84,77.25,82.75,76.75,81.75,76.75,81.5,76.75,80.75,77.25,80.5,78,80,78.25,79.25,78.25,78,78.5,77.25,78.5,76.5,78.5,75.75,78.5,74.25,78,74.5,77.5,74.75,77,75.25,77,76.25,76.25,77.75,76,78.5,75.25,78.5,74.75,78.5,74,77.5,74,76,74.25,74.75,74.25,73.5,75,72.5,76,72.5,76.5,71.5,76.5,70.5,76.5,69.75,76.5,68.5,76.5,67,77,65,77,63.75,76.25,63.25,75,62.25,74,61.25,74.75,61,75.75,59.75,76.75,58.25,78,57.25,79.75,56.5,80.75,55.75,82,54.75,83.5,53.25,85.5,51.5,87,49.75,88.25,48.25,88.75,47.25,90.25,46,92,45,93.5,43.5,94.75,41.25,97.25,40.5,98.5,40.75,99.5,41.25,101,41.25,102,41.75,103.5,42.5,104.75,42.25,107,42,109.25,42,111.25,41.75,112.75,41,114.5,40.75,116.5,40.5,117.75,40.25,119.25,39.75,120.75,39.75,121,41,122.25,40.75,124,40.25,125,40.5,126.5,41,127.75,41,128.5,41.5,130,42,131.75,43,132.5,43,133.25,42.5,133.25,41.75,132.75,41.25,133.5,40.25,134.5,40.25,133.75,39.75,134,38.75,134.25,38.5,133.25,38.5,132.25,38.75,130.75,38.75,129.5,38.75,127.75,38.75,126.75,38.25,127.5,37.5,127.25,36.75,128.25,36.25,129,35.5,130,34.5,131.75,34.25,132.75,34,133.75,33.75,133.75,32.75,134.5,32.5,135.75,32.5,137.25,32.5,139,32.5,140.25,32.5,141.25,32.75,141.75,32.5,143.25,32.5,144.75,33.25,145.5,34.25,146,35.5,145.5,35.75,146.75,35.25,147.75,35.25,148.5,35.5,149.25,35.75,150.25,35.25,151.25,35.25,152,35.5,153,35.25,153.5,34.75,154.25,34.5,155.5,34.25,156.75,34.25,157.5,33.5,158.75,33.5,160,33.75,160.25,34.5,159,35.75,158,36.25,157,36.75,156.75,37.25,155.75,38,155.75,39,156.25,39.75,157.25,40,157.5,40.75,158.5,41,159.5,41,162,41,163,41,163.5,40.75,164,40,164.75,38.75,162.75,39,161.75,38.25,161.75,37.5,161,37.5,160.75,37,160.25,36.5,160.25,36,160.25,35.5,161,35.25,161.75,34.75,162.75,34.75,163.25,33.75,164,33.75,165,33.5,166,33.25,167,33,168,32,168.25,31.75,168.5,31,167.5,31,166.5,31,165.5,30.75,165.5,30.25,165.75,29.25,166.5,28.5,166.5,27.75,167.25,27.25,168.25,27.25,169,27.5,169.5,28.5,171,28,171.25,27.5,171,27.25,170.5,26.75,170.5,26.25,170.25,25.25,171.25,24.5,172.25,24.25,173.5,24.25,174.75,24.25,176,24,176.75,24.75,177.75,25.75,178.75,26,179.5,25.25,180.25,25,180,24.25,179.5,23.25,180.5,22.75,182,22.75,182.75,23.5,182.5,24,182.75,25,183.75,25,184,23.5,184,22.75,184.5,22.5,186.25,22.25,188.5,21.5,190.25,21.25,192,21.25,193.25,21.25,194.5,21.25,195.75,20.25,197.5,20.25,200,20.25,201,20,203.75,20,206.25,19.75,208.5,19.25,210.5,18.5,213,18.75,214.75,18.75,216,18.75,218.5,18.5,219.75,18.5,223,18.75,224.75,18.75,228,19.25,230,19,230.75,19,233,19.5,232.75,20,231.5,20,230.5,20.5,229.5,21,228,21.25,227,21.5,225.25,22.5,223.75,22.5,222,22.5,221,23,220,23.25,219.5,23.25,218.5,23.75,216.5,24,215,24.5,212.5,25.5,211.25,25.5,210,25.5,209.5,26.5,209,26.75,207.75,27.25,207.25,27.5,205.5,27.5,203.75,28,202.75,29,201.75,29.75,200.75,29.75,200.5,30.75,200.25,30.75,198.25,32,198,32.5,197.25,32.5,195.5,33,196.75,33.25,197.75,33.5,198.5,35.25,198.75,36,199.75,36.5,200.5,37,201.5,37.75,202.25,38.5,203.75,39,204.75,39,206,39.25,206.75,41,206.75,42.25,206.5,43.5,205.75,43.5,206,44.25,207.25,44.5,208.25,44.5,209.25,45.25,210.5,46.25,211.5,47.5,210.75,48.5,210,48.5,209,49.5,207.5,49.75,206.5,50.75,206.25,51.25,205.75,51.25,205.25,51.5,203.75,50.75,203.5,50.5,203.25,49.75,202.5,48.5,201.75,48.5,201,49,201,50,201.5,51,202.75,51,203,52.25,203.5,53.75,203,55,202.75,55,202.5,55,201.75,55.5,202,56.5,201.25,57,200.25,57,200,58.75,198.75,58.5,197.75,58.25,196.25,57,195.25,56.75,194,56,192.75,56,192,56,190.75,55.5,190,53.5,189,52.25,188.5,52.25,187.25,52.25,185.25,52.25,184.5,52.25,184,53,184.25,54.75,183.5,54.5,182.5,54.5,181,54.5,180.25,54.5,180.25,53.75,180.75,53.5,181.5,53,182.5,52.25,182.5,51.75,183.25,50.75,183.75,50.25,184.25,50,184.75,49.75,186.25,49.75,187.5,49.75,188.75,49.75,189.75,49.5,191.25,49.25,190.25,48.75,191.25,47.75,192.25,47.25,192.75,46.5,193.5,45.5,192.25,45.5,191,46.25,189.25,46.25,187.75,46.25,187.75,45.5,188,45,189.5,44.5,189.75,43.75,190.25,43.25,189.25,43,188.25,43.5,187,44.5,185.75,44.75,185.75,44,186,43.5,186.25,42.75,185.5,42,184.5,42,184.5,42.75,184.5,43.75,183.75,44.25,182.5,44.25,182.75,45.25,182.75,46,182.25,47,180.75,47.5,180,47.75,178,48,176.5,48.25,177,49.5,176.75,50.25,177.5,51,178,51.75,179,52.75,179,53.75,177.5,54.25,176.25,54.25,175.5,53.75,174.75,53.5,173.75,52.75,172.75,53.25,173.25,54.25,174.75,54.25,174.5,56.25,172.75,56.5,172,57.25,171,57,170,57,169.75,55.75,168.75,55.5,167.75,54.75,166.25,54.25,166.25,53.75,167.5,53.25,169,53.25,170.5,52.25,171,51.25,171,50.25,173.5,49.25,174,48.75,175.25,47.5,174,47.5,173,47.25,173.5,47,173.5,46.25,174,46,174.75,46,175.25,45.5,175.75,44.5,176.5,43.75,177.25,43.5,177.75,42.5,177.5,41.5,176.5,41.25,176,40.75,175.5,39.5,175.5,39,176,38.25,176,37.75,176.5,37.25,177.75,36.25,178.75,35.5,179.5,35.25,180.75,34.75,182,34.5,182.75,34.5,184.5,34,185.25,34,186.75,34,188.5,34,189.75,34,190.75,34,191.75,34,194,34,195,33.75,194.25,33.25,193.25,33,192,32.75,191,32.75,190,32.75,188,32.75,186.5,32.75,185.25,32.75,184.25,32.75,183.25,32.75,182.5,32.75,182.25,33.5,181.75,33.75,180.75,33.75,180,33.75,178.75,34.5,177,35.5,176.25,36,175.75,36.5,174.75,36.25,173.75,36.25,172.75,36.25,172.25,36.75,171.75,37.5,171.25,37.5,171.75,38.5,171.75,39.5,171.75,40.25,172.5,41.25,173.5,42.25,174.75,43,174,44,172.5,44.75,173,46,172.75,46.5,172.75,47.5,172.5,48.5,172.25,49,171.5,49.25,170.75,49.25,170.25,49.75,170.25,50.75,169.5,50.75,169,51.25,168.5,51.75,168,51.75,167.25,52.75,166.5,53,165.5,53.75,163.75,53.75,163.25,53.75,162,53.75,161.75,54.75,160.75,55.5,160.25,55.5,158.75,55.75,157.75,56,156.75,56.5,155.5,57.5,155,58,154,58.25,153.75,58.25,153.25,59,152.25,59.75,151.25,60,150.25,61.25,149.5,62,149.25,63,150.75,63,150.75,64,150.75,65.75,152.25,66.25,153,66.75,153.75,67,155.25,67.5,156.75,68.75,157.5,69.75,158.75,70.5,159.5,70.5,161,70.5,162.25,70.5,163.25,71.25,163.75,72.25,162.75,73.25,162,74.75,163.75,74.5,163.25,76.25,163,77,162,76.75,161.25,76.75,161.75,78,162.75,78.5,163.25,77.75,163.75,77.25,165.25,77.25,165.75,76.75,166.5,75.25,166.75,73.25,167,72.5,167.25,72,167.25,71.5,169,70.75,169.25,70.5,168.25,70.25,167.75,70,167.75,69.75,167.75,69.25,168,69,169,68,169,67.5,169.75,67,170.5,68,171.5,68.5,170.75,69.5,172.25,69.75,173,69,173.25,68.25,174.25,68,174.5,67.25,174.75,66.5,174.75,66,174.5,65,174,64.25,173.75,63.75,173.75,63,172.75,62.5,172,62.25,172.25,61.25,173,60.75,174,60.75,174.25,62,175.5,61.75,177,60.75,177,60.25,176.5,59.25,176.25,58.75,175.25,58.5,175,58,175,57.25,175.5,55.75,176.5,55.25,178,55.25,178.75,56,180,55.25,181,55.5,182.5,55.5,184.5,56,185.75,56,187,55.5,188.25,56.25,189.25,58,190.25,58.5,191.5,58.5,192.5,59.5,193.75,59.5,194.75,59.75,193.75,60.75,193,61.5,192.25,61.5,192,61.25,191.25,60.5,191,61.25,190.5,61.75,191,62.75,192.25,63.75,193.25,63.25,193.75,62.5,194.75,62,196.25,61.25,197,60,198.25,59.75,199,59.5,199.5,60.75,199.75,62,200,63.25,200.25,65,201,65.5,201,66.5,201,67.75,200,68.75,201.25,70,202,70.75,203,71,204,71.25,205,72.25,204.75,73.5,205.75,74.25,206.25,75.5,206.25,77,205.75,79,205.5,79.75,205,81,203.75,81.25,203.5,82.25,204.75,82.75,206,82.75,207,83.25,207.25,84.5,207.5,86.75,207.5,89,206.75,89.5,206.5,90.25,205.75,90.75,205,90.75,203.75,90.5,202.5,89.5,202,90,201,90,200,89.75,198.75,89.75,198.75,89.25,198.25,88.75,197.25,88.75,196.25,88.75,194.75,88.75,194.25,88.25,194.25,87.5,194.5,86.75,195.25,86,195.75,85.5,196.25,84.75,197.25,84,197.5,83.5,198,82.75,198.5,82.25,199.25,81.75,199.5,81.25,200,80.5,199,80.75,197.75,81.25,196.25,81.75,195,82.25,194.25,82.25,193,82.25,192,82.25,191.5,82.75,192.75,83.75,192.5,84.5,191.75,84.75,190.5,84.75,189.25,84.75,188.5,84.75,187.75,83.25,186.75,82.5,186.25,82.5,184.75,83,184.25,83.25,186,84,187,84,188,85.25,187.75,86,187,86.5,186.25,87,186.75,87.75,186.25,88.25,186.5,89,187.25,89.75,188.25,89.75,189,89,189,87.75,190,87.25,192,87.5,192.5,88.5,193.25,89,193.5,89.75,193.25,91,193.25,92.5,192,93,191,93.5,190,94,188.5,94.25,187,94.5,185.75,95,185,93.75,184.5,92.75,184,92.25,183,91.75,182.5,91.5,181.25,91.5,181,91.5,180.25,92.25,179.5,91.5,180,90.75,180.25,90.5,180.25,90,180.25,89,180.25,87.75,180.25,87.25,180.25,87,180.25,86.25,180.75,85.75,181.75,85.5,181.75,84.75,181,84.25,180.25,84.25,179.75,84.25,179,84.75,178.25,85.5,177.75,85.5,176.75,85.5,175.75,85,174.5,85,173.5,85,172.75,85,172,85,171.25,84.75,169.5,84.5,168.75,85,168.5,86.25,167.75,86.25,167.5,86.5,166.5,86.75,165.5,86.75,165,87.75,164.25,88.25,163,88.75,161.25,89.75,160,90,158.75,90.25,156.75,90,155.5,88.75,155.25,88,154.25,87.5,153.25,86.5,152.5,86,151.75,85.75,151,85.75,150.25,85.75,149.5,85.75,148.25,85.75,147.25,85.75,145.5,85.5,144.25,85.25,143.5,85.25,142,84.75,140.75,84.5,138.75,84.25,137,84.25,136,84.5,135.25,85.25,134,86.25,132.75,88,131.75,88.75,131,89.25,130.5,89.5,130,90,129.25,90,128.75,90,128,90,127.5,89.75,126.25,90.25,125,91.25,124.25,91.75,123.25,91.75,122.5,91.5,121,91.5,120.75,91.5,120,91.5,119.25,91.5,118.25,91.5,117.75,91.5,116,91.25,114.5,91.25,113.75,91,112.75,91,112,91,110.5,91,108.75,91,107.5,91,106.5,91,105.5,91,104.75,90.75,103.5,90.75,102,90.75,100.75,91.25,99.5,91.25,98.5,91.75,98,92,97.75,92,96.75,92,95,92,93.5,92,92.25,92,90.75,92,90,92.75,88.25,93.5,87.5,94.25,86.25,95,85,95,84.25,94.5,83,94.5,82,94.5,81.75,95.5,81,95.75,80,96,79.25,96,78,96,77.5,96.5,77.25,96.5,76.5,96.75,75.5,97,74.5,97.5,73.75,97.5,72.75,97.5";
    areaArray[1]="161.75,32,161,32.25,160.25,32.25,160,32.25,159.25,32.5,158.5,32.5,157.75,32.5,157.5,32.5,157,32.5,156.25,32.5,155.75,32.5,155,33,154.25,33,153.5,33.25,152.75,33.25,151.75,33.25,150.5,33.75,149.5,33.75,148.5,33.5,148.25,33.25,147.75,33,147.25,32.75,146.75,32.5,146.25,32.25,145.5,32.25,145.25,32.25,144.75,31.5,144.25,31.5,144,31.5,143.5,31.5,143,31.5,142.25,31,141.5,31,141,30.75,140.5,30.5,140.5,29.75,141.25,29,142.5,29,143.75,29,144.5,28.75,145.5,28.75,146.25,28.25,147.25,27.75,148,27.5,149.75,27.25,150.75,27.25,152.75,27.25,154,27.25,155,27.75,154.75,28,154,28.25,153.25,28.75,154.25,29.25,155,29.25,156,29.25,156,30,157,30.5,157.25,29.75,157.5,29.25,158,28.5,157.75,28,157.75,27.25,158,27,158.5,26.5,159.25,26.25,160,26.25,160,25.75,160.25,25.5,160.5,25.25,161.75,25.25,162.5,25.25,163.5,25.25,164.75,25.25,165.5,25.75,165,26.25,164.75,26.75,164.5,26.75,163.5,27.5,162.75,27.5,162.5,27.75,162,28.25,161,28.25,160,28.25,159,28.25,158.75,29.25,159.5,29.25,160.25,29.25,160.75,29,162,29.75,162.75,29.75,163.75,29.75,164.5,30.75,165.25,31.25,165,32.25,164.25,32.25,163,32.25";
    areaArray[2]="530,82.75,528.75,81.75,527.75,82.25,526.75,82.25,525.5,82.25,524.75,82.25,524.5,82.25,524,82.25,522,82,521.5,81.5,519.75,80.25,518.5,79.75,517,79.25,515,78.25,513.75,77.5,511.25,76.5,510,76.5,508.75,76.5,507.25,76.25,506.75,76,504.75,76,503.5,76,502,75.5,501,75.5,498.75,75.5,498,75.5,496.5,76,495.5,76.5,494.5,77.25,493.25,77.75,491.75,78.25,489.75,79.25,489,79.75,487.25,79.75,486.25,81,485,81.5,485,82.75,484.75,83.5,484.5,84.5,484.25,85,484,85.75,483.25,86.5,482.75,86.75,482,87.75,481.25,88.25,480.5,88.75,480.25,89.25,480,89.5,479.75,90.25,479.5,90.75,479,91.5,479,92.75,478.75,93.25,478.5,94,478.5,94.75,478.5,95.75,477.5,97.25,477.5,98,476.5,96.5,476,95.25,475.5,94,475,93.75,474.25,93.75,474,93.75,473,94.25,472.25,94.25,471.75,94.25,471.25,94,469.75,94,469.25,94,467,94,466.25,94,465.75,94,464.75,94,463.75,93.75,462.75,93.75,461,93.5,461,93,460.5,92,460,91.25,458.5,90,458.5,89,458.5,88.5,458,88,457.5,87.5,456.75,86.25,456.5,86.25,456,86,455.5,85.5,455.25,85,454.25,85,453.5,84.5,453,84.5,451.75,84,451.25,84,451,84,449.5,84.75,448.5,84.75,448,84.75,447.5,84.75,447,84.25,445.75,83.75,445.25,83.75,445,83.75,444,83.75,443.5,83.75,443,83.75,442.5,84,440.75,84.25,439.5,84.25,439.25,84.25,438.5,84.25,438.25,84.25,437.25,84.25,435.25,84.25,433.5,83.75,432.75,83.75,432.5,83.75,431.5,83.75,430.25,83.75,429.5,82.25,428.75,82.25,428,82.25,427.5,82,427,82,426.5,81.5,425.5,82.5,424,83,423.5,83,423,82.75,420.75,81.75,418.75,81.25,417.5,80.75,414.75,79.75,413.75,79.75,413,79.75,412.5,79.75,411,79.75,410.25,79.75,409.5,79.75,408.5,79.5,406.5,80.25,406,80.25,405.75,81,404.75,81,403.5,80.75,402.25,79.75,401.75,79.25,400.5,79,400,78.5,399.25,78.25,398.75,78,398,78,397,78,396.25,77.75,395.5,77.75,394.5,77.75,394,77.75,393,77.25,392.25,77.25,391.5,77.25,391,77.25,391,77,390.25,77,390,77,389.5,77,389,77.5,388.25,77.75,388.25,79.25,387.75,80,387.5,80.5,386.75,81.25,387,82,387.25,83.75,387.25,85.25,387.25,86.25,387,87.5,386.25,89,385,90,383.5,89.75,382.75,89.75,381.75,88.75,380.75,88.75,380,88.75,379.5,88.75,378.75,88.75,378,88.75,377.5,88.5,378.25,89.75,379,90.75,380.5,91.75,381.75,93.5,383.75,94.25,384.25,94,384.75,94.75,386,95.25,386.5,97,387,98.25,386.75,98.5,385.75,98.5,385,98.5,383.25,98.75,382,98.75,381,98.5,379.25,98.5,378,98.75,376.75,98.75,376,99,375.25,98.25,375.25,97.5,374.75,97,374.5,96.5,373.25,95.75,371.75,95,370.5,94,369.75,92.5,369.5,91,369,90,369,89.25,369,89,368.25,89,366.75,88.5,365.75,88.25,364.75,88.25,364.5,88.25,363.75,87.75,362.75,87,362.25,86.25,361.25,85,361.25,83.75,360.75,83,360.25,81.75,359,81,359,80,358.75,79.5,358,78.5,357.5,78,357,77.75,356,77.75,354.75,77.75,353.75,78.25,353.5,78.75,352.75,78.5,352.25,78.25,351.75,77.5,351,76.75,350.75,76.5,350,76,349.5,75.5,349.5,74.75,348.75,73.75,348.75,73.25,348.75,72.75,348.75,71.75,348.75,70.75,348.25,69.75,348.25,68.75,347.75,67,347.25,66.25,347.25,64.5,347.25,63.25,347.5,62,347.5,61.5,347.75,61.25,348.25,61,348.5,60.75,348.25,60.5,347.5,59.75,347.5,59.5,347.5,58,347.5,56.25,347.5,55,347.5,54.5,347.5,52.5,348,51.5,348,50.5,348,49.25,348,48.75,348,47.25,348.25,45.75,348.75,45.5,348.75,44,349.5,42.5,350,41.25,350,41,351,41,352.25,41.5,353,41.5,353.75,41.5,354.75,41.5,355.5,41.75,356.25,41.75,357.5,42.5,358.5,42.25,359.5,42.75,360.75,42.75,362,43.5,362.75,44,364.25,44.5,365.75,46,366,47.25,364.5,48.25,362.5,48.5,362,49,361.25,49,360.25,48.75,359.25,48.75,357.75,48.5,356.5,48.25,355.25,48,353.25,47,355,47.75,356.75,49.25,357.75,49.75,358.5,49.75,360.25,49.75,361.75,50.25,363.25,50,364,49.5,364.75,49,365.25,48.5,367,46.75,367.5,46.5,368,46,368,44.75,367.25,44.75,366.75,43.75,366.75,43,367.5,42.75,368.5,42.75,369.5,43,370.25,43,372.5,44,372.5,45.25,371.75,45.25,370.75,45.75,373.5,45.75,374.25,45.25,375.5,44.25,374.25,44,373.5,43.25,373.5,42,373.5,41.5,375.75,41.5,376.75,41.5,376.75,42.25,377.25,43,378,43.5,379,43,380.75,43,382,42.5,383,42.5,384.25,42.5,385.25,42.75,386.75,42.75,388.25,42.75,389.5,42.75,390.75,42.5,390.25,42,389.5,42,388.5,42.25,387.25,41,387.25,40,388,39,389,38.75,390.25,38.75,391,39.25,391.5,40,392.5,40.5,394,40.5,395.25,41,396.25,41,398,41.5,398.75,41.75,400.75,42.25,401.5,42.25,402.5,42.25,403.25,42.5,401.75,41.5,401,40.75,399.75,39.75,398.75,39,398.25,37.75,398.75,36.75,400,35.75,401,34.25,402,34.25,404,35,405.25,35,406.25,36.5,406.5,37.5,406.5,38.5,407.5,39,408.25,40.5,408.75,41.25,410,42.25,411.5,43.75,411.75,45.25,413.5,45.25,413.5,44.5,413,43.25,412.5,42.5,411.75,42.5,411.25,42,411,41.25,409.75,40.25,409,39,408,38,408,37.75,409,36.75,409,35.75,408,35.25,408,34.5,408.25,33.75,409.5,33.75,411,33.75,411.75,34,413.25,35,414.25,36,416,36.75,417.75,37,419.75,37,418.75,36.5,418,36.25,417.25,36,416.5,34.75,416,34.75,415.25,33.5,415.25,33,416.25,32.5,417.5,32.5,419.25,32.5,420.25,32.5,420.75,31.5,421.75,31.5,423.75,31,425.75,30.5,427.25,30,429.25,30,430,29.5,432.75,29,433.5,29,435.25,29,436.25,28.75,437.25,28.25,437.5,27.5,436.75,27,435.5,27,434.5,27.25,433.5,27.25,432.5,26.25,431,25.75,429.5,26.5,428.25,26,426.5,26,426,26,424.75,25.25,423.25,25.25,422.25,25.25,421,24.75,419.75,24.5,419,23.25,419,22.5,419,21.5,420,20.25,420.25,18.75,421.5,18.25,423.25,18.5,423.75,20,424.75,20.25,426,20.75,427.5,21.25,429,22.25,430.5,23.5,433.25,23.75,435,23.5,435.75,23.5,437.5,23.5,439,24,440.75,24.75,442.75,25.25,443.75,26,444.75,27,446.75,27,448.25,27.5,450.25,27,452.5,27.5,454.75,28,456.5,29,457.75,30.5,459.5,31.25,459,32.25,458,32.25,456.5,33,455.25,33.5,458,33.5,459.5,33.25,460.25,33.25,462,33.25,463.25,33.5,464.75,33.5,466.25,33.5,467.5,33.5,469,34,470.5,34.75,472.25,34.75,474.5,34.75,475,33.5,476.5,33.25,478.25,33.25,480.5,33.25,483.75,33.25,484.75,34.25,487,36.25,489.5,36.75,490.75,37,493,37,495.25,37,497.25,37,498.75,37,499.5,37,499,36,497.75,35.5,497,34.75,496.25,33.75,495,33.25,494.25,33.25,493.25,33.25,492.5,34,490.5,35.25,489.25,34.25,489.25,33.5,488.5,32.75,487.5,31.75,487.5,31,487.5,30.25,488.5,28.75,489.5,28.75,490.5,28.75,491.75,28.75,493.5,28.5,496.5,29,498.25,30,499.5,29.75,501,29,502.5,29.5,503.5,29.5,504.5,29.5,505.75,30,508,30,509.25,30.5,510.25,32.25,509.25,32.75,507.75,32.75,504,32.75,502.25,32.5,501.5,32.5,500.75,32.5,499,32.5,498.5,32.5,499.75,33,500.75,33.5,502.25,33.25,503,33.75,503.75,33.75,504.5,34.25,506,34.25,507.5,35,508.75,35,509.5,35.5,510.75,35.5,512.25,35.75,513.75,36.25,516,36.5,518,37.75,519.75,38,521.75,38,523.75,38,525,37.75,527.25,37.75,530,37.75,531.75,38,534.5,38.75,536,40.25,539.5,40.25,541.25,40,543,39.5,545,39.75,547.25,40,549.25,40.25,551.75,40.25,552.5,39.75,554.75,39.75,556.5,40,558.25,40,560.5,40.75,562.5,40.75,565.75,40.75,567,41.25,569.25,41.25,572.25,42,574.25,42.5,575.75,43.75,579,44.5,581.5,46,585.5,45.5,587.75,46.75,590.5,46,591.5,47.75,591.25,50,591.75,51.5,591.75,53.25,590.75,53.25,589.25,52.75,587.25,52.5,585.5,52.25,584.25,52,583.75,52,582.5,50.75,581.5,50.75,580,50.75,579.5,50.75,578.75,50.75,578.25,51.75,579,51.75,579.25,52.75,580.5,53,581.5,53,584,53.75,585,55.75,584.5,57,583.25,57.75,582.25,57.75,579.75,57.75,579.25,57.75,577.5,58.5,577.5,59.5,577.25,60.5,577.25,62,576.75,63,575.75,63,574.5,62.75,573.75,62.25,572.75,62,572,61.75,571,61.25,570.25,61.75,569.5,63.25,569.5,65.5,570.75,66,572.5,68.5,573.75,69,573.75,70.25,574.5,71.5,575.25,73,575.25,74,574,74,574.75,75,575.5,76.25,574,76.75,574.5,77.75,574.5,78.75,574.5,80.25,574.25,81.25,573.5,82.25,573.25,83,573.25,84.75,573,84.75,573,87.5,573,89.25,572,89.75,571.25,91,570.5,92.5,569.5,93.5,569,93.5,567.75,94.5,567,95.75,567.25,97,566.5,97.25,565.75,97.25,565,97.25,564,97.25,563.75,97.25,563,96.5,563.75,96.5,564,95.5,563.25,95,564.25,94,565.25,94,565.5,93.5,566,92.75,566.75,92,567.5,92,568.25,91.75,568.75,91.25,569.75,90.5,570.25,89.75,570.5,89,570.5,87.5,570.5,86.75,570.5,85.5,571.25,84.25,571.25,84,571,83,571,82,570.25,81,570.25,80,570.25,79.5,570,78.75,569.25,78.5,568.5,78,567.5,77.5,566.25,76,565.25,75,564.75,74.5,564,73.75,562.75,73.25,562.25,72.5,561,71.5,560,69.75,558.75,68.75,558.75,68.25,558.75,67.75,558.75,67,558.75,66.5,558.75,65.25,558.75,64.5,559.25,63.75,560,63,560,62.25,560.25,61.75,560.25,61,560.75,60.25,560.75,59,560,59,559.25,60,559,60.5,558.5,60.5,558.25,60.5,557.5,60.25,557,60,555.75,59.5,555.5,59,554.5,58.75,553.75,58.5,553.5,58.25,552.75,58.25,551.75,58.25,551.75,59.75,551.5,60.75,551.75,61.5,553.25,61.5,554.5,62,554.5,63,553.5,63.25,553.25,63.75,552.75,64.25,551.5,64,551.25,64,549,64.25,547.25,64.75,546.75,64.5,546.25,64.25,545.75,64.25,544.5,63.5,544,63.25,542.75,63.25,541.75,63.25,540.25,63.25,539.25,63.25,538,63.5,536.25,63.5,535,63.5,534,63.5,533.5,65,533.25,66.75,532.5,67.5,532.25,68.25,532.25,69.5,531.25,70.5,533.75,70.5,534.75,71.25,535.75,72.5,537,72.25,537.75,72,540.25,72,540.75,73,542,73,542.75,72.75,543.75,72.75,545.5,74.25,549.25,78.25,556.5,85.25,556.25,86.75,555.25,86.75,553.75,85.5,553.5,85.5,554.25,86.75,555.25,87.75,556,88.25,557.25,89.25,558.25,90.75,558.25,91.75,557.75,91.75,557.25,91.75,557,91.75,555.25,91.75,555.25,91.25,554,91,553.25,91.5,552.75,91,552.5,90.25,552,89.25,551.75,87.75,550.75,86.75,550,86,549.5,85.25,548.75,84.25,548.75,83,547.75,82,547.5,80.75,547,80,546.75,79.75,546,79,545.5,79,545,78,544.25,77.25,543.5,76.25,543.25,76.25,542.5,75.75,542.25,75.5,543.25,77.25,544,78,544.75,79.5,545.75,81.25,546.75,82.25,547.75,84,547.75,86,548,87.5,547.75,89.25,547.75,91,547.5,92.5,547.5,93.5,547.25,94.5,547.25,96.75,546.25,98,545.75,98.25,544.25,99.25,542.75,99.5,541.5,99.5,540.25,99.75,540,100.25,540,101.25,540,102.75,539.5,103.75,538.75,105,538,105,537.5,105,536.75,104.75,535.75,104.25,535.25,103.75,534,103.25,534.5,103,534.75,102.5,535.75,102.5,536.25,102.25,537.25,101.25,537.5,100.25,538.25,99.25,539.25,98.5,540.25,98.25,540.25,97.75,541,97.25,541,96,541.75,95.25,542.75,94.5,543,93,543,91.75,543.25,91,543.25,89.25,542.75,88.75,541.75,87.75,540.5,86.75,540,86.75,539,86.75,537.75,86.75,536.25,86.75,535,86.75,534.75,86.75,533.5,86.75,533,86,532.25,85.25,531.75,84.5,531,83.5";
	areaArray[3]="386.25,40.75,385.5,40.75,384.75,40.75,384.25,40.75,383.25,40.75,381.75,40.5,380.75,40.5,379.5,39.75,379,39.5,377.75,39.5,377.5,38.75,376.5,38.5,376.25,38,376.25,37.75,376.25,37,377,36.5,377,35.75,377.5,35.25,378.25,34.75,378.25,34.25,378.25,34,378.5,33.5,379.25,33,379.75,32.75,380.25,31.25,380.5,30.75,381.5,30.75,382.75,30.5,384.25,30,385,29.5,386,29.5,387.25,29.25,388.25,29.25,389.5,29.25,391,29,392,29,392.75,28.25,394,28.25,395,28.25,396,28.5,396.25,29.75,396,30.25,395.75,30.25,394.5,30.75,393,31.25,391.5,31.5,390,31.75,388.75,31.75,388.25,32.25,387,32.5,387,33.5,385.75,33.5,385,34,384.25,35,384,35.5,383.25,36,383.75,37.5,384.25,38.25,386,39.25,387,39.25,387,40.5";
	areaArray[4]="347.5,123.25,347.25,124,347.25,125,347.25,126.25,347.25,127.5,347.25,128.5,347.25,129.5,347.25,130.5,347.25,132.5,347.25,135,347,139.5,349.75,139.5,354.5,140,358.75,140.25,361,140.25,362.75,140.25,364,140.25,365.75,140,367,140,366.75,138.75,364.75,135.5,364,132.5,361.5,129.25,361,127.5,360.75,126.25,360.25,124.75,359.5,123.5,357.75,123.5,357.25,124,355.25,124.25,353.25,124.25,351.75,124.25,349.25,123,348.25,122.25";
	areaArray[5]="460.25,128.75,460.25,128.5,460,128.25,459.25,128.25,459.25,127.5,459.25,126.75,459.75,126,459.75,125.25,460,124.25,460,123.75,459.75,122.75,459.75,122,459.25,121.5,458.75,121.25,458.5,120.5,457.75,119.75,456.75,119.25,457.5,118.75,458.25,118,459.25,117.25,460,116.75,461,116,461.5,115.5,462,114.75,462.5,114.25,463.5,114,464.5,113.5,465.75,112.75,466.5,112,467.5,111.5,468.5,111.25,469,110.5,469.75,109.25,470.75,109,471.75,108.5,472.5,108.5,473,107.75,473.75,106.5,474.5,105.25,475.25,104.25,476,103.5,476.25,102.5,476.75,100.75,477,99.25,477.5,98.75,478.25,98,478.75,97.5,479.75,97.25,481,97.25,482.5,97.25,484,97,485.25,97,486.5,97,488.5,97,490.75,97,492.25,97,493.5,97.5,493.75,98.5,494.5,99.5,495.25,99.75,496.25,99.75,497.25,99.75,498.75,99.75,499.25,99.5,499.75,98.75,500.5,98.75,502.5,99,504.25,99,505.25,99,507,99,508.75,99,510.25,99,510.75,98.5,510.75,97.75,510.75,97.25,510.75,97,511.5,96.75,512.5,96.75,513.5,96.75,515,96.75,516.5,96.75,517.25,96.25,517.25,95.5,517.25,94.75,517.25,94,517.25,93.25,517.25,92.25,517.75,91.25,518.75,90.25,519.25,89.5,520,88.5,520.25,87.5,521,86.5,522.75,85.75,523.5,85,524.5,84,525.25,83.25,526,83.25,527,83,527.75,83,528.75,83,529.5,83,530.25,83.25,531,84.25,531.5,85,532,85.75,532.75,86.25,533.5,86.75,534.5,87.25,535.75,87.25,537,86.75,538.5,87,540.25,87,541.25,87.5,542.5,89,543.25,89,544,89.25,544,90.25,543.75,91,544,91.75,543.75,92.5,543.75,93.25,543.5,93.75,543.25,94,542.75,95,542,96,541,97,540.75,98.25,540,98.75,538.75,99.25,538,99.25,537.75,100,537.25,101.25,536.75,101.75,535.75,103,534.25,103.25,534,104,533.5,105.25,532.75,105.5,532.5,105.75,532.25,106.5,531.5,106.5,530.75,106.5,529.5,106,528.75,106,528,106.5,527.5,107.5,526.5,107.75,525.5,108,525,108,525,107.5,525,106.75,524.5,106.25,524.5,105.5,525,105,525.25,104,524.5,104,523.75,103.5,523.5,104.25,522.75,105.25,522.25,106.25,522,106.75,520,107.25,520.75,108.25,521.75,108.25,522.75,108.25,523.5,109.75,523.5,111,524.25,110.75,524.25,109.75,525.75,109.25,526.5,109.5,528,110,529.25,110,530.25,110.5,530.5,111.75,530.5,112.75,529.75,112.75,528.25,113.25,527.75,114,527,115.25,526.75,116,528,117,529,117.75,530,119.25,531.75,120.25,532.75,122,533.5,122.75,534,124.25,534.75,126,536,126.75,536,129.25,535.75,130.75,535.5,132.25,535,132.75,534.25,133.25,534,134.75,533.5,136.25,534,138.75,532.5,138.75,531.5,140,530.75,141,530.75,141.75,529.75,142,529.25,141.75,527.75,141.75,527.25,141.75,526.5,142.25,526,142.5,525.5,143.25,523.75,143.25,522.75,144,522.25,145.5,521.25,145.25,520.5,145,518.5,144.75,516.75,144.5,515.25,143.75,514,143.75,512.25,143.75,510.75,143.75,509.5,143.5,509,142.75,509,142,509,141.25,508.25,140,507,140,505.5,139.25,503.5,139,502,138.25,501,137.75,499.5,137.25,497.25,137,496,136.75,494.5,135.75,493.25,134.75,491.75,133.5,490.75,132.25,490.25,131.25,488,131,486.75,131,486.25,130.75,485.75,130.75,485.5,131.25,485,131.75,484.75,132.5,483.5,133,482.75,133,481.25,133,480.25,133,479.5,132.75,478.75,132.75,478,132.75,477,132.75,476,133.25,475.25,133.25,474.75,133.5,474,133.25,473,133.25,472.25,133.25,471.25,133,470,132.75,468.75,132,467.75,132,467,132,465.5,132.25,464.75,132.25,463.5,132.25,463,132.5,462,132.25,461,132,460.25,131.5,460,131,460,130";
	areaArray[6]="194.25,320,194,320.5,193.25,321,192.5,321.25,191.75,321,190.75,320.75,191,322,190.5,322.5,189.75,323,189.25,323,188,323,186.5,322.75,185.25,322.25,183.25,322,182.25,321.5,180.75,321,180,320.75,179.5,320.5,179,320.25,178.5,320,177.5,319.75,176.75,319.25,176.5,319.25,176.25,319,175.25,318.25,174.5,317.75,174.25,317.25,173.75,316.5,172.75,316.25,172.25,316,172.25,315.25,171.75,315.25,170.5,314,169.75,313,169.5,311.75,168.75,311.75,168.25,311,168.25,310.25,167.5,309.5,167.25,308.75,166.75,307.75,165.75,306.75,165.75,305.75,165.75,304.75,165.75,304.25,165,303.5,164.25,302.75,164.25,302,164.25,301.75,164.25,301,164.25,300,164.5,299,164,299,163.5,298.25,163.5,297.5,163.5,296.25,162.75,294.75,162.5,293.5,162.75,291.5,162.75,290.5,162,289.5,162,288.75,162,287.75,161.75,287,161.75,286,161.75,285,161,284.25,161,283.25,160.75,282.5,160.25,281.5,160.25,280.75,160,280.25,160.25,278.75,160.25,277.75,160.75,276.75,160.75,275.75,160.75,274.75,160.75,274,160.75,273,160.75,272.25,160.75,271.5,160.5,270.75,160.5,269.5,160.25,268.5,160,267.5,160,266.5,159.5,265.25,159.5,264,159.5,263.25,159.5,262.5,159.5,261.25,159.5,260.25,159.5,258.75,159.5,257.5,159.5,255.75,159.5,254.5,159.5,253.5,159.5,252.25,159.5,251.25,159,250.25,159,249,159,248,159,247.5,159.5,246.25,159.5,244.5,158.75,243.25,158.75,241.5,158.5,240.25,158.25,239.5,157.25,238.5,156.25,237,155,235.75,154,234.75,152.75,234.5,151.25,233.75,150.25,233.25,149.5,232.75,149,232.25,147.5,231.25,147,230.5,145.75,229.5,144.75,228,143.5,226.5,142.25,224.5,141.75,223,140.25,220.75,138.75,219,138.25,217.25,137.5,215.5,137.25,213.75,137.25,213,137.25,211.75,137.25,210.5,136.25,209,135,207.5,135,206.25,135,205.25,135.5,204.5,137.25,204.5,139.25,204.5,141,203.75,142.5,202.75,144,201.75,144.75,200,145.75,199,147.25,198.5,147.5,197.25,147.5,195.75,147,195.25,146.75,193.5,147,192.25,147,189.75,146.5,189.25,146,188.25,145,187.5,144.5,187,144,186.25,143.25,185.25,142.75,184.75,142.5,184,141.75,183.75,141.75,182.75,141.5,181.25,141.5,180.25,141.5,178.75,141.5,177.5,140.75,176.5,139.75,176.5,139.25,176,139.75,175.75,141,175.5,141.75,175.25,142.5,175,144,175,145.25,175,146,174.5,146.5,173.5,147.25,172.75,147.25,172,147.25,171,147.75,170.25,148.75,169.75,149.75,169.25,150.5,169,151.75,169,153,168.5,153.5,167.75,154.5,167,155.75,166.75,157.25,166.75,158,166.75,159.25,167.5,159.75,168.25,160.75,169.5,162,170.75,163.25,170.75,165.25,170.75,166.5,170.75,168.5,170.75,170.5,170.5,174.25,170.25,175.5,170,177,169.75,174.75,171,174.5,172,173.5,172.75,173,173.25,173,174.75,173,176.5,173.5,177.75,173,178.5,173,179.5,173.25,180.75,173.75,182.75,174.25,184.5,176,186.5,177.5,187.25,178.5,188.75,180.75,189.25,182.25,190.25,182,192,182,193.75,183.25,195.75,184.25,198,184.75,200.25,184.25,202.25,183,204,182.5,205,182,206.5,181.25,208,181.5,209.75,181.25,210.5,181,211.75,181.5,213.25,182.5,214,183.5,216,184.75,217.75,185.25,218.75,184,219,183,219,182,219,181,219,179.75,219,179.25,219.75,178.25,220.5,177.75,222,177,223.75,176,224.5,176,225.5,175.5,227.75,174.5,229,174.25,230.75,172.75,232.5,171.5,233.5,171,234.25,170.5,234.5,169.75,235,170,236.5,170.25,237.25,170.25,238.25,170.25,240.25,171.75,240.25,173.75,239,175.25,237.5,176.75,236.75,177.25,235.75,177.25,234.5,177.75,233.75,179,233.25,178.75,233.25,178,235,179,236,180.25,236.5,181.5,238,182.5,239,182.75,241,182.75,243,182.75,245.25,183.25,247.5,184,247.75,186,248.25,187.5,250,188.5,252,188.5,253.75,190.25,254.75,191.25,256,192.25,257.5,192,259,190.75,260,189.75,260.75,188.25,261.75,186.75,263.5,185.5,265.25,185.5,266.75,185.5,268,185.25,268.5,185.5,270,186,271.75,186.75,272.25,186.75,273.75,187.75,274.25,188.5,274.25,190.5,275.5,191.5,276.75,191.75,278,193,278,193.25,279.75,192.75,281.5,192,283,191.25,283.75,189.75,284.25,187.75,285,186.25,284.75,185.25,284.75,185,286,185,287.25,185.25,289.25,183.75,289.75,182.5,290,181.75,290,183.25,291,183.75,292.25,183.75,293.25,183.5,294,183,294,182,294.25,182.5,296,182.5,297.75,181.75,298,181.25,298.5,180,298.5,179.75,299.75,179.75,300.75,180.75,301.25,181.75,301.5,182.75,301.75,183.5,302,184.25,302.25,184.5,303.75,184.5,305.25,183.75,306.25,182.75,306.75,182.5,307.5,182.5,308.75,182.25,310.25,181.25,310.5,181.75,311.5,182.75,312.5,183.75,313.25,184.75,315,186,315.75,187,316.75,188,317.25,189,318,191,318.5,192,318.75,193,319.25,194.5,319.25";
	areaArray[7]="110,159.75,109.25,159.75,109,160.5,108.5,160.5,107.5,160.5,106.75,160.75,105.75,160.75,104.75,161,104,160.5,103.75,160.5,102.25,159.75,101.75,159.25,101.25,159.25,100.25,158.5,99.5,158.5,99,158.25,97,158.25,96.75,158,94.75,157.25,93.5,155.5,93,155.5,92,154.75,91.5,154.5,90.75,153.75,90.25,153.5,90,153,89.25,153,89.25,151.5,88.75,151.25,88.75,150.25,88.75,149.25,88.75,148.75,89,147.5,89,146.25,89,144.75,88.25,143.75,87.25,142.5,85.5,140.5,85.5,139.25,84.5,138.25,83.5,137.5,83.5,136.5,83,135.75,82.5,134.25,81.75,133,80.5,131.25,80.5,130.5,80.5,129.75,80.25,128.5,80,127.75,79.5,126,78.25,125,78,125.25,77.75,126,78.25,128,78.5,129.25,78.75,130.75,79.75,131.75,79.75,132.75,80.25,133.75,81,135.75,82,137.5,83.25,139,84,141,83.75,143.25,82.5,144.5,81.25,144.5,80.25,144.25,79.25,143.5,78.25,142.5,78.25,141.5,78.25,140.75,77.75,140,77.5,139.5,77.5,138.25,77.5,137.75,77,136.5,75.75,135.75,74.5,133.75,74,132.25,74,131.25,74.75,130.75,75.75,130.75,75.5,130,74.5,129.5,73.75,128.25,73.75,126.75,73.75,124.75,73.75,124,74.5,123.75,76,123.75,77.25,123.75,77.5,122.5,79,122.5,81,124,83.5,124,84.5,124,85.5,124,87.5,124,89.25,123.75,90.5,123.75,91.75,122.75,92.75,122.75,94,123.25,96,124.25,97,124.5,98.25,126.25,100,127.25,100.5,127,101.5,127.75,102.5,128.75,103.25,130.25,104.25,131,105.25,132.25,107,133,108.25,134.5,109,135,109.5,136.5,109.25,137.25,108.75,139,107.75,140.5,107,141.75,107,144,107.5,145.75,108,147.75,108.25,149,109.5,150.5,110.25,150.5,110.5,152,111.5,152.75,113.25,153,114.75,153,116.25,152.75,117.75,152,118.5,151,118.5,150.5,118.5,150,119,149,119,148.25,119.75,147.5,120.75,146.25,123,146.25,124.25,146.25,125,146.25,126,146.25,127,146.25,128,147.5,128,149.25,127.25,149.5,126.25,150.25,125.5,150.25,124.5,150.25,124.25,151.5,124,153,124.25,154.25,124,154.75,123.5,155.75,123,157.25,122.25,157.25,121.5,157.25,120.5,157.25,119.5,157.75,118.25,157.75,117,158.25,116.25,158.75,114.75,159,114,159.25,113.5,159.5,112.25,160,111.5,160,110.75,159.75";
	areaArray[8]="567.5,285.25,567,285.25,566.75,285,565.75,284.25,565.5,284.25,564.75,284,564,284,563.75,284,563,283.5,562.75,283,562.25,283,562,282.75,562,282.25,561.75,281.75,561.75,281,561.5,280.25,561.5,279.75,562,279.25,562.25,278.5,561.75,278,561.25,277.75,560.5,278.25,559.75,278.25,558.75,278.25,558,278.25,557.25,278.25,556.75,277.75,556.75,277,556.75,276.75,557.5,276,558.25,275.5,558.75,275,557.25,275.25,556,275.25,555.5,275,555.5,274.25,555.5,273.75,556,273.25,555.75,272.5,555,271.5,555,270.75,554.75,270.25,553.75,269.25,553.25,269.25,552.5,269.25,552,269.25,551.25,268.5,550.25,268.5,549,268.5,546.75,269,546,269,545.25,269.75,544.5,269.75,542.75,269.75,541.25,270.25,540.75,270.25,540.25,270.25,539.25,270.75,538.5,271.5,537,271.75,536.75,272,535.75,272.25,535.25,273.5,534.75,274,534,274,532.75,274,531.75,274,530.75,274,530.25,273.75,528.5,274,527,274.25,525.5,275,524.25,275.5,522.75,276.25,521.75,276.25,521,276.25,520.5,276.25,519.75,276,519,276,518.75,275.25,518,274.75,517.5,274,517.5,273.75,517.5,272.75,517.5,272.25,517.75,271.75,519,271.25,519.5,270.5,519.5,269.75,520.25,269,520.25,268,520.25,267.25,520.25,266.25,520.25,265.25,520.25,264.25,520.25,263.5,520.25,262.5,520.25,261.25,520.25,260.5,520,259.75,520,258.25,520,257.25,519.5,256.5,519.25,256,519,255.25,518.5,254.25,518.5,253.75,518.75,253.25,519.75,253.25,520.25,253,520.25,252.5,520.25,250.75,520.5,249.75,520.75,248.75,521,247.75,521.5,247,521.5,245.5,522.5,245,522.75,244.5,523.75,244.5,525.25,244.5,525.25,243.75,525.5,243,525.75,242.5,527,242.5,528,241.75,529,241.75,529.75,241.75,531,241.75,531.75,241.75,532.5,241,533,240.75,533.75,240.75,534.75,240.75,535.5,240.5,536.5,240.25,537.25,240,537.5,239,538.75,237.75,539.25,237.25,540.25,236.75,539.75,235.75,540,234.5,540.75,234,542,233.5,542.5,233,543.25,232.75,543.5,232.5,544,232.25,545,232.25,544.75,231,544.75,230.75,545,230.25,545.75,230,546.75,229.75,546.75,229.25,546.75,228.5,547.25,228.25,548,228,548.5,227.5,549.5,226.75,549.75,226.5,550.75,226.5,551.5,226.5,552.5,226.5,553.25,227,554,228,555.75,228.25,555.75,227.75,555.75,226.75,556,226.5,556.5,226,556.75,225.5,557.25,224.75,558.25,224.25,558.5,223,557.5,222.75,558,221.75,558.25,220.75,559,220.75,560.5,220.75,562,220.75,564,220,564.75,220.75,565.75,221.25,566.75,221.5,568,221.5,569.25,221.5,570.5,221.5,571.75,219.75,572.75,220.5,573,221.25,572.5,222.5,573,223.75,572.75,224.75,572,225.5,572.25,226.75,572.5,228.25,571.75,228.75,571,229.25,570,229.25,569.5,229,570.5,230.25,571.5,231,572.5,231.5,573.25,232.5,574,232.5,575,232.5,575.75,232.5,577,233.25,576.25,234.25,575.75,234.25,576.5,235.5,577,235.25,578,234.25,578.5,232.5,579,231.75,579.5,230.25,579.75,229.5,579.75,229,579.75,227.5,579.75,227,579.75,226.25,580,225.25,580.75,224.25,580.75,223.25,581.5,222.25,581.75,221.25,581.75,220.25,582.25,219.5,582.75,218.75,582.75,218.5,583.75,218.5,584,219.5,584.5,220.75,585.25,222.75,585.25,224,585.5,225.25,585.5,226,586,227.5,587.25,228,588.5,229,588.5,230.25,588.5,231.5,589,233.75,589.25,234.5,589,236,589,236.75,589.25,238.25,590,239.25,591.25,239.5,592.5,240.75,593.5,241,593.75,242.75,594,244.25,594.75,245.5,596,245.5,596,247,596,249.25,597,250.5,598.25,251.5,599.25,251.5,599.5,252.5,599.5,253.5,599.25,255.25,598.5,257,598.5,258.75,598.5,261,597.75,262.5,597.25,263.5,596.25,263.75,595.25,265.25,593.5,266,594,266.75,593.75,267.5,593.25,268.75,592.75,269.75,591.5,270.5,590,271.75,588.5,272.5,587.75,274,587,274.75,586.25,275.75,585,276.5,584.25,277.75,583.25,279,582.75,280,582,281.5,581.25,281.75,580,282.5,579.5,282.5,578.75,282.5,577.25,283,576.25,283.5,575.25,283.75,574.5,284.25,573.75,284.5,573.5,284.75,572.5,285,571.75,285.25,571.25,285.25,571,284.5,569.75,283.75,569.25,283.75,568.75,284,568,284.25,567.5,284.75";
	areaArray[9]="566.75,285.5,566,285.5,565.75,286,565.75,286.75,566.25,287.5,566.25,288.75,565.5,289.25,565.5,290.25,565.25,291.5,565,292,564.75,293,564.75,294,565,294.75,565.5,295.5,566.5,295.5,567.75,295.5,568.5,295.25,569,295,569.75,295,570.5,294.25,571,293.75,571.25,293.25,571.75,292.75,572.25,292.5,572.75,292.25,573,291.75,573.5,291.25,573.75,290.75,573.75,290,574.25,289.25,574.75,288.75,575,288.5,575.5,287.25,575.5,286.75,575.25,286.5,575.25,286,574.75,285.75,574.25,285.75,573.75,285.5,573.25,286,573.25,287.5,572.75,288,572,288,571.25,288,570.25,288.25,569.5,288.25,568.75,288,568.75,287.5,568.5,287.25,568,286.5,568,286,567.75,285.5";
	areaArray[10]="201.5,267,200.75,267,200.25,267,199.5,267,199,266.75,198.25,266.75,197,265.75,196,265.25,195.25,264.75,194.5,263.75,193.5,263.25,192.5,262.5,192.25,261.5,191.75,260,191.75,259.25,191.75,258.75,191.5,257.75,191.5,257,191.5,256.75,192,255.5,192,254,192,253,192.75,253,192.75,252,193.25,251,194.75,250.5,195.25,250,195.75,248.75,195.75,247.75,195.75,246.75,196.5,245.5,197.75,244.75,198.75,243.5,199.25,240.75,199.25,240,199.75,237.75,199.5,236.25,199.25,235.25,198.25,233.5,198,232,197,231,196.25,229.75,195.5,228.75,194.75,228.5,194.25,227.25,193.25,226.25,192.25,225.25,192,224.5,191,223.75,190.75,222.75,189.5,221.5,188.5,220.75,187.75,220.25,187.25,219.75,186.75,219.25,186.25,218.75,185.25,218.25,184.5,218,184.5,217.25,184,216.75,183.75,216.5,183.25,216.25,183.25,215.75,183,215.25,182.5,215,182.5,214.25,181.75,214,181.5,213.5,181,213.25,181,212.75,181,212,181,210.75,181,210.25,181,209.75,181,209,181,208.25,181,207.75,181,206.75,181.25,206,182,205.5,183,204.5,183.25,203.75,183.25,202.75,183.75,202,184,201.25,184,200.5,184,199.5,183.75,198.25,183.75,197.25,183,195.5,182.5,194.75,182.25,194,182,193.5,182,192,182,191.5,182.25,190.25,183,190.25,184.25,190.5,185.5,190.5,186.25,191,187.75,191,189.5,191,190.75,191,192.25,190.75,193.5,190.5,195.5,190,195.75,189,196.5,189.5,197,190.5,197.75,191.5,198.25,192.25,198.25,193.25,198.75,194.5,199,195.25,199.75,195.75,200.75,196,201.75,196.75,202.75,196.75,204,196.75,205,197.25,206.25,198,207.25,198.5,208.25,198.75,209,199.25,210,200.25,210.75,200.75,211.75,200.75,213,201,214.5,201.25,216.5,201.25,217.75,201.5,219.25,202.5,220.25,203.5,221.75,204,222.25,205.25,224,206.25,225.25,207,226.25,207,227,207.5,228,208.5,228.5,210,228.5,212,228.5,214.25,228,216,227.75,217.5,226.75,218.75,226.25,219.5,225.75,220.25,224.75,220.75,224,222.25,223.25,223,223.25,224,222,225,221.75,226.25,221.25,227.25,221.25,229,221,230.5,221.25,233,221.25,234.75,221.25,236.75,220.5,238.5,220.5,240.5,219.75,241.75,219.75,242.75,219.25,243,219,244.25,218.25,245.5,218,246.25,217.5,246.75,217.25,246.75,216.75,247.75,216.5,248.25,216,248.5,215,249,213.75,249,213,249,212.5,249,211.25,249.5,210.5,249.5,210.5,250.25,209.5,250.75,208.25,250.75,207.75,251.25,207.25,251.5,206.5,252,205.75,251.75,205.25,253.25,204.5,254.75,204.5,256.25,204.5,257,205,258.5,205,259.75,205,261,204.75,261.5,204,262,203.25,262.5,203,263.25,203,264.25,202.75,265,202.25,265.5,202.25,266.5";
	areaArray[11]="530,150,528,150,527,150,525,149,525,147,525,145,525,144,527,143,528,142,530,142,531,143,533,143,533,146,533,147,532,148,530,150,530,149,529,149,527,148,526,149";
	areaArray[12]="523,145,523,144,525,144,526,144,527,143,527,145,525,145,523,145,523,145";
	areaArray[13]="457.5,175.25,457,175.5,456.5,176,455.5,176.5,455.25,177.5,454.75,178,454.25,178.25,453.75,178.25,453.25,178.25,452.75,178.25,452.5,178,451.5,177.5,451.25,176.5,450.5,175.5,450.5,174.75,450.25,174.25,449.75,173.75,449.5,173.5,449.25,172.75,449.25,172,449,171.5,448.75,171,448.5,170.25,448,169.25,447.75,168.5,447.25,167.75,446.75,167.25,446.5,166.25,446.25,165.5,446,164.75,445.5,164,445.25,163,444.5,162,444.25,160.75,443.75,160.25,443.5,159.5,443,158.75,442.5,157.5,442.75,156.75,442.25,155.75,442,154.5,441.5,153,441.5,152.25,441.5,151.5,441.25,151,441.25,150.25,441.25,149.25,441.25,148.5,440.5,148.5,440,149,439.5,149,439.25,149,439,149.25,438,149.25,437.5,148.75,437,148.5,436.25,147.25,435,146.75,434,146,434,145.5,434,145,433.75,144.75,433.75,144,434.75,143.75,435.5,143.5,435.5,142.75,434.75,142.5,434,142.25,433.75,142,433,142,433,141.25,433.25,140.75,433.75,140,434.75,139.75,435,139,435,138.5,435.25,137.75,436,137.5,437.5,137,438.75,135.75,439.5,135.25,440.5,134,442.25,134,443.5,132.5,444.25,130.75,444.25,129.75,443.75,129,442.75,127.75,441.75,126.75,441.75,126,441.5,125.5,441.25,125,441.5,124.5,442.25,124,443,123.75,444,123.75,444.5,123.5,445.25,124,446,124,447.25,124.5,448.5,124.5,449.5,124.5,450.75,124.5,451.25,124,452,123.25,453,123,453.75,122.75,454.75,122.5,456,122.5,457,122.5,458,122.75,458.75,123.5,459.5,124.25,459.75,125.5,459.75,126.25,459.5,127.25,459.5,128.75,459.75,130.5,460,131.75,461.25,132.75,462,133,463.75,133,463.5,133,463.5,133.75,463.75,134.75,464.75,135.25,466.25,135.5,467.5,135.5,468.25,136,469.75,136,470.75,136.25,471.75,136.25,472.5,136.5,473.75,136.75,474,136.25,474,136,474.25,135.5,474.25,134.75,474.75,133.5,475.5,133.75,476,134.75,477,135.25,478.75,134.75,479,134.5,479,134,480,133.75,481.5,133.75,482.75,133.75,483.75,133.5,484.25,133.25,485.25,133,485.5,132,486.75,131.5,486.75,133,486,133.5,485.5,134,485.25,134.75,484.75,135.25,484.25,136.25,483.5,137.5,483.25,138.5,482.75,140,482.75,141.75,482.75,144,483,146.25,483.5,148,484,150.25,484,152.5,484.75,154.25,484,154,483.25,153.5,482.75,153,483,152.5,482.5,151.75,482,151.25,481.75,150.75,481,150.25,480,149.75,480,149,479.75,148.5,479.5,147.5,479,146.75,478.75,146.25,478.25,145.5,477.25,144.5,477.75,144,477.75,143.25,478.25,142.75,477.75,142.75,476.75,142.5,475.75,142.25,475,141.75,474.5,141.25,474.5,140.5,474.5,140,474.25,139.25,473.75,139.25,473.5,140,473.5,141,473.5,142,473.5,142.75,473.75,144,474,145,473.5,145.75,473,145.75,472,145.75,472,145.5,472,146.5,472,147.25,471.5,147.25,471,147.25,470.75,148.25,470.75,149.25,470.5,150.25,470.25,150.5,469.25,151,468.25,151.5,467.75,151.75,467.25,152.25,466.75,152.75,466,153.5,465.75,154.25,465,155.25,464.5,156,463.75,156.75,463.5,157,463,157.5,462.5,158,461.5,159,460.25,160,459.25,160.25,458.75,161.25,458.5,162.25,458.75,163.25,459,164.75,459.25,166,459.5,167,459.5,168.25,459,169,458.5,170.5,458.5,172,458.25,173,457.5,173.5,457.5,174.5,457,175.25,456.75,175.25,455.5,175.75";
	areaArray[14]="550.75,126,549.5,126,549,125.75,548.75,125,548.75,124.5,548,124,548,123.75,547.75,123.5,547.5,123,547,123,546.75,122.25,546.5,122,546,121.25,545.5,120.5,545.5,120.25,545.75,119.75,546,118.75,546.5,118.25,547.25,117.75,548,117.25,548.75,117,550,116.25,550.25,115,550.25,114.5,551.25,114.5,552,114,553.5,114,555,113.75,555.75,113.25,556.25,111.75,555.75,111,556,110.5,556.75,110,556.75,109.25,557.5,109,558.5,109,558.5,108.25,558.5,107,558,105.75,557.25,105,556.5,104,556.25,103.5,556.25,102.5,556,101.5,555,100.75,555,100.25,554.75,99.75,554,99.5,554,98.75,554.75,98.75,555.5,98.5,555,97.5,555.25,96.75,556,96.75,556,96,555.25,94.75,554.75,94,554,94,553.75,93.75,553.75,93.25,553.5,93,553.5,92.25,554.5,92,555,91.5,556.5,92.25,557.5,93,558.75,93.75,559.5,93.75,560.25,94.5,561.5,94.5,562.5,94.75,563.25,94.75,563.25,96,563.25,97,563.5,97.75,564.75,97.75,566,97.75,565.5,98.75,565,98.75,564,99,564,100,564,101.25,563.25,101.25,562.25,101,561,101,560,100.75,561.5,102.25,562.75,103,564,104.5,564.75,106,564.75,108.25,564.75,109.75,565.5,111.25,565.5,112.75,565.75,113.5,566.75,114.5,566.75,115.75,566.75,117.25,566,117.75,565.5,117.75,564,117.75,563.5,117.75,561.75,117.75,560.5,117.75,559.75,119,559.5,119.5,559.5,120.25,558.5,120.25,557.25,120.25,556.5,120,556.25,120.5,555.75,120.5,555,121,554.5,121,554.5,122,553.25,122,552.75,123,552.75,124.5";
	areaArray[15]="542,110,541.75,110.5,541.5,110.75,540.5,111.25,539.5,111.75,538.75,111.75,538,111.75,537.5,111.75,536.75,111.5,536,111.75,536.5,112.75,537.25,114,537.75,115.75,537.75,117.75,538.75,118.25,539.5,118.25,540.75,118.25,541.5,117.75,542.25,117.75,543.75,117.5,544.5,117.25,544.75,116.5,545,116,545,115.25,545,114.25,544.5,113.5,543.75,112.5,543.5,111.75,543.25,110.75";
	areaArray[16]="364.25,253.5,363.75,254,363.5,255,363,255.25,363,256.25,363,257.5,363,258.75,362.5,260,362.25,260.75,361.75,261.75,361,262.25,360.25,262.75,360,263.75,359.25,264.75,358.75,265.5,358.25,266.5,357.75,267,357.25,268,356.5,268.75,355.5,269.25,354.75,270,354,271.25,353.25,271.75,352,272.5,351,273.25,349.5,273.5,348,274,346.5,274,345,274.25,344.25,274.25,342.75,274.25,341.5,274.25,341,274.75,339.75,274.75,339,275,338,275.5,337.25,276,336.75,276,336.25,275.75,335.75,275.5,335,275,333.75,274.75,333,274.5,333,273.75,333,272.75,332.5,272,332.5,271.25,332.5,270.5,332.5,269.5,332.5,268.75,332.5,267.75,332.5,267.5,332,266.5,331.5,265.75,331,264.75,330.5,263.25,330.25,262.5,330,261.75,329,260.25,328,259,328,258.25,328.75,258.25,329.5,258.25,330.5,258.5,332,258.5,332.75,258.5,333.75,258.5,334.5,258.5,335.25,258.25,335.75,257.75,336.5,257,337.5,256.5,338.25,256,339.25,255.25,340.25,255,341.25,254,341.5,253.75,342.75,253.25,344,253,344.75,252.25,345.5,251.5,346.5,251,347,250.25,347.75,249.25,348,248.25,348,247.5,348,246.25,348.5,244.75,348.5,243.5,349.25,242.5,350.5,242,351,241.5,352,241.25,353.5,240.75,354.5,239.75,355.75,238.75,356.75,238.25,358,237.5,358.75,237,360,238,360,239.75,360.5,241.5,361.5,242.5,362.5,243.5,363,245,363,247,363,248.5,362.75,250,362.75,251.25,362,251.75,360.5,251.5,359.25,251.5,359.75,252.25,359.75,253.25,360.5,254.5,359.5,255.75,358.75,257,357.75,257.75,356.5,258.5,356,259.5,355.25,259.5,353.75,259.5,352.75,259.75,352.25,259.75,351.5,260,351,260.25,350.75,260.5,350.25,260.5,350,260.75,349.75,261.5,350,262.75,350.75,263.5,351.5,263.75,352.5,263.75,354.25,264,355.25,264,355.75,263.25,356,262,356,261,356,260.25,357.5,258.25,358,257.5,359,256.5,361.5,254.75,362.5,254.75,363.25,254,363.75,253.25,363.75,252.5,363.5,252";
	areaArray[17]="361.25,254.75,361,254.5,360.25,254.25,360,255,359.5,255.5,358.5,256.25,358,257,357.25,257.5,356.5,258.5,356.25,259.5,358.5,257.75,359,257.25,360.25,257,360.75,256.25";
	areaArray[18]="356,111,352,113,351,113,349,112,349,112,349,110,348,107,348,106,345,102,347,102,347,100,350,101,354,101,356,101,359,100,364,100,366,100,370,100,373,101,373,103,373,107,371,107,370,107,369,108,367,108,366,110,365,112,365,112,363,113,362,113,360,112,359,111,357,111,356,113,354,113,350,112,349,111";
	areaArray[19]="109.25,135.5,108.5,134.75,108.25,134,107.5,133.5,106.75,133.25,106.5,133,106,132.75,105.5,132.25,105.25,132,104.25,131.5,103.75,130.75,103.25,130.25,102.75,129.5,102.5,128.75,101.75,128.5,101.5,127.75,100.5,127.5,99.75,127.25,99.25,127.25,98.5,126.75,98.25,125.75,97.5,124.75,96.5,124.5,95.5,124.25,94.75,124,94.25,123.25,93.5,123,92.25,123,91.25,122.5,91,123,90.25,123,89.5,123.5,88.75,123.5,88.25,123.5,87,123.5,86.5,123.5,84.75,123.75,83.5,124,82.5,124,81.75,124,80.75,123.75,80.25,123.5,79.75,123,79,122.5,78,122.5,77.5,122.5,77,122.75,76.25,123.5,75,123.5,74.5,123.5,73.75,123.5,73.25,123,72.5,122.25,72.75,121.5,72.75,120.75,72,120,71.5,119.75,70.75,119.75,70,119.75,69.5,119.75,69,119.75,69,119,69,118.25,69,117.75,68.5,117.5,68.5,116.75,68.75,116,68.75,115.25,68,114.5,68,113.5,68,112.5,68,111.25,68.25,110.25,68,109.25,67.75,107.25,67.75,106,68,105.25,68.25,104,68.25,103,68.75,102.25,69.5,101,70,100.25,71,98.75,71.75,98,72.25,97,73.25,98.25,74.5,98,75.5,97.5,77.25,97.25,79,96.5,81.25,96.25,82.5,95.25,83.5,94.75,84.5,94.75,85.25,95.25,86.25,95.5,87.25,95,88.75,94,89.25,93.75,90.25,93.5,91.25,93,92,92.5,93,92.25,94.25,92,96.25,92,98,92,99.75,91.75,102.5,91.75,103.5,91.75,105.25,91.75,106.5,91.75,109.25,91.5,110.75,91.5,113,91.5,115.25,91.5,117.25,91.5,120.25,91.5,122.5,91.5,125,91.5,127,90.5,127.25,90,128,90,129.75,90.5,131.75,89.5,132.25,88.75,133.5,87.5,134.75,86.5,136.25,85.75,138.25,84.5,140.75,85,142.5,85,144.5,85.75,146.5,85.5,148.25,86,150,86,152,86,154,87,155.5,88.25,156.25,89.25,156.75,90.25,158,90.75,159.75,90.75,161,90.25,161.75,89.5,163.75,89,165.25,88,166.5,87.75,167.25,86.75,168.75,86.5,169.25,86,169,85.25,170,85,171.25,85,172.5,85.5,173.75,85.25,175.5,85.5,177,85.75,178.25,85.75,179.25,85.75,180,85.5,180.5,84.5,181.25,85,181,85.75,180,86.75,180.25,88,180.25,89.25,180.5,90.5,180,91,179.75,91.75,180.25,92.75,180.75,92.25,181.25,91.75,182.25,91.75,183,91.75,184.25,92.25,184.75,93.5,185.25,94.25,185.5,95.25,184,96,183,97.5,181.25,97.5,180.5,97.5,179.5,97.5,178.5,96.75,179.25,95.5,178.75,95.25,177.75,95.25,176.5,95.5,175.5,96.25,174.25,96.5,173.75,97,172.75,97.5,171.75,98.5,171.75,99.75,172.25,101,172.25,102,172,103,170.75,103,169.75,103,169,103,168,103,167,103.75,166,103.75,164.5,104.5,163.5,104.5,163.25,105.5,162.5,106.5,161.75,107.5,160.75,108,160.25,109,159.25,110,158.25,111,157.5,112.5,157.5,114.25,157.5,115.75,156,116.25,154.75,117.25,153,118.25,152,118.75,151,119.5,149.75,119.75,149,120.75,148.5,121.75,146.75,121.75,146.25,123.25,145.25,123.75,144.75,123.75,144,124.5,143.25,125.5,143.25,127.25,143.25,129.25,143.75,131,143.5,133.5,143.5,136.75,142.75,138.75,141.75,139.75,140.25,139.75,138.25,139.5,137.75,137.75,137.25,136,136.75,134,136.5,133,136.5,132,136.75,131,136.75,130.25,136.75,129.5,136,128.75,135.25,129,134.25,129,133,129,132.75,128,131,128,129.25,128,128.5,128,127.5,128,126.75,128,126.75,129,127.25,130.25,126.5,131,125.75,131,124.75,131,123.75,130.75,123,130.75,121.75,130.5,120.5,130,119.25,129.5,118.75,129.5,117.75,129.5,117.5,129.5,116.25,129.75,115.5,130,115,130.75,114.75,130.75,114.5,131.5,114,132.25,112.75,132.25,111.5,132,111.25,133,111,133.75,110.75,134.25,109.75,134.25,109.5,135.25";
	areaArray[20]="291.25,113.5,290.25,113.75,289.75,113.75,289.25,114.25,289,114.25,288.25,114.25,288,113.75,287.5,113.75,287.25,113.75,286.25,113.25,285.75,113,285.25,112.5,283.75,112.5,283,112.5,282.5,112.5,281.75,112.5,281.75,112,281.25,111.25,281.25,110,281.25,109.25,280.75,108.5,281,107,281,106,281.5,104.75,282.25,104.25,282,102.75,282.25,101.75,282.75,100.75,282.25,99.5,282.25,98.75,282.25,97.5,282.25,96.5,283.25,96,284.75,95.5,286,95.5,287,96,288,96,289,96,291,96,292.25,96,293.75,96,295.25,95.75,296,95.25,296,94.5,296.25,92.75,296,91.75,295.5,90.5,294.75,89.75,293.75,89,293,89,291.75,88.75,291.25,87.75,291.25,87,291.25,86,291.25,85.25,291.5,84.75,292,84.5,293,84.25,293.75,84.25,294.5,84.25,296,84.25,296.5,83.75,296.5,83.5,297,83,298,82.5,299,83,300.25,83,301.25,82.75,301.75,82.25,302.75,81.75,303.25,81,302.75,80.5,301.75,81,300.75,81,300,81,299.25,81,298.75,82,298,82,297,82,296.25,82,295.5,82,294.75,82.5,294.5,83,294,83,293,82.75,292.25,83.5,291.25,83.25,290.5,83.25,290.25,83.25,290.25,81.75,290.25,81.25,290.75,80.75,291.75,80.5,292,80.25,291.25,79.25,291.25,78.5,291.75,77.5,292.5,77.25,292.25,76.5,292.25,75.75,292.75,75.25,292.25,74,292,73.75,291.75,74,291.25,74.5,291.25,75.5,291,76.75,291,77.75,290,78.5,289,78.5,288.5,79,287.25,79.75,286.25,79.75,284.5,79.75,283,80,282,79.75,282,78.5,282,77.75,282.25,77.25,282.75,76.75,283,76.5,282.5,76,282.5,75.25,282.75,74.5,282.75,73.5,284,72.5,285.5,71.75,286.75,71.75,287.25,70.75,287.75,70.5,288.5,69.5,288.5,68.5,288.5,66,290.25,64.5,292.25,63.5,293.75,63,295.75,63,297.5,62.25,298.5,61.75,298.5,62.75,298.5,63.75,298.25,64.5,297.5,64.75,298.25,65.25,299,65.5,299.75,66.25,299.5,67,298.75,68.25,298.25,68.5,299,69.5,299.75,70.75,300.5,72,301.5,73.25,302.5,74,302.75,74.75,303.5,75.5,304.75,76.25,304.75,78,304,79,304,79.75,305.25,79.75,306.25,79.25,307,78.25,308,77.25,309,76.5,309.75,76,310,77,311,77.25,311,76.75,310,75.5,310,75,310.5,74.25,311.5,74.25,312.5,74.25,313.25,74,314.25,73.75,314.5,73.25,315,73,314.5,71.75,314.5,71,314.5,69.25,314.5,67.75,315.75,66.75,317,65.5,318,65,319.75,65.5,319.25,67.5,320,69,318.25,69.75,318.25,70.75,318.5,71.75,320,71.5,320.75,70.25,321,69,322.25,68.5,321.25,66.75,321.25,65.5,320,63.5,319.5,63.25,318.75,63.25,317.75,63.75,317,64,315.75,65,314.5,65.25,313.25,65.25,311.75,65.25,310.5,64.25,309.75,64,309.75,63.5,309.75,62.5,309.75,61.5,309.75,60.5,310,59.25,310,58.25,310,57,310,56,310.5,55,311.75,55,313.25,54,314.25,53.5,315.25,53,315.5,52,316.25,50.75,316.75,49.75,317.5,49,319,48,319.5,47,321.25,46,322.25,44.5,323.25,43.75,323.75,43.25,324.75,42.25,326,41.25,327.25,40.5,328.25,39.75,329.75,39.75,331.5,39.75,332.75,39.75,334.75,39.75,335.5,39.25,336.5,39.25,337.5,38.5,339.5,38.5,341,38.5,342.75,38.5,344.5,38.5,345.25,38.75,346.5,39.25,347.25,39.25,348.25,40,349.5,40,350,41,349.75,42.5,349,43.75,349,45.5,348.25,46.5,347.75,48,347.75,49,347.5,50.5,347.5,51.75,347.5,53.25,347.5,54.5,347.5,55.75,347.25,56.75,347.25,58.75,347.25,59.75,346.5,60.25,345.75,60.25,344.75,60.25,343.5,60.5,342.25,61,342,61,341,61.5,340.25,61.5,339,61.5,338.25,61.5,337.5,61.5,336.5,61,336.25,60.5,335.75,60,335.75,58.75,335.75,57.75,335.75,56.75,335.5,56,335.5,55.25,335.75,54.25,337.25,53,338.5,52.25,339.5,51.25,340,50.75,339.5,50.25,338.5,50,337.75,50,337.25,50.5,336.75,50.75,336.75,51.75,336.75,52.5,336,53,335.5,53.75,334.75,54.5,334.25,54.5,332.75,54.5,332,55.75,331,57,331,58,332.75,59.25,333.75,59.75,335,61,335,61.75,334.75,62.75,334.25,64,335,65.5,334.25,67.75,333,68.25,331.5,68.5,330,68.75,329.5,69.25,329.25,70,328.25,70,327.25,70,325.75,70,326.75,70.5,327,71.25,326.75,71.75,326,72.5,325.25,72,324.5,71.75,323,71.75,321.75,71.75,320.75,72,320.25,72.75,321.25,72.75,322.75,72.5,323.5,72.5,324.75,72.75,327.25,73,328.5,72.75,330,72.25,331,71.75,331.75,71.75,332.75,71.75,333.75,71.75,335,71.75,335.25,70.25,335.25,69.5,335.25,69,335.5,68,336.25,66.25,337.5,65.75,337.5,65.25,337.25,64.5,337.25,63,337.25,62.75,338.75,62.75,339.75,62.75,340.25,62.5,341.25,62.25,342.25,62.25,343.5,62.25,344,61.75,344.75,61.5,345.25,61.25,347,61.25,347,62.25,347.5,63.5,347.5,65,347.5,67,348.25,69,349,71.25,348.5,72.5,349,74,349.25,75.75,350.5,76.75,351.5,78,352.25,79,354.5,79.5,355,79,355.75,78.75,356.25,78.5,357,78.5,358.75,79.5,359.5,81.25,361,83,361.5,85.25,362.25,86,363.25,87.5,364,88.5,364.75,88.5,365.5,88.5,366.25,88.5,366.25,89.5,365.25,90.25,364.5,90.75,364.25,90.75,363.5,91,363,91.75,363,92.5,363,93.25,362.25,94.5,361.5,94.5,360.5,94.5,360,93.75,360.25,93.5,359.75,93,359.25,92.5,358.5,91.5,357.75,90.5,357,90.25,356.25,90,355.25,90,354.75,91.25,354.25,92.25,353.75,94,352.75,94.25,352.75,95.5,352.5,96,352.25,97.25,351.5,98,351.25,98,351,98.75,350.25,99,349.75,99.75,349,99.75,348.25,99.75,347.5,99.75,346.5,100.5,345.5,101,344,101.5,343,102.25,343.5,103.25,344.5,104.25,344.5,105.25,344.5,106.25,345.25,106.75,346,107.75,345.75,109.75,345,110.25,344.5,110.75,344.25,112,343.75,113,343.75,113.75,342.75,114,341.25,113.75,340.25,113.5,339.25,112,338.75,111,338,110.5,337,109.75,337,108.75,337,107.5,336.5,106.5,335.5,105.5,335,104.75,334.75,104.25,334.75,103.5,334.75,102.5,334.25,102,333.75,100.75,332.75,100.25,331.75,99.75,330.5,99,329.5,98.5,328.5,97.5,327.75,96.5,326.25,95.5,326.25,95.25,324.75,94.75,324.25,94.25,323.5,93.75,323,93.25,323,94.25,323.75,95.25,324.5,96.5,325.75,97.25,327.25,98.75,329,100.25,330,100,330,101,331.25,102,332.25,102.5,333.5,103.25,334.25,104.5,334.25,105.75,333.5,106.75,333,106.5,332.25,106,331.5,105,331,105.5,332,107,331.25,108.5,330,109.75,329,110.25,328.5,110.5,328.75,112.25,328.5,113.25,327.5,113.25,326.5,112.75,325,112.25,323.75,111.5,322.75,110.75,321.25,109.75,321.25,108.75,322,108,323.25,108,325.5,108,327,108,328,107.75,328.25,106,327.5,105.25,326.25,104.75,325.5,104.5,324.5,103.25,323,102.75,322.5,102,321.5,102,320.75,101,319.75,100,318.5,99.25,318.25,100.25,317.75,101.25,318.5,101.75,318.75,103.5,318.75,104.75,318.75,105.75,318.75,107.5,318.25,108,317.25,108,316.5,108.25,315.25,108.25,314.5,106.75,314,105.5,314,104.25,314,103,314,102.5,314.25,101,314.75,100.25,316.25,99.5,316.25,98.75,317.5,98,318,97.25,317.5,96.75,316.75,96.5,315.75,96.5,315.25,96.25,314.25,96.75,313.75,97.75,312.75,97.75,312,98.25,311.5,98.25,310.25,98.5,309,98.25,308.25,98,306.75,98,306.25,98,306.5,98.75,306.5,100.25,306.5,101.25,305.5,102,304,102,303.5,103,302.5,103.5,302,104,301.5,104.5,301,105.25,300,106.25,301,107.5,300.25,108.75,299,109.5,298.25,111,297.75,111,296,112,296,113.25,294.75,113,292.5,112.75";
	areaArray[21]="283,51.5,282.75,52,282.25,52.5,281.75,52.75,281,52.75,280.5,53.25,280.25,53.25,279,53.75,278.25,53.75,277.25,54,276.5,54.75,275.75,54.75,275,54.75,274.5,55.25,273.5,55.25,272.5,55.25,271.5,55.25,271,55.25,269.5,54.25,269.25,54.25,268.25,54.25,267.25,54.25,266.5,54.25,266.25,53.25,265.75,52.75,265.25,52.5,265.25,51.75,265.25,51.25,265.25,50.75,265.5,50.25,265.25,50,265.25,49.5,266,48.75,266.5,48.25,267.75,47.5,269,47.5,270,47.75,270.75,48.25,272.25,47.75,273.25,48,274.25,48,275.5,48,276.5,48,277.5,48,278.5,47.5,279.25,47.25,280.25,47.25,281,47.25,282,47.75,281.75,48.5,282.5,49.25,283.25,50.5";
	areaArray[22]="510,196,508,196,507,194,506,194,506,193,506,190,508,189,510,189,514,191,514,193,512,195,511,195,510,195,508,195";
	
	//Array For storing area tag id's	
   
   areaName[0]="areaCanada1";
   areaName[1]="areaCanada2";
   areaName[2]="areaRussia1";
   areaName[3]="areaRussia2";
   areaName[4]="areaEgypt";
   areaName[5]="areaChina";
   areaName[6]="areaLatinAmerica1";
   areaName[7]="areaLatinAmerica2";
   areaName[8]="areaAustralia1";
   areaName[9]="areaAustralia2";
   areaName[10]="areaBrazil";
   areaName[11]="areaHongKong1";
   areaName[12]="areaHongKong2";
   areaName[13]="areaIndia";
   areaName[14]="areaJapan";
   areaName[15]="areaKorea";
   areaName[16]="areaSouthAfrica1";
   areaName[17]="areaSouthAfrica2";
   areaName[18]="areaTurkey";
   areaName[19]="areaUnitedStates";
   areaName[20]="areaEurope1";
   areaName[21]="areaEurope2";
   areaName[22]="areaSingapore";
               for(i=0;i<areaName.length;i++)
                {
                   $(areaName[i]).coords=areaArray[i]; 
                }

   }
   else if(siteid=="TNHK")
   {
		
		var arrayHk=new Array();
		
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaJapan\" name=\"areaJapan\" href=\"/Tools/Charting.aspx?typecode=NM939200&amp;span="+span+"\" title=\"Japan\" alt=\"Japan\" coords=\"188.5,66.5,187.5,66,186.5,65,185.5,64.5,185.5,63,184.5,61.5,183,59.5,182.5,58.5,181,57.5,180,56.5,179,54.5,179,53,179,52,180,50,181.5,49.5,182.5,47.5,183.5,46,184.5,44,186,43,187.5,41,190,40.5,192.5,40,195.5,39.5,198.5,38.5,201,38.5,201,36,201.5,34,202,32.5,201.5,30.5,201.5,29.5,202.5,28.5,204,29,205.5,28,206,26,207,25,209,25.5,210,24,211.5,23,211.5,21.5,210.5,20.5,209.5,19,208.5,19,208.5,17.5,208,15.5,207,13.5,206,12,205,11.5,205,10,203.5,8.5,202.5,8.5,201.5,7.5,200.5,6,200.5,4.5,200.5,3,201.5,2,200.5,0.5,201.5,0,203,0,204.5,0,206.5,0,209,0,210.5,0,212.5,0,215.5,0,218,0,222.5,0.5,221,1,219.5,2.5,218.5,2.5,218,2.5,218,4.5,217.5,5.5,216,6.5,213,6.5,211,6,210,5.5,210.5,7,213,8.5,214.5,11,213.5,11,211.5,11,210,10.5,210.5,12.5,212,14,214,15.5,216,17.5,218.5,21,218.5,26,218.5,29.5,220,33.5,220.5,36.5,222,40,222.5,42.5,222.5,44.5,220.5,45,218.5,45,217,46,215,46,213,46,211.5,45.5,209.5,48,208,49,208,51,206.5,51.5,205,52.5,203,52,201,51,200.5,50.5,199.5,53,197.5,53,195.5,53,195.5,55,194,56.5,190.5,55,191,57.5,191.5,59.5,191,61,188.5,60,190,62,190,63.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaChina\" name=\"areaChina\" href=\"/Tools/Charting.aspx?typecode=NM302400&amp;span="+span+"\" title=\"China\" alt=\"China\" coords=\"68.5,124,68,123,67,121,66,118.5,65,117.5,64.5,116,64,115,64,113.5,63.5,113,62,110.5,60.5,109.5,59,108,56.5,106,56,103.5,56,102,54,100.5,53.5,98.5,52,97,50,95.5,48.5,94,48,91.5,47.5,89,46.5,89,45,88.5,44,88,44,86,43.5,83.5,42,82.5,40.5,81,40.5,78.5,40.5,75.5,39.5,73,37,72.5,34,71.5,32,71.5,31.5,70,28.5,68,26,68,23,68,20.5,68,19,68.5,17.5,68.5,16,68,14.5,68,12.5,68,8,68,4,68,0,67.5,0,63,0,58,0,50.5,0,44.5,0,38.5,0,29.5,0,24,0,14.5,0,8,0,0,3.5,0,8.5,0,13,0,17.5,0,20.5,0,26.5,0,32,0,37,0,42.5,0,47,0,54,0,61,0.5,66,0,71,0.5,74,0.5,76.5,0.5,81,0.5,88,0.5,98,0.5,103,0.5,111.5,0.5,158.5,0.5,157.5,2,155.5,4,153.5,4,152,6,150,8,149.5,10.5,148.5,11.5,147.5,14,147,16.5,147,19,147.5,20.5,147,21.5,146,20.5,144,19,141,18.5,138,18,136.5,17.5,134,19,132.5,21,131,22,129.5,23.5,128.5,23,128.5,21.5,128,19.5,127,17.5,127.5,15,125.5,13,124,12,123.5,13.5,123.5,15,121,16,120,17.5,119.5,18.5,119.5,20.5,118,21.5,116.5,21.5,117,23,118.5,25,120.5,28,123,30.5,125.5,29.5,128,28,130.5,29,133.5,30.5,136.5,30.5,138.5,33,137.5,33.5,135.5,34.5,134,35,133.5,36.5,132,38,130.5,40,129.5,42.5,130,44.5,131,46,132.5,48,134.5,50.5,136.5,51.5,139,55.5,141.5,57.5,144.5,60.5,146,62,147,65,148,68.5,149.5,69,150,72,151,76,149.5,80.5,148,83.5,146.5,86.5,145.5,89,144.5,92,144,95.5,142.5,98,140.5,100,138.5,101.5,136,103.5,134.5,105,133,104,132.5,103,132,102,130.5,101,129.5,100.5,128.5,100.5,127.5,101.5,126,102,124.5,104,124,106.5,124.5,108.5,126,110,125,112.5,122,112.5,120,112.5,119,112.5,117,112.5,116,112.5,114,113,112.5,115,110.5,115.5,109,115.5,107,114,104.5,114.5,103.5,115,101.5,115,99,115,98.5,115,96,113.5,93.5,111,92,111,89.5,110,87.5,110,85.5,108,84,106,81.5,106,78,106,75.5,106,74,106,73,107,70.5,107.5,69.5,111,69,114,69,119,69.5,123.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaTaiwan\" name=\"areaTaiwan\" href=\"/Tools/Charting.aspx?typecode=NM915800&amp;span="+span+"\" title=\"Taiwan\" alt=\"Taiwan\" coords=\"155,112.5,154,112,153.5,112,153,111,152.5,110.5,152,109.5,151.5,108.5,150.5,107,150.5,105,150.5,103.5,151,101.5,151,100,151.5,98,153,97,154.5,96,156.5,98,156.5,100,156.5,102.5,156,104.5,156,106.5,156,108.5,156,110,156,112\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaThailand\" name=\"areaThailand\" href=\"/Tools/Charting.aspx?typecode=NM105769&amp;span="+span+"\" title=\"Thailand\" alt=\"Thailand\" coords=\"72.5,194.5,71.5,195,70.5,195,69.5,195,68,195,66.5,195,66,193.5,64.5,192.5,64,191.5,62.5,190.5,62.5,190,61,189,59,188.5,59,187,60,185.5,60,183.5,60.5,179,61,178,61,176.5,61,175,61.5,172.5,62,168.5,62,166,62,163.5,62,161,62.5,159,61.5,157.5,60.5,156,60.5,153.5,60,153.5,60,150,60.5,148,59,146.5,58.5,145,58.5,142,58.5,139.5,60,137,63,133.5,64.5,131.5,67.5,128.5,68.5,126,70,126,69.5,130,69.5,131.5,69.5,133.5,69.5,135.5,69,135.5,69.5,138,71,137,72,135.5,73.5,135.5,75,136,76,137.5,77.5,138.5,80,141,82.5,142.5,83.5,144.5,84.5,146.5,86,149.5,87,152,86.5,153,85,153,83.5,153,80.5,153,78,153,74.5,154,74.5,157.5,73,159,72.5,161,71.5,162,69.5,162.5,68.5,163.5,66.5,162.5,65,162.5,65.5,165,64.5,167,64,168,64,169.5,63.5,170.5,63,172,62.5,175,62.5,177.5,62,180,63.5,181,64,183,65,184.5,66,186.5,67.5,188.5,68,191,68,192.5,72,194\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaPhiliphines\" name=\"areaPhiliphines\" href=\"/Tools/Charting.aspx?typecode=NM860800&amp;span="+span+"\" title=\"Philiphines\" alt=\"Philiphines\" coords=\"186,200,185,199.5,184,199,182.5,199,181,197.5,180.5,196,179.5,193.5,181,193.5,181,192,179.5,191,179,192,178.5,192,177.5,192,177,191.5,174.5,190.5,174,191,173.5,192.5,172.5,194,171,193.5,171,192,171,190,171,188,171,186.5,173,186.5,173.5,185.5,174.5,183.5,174.5,182.5,173.5,182,172.5,180.5,172.5,178.5,172.5,176.5,171.5,176.5,170.5,176.5,169.5,176.5,169.5,175,169.5,173.5,170,171.5,170,170,169.5,168.5,168.5,166.5,167,166.5,165,166.5,162.5,165,160.5,165.5,159,167.5,159,170,158,172.5,157.5,173.5,157.5,175,157,177,155.5,178.5,154.5,179.5,154,181,153,181.5,151.5,182.5,150.5,184,149.5,184.5,147.5,185,147.5,183,148,181,149,179,150.5,178.5,151.5,177,153,176,154.5,174.5,155,172.5,157,170,157.5,168,159,164.5,160,163.5,161,162,161,160.5,160,158.5,159.5,157,159.5,153.5,158.5,153,157.5,152,156.5,149.5,156,148,156.5,146,155,142.5,156.5,140.5,157.5,139.5,157.5,137.5,157,136,157,133.5,157.5,132,158.5,131.5,159.5,131,161.5,132,163.5,132.5,164.5,134.5,164.5,137.5,165.5,141,166,144,165,145,165.5,147,165,147.5,163.5,148,163,151,165,151,167.5,153,169.5,154.5,171.5,156.5,173.5,155.5,175.5,155.5,177.5,158,177.5,161,177,163.5,178,165,179,163.5,180.5,164,182.5,166,183.5,169,184.5,171.5,185,174,183.5,175,185.5,177,187.5,179,187.5,181.5,189,185,189.5,187.5,190.5,191.5,191.5,194,191,196,188.5,197,187.5,199\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia1\" name=\"areaIndonesia1\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"45.5,202,47.5,201.5,50.5,202,53.5,203,56.5,205.5,59.5,209,62,210.5,64,211.5,66.5,212.5,68.5,214.5,71,216,73,217.5,74,217,76.5,219,78,220,80.5,220.5,82,222.5,84.5,225.5,85.5,228.5,87.5,231,90,233.5,89,235.5,87,237,88,239.5,89.5,238.5,91,238.5,94,238.5,96,241,97,244,99.5,244,102.5,244,104.5,244.5,105.5,246.5,104,247.5,102.5,247.5,99.5,247,97.5,247,96,248,95,250,94.5,253,93.5,255,94,258,94.5,260,95,262.5,96,261.5,98.5,261.5,101.5,262,104,264,106.5,265,109.5,267,112,266,113,265.5,116,265,118,265.5,121,265.5,123.5,265,125.5,266.5,129,267.5,131.5,267.5,134,267.5,135.5,270.5,135,271,134,272,135.5,273.5,138.5,273.5,141.5,273.5,145.5,273.5,149,273.5,152.5,273.5,156.5,273.5,159,273.5,161,274.5,164,274.5,170,274.5,174,273,177.5,273,179,272.5,181,272,183.5,272,185.5,272,188,271,190,270.5,192.5,271,194.5,273,193,276,190.5,277,188,278.5,185.5,279,184,280,182.5,281,182.5,283,180,283,178.5,284,177,285,176,285,175.5,286.5,175,287.5,173.5,287.5,171.5,287.5,170,287,170.5,286.5,172,286,173,285.5,174,285,174.5,283.5,177,282,179,279.5,179.5,278.5,179.5,277.5,177,277,175,276.5,174,276.5,171.5,276.5,169.5,276.5,166.5,277,164,278,161,277.5,163,280,163,281.5,160.5,281.5,160,281.5,160.5,283,158.5,284,156.5,283,155,282,155.5,280.5,156,278.5,155.5,278,154,279.5,152.5,279,152.5,278,150,277.5,147.5,277.5,145.5,278.5,143,278.5,141.5,278.5,137.5,277,133,276,128,275,125.5,275,123,275,119.5,274.5,115.5,273.5,113,273.5,110.5,272,107.5,272,105,272,102,272,100,271,98,270.5,97,268,94.5,267,92.5,267,91,265,89.5,263,86,260,84,257.5,81.5,255,79.5,254,78,250.5,75.5,247.5,74.5,244.5,73.5,247.5,72,246,70,244.5,69.5,247,67.5,245,67.5,244,66,243,65.5,241.5,64.5,239.5,64.5,238,61.5,235,61,233.5,61,232,62.5,232,63.5,233.5,64,235.5,66,237,67.5,239.5,69.5,238.5,73,240.5,72,238.5,71,236.5,68.5,236,67.5,234,66.5,232,64.5,229.5,63,229.5,61,229,61.5,228,62,227.5,62,226.5,62,225,61,223,59,222.5,58.5,223.5,59.5,225.5,59.5,227.5,58.5,229,56.5,227.5,56,225.5,55.5,223.5,54.5,222,54.5,221,55.5,220,57,221,55.5,218,53.5,218.5,52,218.5,50,217,48,215,48,214,49,212.5,50.5,214.5,52,216,53.5,216,53,214.5,53,213.5,51.5,211.5,50.5,211,48,209.5,47,207,46,205,45,203.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia2\" name=\"areaIndonesia2\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"112,222.5,113,224.5,115.5,226.5,117.5,228,119.5,229,121.5,229,123.5,229,125,227,126,225.5,127.5,225,129,224.5,131,224.5,131.5,223.5,134,222.5,135.5,221,136.5,219,136.5,217,137.5,215.5,139,214,141,212.5,144,210.5,144.5,208.5,146.5,208.5,148,208.5,150,208.5,152,209,151.5,211,150.5,212.5,150,215,152,216.5,154,219.5,154,221.5,153,223,154.5,224,155.5,226,153.5,226.5,152.5,226.5,151,226.5,151,228.5,151,230,149.5,231,148.5,232.5,149,234,148.5,236,147,237.5,146.5,238.5,146.5,240.5,145.5,240.5,143.5,241.5,144,243,144.5,245,144.5,246.5,143.5,247.5,143.5,249,144,251,142.5,252,140.5,252,138,251,137,250.5,136,250,134,248.5,130.5,248.5,129,248.5,127,248.5,125,248.5,123,248.5,120.5,247,118.5,246.5,117,246.5,117,245.5,116.5,244,116.5,243,116.5,241,115,239.5,114.5,238,114,240.5,113.5,240.5,112.5,240,112,239,112,238,111,237.5,110.5,236.5,109.5,234.5,111.5,234,112,232,111.5,230.5,111,229.5,111,228,111,227.5,110.5,226,110.5,224,111,222\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia3\" name=\"areaIndonesia3\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"162,262.5,160,262,160,261,158.5,260,158.5,258.5,158.5,257.5,158.5,255,159,254,160,252.5,158.5,250.5,157.5,250.5,156.5,249,156.5,248,156.5,245.5,156,244,156.5,242.5,156.5,241,157,239.5,158,238,159.5,237.5,159.5,236,159.5,234,159.5,232,161.5,230.5,161.5,229,161.5,227.5,163,225,164,224,167,224,168.5,225,171,225,174,225,177,225,179,224.5,180.5,224.5,182.5,223.5,183.5,222,186,223,185,225.5,184,227,182.5,228.5,180,229.5,177,229.5,175.5,229.5,173.5,229.5,172.5,229.5,170.5,230,169,229,167,229,165.5,229,164,229,164.5,231.5,163,233,162.5,234.5,164.5,234,166.5,235,169,234,170.5,233.5,171.5,232,173,232,174.5,232.5,177,232.5,177.5,234.5,178,236,178,238,177,238.5,175.5,239,174.5,240.5,173,239.5,171,239,173,241.5,172,243.5,170.5,243.5,169.5,243.5,169.5,245,171.5,245.5,173,248.5,174.5,250.5,176.5,252.5,176.5,256,175.5,259,175,260.5,173.5,260.5,171.5,259.5,171,258,170,257,169.5,255.5,169,254,169,253.5,169,252,168,250.5,167.5,253,166.5,252.5,165.5,251.5,164.5,250.5,164,250,163.5,251.5,163.5,254,162,255,162,257.5,162,260\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia4\" name=\"areaIndonesia4\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"211,251,210,250.5,209,250,207.5,249.5,206,248.5,203.5,248.5,202,248.5,201,249.5,200.5,250,199,250,197.5,250,197,249.5,196.5,249,196,249.5,195,250,193.5,250,191,250,191,249,192,248.5,192,247.5,192,246,194,246.5,195.5,246.5,197,245.5,199,245.5,200.5,245.5,202.5,245.5,204.5,245.5,204.5,244,206,244,207.5,244,209.5,242.5,209,242,209,241,208.5,240,208.5,238.5,210,237.5,212,237,211.5,235.5,211.5,234.5,211.5,233.5,210,233.5,210,232,211,231,213.5,232,215.5,232,218,232,219.5,232,221.5,232.5,224,233.5,226,234.5,228.5,234.5,230.5,235,232.5,235,235,235.5,235.5,237,235,238,233.5,237.5,231,236.5,230.5,236.5,229.5,237.5,230,240,231,242.5,229.5,243.5,231,244.5,230.5,246,232.5,245.5,233,244.5,235,246,237,246,238,245,238,243.5,238.5,242,237.5,241,237,240.5,238,238.5,239,238,241,237.5,243.5,238.5,246.5,238.5,249.5,241,251.5,243,254,244,254,243.5,254,242.5,255.5,243,257.5,244,260,244,261.5,244.5,263.5,246,265.5,247.5,267,247.5,268,249.5,268,252,266.5,253.5,264.5,256,263,259.5,264,263,262.5,265.5,261.5,268.5,261.5,270.5,260.5,274,259.5,276,259,278.5,258,277,256.5,275.5,254,274.5,252.5,274.5,249.5,273.5,247,275.5,245,274.5,242.5,273,243.5,271,245,270,247,267.5,248,265.5,248,263.5,246.5,260.5,245.5,260,243,258,238.5,256,237,255.5,232.5,254,230.5,253,225.5,253,227.5,252,224,253,223.5,252,223,250.5,221.5,249,220,247.5,219.5,245.5,219.5,244,219.5,243,220.5,242,219.5,240.5,218,239.5,217,239,215.5,239,212.5,238.5,212,240.5,211,241.5,210.5,244,209.5,245.5,208.5,245.5,206.5,245.5,211,247,211,249.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia5\" name=\"areaIndonesia5\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"214,273,214,272.5,213,272.5,213,271,213,269.5,213.5,269,215.5,269,215,271\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia6\" name=\"areaIndonesia6\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"228,267,227.5,265.5,227.5,264.5,227.5,263,227.5,262,228.5,261.5,229.5,263.5,229.5,265.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia7\" name=\"areaIndonesia7\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"198.5,238.5,198,238,197.5,238,197,237,197,236,197,234,196,232.5,196,230.5,197,230,197.5,228,197.5,226.5,198,225,198,224,198,222.5,198,221,198,219.5,199,218,200.5,217,202.5,218.5,202,220,202,222,201.5,223,202,225,202,226.5,202,228,200.5,228,201,229.5,201.5,231.5,201,233.5,199,232.5,200,235,200,236.5,199.5,238\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaIndonesia8\" name=\"areaIndonesia8\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"189.5,242,188.5,242,187.5,241.5,187,241,186,240.5,185,240.5,183.5,240.5,182.5,240,181.5,240,181.5,239.5,182.5,239,184,239,185.5,239,187,239,188.5,240,190.5,241\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaHongKong\" name=\"areaHongKong\" href=\"/Tools/Charting.aspx?typecode=NM934400&amp;span="+span+"\" title=\"Hong Kong\" alt=\"Hong Kong\" coords=\"126.5,109.5,125.5,108.5,127,107.5,127.5,106,129.5,105,131,104,132.5,105,134,106,134.5,107.5,134,109,133,109,132,110,131.5,110.5,130,111.5,128.5,111.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaSingapore\" name=\"areaSingapore\" href=\"/Tools/Charting.aspx?typecode=NM998100&amp;span="+span+"\" title=\"Singapore\" alt=\"Singapore\" coords=\"84,218,84,219.5,83.5,220,83,222,82,222.5,81,222,80,220.5,79.5,220.5,79,220,78,219.5,78,219,78,218,78,217,79,216.5,79.5,215,81,215.5,82.5,216.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaMalaysia1\" name=\"areaMalaysia1\" href=\"/Tools/Charting.aspx?typecode=NM105768&amp;span="+span+"\" title=\"Malaysia\" alt=\"Malaysia\" coords=\"78,219,77,218.5,74.5,217,74,217,73.5,216,72,215.5,72.5,214.5,72.5,213.5,72.5,211.5,71.5,210,70,208.5,71,205.5,70,205,70,204.5,69.5,203,67.5,202,69,201,69,199.5,68,199,66.5,198,66.5,197,66.5,195.5,68.5,195.5,69.5,194.5,71,194,73,196,75,198,77.5,199.5,79.5,201.5,81,203,81.5,205,81.5,207,81.5,208.5,81,210,81.5,212.5,82,214.5,84,215.5,85.5,215.5,85.5,217,86.5,218.5,85.5,218.5,85.5,221,86,224,84.5,224,84,223.5,83,223.5,83.5,222.5,84,221.5,84.5,220.5,84.5,219.5,84.5,218,83,217.5,81.5,216.5,80.5,216,79.5,215.5,79,217,78.5,218.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaMalaysia2\" name=\"areaMalaysia2\" href=\"/Tools/Charting.aspx?typecode=NM105768&amp;span="+span+"\" title=\"Malaysia\" alt=\"Malaysia\" coords=\"114.5,226,113.5,226,113,224.5,112.5,224,111,223,112.5,222,112,221.5,111.5,220.5,110,219,111.5,217.5,114,217,115.5,218.5,117.5,218.5,118.5,217,120,215,121,214,122.5,212.5,122.5,211.5,124,211,126.5,211,127,209.5,129,210,130,209.5,130,208,130,206,131,205,133,204,135,202.5,136,202,137,200.5,137.5,199.5,139,198,140.5,196.5,142,196,144,194,146,192,147,194,148.5,196,150.5,197.5,151.5,199,153,200.5,154.5,201.5,156,204,155.5,206.5,154.5,207.5,153,206.5,152,207.5,151.5,209,150.5,209,149,208.5,148,208.5,146.5,208,145.5,208,144.5,208,144,209,144,210.5,143,211,142,211.5,141,212.5,139.5,213,138.5,214.5,138,216,137,217,136.5,218.5,135.5,220,134.5,221,133.5,222,132.5,223.5,131,224,129,224.5,128,225.5,126.5,225,125.5,225.5,125,227.5,123,228.5,121,229.5,119.5,229.5,118,229,116.5,228.5,115,227.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaMalaysia3\" name=\"areaMalaysia3\" href=\"/Tools/Charting.aspx?typecode=NM105768&amp;span="+span+"\" title=\"Malaysia\" alt=\"Malaysia\" coords=\"83.5,215,82.5,215,82,214.5,81.5,213.5,81.5,212.5,81,211.5,81,210,81,208.5,81,207,81,205.5,81,204,82.5,205.5,83,207.5,83,209.5,83,211.5,83,213.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaKorea\" name=\"areaKorea\" href=\"/Tools/Charting.aspx?typecode=NM941000&amp;span="+span+"\" title=\"South Korea\" alt=\"South Korea\" coords=\"157.5,31.5,160,31,161.5,29,162.5,27.5,164.5,28.5,166,30,167,31.5,168.5,33.5,170.5,36,170.5,38,172,39,172.5,41.5,173,44,171.5,46,170,46,169,46,167.5,46.5,166,48,164,48.5,163,48.5,161.5,47.5,161.5,46,161,45,161,44,161,42.5,160,41,160,39,158,37,156.5,35,155.5,34,156,32.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaAustralia1\" name=\"areaAustralia1\" href=\"/Tools/Charting.aspx?typecode=NM903600&amp;span="+span+"\" title=\"Australia\" alt=\"Australia\" coords=\"125,345.5,127,345.5,129,343.5,130.5,341.5,132,339.5,134.5,339.5,136.5,340,138,339.5,141,338.5,145,337,148,336.5,151.5,335,155.5,335,159,332.5,161.5,329,165,326.5,165.5,322.5,166.5,319,168,317,170,317,172.5,317,173.5,314.5,175,314.5,177,313.5,177,312.5,178,310.5,178.5,309,179,308.5,180,307.5,181.5,306.5,183.5,304.5,185.5,304,187,303.5,190,304.5,192,306.5,194,308.5,196,308,196,306.5,198,307,199.5,307,200.5,306.5,201.5,304.5,203,303,204.5,302,205.5,299.5,206.5,297.5,207.5,296,208,294,207,294,206.5,292.5,206.5,290,207.5,289.5,209,289,211,289.5,213.5,289,215,289.5,216.5,291.5,218.5,292,220.5,293,222.5,294,224,293.5,225.5,294,227.5,294.5,228.5,292.5,230,292.5,232,293,232,291.5,233.5,291.5,235.5,291.5,237,292.5,236.5,294,235.5,295,236.5,297,237.5,299,236.5,299,236,301.5,235.5,302.5,235,304.5,236,306,233.5,306,231.5,306,230.5,307.5,232,309,232,311,229.5,311,231,313,233,314,235.5,315,237.5,318,240,319,241,317.5,243,318,245,318.5,246.5,319,247,321,246.5,322,245,322.5,248.5,323,250,323,252.5,321.5,254,320.5,255,318,256.5,316,256.5,313,257.5,311.5,258,309.5,259,306.5,259,305,259.5,302.5,259.5,300.5,259.5,298.5,259.5,297,259.5,295.5,260.5,292.5,262.5,291,264,288,265.5,290,265.5,291.5,265.5,293.5,267,295.5,267.5,298.5,267,300,267.5,302,267.5,304.5,265.5,305,267,307,269,306,270.5,307.5,272.5,309,274,311.5,274.5,313,274.5,315,275,316.5,274.5,318,274,319,275,321.5,275.5,323,275.5,326,275.5,328,276,330,276,332,277.5,333.5,279,336,280.5,336,282,336,283.5,337,285.5,338,286.5,341,286.5,343,286.5,345,287,347,288,349,289.5,349.5,291.5,351,292,352.5,292,354,292,356,293.5,358,294,360,295.5,361.5,297,361.5,299,361.5,300.5,362.5,301,364.5,300.5,366.5,299.5,369,299,370,298,372,297,375,296.5,379,296,382.5,294.5,386,293,389,291.5,392,289.5,395,288.5,397.5,286.5,399.5,284,402.5,281.5,404,279,406.5,277,409.5,274.5,410,273.5,412.5,270.5,415.5,269.5,418,267.5,419,264.5,420.5,265,422,264,423,263,424.5,262,426,261.5,428,260,429.5,258,430.5,255.5,433,252.5,433.5,250.5,433.5,248,433.5,245,435.5,242,437.5,238.5,438.5,235.5,436.5,232.5,436.5,230,436.5,227.5,438.5,226,438,222,436.5,220,435.5,217.5,435,214.5,432,214.5,429.5,215,427.5,215,425.5,216,423.5,216,422,214,422,212,421,209.5,422,207.5,422.5,205.5,422,204,422,204,420.5,204,419,204,418,203,417,201,416,201,413,201,411,201,410,201,409,201,408,200,406.5,200,405,198.5,404.5,196.5,404,194,402.5,191.5,402.5,189,401,188,400.5,186.5,400,183.5,400,182,400,181,400,179,401,178,401,175.5,401.5,174,402.5,171,403.5,168,404.5,164.5,404.5,161,405,160.5,406,158,406.5,156.5,407.5,154.5,409,152.5,410.5,150.5,412.5,148.5,413.5,146.5,412.5,143.5,412.5,141.5,412.5,139,412.5,137.5,412.5,135.5,412.5,133,413,130.5,415,129,415,127,415.5,125.5,417,125,418.5,123,418.5,119,418.5,118,418.5,115.5,417,112.5,414.5,111,412.5,111,410,111.5,408,111.5,407,113,406,115,405.5,116.5,404,117,400.5,118,396.5,118,393,118,391,118,387.5,118,385.5,118,382,118,379,118,375.5,117.5,374,115.5,372.5,114.5,369,115.5,367,116,365.5,116.5,364,118.5,364,118,362,118,358.5,118.5,354.5,119.5,353,121.5,351,121.5,349,121.5,346.5,123.5,345.5\">";
		arrayHk[arrayHk.length]="<area shape=\"poly\" id=\"areaAustralia2\" name=\"areaAustralia2\" href=\"/Tools/Charting.aspx?typecode=NM903600&amp;span="+span+"\" title=\"Australia\" alt=\"Australia\" coords=\"227,462.5,225.5,463,224.5,462,223.5,461.5,223.5,459.5,223.5,458,223.5,456.5,223.5,455.5,223.5,454,224.5,452.5,225,451,225,450,225.5,447.5,226,446.5,227.5,447.5,229.5,449,232,449,234,449,234,447.5,236,447.5,237.5,447.5,239,446,240.5,446,242.5,445.5,244,445,243,447.5,242,449.5,241,450.5,239.5,451.5,239,453,238.5,454,237,455,235.5,456.5,235,457.5,234,459.5,232.5,461,231.5,461,230,461,229,461.5\">";
		$("indicesMap").innerHTML=arrayHk.join("");
		
  
   }
   else if(siteid=="TNSG")
   {
   var arraySG=new Array();
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM939200&amp;span="+span+"\" id=\"areaJapan\" name=\"areaJapan\" title=\"Japan\" alt=\"Japan\" coords=\"224.25,47,223.25,46.75,222.75,46.5,222.5,45.5,221.75,44.75,221.25,44,220.5,43.25,220.5,42.25,219.75,41.5,219,40.5,218.25,40,217.75,39.25,217.25,38.5,217.25,37.75,217.75,37.5,217.75,36.75,218.5,36,219.25,36,219.5,35,219.75,34.75,220.5,34,220.75,33.25,221.25,32.5,221.75,32,222.25,31.5,223.25,30.75,223.75,30.5,224.25,30,225.25,29.75,226.25,29.25,227.75,29.25,229.25,29.25,230.25,28.5,231.5,28.5,233,28.5,233.25,28,233,27,233.75,27,233.75,26.5,234,25.25,234,24,234,22.5,234.25,22,235.5,21.75,236.25,21.75,236.25,21,237,20.75,237.25,20.25,237.25,19.25,237.5,19,238.5,19.25,239.25,19.5,239.25,19,239.25,18.5,239.25,17.75,239.75,17.5,240.25,17.25,240.25,16.5,240.25,16,240,15.25,239.75,14.75,239,14.25,238.75,13.75,238.25,12.75,238.25,12,237.75,11.25,237.5,10.5,237.75,9.75,237,8.75,236,8.25,235.75,7.5,235.5,6.75,234.5,6.5,233.75,6.25,233,5,233,4,233,3,233.25,2.25,233.25,1.5,233.25,0.75,233.5,0,234.25,0,235.25,0,236.25,0,237.5,0,238.5,0,239.75,0,241.25,0,242.75,0,243.75,0,245.5,0,246.5,0,248,0.25,248.5,1,247.5,1.5,247,1.75,246.25,2.25,245.25,2.25,244.5,2.25,244.5,3.25,244.5,4,245,5.5,243.5,5.5,242.75,5.5,241.75,5.25,240,4.5,238.75,4.25,239.25,5,240,5.75,239.75,6.25,240.75,7,241.5,8,242,8.75,240.5,8.25,239.5,8,238.25,7.5,239.25,8.5,239.75,9.75,240.5,10.25,241.25,11,242.5,12,243.5,13.75,244.75,15.5,245.25,17.25,245.25,18.75,246,20,245.75,21.5,245.75,22.75,246.5,24.25,246.75,25.75,246.5,27.25,247.25,28.75,248,30,248.5,31,247.75,32.25,246.75,32.75,246,32.5,245,33,243.75,33.25,242.5,33,241.25,33,240.5,33.25,240,34,239,34,238.5,34.75,238,35.75,237.75,36.75,236.75,37.25,235.5,37.25,234.5,37.5,233.5,36.75,232.75,36.5,232.5,37.5,232,38,231.75,38.25,231.25,38.25,230.25,38,229.75,38,229.75,39.25,229.25,40,228.25,40,226.25,40,226.75,41,226.75,42.25,226.25,43.25,225,43.25,224.75,44,224.75,44.75,225,45.75,225,47\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM935600&amp;span="+span+"\" id=\"areaIndia\" name=\"areaIndia\" title=\"India\" alt=\"India\" coords=\"64.25,50.75,63.5,50.75,62.5,50.75,62.25,51.25,62,51.5,61.5,51.75,61.5,52.5,61,52.75,60.25,52.75,60,53.25,59,53.5,58.5,53.75,57.75,53.75,57.5,53.75,57.25,53.75,57,53.5,56.5,53.25,56,53.25,55.25,53.25,55,52.5,54.25,52.5,53.25,52.5,53,52.5,52.5,52.5,52,52.75,52.5,53.5,52.5,54.75,53,56,53.25,56.75,53.75,57.75,54.25,59,54,60,53.5,61.25,53,61.5,52.25,61.75,51.25,62.25,50.5,62.5,50,62.75,49.5,63,49,63.25,48.75,64,48.25,64.75,47.5,65.75,47.5,66.5,47,66.75,46.25,67.5,45.75,68,45,68.5,44.5,68.75,43.25,69.25,42.75,69,42.25,69,41.25,69,40.25,69,39.25,69,38.5,69.25,38,70,38,71,38,71.75,38,72.75,37.75,73.5,37,74,36.25,74,35.75,74,35.5,73.5,35,73.5,34.25,73.5,33.75,73.5,33,73.5,32.5,73.75,32,74.25,31.5,74.75,31.25,76,31.25,76.75,32,76.75,33,76.75,33.75,76.5,33.75,77.5,33.25,77.5,32.5,77.75,31.75,78,31.5,79.25,32.25,80,33,81,34.25,82,34.75,83,35.75,84,36.5,85,37.5,85.25,38.5,85.25,39.5,85.25,40.25,84.5,40.5,84,41,83.75,41.75,84,42,83.75,42.5,83.5,43,84.5,43.25,85.25,44,85,44,86,44.75,86.75,44.75,87.75,45,89,45.25,90.25,45.5,91.5,45.75,93,46.25,94.5,46.5,96.25,47,97.5,47.25,98.5,47.5,100,47.75,101.25,48.25,102.5,49,104,49.5,105,50.5,106.25,51.25,107.75,51.75,109.25,53,111,53,112.75,53.75,114.5,54.5,116.25,55,117.5,55.5,119,56.75,120.5,58,121.75,58.5,122.75,58.75,123.75,59.25,124.75,59.75,125.75,59.5,126.25,59.75,127.5,60,129,61,130,61.75,131.5,63,132,64.5,132.25,65.25,131.75,66,131,66.25,130.25,66.25,129.5,66.5,129,66.75,128.5,67.25,128.25,68.5,128.25,69.5,128.75,70.75,128.75,71,128,71,127.25,71,126.75,70.75,126,70.25,125.25,70,124.5,70,123.5,70.25,123,70.25,122.5,70.25,121.75,70.25,121.25,70,120.75,69.75,120.25,70.25,119.75,71,118.75,71.25,118,71,116.75,71.5,116.25,71.5,115.25,71.5,114.5,71.5,113.5,70.5,112.25,70.5,111.25,70.5,110.75,70.5,109.5,70.5,108,69.75,107,70.75,107,71.5,106.5,71.5,106,71.5,105.25,71.5,104.25,72.25,104,73.25,103.75,73.75,103,74.5,103.5,75,102.75,75,102,75.5,101.75,76.25,101,77,101.25,78,100.25,78,98.5,78.25,97.75,79.5,97.25,80,96.75,81,96.5,82,95.75,82.5,94.5,82.5,94,83.75,93.25,84.25,92.5,85,92,85,91.5,85,90.75,86,89.25,87.75,88.75,88.5,88.25,89.5,87.75,90,86.5,90.75,85.5,91.25,84,91.25,83.25,91.25,82.75,91.25,82,91.5,81.5,92.5,81.5,92.75,81.25,92.75,80.75,92.75,80,92.5,79.75,92,79.25,91.5,78.25,91.5,77.5,91.5,76.75,92,76,92.25,75,92.25,74.25,93,73,93.75,73.5,94.5,74,94.5,74.75,95.25,75.75,96,75.75,96.75,76,97.75,76.25,97.75,77,97.75,78,97.75,79,97.25,80.25,98,80.5,98.5,81.5,99.5,81.5,100.25,80.75,101,80.5,102.25,80.5,103.25,80.25,104,80.25,105,80.5,106,81.25,107,82.5,107.25,83.25,107.75,84,108.5,85,108.75,85.75,109,86.5,110,87,110.75,87.5,110.75,87,110.5,85.75,110,84.5,110,83.5,110,82.5,110,81.75,110,81.25,110,80.75,109.5,80.75,109.5,80,109.25,79,109.25,78,109.25,77.25,109.25,76.25,109.25,75.75,109.25,75,109.25,73.75,109.25,73.25,109.25,72.25,109.25,71.25,109.25,70.75,109.5,70,109.5,69,109.5,67.75,109.75,66.75,109.75,65.75,110.5,64.75,110.75,64.5,111.75,63.5,112,62.5,112.5,62,112.75,61.25,113.5,60.5,113.75,59.25,114.75,59,114.25,58.5,113.5,58.5,113,58.75,112,59,111.25,60,110,60.5,109.25,60.75,108.25,61,107.75,61.25,107,61.5,107,62.5,106.5,63,106.25,63,105.25,63,104,63,103,63,102.25,63.25,101.25,63.75,100.75,64.25,100.5,65.75,99.75,66,99,66,98.5,66,97.75,66.25,97,66.25,95.75,66.25,94.5,66.25,94,66.25,93.75,66.25,92.5,65.75,91.75,65.75,90.75,65.75,90.75,67,90,67.5,89.25,67.75,88.75,68.25,87.75,68.75,86.5,68.75,85.25,68.75,84,68.75,83.25,68.75,82.5,68.75,81.25,68.5,79.5,68,78.25,67.5,77.5,67.5,76.25,67.25,75.5,66.75,74.75,66.5,73.75,66.25,73.25,66.25,72.25,66.25,71.5,65.75,70.75,65.25,70.5,64.5,70.5,64,70.25,63,69.5,62,68.5,61.25,67.75,60.75,67,60.75,66.75,60,66.25,59.5,66.25,58.75,66.25,58.5,66.25,58.25,66.25,57.5,66.25,56.75,66.25,56,66.25,55.75,66.5,55,67,54.5,67,53.75,66.75,53,66.5,52.5,66,51.75,65.5,51\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM958600&amp;span="+span+"\" id=\"areaPakistan\" name=\"areaPakistan\" title=\"Pakistan\" alt=\"Pakistan\" coords=\"52.25,52.75,52.25,54,52.25,55.25,52.75,56.25,53.5,57.5,54,58.75,53.75,60,53.5,60.75,53,60.75,52.25,61.25,51.25,61.5,50.25,62.5,49,62.75,48.75,63.5,48.25,64,47.75,65.25,47,66.25,46.25,67.25,45.75,67.75,45.25,68,44.75,68.5,43.25,69,41.75,69,40.5,69,39.75,69,38.5,69,38,69,37.75,69.75,37.75,71.5,37.5,72.75,37.25,73.5,36.25,73.5,36,73.5,35.25,73.25,34.25,73.25,33.5,73.25,32.5,73.25,31.75,73.75,31.25,74.25,31,75.25,30.5,75,30,74.75,29.5,74.75,28.25,74.75,27.25,73.75,27.25,73.5,26.5,72.25,25.75,72,25.25,71.5,24.5,70.75,24.75,70,24.75,69.25,25.25,68.25,26.25,67.75,27,67.25,27,66.25,26.75,65.25,26.25,64.5,26,64.25,25.75,64,25.25,63.25,25,62.25,25,61.75,25,61.25,25,60.5,25,59.5,25,59,25,58.5,25,57.5,26.25,57.5,28,57.75,29.25,57.75,30.5,57.75,31.75,58,33.25,58,34,58.25,34.5,58,35.75,57.25,35.75,56.75,36.75,56.75,37.75,56.25,38.75,55.75,40,55.25,40,54.25,40.75,53.5,41.5,53,42,52.75,42.5,51.75,42.75,51,42.75,50.25,43.25,49.75,43.5,49.5,43.5,49.25,44,48.25,44.5,47.75,45.5,46.5,46.5,46,47,45.25,47,44.75,47.5,43.75,48,43,48.75,43.5,49.25,44.5,50.5,45.5,51.25,46.75,52,47.5,53.25,47.75,54.25,48.25,55,48.75,55.75,49,57,49.5,58,50.5,58.75,51,59.5,51.25,60.5,52.25,60.25,52.75,59.25,53.25,58.75,53.25,58,53.25,57.75,53.25,57,53.25,56.5,53,56,52.75,55.25,52.75,54.25,52.75,53.75,52.5,53,52.25\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM302400&amp;span="+span+"\" id=\"areaChina\" name=\"areaChina\" title=\"China\" alt=\"China\" coords=\"101.5,11.25,100,12,99,12.25,98,12.5,98,13.75,98,14.75,97.5,16,97,16,95.5,15.5,93.25,15.75,92.5,15.75,91.5,16.75,91.25,18.25,91,19.25,90,19.75,89,19.75,87.25,19.75,85.75,19.75,85.25,20,84.75,21.5,83.75,22,82,22.25,80,22.25,78.5,23.75,78.5,24.75,77,25.75,75.75,25.75,75.5,25.75,74.5,25.25,73,25.75,71.5,27.25,71,27.25,70.25,27.25,69.25,27.75,68,29.5,67.5,32,67.5,32.75,67,33,66.25,33.75,65.5,34,65.25,34,63.5,35.25,62.75,35.75,62,36.5,60,38.75,59,39,58,41,57.25,42,57.25,43.5,57.25,44.25,57,45.25,57,46.5,56.75,48,56.75,49,57,49.75,57.75,50.25,58.75,51.25,60,52,61.25,52.5,61.75,52.25,62.25,51.25,63.25,50.75,64.5,51,65.5,51,66.5,52.25,67.25,53.5,67.25,54.75,66.75,55.5,66.5,55.5,66.25,55.75,66.5,56.5,66.25,57.25,66.5,58.25,66.75,59.25,67,60,67,60.75,67.75,60.75,69,61,69.75,61.25,70.75,60.75,71.75,60.25,72.75,60,73.5,59.75,74.5,60,75.5,60,76.75,60.25,78,60.5,79.25,61,80.5,61,82,61.5,83.5,61.75,85.5,62.25,87,62.5,88,63,89.5,64,90.75,65.25,91.5,65.5,92.5,65.5,92.5,65.25,93.75,63.5,94.5,62.5,95.25,62.5,97.25,62.5,98.5,62.5,100,63,101,63,102,63.75,102.5,63,103,62.5,104,63,105,63.25,106,63.25,106.25,62.75,106.75,62.25,107.25,61.5,108,61.5,108.75,60.75,110,60.5,111,60.25,112,59.75,112.75,58.5,114,58.5,115.25,59,116.75,59,117.75,59.25,118.75,59.5,119.5,60.5,120.75,61,121.5,61.75,123,62.75,123.25,64.75,123.25,65.5,122.75,66.75,122.75,67.75,122.5,68.25,123.5,69,125.25,69,126,68.75,126.75,69.25,127.5,70.25,128.5,71,129.25,73,130.5,73,131.5,75,132.25,77,133.5,78.5,134.5,80,135,81.75,134.75,82.5,134.75,83.75,134.75,85,135,86.75,135.25,87.5,135.5,88.5,135.75,90,136,90.75,136.25,91.5,136.25,93,136.5,90.5,136.5,89,135.75,87,135.75,85.25,135.75,84.75,136,83.25,136,82,136.25,80.75,136.75,79.75,137.75,79,139.25,79,140.75,79,142.5,79.75,144.75,80.75,146.5,81,148.25,82,149.5,82.25,150.75,82.75,151.75,82.75,153,83.25,154.75,83.5,155.75,83.5,157.25,83.5,157.75,83,159,82.5,160,82,160.75,82,162,81.75,163.75,82.5,165.25,82.5,166.75,82.5,168,83,170.25,82.75,171.75,81.75,173,81.5,174.5,81.5,175.75,80.5,176.75,80,178.75,79.75,180.5,79.25,180.25,79,180,78.25,179.5,78,179,77.25,178.25,77,178.25,75.75,178.5,74.5,179,73.5,179.75,72.75,180.75,72.75,182,72.75,182.25,73.5,183.25,74.5,184.25,75,185.25,75.75,186.5,75.75,187.25,75.25,188.25,74.5,188.75,74,189,73,189.5,72.25,189.75,71.75,190.75,71.75,192.25,70.75,192.25,70,192.75,68.75,193,68.25,193.25,67,194,66.25,194,65.25,194.5,63.75,195.25,62.5,195.5,60.75,196,59.75,196.25,58.5,196.25,57.5,196.75,56.25,197.5,55.25,197,54.25,197,53.5,197,52.75,197,52,197,50.75,196.75,50,196.25,49,195.75,48.25,195.25,47.75,195.25,47,195.25,46.25,195.25,45.25,194.75,45.25,194.75,44.75,193.75,44,193.25,43,192.5,42.75,191.5,41.5,191.25,41.25,190.75,40.75,190.25,39.75,189,39.25,188.5,39,188,38,187.75,37,187.25,36,186.25,34.75,185.5,34.25,184.25,33.75,184,33.75,183,33,182.25,32.25,182.75,31.75,182.75,31.5,183,30.75,183.25,30,183.25,29.75,183.5,29.25,183.75,28.5,184.75,27.25,185.5,27.25,186,27,186,26,186.75,25,187.75,24.75,188.5,24.75,188.5,23.75,187.75,23,187,22.5,186.5,22,186,22,185.75,22,185,22,184.5,22,184,22,182.75,21.5,181.5,21.75,180.75,21.75,180,22.25,179.75,22.75,179.5,23.5,178.25,23,177.5,22.5,177,21.5,176.25,20.25,175.25,20,174.25,20,173.5,19.75,172.75,19.75,171.5,19.25,171.5,18.75,172.25,18.75,173.25,18.75,174.25,18.25,174.5,17.25,173.75,16.75,172.75,16.5,173.5,15.75,174.25,15.75,175,15.75,175.5,15.5,175.75,15,176,14.25,176,13,176.25,12.25,177,12.25,178,12.25,178.75,11.5,178.5,10.75,179.25,9.5,180,9.5,180.5,10.25,181,11,182.25,10.5,183.5,11,183.25,11.5,183.25,12.25,183,12.75,182.5,13,182.75,13.75,182.75,15,183.5,16,183,16.5,184.5,17,184.25,17,184,17,185,16.5,185.5,16,185.75,15.25,186.75,14.75,187.25,14.5,187.5,14,187.75,13.25,189,13.75,189.75,13.75,191.25,14,192.5,14.5,194.75,14.75,196,15.25,196.75,15.25,198,14.75,198.25,13.5,199.5,12.25,200,9.5,201.5,6.75,203,4.75,203.25,3.75,204.75,2.75,206,1.25,207.5,0.25,206,0.25,205.25,0.25,204.25,0.25,203,0.25,201.25,0,200.25,0,199,0,197,0,194.25,0.25,192.75,0.25,191.5,0.25,190,0,189,0,187.75,0,186.75,0,185,0,183,0.25,181,0,178.75,0,177.25,0,175.5,0,174,0,172.25,0,170.75,0,169.25,0,168.5,0,166.75,0,165.5,0,163.75,0,161.75,0,159.75,0,158.5,0,157.25,0,156.25,0,154.5,0,152.75,0,151.5,0.25,150.75,0.25,149.75,0.25,149.25,1,149,2,148.25,2.75,148.25,3.5,148,4.75,147.75,5.75,147.75,7,146.75,8,146.25,9.25,144.5,10.75,144.25,13,144,15.25,142.75,16.75,140.75,18,138,18.5,136.25,19.5,134.5,20.75,132.75,21.5,130.75,21.5,129.75,22,127,22.25,124.25,22.25,121.75,21.75,119,21.5,117.75,19.75,116,19.25,114.25,19.25,113.5,19,112.5,18.75,111.25,17.75,110,16.25,109,15.25,107.75,14.25,107.25,13.75,106.75,13.75,106,13.75,105.75,13.75,105,12.75,104,12,103,12\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM914400&amp;span="+span+"\" id=\"areaSrilanka\" name=\"areaSrilanka\" title=\"Srilanka\" alt=\"Srilanka\" coords=\"72.5,127.75,72.25,127.75,72.25,128.75,72,130,71.75,131.5,71.5,132.75,71.5,134,71.75,135.25,71.75,136.25,72,137.5,72.25,138.5,72.75,140,73.5,141.25,74.5,141.25,75.25,140.75,75.75,140.25,76.75,140.25,77.5,140.25,78.25,139.5,78.25,138.75,78.25,137.75,78,136.75,78.25,136.25,78,135.25,77.5,134.5,77.25,133.75,76.75,132.75,76.5,132.25,76,131.5,75.5,130.75,75.5,130.25,75.25,130,74.5,129.75,74.5,129,73.75,128.25,73.25,127.75\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM915800&amp;span="+span+"\" id=\"areaTaiwan\" name=\"areaTaiwan\" title=\"Taiwan\" alt=\"Taiwan\" coords=\"200.5,79.75,200,79.5,199.5,79.25,199.25,78.75,199,78.5,198.75,78,198.25,78,198.25,77.25,197.5,76.75,197.5,76,197.5,75.25,197.5,74.75,197.5,74.25,197.5,73.25,197.75,72.5,197.75,72,198.25,71.25,198.75,70,199,69.75,199.5,69.25,200,69,201,69.5,201.25,70.5,201.5,71.25,201.75,72.25,201.75,73.25,201.5,74.25,201.25,75.25,201,76.25,201,77.25,201,78.5,201,79.5\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105769&amp;span="+span+"\" id=\"areaThailand\" name=\"areaThailand\" title=\"Thailand\" alt=\"Thailand\" coords=\"136.25,92.75,137.25,93,138,93.25,138.75,93.25,139.75,94,139.75,94.75,140.5,95.25,141.25,96.75,141.25,97.5,141.25,98.25,141,98.75,142,98.75,142.5,97.75,143.25,97.25,144,97.25,145,97.75,146,98.25,147,99.75,148,101.25,148.75,102.5,149.5,104,150.25,105.75,151,106.5,150.25,107,149.25,107.75,148,107.75,147.25,108,146.5,108.75,146.75,109.5,146.75,110.75,146.5,112.75,145.75,113.5,144.5,113.5,142.75,113.5,141.5,113.75,140.25,113.75,139.75,114,138.75,114.5,138,115.25,137.75,116.25,137.75,117.5,137.25,118,137,118.5,136.75,119.5,136.25,120.25,136,121.5,135.75,123,135.25,124.25,135,124.75,134.5,125.75,134.5,126.5,135.25,127,136.5,127.25,137.25,128.5,137.25,129.5,137.5,130.75,138,131.75,138.25,133.25,138.75,134,138.5,134.75,139.25,135.5,139.25,137,138.5,137.25,137.75,137.25,137.5,136.75,137.25,136.25,137,136,136.5,135.75,136.5,135.5,136,135.25,134.75,135,134.5,135,133.75,134.75,133.75,134,132.75,133,132.75,132,132.5,131.25,132.5,131,132.5,130.5,132.5,129.75,132.75,129.25,132.75,128.75,133.25,128,133.75,127.5,134.25,126.75,134.25,125.5,134.25,125,134.25,124.5,134.25,123.75,134.5,122.75,134.75,122.25,134.75,121.25,135,120.75,135,119,135.75,118.25,136,118,135.5,117.5,136.25,116.25,136.25,115.75,135.75,114.75,135.25,114.5,135.25,113,134.25,111.5,133.5,110.75,133,110.25,132.5,108.75,131.5,107.5,131.5,106.25,131.5,105.5,131.25,104.75,131.25,103.5,131.25,102.75,131.25,101.75,131,100.75,131,99,131,97.5,132,96.5,133.25,96.5,134,95.25,134.25,94.75,134.75,93.75,135.25,93.25,135.5,92.5,136,92.25\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM860800&amp;span="+span+"\" id=\"areaPhiliphines\" name=\"areaPhiliphines\" title=\"Philiphines\" alt=\"Philiphines\" coords=\"195.75,134,195.5,133.75,195.25,133,195.25,132.5,195.5,131.75,195.5,131,195.75,130.75,196,129.75,196.25,129,196.5,128.5,197.25,128,197.75,127.5,198,127,198.5,126.5,199.5,125.75,200,125.25,200,124.75,200.25,123.75,201.25,123,202,122.25,202,121.5,202,120.75,202.5,120,203,119.5,203.25,119,203.25,118,203.5,117.25,203.5,116.25,203.5,116,204,115.75,205,115.25,205.25,114.75,205.25,113.75,205.25,113,204.25,112.5,203.75,111.5,203.5,111.25,203.25,110.5,203.5,109.75,203.75,109,203,108.75,203,108.25,202.75,107.75,202.5,107.25,202.5,106.75,201.75,106.5,201.75,105.5,201.75,105,201.5,104.25,201.25,103.75,201,102.75,201,102,201.25,101,201.25,100.25,201.75,99.5,202,99,203,99,202.75,98.5,202,98,202.25,97.5,202.5,96.5,202.5,95.75,202.5,95,202.5,94.25,203,93.25,203,92.75,203.75,92.75,204,93.75,204.75,93.75,205.5,93.75,206.25,93.75,207.25,94.25,207.5,95.75,207.5,96.75,207.5,97.75,208,98.5,208.5,99.5,209,100.5,208.75,101.25,208.5,102.25,208,103,208.5,103.75,208.5,104.75,207.75,105.25,207,105.25,206.75,105.5,206.5,106.25,207.25,106.75,208.25,107,209,108,209.75,108.75,210.5,109.5,212,110.25,213.25,110.25,214.25,110.25,215,110.25,216,111.25,216.75,112,216.75,113.5,216.25,114.5,216.25,115.75,217.5,115.75,218.75,115.75,219.5,116,220.25,117.25,221,118.5,221.25,120,221.5,121.5,222.25,123.25,221.5,124.5,221.75,125.5,223,126.25,223.75,127,224,128.25,223.75,128.75,224.25,130,224.75,131,225,132.25,225.5,133.5,225.75,135,226,136,226,137.5,225.5,139,225,139.75,224.5,140.25,223.75,141.5,222.75,141.75,222,141.75,221,141.25,220,141.25,219,140.25,219,139.75,218.75,139,218.75,138.5,218.75,138,218.75,137.5,218.75,137,218.5,136.75,217.75,136.75,216.5,136.75,216.5,136,215.5,135.75,214.75,135,213.75,135.75,212.75,136.25,212,136.5,211.25,135.5,211.5,135.25,211.75,134.75,212,134.25,212,133.5,212,132.75,212.25,131.75,213.25,131.5,213.75,131,214,130.5,214.25,130.25,214.75,129.75,214,129,213.5,128.25,213,127.75,212.75,127,212.25,126.25,212.25,125.25,211.75,125.25,211.5,124.75,211.25,124.5,211,123.75,210.75,123,210.75,122.75,210.75,122,211,121.25,211,120,210.5,119.25,210.25,119,210.25,118.5,209.75,118.25,208.75,118,208,117.75,207.5,117.5,207,117.25,206.25,117.25,205.25,117.25,204.75,117.75,204.25,117.75,204,118.25,204,119,203.75,120.25,203,121.25,202.75,122.5,202.25,123.25,202,124,202,124.75,201.5,125.5,200.75,126,200.5,126.75,200,127.5,199.25,127.75,198.5,128.75,197.75,129.5,197.25,129.75,196.5,130.5\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105768&amp;span="+span+"\" id=\"areaMalaysia\" name=\"areaMalaysia\" title=\"Malaysia\" alt=\"Malaysia\" coords=\"170.25,157.5,170.25,158.5,170.75,159.75,170.75,161,171.5,161.75,172.5,162.75,173,163.75,173.5,165,174.75,165,176,164.25,177.5,163.75,178.75,162.75,179.25,161.5,181,160.5,182,160.25,183.25,159.75,184.25,158.75,185.5,158.75,186.5,157.5,187.25,156.25,187.75,154.5,188.75,154.5,189.75,152.75,190.75,151.5,191.5,150,193,149.25,194.75,148,195.5,146.75,196.5,145.75,197.75,145.75,198.5,144.75,198.75,145.5,199,146.5,200,146.75,200.75,146.75,201,146.25,201.5,145.75,201.5,145,201.25,144.75,202,144.5,202,144,201.5,143.25,200.75,142.75,199.75,142,199.25,141.75,198.5,141.5,198,140.75,197,139.75,196,138.75,195.5,138,194.75,137.25,194.75,136.5,194.25,136.5,193.75,137.25,193,138.25,192.25,138.75,192,139.75,191.5,140.25,191,140.5,190,141.5,189,142.5,188.5,143.25,187.5,144.25,186.5,144.75,185.5,145.25,184.5,146.25,184.5,147.5,183.75,148.5,183,149,182.25,150,181.5,150.5,180.5,150.75,180,151.25,179,151.5,178,151.5,177,151.75,177,152.75,177.25,153.75,176.5,154.5,175.25,154.75,175.25,155.75,175,155.75,174.5,155.75,173.75,155.25,172.75,155.25,171.5,156,171,156.5,170,156\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105768&amp;span="+span+";\" id=\"areaMalaysia2\" name=\"areaMalaysia2\" title=\"Malaysia\" alt=\"Malaysia\" coords=\"138,137.5,138.75,137,139.25,136.5,140,137,141,137,141.75,137.5,142.5,137.75,143.25,138.25,144.25,139,145.5,140,146.5,141,147.25,142,148,142.75,148.75,143.75,149.5,145.25,149.75,147,150,148.25,150,149.5,150,150.75,150.25,153,151,152.75,151.5,152.5,152.25,153.5,152.25,154.75,152,155.75,152.25,157.25,152.5,158.25,151.5,158.25,151.25,158.25,150.75,157.5,150.25,157.5,150,157.25,149.5,157,149.25,156.25,149.5,155.75,150.25,155.25,150.25,154,149.75,151.75,149.75,152.5,149,151.25,147.75,151.25,146.5,151.5,145.75,152.25,145.25,153,145,154,145.5,155,146.25,156,147,156.25,148,156.25,147.75,157,147.5,157,146.75,157,146,156.75,145.5,156.5,144.75,155.5,144.75,154.5,144.5,153.75,143.75,153.5,143,153,143.5,152.25,143.5,151.75,143.25,151.25,143,150.75,142,149.75,141.75,148.5,141,147,141,146,141.25,145,140.25,144.5,139.75,143.5,139.75,142.5,140.25,142.25,140.25,141.75,140.25,141,139.5,140.75,138.75,140.5,138.25,139.5,137.75,138.75,137.75,138\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia\" name=\"areaIndonesia\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"170,157,169.5,158,169.5,159.25,169.25,160.5,169,161.5,169.25,162.25,169.5,163.5,169.5,164.5,170,165.75,170.25,166.75,169.5,167.25,170,168,170.75,168.75,171,169.75,172,169.75,172.5,168.75,173,169.5,173.5,170.5,173.5,171.5,173.25,172.5,173.5,173.5,174,174.75,174.75,175,175.5,175,176.5,174.75,177,175.5,177.75,175.75,178.75,175.5,179.5,176,180.5,176,181.5,176,182.25,175.75,183.25,176.25,184.25,176.25,185.25,176,186.25,176.75,187.5,177,188.25,178,188.5,179,189,178.5,189.5,178,190.5,178,191.25,178.25,192,178.25,193,178.25,193,177.75,192.75,177,192.75,176,193.25,175.5,193.25,175.25,193.5,174.75,193.5,174.25,193.5,174,193.75,173,193.5,172.5,193,171.75,193.5,171.25,194,171,194.5,170.5,195,170,195,169.75,195,169,194.5,169,195.25,168,195.75,167.5,196.5,167,196.75,166.5,196.75,166,197,165.5,196.75,165,196.75,164.25,197,163.5,197.25,163.25,197.5,163,198.25,162.75,197.75,162,198,161.25,198.25,160.5,199,159.75,199.75,160,200.5,160,200.75,159.75,200.75,159.25,200,158.75,199.25,157.75,198.75,157.25,198.75,157,200,157.25,200.25,156,200,154.5,199,154.25,198.5,154.75,198,154,197.75,153.25,197.25,152.5,197.75,152,197.75,151.25,197.75,150.25,197.75,149.75,198.5,149.75,199.25,149.5,199.25,149,199.25,148.25,199,147.25,199,147,198.75,146,198.5,145.5,198.75,145,198.5,144.75,198.25,145.25,197.5,145.5,196.5,145.5,196.25,146,196,146.25,195.5,146.75,195.25,147.25,194.5,148.25,193.75,148.5,193,149,192.5,149,192,149.5,191,150,190.5,151.25,190,152,189.25,153.25,188.5,154,188,154.25,187.75,154.5,187,155,187.5,156,187,156.5,186.5,157.25,185.75,157.75,185.25,158.75,184.25,158.75,183.25,159.5,182.5,160,182,160,181,160.5,180.25,160.5,179.25,161.5,178.75,162.5,178.5,163,177.75,163.25,176.75,163.75,176.25,164.25,175.5,164.5,174.75,164.75,173.75,164.75,173,164.5,172.75,163.5,172.75,162.75,172,162.5,171.25,161.5,170.75,161,170.75,160.5,170.75,160,170.5,159.5,170.25,158.75,170.25,157.75\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia2\" name=\"areaIndonesia2\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"148.75,156.5,148,157,146.75,157.25,145.75,157.25,145,156.75,144.25,156.25,144.25,155,144.25,154.25,143.75,154,143.25,153.75,143,153,142.75,152.75,142.25,151.75,141.5,150.75,141.25,149.75,141.25,151,141.75,152,142.25,153.25,141.75,153.75,141,153,140.5,152.25,139.5,151,138.25,150,137.5,149,137.75,150.25,138.25,151,138.75,151.75,139.25,152.5,139.75,153.25,139.5,154.25,138,154.25,137.25,152.75,136,151.25,135,150,134,149,133.25,148,132.5,147,131.5,145.75,130.75,144.75,129.25,143.5,127.5,143.5,126.25,143.25,125.25,143,123.5,142,123.25,143.75,123.75,145,124.5,146.5,125.5,147.5,126.75,148.5,128.25,150,129.5,150,130.5,151.25,131,152.75,130,152.25,128.75,150.75,128.75,152,129.5,153.5,129,153.75,128.25,153.25,127.75,152.5,127,152,126,151.5,125.25,152,125.5,153.25,126.75,154.25,127.75,154.75,129,154.75,130.25,154.75,131.5,155.25,131.5,156,130.75,156,129.75,156.5,130,157.25,130.5,158.75,131.5,159.5,131.75,160.5,132.25,161.25,133.25,161.75,133.75,161.25,133.5,160.25,133,159,133,158,132.75,157,133.5,157.75,134.5,159,135,159.75,135.25,161.25,135,162.5,134,163.25,134.25,164.5,134.25,165.25,135,166.25,135.75,167.25,136.75,168.5,137.25,169.75,138,171,138.5,172,139.5,172.75,140,174,140.5,175,141,174.75,141.5,174.25,141,173.25,141.75,173.75,142.5,173.75,142.75,174.5,143.5,175.25,143.5,174.25,143.5,173.5,143,173,142.5,172.75,141.75,172.5,141.25,172,140.75,172,140.25,171.5,139.75,171.25,139.25,170.25,138,169.25,137.75,168.25,137,166.75,136,165.5,135.75,164.75,135.25,163.5,136.25,162.5,137,163.25,137.25,164,137.75,164.75,138.25,165.75,138.75,166.5,139.5,167.75,140.25,168,139.75,167.25,139.5,166.25,138.75,165.25,138.5,164.5,137.75,163.25,138.5,163.25,139.5,164,139.75,165,140.5,166,141.25,166.75,141.25,167.75,142,168.5,142,169.25,142.5,170.5,142,170.5,141.5,170.25,141.25,169.5,140.5,169.25,140.75,170,141.25,171,142,171.75,142.75,172.25,143.75,172.75,144.5,173.75,144.75,174.75,145.25,176,146.25,176.5,146.75,177.5,147.5,178.25,148.25,179.25,149,180.5,150,181.25,151.25,182,152.25,183.5,153.5,185,155,185.75,156.5,186.5,156.5,187.5,157,188.75,157.5,189.5,158.75,189.5,159.75,190,161,191.25,162,191.5,163.5,191.75,165,192.25,166.5,192,168,192,169.5,192.25,171,193,172.25,193,173.25,194,175,194.5,176.5,194.5,179,194.25,180.5,194.25,181.75,195.25,183.75,195.5,185,195.5,186,196,188,196.25,189.5,196.25,190.75,196.5,192.25,196.5,193.25,197,194.75,197,197.25,197,198.5,196.75,199.75,197.5,201.25,197.25,201.5,198,201.75,199,201.75,200.25,202.75,200.5,203.75,200.75,204.5,201.25,205.75,202.5,206.5,202.25,206.25,200.75,205.5,200.25,205,199.75,204,199.25,204.75,199.25,205.75,199.5,206.75,199.5,206.75,199,206.5,198.75,206,198,206.25,197.5,205.75,197.25,206.75,196.75,207.5,196.25,208.5,196.75,209.5,196.75,210.75,196.5,211.5,195.75,212.75,196,213.75,195.75,215,195.75,216.5,196,217.75,196.25,219,196.25,218.5,197,217.75,197,217.5,197.5,216.5,198.75,216,199.5,215.75,200.25,215.5,200.75,214.75,201,214.25,201.5,213.75,202,213.25,202,212.75,202,211.75,202.25,211.5,203,212.25,203.5,213.5,203,213.75,203.75,214.75,203.25,215.25,202.5,215.5,202.25,216,202,216.75,202,217.25,201.75,217.25,201,218,201,218.75,201,219.75,200.5,220,199.75,220.75,198.75,221.5,198.5,222,198.25,222.75,197.5,223.5,197.25,224.75,197,225.5,196.75,226.25,195.75,227.25,195.75,227.75,195,228.5,194.5,228.75,193.75,228.75,193.25,228.75,192.5,227.5,191.75,226.75,191,225.75,191.25,225.25,191.75,224,191.5,223.75,192.25,223,193.25,222,193,221,193,219.75,194,218.75,193.75,217.75,193.5,217,193.75,216,193.75,215.25,194.25,214.25,194.25,213.5,194.25,213.5,194,212,194,211.5,194,210.5,194,209.25,194.75,208,194.5,206.75,194.5,204.25,194.5,203.25,193.75,201.5,194.75,200.75,194,200,193.5,198.25,193.5,196.5,193.5,194.75,193.5,193.5,193.5,192.75,194,191.75,194,190.5,194,188.75,193.75,187.5,193.25,186.25,193.75,185.5,193.5,185.25,192.75,185.75,192.25,186.5,192,187.5,192.5,187.75,191.75,187,191.25,186.5,191,186.5,189.75,186,189,185.25,188.75,183.5,188.75,182.75,189,181.75,189,180,188.75,178.25,188.75,178.25,188,178.5,187.5,177.5,187.25,177.25,187.5,177.5,188.25,177,188.75,176.25,188.5,175.25,188,175,187.75,174,187.5,173,187.5,172.25,187.5,171,187.75,170.75,188.75,170.25,189.25,169.75,189,169,189,168,188.25,167.25,188.25,166.5,188.25,166.5,187.75,166,187.25,165.25,186.75,164.75,186.75,163.75,186.5,162.75,186.75,162.25,186.25,161,185.25,160,185,158.25,185.25,158,184.75,157.75,183.75,157.75,182.75,158,180.75,158,180.25,158,179.5,158,179.25,158,178.25,158,177.5,159,177.5,159.25,176.5,159.25,175.25,160,174.5,161,174.25,161.75,174.5,163,174.75,164,174.75,164.75,175,165.5,175,165.25,174,165.25,173.25,164.75,173,163.75,172.5,162,172.75,160.75,173,160.25,173,159.5,172.5,159.25,171.5,159,170.25,157.75,169.25,156.75,168.5,155.5,168.75,154.25,169.25,154,170,153.25,169,153.25,168.25,153.5,167.5,154.25,167,154.25,166.5,154.25,166,154.25,165.25,154.5,164.75,154.25,164,154,163.25,153.5,162.75,153.25,162,153.25,161.25,152.5,161,152.75,160,152.75,159.25,152.5,158.75,152.5,158,152,158.5,151.5,158.75,151.25,158.25,150.75,158,149.75,157.25\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia3\" name=\"areaIndonesia3\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"205.5,185.75,205,185.5,204.75,185.25,204,184.5,203.75,183.75,203.75,183,203.75,182,203.75,181,204.5,180,204.5,179.5,204.5,179,204.5,178.25,204.25,177.5,203.75,177.5,202.75,177,202.5,176.5,202.5,175.5,202.25,174.25,202.5,173.25,202.5,172.5,202.5,171.75,203.25,171,203.5,169.75,203.5,169.25,204,168.25,204,167.25,204,165.75,204.25,164.75,205,164,205.25,163,205.25,162,205.25,161.25,205.75,160.25,206.25,159.25,206.75,158.75,208.25,158.75,209.5,158.75,210.5,158.75,211.5,159,212.25,159.75,213,159.5,214,159.5,214.75,159.5,215.75,159.75,216.75,159.25,217.75,158.75,219,158.75,220,158.5,220.75,157.25,222,157.25,222.5,158.5,221.75,159.25,221.25,160,220.75,161,219.75,161.75,218.75,162,217.75,162,217,162,215.75,162,214.5,161.75,213.25,161.5,212,161.25,212.25,162,212,162.75,211.25,162.5,210.5,162.25,209.5,161.5,208.5,161.25,207.5,161.25,207,162,206.25,162.75,207,163.75,207,164.5,206.25,164.5,206,164.5,205.5,165,205.5,166,206,167,207,167.25,207.25,166.75,207.75,166.25,208,165.75,209,165.5,209.75,166.25,211,165.75,211.5,165.25,212.25,165.25,212.75,164.75,213.75,164.75,214.75,165.25,216.25,166,216.5,167.5,216.75,168.75,215.75,169.25,214.25,169.25,213.5,169,212.75,169,212.5,170.25,213.25,171.75,212,171.75,211.5,172,210.75,172,211.5,173.5,212.5,175,213,176.25,213,177.75,214.25,177.75,214.75,178.5,215.5,179.25,215.5,180.5,215.25,181.25,215.25,182.25,215,183.5,213.75,184.25,212.75,184,212.25,183.75,211.5,183.25,211.5,182.5,211.5,182,211.25,181.5,211.25,180.75,211.25,179.75,211.25,179.25,211,178.5,210.75,178,210,179,209.5,179.5,208.75,178.75,208.5,178,207.75,176.75,206.75,177,206.75,178.25,207,179.75,207.25,180.75,206,180,206,180.75,206.25,181.75,206.25,182.5,205.75,183.25,205.5,184.25,205.75,185.5\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia4\" name=\"areaIndonesia4\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"231.75,169.5,231,169.25,230.75,168.75,230.5,168,230.5,167.5,230.75,167,229.75,166.5,229.75,164.25,229.75,163.5,230.5,162.75,231,162.5,231.25,161,231.25,160,230.5,159.25,231,158.5,231,158,231,157.5,230.5,156.75,230.75,155.75,231.25,154.75,231.5,154.25,232.25,153.5,233.25,153.25,233.75,154.5,233.75,156.25,233.5,157.5,234,158.5,233.75,159.5,234,161,233.75,161.75,233,162.25,233.5,163.25,233.75,164.5,233.25,165.25,232.5,165.25,232,165,231.75,165.75,232.5,166.75,233,168.25,232.25,169.25\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia5\" name=\"areaIndonesia5\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"273.75,196,274.5,194.75,274.5,193.25,275.5,192.25,275.75,191.25,276.5,189.25,277.25,187.75,277.25,187,277.75,185.25,277.75,184,278.25,183.25,279.25,182.25,280,180.5,280,179.75,280.5,178,281,177,281.5,176,280.75,175.75,280.25,175.75,279.5,175.5,278.5,175,278,174.75,277,173.75,275.5,173.25,274.5,173,273.25,172.75,272.5,172.25,270.25,172.25,269.75,171.75,268.25,171.25,267.5,170.5,265.75,169.75,264,169,262.25,169,261.25,169,260,169,259,169.5,258.25,170.25,259.25,170.25,260,171.5,259.25,173,258.25,174,257,174,256,173.75,255.5,173.5,255.25,174.5,254.5,175,254,174.75,253.5,174.25,253.75,173.5,253.25,173.25,252.75,173,252.75,172.5,253.75,172.25,254.5,172.5,255,172.25,254.75,171.5,254.25,170.75,254.25,170.25,253.75,169.75,254.25,169.25,254.5,168.75,254.5,168.5,255.25,169,256.5,169,257.25,168,257.25,167.25,256.5,166.5,255.5,166.25,254.25,165.5,253,166.25,252.5,167,251.75,166.25,251,166.25,250.5,166,250,165.5,249.25,165.5,248,165,247.25,164.75,246.25,164.25,245.25,164.25,243.75,164.75,243,164.75,242.5,164.25,242,163.75,241.25,163.5,240.75,163.25,240,163.25,238.75,163.25,238.75,164,239.75,164.5,240.5,164.5,240.75,165.5,241,166.5,239.75,166,240.5,167.5,240.25,168.25,239.25,168.75,238.75,169,238.5,170.25,238.75,171.25,238.5,172.25,237.75,172.75,237,173,236,172.75,235.25,173.25,234.25,173.75,233,173.75,232,173.75,230.75,173.75,230,174.25,229,174.25,228,174.25,227.25,174.25,226.75,174.25,226,174.25,225.75,175.25,226.25,176.25,226.75,177.25,227.75,177.25,228.5,177.25,229.25,177.25,230.25,176.5,230.75,177.25,231.5,177.5,232.25,177.5,233.25,177,233.75,176.5,234.75,176.25,235.75,176.25,236.75,176.25,237.75,176.75,238.5,176.75,239.5,176.75,240.5,177.25,240.5,176.5,240,176.5,240.25,175.75,239.75,175.25,239.25,174.5,238.5,174.5,238,174.5,237.75,174.5,237.5,173.75,238.25,173.75,239,173,239.25,170.5,240.25,170.5,240.75,169.75,241.25,169.25,241.25,168.75,241.25,168.25,242,168.75,243,169.25,244.25,169.5,245,169.5,246,170,246.25,170.75,245.75,172,246,173.25,245.75,173.5,246.25,174.25,247,175,247.75,175.5,248.5,176.5,248.75,177.75,249.5,178.75,250.75,178.75,251,178,251.75,177.75,252.5,178.75,253.25,178.5,254.25,178.75,255,179.25,256.25,179.25,256.75,180.25,257.75,180.25,259,180.5,260,181,260.75,181.5,261.75,182,262.75,182.25,264,182.5,265.25,183.25,265.5,185,266.25,186,266.75,187.25,267,188.75,266.5,190.5,266,190.25,265.5,190.25,264.5,190.75,263.5,191.5,263.5,193,263.75,194,264.25,195,265.75,194.75,266.75,194.5,267.75,193.75,269,193.75,270,194.25,271.5,194.25,272.5,194.75,273,196.25\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia6\" name=\"areaIndonesia6\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"242,192.75,241.5,192.25,241.5,191.75,241.5,191.25,241.5,190.5,241.5,190,242.25,190.25,243.25,190.25,243.75,191,243.25,191.75,243,192.5\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia7\" name=\"areaIndonesia7\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"252.25,189.25,251.75,188.75,251.75,188.25,251.75,187.5,251.5,186.75,252,186,252,185.25,252.5,184.75,253.25,185.25,253.25,186,253.5,187.5,253.25,188.25,253,189\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM105767&amp;span="+span+"\" id=\"areaIndonesia8\" name=\"areaIndonesia8\" title=\"Indonesia\" alt=\"Indonesia\" coords=\"225.5,171,225,171.75,224.5,171.75,224,171.5,223,171.25,222.5,171,222,170.5,220.75,170.25,219.25,170.25,218.75,170.25,218.75,169.75,219.25,169.5,220.5,169.5,221.25,169.25,222.25,169.25,223.75,169.5,225,170.25\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM998100&amp;span="+span+"\" id=\"areaSingapore\" name=\"areaSingapore\" title=\"Singapore\" alt=\"Singapore\" coords=\"146.75,152,146.5,152,146,152.75,145.5,153.75,145.75,154.75,146.25,155.75,147.25,156.25,148.25,156.25,149.25,156,149.75,155.25,150,154.5,150,153.5,150,153,149.75,152.5,149,151.75,148,151.5\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM941000&amp;span="+span+"\" id=\"areaKorea\" name=\"areaKorea\" title=\"South Korea\" alt=\"South Korea\" coords=\"213.25,32,213.25,31.25,212.75,30,212.25,29.5,212,28.5,211,27.5,211,26.5,210.75,25.75,210.25,24.25,210,23.75,209,23.25,208.25,22.5,207.75,22,206.75,21,206.25,20.5,206,20.5,205.25,20.5,204.5,21.5,203.5,22.25,202.5,22.75,202,23.5,201.5,25,202.25,25.75,203.25,26.5,203.75,27.75,204.75,28.5,205.25,29.25,205.25,30.25,205.25,31.25,205.25,32.25,205.5,33.5,206.25,34.25,207,33.5,208,34,208.75,34,209.5,33.75,209.75,33,210.75,33,212.25,33,213,32.75\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM903600&amp;span="+span+"\" id=\"areaAustralia\" name=\"areaAustralia\" title=\"Australia\" alt=\"Australia\" coords=\"173.75,294.25,173.25,294.25,173.25,293.5,172.5,293,171.75,292.75,171,292.25,171,290.75,171,290.25,171,288.75,171.5,288.25,172.25,288.25,173.5,287.5,174.25,286.5,174.5,285.25,174.5,283.5,175,283,175.75,281.5,176,280.25,175.75,279.25,175.75,278.25,175.5,277.25,175.5,276,175.75,274,175.75,272.75,176,271.5,175.25,270.25,174.75,268.25,174.75,267.25,174.75,266.25,174.5,265,173,262.25,173.25,261,173.25,259,173.25,258.25,174,257.5,175.25,257.5,176,257.5,175,256.5,175,255.25,175.75,254,175.75,252.75,176,252,176.5,251,176.75,249.5,177.75,248.5,177.75,247,178,245.5,178.5,244.5,180.25,244.25,181.75,244.25,182.75,243.25,183.5,242.25,184.5,241.25,186,241,187.25,240.5,188.75,240.5,190,239.75,191.25,239.75,192,239.25,193.25,239,194.5,238.25,195.5,238.25,197.5,237.75,199.5,237.25,200.75,236.75,202,235.75,203,235.25,204,235,204.75,234,205.75,232.75,206,231.25,207.25,230.5,208.5,229,208.5,227.5,208.75,226.25,209.25,225.25,210.25,224.75,211,224,212.25,223.75,213.25,223,214.25,223,215.25,223,215.75,222.75,215.75,222,216.25,221.5,216.5,221.25,217,219.75,218,218.75,219.25,218.25,219.5,217,220.75,216.25,221.25,215.75,222,215.25,222.75,214.75,224,214.75,225.25,215.25,226.5,216.25,227.75,217.5,228.75,218.75,230,218.25,230,217.25,231,217.25,232.5,217.5,232.75,217.25,233.25,216.25,234,216.25,234,215,235,213.75,235.5,212.5,236.75,211.5,237,210.75,237.75,209.25,238.5,208.5,237.75,208,237.75,207,237.75,206,238.25,205.25,239,205,240,205,241.25,205,242.25,204.75,243.5,204.5,244.25,205,244.75,205.75,246.25,206.75,247.75,207.25,249.25,207.5,250.5,207.75,251.75,208.25,252.5,207.5,253.75,207.5,254.5,208,255.25,207.5,255.75,206.75,256.25,206.25,257.5,206,258.25,206.5,258.25,208,258,209,258.5,210.5,258.25,211.75,257.75,212.75,257,213.25,257,214,256.5,214.75,257.25,215.25,257.5,217,256,217,254.5,216.25,254.25,217.5,255.25,218.5,255.25,220,254.25,219.75,253.5,219.25,252.75,219.5,253.25,220.5,254.25,221.75,255.25,222,256.25,221.75,257.25,221.75,257.75,222.5,257.5,223.5,258.25,224.5,259.25,225.25,260.75,225.75,261.25,225.25,262.5,225,263.5,225.75,264,225,264.75,224.75,265.5,225.5,265.25,226.5,264.75,227.75,264,228.25,265,229,266.25,227.75,267.5,228.25,268.5,227.5,269.75,226.25,270.5,224.5,271.5,224,272,222.75,272.5,220.75,273.25,219.5,273.5,218,273.5,215.75,273.75,213.25,274.75,211.75,275,210.5,275.5,209.5,275.25,208.75,276,207.5,276.75,206.5,277.5,205.25,277.75,204.25,278.5,205.25,278.5,207,278.75,208,279.5,209,279.75,210.25,279.75,212,280,213.25,280,214.25,280.25,215.5,280.5,216.75,281.5,216.75,282.75,217,283.25,218.25,284.25,219.75,284.75,220.75,284.75,222.25,284.5,223,284.25,223.75,284.75,224.75,284.75,225.75,285.5,226.75,285.75,228.25,285.75,229.75,286,231,285.75,231.75,285.75,232.75,285.5,233.75,286.25,234.75,286.25,236.25,287.5,235.5,288.75,236.5,289.5,237.75,291.25,238.5,292.75,239.5,293,241.5,293,243,293.5,244.5,294,245.75,295,246.75,296.25,246.75,297,247.5,297,248.5,297,249.5,296.75,250.5,297,251.25,297.5,252,298,253,299,254,299.5,255,299.75,256.25,301,256.25,302.25,256.25,303.25,257.25,303,258,302.75,258.75,302.75,260,302.25,261.25,301.25,262.25,300.75,263.75,300.5,265,301,266.75,300.75,268.5,300,269.5,299.75,271,299.25,272.5,298,273.75,297,275.25,296,277,295,278.75,294.5,280.5,293.5,281.75,292.25,283,291.5,284.25,290.5,285.5,289.25,286,288.25,287,286.75,288.25,285.25,289.25,283.5,291.5,282.5,293,281.5,294.25,280.5,295.25,279.75,296,278.75,297,277.75,298.25,276.25,300.25,275.5,301.5,274.5,303.25,273.25,304.25,272.5,304.75,271.25,305,270.25,305,269,305,267.75,305.25,266.25,305.25,265.25,306.25,263,307,262.25,308.5,260.75,308.75,259.75,309,258,309,257.25,308.25,256,308.25,254.25,307.5,253.75,308,252.5,308.25,251.25,309.25,249.75,308.5,248.75,308,247,307.25,245,306.75,243.75,305.5,243.5,304,243.25,303,243.25,301.5,243.25,300.75,243.75,300,244.5,299.75,244.5,298.5,243.75,297.5,243,298.25,242.25,297.5,241.25,296.5,241,297.25,239.5,298,238.5,298.5,237.75,298.75,236.5,298.75,236,297.75,235.75,297.25,236,296.25,236.25,295.5,235.75,295.25,235,294.75,233.75,294,233.25,292.5,233.25,291.75,233.75,290.5,234.25,290.25,234.25,289.75,234.25,288.75,233.75,288.5,233.25,287.5,233,287.25,232.75,286.5,232.75,285.25,232,285,231,285,228.75,284.25,228,284,227.5,283,226.5,282.75,225.25,282.75,223.5,282.5,222.5,281.75,220.5,282,219.25,282,218,282.25,217,282.5,216,283.25,213.75,283.5,212.25,284.5,211,284.75,209.5,284.75,207.25,284.75,205.75,284.75,205,285.75,202.75,286.5,201,287.25,199,288.75,197.5,290.5,195.5,290.25,193.75,290.25,191.75,291,190.5,290,189,290.25,188,290.25,186.75,290.25,185.75,290.25,185.25,291.25,183.75,292,182,292.75,180,294,178.5,294.75,176.75,294.75\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM903600&amp;span="+span+"\" id=\"areaAustralia2\" name=\"areaAustralia2\" title=\"Australia\" alt=\"Australia\" coords=\"250,326.75,249.75,326.5,249.5,326,249.25,325.25,249.25,324.25,249.25,323.25,249.25,322.5,249.5,321.75,249.5,321,250,320.25,250.75,319.5,250.75,318.75,250.5,318.25,250.5,317.75,250.75,317.25,250.75,316.75,251,315.75,251.75,316.25,252.5,316.75,253.5,317.5,253.75,317.25,254,316.75,255,316.5,255.75,316.75,256.5,316.5,257.75,316.25,258.5,316,259.25,316,260,315.25,261.25,315.25,262,314.75,262.75,314,262.25,316,261.75,316.75,261.25,317.5,261,318.25,260.75,319,260.25,319.5,259.75,320.5,259.25,321,258.25,321.25,257.75,322.25,257,322.75,256.5,323.5,256.25,324.5,255.25,324.75,254,325,253.5,325.75,252.75,326.5,252,326.5,251,326.75\">";
   arraySG[arraySG.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NM934400&amp;span="+span+"\" id=\"areaHongKong\" name=\"areaHongKong\" title=\"Hong Kong\" alt=\"Hong Kong\" coords=\"180.75,78.5,180.25,78,180,77.75,179.5,77.5,179.5,77,179.25,76.25,179.5,75,180.25,74.25,181.25,73.75,182,73.75,183.25,74,184,75,184.5,75.75,184.5,76.75,184.5,77.5,184.25,78.25,184,78.75,183.25,79,182,79\">";
   $("indicesMap").innerHTML=arraySG.join("");
   }
   else if(siteid=="TNME")
   {
    var arrayME=new Array();
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG449&amp;span="+span+"\" title=\"Oman\" alt=\"Oman\" coords=\"333.5,217.5,358.5,206.5,367,188.5,362,181,362,171,366.5,169.5,363.5,166,363,166,362.5,165,362,164,363.5,164.5,365,164.5,365.5,164,365,162.5,364.5,161.5,365,161,366.5,162,368,164,370.5,165.5,372.5,166,375,166,377,167,379,167.5,380.5,167.5,382,169,383.5,171,385.5,173,387,175.5,389.5,177,392,179,391.5,183,392,186,389.5,190,390,193,388.5,195,387,196,386.5,199.5,385,199.5,384,199.5,383,199.5,382,200,381,200,380.5,201.5,381,204,381.5,206.5,379.5,207,378.5,207,377,207,377,208.5,378,210.5,378,212,376,212,375,212.5,374,213,372.5,214,371.5,215.5,371.5,217,371,220,369.5,221.5,368,222,366,222,364.5,222,363,222,362,223,361.5,224.5,361.5,227,360.5,228.5,359,229.5,358,231,356,231,355,231,353.5,230.5,351,230.5,349.5,231,348.5,231,347.5,231.5,346.5,232.5,344,233.5,341.5,233.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG449&amp;span="+span+"\" title=\"Oman\" alt=\"Oman\" coords=\"364,147,363,147,362,146.5,361.5,146.5,360.5,146,359,145.5,359,144.5,360.5,143.5,362,143,363.5,143.5,364.5,145,365.5,146.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG466&amp;span="+span+"\" title=\"UAE\" alt=\"UAE\" coords=\"361,180.5,357.5,180.5,353,180,351,180,347.5,179.5,344,179,341,179,338.5,178.5,335,178.5,332.5,178.5,329.5,177.5,327.5,177,325.5,167.5,324.5,166.5,324,166,322.5,164.5,322,163.5,320.5,163,320.5,161.5,321,160,320.5,159,322,158,322.5,159.5,323,161.5,324,163.5,326,163,329,163,332.5,163,335.5,163,338.5,161.5,341.5,161.5,343,160.5,345.5,159.5,348,158.5,349,156.5,351,155.5,352,154,353,151.5,354.5,150.5,355.5,149,357,147.5,359,145.5,360.5,146,362.5,147,364.5,148,366,151,367.5,153,368,155,367,155,366,154,364.5,154,363,152.5,362,151,361.5,151,361.5,153,362,155.5,363,158,364.5,161,365,164,363.5,164,362,164,361.5,165,363.5,167,365.5,169.5,363.5,169.5,361.5,169.5,360.5,172,360.5,174.5,361,177.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG452&amp;span="+span+"\" title=\"Qatar\" alt=\"Qatar\" coords=\"318.5,157.5,318,158,317,157,317,156,316.5,155,316,153.5,316.5,152,317.5,150.5,318.5,149.5,320,148,320,146,321.5,148,321.5,150.5,322,153,323,155.5,322.5,157.5,321,158,320,158.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG419&amp;span="+span+"\" title=\"Bahrain\" alt=\"Bahrain\" coords=\"317,148,315,149,313,148.5,312,147.5,310.5,146,310.5,143.5,311,142,312.5,141,314.5,141,316.5,141.5,318,143,318,144.5,318,147\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG443&amp;span="+span+"\" title=\"Kuwait\" alt=\"Kuwait\" coords=\"294.5,124,284.5,125.5,282.5,124.5,281.5,122.5,280.5,121,280,120.5,279,119,278,117.5,276.5,116,275,116,273,115.5,271.5,114.5,270,114,267.5,113.5,268.5,112,271,111,274,109.5,276.5,107.5,278.5,104.5,281.5,103.5,283.5,101.5,286.5,101.5,289.5,104,291.5,106,293.5,106,295,107.5,294.5,108.5,295,110,295.5,111.5,295,113,294,113,292.5,113,291.5,114,290.5,115.5,291.5,118,293,119.5,294.5,122\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG469&amp;span="+span+"\" title=\"Egypt\" alt=\"Egypt\" coords=\"100,88.5,100,91.5,100,94.5,100,97.5,100,100,100,103,99.5,106.5,99.5,110.5,99,115.5,99.5,120,99.5,126,99.5,131,99.5,137,99,142.5,99.5,147,99.5,152.5,99,157,100,162,100,168,100.5,173,100.5,177.5,100.5,180.5,105,181,110,181,113.5,181,120.5,181,128,181.5,134.5,181.5,142,181,149,181,155,180.5,163,180.5,166,180.5,169.5,180,173,180,177,179.5,181,179.5,185.5,178,188.5,178.5,190,178.5,192.5,178.5,195,178.5,194.5,178,194,177.5,192.5,177,191,175,191,173,191,171.5,191,170.5,192,169.5,192,167,191.5,165.5,189.5,164,188,162.5,188,161.5,187.5,160,186,157.5,185,157,184.5,156,184,154.5,183.5,152.5,183,151.5,181.5,150.5,181.5,149.5,181,149,179.5,147,178.5,145.5,178,144,177.5,143.5,177,142.5,176,141.5,175.5,140.5,176,138.5,175.5,138,175.5,137.5,174.5,136.5,174,135,175.5,134.5,177,133,178,132.5,178.5,131.5,178.5,130,178.5,129.5,178,128.5,178.5,127.5,179.5,126.5,180.5,126,181.5,125,181.5,124.5,181.5,123.5,181,122.5,181,121.5,180,119.5,181,117,181,114.5,181,112.5,182.5,110.5,182,108,182,106.5,181.5,105,181.5,103.5,180.5,101.5,179.5,100,179,98,175.5,94,173.5,94,172,94,171,93.5,169.5,94,166.5,94,164,95,162.5,94.5,161,95,159.5,95.5,158.5,94,157,93,154.5,91.5,151,90.5,148,91.5,145,91.5,143.5,92,142,92.5,138.5,94,137,94.5,135.5,95,133.5,95.5,132,95.5,130.5,96,129.5,96.5,129,96,128.5,95.5,126,95.5,125,95,123,95,122,95,121,95,120,94,118,93.5,116.5,93,114,92.5,112.5,92,112,92,110.5,92,110,91,108,91,106.5,91,106,91,105,91,104,91,103,90,101.5,89.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG456&amp;span="+span+"\" title=\"Saudi Arabia\" alt=\"Saudi Arabia\" coords=\"309,144,309,143,309,141.5,309,140.5,309,139,308,138,307.5,137,306.5,136.5,306,135,305,134,304,133,302.5,131.5,301,131.5,300,130,299,129,297,127,295,125,294.5,124,293,124.5,291.5,124.5,289,124.5,287,124.5,285.5,124.5,284,124.5,282.5,124,280.5,122.5,280,121,279,120,278,118,277,117,276.5,116,275,116.5,273,115.5,271.5,115.5,270,115,269.5,114,268,114,267,113.5,264,114,259.5,114,255.5,114,230,90.5,224.5,90.5,221,90,218,90,214,90.5,211,90.5,208.5,90.5,210.5,93,212,96,213.5,97.5,214,100.5,213.5,102.5,211.5,102.5,209.5,104,207,106,205,106,205,108,204.5,110.5,203,111.5,201,113,198.5,113,196.5,113,194.5,113,192,112.5,190.5,112.5,189,112.5,188.5,114.5,186.5,116.5,186,119,186.5,121.5,185.5,124,186,126.5,187,128,188,126.5,190,127,191,129.5,193,133.5,195.5,138,198,141.5,200,144,202,147,204,149,205.5,153.5,207.5,159.5,210.5,162,212.5,163.5,215.5,165.5,218,170,219.5,173.5,222.5,178,222.5,183,223.5,188,224,193,227,195.5,229.5,199.5,233.5,201,236.5,204,238.5,207,240.5,211,242,215,244,219,246.5,222.5,248.5,224.5,251,226,252,229,254,231.5,255.5,234,256.5,237,256.5,243,258,241.5,258.5,240,258.5,238.5,258.5,236.5,260,235,262.5,235.5,264,235.5,266,235,268,232.5,270.5,231.5,274,231.5,277,231,280.5,230,284.5,229.5,288,229.5,291,229.5,293,232,294,235,296,233.5,298.5,232.5,300.5,231,300.5,228.5,302.5,226.5,304.5,222.5,308.5,221,314.5,219,318.5,217.5,322.5,216,326,216,329,216,332.5,216,335,215.5,339,214,343,213,348.5,211,356.5,207.5,360.5,204,363.5,198.5,366,192,366.5,187,365.5,184.5,361,180.5,359.5,180,356.5,180.5,354,180.5,350.5,180,347.5,179,344,178.5,341,178.5,339,178.5,335,178.5,331,178.5,329,178,327.5,177,327,176.5,327,175,325.5,172,325.5,169.5,325,167,323,166,322.5,165,321.5,163.5,320,162.5,319.5,161.5,319.5,159.5,319.5,158,318,158,316.5,157.5,316.5,155.5,316,153.5,316,151.5,315,152,313.5,152,311.5,151,310,149.5,309,149,308.5,147,308.5,145.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG439&amp;span="+span+"\" title=\"Jordan\" alt=\"Jordan\" coords=\"188.5,111.5,189.5,110,189,107,189,105.5,189,104.5,189,102.5,189,100.5,189,98,189,97,189,93,188.5,87.5,188,84,188.5,80,191,80.5,193,81.5,195.5,82.5,197.5,82.5,199.5,81.5,202.5,80,205,77,207,74,209,74.5,212,74.5,214.5,73,216,74,214.5,75.5,215,78,214.5,79,216.5,80.5,218.5,82.5,218,83.5,221,85.5,221.5,88,221.5,90,216,90,214,90.5,212.5,90.5,210,90.5,208.5,90.5,209,92,210.5,94,212,96,212.5,98,214.5,99.5,214.5,102,211.5,102.5,209,105.5,208,106,206.5,106.5,206,107.5,205,110,204,111,202.5,112.5,200.5,113,198.5,113,197.5,113,195.5,113,192.5,112.5,191.5,112.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG534&amp;span="+span+"\" title=\"India\" alt=\"India\" coords=\"463,164,463,163.5,463,162.5,464,161,466,160,468,158,470.5,157.5,473.5,157.5,476,157.5,478,156.5,479.5,155.5,482,155.5,483.5,155.5,484.5,154.5,484.5,152,484,150.5,484,150,484,148.5,484,147,484,145,485,143,486.5,142.5,488.5,142.5,492.5,142.5,496,142.5,499.5,142.5,503,142,505.5,139.5,509,138,510,137,511.5,135,513,132.5,514.5,131.5,516.5,130,518.5,129.5,519.5,128.5,521,126.5,520.5,125,520,124,519,123,518.5,121,518,119.5,516.5,117.5,516.5,116,516.5,115,516.5,114,516.5,113,517,112,517,111,517.5,109,517,109,517,107.5,516.5,105.5,516,104.5,516,103.5,516,102,515,100.5,514.5,100.5,513.5,99,514,97.5,515,97,517,96,517.5,95.5,520,94,521.5,94,524,94.5,525.5,97,527.5,98.5,529.5,99.5,532,100.5,534,101,537,101,539.5,101,542,101,543.5,100.5,546,101.5,547.5,103.5,547.5,105.5,547,107.5,545.5,109.5,544,110.5,544,112,543.5,114.5,544,116.5,546,117,547.5,117.5,548.5,119,549.5,121.5,548.5,123.5,547,124.5,545,124,542.5,124,543.5,126,547,127,549,128,550,133,551.5,133,553,132,555,132,557.5,131.5,558,133,557,142.5,559.5,143,562.5,144,564.5,145.5,568,147,570,147.5,573.5,149.5,579,149.5,583.5,150,587.5,151,591,151,594.5,151,595,149,595,146.5,594.5,144.5,595,143,596,141,598,141.5,600,143.5,599.5,145.5,600,148,601.5,150,603,149,604.5,149,607,149,609,149,612.5,149,615.5,148.5,618,147,618,143.5,618,142.5,617,141.5,615.5,140.5,618.5,140.5,622,138,624.5,137.5,628.5,136,631.5,134,635.5,133.5,636.5,132.5,638.5,131,647.5,126.5,646.5,185.5,645.5,185.5,645,185.5,644,185,643,183.5,642,182.5,640.5,181.5,639,179.5,638.5,178,637,176.5,636,174.5,635,172.5,633.5,172.5,632.5,174,631,175.5,630.5,176.5,629,176.5,628,175.5,626,174,626,172.5,626.5,171.5,627,170.5,627.5,169,628,168,628,167.5,628,166,628,164.5,628,163,626.5,162,625.5,161.5,624.5,161.5,623,161.5,621,161.5,619.5,161.5,617,160.5,616,159.5,615.5,158.5,614.5,157.5,613.5,156.5,611.5,156,609.5,156,607,155,605.5,154,604.5,154,603.5,154.5,602.5,155.5,602,159,604.5,160.5,606.5,160.5,609,161,608.5,163.5,607.5,164.5,607,165.5,605.5,166.5,604,166.5,603.5,167,604,169,606.5,170.5,607.5,170,609,171,610.5,171.5,611,174,610.5,175.5,610,177.5,611,180,611.5,182,612,184,613.5,185.5,616,187.5,618,187.5,620,187.5,622,188,623.5,189.5,623.5,192,622.5,193.5,621,194,620.5,195,620,196,620,198.5,619.5,200.5,617.5,201.5,616,203,614.5,203.5,612.5,204.5,610,204.5,608.5,208,607,209.5,606,212,605,213,604,213.5,603.5,214,602,216,600,218.5,599,219.5,598.5,220.5,597.5,221,596,221.5,595.5,223.5,594.5,224.5,593.5,225,592,226,590,226.5,589.5,227,589,229.5,589,232,588.5,233,588,233.5,587.5,234,585.5,234.5,585.5,236,583.5,237.5,581.5,237.5,580.5,237.5,580,238.5,579.5,239.5,579,240,577,242,574,242.5,572,242.5,572.5,245.5,572,248,571.5,250,570,250.5,568.5,251,568.5,253.5,568.5,255.5,569.5,257.5,570,260.5,571.5,262.5,572,265.5,572,268,571.5,271,571.5,274,571,276.5,570.5,279,570,280.5,568.5,282,568,283.5,568,286.5,568.5,290.5,569.5,295,570.5,298,572,300,573,302.5,572,305,571,306.5,569,306.5,567,307,566.5,306.5,565.5,306.5,563.5,306.5,561.5,306,561,306.5,560,307,559.5,308.5,559,310.5,557.5,311.5,556,313.5,553,315.5,551,315,550,314,549,312,547.5,309.5,546,308,545.5,306,544.5,305,542.5,303,541.5,301.5,541,300,540.5,298.5,539,296,538.5,294,537,292.5,536.5,291.5,535.5,289.5,534.5,288.5,533.5,286.5,533.5,284.5,533,281,532,278,530.5,276,529,274,527,271.5,524.5,268.5,524.5,266.5,524,262,521.5,256,520,253,518.5,250,516.5,248.5,516,244,515,240.5,513,237,512.5,233.5,511,231,508.5,228,508.5,226,508.5,222.5,508,220,507.5,216.5,506.5,216,505.5,214.5,505.5,212,505.5,209,504.5,205,504,202.5,504,200,504,199,504.5,197.5,505,196,505,194.5,505,192.5,503.5,193.5,501.5,194,501,194,501,193,499.5,190.5,498.5,190.5,498.5,189,498.5,186,498,184.5,497.5,186,497,188,496.5,191,495,191.5,493.5,193.5,492.5,193.5,491.5,195,489,195,487,195,486.5,194,484,194,483,193,482,191.5,480,190,478.5,188.5,478,186.5,475,184.5,474,183,473.5,181.5,472,179,472,178,472.5,177.5,474,175.5,476.5,175,477,174.5,477.5,173,477,172.5,475.5,172.5,473.5,173.5,472.5,174,470.5,173.5,469.5,172,469,172,467.5,171,465.5,169.5,464,167,462.5,166.5\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG564&amp;span="+span+"\" title=\"Pakistan\" alt=\"Pakistan\" coords=\"463,167,462,167,461,166,460,166,459,165,458.5,164.5,457,164,456.5,163,456,161,454.5,159.5,454.5,158.5,454,158,453.5,157,453.5,156,453.5,155,453,154,452,154,450,153.5,449.5,152,448.5,150.5,447.5,149.5,448,148,448,145.5,449.5,144.5,450.5,142.5,452,141,452.5,140,452.5,139,452,137.5,452,136.5,452,134,452,132,452,130,452,129,452,128,452,126.5,451.5,125.5,451.5,123.5,451.5,122,451,120.5,451,119.5,450.5,117,450,116,452.5,117.5,454.5,119.5,457.5,121.5,459,123.5,461,124,463,124.5,466.5,124.5,469,124,470.5,122.5,472.5,121,472.5,119,474.5,118,477,118,478,116,479,114.5,481.5,114.5,482,113,481.5,111,482,109.5,484,109,484.5,108,486.5,107,488,106,488,104.5,490,103,491.5,102,492,100,493.5,98.5,495.5,96.5,497,95,498,94.5,500.5,94,501.5,91.5,501.5,89,501.5,86.5,501.5,84.5,502.5,83.5,503.5,83,503.5,81,504.5,80,505.5,79,508,79.5,510,82,510.5,84,511.5,86,513,87.5,514,89.5,516,92,517.5,94,516.5,95.5,515,96,513.5,96,513,97.5,512.5,99.5,514.5,101,515.5,103.5,515.5,106,516.5,108.5,516,111,516,113,515.5,115,516,118,517.5,120.5,519,123,521,125.5,519,127,518.5,128.5,516,129,515,130,513.5,131.5,512.5,132.5,511.5,133.5,510,135.5,508.5,136.5,508,137.5,507,138,506,138.5,505.5,138.5,504.5,139,503.5,140.5,501,141.5,499.5,141.5,498,142.5,494.5,142.5,492,142.5,491,142.5,489,142.5,486,142.5,485,142,485,143.5,484,147,483.5,151,484,153.5,483.5,155,481.5,155,480,155,477.5,155,477.5,156.5,475.5,156.5,474.5,156.5,471.5,156.5,469.5,156.5,467.5,156.5,467.5,158.5,466,158.5,464.5,159.5,463,161,462.5,163.5,463.5,166\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG524&amp;span="+span+"\" title=\"Srilanka\" alt=\"Srilanka\" coords=\"574,304,574,306,573.5,308,573.5,310.5,573,312.5,572,314.5,572,317,573,319,573.5,320.5,573.5,322,573.5,324,573.5,326.5,573.5,328.5,574,330,574.5,331.5,575.5,333,575.5,335,577,336,578.5,336.5,580,337,582,335.5,583.5,335,586,334.5,587.5,333.5,588.5,332.5,589,331,589,329,588.5,327.5,588.5,326,588.5,325,588,324,587.5,323,587.5,321.5,586.5,320.5,585,319,584,317.5,583.5,315,583,313.5,582.5,313,582.5,312.5,580.5,310,579,307.5,577.5,306.5,576,304\">"
   arrayME[arrayME.length]="<area shape=\"poly\" href=\"/Tools/Charting.aspx?typecode=NSPG186&amp;span="+span+"\" title=\"Turkey\" alt=\"Turkey\" coords=\"268,63.5,266.5,64.5,265.5,64,264.5,64,263.5,63.5,263,62,261.5,60.5,260,60,259.5,57,259,55.5,258,53,257,52.5,256,50.5,255,50,254,50,249.5,51,247.5,51,246,48.5,243,48.5,240,48.5,236,48.5,234.5,48.5,230,48.5,225,50,222,49,219.5,48.5,218,48,216,48,214.5,48,212.5,48,209.5,48,205,47,203.5,46,201.5,45.5,199.5,45,197,44.5,194,44,192.5,43.5,191.5,43.5,190.5,43,188.5,44,187,45.5,186,45.5,184.5,44,183,43.5,180.5,43.5,177.5,42,175,40.5,174.5,42,174,43.5,175.5,45.5,177,47.5,177,49.5,176,51,175.5,51,175,51,174.5,50.5,174,50,173,49,172,48.5,171,49.5,170.5,50,169.5,52,168.5,53,168,52.5,167,52.5,166,51.5,164.5,51,164,51,163,50,162,49.5,160.5,47.5,159,46.5,158.5,46.5,158,45.5,156.5,45,155.5,44.5,154.5,43.5,153.5,43,153,43,151.5,43.5,151,42.5,150,42.5,149.5,42.5,148.5,41.5,147.5,41,146.5,40.5,145,40.5,145,42.5,145,44.5,143.5,45.5,142.5,47,140.5,47.5,138,47.5,137,47.5,135,46.5,133.5,46.5,132,46,130.5,46,130,45,129,44.5,127.5,43.5,126.5,45,126.5,47,126,47.5,125.5,48.5,124,50,123,50,122.5,48.5,123,46,123,45,122,43.5,121,43.5,118.5,43,118,42.5,118,41.5,117,40.5,116,41.5,115.5,43,114.5,42.5,114.5,41.5,115.5,40.5,114.5,40,113.5,38.5,112,38,111.5,37,110.5,36.5,109,36.5,108.5,34.5,106.5,33,106.5,30.5,106.5,28.5,105,26.5,105.5,26,107.5,24,107.5,23.5,107,22,108.5,21,109,20.5,108.5,19.5,108,19.5,107,17.5,107,15,107,14,107,11.5,107,10.5,108,7.5,109,7,111,5,112.5,3.5,115,3,116.5,2,118,0,121,0,124.5,0,129.5,0,133.5,0,137,0,272.5,0,270.5,1,268.5,1,267,1.5,265.5,1.5,264.5,1.5,264.5,4,266.5,4.5,265.5,6,265,8,265,10.5,265.5,13.5,265,16,264,18.5,264,23.5,264.5,29,263.5,35,263.5,44,262,51.5,263.5,53,265.5,54,267.5,57,268.5,59.5\">";
   $("indicesMap").innerHTML=arrayME.join("");
   }
  
              
}
	
 function changePerformance()
	{
		  var performance=$('DynamicMap').value;				
		    $('hdPerformance').value=performance; 
		  var universe=$('universeType').value;  
		    $('hdUniverse').value=universe;  
		  var imageSource = "/Tools/DrawMap.aspx?universeCode=" + universe + "&perf=" + performance+"&ltype=volatility";
		  var imgObj = $("regionalPerformance");
	          if (imgObj) 
	            {
		             imgObj.src = imageSource;
	            }	  
	}
	function doSubmitType(type)
	{
	 $("hdType").value=type;
	 $("hdfocus").value=type;
	 $('aboutlink').focus();
     window.document.masterForm.submit();
	}
	function doSubmitYear(year)
	{
	   $("hdYear").value=year;
	   $('aboutlink').focus();
	   $("hdfocus").value=year;
	   window.document.masterForm.submit();
	}
//End DrawMap	


/************** Global Indices control ******************/

var imgHeight = 147;
var codeArray = new Array();
var newCookieAry = new Array();	    		
var cookie = GetCookie("TN_GIBar");	
newCookieAry = cookie.split(',');    
var giDirectionStatus = "Up";

function assignGITypeCode(typecode) {
	codeArray = typecode.split(',');
}
    
// It will change the charts based on the time span
function changeGlobalChart(val) {	  
  for(i=0;i<newCookieAry.length;i++) {
	var imgObj = $(newCookieAry[i]);
	if(imgObj) {
		imgObj.src = "/Tools/ChartBuilder.aspx?width=145&height=99&formatYaxis=0&formatXaxis=MMM yy&codes=" + newCookieAry[i] + "&hide=1&span=" + val + "&fontXaxis=8&color=" + strGIBMColourCode;
	}
  }	  
} 

// On Clicking the chart it will navigate to charting page
function onGIClick(typeCode) {	  	  
  var sel = $("GISpanVal")[$("GISpanVal").selectedIndex].value;
  window.location="/Tools/Charting.aspx?typecode=" + typeCode + "&hdTimeSpanVal=m" + sel;
} 

// It will execute when up and down scrolls clicked based on the parameter passed
function giScroll(direction, state) { 	  
  if(state=="Start" && direction=='') {		 
	 direction=giDirectionStatus;
  }
  else if(direction!='') {
	 giDirectionStatus = direction;
  }
  $("hdnGIDirection").value = direction;
}

// Function to keep the charts moving always
function moveGIChart() {
  var eleHdn = $("hdnGIDirection");
  var eleInnerDiv = $("giInnerDiv");
  var inEleHeight = newCookieAry.length * imgHeight;
  var jump = 5;
  var scrollTimer = 0;	  
  	  
  if(eleHdn.value=="Up") {
	 for(i=0;i<newCookieAry.length;i++) {
		var eleChart = $(newCookieAry[i] + "_div");
		if(eleChart){
			var chartHeight = eleChart.style.top;
			chartHeight = parseInt(chartHeight.replace('px','')) - parseInt(jump);
			eleChart.style.top = chartHeight + "px";
			if(chartHeight<-imgHeight) {
			   eleChart.style.top = parseInt(inEleHeight) - parseInt(imgHeight) + "px";
			}
		}
	 }
  }
  else if(eleHdn.value=="Down") {		 
	 for(i=0;i<newCookieAry.length;i++) {
		var eleChart = $(newCookieAry[i] + "_div");
		if(eleChart){
			var chartHeight = eleChart.style.top;
			chartHeight = parseInt(chartHeight.replace('px','')) + parseInt(jump);
			eleChart.style.top = chartHeight + "px";
			if(chartHeight > (parseInt(inEleHeight) - parseInt(imgHeight))) {
			   eleChart.style.top = -(parseInt(imgHeight)) + "px";			   
			}
		}
	 }  
  }
  if(newCookieAry.length>4) {
	scrollTimer = setTimeout('moveGIChart()',300);
  }
  else {
	clearTimeout(scrollTimer);	
  }
}

// It will decide to display or hide the outer border
function updateOuterDiv() {
  var eleOuterDiv = $("giOuterDiv");
  var eleInnerDiv = $("giInnerDiv");
  var eleScrollUp = $("giScrollUp");
  var eleScrollDown = $("giScrollDown");
  
  if (newCookieAry.length>4)
  {
	 eleOuterDiv.style.border = 'solid 1px #A7C7E7';
	 eleOuterDiv.style.height = '588px';
	 eleScrollDown.style.visibility='visible';
	 eleScrollUp.style.visibility='visible';
	 moveGIChart();
  }
  else
  {
	 eleOuterDiv.style.border = 'none 0px white';
	 eleOuterDiv.style.height = (parseInt(eleInnerDiv.getElementsByTagName('img').length * imgHeight)-10) + "px";
	 eleScrollDown.style.visibility='hidden';
	 eleScrollUp.style.visibility='hidden';
  }
}	   

// Function to display or hide Global Indices Popup
function getGIPopup(val) {
  if(val=="True") {
	 $("giPopup").style.visibility='visible';
	 $("giIFrame").style.visibility='visible';
  }
  else if(val=="False") {
	 $("giPopup").style.visibility='hidden';
	 $("giIFrame").style.visibility='hidden';
	 updateGI_Cookie();
	 document.forms[0].submit(); 
  }
  else {
	 $("giPopup").style.visibility='hidden';
	 $("giIFrame").style.visibility='hidden';		 
  }
}

function getSCPopup(val) {
var element = document.getElementsByName("perf");
	var perfs = "";
	var spliter = "";
	var len = element.length;
	var count=0;
	for(var i=0; i< len; i++) {
		if(element[i].checked) {
			perfs += spliter + element[i].id;
			spliter = ",";
			count++;
		}
	}	
	 var ele= $("hdnSQScroll");
	 if(ele)
	 {
	 ele.value="1";
	 }
  if(val=="True") {
	 $("scPopup").style.visibility='visible';
	 $("scIFrame").style.visibility='visible';
  }
  else if(val=="False") {
	 $("scPopup").style.visibility='hidden';
	 $("scIFrame").style.visibility='hidden';	 
	 if(count!=3)
	  {
	  alert("Please select any three");
	  return false;
	  } 
	
	  $("hdPerf").value=perfs;
	 document.forms[0].submit(); 
  }
  else {
	 $("scPopup").style.visibility='hidden';
	 $("scIFrame").style.visibility='hidden';		 
  }
    
}
// Function to update global indices cookie values
function updateGI_Cookie() {
  var prevCookie = GetCookie("TN_GIBar");	  

  if(prevCookie==null) {
	 SetCookie("TN_GIBar", null, 123231);
  }
  else {		 
	 var k=0;
	 var newCookieValue='';
	 for(j=0;j<codeArray.length;j++) {
		if($(codeArray[j] + "_Chk")) {
			if($(codeArray[j] + "_Chk").checked) {
				if(k>0) { 
				  newCookieValue += ","; 
				}
				newCookieValue += codeArray[j];
				k++;
			}
		}			
	 }
	 SetCookie("TN_GIBar", newCookieValue, 123231);		 
  }	 
}
/************** End Global Indices control ******************/
