﻿var Url = {
encode : function (string) {
    return escape(this._utf8_encode(string));
},
decode : function (string) {
    return this._utf8_decode(unescape(string));
},
_utf8_encode : function (string) {
    string = string.replace(/\r\n/g,"\n");
    var utftext = "";
    for (var n = 0; n < string.length; n++) {

        var c = string.charCodeAt(n);

        if (c < 128) {
            utftext += String.fromCharCode(c);
        }
        else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        }
        else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }
    }
    return utftext;
},
_utf8_decode : function (utftext) {
    var string = ""; var i = 0; var c = c1 = c2 = 0;
    while ( i < utftext.length ) {
        c = utftext.charCodeAt(i);

        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        }
        else if((c > 191) && (c < 224)) {
            c2 = utftext.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        }
        else {
            c2 = utftext.charCodeAt(i+1);
            c3 = utftext.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
       }
   }
    return string.replace(/\+/g, " ").replace(/''/g, "'");
}
}
/* Clear Default Text: functions for clearing and replacing default text in <input> elements.*/
function clearDefaultText(target) {
    if (!target || !target.attributes["title"]) return;
    if (target.value == target.attributes["title"].value)
        target.value = '';
    else
        target.select();
}
function replaceDefaultText(target) {
    if (!target) return;
    if (target.value == '' && target.attributes["title"]) {
        target.value = target.attributes["title"].value;
    }
}
function getParentWithCopyId(obj){
    if( obj.attributes == null ) return null;
    if( obj.attributes["CopyId"] != null ) return obj;
    if( obj.parentNode == null ) return null;
    return getParentWithCopyId(obj.parentNode);
}
function ClientShowing(sender, args){var target = sender.get_completionList();calculateSize(target, sender.get_element().style.width);}
function calculateSize(target, textBoxWidth){
    var maxWidth = 500;
    var maxHeight = 350;
    if(target==null) return textBoxWidth + 'px';
    var elements = target.getElementsByTagName('LI');
    var maxLength = 0;
    if(textBoxWidth=='') textBoxWidth='150px';
    textBoxWidth = textBoxWidth.replace('px','');
    for(var i=0;i<elements.length;i++){
        var tempLength = elements[i].innerHTML.length * 6;
        if(tempLength > maxLength)
            maxLength = tempLength;
    }
    if(maxLength < parseInt(textBoxWidth)) maxLength = parseInt(textBoxWidth);
    if(maxLength>maxWidth) maxLength = maxWidth;
    target.style.width = maxLength + 'px';
    var tempHeight = Math.min(elements.length * 14 + 4, 120);
    if(tempHeight > maxHeight){
        tempHeight=maxHeight;
        target.style.height = tempHeight + 'px';
        target.style.overflow = 'auto';
    }else{
        target.style.overflow = 'visible';
    }
}
function ChangeHrefToJSVoid(objectId){
    var object = document.getElementById(objectId);
    if(object==null) return;
    var anchors = object.getElementsByTagName("a");
    if(anchors==null) return;
    for (var i = 0; i < anchors.length; i++){
        var anchor = anchors[i];
        if(anchor.href.endsWith('#')){
            var newHref = 'javascript:void(0);';
            anchor.href = newHref;
        }
    }
}
function GetActiveToolTip(){
    var controller = Telerik.Web.UI.RadToolTipController.getInstance();
    if(controller==null)return null;
    return controller.get_activeToolTip();
}
function SetActiveTooltipTitle(title){
    var activeTooltip = GetActiveToolTip();
    if(activeTooltip==null)
        return;
    activeTooltip.set_title(title);
}
function ShowToolTip(tooltipManager, element, title, manualClose, width, height){
    if(tooltipManager==null) return;
    var CSTooltip = tooltipManager.getToolTipByElement(element);
    if(CSTooltip==null){
        //Create a new tooltip;
        CSTooltip = tooltipManager.createToolTip(element);
        CSTooltip.set_targetControl(element);
        CSTooltip.set_serverTargetControlID(element.id);
        CSTooltip.set_title(title);
        CSTooltip.set_height(height);
        CSTooltip.set_width(width);
        CSTooltip.set_manualClose(manualClose);
    }
    CSTooltip.show();
}
function CloseToolTip(){
    if(Telerik.Web.UI.RadToolTipController == null) return;
    var instance = Telerik.Web.UI.RadToolTipController.getInstance();
    if(instance==null) return;
    var tooltip = instance.get_activeToolTip();
    if(tooltip==null) return;
    tooltip.hide();
}
function insertAtCursor(myField, myValue){
    //IE support
    if (document.selection){
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
    }
    //MOZILLA/NETSCAPE support
    else if (myField.selectionStart || myField.selectionStart == '0'){
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        myField.value = myField.value.substring(0, startPos)
        + myValue
        + myField.value.substring(endPos, myField.value.length);
    }
    else{myField.value += myValue;}
}
function styleCheckboxes() {
   var cbxs=document.getElementsByTagName('INPUT');
   for (var i=0; i<cbxs.length; i++) {
       if(cbxs[i].type=='checkbox' || cbxs[i].type=='radio') {
         cbxs[i].style.border='none';
         cbxs[i].style.background='transparent';
       }
    }
}
function SetRadEditorContentAreaClassName(editor, args)
{
    if( editor != null && editor.get_contentArea() != null)
        editor.get_contentArea().className="brandedEditor";
}
//windowManagerClientId is set in the Master Page.
function OpenWindow(url, name, width, height){
    var oManager = $find(windowManagerClientId);
    var wnd = oManager.open(url, name);
    wnd.setSize(width, height);
    wnd.center();
    CloseToolTip();
    return false;
}
function OpenWindowWithCallBack(url, name, width, height, callBack){
    var oManager = $find(windowManagerClientId);
    var wnd = oManager.open(url, name);
    wnd.setSize(width, height);
    wnd.center();
    wnd.add_close(callBack);
    return false;
}
function OpenCandSearchWindow(name, applicationId, width, height)
{
    var oManager = $find(windowManagerClientId);
    var wnd = oManager.open(GetCandidateSearchWindowUrl(name, applicationId), null);
    SetWindowProperties(oManager, wnd, {Name:name, Width:width, Height:height}, applicationId);
    return false;
}
function OpenCandSearchWindowWithCallBack(name, applicationId, width, height)
{
    var oManager = $find(windowManagerClientId);
    var wnd = oManager.open(GetCandidateSearchWindowUrl(name, applicationId), null);
    SetWindowProperties(oManager, wnd, {Name:name, Width:width, Height:height}, applicationId);
    wnd.add_close(RadWindowCallbackFunction);
    return false;
}
function OpenRecmdWindow(url, width, height)
{
    var oManager = $find(windowManagerClientId);
    var wnd = oManager.open(url, null);
    SetRecmndWindowProperties(oManager, wnd, width, height);
    return false;
}
function OpenRecmdWindowWithCallBack(url, width, height, callBack)
{
    var oManager = $find(windowManagerClientId);
    var wnd = oManager.open(url, null);
    SetRecmndWindowProperties(oManager, wnd, width, height);
    wnd.add_close(callBack);
    return false;
}
function SetRecmndWindowProperties(oManager, wnd, width, height)
{
    _closedWindows="";
    prefs.load();
    SetDefaultCsPrefs();
    if(MoreThanOneWindowOpen(oManager)&&prefs.data.candSearchTileOnOpen)oManager.tile();
    else{
        wnd.setSize(width, height);
        wnd.center();
    }
    CloseToolTip();
}
function SetWindowProperties(oManager, wnd, wndProps, applicationId)
{
    _closedWindows="";
    prefs.load();
    SetDefaultCsPrefs();
    if(MoreThanOneWindowOpen(oManager)) {
        if(prefs.data.candSearchTileOnOpen)oManager.tile();
        AddOpeningWindowToCookie(wndProps);
    }
    else{
        wnd.setSize(wndProps.Width, wndProps.Height); 
        var oW=prefs.data.candSearchOpenWindows;
        if(oW==undefined || WindowIsInArray(wndProps,oW)==-1){
            wnd.center();
            prefs.data.candSearchOpenWindows=new Array(wndProps);
            prefs.save();
        }
        else{
            // opening window is in the cookie and there are no other windows open so open them all
            var b=false;
            for(var i=0;i<oW.length;i++) {
                if(oW[i].Name!=wndProps.Name) {
                    var wnd = oManager.open(GetCandidateSearchWindowUrl(oW[i].Name, applicationId), null);
                    wnd.setSize(oW[i].Width,oW[i].Height);
                    wnd.add_close(RadWindowCallbackFunction);
                    b=true;
                }
            }
            if(b&&prefs.data.candSearchTileOnOpen)oManager.tile();else wnd.center();
        }
    }
    CloseToolTip();
}
function WindowIsInArray(wndProps, wnds)
{
    for(var i=0;i<wnds.length;i++) {
        if(wnds[i].Name==wndProps.Name)
            return i;
    }return -1;
}
function AddOpeningWindowToCookie(wndProps){
    if(prefs.data.candSearchOpenWindows==undefined){
        prefs.data.candSearchOpenWindows=new Array(wndProps);prefs.save();
    }else if($.inArray(wndProps,prefs.data.candSearchOpenWindows)==-1) {
        prefs.data.candSearchOpenWindows.push(wndProps);prefs.save();
    }
}
function MoreThanOneWindowOpen(oManager) {
    var w=oManager.get_windows();var j=0;
    for(var i=0; i<w.length; i++){
        if(!w[i].isClosed() && w[i].isVisible())j++;
        if(j>1)return true;
    }return false;
}
function GetCandidateSearchWindowUrl(name, applicationId)
{
    switch(name)
    {
        case "Edit":
            return "EditLateralHirePosition.aspx?applicationId=" + applicationId;
        case "Process":
            return "ProcessCandidate.aspx?applicationId=" + applicationId;
        case "Recommend":
            return "CandidateRecommendations.aspx?applicationId=" + applicationId;
        case "Appoints":
            return "CandidateAppointmentScheduler.aspx?applicationId=" + applicationId;
        case "Note":
            return "NoteManagement.aspx?applicationId=" + applicationId;
        case "AgentNote":
            return "NoteManagement.aspx?Agent=1&applicationId=" + applicationId;
        case "Email":
            return "EmailHistory.aspx?applicationId=" + applicationId;
        case "History":
            return "ApplicationHistory.aspx?applicationId=" + applicationId;
        case "AddDocs":
            return "CandidateDocs.aspx?UploadedDocumentTypeId=2&applicationId=" + applicationId;
        case "Print":
            return "RecruiterPrintOptions.aspx?applicationId=" + applicationId;
        case "ManScore":
            return "CandidateManualScoringForm.aspx?applicationId=" + applicationId;
        case "Expenses":
            return "CandidateExpensesForm.aspx?applicationId=" + applicationId;
        case "IntNotes":
            return "CandidateDocs.aspx?UploadedDocumentTypeId=3&applicationId=" + applicationId;
        case "DocCheckList":
            return "CandidateDocumentationForm.aspx?applicationId=" + applicationId;
        case "References":
            return "CandidateReferences.aspx?applicationId=" + applicationId;
        default:
            return "CandidateProfile.aspx?applicationId=" + applicationId;
    }
}
var _closedWindows;
function CloseAllWindows(sender, eventArgs){
    if(_closedWindows==undefined||(sender.get_name!=undefined&&sender.get_name().indexOf("ested")>=0))return;
    prefs.load();
    SetDefaultCsPrefs();
    if(prefs.data.candSearchCloseAllOnClose){
        var oM=$find(windowManagerClientId);
        var w=oM.get_windows();var j=0;
        for(var i=0; i<w.length; i++){
            if(_closedWindows.indexOf(w[i].get_id())==-1&&!w[i].isClosed()&&w[i].isVisible()){ _closedWindows+=w[i].get_id();w[i].close();}
        }
    }
}
function SaveCsPrefs(){
    prefs.load();
    prefs.data.candSearchTileOnOpen=document.getElementById("TileCb").checked;
    prefs.data.candSearchCloseAllOnClose=document.getElementById("CloseAllOnCloseCb").checked;
    prefs.save();
    CloseToolTip();
}
function SetCsPrefs(sender, eventArgs){
    prefs.load();
    SetDefaultCsPrefs();
    document.getElementById("TileCb").checked = prefs.data.candSearchTileOnOpen;
    document.getElementById("CloseAllOnCloseCb").checked=prefs.data.candSearchCloseAllOnClose;
}
function SetDefaultCsPrefs(){
    if(prefs.data.candSearchTileOnOpen==undefined)
    {
        prefs.data.candSearchTileOnOpen=true;
        prefs.data.candSearchCloseAllOnClose=true;
    }
}
    
function OpenNestedWindowWithCallBack(url, width, height, callBack){
    var oManager = GetRadWindow().get_windowManager();
    var wnd = oManager.open(url, 'nested');
    setTimeout(function(){wnd.setActive(true);}, 0);
    wnd.setSize(width, height);
    wnd.center();
    wnd.add_close(callBack);
    CloseToolTip();
    return false;
}
function OpenSecondNestedWindowWithCallBack(url, width, height, callBack){
    var oManager = GetRadWindow().get_windowManager();
    var wnd = oManager.open(url, 'secondNested');
    setTimeout(function(){wnd.setActive(true);}, 0);
    wnd.setSize(width, height);
    wnd.center();
    wnd.add_close(callBack);
    CloseToolTip();
    return false;
}

function OpenThirdNestedWindowWithCallBack(url, width, height, callBack){
    var oManager = GetRadWindow().get_windowManager();
    var wnd = oManager.open(url, 'thirdNested');
    setTimeout(function(){wnd.setActive(true);}, 0);
    wnd.setSize(width, height);
    wnd.center();
    wnd.add_close(callBack);
    CloseToolTip();
    return false;
}


function OpenNestedWindow(url, width, height){
    var oManager = GetRadWindow().get_windowManager();
    var wnd = oManager.open(url, 'nested');
    setTimeout(function(){wnd.setActive(true);}, 0);
    wnd.setSize(width, height);
    wnd.center();
    CloseToolTip();
    return false;
}
function Print(){
    GetRadWindow().get_contentFrame().contentWindow.focus();
    if (navigator.userAgent.indexOf("Firefox")!=-1)
    {
        GetRadWindow().get_contentFrame().contentWindow.print();
        //alert("This window can be closed after you have printed.");
        return;
    }
    setTimeout("GetRadWindow().get_contentFrame().contentWindow.print();", 100);
    if (window.document.readyState == "complete")
        JustClose();
    else
        setTimeout("JustClose();",500);
}

function GetRadWindow() { var oWindow = null; if (window.radWindow) { oWindow = window.radWindow; } else if (window.frameElement.radWindow) { oWindow = window.frameElement.radWindow; } return oWindow; }
function SetWindowSize(w, h) { var oWnd = GetRadWindow(); var bounds = oWnd.getWindowBounds(); if (h >= bounds.height) { h = bounds.height - 40; w = w + 20; } if (w >= bounds.width) { w = bounds.width - 40; } oWnd.set_height(h); oWnd.set_width(w); oWnd.center(); return; }
function SetWindowModality(bln) { var oWnd = GetRadWindow(); oWnd.set_Modal(bln); return; }
function CloseAndRebind(HFID) { GetRadWindow().BrowserWindow.postBackHF(HFID); GetRadWindow().Close(); }
function CloseAndRedirect(parentLocation) { window.top.location.href = parentLocation; GetRadWindow().Close(); }
function JustRebind(HFID) { GetRadWindow().BrowserWindow.postBackHF(HFID); }
function JustClose() { GetRadWindow().Close(); }
function CloseAndRefresh(parameter) { GetRadWindow().Close(parameter); }
function AddWindowArgument(parameter) { GetRadWindow().argument = parameter; }

var isEditing = false;
var controlId;

$(function($)
{
   $('.editor').click(function(){
      if (isEditing)
      {
         $('.editableLabel').removeClass('editable');
         $(this).text('Edit this page');

      }
      else
      {
         $('.editableLabel').addClass('editable');
         $(this).text('Stop Editing');

    $('.editable').contextMenu('cmsContextMenu', {
      bindings: {
        'edit': function(t) {
        if (!isEditing) return;

        controlId = '#' + $(t).attr('id');
        OpenContentEditor(t);
          //alert('Trigger was '+t.id+'\nAction was edit');
        },
        'undo': function(t) {
          alert('Trigger was '+t.id+'\nAction was undo');
        },
        'home': function(t) {
          document.location="RecruiterHome.aspx";
        }
      }
    });

      }
      isEditing = !isEditing;

   });

   $('.editableLabel').dblclick(function(){
        if (!isEditing) return;

        controlId = '#' + $(this).attr('id');
        OpenContentEditor(this);
   });

   function OpenContentEditor(ctrl)
   {
      OpenWindowWithCallBack('ContentEditor.aspx?CopyId='+ $(ctrl).attr('copyId') + '&id=' + $(ctrl).attr('id'), 'ContentEditor', 750,600, RefreshContent);
   }

   function RefreshContent(sender, eventArgs)
   {
      /*if (eventArgs != null && eventArgs.get_argument() != null)
      {
        var argument = eventArgs.get_argument();
        $(controlId).html(Url.decode(argument));
      }*/
      sender.remove_close(RefreshContent);
      controlId = null;
   }
 });

// Context menu (http://www.trendskitchens.co.nz/jquery/contextmenu/)
(function($){var menu,shadow,trigger,content,hash,currentTarget;var defaults={menuStyle:{listStyle:'none',padding:'1px',margin:'0px',backgroundColor:'#fff',border:'1px solid #999',width:'100px'},itemStyle:{margin:'0px',color:'#000',display:'block',cursor:'default',padding:'3px',border:'1px solid #fff',backgroundColor:'transparent'},itemHoverStyle:{border:'1px solid #0a246a',backgroundColor:'#b6bdd2'},eventPosX:'pageX',eventPosY:'pageY',shadow:true,onContextMenu:null,onShowMenu:null};$.fn.contextMenu=function(id,options){if(!menu){menu=$('<div id="jqContextMenu"></div>').hide().css({position:'absolute',zIndex:'500'}).appendTo('body').bind('click',function(e){e.stopPropagation()})}if(!shadow){shadow=$('<div></div>').css({backgroundColor:'#000',position:'absolute',opacity:0.2,zIndex:499}).appendTo('body').hide()}hash=hash||[];hash.push({id:id,menuStyle:$.extend({},defaults.menuStyle,options.menuStyle||{}),itemStyle:$.extend({},defaults.itemStyle,options.itemStyle||{}),itemHoverStyle:$.extend({},defaults.itemHoverStyle,options.itemHoverStyle||{}),bindings:options.bindings||{},shadow:options.shadow||options.shadow===false?options.shadow:defaults.shadow,onContextMenu:options.onContextMenu||defaults.onContextMenu,onShowMenu:options.onShowMenu||defaults.onShowMenu,eventPosX:options.eventPosX||defaults.eventPosX,eventPosY:options.eventPosY||defaults.eventPosY});var index=hash.length-1;$(this).bind('contextmenu',function(e){var bShowContext=(!!hash[index].onContextMenu)?hash[index].onContextMenu(e):true;if(bShowContext)display(index,this,e,options);return false});return this};function display(index,trigger,e,options){var cur=hash[index];content=$('#'+cur.id).find('ul:first').clone(true);content.css(cur.menuStyle).find('li').css(cur.itemStyle).hover(function(){$(this).css(cur.itemHoverStyle)},function(){$(this).css(cur.itemStyle)}).find('img').css({verticalAlign:'middle',paddingRight:'2px'});menu.html(content);if(!!cur.onShowMenu)menu=cur.onShowMenu(e,menu);$.each(cur.bindings,function(id,func){$('#'+id,menu).bind('click',function(e){hide();func(trigger,currentTarget)})});menu.css({'left':e[cur.eventPosX],'top':e[cur.eventPosY]}).show();if(cur.shadow)shadow.css({width:menu.width(),height:menu.height(),left:e.pageX+2,top:e.pageY+2}).show();$(document).one('click',hide)}function hide(){menu.hide();shadow.hide()}$.contextMenu={defaults:function(userDefaults){$.each(userDefaults,function(i,val){if(typeof val=='object'&&defaults[i]){$.extend(defaults[i],val)}else defaults[i]=val})}}})(jQuery);$(function(){$('div.contextMenu').hide()});

function ToggleCheckboxes(select,gridId,selAllBtnId){
    var grid = $find(gridId);
    var btn = $get(selAllBtnId);
    if(grid==null) return;
    var masterTable = grid.get_masterTableView();
    var dataItems = masterTable.get_dataItems();
    for(var i=0;i<dataItems.length;i++){
        var cell = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[i], "CheckBox");
        if(cell==null)continue;
        var checkbox = cell.getElementsByTagName("Input")[0];
        checkbox.checked = select;
    }
}

function GridHasAtLeastOneRowChecked()
{
   var chk = new Array();
   chk = document.getElementsByTagName('input');
   for (var i = 0; i < chk.length; i++){
      if (chk[i].type == 'checkbox' && (chk[i].id.indexOf('RowSelector') > 0)){
         if (chk[i].checked){return true;}
      }
   }
   return false;
}

function OpenBulkPrintOptionsWindow(gridClientId, clientDataKeyValue, queryStringVariable, secondClientDataKeyValue, secondQueryStringVariable)
{
    if (!GridHasAtLeastOneRowChecked()){alert("Please select one or more applications");return false;}
    var gridObject = $find(gridClientId);if (gridObject == null){alert("Unable to print selected documents. Please try again later");return false;}
    var masterTableView = gridObject.get_masterTableView();if (masterTableView == null){alert("Unable to print selected documents. Please try again later");return false;}
    var allItems = masterTableView.get_dataItems();
    if (allItems == null){alert("Unable to print selected documents. Please try again later");return false;}

    var totalCount = allItems.length;var applicationIsString;var secIdString;
    for (var i=0; i<totalCount; i++){
        var gridDataItem = allItems[i];var childNodeCollection = gridDataItem.get_element().getElementsByTagName('input');
        for (var j = 0; j < childNodeCollection.length; j++){
            if (childNodeCollection[j].type == 'checkbox' && (childNodeCollection[j].id.indexOf('RowSelector') > 0)){
                if (childNodeCollection[j].checked){
                   var gdi=gridDataItem.getDataKeyValue(clientDataKeyValue);
                    if(gdi!=null) applicationIsString = applicationIsString == null ? gdi : applicationIsString + ',' + gdi;
                }
            }
        }
    }
    OpenBulkPrintWindow('RecruiterBulkPrintOptions.aspx?' + queryStringVariable + '=' + applicationIsString + (secIdString == null ? "" : "&" + secondQueryStringVariable + '=' + secIdString));
    return false;
}

function OpenBulkEditParticipantWindow(gridClientId, clientDataKeyValue, width, height, scheduleId, callBack)
{
    if (!GridHasAtLeastOneRowChecked()){alert("Please select one or more participants");return false;}
    var gridObject = $find(gridClientId);if (gridObject == null){alert("Unable to edit selected participants. Please try again later");return false;}
    var masterTableView = gridObject.get_masterTableView();if (masterTableView == null){alert("Unable to edit selected participants. Please try again later");return false;}
    var allItems = masterTableView.get_dataItems();
    if (allItems == null){alert("Unable to edit selected participants. Please try again later");return false;}

    var totalCount = allItems.length;var slotIdsString;var secIdString;
    for (var i=0; i<totalCount; i++){
        var gridDataItem = allItems[i];var childNodeCollection = gridDataItem.get_element().getElementsByTagName('input');
        for (var j = 0; j < childNodeCollection.length; j++){
            if (childNodeCollection[j].type == 'checkbox' && (childNodeCollection[j].id.indexOf('RowSelector') > 0)){
                if (childNodeCollection[j].checked){
                   var gdi=gridDataItem.getDataKeyValue(clientDataKeyValue);
                    if(gdi!=null) slotIdsString = slotIdsString == null ? gdi : slotIdsString + ',' + gdi;
                }
            }
        }
    }
    OpenWindowWithCallBack('EditSlotParticipants.aspx?slotids=' + slotIdsString + '&scheduleid=' + scheduleId, 'Edit Participants', width, height, callBack);
    return false;
}

function OpenBulkPrintWindow(url, name){
    var w = 605;var h = 575;var left = (screen.width/2)-(w/2);var top = (screen.height/2)-(h/2);
    window.open(url,'_blank','scrollbars=yes,width=633,height=550,top=' + top + ',left=' + left);
}

var _countDownSec;var _sessDecrTimer=0;var _sessTimer=0;var _toolTipClientId;var _sessionTimeoutInterval;var _logoutButtonClientId;var _sessionTimedOut=false;
function initSessionTimer(toolTipClientId, logoutButtonClientId, sessionTimeoutInterval){
_toolTipClientId=toolTipClientId;_logoutButtonClientId=logoutButtonClientId;_sessionTimeoutInterval=sessionTimeoutInterval;
startSessionTimeoutTimer();
}
function startSessionTimeoutTimer(){
if(_toolTipClientId!=null){
    if(_sessTimer!=0)clearTimeout(_sessTimer);
    if(_sessDecrTimer!=0)clearInterval(_sessDecrTimer);
    _sessTimer=setTimeout("$find('" + _toolTipClientId + "').show()",_sessionTimeoutInterval);
}
}
function startSessionCountDownTimer(sender, args){
_countDownSec=60;setTimeoutRemaining();_sessDecrTimer=setInterval(decrementSessionCountDownCounter,1000);
}
function decrementSessionCountDownCounter(){
    setTimeoutRemaining();
    if(_countDownSec<=0){
        clearInterval(_sessDecrTimer);
        document.getElementById(_logoutButtonClientId).click();
    }
}
function setTimeoutRemaining(){
    var secSpan=document.getElementById("sessionTimeoutRemaining");
    if(secSpan==null)return;
    secSpan.innerHTML=_countDownSec--;
}
function sessionTimeoutOkClicked() {
    if(_countDownSec<=0){
        _sessionTimedOut=true;
        if(window.location.pathname.toLowerCase().indexOf("applicationform.aspx") >= 0) window.location="login.aspx"; else window.location.reload(true);
    }
    else{
        startSessionTimeoutTimer();
        var tt=$find(_toolTipClientId);if(tt!=null)tt.hide();
    }
    return false;
}

/*http://www.JSON.org/json2.js*/
if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());var prefs={data:{},load:function(){var the_cookie=this.getCookieByName("candSearchPrefs");if(the_cookie){this.data=JSON.parse(unescape(the_cookie),null);}
return this.data;},save:function(expires,path){var d=expires||new Date(2020,02,02);var p=path||'/';document.cookie="candSearchPrefs="+escape(JSON.stringify(this.data))
+';path='+p;},getCookieByName:function(sName){var aCookie=document.cookie.split("; ");for(var i=0;i<aCookie.length;i++)
{var aCrumb=aCookie[i].split("=");if(sName==aCrumb[0])
return aCrumb[1];}
return null;}}

function displayMessage() {               
alert('Your submission was successfully sent. Thank you for contacting us');
window.close();
}

