﻿function windowopen() {
    var n = screen.width / 2 - 300;
    var s = 'left=' + n;
    window.open('AboutCVV.htm', 'cvvaboutwindow', 'width=600,height=360,' + s + ',top=200');
}


function OnClick1() {
    var x = document.getElementById("divCalendarSt");
    if (x.style.display == 'none')
        x.style.display = ''; else x.style.display = 'none';
}

function ChangeDate1() {
    Dateent = window.ASPxCalendar1.GetSelectedDate();
    var month = Dateent.getMonth() + 1;
    var day = Dateent.getDate();
    if (month < 10)
        window.txtStartDate.SetText('0' + month + '/' + day + '/' + Dateent.getFullYear());
    if (day < 10)
        window.txtStartDate.SetText(month + '/0' + day + '/' + Dateent.getFullYear());
    if (day < 10 && month < 10)
        window.txtStartDate.SetText('0' + month + '/0' + day + '/' + Dateent.getFullYear());
    var x = document.getElementById("divCalendarSt");
    x.style.display = 'none';

}

function chkDoc() {
    Stage = 0;
    if (window.txtZIP.GetText() != '')
        window.Callback1.PerformCallback('check'); else
        alert('Please enter ZIP code below ...');
}

function ValidationComplete(s, e) {
    if (Stage == 1) {
        if (e.result == 'OK') {
            var x = window.confirm('The doctor is available. Please confirm requested appointment time.')
            if (x) {
                window.Callback2.PerformCallback('pending');
            }
            else {
                window.Callback2.PerformCallback('recalled');
            }
        } else
            if (e.result == 'fail') {
            alert('Doctor is not available within next 72 hours. Please come back later and check again.');
        }
        else {
            var x = window.confirm('We are sorry, there is no doctor available for the requested time, but one of our doctors will be available ' + e.result + '. Woudl you like to proceed?')
            if (x) {
                window.Callback2.PerformCallback('pending');
            }
            else {
                window.Callback2.PerformCallback('recalled');
            }
        }
    }
    if (Stage == 0) {
        if (e.result == 'OK') {
            window.confirm('The doctor is available.')
        } else
            if (e.result == 'fail') {
            alert('Doctor is not available within next 72 hours. Please come back later and check again.');
        }
        else {
            window.confirm('We are sorry, there is no doctor available for the requested time, but one of our doctors will be available ' + e.result + '.')
        }
    }
}

function ValidationComplete2(s, e) {
    if (e.result == 'OK') {
        location.replace('thankyou.aspx');
    } else {
        location.replace('failed.aspx');
    }
}

function SendOrder() {
    Stage = 1;
    if (window.txtZIP.GetText() != '' && Page_IsValid) {
        window.Callback1.PerformCallback('check');
    }
    else {
        alert('Please enter required fields correctly ...');
    }
}

var Stage;

$(function() {
    var $rbSameAddressYes = $('[id$="_rbSameAddressYes"]');
    $rbSameAddressYes.change(rbSameAddressYes_changed);
});

function rbSameAddressYes_changed() {
    var checked = $(this).attr('checked');
    if (checked) {
        var $tbFirstName = $('[id$="_tbFirstName"]');
        var $tbLastName = $('[id$="_tbLastName"]');
        var $tbCardName = $('[id$="_tbCardName"]');
        var $tbStreet = $('[id$="_tbStreet"]');
        var $tbCardStreet = $('[id$="_tbCardStreet"]');
        var $tbCity = $('[id$="_tbCity"]');
        var $tbCardCity = $('[id$="_tbCardCity"]');
        var $tbRoom = $('[id$="_tbRoom"]');
        var $tbCardRoom = $('[id$="_tbCardRoom"]');
        var $ddlState = $('[id$="_ddlState"]');
        var $ddlCardState = $('[id$="_ddlCardState"]');
        var $txtZIP = $('[id$="_txtZIP_I"]');
        var $tbCardZip = $('[id$="_tbCardZip"]');
        $tbCardName.val($tbFirstName.val().toUpperCase() + ' ' + $tbLastName.val().toUpperCase());
        $tbCardStreet.val($tbStreet.val());
        $tbCardCity.val($tbCity.val());
        $tbCardRoom.val($tbRoom.val());
        $ddlCardState.val($ddlState.val());
        $tbCardZip.val($txtZIP.val());
    }
}
