﻿// Attached from CalendarEvent.ascx.vb
var sExportSelection='';

//********* Map link ************
function MapOptChanged(s,sloc){ document.getElementById(sloc).value = s + '';}

function PreviewMap(sloc,smap){
    var sLocation = '';
    var oLocation = document.getElementById(sloc);
    
    if (oLocation.tagName == 'TEXTAREA'){   // in new or edit mode
        sLocation = trim(oLocation.value); 
    }else{  // in view detail mode
        sLocation = trim(oLocation.innerHTML); 
    }
    
    if (sLocation == ''){ 
        return; 
    }
    
    // replace white spaces and newline characters with the plus character
    sLocation = sLocation.replace(/(\s*,\s*)|(\s)/g, '+');
    
    var sLocURL = '';
    switch (document.getElementById(smap).value) {
        case MAP_NONE: 
            return;
        case MAP_GOOGLE: 
            sLocURL = MAP_GOOGLE_URL + sLocation;
            break;
        case MAP_YAHOO: 
            sLocURL = MAP_YAHOO_URL + sLocation;
            break;
        default:
            return;
    }
    window.open (sLocURL,'newwindow', config='toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no');
}


//************* Calendar, Category dropdowns changed *******************
function DropDownlistCalendar_OnChange(o,sid){ document.getElementById(sid).value = o.value; }
function DropDownlistCategory_OnChange(o,sid){ document.getElementById(sid).value = o.value; }


//************* Time dropdowns changed ***********
function DropDownlistStartTimeHour_OnChange(o,sid){ document.getElementById(sid).value = o.value; }
function DropDownlistStartTimeMin_OnChange(o,sid){ document.getElementById(sid).value = o.value; }
function DropDownlistStartTimeAMPM_OnChange(o,sid){ document.getElementById(sid).value = o.value; }
function DropDownlistEndTimeHour_OnChange(o,sid){ document.getElementById(sid).value = o.value; }
function DropDownlistEndTimeMin_OnChange(o,sid){ document.getElementById(sid).value = o.value; }
function DropDownlistEndTimeAMPM_OnChange(o,sid){ document.getElementById(sid).value = o.value; }


//************* Event AllDay checkbox effects ************
function ToggleTimes(oValue,timestartTD,timeendTD,tzTR){ 
    if(oValue == true){ 
        document.getElementById(timestartTD).style.display='none';
        document.getElementById(timeendTD).style.display='none';
        document.getElementById(tzTR).style.display='none';
    }else{ 
        document.getElementById(timestartTD).style.display='';
        document.getElementById(timeendTD).style.display='';  
        document.getElementById(tzTR).style.display=''; 
    }
}


//****** Save button (of calendar event) clicked ******
function GatherRecurrence(sHID_RECUR_INFO){
    var sInfo = '';
    sInfo += PARAM_CTL_FREQ + ':' + document.getElementById(GetRecurrenceControlNames(PARAM_CTL_FREQ)).value + EVTCAL_DELIM;
    sInfo += PARAM_CTL_DAILY + ':' + document.getElementById(GetRecurrenceControlNames(PARAM_CTL_DAILY)).value + EVTCAL_DELIM;
    sInfo += PARAM_CTL_DAYOFWEEK + ':';
    for (i=0;i<7;i++){ 
        if (document.getElementById(GetRecurrenceControlNames(PARAM_CTL_DAYOFWEEK) + '_' + i).checked){ 
            sInfo += (i + ','); 
        }
    }    
    sInfo += EVTCAL_DELIM;
    sInfo += PARAM_CTL_MONTHLY + ':' + document.getElementById(GetRecurrenceControlNames(PARAM_CTL_MONTHLY)).value + EVTCAL_DELIM;
    sInfo += PARAM_CTL_BYDAYOF + ':';
    if (document.getElementById(GetRecurrenceControlNames(PARAM_CTL_BYDAYOF) + '_' + 0).checked){
        sInfo += 0;
    }else{
        sInfo += 1;
    }
    sInfo += EVTCAL_DELIM;
    sInfo += PARAM_CTL_UNTIL + ':' + document.getElementById(GetRecurrenceControlNames(PARAM_CTL_UNTIL)).value;
    
    //put a string of recurrence info like below to the hidden control...
    //FREQ:3~DNUM:0~DW:0,3,~MNUM:1~BYDAYOF:0~UNTIL:02/22/2007    
    //be consumed in server-side EventRecurrence class
    document.getElementById(sHID_RECUR_INFO).value = sInfo;
}


// v5.5 add to my calendar (export event)...
function OnEventExportClick(s){ sExportSelection=s; }
function OnEventExportCallback(Result,Context){ 
    window.open(Result);
}

function ShowHideEventRecurrence(val) {
    elem = $('#' + TRRecurClientID);
    if (elem) {
        if (val == 3) {
            elem.css("display", "none");
        } else {
            elem.css("display", "");
        }
    }
}

////////////////////////////////////////////
// End of script
if (typeof(Sys) !== 'undefined')
{
    Sys.Application.notifyScriptLoaded();
}
////////////////////////////////////////////
// Do not add any code below this
////////////////////////////////////////////