﻿/*
    Edit Scripts for Members
*/

var GarageHandlerUrl = "/appmain/handler/UserGarageHandler.asp"
var NewVecDataHandlerUrl = "/appmain/handler/newVecDataHandler.asp"
var NewVecPicCompareHandlerUrl = "/appmain/handler/newVecPicAdminCompare.asp"
var removeVecPicHandlerUrl = "/appmain/handler/removePicHandler.asp"
var removeUserHandlerUrl = "/appmain/handler/removeUserHandler.asp"

    function addVecToGarage(vecID) {
    var buttonsOpts = {}
    buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
    buttonsOpts[strLang_SaveButton] = function () {
        $dialog.load(GarageHandlerUrl + "?action=addVecToUserGarage&VecID=" + vecID + "&GarageID=" + document.getElementById('LinkVecToGarage').value);
        $dialog.dialog({ buttons: { OK: function () { $dialog.dialog('close'); } } });
        };

        $dialog.load(GarageHandlerUrl+"?action=addGarageDialog&id="+vecID);
        $dialog.dialog({ title: strLang_SaveVecInGarageTitle });
        $dialog.dialog({ buttons: buttonsOpts });
        $dialog.dialog('open');
    }

    function removeUser() {
        var buttonsOpts = {} 
        buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
        buttonsOpts[strLang_ProcedButton] = function () { $dialog.load(removeUserHandlerUrl + "?action=removeUser"); $dialog.dialog({ buttons: { OK: function () { $dialog.dialog('close'); location.reload(); } } }) };

        $dialog.load(removeUserHandlerUrl + "?action=NewDialog");
        $dialog.dialog({ title: strLang_RemoveMyAccountTitle });
        $dialog.dialog({ buttons: buttonsOpts});
        $dialog.dialog('open');
    }

    function removeUserGarage(GarageName, GarageID) {
        var buttonsOpts = {}
        buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
        buttonsOpts[strLang_RemoveButton] = function () {
                $dialog.load(GarageHandlerUrl + "?action=RemoveGarage&GarageID=" + GarageID);
                $dialog.dialog({ buttons: { 'OK': function () { $dialog.dialog('close'); location.reload(); } } });
             };

        $dialog.html('<p>'+strLang_ConfirmRemoveFromGarage1Text+' "' + GarageName + '" '+strLang_ConfirmRemoveFromGarage2Text+'</p>');
        $dialog.dialog({ title: strLang_RemoveGarageTitle });
        $dialog.dialog({ buttons: buttonsOpts});
        $dialog.dialog('open');
    }

    function compareVecPics(NewPicAdress, OldPicAdress) {
        var buttonsOpts = {}
        buttonsOpts[strLang_CloseButton] = function () { $dialog.dialog('close'); };

        $dialog.load(NewVecPicCompareHandlerUrl + "?action=compareVecPic&NewPicAdress=" + NewPicAdress + "&OldPicAdress=" + OldPicAdress);
        $dialog.dialog({ title: strLang_CompareUploadedPictureTitle });
        $dialog.dialog({ height: 450 });
        $dialog.dialog({ width: 800 });
        $dialog.dialog({ buttons: buttonsOpts });
        $dialog.dialog('open');
    }

    function removeVecPic(vecID) {
        var VecDataID = vecID
        var buttonsOpts = {}
        buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
        buttonsOpts[strLang_RemoveButton] = function () {
                $dialog.load(removeVecPicHandlerUrl + "?action=doRemove&ID=" + VecDataID);
                $dialog.dialog({ buttons: { 'OK': function () { $dialog.dialog('close'); getVecData("id=" + VecDataID); } } });
            };

        $dialog.load(removeVecPicHandlerUrl + "?action=RemovePic&id=" + vecID);
        $dialog.dialog({ title: strLang_RemovePictureTitle });
        $dialog.dialog({ height: 450 });
        $dialog.dialog({ width: 470 });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }

    function removeVecFromUserGarage(LinkID, GarageID, GarageName) {
        var buttonsOpts = {}
        buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
        buttonsOpts[strLang_RemoveButton] = function () {
                $dialog.load(GarageHandlerUrl+"?action=removeVecFromUserGarage&linkID=" + LinkID + "&GarageID=" + GarageID);
                $dialog.dialog({ buttons: { 'OK': function () { $dialog.dialog('close'); location.reload(); } } });
            };

        $dialog.html('<p>'+strLang_ConfirmRemoveVecFromGarage1Text+' "' + GarageName + '"?</p>');
        $dialog.dialog({ title: strLang_RemoveVecFromGarageTitle });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }

    function addNewVecData(vecID) {
        var buttonsOpts = {}
        buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
        buttonsOpts[strLang_SendButton] = function () {
                $dialog.load(NewVecDataHandlerUrl + "?RememberCurrentUser=" + document.getElementById('RememberCurrentUser').checked + "&action=NewVecData&VecID=" + vecID + "&Ue=" + encodeCharsForAjax(document.getElementById('UserEmail').value) + "&UserID=" + encodeCharsForAjax(document.getElementById('UserID').value) + "&nvd=" + encodeCharsForAjax(document.getElementById('NewVecData').value));
                $dialog.dialog({ buttons: { strLang_OKButton: function () { $dialog.dialog('close'); } } });
            };

        $dialog.load(NewVecDataHandlerUrl+"?action=NewVecDialog&id=" + vecID);
        $dialog.dialog({ title: strLang_CreateAdditionTitle });
        $dialog.dialog({ height: 350 });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }

    function CreateNewGarage() {
        var buttonsOpts = {}
        buttonsOpts[strLang_AbortButton] = function () { $dialog.dialog('close'); };
        buttonsOpts[strLang_CreateButton] = function () {
            $dialog.load(GarageHandlerUrl + "?action=addgarage&GarageName=" + encodeCharsForAjax(document.getElementById('GarageName').value));
            $dialog.dialog({ buttons: { 'OK': function () { $dialog.dialog('close'); location.reload(); } } });
        };

        $dialog.html('<p>'+strLang_ToCreateANewGarageEnterTheNameForItText+'</p><fieldset><label for="GarageName">'+strLang_GarageNameLabel+'</label><input size="35" class=text type=text name="GarageName" id="GarageName" maxlength="45"></fieldset>')
        $dialog.dialog({ title: strLang_CreateNewGarageTitle });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }

    function createUserMessageService(GarageID, GarageName) {
        var buttonsOpts = {}
        buttonsOpts[strLang_OKButton] = function () { $dialog.dialog('close'); location.reload();  };

        $dialog.load(GarageHandlerUrl + "?action=addGarageToMessageService&id=" + GarageID+"&garagename=");
        $dialog.dialog({ title: strLang_WatchStartedTitle });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }

    function RemoveUserMessageService(GarageID, GarageName) {
        var buttonsOpts = {}
        buttonsOpts[strLang_OKButton] = function () { $dialog.dialog('close'); location.reload(); };

        $dialog.load(GarageHandlerUrl + "?action=RemoveGarageFromMessageService&id=" + GarageID+"&garagename=");
        $dialog.dialog({ title: strLang_WatchEndedTitle });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }
    
    function sendUserUpdatesToAdmin(UpdateID) {
        var buttonsOpts = {}
        buttonsOpts[strLang_SendButton] = function () { doSendUserAdditionData(UpdateID, document.getElementById('AdditionMessage').value); };
        buttonsOpts[strLang_CloseButton] = function () { $dialog.dialog('close'); location.reload(); };

        $dialog.load(NewVecDataHandlerUrl + "?action=SendUserUpdateDataToMe&VecUpdateID=" + UpdateID);
        $dialog.dialog({ title: strLang_SendAdditionsToMeTitle });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }

    function doSendUserAdditionData(UpdateID,Message) {
        var buttonsOpts = {}
        buttonsOpts[strLang_OKButton] = function () { $dialog.dialog('close'); };

        $dialog.load(NewVecDataHandlerUrl + "?action=createMessage&VecUpdateID=" + UpdateID + "&message=" + encodeCharsForAjax(Message));
        $dialog.dialog({ title: strLang_MessageSentTitle });
        $dialog.dialog({ buttons: buttonsOpts })
        $dialog.dialog('open');
    }
