﻿function OpenEventPreview(URL) {
    var oWin = window.open(URL, "PreviewEvents");
    oWin.opener = self;
}

function OpenEventHistory(EventID) {
    var oWin = window.open("/Events/ViewEventHistory.aspx?EventID=" + EventID, "HistoryEvents", "toolbar=0,menu=0,width=550,height=650,scrollbars=1");
    oWin.opener = self;
}

function OpenCreateThumbnail(FileRepositoryID, FileRepositoryType, ImageObj, ImageSize, Width, Height) {
    var oWin = window.open("/Events/Thumbnail.aspx?FileRepositoryID=" + FileRepositoryID + "&FileRepositoryType=" + FileRepositoryType + "&ImageSize=" + ImageSize + "&Image=" + ImageObj, "HistoryEvents", "toolbar=0,menu=0,width=500,height=300,scrollbars=1");
    oWin.opener = self;
    oWin.focus();
}

function WindowClose() {
    window.close();
}

function OpenPrivacyPolicy() {
    var oWin = window.open("/PrivacyPolicy.aspx", "PrivacyPolicy", "toolbar=0,menu=0,width=550,height=650,scrollbars=1");
    oWin.opener = self;
}

function OpenTermsOfUse() {
    var oWin = window.open("/TermsOfUse.aspx", "TermsOfUse", "toolbar=0,menu=0,width=550,height=650,scrollbars=1");
    oWin.opener = self;
}


function ToggleValidator(validator, Enable) {
    if (typeof (Page_Validators) == "undefined")
        return;

    if (validator == null)
        return;

    ValidatorEnable(validator, Enable);
}


function ResetValidators(ForGroup) {
    if (typeof (Page_Validators) != "undefined") {
        var i;
        for (i = 0; i < Page_Validators.length; i++) {
            var val = Page_Validators[i];
            val.isvalid = true;

            if (val.validationGroup == ForGroup) 
            {
                ValidatorUpdateDisplay(val);
                val.display = 'None';
            }
        }
       // Page_IsValid = true;
        ValidationSummaryOnSubmit(ForGroup);
    }
}

function DateAdd(timeU, byMany, dateObj) {
    var millisecond = 1;
    var second = millisecond * 1000;
    var minute = second * 60;
    var hour = minute * 60;
    var day = hour * 24;
    var year = day * 365;

    var newDate;
    var dVal = dateObj.valueOf();
    switch (timeU) {
        case "ms": newDate = new Date(dVal + millisecond * byMany); break;
        case "s": newDate = new Date(dVal + second * byMany); break;
        case "mi": newDate = new Date(dVal + minute * byMany); break;
        case "h": newDate = new Date(dVal + hour * byMany); break;
        case "d": newDate = new Date(dVal + day * byMany); break;
        case "y": newDate = new Date(dVal + year * byMany); break;
    }
    return newDate;
}
