﻿// JScript File
var rateRecomputeafterLocationchanged='no';
var xmlhttp;
var isCountryChangesTemp='no';
var isDeleteMeeting='no';
var divMeetingCompletionMenu = "";
var isMenuBtnClick='no';
var isCountryChangedMsgShow='no';
var totalNoOfMeetings=0;

var isEndClicked = 'no';

var cookieEmail = '';
var cookiePassword = '';

var isEditTimerMsgShow = 'no';

//var isLogoutClick = 'no'; 

// 5 Recent comma sep. job title
var recentJobTitles = [];

// service proxy url.
var proxyUrl = "ServiceProxy.aspx";

//initial text for country, state and city.
var initialTextForCity = "- Enter City Name -";
var initialTextForState = "- Select State -";
var initialTextForCountry = "- Select Country -";

// can edit timer
var canEditTimer = 'yes';

// valid email regular expression.
var emailfilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

//history meeting reponse
var historymeetingresponse = null;

// Logged Flag
var isLoggedIn="no";

// Logged in user email
var loggedinUsrEmail="";

// Logged in user password
var loggedinUsrPwd="";

// Start Time while edit timer
var editTimerStartDiff;

// end Time while edit timer
var editTimerEndDiff;

// edit timer time diff in seconds
var editTimerDiff = 0;

// Current timer value
var currentTimer = "";

// Edit Timer save click
var isTimerEdit = "no";

// is edit timer
var isEditTimer = "no";

// next ID when new att added
var nextID = 1;

// current Id 
var currentID = 1;

// jobs titles array
var jobTitles = new Array();

// current edit att ID
var currentattEdit = 0;

// alaram amount
var alarmAmount =0.00;

// connectivity message

var noConnectivityMessage = 'PayScale.com is currently unavailable.' ;

// register failed message
var registerFailedMessage = 'PayScale.com is currently unavailable. Registration failed, try again shortly.' ;

// alarm time
var alarmTime = 0;

// is alarm activated
var alarmIsSet ='no';

// alarm currency
var alarmSettingValue = "USD";

// money counter
var moneyCounter = 0.00;

// time counter
var timeCounter = new Date();

// current selected currency
var currentSelectedCurrency = '';

// check if meeting status pause 
var isMeetingPause ='no'

// click counter
var ticksCounter =0;

// edit timer counter
var editticksCounter = 0;

// average per second , use in accrual rates
var averagePerSecond = 0.00;

// hashtables to store att information
var attendeesHashtable  ;
var combinedRates  ;
var inOutHashtable  ;
var attendeesJobTitle ;
var attendeesEditList;

var currentMeetingAmount = 0.00;

// Constant for monthly to annual salary conversion
var totalHoursInYear = 52 * 8 * 5;

// timer ID
var timerID = 0;

// meeting heading
var meetingHeading;

// meeting started or not
var isMeetingStarted ='no'

// innerHTML of heading text
var headingDivleft ='<div id="divMeetingHeading" class="headingDiv">';
var headingDivright ='</div>';

// innerHTML of alarm disabled
var divAlarmDisabled = '<input type="image" class="alarmoffmainbutton"  src="image/AlarmOffMainButton.png" alt="Alarm Settings" onclick="editAlarmSetting(this);" id="AlarmDisablebtnId" />';
//var divAlarmDisabled = '<img src="image/AlarmOffMainButton.png" alt="Alarm Settings" style = "cursor: pointer;" onclick="editAlarmSetting(this);" />';

// innerHTML of alram enabled
var divAlarmEnalbed ='<input type="image" src="image/AlarmOnMainButton.png" alt="Alarm Settings" id="AlarmEnablebtnId" class="alarmoffmainbutton" onclick="editAlarmSetting(this);" />';

// innerHTML of pause button
var divPausebtn = '<input type="image" alt="Pause Meeting" class="pausebutton" src="image/meetingmiserpausebtn.PNG" onclick="pausemeeting();" />';
//var divPausebtn = '<img src="image/meetingmiserpausebtn.PNG" alt="Pause Meeting" style = "cursor: pointer;" onclick="pausemeeting();" />';

// innerHTML of start button
var divStartbtn='<input type="image" alt="Start Meeting" class="startbutton" src="image/meetingmiserstartbtn.PNG" onclick="startmeeting();" />';
//var divStartbtn='<img src="image/meetingmiserstartbtn.PNG" alt="Start Meeting" style = "cursor: pointer;" onclick="startmeeting();" />';

// innerHTML of space image
var spaceImage ='<img src="image/meetingmiserspace.PNG" alt="" />';

// innerHTML of little image
var littlespaceImage = '<table cellpadding="0" cellspacing="0"><tr style="height:1px;"><td></td></tr></table>';

// html for bottom-left and bottom-right
var divBottomLeft = '<table cellpadding="0" cellspacing="0" width="100%" border="0"><tr><td style="width:40px;"><img src="image/menu_btn.PNG" style = "cursor: pointer;" alt="" id="btnMenu" onclick="showMenu();" /></td>';
var divBottomRight = '</tr></table>';

// innerHTML of bottom image to edit meeting setting
var divMaxTag = divBottomLeft + '<td style="text-align:left;padding-left:15px;cursor:pointer;" onclick="showText();"><img src="image/editmeetingseeting.png" style = "cursor: pointer;" alt="Edit meeting settings" /></td>' + divBottomRight;

// innerHTML of botton image to minimize
var divMinTag = divBottomLeft + '<td style="text-align:left;padding-left:35px;cursor:pointer;" onclick="hideText();"><img src="image/minimizemeetingsetting.PNG" style = "cursor: pointer;" alt="Edit meeting settings" /></td>' + 
'<td style="width: 40px;">' +
'<img src="image/clearallparticipants.gif" ' +
'onmouseover="doTooltip(event,\'click to clear all participants\')" onmouseout="hideTip()"' +
'style="cursor: pointer;" alt="" id="btnClearAll" onclick="clearAllParticipants();" /></td>' +
divBottomRight;

// country value , state value , city value
var countryValue ='';
var stateValue ='';
var cityValue ='';

// 'yes' if location edited
var editcaselocation = 'no';

// innerHTML of div before minimizing, after edit meeting setting, we need to show all text again
var divShowHideText = '';

// used to check connectivity in edit location case

var editLocationConnectivity = 'no';

// to check if country changed
var isCountryChanged = 'no';

// to check if state or city changed
var isStateORCityChanged = 'no';


// innerHTML of initial text which need to show when user click edit meeting setting first time
var divintialMax = '<table cellpadding="0" cellspacing="0" border="0" width="100%">'+
    '<tr>'+
        '<td>'+
            '<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:31px;">'+
                '<tr>'+
                    '<td align="center" style="width: 221px" valign="bottom">'+
                        '<div id="divlblLocation" class="textBold">'+
                            'Location</div>'+
                    '</td>'+
                '</tr>'+
            '</table>'+
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">'+
                '<tr>'+
                    '<td style="background-image: url(image/linespacersmall.png);background-repeat:no-repeat;background-color:Transparent;height:12px;border:none;cursor:pointer;" ></td>'+
                '</tr>'+
            '</table>'+
            '<div id="divLocation">'+
            '</div>'+
            '<div id="divCountry">'+
                '<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:31px;">'+
                    '<tr>'+
                        '<td style="width: 5px">'+
                        '</td>'+
                        '<td style="width: 204px" valign="top">'+
                            '<div id="countryAutoComplete" class="">'+
                                '<select id="txtCountry" onchange="javascript:fillStates();changeState();" style="width: 204px;">'+
                                    '<option value="' + initialTextForCountry + '">' + initialTextForCountry + '</option>'+
                                '</select>'+
                                '<div id="containerCountry" class="">'+
                                '</div>'+
                            '</div>'+
                        '</td>'+
                        '<td style="width: 12px">'+
                        '</td>'+
                    '</tr>'+
                '</table>'+
            '</div>'+
            '<div id="divState">'+
            '</div>'+
            
            '<div id="divCity">'+
            '</div>'+
            
            '<div id="divLocationSave">'+
                '<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:30px;">'+
                    '<tr><td colspan="3" style="height:7px;"></td></tr>'+
                    '<tr>'+
                        '<td style="width: 29px">'+
                        '</td>'+
                        '<td align="left" style="width: 60px">'+
                            '<input type="image" alt="" src="image/meetingmisersavetbtn.PNG" class="savebutton"'+
                                'id="btnSaveLocation" onclick="showlocation();" /></td>'+
                        '<td style="width: 132px">'+
                        '</td>'+
                    '</tr>'+
                '</table>'+
            '</div>'+
        '</td>'+
    '</tr>'+
    '<tr>'+
        '<td>'+
            '<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:31px;">'+
                '<tr>'+
                    '<td align="center" style="width: 221px" valign="bottom">'+
                        '<div id="divlblMeetingAttendees" class="textBold">'+
                            'Meeting Attendees</div>'+
                    '</td>'+
                '</tr>'+
            '</table>'+
        '</td>'+
    '</tr>'+
    '<tr>'+
        '<td style="background-image: url(image/linespacersmall.png);background-repeat:no-repeat;background-color:Transparent;height:12px;border:none;cursor:pointer;" ></td>'+
    '</tr>'+
    '<tr>'+
    '<td>'+
        '<div id="divMeetingAttWhole">'+
        '</div>'+
        '<div>'+
            '<div id="divTextatt1">'+
                '<table cellpadding="0" cellspacing="0" border="0" width="100%">'+
                    '<tr>'+
                        '<td colspan="3" style="height:8px;"></td>'+
                    '</tr>'+
                    '<tr style="height:31px;">'+
                        '<td style="width: 5px">'+
                        '</td>'+
                        '<td style="width: 204px" valign="top">'+
                            '<div id="attloading" class="attloading" style="display: none"><br></div>'+
                            '<div id="att" class="yui-ac">'+
                                '<input id="attinput1" type="text" class="yui-ac-input" value="- Enter Job Title -"'+
                                'onkeypress="return noenter();"' +
                                'onfocus="refreshJobTitle(this);" onblur="refreshJobTitleOnLostFocus(this);" />'+
                                '<div id="attdatasource1" class="yui-ac-container">'+
                                '</div>'+
                            '</div>'+
                        '</td>'+
                        '<td style="width: 12px">'+
                        '</td>'+
                    '</tr>'+
                '</table>'+
            '</div>'+
        '</div>'+
    '</td>'+
'</tr>'+
'</table>';

// innerHTML of state input
var divState ='<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:31px;">'+
                    '<tr style="height:31px;">'+
                        '<td style="width: 5px">'+
                        '</td>'+
                        '<td style="width: 204px" valign="top">'+
                            '<div id="stateAutoComplete" class="">'+
                                '<select id="txtState" onchange="javascript:checkState();changeCity();" style="width: 204px;">'+
                                    '<option value="'+initialTextForState+'" selected>'+initialTextForState+'</option>'+
                                '</select>'+
                                '<div id="containerState" class="">'+
                                '</div>'+
                            '</div>'+
                        '</td>'+
                        '<td style="width: 12px">'+
                        '</td>'+
                    '</tr>'+
                '</table>';

// innerHTML of city input
var divCity ='<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:31px;">'+
    '<tr style="height:31px;">'+
        '<td style="width: 5px">'+
        '</td>'+
        '<td style="width: 204px" valign="top">'+
            '<div id="cityAutoComplete" class="yui-ac">'+
                '<input id="txtCity" type="text" class="yui-ac-input" value="'+initialTextForCity+'" onfocus="refreshCity();"'+
                    'onkeypress="return noenter();" />'+
                '<div id="containerCity" class="yui-ac-container">'+
                '</div>'+
            '</div>'+
        '</td>'+
        '<td style="width: 12px">'+
        '</td>'+
    '</tr>'+
'</table>';

// innerHTML of loading image
var loadingImage = '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr style="height:31px;">' +
'<td style="width:5px"></td><td style="width:204px ; text-align:center " valign="top"> <img src="image/loading.gif" alt="" />' +
'</td><td style="width:12px"></td>'+
'</tr></table>' ;

// innerHTML of country input
var divCounty ='<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:31px;">'+
                    '<tr style="height:31px;">'+
                        '<td style="width: 5px">'+
                        '</td>'+
                        '<td style="width: 204px" valign="top">'+
                            '<div id="countryAutoComplete" class="">'+
                                '<select id="txtCountry" onchange="javascript:fillStates();changeState();" style="width: 204px;">'+
                                    '<option value="' + initialTextForCountry + '">' + initialTextForCountry + '</option>'+
                                '</select>'+
                                '<div id="containerCountry" class="">'+
                                '</div>'+
                            '</div>'+
                        '</td>'+
                        '<td style="width: 12px">'+
                        '</td>'+
                    '</tr>'+
                '</table>';

// innerHTML of location display, after editing
var divDisplayLocationLeft = '<table  cellpadding="0" cellspacing="0" border="0" width="221px" onmouseover="changeColorOnMouseOver(this);" onmouseout= "changeColorOnMouseOut(this);"><tr>' +
'<td style="width:6px;"></td><td align="left" valign="middle"  style=" width:25px"><a href="#" onmouseover="doTooltip(event,\'click to edit location\')" onmouseout="hideTip()"><img src="image/meetingmiserlocationeditimage.gif" alt="" onClick ="editLocation();" border="0" style = "cursor: pointer;"/></a></td>'+
'<td style=" width:180px" class="location" id="divDisplayLocation" onClick ="editLocation();">';

var divDisplayLocationRight = '</td><td style="width:10px;"></td>' +
'</tr></table>';

// innerHTML of save and cancel button when location is being edited
var divDisplayLocationSave = '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr style="height:30px;">' +
'<td style=" width:25px"></td>'+
'<td align="left" style=" width:58px"><input type="image" alt="Save Location" src="image/meetingmisersavetbtn.PNG" class="savebutton" id="btnSaveLocation" value="" onclick="showlocation();" /></td>'+
'<td style=" width:3px"></td>'+
'<td align="left" style=" width:58px"><input type="image" alt="Meeting Miser" class="cancelbutton" src="image/meetingmisercanceltbtn.gif" onclick="showlocationcancel();" /></td>'+
'<td style=" width:77px"></td>'+
'</tr></table>';

// In and Out image button src
var imageAttOutSrc = "image/OutButton.gif" ;
var imageAttInSrc = "image/InButton.gif" ;

// innerHTML of att display
var divDisplayMeetingAttLeft = '<table  cellpadding="0" cellspacing="0" border="0" width="100%" onmouseover="changeColorOnMouseOver(this);"  onmouseout="changeColorOnMouseOut(this);"><tr height="45">' +
'<td align="left" valign="middle" style=" width:16px "><a href="#"><img src="image/InButton.gif" style = "cursor: pointer;" onClick= "editAtt(this); return false;" alt="" border="0" ';


var divDisplayMeetingAttMiddle = '/></a></td><td style="padding-left:5px;width:205px"><a href="#" style = "cursor: text;"><div class="jobtitle" ';

var divDisplayMeetingAttRight ='</div></a></td></tr></table>';

// innerHTML need to display when meeting stopped
var divStopMeetingText = '<table cellpadding="0" border="0" cellspacing="0" width="252px">' +
    '<tr>' +
        '<td>' +
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                '<tr>' +
                    '<td style="width: 110px">' +
                        '<a href="#" onclick="openNewURL(\'http://www.payscale.com?src=mm_logo\'); return false;"' +
                            'style="border: none;">' +
                            '<img src="image/meetingmisertopleft.PNG" alt="PayScale Salary Information" style="cursor: pointer;' +
                                'border: none;" /></a></td>' +
                    '<td style="width: 142px">' +
                        '<img src="image/meetingmisertopright.PNG" alt="PayScale Salary Information" /></td>' +
                '</tr>' +
            '</table>' +
        '</td>' +
    '</tr>' +
    '<tr>' +
        '<td>' +
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                '<tr>' +
                    '<!-- left border -->' +
                    '<td align="left" style="width: 12px; background-image: url(image/headingleft.PNG);">' +
                    '</td>' +
                    '<!-- left border -->' +
                    '<!-- middle -->' +
                    '<td style="width: 221px">' +
                        '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                            '<tr style="height:31px;">' +
                                '<td style="vertical-align: middle; width: 100%" id="tdHeading">' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="width: 100%; text-align: left; vertical-align: middle;">' +
                                                '<div id="divDisplayMeetingHeading" onclick="showInputHeading();"' +
                                                    'class="headingDiv" onmouseover="changeColorOnMouseOver(this);" onmouseout="changeColorOnMouseOut(this);">' +
                                                '</div>' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr style="height:46px;">' +
                                '<td>' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="width: 25px;">' +
                                            '</td>' +
                                            '<td style="background-image: url(image/meetingmisercostbg.PNG); width: 165; height: 50px;' +
                                                'vertical-align: middle; text-align: center; background-repeat: no-repeat;">' +
                                                '<table cellpadding="0" cellspacing="0" border="0px" width="100%" style="height: 50px;">' +
                                                    '<tr>' +
                                                        '<td id="divCost" style="text-align: center; vertical-align: bottom; padding-top: 4px;"' +
                                                            'class="moneyCounter">' +
                                                            '$0.00</td>' +
                                                    '</tr>' +
                                                    '<tr>' +
                                                        '<td style="text-align: center; vertical-align: top; padding-bottom: 6px;" class="accuralRate"' +
                                                            'id="divMin">' +
                                                            '0:00:00</td>' +
                                                    '</tr>' +
                                                '</table>' +
                                            '</td>' +
                                            '<td align="right" style="width: 31px; text-align: right;">' +
                                                '<div id="divAlarm">' +
                                                    '<input type="image" class="alarmoffmainbutton" src="image/AlarmOffMainButton.png"' +
                                                        'alt="Alarm Settings" onclick="editAlarmSetting(this);" /></div>' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height: 8px;">' +
                                '</td>' +
                            '</tr>' +
                            '<tr id="loadingdotsId" style="padding-top: 5px; padding-bottom: 5px; display: none;">' +
                                '<td style="text-align: center; height: 8px;" valign="top">' +
                                    '<img src="image/loading.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr id="showMessagId" style="display: none;">' +
                                '<td style="text-align: center; height: 8px;" valign="top" class="textBold">' +
                                    'Meeting saved.</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/stopReturntomeetingNormal.gif" alt="" style="cursor: pointer;" onmouseover="stopChangeReturnMeetingImage(this);"' +
                                        'onmouseout="stopChangeReturnMeetingOut(this);" onclick="returnMeetingBack();" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="text-align:center;" >' +
                                    '<img src="image/stopLineSpacer.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/stopStartNewmeetingNormal.gif" style="cursor: pointer;" alt="" onmouseover="stopChangeNewMeetingImage(this);"' +
                                        'onmouseout="stopChangeNewMeetingOut(this);" onclick="startNewMeeting();" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="text-align:center;" >' +
                                    '<img src="image/stopLineSpacer.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<a href="#" id="emaildata" border="0">' +
                                        '<img src="image/stopEmaildataNormal.gif" style="border: 0; cursor: pointer;" alt=""' +
                                            'onmouseover="stopChangeEmailDataImage(this);" onmouseout="stopChangeEmailDataOut(this);" /></a></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="text-align:center;" >' +
                                    '<img src="image/stopLineSpacer.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/ViewMeetingHistory.gif" style="cursor: pointer;" alt="" onmouseover="changeViewHistoryMeetingImage(this);"' +
                                        'onmouseout="changeViewHistoryMeetingOut(this);" onclick="showMeetingHistory();" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="text-align:center;" >' +
                                    '<img src="image/stopLineSpacer.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/stopComparesalary.gif" style="cursor: pointer;" alt="" onmouseover="stopCompareSalaryImage(this);"' +
                                        'onmouseout="stopCompareSalaryOut(this);" onclick="openNewURL(\'http://www.payscale.com/?src=mm_box\');" /></td>' +
                            '</tr>' +
                        '</table>' +
                    '</td>' +
                    '<!-- middle -->' +
                    '<!-- right border -->' +
                    '<td style="text-align: right; width: 19px; background-image: url(image/headingright.PNG);">' +
                    '</td>' +
                    '<!-- right border -->' +
                '</tr>' +
            '</table>' +
        '</td>' +
    '</tr>' +
    '<tr>' +
        '<td style="background-image: url(image/stopBottom.gif); width: 252px; height: 47px;' +
            'vertical-align: top;">' +
            '<div id="divLoggedInEmail" style="vertical-align: top; padding-top: 5px; text-align: center;">' +
            '</div>' +
        '</td>' +
    '</tr>' +
'</table>';

// innerHTML to store all Text before meeting stopped, need to show same text if user click on return to meeting
var divMeetingTextBeforeStop = '';

// innerHTML use to show initially, when user click to start new meeting
var divStartNewMeetingText = '<table cellpadding="0" cellspacing="0" border="0" width="252px">' +
    '<tr>' +
        '<td>' +
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                '<tr>' +
                    '<td style="width: 110px" align="left">' +
                        '<a href="#" onclick="openNewURL(\'http://www.payscale.com?src=mm_logo\'); return false;"' +
                            'style="border: none;">' +
                            '<img src="image/meetingmisertopleft.PNG" width="110" height="56" style="cursor: pointer;' +
                                'border: none;" alt="PayScale Salary Information" id="imgMMLeft" /></a></td>' +
                    '<td style="width: 142px" align="left">' +
                        '<img width="142x" src="image/meetingmisertopright.PNG" alt="PayScale Salary Information" /></td>' +
                '</tr>' +
            '</table>' +
        '</td>' +
    '</tr>' +
    '<tr>' +
        '<td>' +
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                '<tr>' +
                    '<!-- left border -->' +
                    '<td align="left" style="width: 12px; background-image: url(image/headingleft.PNG);">' +
                    '</td>' +
                    '<!-- left border -->' +
                    '<!-- middle -->' +
                    '<td style="width: 221px">' +
                        '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                            '<tr style="height:31px;">' +
                                '<td style="vertical-align: middle; width: 100%" id="tdHeading">' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="text-align: left; vertical-align: middle; width: 173px">' +
                                                '<input id="txtMeetingHeading" class="headinginput" type="text" maxlength="25" style="width: 165px" /></td>' +
                                            '<td style="width: 48px; text-align: left">' +
                                                '<input type="image" alt="Save Meeting Heading" src="image/headingSaveBtn.PNG" class="headingsavebutton"' +
                                                    'onclick="displayMeetingHeading();" /></td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr style="height:46px;">' +
                                '<td>' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="width: 25px;">' +
                                            '</td>' +
                                            '<td style="background-image: url(image/meetingmisercostbg.PNG); width: 165; height: 50px;' +
                                                'vertical-align: middle; text-align: center; background-repeat: no-repeat;">' +
                                                '<table cellpadding="0" cellspacing="0" border="0px" width="100%" style="height: 50px;">' +
                                                    '<tr>' +
                                                        '<td id="divCost" colspan="2" style="text-align: center; vertical-align: bottom; padding-top: 4px;"' +
                                                            'class="moneyCounter">' +
                                                            '0.00</td>' +
                                                    '</tr>' +
                                                    '<tr>' +
                                                        '<td style="text-align: left; vertical-align: top; padding-left: 17px; padding-bottom: 6px;"' +
                                                            'class="accuralRate" id="divAveragePerSecond">' +
                                                            '0.00/sec</td>' +
                                                        '<td style="text-align: right; vertical-align: top; padding-right: 17px; padding-bottom: 6px;"' +
                                                            'class="accuralRate" id="divAveragePerMin">' +
                                                            '0.00/min</td>' +
                                                    '</tr>' +
                                                '</table>' +
                                            '</td>' +
                                            '<td align="right" style="width: 31px; text-align: right;">' +
                                                '<div id="divAlarm">' +
                                                    '<input type="image" class="alarmoffmainbutton" src="image/AlarmOffMainButton.png"' +
                                                        'alt="Alarm Settings" onclick="editAlarmSetting(this);" /></div>' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height: 8px;">' +
                                '</td>' +
                            '</tr>' +
                            '<tr style="height:30px;">' +
                                '<td>' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="width: 28px">' +
                                            '</td>' +
                                            '<td align="left" style="width: 60px; vertical-align: top" id="divStartStop">' +
                                                '<input type="image" src="image/meetingmiserstartbtn.PNG" alt="Start Meeting" class="startbutton"' +
                                                    'onclick="startmeeting();" /></td>' +
                                            '<td style="width: 3px">' +
                                            '</td>' +
                                            '<td align="left" style="width: 54px; vertical-align: top">' +
                                                '<input type="image" class="endbutton" src="image/meetingmiserstopbtn.gif" alt="End Meeting"' +
                                                    'onclick="stopmeeting();" />' +
                                            '</td>' +
                                            '<td style="width: 5px">' +
                                            '</td>' +
                                            '<td id="divMin" class="timeCounter" onclick="editTimer(this);" style="cursor: text;">' +
                                                '0:00:00</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td id="divMinMax">' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="background-image: url(image/linespacersmall.png); background-repeat: no-repeat;' +
                                    'background-color: Transparent; height: 12px; border: none; cursor: pointer;">' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td id="divMinMaxTitle">' +
                                    '<table cellpadding="0" cellspacing="0" width="100%" border="0">' +
                                        '<tr>' +
                                            '<td style="width: 40px;">' +
                                                '<img src="image/menu_btn.PNG" style="cursor: pointer;" alt="" id="btnMenu" onclick="showMenu();" />' +
                                            '</td>' +
                                            '<td style="text-align: center; cursor: pointer; width: 130px;" onclick="showText();">' +
                                                '<img src="image/editmeetingseeting.png" style="cursor: pointer;" alt="Edit meeting settings" />' +
                                            '</td>' +
                                            '<td style="width: 51px;">' +
                                                '<img src="image/clearallparticipants.gif" onmouseover="doTooltip(event,\'click to clear all participants\')"' +
                                                    'onmouseout="hideTip()" style="cursor: pointer;" alt="" id="btnClearAllParticipants"' +
                                                    'onclick="clearAllParticipants();" />' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                        '</table>' +
                    '</td>' +
                    '<!-- middle -->' +
                    '<!-- right border -->' +
                    '<td style="text-align: right; width: 19px; background-image: url(image/headingright.PNG);">' +
                    '</td>' +
                    '<!-- right border -->' +
                '</tr>' +
            '</table>' +
        '</td>' +
    '</tr>' +
    '<tr>' +
        '<td>' +
            '<img src="image/meetingmiserbottomimg.png" alt="" width="252" height="25" /></td>' +
    '</tr>' +
'</table>';


var divMeetingHeadingInput = '<table cellpadding="0" cellspacing="0" border="0" width="221px"><tr> ' +
'<td style="width:165px; text-align:left ; vertical-align:middle"><input id="txtMeetingHeading"  class="headinginput" type="text" maxlength="25" style="width:165px"/></td><td style="width:48 ; text-align:right"> <input type="image" alt="Save Meeting Heading" src="image/headingSaveBtn.PNG" class="headingsavebutton" onclick="displayMeetingHeading();" /></td> ' +
'</tr> ' +
'</table> ';


var innerHTMLRegisterUser = '<table cellpadding="0" cellspacing="0" border="0"  width="100%" style="vertical-align:top;background-color:#E0EFF8; background-repeat:repeat;"  >' +
                                '<tr>' +
                                   '<td style="height:5px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td class="loinginput" style="width:50%;padding-left:4px;">Enter your email</td>' +
                                    '<td class="loinginput"><input type="text" id="txtEmailId" style="width:100px;" value="" maxlength="100"></td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td class="loinginput" style="padding-left:4px;">Choose password</td>' +
                                    '<td class="loinginput"><input type="password" id="txtChoosePassword" style="width:100px; maxlength="50"></td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td class="loinginput" style="padding-left:4px;">Confirm password</td>' +
                                    '<td class="loinginput"><input type="password" id="txtConfirmPassword" style="width:100px; maxlength="50"></td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:10px;" colspan=2></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td colspan=2 style="height:20px;vertical-align:top;width:100%" ><a href="#" style="cursor:pointer;" class="blueboldlink" onclick="showLoginUser();">Already a PayScale member? Login here</a>.</td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td colspan=2>' +
                                        '<table cellpadding=0 cellspacing=0 width="100%">' +
                                            '<tr>' +
                                                '<td valign=top><input type="checkbox" id="chkNewsLetter" /></td>' +
                                                '<td style="padding-left:4px;" class="loinginput">Please send me the PayScale Salary Monthly Email Newsletter.</td>' +
                                            '</tr>' +
                                        '</table>' +
                                    '</td>' +    
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:10px;"></td>' +
                                '</tr>' +
                                '<tr id="loadingdotsId" style="vertical-align:top;padding-bottom:5px;display:none;">' +     
                                    '<td colspan="2" style="text-align:center " valign="top"><img src="image/loading.gif" alt="" /></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td style="text-align:left;padding-left:4px;" ><input type="image" src="image/joinnow.gif" class="joinnowbutton" onclick="registerUser();"/></td>' +
                                    '<td style="text-align:right;padding-right:3px;cursor:pointer;" onclick="openNewURL(\'http://www.payscale.com/license.asp\');" class="blueboldtext" >Terms of Use.</td>' +
                                '</tr>' + 
                                '<tr>' +     
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                            '</table>'

var innerHTMLdivLoginUser = '<table cellpadding=0 cellspacing=0 width="100%" style="background-color:#E0EFF8; background-repeat:repeat;"  >' +
                                '<tr>' +
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td class="loinginput" style="padding-left:4px;">Enter your email</td>' +
                                    '<td class="loinginput"><input type="text" id="txtEmailId" style="width:100px;" value="" maxlength="100"></td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td class="loinginput" style="padding-left:4px;">Enter password</td>' +
                                    '<td class="loinginput"><input type="password" id="txtPassword" style="width:100px; maxlength="50"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td style="height:10px;"></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td colspan=2 style="text-align:center;" ><input type="image" src="image/join.gif" alt="" class="loginbutton" onclick="validateUser();" /></td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:10px;"></td>' +
                                '</tr>' +
                                '<tr id="loadingdotsId" style="padding-bottom:5px;display:none;">' +     
                                    '<td colspan="2" style="text-align:center " valign="top"><img src="image/loading.gif" alt="" /></td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td colspan=2 class="blueboldtext" style="height:20px;vertical-align:top;" ><a href="#" style="cursor:pointer;" class="blueboldlink" onclick="showRegisterUser();">Not a PayScale member? Register</a></td>' +
                                '</tr>' +
                                '<tr>' +     
                                    '<td style="height:5px;"></td>' +
                                '</tr>' +
                            '</table>'

var innerHTMLUserLogin = '<table cellpadding="0" cellspacing="0" border="0" width="248px">' +
    '<tr>' +
        '<td>' +
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                '<tr>' +
                    '<td style="width: 110px">' +
                        '<a href="#" onclick="openNewURL(\'http://www.payscale.com?src=mm_logo\'); return false;"' +
                            'style="border: none;">' +
                            '<img src="image/meetingmisertopleft.PNG" style="cursor: pointer; border: none;" alt="PayScale Salary Information" /></a></td>' +
                    '<td style="width: 142px">' +
                        '<img src="image/meetingmisertopright.PNG" alt="PayScale Salary Information" /></td>' +
                '</tr>' +
            '</table>' +
        '</td>' +
    '</tr>' +
    '<tr>' +
        '<td>' +
            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                '<tr>' +
                    '<!-- left border -->' +
                    '<td align="left" style="width: 12px; background-image: url(image/headingleft.PNG);">' +
                    '</td>' +
                    '<!-- left border -->' +
                    '<!-- middle -->' +
                    '<td style="width: 221px">' +
                        '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                            '<tr>' +
                                '<td style="height: 7px;">' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="vertical-align: middle; width: 100%" id="tdHeading">' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="text-align: center; vertical-align: middle;" class="headingDiv">' +
                                                '<div style="width: 220px;" id="divDisplayMeetingHeading" onclick="showInputHeading();"' +
                                                    'class="headingDiv" onmouseover="changeColorOnMouseOver(this);" onmouseout="changeColorOnMouseOut(this);">' +
                                                '</div>' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height: 10px;">' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td>' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                        '<tr>' +
                                            '<td style="width: 25px;">' +
                                            '</td>' +
                                            '<td style="background-image: url(image/meetingmisercostbg.PNG); width: 165; height: 50px;' +
                                                'vertical-align: middle; text-align: center; background-repeat: no-repeat;">' +
                                                '<table cellpadding="0" cellspacing="0" border="0px" width="100%" style="height: 50px;">' +
                                                    '<tr>' +
                                                        '<td id="divCost" style="text-align: center; vertical-align: bottom; padding-top: 4px;"' +
                                                            'class="moneyCounter">' +
                                                            '$0.00</td>' +
                                                    '</tr>' +
                                                    '<tr>' +
                                                        '<td style="text-align: center; vertical-align: top; padding-bottom: 6px;" class="accuralRate"' +
                                                            'id="divMin">' +
                                                            '0:00:00</td>' +
                                                    '</tr>' +
                                                '</table>' +
                                            '</td>' +
                                            '<td align="right" style="width: 31px">' +
                                                '<div id="divAlarm">' +
                                                    '<input type="image" class="alarmoffmainbutton" src="image/AlarmOffMainButton.png"' +
                                                        'alt="Set Alarm" onclick="editAlarmSetting(this);" /></div>' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height: 8px;">' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td>' +
                                    '<table cellpadding="0" cellspacing="0" border="0" width="100%" style="text-align: center;">' +
                                        '<tr>' +
                                            '<td>' +
                                                '<table cellpadding="0" cellspacing="0" width="100%">' +
                                                    '<tr>' +
                                                        '<td style="height: 5px;">' +
                                                        '</td>' +
                                                    '</tr>' +
                                                    '<tr>' +
                                                        '<td class="savemeetingheading">' +
                                                            'Save Your Meeting</td>' +
                                                    '</tr>' +
                                                    '<tr>' +
                                                        '<td style="height: 5px;">' +
                                                        '</td>' +
                                                    '</tr>' +
                                                    '<tr>' +
                                                        '<td>' +
                                                            '<div id="divUserLogin">' +
                                                                innerHTMLRegisterUser +
                                                            '</div>' +
                                                        '</td>' +
                                                    '</tr>' +
                                                '</table>' +
                                            '</td>' +
                                        '</tr>' +
                                    '</table>' +
                                '</td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/stopReturntomeetingNormal.gif" alt="" style="cursor: pointer;" onmouseover="stopChangeReturnMeetingImage(this);"' +
                                        'onmouseout="stopChangeReturnMeetingOut(this);" onclick="returnMeetingBack();" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="text-align:center;" >' +
                                    '<img src="image/stopLineSpacer.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/stopStartNewmeetingNormal.gif" style="cursor: pointer;" alt="" onmouseover="stopChangeNewMeetingImage(this);"' +
                                        'onmouseout="stopChangeNewMeetingOut(this);" onclick="startNewMeeting();" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="text-align:center;" >' +
                                    '<img src="image/stopLineSpacer.gif" alt="" /></td>' +
                            '</tr>' +
                            '<tr>' +
                                '<td style="height:38px;padding-left:15px;">' +
                                    '<img src="image/stopComparesalary.gif" style="cursor: pointer;" alt="" onmouseover="stopCompareSalaryImage(this);"' +
                                        'onmouseout="stopCompareSalaryOut(this);" onclick="openNewURL(\'http://www.payscale.com/?src=mm_box\');" /></td>' +
                            '</tr>' +
                        '</table>' +
                    '</td>' +
                    '<!-- middle -->' +
                    '<!-- right border -->' +
                    '<td style="text-align: right; width: 19px; background-image: url(image/headingright.PNG);">' +
                    '</td>' +
                    '<!-- right border -->' +
                '</tr>' +
            '</table>' +
        '</td>' +
    '</tr>' +
    '<tr>' +
        '<td>' +
            '<img src="image/stopBottom.gif" width="252px" alt="" /></td>' +
    '</tr>' +
'</table>';



var innerHTMLMeetingHistory =  '<table cellpadding="0" cellspacing="0" border="0" width="252px" style="border:red solid 1px;padding-left:10px;">' +
                                   '<tr>' +
                                        '<td>' +
                                            '<table cellpadding="0" cellspacing="0" border="0" width="100%">' +
                                               '<tr>' + 
                                                    '<td style="padding-top:10px;"><a href="#" onclick="openNewURL(\'http://www.payscale.com?src=mm_logo\'); return false;" style="border:none;" ><img src="image/historypayscale.png" alt="PayScale Salary Information" style="width:102px;border:none;" /></a><img src="image/historymeetingmiser.png" alt="PayScale Salary Information" style="width:132px;" /></td>' +
                                               '</tr>' + 
                                               '<tr>' + 
                                                    '<td style="height:10px;" colspan="2"></td>' +
                                               '</tr>' +  
                                               '<tr>' + 
                                                    '<td>' +  
                                                        '<table cellpadding="0" cellspacing="0" width="100%" border="0">' +  
                                                            '<tr>' +  
                                                                '<td class="meetinghistoryheading" style="width:150px;">Meeting History</td>' +  
                                                                '<td style="text-align:right;padding-right:5px;"><img src="image/menu_btn.PNG" style="cursor: pointer;" alt="" id="btnMenu" onclick="CloseMeetingHistory();" /></td>' +
                                                            '</tr>' +  
                                                            '<tr>' +  
                                                                '<td colspan="2" id="loadingdotsId" style="display:none;text-align:center;padding-top:5px;" valign="top"><img src="image/loading.gif" alt="" /></td>' +  
                                                            '</tr>' +  
                                                        '</table>' +  
                                                    '</td>' +      
                                               '</tr>' +  
                                               '<tr>' + 
                                                    '<td style="height:5px;"  colspan="2"></td>' +
                                               '</tr>' +  
                                               '<tr>' + 
                                                    '<td  colspan="2"><img alt="" src="image/linespacerhistory.gif" /></td>' +
                                               '</tr>' + 
                                               '<tr>' + 
                                                    '<td style="height:10px;"  colspan="2"></td>' +
                                               '</tr>' + 
                                               '<tr>' + 
                                                    '<td  colspan="2">' +
                                                        '<div id="divmeetinghistory" style="overflow:auto;width:235px;height:350px;min-height: 100%; margin-bottom: 1px;overflow-x:hidden;"></div>' +
                                                        '<div style="height:10px;"></div>' +
                                                        '<div style="height:10px;"><img alt="" src="image/linespacerhistory.gif" /></div>' +
                                                        '<div id="divmeetinghistorytotal"></div>' +
                                                    '</td>' +
                                               '</tr>' +
                                            '</table>' +
                                        '</td>' +
                                   '</tr>' +
                                '</table>' 

var innerHTMLEditAttPopup = '<table cellpadding="0" cellspacing="0" width="76px"  >' +
'<tr>' +
'<td>' +
    '<table cellpadding="0" cellspacing="0">' +
        '<tr>' +
            '<td><img src="image/inNormalSmall.png" alt="In" style = "cursor: pointer;" onclick="attIn();" id="inImg" onmouseover="changeinImage(this);"  onmouseout="changeinImageRollover(this);"  /></td>' +
            '<td>' +
                '<table cellpadding="0" cellspacing="0">' +
                    '<tr>' +
                        '<td style="padding-top:2px;" style="width:12px;"><img src="image/inOutFrameClose.png" style = "cursor: pointer;" alt="" onclick="CloseDeleteMeetingAttMessage();"></td>    ' +
                    '</tr>' +
                    '<tr>' +
                        '<td><img src="image/inbottomspaceNormal.png" alt="In" style = "cursor: pointer;" onclick="attIn();" id="inImgSpace" onmouseover="changeinspaceImage(this);"  onmouseout="changeinspaceImageRollover(this);" ></td>' +
                    '</tr>' +
                '</table>' +
            '</td>' +
        '</tr>' +
    '</table>' +
'</td>' +
'</tr>' +
'<tr>' +
'<td> <img src="image/OutNormal.PNG" alt="Out" style = "cursor: pointer;" onclick="attOut();" onmouseover="changeoutImage(this);"  onmouseout="changeoutImageRollover(this);" /></td>' +
'</tr>' +
'<tr>' +
'<td> <img src="image/EditNormal.PNG" alt="Edit" style = "cursor: pointer;" onclick="attEdit();" onmouseover="changeeditImage(this);" onmouseout="changeeditImageRollover(this);"  /></td>' +
'</tr>' +
'<tr>' +
'<td> <img src="image/DeleteNormal.PNG" alt="Delete" style = "cursor: pointer;" onclick="attDelete();" onmouseover="changedeleteImage(this);" onmouseout="changedeleteImageRollover(this);" /></td>' +
'</tr>' +
'</table>';                           

var meetingStartingTime ;

var meetingPauseTimeTime ;


// click counter to count PauseTime
var ticksCounterPauseTime =0;

var ticksPastPauseTime = 0;


var jobTitleConnectivityMessage ='no';

function openNewURL(url)
{
     window.open (url,"Payscale","status=1,toolbar=1,menubar=1,location=1,resizable=1,titlebar=1");
}

// show hide text
function showText()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    
    var intialText = document.getElementById("divMinMax"); 
    if(divShowHideText == '')
    {
        intialText.innerHTML = divintialMax;       
    }
    else
    {
        intialText.innerHTML = divShowHideText;
    }
    
    autoFillCountry();
    getJobTitles();
    //fetchFiveMostRecentAttendees();
    
    var city = document.getElementById("txtCity");
//    if(city != null)
//    { 
//        fillcities();
//    }
    if(isEditAtt == 'yes')
    {
        attEditSliderLocationChangeCase();
    }    
    var divMinMaxTitle = document.getElementById("divMinMaxTitle"); 
    divMinMaxTitle.innerHTML = divMinTag;     
}

// minimize text
function hideText()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var intialText = document.getElementById("divMinMax"); 
    divShowHideText =  trim(intialText.innerHTML);
    intialText.innerHTML = littlespaceImage;    
    var divMinMaxTitle = document.getElementById("divMinMaxTitle"); 
    divMinMaxTitle.innerHTML = divMaxTag;
    
}

// Display Title first time
function getTodayTime()
{
    var currentTime = new Date();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();
    var todayTime = month + "/" + day + "/" + year;
    var txtHeading = document.getElementById("txtMeetingHeading");    
    txtHeading.value = "My Meeting";    
    //txtHeading.value = todayTime + " MEETING";    
    meetingHeading =txtHeading.value ;
}

// select the meeting title
function selectInputHeading()
{
    var input = document.getElementById("txtMeetingHeading");
    if(input != null)
    {
        input.select();
    }

}

// change Meeting Title 
function displayMeetingHeading()
{
        
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var txtHeading= document.getElementById("txtMeetingHeading");       
    var divHeading= document.getElementById("tdHeading"); 
    divHeading.innerHTML  = '<a href="#" onmouseover="doTooltip(event,\'click to edit meeting title\')" onmouseout="hideTip()" ><div style="width:221px;" id="divDisplayMeetingHeading" onclick="showInputHeading();" class="headingDiv" onmouseover="changeColorOnMouseOver(this);"  onmouseout="changeColorOnMouseOut(this);" >' +  txtHeading.value + '</div></a>'  ;     
    meetingHeading = txtHeading.value;
}

// show input heading again
function showInputHeading()
{
    hideTip();
    
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    
    if(isEndClicked == 'no')
    {
        var divHeading= document.getElementById("tdHeading");     
        var divDisplay = document.getElementById("divDisplayMeetingHeading");     
        divHeading.innerHTML = "";
        divHeading.innerHTML = divMeetingHeadingInput ;    
        var input = document.getElementById("txtMeetingHeading");
        input.value = meetingHeading;
        input.focus();
        input.select();
    }
    
}


// when country or state gets change initialize city textbox value.
function changeCity()
{
    
    var city = document.getElementById("txtCity"); 
    var country = document.getElementById("txtCountry"); 
    var state = document.getElementById("txtState"); 
    if( city !=  null)
    {
        city.value =initialTextForCity;
    }
}

// when country gets change initialize state dropdown value.
function changeState()
{
    var state = document.getElementById("txtState"); 
    if( state !=  null)
    {   
        state.options[0].selected = true;
       // hide city         
    }
     var city = document.getElementById("divCity"); 
     if(city != null) 
        city.innerHTML = littlespaceImage;
}

// delete country when focus if it is - Select Country -
function refreshCountry()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var country = document.getElementById("txtCountry");  
    if( country.value == initialTextForCountry)
    { 
        country.value ='';
    }
    country.select();
}

// delete state when focus if it is - Select State - or - Select Province -
function refreshState()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var state = document.getElementById("txtState"); 
    // wtg - changed9/27/2007
    //if( state.value == '- Select State Name -')
    if( state.value.indexOf("- Select ") == 0)
    {   
        state.value ='';
    }
    state.select();
}

// delete city when focus if it is - Select City -
function  refreshCity()
{   
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var city = document.getElementById("txtCity"); 
    if( city.value == initialTextForCity)
    {   
        city.value ='';
    } 
    city.select();     
}

function checkState()
{
    var state = document.getElementById("txtState"); 
      var state = document.getElementById("txtState"); 
    // wtg - changed9/27/2007
    //if( state.value == '- Select State Name -')
    if( state.value.indexOf("- Select ") == 0)
    {   
        var cityDiv = document.getElementById("divCity");
        if(cityDiv != null)
        {
            cityDiv.innerHTML = littlespaceImage;
        } 
    }
    else
    {
        fillCities();
    }
}


// delete job titles when focus if it is - Enter Job Title - and also check if location has been edited before filling job titles
function refreshJobTitle(source)
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    if(countryValue != '')
    {
        if(source.value == '- Enter Job Title -')
        {
            source.value = '';
        }
        source.select();
    }
    else
    {
        var country = document.getElementById("txtCountry");  
        country.focus();
        ShowErrorMessage("attinput1", "Please edit location first.");
    }
}

// again set Enter Job Title when focus lost

function refreshJobTitleOnLostFocus(source)
{
    source.value = '- Enter Job Title -';
}

// start meeting
function startmeeting()
{
    CloseDropdownWindow(); 
    CloseAlarmDropdownWindow();   
    CloseErrorMsgWnd();
    if(countryValue == '')
    {
        ShowErrorMessage("divMin","Please edit location first."); 
        return;
    }    
    if(countParticipants() > 1)
    { 
        isMeetingStarted ='yes'
        var divAlram= document.getElementById("divStartStop");     
        divAlram.innerHTML  = divPausebtn ;
    }
    else
    {
        ShowErrorMessage("divMin","At least one participant should be present to start the meeting, please add participants."); 
        return;
    }
    isMeetingStarted ='yes'
    //canEditTimer = 'no';   
    isMeetingPause = 'no'  
    // check if meeting started first time 
    if(ticksCounter == 0)
    {
        meetingStartingTime  = new Date();  
    }
    ticksPastPauseTime = ticksPastPauseTime + ticksCounterPauseTime ;
    
    objbtnClearAll = document.getElementById("btnClearAll");
    if(objbtnClearAll != null)
    {
        objbtnClearAll.style.display='none';
    }
    
    startTimer();
}

// pause meeting
function pausemeeting()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var divstartStop= document.getElementById("divStartStop");     
    isMeetingStarted ='no';  
    isMeetingPause = 'yes';   
    //canEditTimer = 'yes';   
    divstartStop.innerHTML  = divStartbtn ;
    meetingPauseTimeTime = new Date();
    
    objbtnClearAll = document.getElementById("btnClearAll");
    if(objbtnClearAll != null)
    {
        objbtnClearAll.style.display='';
    }
}

// stop meeting
function stopmeeting()
{
    isEndClicked = 'yes';

    var body = ""; 
    var currentDate = new Date();

    isMeetingStarted ='no'; 
    isMeetingPause = 'yes';   
    meetingPauseTimeTime = new Date();
    CloseAlarmAlertWidow();
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();     

    if(loggedinUsrEmail == "" && loggedinUsrPwd == "")
    {

        var divWholeMeeting = document.getElementById("divWholeMeetingDisplay"); 
        divMeetingTextBeforeStop = '';
        divMeetingTextBeforeStop = trim(divWholeMeeting.innerHTML);
        divWholeMeeting.innerHTML = innerHTMLUserLogin;     
        
        var objdivDisplayMeetingHeading = document.getElementById("divDisplayMeetingHeading"); 
        if(objdivDisplayMeetingHeading != null)
        {
            objdivDisplayMeetingHeading.innerHTML = meetingHeading;
            objdivDisplayMeetingHeading.onmouseover='';
            objdivDisplayMeetingHeading.onmouseout='';
        }
        
        
        var objdivCost =  document.getElementById("divCost");  
        if(objdivCost != null)
        {
            objdivCost.innerHTML = trim(formatCurrency(round(moneyCounter)));     
        }
        
        
        var objdivTotalMeetingTime =  document.getElementById("divMin");  
        if(objdivTotalMeetingTime != null)
        {
            if(currentTimer != "")
            {
                objdivTotalMeetingTime.innerHTML = currentTimer;     
            }
            else
            {
                objdivTotalMeetingTime.innerHTML = "0:00:00";     
            }
            
        }
    }
    else
    {
        var divWholeMeeting= document.getElementById("divWholeMeetingDisplay"); 
        divMeetingTextBeforeStop = '';
        divMeetingTextBeforeStop = trim(divWholeMeeting.innerHTML);
        divWholeMeeting.innerHTML = divStopMeetingText;     
        //var heading = document.getElementById("divstopMeetingHeader");      
        var heading = document.getElementById("divDisplayMeetingHeading");      
        heading.innerHTML = meetingHeading ;
        
        heading.onmouseover='';
        heading.onmouseout='';
        
        var objdivCost =  document.getElementById("divCost");  
        if(objdivCost != null)
        {
            objdivCost.innerHTML = trim(formatCurrency(round(moneyCounter)));     
        }
        
        
        var objdivTotalMeetingTime =  document.getElementById("divMin");  
        if(objdivTotalMeetingTime != null)
        {
            if(currentTimer != "")
            {
                objdivTotalMeetingTime.innerHTML = currentTimer;     
            }
            else
            {
                objdivTotalMeetingTime.innerHTML = "0:00:00";     
            }
            
        }
        
        if(attendeesHashtable.size() > 1 && currentTimer != "")
        {
            // saves the meeting 
            saveMeeting();
        }
        
        var objdivLoggedInEmail = document.getElementById("divLoggedInEmail");
        if(objdivLoggedInEmail != null)
        {
            var loggedinUsrEmailForDisplay = loggedinUsrEmail;
            if(loggedinUsrEmail.length > 25)
            {
                loggedinUsrEmailForDisplay = loggedinUsrEmail.substring(0,22) + '...';
            }
            objdivLoggedInEmail.innerHTML = '<table cellpadding="0" cellspacing=0 width="100%" border="0"><tr><td width="70%" style="text-align:right;"><Font class="blacktextbold">'+loggedinUsrEmailForDisplay+'</Font> </td> <td style="text-align:left;">&nbsp;|&nbsp;<a href="#" onclick="logoutUser();" class="blackboldlink">Logout</a></td></tr></table>';
        }
        
        if(attendeesHashtable.size() > 1 && currentTimer != "")
        {
            body = '';
            var currdate = (currentDate.getMonth()+1)+'/'+currentDate.getDay()+'/'+currentDate.getFullYear();
            var cost = trim(formatCurrency(round(moneyCounter)));
            var emaildata = getEmailBodyFormat(currdate,currentTimer,cost,meetingHeading);
            
            var objemaildata = document.getElementById("emaildata"); 
            if(objemaildata != null)
            {
                objemaildata.href=emaildata
            }
        }
        else
        {
            var objemaildata = document.getElementById("emaildata"); 
            if(objemaildata != null)
            {
                objemaildata.href='#';
            }
        }
    }


    if(alarmIsSet == 'yes')
    {
        var divAlram= document.getElementById("divAlarm"); 
        if(divAlram != null)
        {
            divAlram.innerHTML  = divAlarmEnalbed;
        }    
    }
    else
    {
        var divAlram= document.getElementById("divAlarm"); 
        if(divAlram != null)
        {
            divAlram.innerHTML  = divAlarmDisabled;
        }    
    }  
    
    var objimgMMLeft = document.getElementById("imgMMLeft"); 
    if(objimgMMLeft != null)
    {
        objimgMMLeft.focus();
    }  
}

// show meeting completio menu.

function showMeetingCompletionMenu()
{
    var body = ""; 
    var currentDate = new Date();
    
    var divWholeMeeting= document.getElementById("divWholeMeetingDisplay"); 
    divWholeMeeting.innerHTML = divStopMeetingText;     
    //var heading = document.getElementById("divstopMeetingHeader");      
    var heading = document.getElementById("divDisplayMeetingHeading");      
    
    heading.innerHTML = meetingHeading ;
    heading.onmouseover='';
    heading.onmouseout='';
    
    var objdivCost =  document.getElementById("divCost");  
    if(objdivCost != null)
    {
        objdivCost.innerHTML = trim(formatCurrency(round(moneyCounter)));     
    }
    
    
    var objdivTotalMeetingTime =  document.getElementById("divMin");  
    if(objdivTotalMeetingTime != null)
    {
        if(currentTimer != "")
        {
            objdivTotalMeetingTime.innerHTML = currentTimer;     
        }
        else
        {
            objdivTotalMeetingTime.innerHTML = "0:00:00";     
        }
        
    }
    if(attendeesHashtable.size() > 1 && currentTimer != "")
    {
        showloadingdots('yes');
    }
    
    var objdivLoggedInEmail = document.getElementById("divLoggedInEmail");
    if(objdivLoggedInEmail != null)
    {
        var loggedinUsrEmailForDisplay = loggedinUsrEmail;
        if(loggedinUsrEmail.length > 25)
        {
            loggedinUsrEmailForDisplay = loggedinUsrEmail.substring(0,22) + '...';
        }
        objdivLoggedInEmail.innerHTML = '<table cellpadding="0" cellspacing=0 width="100%" border="0"><tr><td width="70%" style="text-align:right;"><Font class="blacktextbold">'+loggedinUsrEmailForDisplay+'</Font> </td> <td style="text-align:left;">&nbsp;|&nbsp;<a href="#" onclick="logoutUser();" class="blackboldlink">Logout</a></td></tr></table>';
    }
    
    if(attendeesHashtable.size() > 1 && currentTimer != "")
    {
        body = '';
        var currdate = (currentDate.getMonth()+1)+'/'+currentDate.getDay()+'/'+currentDate.getFullYear();
        var cost = trim(formatCurrency(round(moneyCounter)));
        var emaildata = getEmailBodyFormat(currdate,currentTimer,cost,meetingHeading);
        
        var objemaildata = document.getElementById("emaildata"); 
        if(objemaildata != null)
        {
            objemaildata.href=emaildata
        }
    }
    else
    {
        var objemaildata = document.getElementById("emaildata"); 
        if(objemaildata != null)
        {
            objemaildata.href='#';
        }
    }
    //isMenuBtnClick = 'no';
    
    var objimgMMLeft = document.getElementById("imgMMLeft"); 
    if(objimgMMLeft != null)
    {
        objimgMMLeft.focus();
    }
    
}

function getEmailBodyFormat(currdate,timer,cost,title)
{
    var body = '';
    body = body + 'Hello there,%0A%0A'
    body = body + 'The Meeting Miser caught you spending money on '+currdate+'. Your meeting ran for '+timer+' and cost you a whopping '+cost+'. Was it worth every penny ... or a waste of time?%0A';
    body = body + 'Who was there?%0A';
    
    
    for(i=0; i < attendeesJobTitle.size(); i++)
    {
        var k = attendeesJobTitle.keys()[i];
        
        var valQuotes = combinedRates.get(k);
        
        if(valQuotes.Median != null)
        {
            body = body + attendeesJobTitle.get(k)+', '+formatTimerFromSecs(attendeesHashtable.get(k))+'%0A';
        }
    }
    
    body = body + '%0ATo track the cost of your next meeting, go to%0Ahttp://www.payscale.com/meetingmiser%0A%0A'; 
    body = body + 'For the latest in workplace and salary news%0A';
    body = body + 'http://www.blogs.payscale.com';
    
    
    var emaildata = '';  
    if(loggedinUsrEmail != "")
    {
        emaildata = emaildata + 'mailto:'+loggedinUsrEmail;
        emaildata = emaildata + '?subject='+title + ' - Summary';
        emaildata = emaildata + '&body='+body;
    }
    
    return emaildata;
}


// start new meeting, set all variable to initial values
function startNewMeeting()
{
    //getLoginPwdFromCookie();
    nextID = 1;
    currentID = 1;
    currentattEdit = 0;
    alarmAmount =0.00;
    alarmTime = 0;
    alarmIsSet ='no';
    alarmSettingValue = "USD";
    moneyCounter = 0.00;
    currentSelectedCurrency = '$';
    isMeetingPause ='no'
    ticksCounter =0;
    ticksCounterPauseTime =0; 
    ticksPastPauseTime = 0;
    attendeesHashtable.clear();
    combinedRates.clear(); 
    inOutHashtable.clear() ;
    attendeesJobTitle.clear();
    attendeesEditList.clear(); 
    timerID = 0;
    countryValue ='';
    stateValue ='';
    cityValue ='';
    editcaselocation = 'no';
    averagePerSecond = 0.00;
    var divWholeMeeting= document.getElementById("divWholeMeetingDisplay"); 
    divWholeMeeting.innerHTML = divStartNewMeetingText;
    getTodayTime();
    hideText();
    showText();
    displayMeetingHeading();
    isMeetingStarted ='no'
    //canEditTimer = 'yes'
    isEndClicked = 'no';
    isMenuBtnClick = 'no';
    editticksCounter = 0;
    showToolTipDiv('yes');
    // Restore the saved location!
    showSavedLocation();
}

// return back to meeting , after stopped
function returnMeetingBack()
{
    var divWholeMeeting= document.getElementById("divWholeMeetingDisplay");
    if(divWholeMeeting != null)
        divWholeMeeting.innerHTML =  divMeetingTextBeforeStop ;
    
    var objdivDisplayMeetingHeading = document.getElementById("divDisplayMeetingHeading"); 
    if(objdivDisplayMeetingHeading != null)
    {
        objdivDisplayMeetingHeading.innerHTML = meetingHeading;
    }
        
        
    isEndClicked = 'no';    
    //isMeetingStarted ='yes'
    //canEditTimer = 'yes'
    
    // check if country was edit when meeting stopped
    var country = document.getElementById("txtCountry");
    var state = document.getElementById("txtState");
    var city = document.getElementById("txtCity");
    if(country != null)
    {
        for (var i = (country.options.length-1); i >= 0; i--)
        {
            country.options[i]=null;
        }
        country.options[0]=new Option(initialTextForCountry,initialTextForCountry);
        autoFillCountry();
        if(countryValue != "")
            country.value = countryValue; 
    }
    if(state != null)
    {
        fillStates(); 
    }

    if(isEditAtt == 'yes')
    {
        attEditSliderLocationChangeCase();
    }
    getJobTitles();
    
    if(isMenuBtnClick == 'yes')
    {
        if(isMeetingPause != 'yes')
        {
            isMeetingStarted ='yes' ;
            isMeetingPause = 'no';
        }    
        isMenuBtnClick = 'no';
    }
    else
    {
        objbtnClearAll = document.getElementById("btnClearAll");
        if(objbtnClearAll != null)
        {
            objbtnClearAll.style.display='';
        }
    
        isMeetingStarted ='no';
        isMeetingPause = 'yes';
        
        
         var divstartStop= document.getElementById("divStartStop"); 
         if(divstartStop != null)
            divstartStop.innerHTML  = divStartbtn ;
    }    
    
    var txtHeading= document.getElementById("txtMeetingHeading");    
    if(txtHeading != null)
    {
        txtHeading.value = meetingHeading;
    }
    showToolTipDiv('yes');
    
    if(alarmIsSet == 'yes')
    {
        var divAlram= document.getElementById("divAlarm"); 
        if(divAlram != null)
        {
            divAlram.innerHTML  = divAlarmEnalbed;
        }    
    }
    else
    {
        var divAlram= document.getElementById("divAlarm"); 
        if(divAlram != null)
        {
            divAlram.innerHTML  = divAlarmDisabled;
        }    
    }
}

// on alarm
function alarmOn()
{
    var divAlram= document.getElementById("divAlarm"); 
    divAlram.innerHTML  = divAlarmEnalbed ;
    alarmIsSet ='yes';
    CloseAlarmDropdownWindow();

}

//  alarm off
function alarmOff()
{
    var divAlram= document.getElementById("divAlarm"); 
    divAlram.innerHTML  = divAlarmDisabled ;
    alarmIsSet ='no';
    CloseAlarmDropdownWindow();
    alarmAmount= 0.00;
    alarmTime =0;
}


// save alarm setting
function saveAlarmSetting()
{
    var txtAlarmAmount = document.getElementById("txtAlarmAmount"); 
    
    if(txtAlarmAmount.value >0 )
    {
        var txtAlarmCurrency = document.getElementById("listAlarmCurrency"); 
        alarmSettingValue = txtAlarmCurrency.value;
        alarmIsSet ='yes';
        if(alarmSettingValue =="USD")
        {
            alarmAmount =txtAlarmAmount.value; 
        }
        else
        {
            alarmTime =txtAlarmAmount.value; 
        }
        alarmOn(); 
    }
    else
    {
        CloseAlarmDropdownWindow();
    }
}

// helper used to prevent return from doing a 'submit' -- which opens the alarm settings!
function noenter()
{
    return !(window.event && window.event.keyCode == 13);
}

// open alarm pop up alert
function editAlarmSetting(source)
{
    if(isEndClicked == 'no' && isMenuBtnClick == 'no')
    {
        var oCurrentNode=source;
        var iLeft=0;
        var iTop =0;
        while(oCurrentNode.tagName!="BODY")
        {
            iTop+=oCurrentNode.offsetTop;
            iLeft+=oCurrentNode.offsetLeft;
            oCurrentNode=oCurrentNode.offsetParent;
        }
        CreateAlarmDropdownWindow(iLeft + 5 ,iTop + 5);
    }
}


// Fill country
function autoFillCountry()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var country = document.getElementById("txtCountry"); 
    try
    {
        if(country != null)
        {
            var countryArray = ["United States", "Canada", "United Kingdom", "Australia", "India"];
            var i =0;
            for(i=0;i<countryArray.length;i++)
            {
               var optn = document.createElement("OPTION");
               optn.text = countryArray[i];
               optn.value = countryArray[i];
               country.options[country.options.length]= optn;

            }
        }
    }
    catch(exception)
    {
        ShowErrorMessage("divMin",noConnectivityMessage);
    }
}

// check if country selected from list
function checkCountry()
{
    var returnResult = false;
    var country = document.getElementById("txtCountry");
    if(country.value == "United States")
    {
       returnResult = true;        
    }
    if(country.value == "Canada")
    {
        returnResult = true;
    }
    if(country.value == "United Kingdom")
    {
        returnResult = true;
    }
    if(country.value == "Australia")
    {
        returnResult = true;
    }
    if(country.value == "India")
    {
        returnResult = true;
    }
    
    return returnResult;
}

// Fill states
function fillStates() 
{
    if(checkCountry())
    {
        objbtnSaveLocation = document.getElementById("btnSaveLocation");
        if(objbtnSaveLocation != null)
        {
            objbtnSaveLocation.disabled = true;
        }
        
        editLocationConnectivity = 'no';
        try
        {
            CloseDropdownWindow();
            CloseAlarmDropdownWindow();
            CloseErrorMsgWnd();
            var stateDiv = document.getElementById("divState");
            stateDiv.innerHTML = loadingImage;
            var country = document.getElementById("txtCountry");    
            givePrivilegeAccess();
            var url ="../syndication/simplequote.asmx"; 
            var pl = new SOAPClientParameters();
            pl.add("country", country.value);            
            SOAPClient.invoke(url, "GetStates", pl, true, fillStates_CallBack,"1"); 
        }
        catch(exception)
        {
            ShowErrorMessage("divMin",noConnectivityMessage);
                    
            editLocationConnectivity = 'yes';
            var stateDiv = document.getElementById("divState");
            if(stateDiv != null)
            {
                stateDiv.innerHTML = littlespaceImage; 
                //stateDiv.style.className = "littlespacer";
            }
            fillCities();
        }
       
    }
    else
    {
        stateValue = '';
        var stateDiv = document.getElementById("divState");
        stateDiv.innerHTML = littlespaceImage;
        
        var cityDiv = document.getElementById("divCity");
        if(cityDiv != null)
        {
            cityDiv.innerHTML = littlespaceImage;
        }    
    }
}
 

// hide states and cities while country  changes 
function countryFocusEvent()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var stateDiv = document.getElementById("divState");
    stateDiv.innerHTML = loadingImage;
    var cityDiv = document.getElementById("divCity");
    cityDiv.innerHTML = littlespaceImage;
    editcaselocation ='no';
}

// Call back function while fill states   
function fillStates_CallBack(result)
{ 
    
    objbtnSaveLocation = document.getElementById("btnSaveLocation");
    if(objbtnSaveLocation != null)
    {
        objbtnSaveLocation.disabled = false;
    }
    
    var stateText = divState;
    // wtg - changed to display Province for Canada
    var countryDiv = document.getElementById("txtCountry");
    if (countryDiv != null && countryDiv.value == "Canada") 
    {
        stateText = divState.replace(/- Select State -/g,"- Select Province -");
    }
    var stateDiv = document.getElementById("divState");
    if(stateDiv != null)
        stateDiv.innerHTML = stateText;
    
    
    try
    {
        if(result != null && result.length > 0)
        {
            stateDiv.innerHTML = stateText;
            var objstate= document.getElementById("txtState");
            
            var j=0;
            for(j=0;j<result.length;j++)
            {
               var optn1 = document.createElement("OPTION");
               optn1.text = result[j];
               optn1.value = result[j];
               objstate.options[objstate.options.length]= optn1;
            }
            
            if(stateValue != '' && editcaselocation =='yes')
            {
                var state = document.getElementById("txtState");                
                state.value = stateValue;
                if(state.value == "")
                {
                    if(countryValue != "United Kingdom")
                    {
                        
                        state.options[0].selected = true;
                        var cityDiv = document.getElementById("divCity");
                        if(cityDiv != null)
                        {
                            cityDiv.innerHTML = littlespaceImage; 
                        }
                    }
                    else
                    {
                        state.options[0].selected = true;
                    }
                }
                //state.select();
                if(stateValue == '' && stateValue == initialTextForState)
                {
                    var cityDiv = document.getElementById("divCity");
                    if(cityDiv != null)
                    {
                        cityDiv.innerHTML = littlespaceImage; 
                    }
                }
            }
            else if(stateValue == '') 
            {
                var cityDiv = document.getElementById("divCity");
                if(cityDiv != null)
                {
                    cityDiv.innerHTML = littlespaceImage; 
                }
            }
        }
        else
        {
            stateValue = "";
            stateDiv.innerHTML = littlespaceImage;
            fillCities();
            var city = document.getElementById("txtCity");
            if(city != null)
            {
                if(countryValue != "United Kingdom")
                {
                    city.value = initialTextForCity; 
                }
            }
        }
    }
    catch(exception)
    {
        
        ShowErrorMessage("divMin",noConnectivityMessage); 
            
        editLocationConnectivity = 'yes';
        var stateDiv = document.getElementById("divState");
        if(stateDiv != null)
        {
            stateDiv.innerHTML = littlespaceImage; 
        }
    }
}

/// show cities
function fillCities()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    
    try
    {
        var cityDiv = document.getElementById("divCity");
        cityDiv.innerHTML = divCity; 
        var city = document.getElementById("txtCity");    
        if(city != null)
        {
            oACDS = new YAHOO.widget.DS_XHR("../complete.aspx", ["Answers","sv"]);
            oACDS.queryMatchContains = true;
            oACDS.scriptQueryParam  ="s"; 
            oACDS.scriptQueryAppend = "field=City&ss=n&sa=n&min=0"; 
            cityAutoComp = new YAHOO.widget.AutoComplete("txtCity","containerCity", oACDS);
            cityAutoComp.useIFrame = true;
            cityAutoComp.useIFrame = true;
            cityAutoComp.itemSelectEvent.subscribe(showloc); 
            cityAutoComp.unmatchedItemSelectEvent.subscribe(unmatchCityEnterd);            
            if(cityValue != '' && editcaselocation =='yes')
            {
                city.value = cityValue;
            }
        }
    }
    catch(exception)
    {
        ShowErrorMessage("divMin",noConnectivityMessage); 
    }
}

// fired when found un-matched city in data source
function unmatchCityEnterd(oSelf)
{
    var city = document.getElementById("txtCity");
    if(city != null && (city.value != initialTextForCity && city.value != ""))
    {
       city.value = "";
    }
}


// edit location
function editLocation()
{
    hideTip();
    editLocationConnectivity ='no';
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var divcityref1 = document.getElementById("divCity");
    var divcountryref1 = document.getElementById("divCountry");
    divcountryref1.innerHTML = divCounty;    

    if(stateValue != '' && cityValue == '' )
    {
        divcityref1.innerHTML = divCity;
    }    

    var country = document.getElementById("txtCountry");
    autoFillCountry();
    country.value = countryValue; 
    var stateDiv = document.getElementById("divState");
    stateDiv.innerHTML = loadingImage; 
        
    var divLocationDisplay = document.getElementById("divLocation");
    divLocationDisplay.innerHTML =littlespaceImage;
    var divLocationSave = document.getElementById("divLocationSave");
    divLocationSave.innerHTML = divDisplayLocationSave;
    
    fillStates();
    fillCities();
    
    if(editLocationConnectivity == 'yes')
    {
        showlocationcancel();
    }
}


// hide all text box and show location
function showlocation()
{
    if(checkCountry())
    {
        isStateORCityChanged = 'no';
        isCountryChanged = 'no';
        var oldCurrenySymbol = currentSelectedCurrency;
        CloseDropdownWindow();
        CloseAlarmDropdownWindow();
        CloseErrorMsgWnd();
        var city = document.getElementById("txtCity");
        var state = document.getElementById("txtState");
        var country = document.getElementById("txtCountry");
        if(country.value ==initialTextForCountry || country.value =='' )
        {
            ShowErrorMessage("divMin","Please enter location first");
             
            return;
        } 
   
         
        if((countryValue != country.value) ) // check if country chnaged
        {
            isCountryChanged = 'yes';
            if(BrowserDetect.browser =="Safari")
            {
                if(countryValue != '' && ( attendeesEditList.size() > 2 ))
                {
                    var objdivMin = document.getElementById("divMin");
                    if(objdivMin != null)
                    showCountryChangeMessage(objdivMin);

                    isCountryChangedMsgShow = 'yes';
                } 
            }
            else if(countryValue != '' && ( attendeesEditList.size() > 1 ))
            {
                var objdivMin = document.getElementById("divMin");
                if(objdivMin != null)
                      showCountryChangeMessage(objdivMin);
                
                isCountryChangedMsgShow = 'yes';
            }
        }
        
        if(isCountryChangedMsgShow == 'no')
        {
            if(state != null)
            {
                // wtg - changed 9/27/2007
                // if( state.value.indexOf("- Select ") == 0)
                if(state.options[0].selected == true || state.value == initialTextForState || state.value == '')
                {   
                    stateValue = "";
                }
                else
                {
                    stateValue =state.value;
                }
                if(stateValue != state.value)
                {
                    isStateORCityChanged = 'yes';
                }
            }
            else
            {
                if(stateValue != '')
                {
                    isStateORCityChanged = 'yes';
                }
                stateValue ='';
            }
            
            if(city != null)
            {
                if( city.value == initialTextForCity)
                {   
                    city.value ='';
                } 
                if(cityValue != city.value)
                {
                    isStateORCityChanged = 'yes';
                }  
                cityValue =city.value;
            }
            else
            {
                if(cityValue != '')
                {
                    isStateORCityChanged = 'yes';
                }  
                cityValue ='';          
            }
            
            countryValue = country.value;
            editcaselocation ='yes';

            if(country.value == "United States")
            {
                currentSelectedCurrency = "$";
            }
            if(country.value == "Canada")
            {
                currentSelectedCurrency = "C$";
            }
            if(country.value == "United Kingdom")
            {
                currentSelectedCurrency = "\243";
            }
            if(country.value == "Australia")
            {
                currentSelectedCurrency = "AU$";
            }
            if(country.value == "India")
            {
                currentSelectedCurrency = "Rs";
            }
            var divMoneyCounter =  document.getElementById("divCost");
            var divString  = trim(divMoneyCounter.innerHTML);
            divMoneyCounter.innerHTML = currentSelectedCurrency + divString.replace(oldCurrenySymbol ,'');

            var divCostperSec=  document.getElementById("divAveragePerSecond");
            var divString1  = trim(divCostperSec.innerHTML);
            divCostperSec.innerHTML = currentSelectedCurrency + divString1.replace(oldCurrenySymbol ,''); //divString1.replace(oldCurrenySymbol ,currentSelectedCurrency);

            var divCostperMin =  document.getElementById("divAveragePerMin");
            var divString2  = trim(divCostperMin.innerHTML);
            divCostperMin.innerHTML = currentSelectedCurrency + divString2.replace(oldCurrenySymbol ,'');//divString2.replace(oldCurrenySymbol ,currentSelectedCurrency);
            
            recomputeMoneyCounterAfterLocationChange();
            updateAccrualRates();
            if(isEditAtt == 'yes')
            {
                attEditSliderLocationChangeCase();
            }
            
            // prepare string
            var locationstring = cityValue;
            if(locationstring != '')
            {
                locationstring = locationstring + ", ";
            }

            if(stateValue != '')
            {
                locationstring = locationstring + stateValue + " - ";
            }

            if(countryValue != '')
            {
                locationstring = locationstring + countryValue;
            } 
            
            setCookie('location',locationstring,10);
            
            
            showlocationcommondisplay();
        }
    }
    else
    {
        ShowErrorMessage("divMin","Please enter any of the following countries - United States, Canada, United Kingdom, Australia, India.");
    }
}
 
// Fix to allow this to be attached to the autocomplete event - otherwise showlocation() destroys the autocomplete mid-process & breaks IE
function showloc()
{
    setTimeout("showlocation();", 10);
}

// display location in both case, edit and cancel
function showlocationcommondisplay()
{
    var divLocationDisplay = document.getElementById("divLocation");
    
    isCountryChanged = 'no';
    isStateORCityChanged = 'no'

    // prepare string
    var locationstring = cityValue;
    if(locationstring != '')
    {
        locationstring = locationstring + ", ";
    }

    if(stateValue != '')
    {
        locationstring = locationstring + stateValue + " - ";
    }

    if(countryValue != '')
    {
        locationstring = locationstring + countryValue;
    } 
    
    divLocationDisplay.innerHTML =  divDisplayLocationLeft +'<a href="#" onmouseover="doTooltip(event,\'click to edit location\')" onmouseout="hideTip()" class="locationlink">'+locationstring +'</a>'+ divDisplayLocationRight;
    var divcityref1 = document.getElementById("divCity");
    var divstateref1 = document.getElementById("divState");
    var divcountryref1 = document.getElementById("divCountry");
    var divLocationSave = document.getElementById("divLocationSave"); 
    if(divcountryref1 != null)
    {
        divcountryref1.innerHTML = littlespaceImage;
    }
    
    if(divstateref1 != null)
    {
       divstateref1.innerHTML = littlespaceImage;
    }
    
    if(divcityref1 != null)
    {
       divcityref1.innerHTML = littlespaceImage; 
    }
    
    if(divLocationSave != null)
    {
       divLocationSave.innerHTML = littlespaceImage; 
    }
    
    editcaselocation ='yes';
}


// show location in cancel case
function showlocationcancel()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    showlocationcommondisplay();  
}

// hide city while state changes
function stateFocusEvent()
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var cityDiv = document.getElementById("divCity");
    cityDiv.innerHTML = loadingImage; 
    editcaselocation ='no';     
 
}

// Get job titles
function getJobTitles()
{
    try
    {
        this.oACDS = new YAHOO.widget.DS_XHR("../complete.aspx", ["Answers","sv"]);
        this.oACDS.queryMatchContains = true;
        this.oACDS.scriptQueryParam  ="s"; 
        this.oACDS.scriptQueryAppend = "field=Job&sa=n&ss=n&min=5";    
        // Instantiate AutoComplete
        this.oAutoComp = new YAHOO.widget.AutoComplete("attinput1","attdatasource1", this.oACDS);
        this.oAutoComp.itemSelectEvent.subscribe(displayMeetingAtt);
       // oAutoComp.unmatchedItemSelectEvent.subscribe(unmatchJobTitleFound);   
        this.oAutoComp.maxResultsDisplayed = 5;
        //this.oAutoComp.typeAhead = true;
    }
    catch(exception)
    {
        if(isMenuBtnClick == 'no')
        {
            ShowErrorMessage("divMin",noConnectivityMessage); 
        }    
    }
}

// fired when found un-matched city in data source
function unmatchJobTitleFound(oSelf)
{
    var jobTitle = document.getElementById("attinput1");
    if(jobTitle != null)
    {        
        jobTitle.focus();
    }
}

function displayMeetingAttForSimiliarMeeting(jobTitle) 
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    CloseErrorMsgWnd();
    var divDisplayAtt = document.getElementById("divMeetingAttWhole");
    var txtMeetingAtt = document.getElementById("attinput1");
    if( txtMeetingAtt != null && divDisplayAtt != null)
    {
        var divId ='id ="divDisplayattDesign' + currentID + '"';
        var showdivId ='"divAttShow' + currentID + '"';
        var startingDiv = '<div id=' + showdivId + ' onclick="CloseTooltipWindow(); editAttDivCase(this); return false;" >';
        var imageId = 'id="' + currentID + '"';
        //rateRecomputeafterLocationchanged = 'no';
        
        addAttendeedes(currentID ,jobTitle, cityValue, stateValue, countryValue);
        if(jobTitleConnectivityMessage =='no')
        {        
            divDisplayAtt.innerHTML =  trim(divDisplayAtt.innerHTML) + startingDiv + divDisplayMeetingAttLeft + imageId + divDisplayMeetingAttMiddle +  divId + "     >" + attendeesJobTitle.get(currentID) + divDisplayMeetingAttRight + "</div>";
        }
    }
    currentID = currentID + 1; 
}
    

// display meeting att
function displayMeetingAtt(oSelf , elItem , oData) 
{
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();
    var divDisplayAtt = document.getElementById("divMeetingAttWhole");
    var txtMeetingAtt = document.getElementById("attinput1");
    if( txtMeetingAtt != null && divDisplayAtt != null)
    {
        var divId ='id ="divDisplayattDesign' + currentID + '"';
        var showdivId ='"divAttShow' + currentID + '"';
        var startingDiv = '<div id=' + showdivId + ' onclick="CloseTooltipWindow(); editAttDivCase(this); return false;">';
        var imageId = 'id="' + currentID + '"';
        rateRecomputeafterLocationchanged = 'no';
        addAttendeedes(currentID ,txtMeetingAtt.value, cityValue, stateValue, countryValue);
        if(jobTitleConnectivityMessage =='no')
        {        
            divDisplayAtt.innerHTML =   trim(divDisplayAtt.innerHTML) + startingDiv + divDisplayMeetingAttLeft + imageId + divDisplayMeetingAttMiddle +  divId + "     >" + attendeesJobTitle.get(currentID) + divDisplayMeetingAttRight + "</div>";
        }
    }
    currentID = currentID + 1; 
}

// open edit pop up window when click on job title insead of edit image
function editAttDivCase(source)
{
    var divId = "divAttShow" + currentattEdit;
    var showdivatt =document.getElementById(divId);        
    
    if(showdivatt != null && currentattEdit != source.id.replace("divAttShow",""))
    {   
        CloseDropdownWindow();
        popupalreadyopened = 'no';
        
        /*var divId = "divAttShow" + currentattEdit;
        var showdivatt =document.getElementById(divId);     
        if(showdivatt != null)
        {
            showdivatt.innerHTML = divAttBeforeEdit ; // set back the same innnerHTML, that was before edit
            
            isEditAtt = 'no';
            currentJobTitle ='';
            quoteValueEditCase = null;
        }*/
    }
    
    if(popupalreadyopened =='no' && isEditAtt == 'no')
    {
        var imageObjectId = source.id;
        imageObjectId = imageObjectId.replace("divAttShow","");
        var displaytext = source;
        currentattEdit = imageObjectId;
        var imgId=document.getElementById(imageObjectId);
        var oCurrentNode=document.getElementById(imageObjectId);
        var iLeft=0;
        var iTop =0;
        while(oCurrentNode.tagName!="BODY")
        {
            iTop+=oCurrentNode.offsetTop;
            iLeft+=oCurrentNode.offsetLeft;
            oCurrentNode=oCurrentNode.offsetParent;
        }
        getScrollBarOffset();
        CreateDropdownWindow(iLeft + 5 ,iTop + 5);
        setScrollBarOffSet();
    }
}

// open edit pop up window when click on edit image
function editAtt(source)
{   
    var divId = "divAttShow" + currentattEdit;
    var showdivatt =document.getElementById(divId);        
    
    if(showdivatt != null && currentattEdit != source.id)
    {   
        
        CloseDropdownWindow();
        popupalreadyopened = 'no';
        /*var divId = "divAttShow" + currentattEdit;
        var showdivatt =document.getElementById(divId);     
        if(showdivatt != null)
        {
            showdivatt.innerHTML = divAttBeforeEdit ; // set back the same innnerHTML, that was before edit
            
            isEditAtt = 'no';
            currentJobTitle ='';
            quoteValueEditCase = null;
        }*/
    }
    
    if(popupalreadyopened =='no' && isEditAtt == 'no')
    {
        var displaytext = document.getElementById("divDisplayattDesign" + source.id);
        currentattEdit = source.id;
        var oCurrentNode=source;
        var iLeft=0;
        var iTop =0;
        while(oCurrentNode.tagName!="BODY")
        {
            iTop+=oCurrentNode.offsetTop;
            iLeft+=oCurrentNode.offsetLeft;
            oCurrentNode=oCurrentNode.offsetParent;
        }
        getScrollBarOffset();
        CreateDropdownWindow(iLeft + 5 ,iTop + 5);
        setScrollBarOffSet();
    }
}

// Get access right 
function givePrivilegeAccess()
{
    try 
    {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
    }
    catch (err)
    {   
        //alert("Sorry, you can not enjoy this site because of " +err+ ". Please check your settings.");		
    }
}

// creates new object of hashtables
function createHastableObjects()
{
    if(attendeesHashtable == null)
    {
        attendeesHashtable = new Hashtable(); 
        combinedRates = new Hashtable();
        inOutHashtable = new Hashtable();
        attendeesJobTitle = new Hashtable();
        attendeesEditList = new Hashtable();
    } 
}

// start timer
function startTimer()
{
    timerID  = setTimeout("UpdateTimer()", 1000);
}

// update timer
function UpdateTimer()
{
    if(isMeetingStarted == 'yes')
    {
    // check current time
        
        var currentTime = new Date();
        
        var difference = 0;
        
        if(isTimerEdit == 'no')
        {
            if(editTimerEndDiff != null && editticksCounter != 0)
            {
                difference = Math.ceil(((currentTime.getTime()+(editticksCounter*1000)) - editTimerEndDiff.getTime())/1000);
            }
            else
            {
               difference = Math.ceil(((currentTime.getTime()+(editticksCounter*1000)) - meetingStartingTime.getTime())/1000);
            }    
        }
        else if(isTimerEdit == 'yes' && editticksCounter != 0) 
        {
           difference = Math.ceil(((currentTime.getTime()) - meetingStartingTime.getTime())/1000);
           isTimerEdit = 'no' 
           difference = editticksCounter;
           ticksPastPauseTime = 0;
           editTimerEndDiff = new Date();
        }
        else if(isTimerEdit == 'yes' && editticksCounter == 0)  
        {
            difference = 0;
            ticksCounter = 0;
            ticksPastPauseTime = 0;
            meetingStartingTime = new Date();
            isTimerEdit = 'no' 
        }
        
        ticksCounter = difference - ticksPastPauseTime;
        
        for(i=0; i < attendeesHashtable.size(); i++)
        {
            var k = attendeesHashtable.keys()[i];
            if(inOutHashtable.get(k) == "In")
            {
                attendeesHashtable.put(k, ticksCounter);
            }
        }
        if(isEditTimer == 'no')
        {
            var timeDiv  =   document.getElementById("divMin");
            if(timeDiv != null)
                timeDiv.innerHTML = formatTicksCounter(ticksCounter);
                
            var objdivTotalMeetingTime =  document.getElementById("divMin");      
            if(objdivTotalMeetingTime != null)
                objdivTotalMeetingTime.innerHTML = formatTicksCounter(ticksCounter);
        }    
        updatemoneycounter();
        timerID  = setTimeout("UpdateTimer()", 1000);
       
    } 
    if(isMeetingPause =='yes')
    {
        var currentTime1 = new Date();        
        var difference1 = Math.ceil((currentTime1.getTime() - meetingPauseTimeTime.getTime())/1000);        
        ticksCounterPauseTime = difference1;
        
        timerID  = setTimeout("UpdateTimer()", 1000);      
    }

}

// updated accrual rates
function updateAccrualRates()
{
    averagePerSecond = getAverageRatePerSeconds();
    var averagePerSecondFormated = formatCurrency(averagePerSecond) + "/sec.";
    var averagePerMinFormated = formatCurrency(averagePerSecond * 60)  + "/min.";
    var avgPerSecond = document.getElementById("divAveragePerSecond");
    var avgPerMin = document.getElementById("divAveragePerMin");
    
    if(avgPerSecond != null)
        avgPerSecond.innerHTML = averagePerSecondFormated;
        
    if(avgPerMin != null)
        avgPerMin.innerHTML = averagePerMinFormated;
}

// format time counter
function formatTicksCounter()
{
    var hrs  = 0;
    var mins = 0;
    var secs = 0;
    var ticksCnt = ticksCounter;
    var strResult = "";
    hrs = parseInt(ticksCnt / 3600);
    ticksCnt = ticksCnt % 3600;
    mins = parseInt(ticksCnt / 60);
    secs = ticksCnt % 60;
    strResult += hrs + ":";

    if(mins < 10)
    {
        strResult += "0";
    }
    strResult += mins+":";
    if(secs < 10)
    {
        strResult +="0"
    }
    strResult +=secs;
    
    /*if(hrs == 9 && mins == 59 && secs == 59)
    {
        ticksCounter =0;
        editticksCounter = 0;
    }*/
    
    if(hrs >= 10 || (hrs == 9 && mins == 59 && secs == 59))
    {
        ticksCounter =0;
        editticksCounter = 0;
        ticksPastPauseTime = 0;
        meetingStartingTime = new Date();
        isTimerEdit = 'no' 
    }
    
    currentTimer = strResult;
    return strResult;
}



function getDateForTitle(strDate)
{
    var arrDate = strDate.split(',');
    var dayTitle = (trim(arrDate[1])).substring(0,2);
    var month = (trim(arrDate[1])).substring(3,6);            
    switch(month)
    {
        case "Jan":
            month = "01";
            break;
        case "Feb":
            month = "02";
            break;        
        case "Mar":
            month = "03";
            break;        
        case "Apr":
            month = "04";
            break;        
        case "May":2
            month = "05";
            break;        
        case "Jun":
            month = "06";
            break;        
        case "Jul":
            month = "07";
            break;        
        case "Aug":
            month = "08";
            break;        
        case "Sep":
            month = "09";
            break;        
        case "Oct":
            month = "10";
            break;        
        case "Nov":
            month = "11";
            break;        
        case "Dec":
            month = "12";
            break;        
    }
    var yearTitle = (trim(arrDate[1])).substring(7,11);
    
    var yr = new String(yearTitle);
    yearTitle = yr.substring(2,4);
    
    strDate = " (" + month + "/" + dayTitle + "/" + yearTitle + ")";
    return strDate;
}

function formatDate(inputdate)
{
    if(inputdate != "")
    {   
        var date = new Date(inputdate);
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var year = date.getFullYear()
        var yr = new String(year);
        year = yr.substring(2,4);
        
        if(month < 9)
        {
            month = '0'+month
        }
        
        if(day < 9)
        {
            day = '0'+day
        }
        
        return (month + "/" + day + "/" + year);
        
    }
}

// format time counter
function formatTimerFromSecs(ticks)
{
    var hrs  = 0;
    var mins = 0;
    var secs = 0;
    var ticksCnt = ticks;
    var strResult = "";
    hrs = parseInt(ticksCnt / 3600);
    ticksCnt = ticksCnt % 3600;
    mins = parseInt(ticksCnt / 60);
    secs = parseInt(ticksCnt % 60);
    strResult += hrs + ":";

    if(mins < 10)
    {
        strResult += "0";
    }
    strResult += mins+":";
    if(secs < 10)
    {
        strResult +="0"
    }
    strResult +=secs;
    if(hrs == 9 && mins == 59 && secs == 59)
    {
        ticksCounter =0;
    }
    return strResult;
}

// updated money counter
function updatemoneycounter()
{
    moneyCounter = 0.0;
    for(i=0; i < attendeesHashtable.size(); i++)
    {
        var key = attendeesHashtable.keys()[i];
        var valTime =  attendeesHashtable.get(key);
        if(combinedRates.containsKey(key))
        {
            var valQuotes = combinedRates.get(key);
            var multiplier = getMultiplierForQuotes(valQuotes);
            if(multiplier != null && valQuotes.Median != null)
            {
                moneyCounter = moneyCounter + ((valTime * valQuotes.Median)/multiplier);
            }
        }
    }
    var divMoneyCounter =  document.getElementById("divCost");
    if(divMoneyCounter != null)
        divMoneyCounter.innerHTML = trim(formatCurrency(round(moneyCounter)));
    
    if(alarmIsSet =='yes' )
    {
        if(alarmSettingValue =="USD" && alarmAmount < round(moneyCounter))
        {
            alertAlarmPopUp();
            var divAlram= document.getElementById("divAlarm");     
            if(divAlram != null)
                divAlram.innerHTML  = divAlarmDisabled ;
                
            alarmIsSet ='no' 
        }
        
        if(alarmSettingValue =="Minutes" && (alarmTime * 60) < ticksCounter)
        {
            alertAlarmPopUp();
            var divAlram= document.getElementById("divAlarm");     
            if(divAlram != null)
                divAlram.innerHTML  = divAlarmDisabled ;
                
            alarmIsSet ='no' 
        } 
    }
}

// get average per second
function getAverageRatePerSeconds()
{
    var avg = 0.00;
    var multiplier = 0;
    //combinedRates
    for(i=0; i < attendeesHashtable.size(); i++)
    {
        var key = attendeesHashtable.keys()[i];
        if(combinedRates.containsKey(key))
        {
        var valQuotes = combinedRates.get(key);
        multiplier = getMultiplierForQuotes(valQuotes);
            if(inOutHashtable.get(key) == "In")
            {
	            avg  = avg + (valQuotes.Median / multiplier);
            }
        }
    }

    return avg;
}



function round(num)
{
    var n = Math.round(num *100);
    n = n / 100;
    return n;
}

// get multiper while calculating money counter
function getMultiplierForQuotes( pDetail )
{
    var multiplier = 0;
    switch (pDetail.Type)
    {
        case "Salary":
            multiplier = totalHoursInYear*60*60;
        break;
        case "TotalAnnualCompensation":
            multiplier = totalHoursInYear*60*60;
        break;
        case "AnnualizedBasePay":
            multiplier = totalHoursInYear*60*60;
        break;
        case "TotalCashCompensation ":
            multiplier = totalHoursInYear*60*60;
        break;
        case "Bonus":
            multiplier = totalHoursInYear*60*60;
        break;
        case "Commission":
            multiplier = totalHoursInYear*60*60;
        break;
        case "Hourly":
            multiplier = 60*60;
        break;
        case "Monthly":
            multiplier = (totalHoursInYear / 12) * 60 * 60;
        break;
    }
    return multiplier;
}

// format currency
function formatCurrency(num)
{
    if(countryValue == "India")
    {
        var start,end,len;
        var str = new String(num);
        len = str.length;
        num = num.toString().replace(/\$|\,/g,'');
    	
	    if(isNaN(num))
	    num = "0";
	    sign = (num == (num = Math.abs(num)));
    	
	    num = Math.floor(num*100+0.50000000001);
	    cents = num%100;
	    num = Math.floor(num/100).toString();
    	
	    if(cents < 10)
	    cents = "0" + cents;
    	
	    if(num.length > 3)
	    {
	        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	        {
	            if(i == 1)
	            {
	                break;
	            }
	            start = num.substring(0,num.length-(4*i+3));
	            end = num.substring(num.length-(4*i+3));
	        }
	        
	        for (var i = 0; i < Math.floor((start.length-(i))/2); i++)
	        {
	            start = start.substring(0,start.length -(3*i+2))+','+ start.substring(start.length -(3*i+2));
	        }
        	
	        num = start + "," + end ;
	        if((len % 2)== 1)
	        {
	            num = num.substring(1,num.length); 
	        }
	    }
	    return (((sign)?'':'-') + currentSelectedCurrency +  num + '.' + cents);
	}
    else
    {
        num = num.toString().replace(/\$|\,/g,'');
        if(isNaN(num))
        num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
        if(cents < 10)
        cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
        num.substring(num.length-(4*i+3));
        return (((sign)?'':'-') + currentSelectedCurrency +  num + '.' + cents);
    }
    
}

// format currency
function formatCurrencyWithoutCurrencySymbol(num)
{
    if(countryValue == "India")
    {
        var start,end,len;
        var str = new String(num);
        len = str.length;
        num = num.toString().replace(/\$|\,/g,'');
    	
	    if(isNaN(num))
	    num = "0";
	    sign = (num == (num = Math.abs(num)));
    	
	    num = Math.floor(num*100+0.50000000001);
	    cents = num%100;
	    num = Math.floor(num/100).toString();
    	
	    if(cents < 10)
	    cents = "0" + cents;
    	
	    if(num.length > 3)
	    {
	        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	        {
	            if(i == 1)
	            {
	                break;
	            }
	            start = num.substring(0,num.length-(4*i+3));
	            end = num.substring(num.length-(4*i+3));
	        }
	        
	        for (var i = 0; i < Math.floor((start.length-(i))/2); i++)
	        {
	            start = start.substring(0,start.length -(3*i+2))+','+ start.substring(start.length -(3*i+2));
	        }
        	
	        num = start + "," + end ;
	        if((len % 2)== 1)
	        {
	            num = num.substring(1,num.length); 
	        }
	    }
	    return (((sign)?'':'-') + num + '.' + cents);
	}
    else
    {
        num = num.toString().replace(/\$|\,/g,'');
        if(isNaN(num))
        num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
        if(cents < 10)
        cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
        num.substring(num.length-(4*i+3));
        return (((sign)?'':'-') + num + '.' + cents);
    }
    
}

// format currency in slider case
function formatCurrencySliderCase(num)
{
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents < 10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));

    if(isAnnualSalaryVisible == 'yes')
    {
        return (((sign)?'':'-')  + num) ;
    }
    return (((sign)?'':'-')  + num + '.' + cents);
}

//// change table color when mouse over
function changeColorOnMouseOver(source)
{
    source.style.backgroundColor = "#e0e0e0";
}

// change table color when mouse out
function changeColorOnMouseOut(source)
{
    source.style.backgroundColor = "#FFFFFF";
}

function stopChangeNewMeetingImage(source)
{
    source.src = "image/stopStartNewmeetingRoll.gif";
}

function stopChangeNewMeetingOut(source)
{
    source.src = "image/stopStartNewmeetingNormal.gif"; 
}

function stopChangeReturnMeetingImage(source)
{
    source.src = "image/stopReturntomeetingRoll.gif";
}

function stopChangeReturnMeetingOut(source)
{
    source.src = "image/stopReturntomeetingNormal.gif"; 
}

function stopChangeEmailDataImage(source)
{
    source.src = "image/stopEmaildataRoll.gif";
}

function changeViewHistoryMeetingImage(source)
{
    source.src = "image/ViewMeetingHistoryRollover.gif";
}

function stopChangeEmailDataOut(source)
{
    source.src = "image/stopEmaildataNormal.gif"; 
}

function changeViewHistoryMeetingOut(source)
{
    source.src = "image/ViewMeetingHistory.gif"; 
}

function stopChangeExportDataImage(source)
{
    source.src = "image/stopExportdataRoll.gif";
}

function stopCompareSalaryImage(source)
{
    source.src = "image/stopComparesalaryRollover.gif";
}



function stopChangeExportDataOut(source)
{
    source.src = "image/stopExportdataNormal.gif"; 
}

function stopCompareSalaryOut(source)
{
    source.src = "image/stopComparesalary.gif"; 
}



// recompute money counter after location changed
function recomputeMoneyCounterAfterLocationChange()
{
    if(isCountryChanged == 'yes')
    {
        isCountryChangesTemp = isCountryChanged;
        hastableCnt = attendeesJobTitle.size();
        jobTitleWithout = "";
        
        for(i=0; i< attendeesJobTitle.size(); i++)
        {
            var keyString = attendeesHashtable.keys()[i];
            var jobTitle = attendeesJobTitle.get(keyString);
            if(jobTitle != null)
            {
                rateRecomputeafterLocationchanged = 'yes';
                addAttendeedes(keyString, jobTitle, cityValue , stateValue, countryValue);
            }
            
        }
        updateAccrualRates();
        attendeesEditList.clear(); // clear all items from edit list
    }
    else if(isStateORCityChanged == 'yes')
    {
        for(i=0; i< attendeesJobTitle.size(); i++)
        {
            var keyString = attendeesHashtable.keys()[i];
            var jobTitle = attendeesJobTitle.get(keyString);
            if(! attendeesEditList.containsKey(keyString))
            { 
                rateRecomputeafterLocationchanged = 'yes';
                addAttendeedes(keyString, jobTitle, cityValue , stateValue, countryValue);
            }
        }
    }

}

function editTimer(source)
{
    if(attendeesHashtable.size() > 1)
    { 
        var oCurrentNode=source;
        var iLeft=0;
        var iTop =0;
        while(oCurrentNode.tagName!="BODY")
        {
            iTop+=oCurrentNode.offsetTop;
            iLeft+=oCurrentNode.offsetLeft;
            oCurrentNode=oCurrentNode.offsetParent;
        }
        editTimerStartDiff = new Date();
        CreateEditTimerWindow(iLeft + 5 ,iTop + 5);
    }
}

function editTimerMessageOkClick()
{
    isEditTimerMsgShow = 'no';
    var newTimer = "";
    editticksCounter = 0;
    ticksPastPauseTime = 0;
    objtxtEditTimer = document.getElementById("txtEditTimer");
    if(objtxtEditTimer != null)
    {
        if(validateTime(objtxtEditTimer.value) == 1)
        {
            newTimer = objtxtEditTimer.value 
            if(newTimer.indexOf(':') == -1)
            {
                editticksCounter = editticksCounter + parseInt(parseVal(newTimer)*60)
            }
            else
            {
                var arr1 = newTimer.split(':');
                
                if(arr1.length == 2)
                {
                    editticksCounter = editticksCounter + parseInt(parseVal(arr1[0])*3600) 
                    editticksCounter = editticksCounter + parseInt(parseVal(arr1[1])*60)  
                }
                else
                {
                    if(arr1[0] != null && arr1[0] != 0)
                    {
                        editticksCounter = editticksCounter + parseInt(parseVal(arr1[0])*3600)    
                    }
                    if(arr1[1] != null && arr1[1] != 0)
                    {
                        editticksCounter = editticksCounter + parseInt(parseVal(arr1[1])*60)    
                    }
                    
                    if(arr1[2] != null && arr1[2] != 0)
                    {
                        editticksCounter = editticksCounter + parseInt(parseVal(arr1[2]));    
                    }
                }    
            }    
           
            isTimerEdit = 'yes' 
            
            for(i=0; i < attendeesHashtable.size(); i++)
            {
                var k = attendeesHashtable.keys()[i];
                if(inOutHashtable.get(k) == "In")
                {
                    attendeesHashtable.put(k, editticksCounter);
                }
            }
            
            var timeDiv  =   document.getElementById("divMin");
            timeDiv.innerHTML = formatTimerFromSecs(editticksCounter);
            updatemoneycounter();
            
            CloseEditTimerWindow();
        }
        else
        {
            var objError = document.getElementById("trTimerError");
            if(objError != null)
            {
                objError.style.display='';
            }
        }   
    }
}

function parseVal(val)
{
    if(val.length > 1)
    {
       while (val.charAt(0) == '0')
          val = val.substring(1, val.length);
    }
   return val;
}



function editTimerSaveClick()
{
    var newTimer = "";
    
    //editticksCounter = 0;
    //ticksPastPauseTime = 0;
    
    objtxtEditTimer = document.getElementById("txtEditTimer");
    
    if(objtxtEditTimer != null)
    {
        if(validateTime(objtxtEditTimer.value) == 1)
        {
            if(isEditTimerMsgShow == 'yes')
            {
                var objtblEditTimerMessage = document.getElementById("tblEditTimerMessage");
                var objtblEditTimer = document.getElementById("tblEditTimer");
                if(objtblEditTimer != null)
                {
                    objtblEditTimer.style.display = 'none';
                }

                if(objtblEditTimerMessage != null)
                {
                    objtblEditTimerMessage.style.display = '';
                }
            }
            else
            {
                editTimerMessageOkClick();
            }
        
        }
        else
        {
            var objError = document.getElementById("trTimerError");
            if(objError != null)
            {
                objError.style.display='';
            }
        } 
    }   
}

function showRegisterUser()
{
    var objdivUserLogin = document.getElementById("divUserLogin");
    if(objdivUserLogin != null)
    {
        objdivUserLogin.innerHTML = innerHTMLRegisterUser;
    }
}

function showLoginUser()
{
    var objdivUserLogin = document.getElementById("divUserLogin");
    if(objdivUserLogin != null)
    {
        objdivUserLogin.innerHTML = innerHTMLdivLoginUser;
    }
}

function trim(str)
{
    return str.replace(/^\s*|\s*$/g,'');
}

function CloseMeetingHistory()
{
    //changeWidth('menu');
    divMeetingCompletionMenu = divMeetingCompletionMenu.replace("stopEmaildataRoll.gif","stopEmaildataNormal.gif");
    divMeetingCompletionMenu = divMeetingCompletionMenu.replace("stopComparesalaryRollover.gif","stopComparesalary.gif");
    divMeetingCompletionMenu = divMeetingCompletionMenu.replace("stopStartNewmeetingRoll.gif","stopStartNewmeetingNormal.gif");
    divMeetingCompletionMenu = divMeetingCompletionMenu.replace("ViewMeetingHistoryRollover.gif","ViewMeetingHistory.gif");
    divMeetingCompletionMenu = divMeetingCompletionMenu.replace("stopReturntomeetingRoll.gif","stopReturntomeetingNormal.gif");
        
    var divWholeMeeting= document.getElementById("divWholeMeetingDisplay"); 
    divWholeMeeting.innerHTML = divMeetingCompletionMenu;
}

function showMeetingHistory()
{
    if(loggedinUsrEmail != "" && loggedinUsrPwd != "")
    {
        // show loading dots.
        showloadingdots('yes');
        createXmlHttp();
        loadXMLDoc(proxyUrl+"?Action=GetMeetingHistory&address=" + escape(loggedinUsrEmail) + "&password=" + escape(loggedinUsrPwd) + "&offset=0&limit=10" ,"GetMeetingHistory");
    }   
}


function validateUser()
{
    var objtxtEmail = document.getElementById("txtEmailId");
    var objtxtPassword = document.getElementById("txtPassword");
    
    if(objtxtEmail != null && objtxtPassword != null && objtxtEmail.value != "" && objtxtPassword.value != "")
    {
        if (emailfilter.test(objtxtEmail.value))
        {
            var encodedPassword = Base64.encode(trim(objtxtPassword.value));
            
            // show loading dots.
            showloadingdots('yes');
    
            createXmlHttp();
            loadXMLDoc(proxyUrl+"?Action=GetInfo&address=" + escape(trim(objtxtEmail.value)) + "&password=" + escape(encodedPassword),"GetInfo");
        }    
        else
        {
            ShowErrorMessage("txtEmailId","Email address is not valid, please correct it and try it again.");
        }    
    }  
    else
    {
        if(objtxtEmail.value == "")
        {
            ShowErrorMessage('txtEmailId',"Enter your email address.");
        }    
        else if(objtxtPassword.value == "")
        {
            ShowErrorMessage('txtEmailId',"Enter a password.");
        }
    } 
}

function registerUser()
{   
    var objtxtEmail = document.getElementById("txtEmailId");
    var objtxtPassword = document.getElementById("txtChoosePassword");
    var objtxtConfirmPassword = document.getElementById("txtConfirmPassword");
    var objchkNewLetter = document.getElementById("chkNewsLetter");
    
    if(objtxtEmail != null && objtxtPassword != null && objtxtConfirmPassword != null && objchkNewLetter != null && objtxtEmail.value != "" && objtxtPassword.value != "" && objtxtConfirmPassword.value != "")
    {
        if (emailfilter.test(objtxtEmail.value))
        {
            if((objtxtPassword.value).toLowerCase() == (objtxtConfirmPassword.value).toLowerCase())
            {
                var isNewsLetter='false';
                if(objchkNewLetter.checked)
                    isNewsLetter='true';
                
                var encodedPassword = Base64.encode(trim(objtxtPassword.value));
                
                // show loading dots.
                showloadingdots('yes');
                
                createXmlHttp();
                
                loadXMLDoc(proxyUrl+"?Action=Register&address=" + escape(trim(objtxtEmail.value)) + "&password=" + escape(encodedPassword) + "&GetNewsletter="+isNewsLetter,"Register");
            }    
            else
            {
                ShowErrorMessage("txtEmailId","Passwords do not match, please enter them again.");
            }
        }   
        else
        {
            ShowErrorMessage("txtEmailId","Email address is not valid, please correct it and try it again.");
        }
    }
    else
    {
        if(objtxtEmail.value == "")
        {
            ShowErrorMessage("txtEmailId","Enter your email address.");
        }    
        else 
        {
            if(objtxtPassword.value == "")
            {
                ShowErrorMessage("txtEmailId","Enter choose password.");
            }
            else if(objtxtConfirmPassword == "")
            {
                ShowErrorMessage("txtEmailId","Enter confirm password.");
            }
        }
    }
}


function createXmlHttp()
{
    xmlhttp=null
    // code for Mozilla, etc.
    if(window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest()
    }
    // code for IE
    if(xmlhttp == null)
    {
        if (window.ActiveXObject)
        {
            //xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
            var progids = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP","Msxml2.XMLHTTP" ,"Microsoft.XMLHTTP"];
	        var o;
	        for(var i = 0; i < progids.length; i++)
	        {
		        try
		        {
			        xmlhttp = new ActiveXObject(progids[i]);
			        if(xmlhttp != null)
			        {
			           // alert(xmlhttp);
			            break;
			        }
		        }
		        catch (ex) {};
	        }
	        //alert("out");
        }
    }
}

function loadXMLDoc(url,from)
{
    if (xmlhttp!=null)
    {
        if(from == "Login")
        {
            xmlhttp.onreadystatechange=getLoginResult;
        }
        else if(from == "Register")
        {
            xmlhttp.onreadystatechange=getRegisterResult;
        }
        else if(from == "GetMeetingHistory")
        {
            xmlhttp.onreadystatechange=getMeetingHistoryResult;
        }
        else if(from == "ExportToCSV")
        {
            xmlhttp.onreadystatechange=getExportToCSVResult;
        }
        else if(from == "DeleteMeeting")
        {
            xmlhttp.onreadystatechange=getDeleteMeetingResult;
        }
        else if(from == "GetInfo")
        {
            xmlhttp.onreadystatechange=getInfoResult;
        }
        else if(from == "GetInfoAutoLogin")
        {
            xmlhttp.onreadystatechange=getInfoAutoLoginResult;
        }
        
        if (url.indexOf('?') != -1)
        {
            url = url + "&random=" + generateGUID();
        }
        xmlhttp.open("GET",url,true)
        xmlhttp.send(null)
    }
    else
    {
        //alert("Your browser does not support XMLHTTP.")
    }
}

function getDeleteMeetingResult()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        if (xmlhttp.status==200)
        {
            var resulttext = xmlhttp.responseText;
            var response = resulttext.parseJSON();
            
            if(response.Message != null)
            {
                showloadingdots('no');  
                ShowErrorMessage("loadingdotsId",noConnectivityMessage); 
            }
            else if (response.Success == true)
            {   
                showloadingdots('no');  
                //ShowErrorMessage("loadingdotsId","Meeting deleted successfully."); 
                    
                showMeetingHistory(); 
                
            }
         }
    }         
}

function getLoginResult()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        if (xmlhttp.status==200)
        {
            var resulttext = xmlhttp.responseText;
            var response = resulttext.parseJSON();
            
            if(response.NumberOfMeetings == null && response.RecentJobTitles == null && response.LoggedIn == null && response.Message != null)
            {
                showloadingdots('no');  
                ShowErrorMessage("divMin",noConnectivityMessage);
            }
            else if (response.Success == true)
            {
                var objtxtEmail = document.getElementById("txtEmailId");
                var objtxtPassword = document.getElementById("txtPassword");
                
                isLoggedIn = 'yes';
                if(objtxtEmail != null)
                {
                    loggedinUsrEmail = objtxtEmail.value
                    loggedinUsrPwd = Base64.encode(trim(objtxtPassword.value));
                    
                    setCookie('loggedInEmail',loggedinUsrEmail,10);
                    setCookie('loggedInPassword',loggedinUsrPwd,10);
                }
                
                if(attendeesHashtable.size() > 1 && currentTimer != "" && isMenuBtnClick == 'no')
                {
                    // saves the meeting 
                    saveMeeting();
                }
                else
                {
                    showloadingdots('no');         
                }
                
                isMenuBtnClick = 'no';
                showMeetingCompletionMenu();                
            }
            else 
            {
                showloadingdots('no');  
            }
        }
        else
        {
            showloadingdots('no');  
        }
    }
}

function getRegisterResult()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        // if "OK"
        if (xmlhttp.status==200)
        {
            // ...some code here...
            var resulttext = xmlhttp.responseText;
            var response = resulttext.parseJSON();
            
            if(response.NumberOfMeetings == null && response.RecentJobTitles == null && response.LoggedIn == null && response.Message != null)
            {
                showloadingdots('no');  
                ShowErrorMessage("divMin",registerFailedMessage);
            }
            else 
            {
                if(response.Success == true)//if(response.Success == true && response.AlreadyExists == false)
                {
                    // hide loading dots.
                    showloadingdots('no');
        
                    recentJobTitles = response.RecentJobTitles.items;
                    setCookie('fiveRecentAttendees',response.RecentJobTitles.items.toJSONString(),10);
                    
                    var objtxtEmail = document.getElementById("txtEmailId");
                    var objtxtPassword = document.getElementById("txtChoosePassword");
                    isLoggedIn = 'yes';
                    if(objtxtEmail != null)
                    {
                        loggedinUsrEmail = objtxtEmail.value
                        loggedinUsrPwd = Base64.encode(trim(objtxtPassword.value));
                        
                        setCookie('loggedInEmail',loggedinUsrEmail,10);
                        setCookie('loggedInPassword',loggedinUsrPwd,10);
                    }
                    if(attendeesHashtable.size() > 1 && currentTimer != "")
                    {
                        // saves the meeting 
                        saveMeeting();
                    }
                    else
                    {
                        showloadingdots('no');         
                    }
                    
                    showMeetingCompletionMenu(); 
                }
                else
                {
                    // hide loading dots.
                    showloadingdots('no');
                    ShowErrorMessage("divMin",registerFailedMessage);
                }
            }        
        }
        else
        {
            // hide loading dots.
            showloadingdots('no');
            ShowErrorMessage("divMin",noConnectivityMessage);
        }
    }
}

function getMeetingHistoryResult()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        if (xmlhttp.status==200)
        {
            var resulttext = xmlhttp.responseText;
            
            var response = resulttext.parseJSON();
            
            if(response.Message != null && response.Result == null)
            {
                showloadingdots('no');  
            
                ShowErrorMessage("divMin",noConnectivityMessage);
            }
            else if (response.Success == true)
            {
                //changeWidth('ViewHistory');
                showloadingdots('no');
                
                historymeetingresponse =  response;
                var divWholeMeeting= document.getElementById("divWholeMeetingDisplay"); 
                if(isDeleteMeeting == 'no')
                {
                    divMeetingCompletionMenu = trim(divWholeMeeting.innerHTML);
                }  
                isDeleteMeeting = 'no';   
                divWholeMeeting.innerHTML = trim(innerHTMLMeetingHistory);     
                
                var objdivmeetinghistory = document.getElementById("divmeetinghistory");
                var objdivmeetinghistorytotal = document.getElementById("divmeetinghistorytotal");
                
                var totalmeetingcost = 0;
                var totalcostperseconds = 0;
                var totalmeetingminutes = 0;
                var meetingCurrency = "";
                var showSummary='yes';
                
                /*
                var totalmeetingCnt=0;
                totalmeetingCnt=response.Result.items.length
                if(totalNoOfMeetings > 10)
                {
                    totalmeetingCnt = 10;
                }*/
                
                if(objdivmeetinghistory != null)
                {
                    var strmeetinghistory = "";
                    strmeetinghistory = strmeetinghistory + '<table cellpadding=0 cellspacing=0 style="width:100%;">';
                    var i=0;
                    for(i=0;i<response.Result.items.length;i++)
                    {
                        var meetingtitle = response.Result.items[i].Title;
                        meetingtitle = meetingtitle.replace(response.Result.items[i].Guid,"");
                        
                        totalmeetingcost = totalmeetingcost + eval(response.Result.items[i].TotalCost);   
                        totalcostperseconds = totalcostperseconds + eval(response.Result.items[i].CostPerSecond);      
                        
                        totalmeetingminutes = totalmeetingminutes + parseInt(response.Result.items[i].LengthSeconds);
                        
                        if(meetingCurrency != "")
                        {
                            if(meetingCurrency != trim(response.Result.items[i].CurrencySymbol))
                            {
                                showSummary = 'no';
                            }
                        }
                        meetingCurrency = response.Result.items[i].CurrencySymbol;
                        //meetingCurrency = trim(meetingCurrency.replace("{#}",""));
                        
                        strmeetinghistory = strmeetinghistory + '<tr><td class="meetingheading">'+meetingtitle+''+getDateForTitle(response.Result.items[i].Date)+'</td></tr>';
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext">Number of attendess: '+response.Result.items[i].NumberOfAttendees+'</td></tr>'
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext">Meeting length: '+formatTimerFromSecs(response.Result.items[i].LengthSeconds)+'</td></tr>' 
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext">Cost per second: '+concatCurrencySymbol(meetingCurrency,response.Result.items[i].CostPerSecond)+'</td></tr>'
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext">Total cost of meeting: '+ concatCurrencySymbol(meetingCurrency,formatCurrencyOnCountry(response.Result.items[i].TotalCost,response.Result.items[i].Country))+'</td></tr>'
                        strmeetinghistory = strmeetinghistory + '<tr><td style="height:2px;"></td></tr>' 
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext"><div id="divparticipants'+(i+1)+'" style="display:none;"><table cellpadding=0 cellspacing=0 width="100%">'
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext">Participants: </td></tr>'
                        strmeetinghistory = strmeetinghistory + '<tr><td style="height:4px;"></td></tr>' 
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext" id="Participants"></td></tr>'  
                        var j=0;
                        for(j=0;j<response.Result.items[i].Attendees.items.length;j++)// for attendees
                        {
                            strmeetinghistory = strmeetinghistory + '<tr><td><table cellpadding="0" cellspacing="0" border="0"><tr><td style="width:8px;"><img src="image/dot.png" style="vertical-align:middle;width:4px;height:4px;"></td><td style="vertical-align:top;">'+response.Result.items[i].Attendees.items[j].Job+'</td></tr><tr><td colspan="2" style="height:3px;"></td></tr></table></td></tr>'
                        }
                        strmeetinghistory = strmeetinghistory + '</table></td></tr>' 
                        strmeetinghistory = strmeetinghistory + '<tr><td style="height:3px;"></td></tr>'  
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext"><a href="#" class="blueboldlink" onclick="showHideParticipants('+i+',this);">View participants</a></td></tr>'  
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext" style="padding-top:2px;"><a href="#" class="blueboldlink" onclick="startSimilarMeeting('+i+',this);">Start new meeting like this one</a></td></tr>'  
                        strmeetinghistory = strmeetinghistory + '<tr><td class="historytext" style="padding-top:2px;"><a href="#" class="blueboldlink" onclick="deleteMeeting(\''+response.Result.items[i].Guid+'\');">Delete this meeting</a></td></tr>'  
                        strmeetinghistory = strmeetinghistory + '<tr><td style="height:10px;"></td></tr>' 
                    }
                    strmeetinghistory = strmeetinghistory + '</table>';
                    objdivmeetinghistory.innerHTML = trim(strmeetinghistory);
                } 
                
                if(objdivmeetinghistorytotal != null && response.Result.items.length != 0)
                {
                    
                    /*if(totalNoOfMeetings > 10)
                    {
                        var i=0;
                        for(i=0;i<totalNoOfMeetings;i++)
                        {
                            totalmeetingcost = totalmeetingcost + eval(response.Result.items[i].TotalCost);   
                            totalcostperseconds = totalcostperseconds + eval(response.Result.items[i].CostPerSecond);      
                            totalmeetingminutes = totalmeetingminutes + parseInt(response.Result.items[i].LengthSeconds);
                        }
                    }*/
                    
                    totalcostperseconds = (totalcostperseconds / response.Result.items.length).toFixed(2);
                    totalmeetingminutes = formatTimerFromSecs(totalmeetingminutes);
                    totalmeetingcost = totalmeetingcost.toFixed(2);
                    
                    
                    var strtotalmeetinghistory =  '<table cellpadding=0 cellspacing=0 width="100%" style="vertical-align:top;">' +
                                                    '<tr>' +             
                                                        '<td  style="vertical-align:top;">' +             
                                                            '<table cellpadding=0 cellspacing=0 width="100%"  style="vertical-align:top;">' +             
                                                                '<tr>' +              
                                                                    '<td class="meetingheading" id="totalmeeting">Last '+response.Result.items.length+' meeting(s)</td>' +             
                                                                '</tr>' + 
                                                                '<tr>' +  
                                                                    '<td class="meetingheading" id="totalmeetingmin">Last '+response.Result.items.length+' meeting(s) minutes total: '+totalmeetingminutes+'</td>' +  
                                                                '</tr>';  
                                                                if(showSummary == 'yes')
                                                                {
                                                                    strtotalmeetinghistory = strtotalmeetinghistory + '<tr>' + 
                                                                        '<td class="meetingheading" id="totalmeetingsec">Average cost per second: '+concatCurrencySymbol(meetingCurrency,totalcostperseconds)+'</td>' +
                                                                    '</tr>' + 
                                                                    '<tr>' + 
                                                                        '<td class="meetingheading" id="granttotalmeetingcost">Last '+response.Result.items.length+' total cost: '+concatCurrencySymbol(meetingCurrency,totalmeetingcost)+'</td>'  + 
                                                                    '</tr>';               
                                                                }
                                                            strtotalmeetinghistory = strtotalmeetinghistory + '</table>' +             
                                                        '</td>' +
                                                    '</tr>' +   
                                                    '<tr><td style="height:5px;"></td></tr>' +    
                                                    '<tr><td style="height:10px;"><img alt="" src="image/linespacerhistory.gif" /></td></tr>' +    
                                                    '<tr><td style="height:5px;"></td></tr>' +    
                                                    '<tr>' +   
                                                        '<td style="padding-left:5px;"><img src="image/return_toMenu.gif" style="width:160px;cursor:pointer;" alt="" onmouseover="returnToMenuOnOver(this);"  onmouseout="returnToMenuOnOut(this);" onclick="CloseMeetingHistory();"></td>' +    
                                                    '</tr>' +   
                                                    '<tr><td style="height:5px;"></td></tr>' +    
                                                    '<tr><td style="height:10px;"><img alt="" src="image/linespacerhistory.gif" /></td></tr>' +    
                                                    '<tr><td style="height:5px;"></td></tr>' +    
                                                    '<tr>' +   
                                                        '<td  style="padding-left:5px;"><img src="image/export.gif" style="width:191px;cursor:pointer;"  alt="" onmouseover="exportMenuOnOver(this);"  onmouseout="exportMenuOnOut(this);" onclick="exportToCSV();"></td>' +    
                                                    '</tr>' +   
                                                    
                                                    '<tr>' + 
                                                        '<td style="height:10px;"></td>' +
                                                    '</tr>' +               
                                                '</table>'  
                    objdivmeetinghistorytotal.innerHTML =  strtotalmeetinghistory;                                   
                }
            }
            else 
            {
                showloadingdots('no');
                // TODO: handle auth failure!
                ShowErrorMessage("divMin",noConnectivityMessage);
            }
        }
        else
        {
            // hide loading dots
            showloadingdots('no');
            ShowErrorMessage("divMin",noConnectivityMessage);
        }
    }
}


// format currency depend upon country value.
function formatCurrencyOnCountry(num,countryval)
{
    if(countryval == "India")
    {
        var start,end,len;
        var str = new String(num);
        len = str.length;
        num = num.toString().replace(/\$|\,/g,'');
    	
	    if(isNaN(num))
	    num = "0";
	    sign = (num == (num = Math.abs(num)));
    	
	    num = Math.floor(num*100+0.50000000001);
	    cents = num%100;
	    num = Math.floor(num/100).toString();
    	
	    if(cents < 10)
	    cents = "0" + cents;
    	
	    if(num.length > 3)
	    {
	        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	        {
	            if(i == 1)
	            {
	                break;
	            }
	            start = num.substring(0,num.length-(4*i+3));
	            end = num.substring(num.length-(4*i+3));
	        }
	        
	        for (var i = 0; i < Math.floor((start.length-(i))/2); i++)
	        {
	            start = start.substring(0,start.length -(3*i+2))+','+ start.substring(start.length -(3*i+2));
	        }
        	
	        num = start + "," + end ;
	        if((len % 2)== 1)
	        {
	            num = num.substring(1,num.length); 
	        }
	    }
	    return (((sign)?'':'-') + num + '.' + cents);
	}
    else
    {
        num = num.toString().replace(/\$|\,/g,'');
        if(isNaN(num))
        num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
        if(cents < 10)
        cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
        num.substring(num.length-(4*i+3));
        return (((sign)?'':'-') + num + '.' + cents);
    }
    
}

function concatCurrencySymbol(symbol,amt)
{
    symbol = symbol.replace('{#}',amt);
    return symbol;
}


function showloadingdots(inputflag)
{
    if(inputflag == "yes")// show loading dots
    {
        var objshowMessagId = document.getElementById("showMessagId");
        if(objshowMessagId != null)
        {
            objshowMessagId.style.display = 'none';
        }
        
        var objloadingdots = document.getElementById("loadingdotsId");
        if(objloadingdots != null)
        {
            objloadingdots.style.display = '';
        }
    }
    else if(inputflag == "no")// hide loading dots
    {
        var objloadingdots = document.getElementById("loadingdotsId");
        if(objloadingdots != null)
        {
            objloadingdots.style.display = 'none';
        }
    }
}

function deleteMeeting(guid)
{
    if(loggedinUsrEmail != "" && loggedinUsrPwd != "")
    {
       
        var url = proxyUrl+"?Action=DeleteMeeting&address=" + escape(loggedinUsrEmail) + "&password=" + escape(loggedinUsrPwd)+"&GUID="+escape(guid);
        isDeleteMeeting = 'yes';
        showloadingdots('yes');
        createXmlHttp();
        loadXMLDoc(url, "DeleteMeeting");
    }    
}

function startSimilarMeeting(intVal)
{
    //changeWidth('startsimiliarmeeting'); 
    startNewMeeting();
    var j=0;
    var meetingtitle = "";
    CurrentID = 1;
    
    var oldCurrencySymbol1 = currentSelectedCurrency;
   
    stateValue = historymeetingresponse.Result.items[intVal].State;
    cityValue = historymeetingresponse.Result.items[intVal].City;
    countryValue = historymeetingresponse.Result.items[intVal].Country;
    currentSelectedCurrency = historymeetingresponse.Result.items[intVal].CurrencySymbol;
    currentSelectedCurrency = currentSelectedCurrency.replace('{#}','');
    
     var oldCurrenySymbol = currentSelectedCurrency;    

    var divMoneyCounter =  document.getElementById("divCost");
    var divString  = trim(divMoneyCounter.innerHTML);
    divString = divString.replace(oldCurrencySymbol1 ,'');
    divMoneyCounter.innerHTML = currentSelectedCurrency + divString.replace(oldCurrenySymbol ,'');


    var divCostperSec=  document.getElementById("divAveragePerSecond");
    var divString1  = trim(divCostperSec.innerHTML);
    divString1 = divString1.replace(oldCurrencySymbol1 ,'');
    divCostperSec.innerHTML = currentSelectedCurrency + divString1.replace(oldCurrenySymbol ,'');//divString1.replace(oldCurrenySymbol ,currentSelectedCurrency);

    var divCostperMin =  document.getElementById("divAveragePerMin");
    var divString2  = trim(divCostperMin.innerHTML);
    divString2 = divString2.replace(oldCurrencySymbol1 ,'');
    divCostperMin.innerHTML = currentSelectedCurrency + divString2.replace(oldCurrenySymbol ,'');//divString2.replace(oldCurrenySymbol ,currentSelectedCurrency);

    var objheading = document.getElementById("tdHeading");

    if(objheading != null )
    {
        meetingHeading = "My Meeting";
        objheading.innerHTML  = '<div id="divDisplayMeetingHeading" onclick="showInputHeading();" class="headingDiv" onmouseover="changeColorOnMouseOver(this);"  onmouseout="changeColorOnMouseOut(this);" >' +  meetingHeading + '</div>'  ;     
    }
    
    if(stateValue == "WA")
    {
        stateValue = "Washington";
    }
    
    showlocationcommondisplay();
    rateRecomputeafterLocationchanged = 'yes'
    
    for(j=0;j<historymeetingresponse.Result.items[intVal].Attendees.items.length;j++)// for attendees
    {
        var jobid = historymeetingresponse.Result.items[intVal].Attendees.items[j].Id;
        var jobtitle = historymeetingresponse.Result.items[intVal].Attendees.items[j].Job;
        
        if(jobtitle == "Software Engineer")
        {
            jobtitle = "Software Engineer / Developer / Programmer";
        }
        else if(jobtitle == "QA Lead")
        {
            jobtitle = "Test / Quality Assurance (QA) Engineer (Computer Software)";
        }    
        
        displayMeetingAttForSimiliarMeeting(jobtitle)     
    }
}

function showHideParticipants(intval,thisobj)
{
    intval = intval + 1;
    if(thisobj.innerHTML == "Hide participants")
    {
        var objp = document.getElementById("divparticipants"+intval);
        if(objp != null)
        {
            objp.style.display = 'none';
            thisobj.innerHTML = "View participants"
        }
    }
    else if(thisobj.innerHTML == "View participants")
    {
        var objp = document.getElementById("divparticipants"+intval);
        if(objp != null)
        {
            objp.style.display = '';
            thisobj.innerHTML = "Hide participants"
        }
    }
}

function getMinutes(meetingTime)
{
    var timeval = 0;
    var arr1 = meetingTime.split(':');
    if(arr1 != null && arr1.length != 0)
    {
        if(arr1[0] != null)
        {
            timeval = timeval + parseInt(arr1[0]*3600)    
        }
        if(arr1[1] != null)
        {
            timeval = timeval + parseInt(arr1[1]*60)    
        }
        
        if(arr1[2] != null)
        {
            timeval = timeval + parseInt(arr1[2]);    
        }
    } 
    timeval = eval(timeval/60);
    return timeval;    
}

function getSeconds(meetingTime)
{
    var timeval = 0;
    var arr1 = meetingTime.split(':');
    if(arr1 != null && arr1.length != 0)
    {
        if(arr1[0] != null)
        {
            timeval = timeval + parseInt(arr1[0]*3600)    
        }
        if(arr1[1] != null)
        {
            timeval = timeval + parseInt(arr1[1]*60)    
        }
        
        if(arr1[2] != null)
        {
            timeval = timeval + parseInt(arr1[2]);    
        }
    } 
    return timeval;    
}


function isNumeric(str)
{
	var alphaExp = /^[0-9]+$/;
	if(str.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}


function validateTime(time)
{
    if(time.indexOf(':') == -1)
    {
        if(isNumeric(time))
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        var arr = time.split(":");
        if(arr.length == 3)
        {
            var hr=0,mn=0,sc=0;
            
            if(!isNumeric(arr[0]))
            {
                return 0;
            }
            else if(!isNumeric(arr[1]))
            {
                return 0;
            }
            else if(!isNumeric(arr[2]))
            {
                return 0;
            }
            
            hr = parseInt(arr[0]);
            mn = parseInt(arr[1]);
            sc = parseInt(arr[2]);                                
            
            switch(arr.length)
            {
                    case 1 :    if(hr > 599)
                                {
                                    return 0;
                                }
                                else
                                {
                                    if(hr > 0)
                                        return 1;
                                    else
                                        return 0;
                                }
                            break;
                            
                case 2 :        if(hr < 10 && mn < 60)
                                {
                                    return 1;
                                }
                                else
                                    return 0;
                            
                            break;
                        
                case 3 :        if(hr < 10 && mn < 60 && sc < 60)
                                {
                                    return 1;
                                }
                                else
                                    return 0;
                            break;
                            
                default : return 0;
            }    
        }
        else
        {
            return 0;
        }   
    }
}

var MAX_DUMP_DEPTH = 10;

function dumpObj(obj, name, indent, depth) {
      if (depth > MAX_DUMP_DEPTH) {
             return indent + name + ": <Maximum Depth Reached>\n";
      }
      if (typeof obj == "object") {
             var child = null;
             var output = indent + name + "\n";
             indent += "\t";
             for (var item in obj)
             {
                   try {
                          child = obj[item];
                   } catch (e) {
                          child = "<Unable to Evaluate>";
                   }
                   if (typeof child == "function")
                   {
                   } else if (typeof child == "object") {
                          output += dumpObj(child, item, indent, depth + 1);
                   } else {
                          output += indent + item + ": " + child + "\n";
                   }
             }
             return output;
      } else {
             return obj;
      }
}

function getExportToCSVResult()
{
    // if xmlhttp shows "loaded"
    try
    {
        if (xmlhttp.readyState==4)
        {
            if (xmlhttp.status==200)
            {
                var resulttext = xmlhttp.responseText;
                var response = resulttext.parseJSON();
            }   
        }     
    }
    catch(exception)
    {
        
    }   
}

function addElementToXmlDoc(xmldocobj,objP,elementName,elementText)
{
    var newel = null;
    var newtext = null;
    
    newel=xmldocobj.createElement(elementName);
    if(elementText != null)
    {
        newtext=xmldocobj.createTextNode(elementText);
        newel.appendChild(newtext);
    }
    
    objP.appendChild(newel);
}

function saveMeeting()
{
    showloadingdots('yes'); 
    
    var doc = null;
    // code for IE
    if (window.ActiveXObject)
    {
        doc=new ActiveXObject("Microsoft.XMLDOM");
        doc.async="false";
    }
    else // code for Mozilla, Firefox, Opera, etc.
    {
        var parser=new DOMParser();
        doc = document.implementation.createDocument("","",null);
    }
    
    var x=doc.documentElement;
    
    var root = doc.createElement('Meeting'); // create root node
    doc.appendChild(root); // append root node
    
    var objRoot = doc.getElementsByTagName('Meeting');// obj of root node
    
    
    var objParentNode = null;
    
    addElementToXmlDoc(doc,objRoot[0],'Attendees',null);
    
    var objAttendees = doc.getElementsByTagName('Attendees');
    
    
    var currentTime = new Date();
    var month = currentTime.getUTCMonth() + 1;
    var day = currentTime.getUTCDate();
    var year = currentTime.getUTCFullYear();
    
    var minutes = currentTime.getUTCMinutes();
    var hour = currentTime.getUTCHours();
    var seconds = currentTime.getUTCSeconds();
    
    if(hour < 10)
        hour = '0' + hour;
        
    if(minutes < 10)
        minutes = '0'+ minutes;
        
    if(seconds < 10)
        seconds = '0' + seconds;    

    if(month < 10)
        month = '0' + month;
        
    if(day < 10)
        day = '0' + day;
            
    var todayTime = year + "-" + month + "-" + day+'T'+hour+':'+minutes+':'+seconds + 'Z';
    var guid = generateGUID();
    
    addElementToXmlDoc(doc,objRoot[0],'City',cityValue);
    addElementToXmlDoc(doc,objRoot[0],'CostPerSecond',formatCurrencyWithoutCurrencySymbol(averagePerSecond));
    addElementToXmlDoc(doc,objRoot[0],'Country',countryValue);
    
    addElementToXmlDoc(doc,objRoot[0],'Date',todayTime);
    addElementToXmlDoc(doc,objRoot[0],'Guid',guid);
    addElementToXmlDoc(doc,objRoot[0],'LengthSeconds',getSeconds(currentTimer));
    //addElementToXmlDoc(doc,objRoot[0],'Length',getSeconds(currentTimer));
    addElementToXmlDoc(doc,objRoot[0],'NumberOfAttendees',(attendeesHashtable.size()-1));
    addElementToXmlDoc(doc,objRoot[0],'State',stateValue);
    addElementToXmlDoc(doc,objRoot[0],'Title',meetingHeading);
    //addElementToXmlDoc(doc,objRoot[0],'TotalCost',trim(formatCurrencyWithoutCurrenctSymbol(round(moneyCounter))));
    addElementToXmlDoc(doc,objRoot[0],'TotalCost',round(moneyCounter));
    
    var currentcnt = 0;
    var hrlycnt = 0;
    var salarycnt = 0;
    var jobtitlecnt = 0;
    var i=0;
    var j=0;
    for(i=0; i < attendeesHashtable.size(); i++)
    {
        var k = attendeesHashtable.keys()[i];
        var objVals = combinedRates.get(k)
        var jobtitle="";
        var type="";
        var amount="";
        var currencyname="";
        var timeinmeeting = "";
        
        if(k.indexOf("toJSONString") == -1)
        {
            
            addElementToXmlDoc(doc,objAttendees[0],'Attendee',null);
            objParentNode = doc.getElementsByTagName('Attendee');
            
            
            addElementToXmlDoc(doc,objParentNode[j],'ExtensionData',null);
             
            type = objVals.Type
            amount = objVals.Median;
            jobtitle=attendeesJobTitle.get(k);
            
            if(amount != "0.0" && currentcnt == 0)
            {
                addElementToXmlDoc(doc,objRoot[0],'Currency',objVals.Currency);
                addElementToXmlDoc(doc,objRoot[0],'CurrencySymbol',objVals.CurrencySymbol);
                currentcnt = currentcnt + 1;
            }
           
            if(type == "Hourly") 
            {
                if(amount == "0.0")
                {
                    // open job
                    
                    addElementToXmlDoc(doc,objParentNode[j],'Job',null);
                    objParentNode = doc.getElementsByTagName('Job');
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'Title',jobtitle);
                    
                    // close job
                    
                }
                else
                {
                    // open HourlyRate
                    
                    addElementToXmlDoc(doc,objParentNode[j],'HourlyRate',null);
                    objParentNode = doc.getElementsByTagName('HourlyRate');
                    
                    addElementToXmlDoc(doc,objParentNode[hrlycnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[hrlycnt],'Rate',null);
                    objParentNode = doc.getElementsByTagName('Rate');
                    
                    addElementToXmlDoc(doc,objParentNode[hrlycnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[hrlycnt],'Amount',amount);
                                        
                    addElementToXmlDoc(doc,objParentNode[hrlycnt],'CurrencyName',objVals.Currency);
                    
                    
                    // close HourlyRate
                    
                    objParentNode = doc.getElementsByTagName('Attendee');
                    
                    // open job
                    
                    
                    addElementToXmlDoc(doc,objParentNode[j],'Job',null);
                    objParentNode = doc.getElementsByTagName('Job');
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'Title',jobtitle);
                    
                    // close job
                    
                    hrlycnt = hrlycnt + 1;
                }
                
                jobtitlecnt = jobtitlecnt + 1;
            }
            else if(type == "Salary") 
            {
                if(amount == "0.0")
                {
                    // open job
                    
                    addElementToXmlDoc(doc,objParentNode[j],'Job',null);
                    objParentNode = doc.getElementsByTagName('Job');
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'Title',jobtitle);
                    // close job
                }
                else
                {
                    // open Salary
                    
                    
                    addElementToXmlDoc(doc,objParentNode[j],'Salary',null);
                    objParentNode = doc.getElementsByTagName('Salary');
                    
                    addElementToXmlDoc(doc,objParentNode[salarycnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[salarycnt],'AnnualSalary',null);
                    objParentNode = doc.getElementsByTagName('AnnualSalary');
                    
                    addElementToXmlDoc(doc,objParentNode[salarycnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[salarycnt],'Amount',amount);
                    
                    addElementToXmlDoc(doc,objParentNode[salarycnt],'CurrencyName',objVals.Currency);
                    
                    // close Salary
                    
                    objParentNode = doc.getElementsByTagName('Attendee');
                    
                    // open job
                    
                    addElementToXmlDoc(doc,objParentNode[j],'Job',null);
                    objParentNode = doc.getElementsByTagName('Job');
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'ExtensionData',null);
                    
                    addElementToXmlDoc(doc,objParentNode[jobtitlecnt],'Title',jobtitle);
                    
                    // close job
                    salarycnt = salarycnt + 1;
                }
                
                jobtitlecnt = jobtitlecnt + 1;
            }
            j=j+1;
        }
    } 
    
    //alert(doc.xml)
    
    var url = proxyUrl+"?Action=SaveMeeting&address=" + escape(loggedinUsrEmail) + "&password=" + escape(loggedinUsrPwd);
    url = url + "&random=" + generateGUID();

    createXmlHttp();
    xmlhttp.onreadystatechange=getSaveMeetingResult
    xmlhttp.open("POST",url,true);
    xmlhttp.send(doc);
}

function generateGUID()
{
    var guid = (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()).toLowerCase();
    return guid;
}


function S4() 
{
    return (((1+Math.random())*0x10000)|0).toString(16).substring(1);//returns 4 char string
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        { 
            c_start=c_start + c_name.length+1 
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) 
                c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }   
    }
    return ""
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())

}

function deleteCookie(name,path,domain) 
{
    if (getCookie(name)) 
    {
        document.cookie = name + "=" +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=.uregina.ca" : "") +
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function showSavedLocation()
{
    var strlocation = getCookie('location');
    if(countryValue != "" || stateValue != "" || cityValue != "")
    {
    
    }
    else if(strlocation != "")
    {
        if(strlocation.indexOf('-') != -1)
        {
            
            if(strlocation.indexOf(',') != -1)
            {
                var arr1 = strlocation.split(',')
                var arr2 = arr1[1].split('-')
                
                cityValue = trim(arr1[0]);
                stateValue = trim(arr2[0]);
                countryValue = trim(arr2[1]);
            } 
            else
            {
                var arr1 = strlocation.split('-')
                
                stateValue = trim(arr1[0]);
                countryValue = trim(arr1[1]);
            }
        }
        else
        {
            if(strlocation.indexOf(',') != -1)
            {
                var arr1 = strlocation.split(',')
                
                cityValue = trim(arr1[0]);
                countryValue = trim(arr1[1]);
            }
            else
            {
                countryValue = trim(strlocation);
            }    
        }
    }
    
    if(countryValue != "" || stateValue != "" || cityValue != "")
    {
        isCountryChanged = 'yes';
        //isStateORCityChanged = 'yes';
        
        if(countryValue == "United States")
        {
            currentSelectedCurrency = "$";
        }
        if(countryValue == "Canada")
        {
            currentSelectedCurrency = "C$";
        }
        if(countryValue == "United Kingdom")
        {
            currentSelectedCurrency = "\243";
        }
        if(countryValue == "Australia")
        {
            currentSelectedCurrency = "AU$";
        }
        if(countryValue == "India")
        {
            currentSelectedCurrency = "Rs";
        }
        
        var oldCurrenySymbol = currentSelectedCurrency;
        var divMoneyCounter =  document.getElementById("divCost");
        var divString  = trim(divMoneyCounter.innerHTML);
        divMoneyCounter.innerHTML = currentSelectedCurrency + divString.replace(oldCurrenySymbol ,'');

        var divCostperSec=  document.getElementById("divAveragePerSecond");
        var divString1  = trim(divCostperSec.innerHTML);
        divCostperSec.innerHTML = currentSelectedCurrency + divString1.replace(oldCurrenySymbol ,''); //divString1.replace(oldCurrenySymbol ,currentSelectedCurrency);

        var divCostperMin =  document.getElementById("divAveragePerMin");
        var divString2  = trim(divCostperMin.innerHTML);
        divCostperMin.innerHTML = currentSelectedCurrency + divString2.replace(oldCurrenySymbol ,'');
            
        showlocationcommondisplay();   
 
      }
}

function getSaveMeetingResult()
{
    try
    {
        if (xmlhttp.readyState==4)
        {
            if (xmlhttp.status==200)
            {
                var resulttext = xmlhttp.responseText;
                var response = resulttext.parseJSON();
                //alert(resulttext);
                if(response.Message != null)
                {
                    showloadingdots('no');  
                    
                    ShowErrorMessage("divMin",noConnectivityMessage);
                }
                else 
                {
                    if (response.Success == true)
                    {
                        showloadingdots('no');  
                        
                        var objshowMessagId = document.getElementById("showMessagId");
                        if(objshowMessagId != null)
                        {
                            objshowMessagId.style.display='';
                        }
                        //ShowErrorMessage("divMin","Meeting saved successfully.");
                    }
                    else
                    {
                        showloadingdots('no');
                        var objdivMin = document.getElementById("divMin");
                        if(objdivMin != null)
                            ShowErrorMessage(objdivMin,noConnectivityMessage);
                    }
                }
            } 
            else
            {
                showloadingdots('no'); 
                ShowErrorMessage("divMin",noConnectivityMessage);
            }  
        }     
    }
    catch(exception)
    {
        
    } 
}
       
function exportToCSV()
{
    try
    {
        if(loggedinUsrEmail != "" && loggedinUsrPwd != "")
        {
            var url = "ExportToCSV.aspx?Action=ExportToCSV&address=" + escape(loggedinUsrEmail) + "&password=" + escape(loggedinUsrPwd);
            createXmlHttp();
            //openNewURL(url);
            window.open (url,"exporttocsv","status=0,toolbar=0,scrollbars=0,height=600px,width=400px");
            
        }
    }
    catch(exception)
    {
        
    }    
}

function showToolTipDiv(val)
{
    var objtipDiv = document.getElementById("tipDiv"); 
    if(objtipDiv != null)
    {
        if(val == 'yes')
        {
            objtipDiv.style.display = '';
        }
        else
        {
            objtipDiv.style.display = 'none';
        }
    }
}

function showMenu()
{   
    showToolTipDiv('no');
    
    CloseAlarmAlertWidow();
    CloseDropdownWindow();
    CloseAlarmDropdownWindow();     
    CloseErrorMsgWnd();
    
    isMenuBtnClick='yes';
    
    var currentDate = new Date();

    if(loggedinUsrEmail == "" && loggedinUsrPwd == "")
    {

        var divWholeMeeting = document.getElementById("divWholeMeetingDisplay"); 
        divMeetingTextBeforeStop = '';
        divMeetingTextBeforeStop = trim(divWholeMeeting.innerHTML);
        divWholeMeeting.innerHTML = '';
        divWholeMeeting.innerHTML = innerHTMLUserLogin;     
        
        var objdivDisplayMeetingHeading = document.getElementById("divDisplayMeetingHeading"); 
        if(objdivDisplayMeetingHeading != null)
        {
            objdivDisplayMeetingHeading.innerHTML = meetingHeading;
            // remove highlighting
            objdivDisplayMeetingHeading.onmouseover='';
            objdivDisplayMeetingHeading.onmouseout='';
        }
        
        var objdivCost =  document.getElementById("divCost");  
        if(objdivCost != null)
        {
            objdivCost.innerHTML = trim(formatCurrency(round(moneyCounter)));     
        }
        
        
        var objdivTotalMeetingTime =  document.getElementById("divMin");  
        if(objdivTotalMeetingTime != null)
        {
            if(currentTimer != "")
            {
                objdivTotalMeetingTime.innerHTML = currentTimer;     
            }
            else
            {
                objdivTotalMeetingTime.innerHTML = "0:00:00";     
            }
            
        }
    }
    else
    {
        var body = ""; 
        var divWholeMeeting= document.getElementById("divWholeMeetingDisplay"); 
        divMeetingTextBeforeStop = '';
        divMeetingTextBeforeStop = trim(divWholeMeeting.innerHTML);
        divWholeMeeting.innerHTML = '';
        divWholeMeeting.innerHTML = divStopMeetingText;     
        
        var heading = document.getElementById("divDisplayMeetingHeading");      
        heading.innerHTML = meetingHeading ;
        // remove highlighting
        heading.onmouseover='';
        heading.onmouseout='';
            
        var objdivCost =  document.getElementById("divCost");  
        if(objdivCost != null)
        {
            objdivCost.innerHTML = trim(formatCurrency(round(moneyCounter)));     
        }
        
        
        var objdivTotalMeetingTime =  document.getElementById("divMin");  
        if(objdivTotalMeetingTime != null)
        {
            if(currentTimer != "")
            {
                objdivTotalMeetingTime.innerHTML = currentTimer;     
            }
            else
            {
                objdivTotalMeetingTime.innerHTML = "0:00:00";     
            }
            
        }
        
        var objdivLoggedInEmail = document.getElementById("divLoggedInEmail");      
        if(objdivLoggedInEmail != null)
        {
            var loggedinUsrEmailForDisplay = loggedinUsrEmail;
            if(loggedinUsrEmail.length > 25)
            {
                loggedinUsrEmailForDisplay = loggedinUsrEmail.substring(0,22) + '...';
            }
            objdivLoggedInEmail.innerHTML = '<table cellpadding="0" cellspacing="0" width="100%" border="0"><tr><td width="70%" style="text-align:right;"><Font class="blacktextbold">'+loggedinUsrEmailForDisplay+'</Font> </td> <td style="text-align:left;">&nbsp;|&nbsp;<a href="#" onclick="logoutUser();" class="blackboldlink">Logout</a></td></tr></table>';
        }
        if(attendeesHashtable.size() > 1 && currentTimer != "")
        {
            body = '';
            var currdate = (currentDate.getMonth()+1)+'/'+currentDate.getDay()+'/'+currentDate.getFullYear();
            var cost = trim(formatCurrency(round(moneyCounter)));
            var emaildata = getEmailBodyFormat(currdate,currentTimer,cost,meetingHeading);
            
            var objemaildata = document.getElementById("emaildata"); 
            if(objemaildata != null)
            {
                objemaildata.href=emaildata;
            }
        }
        else
        {
            var objemaildata = document.getElementById("emaildata"); 
            if(objemaildata != null)
            {
                objemaildata.href='#';
            }
        }
    }  
    
    if(alarmIsSet == 'yes')
    {
        var divAlram= document.getElementById("divAlarm"); 
        if(divAlram != null)
        {
            divAlram.innerHTML  = divAlarmEnalbed;
        }    
    }
    else
    {
        var divAlram= document.getElementById("divAlarm"); 
        if(divAlram != null)
        {
            divAlram.innerHTML  = divAlarmDisabled;
        }    
    }
    
    var objimgMMLeft = document.getElementById("imgMMLeft"); 
    if(objimgMMLeft != null)
    {
        objimgMMLeft.focus();
    }
}

function logoutUser()
{
    deleteCookie('loggedInEmail');
    deleteCookie('loggedInPassword');
    deleteCookie('fiveRecentAttendees');
    deleteCookie('totalNoOfMeetings');
    
    loggedinUsrEmail = ""; 
    loggedinUsrPwd = "";
    totalNoOfMeetings=0;
    recentJobTitles = [];
    
    var divWholeMeeting = document.getElementById("divWholeMeetingDisplay"); 
    divWholeMeeting.innerHTML = innerHTMLUserLogin;     
    
    var objdivDisplayMeetingHeading = document.getElementById("divDisplayMeetingHeading"); 
    if(objdivDisplayMeetingHeading != null)
    {
        objdivDisplayMeetingHeading.innerHTML = meetingHeading;
        objdivDisplayMeetingHeading.onmouseover='';
        objdivDisplayMeetingHeading.onmouseout='';
    }
    
    var objdivCost =  document.getElementById("divCost");  
    if(objdivCost != null)
    {
        objdivCost.innerHTML = trim(formatCurrency(round(moneyCounter)));     
    }
    
    
    var objdivTotalMeetingTime =  document.getElementById("divMin");  
    if(objdivTotalMeetingTime != null)
    {
        if(currentTimer != "")
        {
            objdivTotalMeetingTime.innerHTML = currentTimer;     
        }
        else
        {
            objdivTotalMeetingTime.innerHTML = "0:00:00";     
        }
        
    }
}

function fetchFiveMostRecentAttendees()
{
    if(getCookie('fiveRecentAttendees') != null && getCookie('fiveRecentAttendees') != "")
        recentJobTitles = getCookie('fiveRecentAttendees').parseJSON();
}

function getInfoAutoLoginResult()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        if (xmlhttp.status==200)
        {
            var resulttext = xmlhttp.responseText;
            var response = resulttext.parseJSON();
            
            if(response.NumberOfMeetings == null && response.RecentJobTitles == null && response.LoggedIn == null && response.Message != null)
            {
                showloadingdots('no');  
                nullAllUserCridentials();
            }
            else 
            {
                if (response.Success == true)
                {
                    showloadingdots('no');
                    totalNoOfMeetings = response.NumberOfMeetings;
                    
                    recentJobTitles = response.RecentJobTitles.items;
                    setCookie('totalNoOfMeeting',totalNoOfMeetings,10);
                    setCookie('fiveRecentAttendees',response.RecentJobTitles.items.toJSONString(),10);
                    
                    loggedinUsrEmail = cookieEmail;
                    loggedinUsrPwd = cookiePassword; 
                        
                    setCookie('loggedInEmail',cookieEmail,10);
                    setCookie('loggedInPassword',cookiePassword,10);
                    
                }
                else 
                {
                    // hiding loading dots.
                    showloadingdots('no');
                    nullAllUserCridentials();
                }
            }
        }
        else
        {
            // hiding loading dots.
            showloadingdots('no');
            nullAllUserCridentials();
        }
    } 

}

function nullAllUserCridentials()
{
    loggedinUsrEmail = ""; 
    loggedinUsrPwd = "";
    totalNoOfMeetings=0;
}

function cleatAllCookies()
{
    deleteCookie('loggedInEmail');
    deleteCookie('loggedInPassword');
    deleteCookie('fiveRecentAttendees');
    deleteCookie('totalNoOfMeetings');
}

function getInfoResult()
{
    // if xmlhttp shows "loaded"
    
    if (xmlhttp.readyState==4)
    {
        if (xmlhttp.status==200)
        {
            var resulttext = xmlhttp.responseText;
            var response = resulttext.parseJSON();
            //alert(resulttext);
            if(response.NumberOfMeetings == null && response.RecentJobTitles == null && response.LoggedIn == null && response.Message != null)
            {
                isMenuBtnClick = 'no';
                showloadingdots('no');  
                if(response.Message.toLowerCase().indexOf('username') != -1)
                {
                    ShowErrorMessage("divMin","The email address and password given do not match.");
                }
                else
                {
                    ShowErrorMessage("divMin",noConnectivityMessage);                    
                }
            }
            else 
            {
                if (response.Success == true)
                {
                    totalNoOfMeetings = response.NumberOfMeetings;
                    recentJobTitles = response.RecentJobTitles.items;
                    setCookie('totalNoOfMeeting',totalNoOfMeetings,10);
                    setCookie('fiveRecentAttendees',response.RecentJobTitles.items.toJSONString(),10);
                    
                    var objtxtEmail = document.getElementById("txtEmailId");
                    var objtxtPassword = document.getElementById("txtPassword");
                    
                    isLoggedIn = 'yes';
                    if(objtxtEmail != null)
                    {
                        loggedinUsrEmail = objtxtEmail.value
                        loggedinUsrPwd = Base64.encode(trim(objtxtPassword.value));
                        
                        setCookie('loggedInEmail',loggedinUsrEmail,10);
                        setCookie('loggedInPassword',loggedinUsrPwd,10);
                    }
                    
                    showMeetingCompletionMenu(); 
                    
                    if(attendeesHashtable.size() > 1 && currentTimer != "" && isMenuBtnClick == 'no')
                    {
                        // saves the meeting 
                        saveMeeting();
                    }
                    else
                    {
                        showloadingdots('no');         
                    }
                }
                else if(response.Message.toLowerCase().indexOf('username') != -1)
                {
                    // hiding loading dots.
                    showloadingdots('no');
                    isMenuBtnClick = 'no';
                    ShowErrorMessage("divMin","The email address and password given do not match.");
                }
            }
        }
        else
        {
            // hiding loading dots.
            showloadingdots('no');
            ShowErrorMessage("divMin",noConnectivityMessage);
        }
    }      
}

function changeWidth(input)
{
    if(input == "ViewHistory")
    {
        window.style="overflow-y:hidden;";
        window.resizeTo(490,620)
    }
    else
    {
        window.style="overflow:auto;";
        window.resizeTo(287,610)
    }
}

function showCountryChangeMessage(source)
{
    var oCurrentNode=source;
    var iLeft=0;
    var iTop =0;
    while(oCurrentNode.tagName!="BODY")
    {
        iTop+=oCurrentNode.offsetTop;
        iLeft+=oCurrentNode.offsetLeft;
        oCurrentNode=oCurrentNode.offsetParent;
    }
    createCountryChangeMessage(iLeft + 5 ,iTop + 5);
}

function ShowErrorMessageUsingObject(source,messagetext)
{
    var oCurrentNode=source;
    if(oCurrentNode != null)
    {
        var iLeft=0;
        var iTop =0;
        while(oCurrentNode.tagName!="BODY")
        {
            iTop+=oCurrentNode.offsetTop;
            iLeft+=oCurrentNode.offsetLeft;
            oCurrentNode=oCurrentNode.offsetParent;
        }
        CreateErrorMsgWnd(iLeft + 5 ,iTop + 5,messagetext);
    }
}

function ShowErrorMessage(source,messagetext)
{
    var oCurrentNode=document.getElementById(source);
    if(oCurrentNode != null)
    {
        var iLeft=0;
        var iTop =0;
        while(oCurrentNode.tagName!="BODY" && oCurrentNode.tagName!="HTML" && oCurrentNode!=null)
        {
            iTop+=oCurrentNode.offsetTop;
            iLeft+=oCurrentNode.offsetLeft;
            oCurrentNode=oCurrentNode.offsetParent;
        }
        CreateErrorMsgWnd(iLeft + 5 ,iTop + 5,messagetext);
    }
}

function getLoginPwdFromCookie()
{
    cookieEmail = getCookie('loggedInEmail');
    cookiePassword = getCookie('loggedInPassword');
    var csvjobtitleTemp = getCookie('fiveRecentAttendees');
    var csvjobtitle = getCookie('fiveRecentAttendees');
    var noOfMeeting = getCookie('totalNoOfMeeting');
    
    if(cookieEmail != "" && cookiePassword != "")
    {
        createXmlHttp(); 
        loadXMLDoc(proxyUrl+"?Action=GetInfo&address=" + escape(trim(cookieEmail)) + "&password=" + escape(cookiePassword),"GetInfoAutoLogin");
    }
    
}

function yesBtnClickCountryChangedMsgWnd()
{
    attendeesEditList.clear(); // clear all items from edit list
    isCountryChangedMsgShow = 'no';
    CloseCountryChangedMsgWnd();
    var country = document.getElementById("txtCountry");
    countryValue = country.value;
    showlocation();   
}

// JScript File

