﻿var JSreturnValue = "";
function openSeatchart(teamid) {
    window.open('seatchart.aspx?teamid=' + teamid, 'newwindow', 'height=600, width=550, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no');

}
function openPrintPage(page) {
    window.open(page, 'newwindow', 'height=600, width=550, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no');

}

function anotherverify() {
    var img = document.getElementById("img_verifycode");
    img.src = img.src + '?';
}

function countDown(secs, surl) {
    //jumpTo.innerText = secs;
    if (--secs > 0) {
        setTimeout("countDown(" + secs + ",'" + surl + "')", 1000);
    }
    else {
        location.href = surl;
    }
}

function logout() {
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=logout",
        success: function(msg) {
            if (msg == "true") {
                document.location = "thequb.aspx?show=cardholder";
            }
        },
        error: function() {
            alert("Bad Request.");
        }
    });
}

function SeasonTicketTypeSelectedChanged() {
    var TicketType = 0, Section1 = 0, Section2 = 0, TeamID = 0;
    TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }
    UnableSeasonTicketControl();
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=SeasonTicketPrice&TeamID=" + TeamID + "&TicketType=" + TicketType + "&Section1=" + Section1 + "&Section2=" + Section2,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            document.getElementById("div_price").innerHTML = msgs[1];
            EnableSeasonTicketControl();
        },
        error: function() {
            alert("Bad Request.");
            EnableSeasonTicketControl();
        }
    });
}

function PlayoffTicketTypeSelectedChanged() {
    var TicketType = 0, Section1 = 0, Section2 = 0, TeamID = 0;
    TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }
    UnableSeasonTicketControl();
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=PlayoffTicketPrice&TeamID=" + TeamID + "&TicketType=" + TicketType + "&Section1=" + Section1 + "&Section2=" + Section2,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            document.getElementById("div_price").innerHTML = msgs[1];
            EnableSeasonTicketControl();
        },
        error: function() {
            alert("Bad Request.");
            EnableSeasonTicketControl();
        }
    });
}




function SeasonTicketSection1SelectedChanged() {
    var PackageID = 0, TicketType = 0, Section1 = 0, Section2 = 0, TeamID = 0;
    //TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec1").value = Section1;
    UnableSeasonTicketControl();
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        //"&TicketType=" + TicketType +
        data: "name=SeasonTicketPrice_Section1&TeamID=" + TeamID + "&Section1=" + Section1 + "&Section2=" + Section2,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            //document.getElementById("div_price").innerHTML = msgs[1];
            document.getElementById("div_Section2").innerHTML = msgs[2];
            if (Section1.length > 0 && Section1 != "0") {
                document.getElementById("div_Section2").style.display = "block";
            }
            else {
                document.getElementById("div_Section2").style.display = "none";
            }



            EnableSeasonTicketControl();
        },
        error: function() {
            alert("Bad Request.");
            EnableSeasonTicketControl();
        }
    });
}

function SeasonTicketSection2SelectedChanged() {
    UnableSeasonTicketControl();
    var Section1 = "", Section2 = "";
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec1").value = Section1;
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec2").value = Section2;
    EnableSeasonTicketControl();
}

function PlayoffTicketSection1SelectedChanged() {
    var PackageID = 0, TicketType = 0, Section1 = 0, Section2 = 0, TeamID = 0;
    //TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec1").value = Section1;
    UnableSeasonTicketControl();
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=PlayoffTicketPrice_Section1&TeamID=" + TeamID + "&Section1=" + Section1 + "&Section2=" + Section2,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            //document.getElementById("div_price").innerHTML = msgs[1];
            document.getElementById("div_Section2").innerHTML = msgs[2];
            if (Section1.length > 0 && Section1 != "0") {
                document.getElementById("div_Section2").style.display = "block";
            }
            else {
                document.getElementById("div_Section2").style.display = "none";
            }



            EnableSeasonTicketControl();
        },
        error: function() {
            alert("Bad Request.");
            EnableSeasonTicketControl();
        }
    });
}

function PlayoffTicketSection2SelectedChanged() {
    UnableSeasonTicketControl();
    var Section1 = "", Section2 = "";
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec1").value = Section1;
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec2").value = Section2;
    EnableSeasonTicketControl();
}







function searchSeasonTicket() {
    var PackageID = 0, TicketType = 0, Section1 = 0, Section2 = 0, TeamID = 0, Quantity = 0, PriceID = 0;
    TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    PriceID = document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").value;
    Quantity = document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").value;

    UnableSeasonTicketControl();

    if (Quantity.length <= 0) {
        alert("Please input a ticket quantity from the input box.");
        EnableSeasonTicketControl();
        document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").focus();
        return;
    }
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }


    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=SearchSeasonTicket&TeamID=" + TeamID + "&TicketType=" + TicketType + "&Section1=" + Section1 + "&Section2=" + Section2 + "&PriceID=" + PriceID + "&Quantity=" + Quantity,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            document.location = "SecurityCheck.aspx";
            //EnableSeasonTicketControl();
        },
        error: function() {
            alert("Bad Request.");

            EnableSeasonTicketControl();
        }
    });
}

function searchPlayoffTicket() {
    var PackageID = 0, TicketType = 0, Section1 = 0, Section2 = 0, TeamID = 0, Quantity = 0, PriceID = 0;
    TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    PriceID = document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").value;
    Quantity = document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").value;

    UnableSeasonTicketControl();

    if (Quantity.length <= 0) {
        alert("Please input a ticket quantity from the input box.");
        EnableSeasonTicketControl();
        document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").focus();
        return;
    }
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }


    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=SearchPlayoffTicket&TeamID=" + TeamID + "&TicketType=" + TicketType + "&Section1=" + Section1 + "&Section2=" + Section2 + "&PriceID=" + PriceID + "&Quantity=" + Quantity,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            document.location = "SecurityCheck.aspx";
            //EnableSeasonTicketControl();
        },
        error: function() {
            alert("Bad Request.");

            EnableSeasonTicketControl();
        }
    });
}


function TicketTypeSelectedChanged() {

    var TicketType = 0, Section1 = 0, Section2 = 0, MatchID = 0;
    TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    MatchID = document.getElementById("ctl00_ContentPlaceHolder1_lblMatchID").innerHTML;

    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }

    UnableTicketControl();
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=TicketPrice&MatchID=" + MatchID + "&TicketType=" + TicketType + "&Section1=" + Section1 + "&Section2=" + Section2,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            document.getElementById("div_price").innerHTML = msgs[1];
            EnableTicketControl();
        },
        error: function() {
            alert("Bad Request.");

            EnableTicketControl();
        }
    });

}


function TicketSection1SelectedChanged() {

    var TicketType = 0, Section1 = 0, Section2 = 0, MatchID = 0;
    //TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    MatchID = document.getElementById("ctl00_ContentPlaceHolder1_lblMatchID").innerHTML;

    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }

    document.getElementById("ctl00_ContentPlaceHolder1_lblsec1").value = Section1;

    UnableTicketControl();
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=TicketSectionSelectedChanged&MatchID=" + MatchID + "&Section1=" + Section1 + "&Section2=" + Section2,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            //document.getElementById("div_price").innerHTML = msgs[1];
            document.getElementById("div_Section2").innerHTML = msgs[2];
            if (Section1.length > 0 && Section1 != "0") {
                document.getElementById("div_Section2").style.display = "block";
            }
            else {
                document.getElementById("div_Section2").style.display = "none";
            }
            EnableTicketControl();
        },
        error: function() {
            alert("Bad Request.");

            EnableTicketControl();
        }
    });

}

function TicketSection2SelectedChanged() {
    UnableTicketControl();
    var Section1 = "", Section2 = "";
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec1").value = Section1;
    document.getElementById("ctl00_ContentPlaceHolder1_lblsec2").value = Section2;
    EnableTicketControl();
}



function searchTicket() {
    var TicketType = 0, Section1 = 0, Section2 = 0, MatchID = 0, Quantity = 0, PriceID = 0, TeamID = 0;
    TicketType = document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").value;
    Section1 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").value;
    Section2 = document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").value;
    MatchID = document.getElementById("ctl00_ContentPlaceHolder1_lblMatchID").innerHTML;
    TeamID = document.getElementById("ctl00_ContentPlaceHolder1_lblTeamID").innerHTML;
    PriceID = document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").value;
    Quantity = document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").value;
    UnableTicketControl();
    if (Quantity.length <= 0) {
        alert("Please input a ticket quantity from the input box.");
        EnableTicketControl();
        document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").focus();
        return;
    }
    if (Section2 == "" || Section2 == null) {
        Section2 = "";
    }

    if (TeamID == "" || TeamID == null) {
        TeamID = "1";
    }


    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=SearchTicket&TeamID=" + TeamID + "&MatchID=" + MatchID + "&TicketType=" + TicketType + "&Section1=" + Section1 + "&Section2=" + Section2 + "&PriceID=" + PriceID + "&Quantity=" + Quantity,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return;
            }
            document.location = "SecurityCheck.aspx";
            //EnableTicketControl();
        },
        error: function() {
            alert("Bad Request.");

            EnableTicketControl();
        }
    });
}


function chanageProvince() {
    var objCountry = document.getElementById('ctl00_content_ddl_Country');
    var objProvince = document.getElementById('ctl00_content_ddl_State');
    var countryCode = "";
    countryCode = objCountry.value;
    objProvince.disabled = "true";
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=BindProvince&countryCode=" + countryCode,
        success: function(msg) {
            var msgs = msg.split("||");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                objProvince.disabled = "";
                return;
            }
            FillDropDown(objProvince, msgs[1]);
            objProvince.disabled = "";
        },
        error: function() {
            alert("Bad Request.");
            objProvince.disabled = "";
        }
    });



}




function _dosubmit() {
    var objProvince = document.getElementById('ctl00_content_ddl_State');
    var objHFProvince = document.getElementById("ctl00_content_hf_privince_value");
    objHFProvince.value = objProvince.value;
}

























function EnableTicketControl() {
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").disabled = "";
    //document.getElementById("ctl00_ContentPlaceHolder1_rpticket").disabled = "";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").disabled = "";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").disabled = "";
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").disabled = "";
    //document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").disabled = "";
    document.getElementById("ctl00_ContentPlaceHolder1_btn_search").disabled = "";
}



function UnableTicketControl() {
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").disabled = "true";
    //document.getElementById("ctl00_ContentPlaceHolder1_rpticket").disabled = "true";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").disabled = "true";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").disabled = "true";
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").disabled = "true";
    //document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").disabled = "true";
    document.getElementById("ctl00_ContentPlaceHolder1_btn_search").disabled = "true";
}




function EnableSeasonTicketControl() {
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").disabled = "";
    //document.getElementById("ctl00_ContentPlaceHolder1_rpticket").disabled = "";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").disabled = "";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").disabled = "";
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").disabled = "";
    //document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").disabled = "";
    document.getElementById("ctl00_ContentPlaceHolder1_btn_search").disabled = "";
}

function UnableSeasonTicketControl() {
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_pType").disabled = "true";
    //document.getElementById("ctl00_ContentPlaceHolder1_rpticket").disabled = "true";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section").disabled = "true";
    document.getElementById("ctl00_ContentPlaceHolder1_ddl_section2").disabled = "true";
    //document.getElementById("ctl00_ContentPlaceHolder1_ddl_price").disabled = "true";
    //document.getElementById("ctl00_ContentPlaceHolder1_txtTicketCount").disabled = "true";
    document.getElementById("ctl00_ContentPlaceHolder1_btn_search").disabled = "true";
}







function ExecuteAjaxAppendDiv(urlString, param, controlName) {

    $.ajax({
        type: "post",
        url: urlString,
        datatype: "html",
        data: param,
        success: function(msg) {
            document.getElementById(controlName).innerHTML = msg;
        },
        error: function() { alert("Bad Request."); }
    });
}



function FillDropDown(objDDL, result) {
    var piArray = result.split(",");

    objDDL.length = 0;
    objDDL.options.add(new Option("Select Province", ""));
    for (var i = 0; i < piArray.length; i++) {
        var ary1 = piArray[i].toString().split("|");
        //new Option(value,text);
        if (ary1.length > 1)
            objDDL.options.add(new Option(ary1[0].toString(), ary1[1].toString()));
    }
}


function IsNumeric(strString) {
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    for (i = 0; i < strString.length && blnResult == true; i++) {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1) {
            blnResult = false;
        }
    }
    return blnResult;
}

function validateCallback() {

    var name = document.getElementById("txt_name");
    var phone = document.getElementById("txt_phone");
    var besttime = document.getElementById("txt_bestTime");
    var reason = document.getElementById("txt_reason");


    if (name.value == "") {
        alert("Please enter your name before requesting a Call-Back.");
        name.focus();
        return false;
    }

    /*if ((IsNumeric(phone.value) == false)) {
    alert("Please enter your phone number, with area code, before requesting a Call-Back.");
    phone.focus();
    return false;
    }*/
    if (phone.value == "") {
        alert("Please enter your phone number, with area code, before requesting a Call-Back.");
        phone.focus();
        return false;
    }

    if (besttime.value == "") {
        alert("Please let us know the best time to reach you before requesting a Call-Back.");
        besttime.focus();
        return false;
    }
    if (reason.value == "") {
        alert("Please let us know briefly why you are requesting a Call-Back.");
        reason.focus();
        return false;
    }

    name.disabled = "true";
    phone.disabled = "true";
    besttime.disabled = "true";
    reason.disabled = "true";
    document.getElementById("btn_callback").disabled = "true";
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=CallBack&fullname=" + escape(name.value) + "&phone=" + phone.value + "&besttime=" + escape(besttime.value) + "&reason=" + escape(reason.value),
        success: function(msg) {
            name.disabled = "";
            phone.disabled = "";
            besttime.disabled = "";
            reason.disabled = "";
            document.getElementById("btn_callback").disabled = "";
            var msgs = msg.split("||");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return false;
            }
            document.getElementById("div_callback_result").innerHTML = msgs[1];
        },
        error: function() {
            //alert("Bad Request.");
        }
    });
}



function validateContactForm() {
    var fullName = document.getElementById("ctl00_Content_tbx_name");
    var phone_Day = document.getElementById("ctl00_Content_tbx_phone_day");
    var email = document.getElementById("ctl00_Content_tbx_email");
    var message = document.getElementById("ctl00_Content_tbx_message");
    var captcha_code = document.getElementById("ctl00_Content_tbx_verifycode");


    if (fullName.value == "") {
        alert("Please enter your Full Name before sending your message.");
        return false;
    }
    if ((phone_Day.value.length > 0) && (phone_Day.value.length < 10)) {
        alert("Please be sure to enter your full Day-Time phone number, including area code.");
        return false;
    }
    if (email.value.indexOf('@') == -1) {
        alert("Please enter your email address before sending your message.");
        return false;
    }

    if (captcha_code.value == "") {
        alert("Please copy the Confirmation Code into the appropriate field.");
        captcha_code.focus();
        return false;
    }

    fullName.disabled = "true";
    phone_Day.disabled = "true";
    email.disabled = "true";
    message.disabled = "true";
    captcha_code.disabled = "true";
    document.getElementById("btn_submit").disabled = "true";

    var paramData = "name=Contact&fullname=" + escape(fullName.value);
    paramData += "&phone_Day=" + escape(phone_Day.value);
    paramData += "&email=" + escape(email.value);
    paramData += "&message=" + escape(message.value);


    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: paramData,
        success: function(msg) {
            fullName.disabled = "";
            phone_Day.disabled = "";
            email.disabled = "";
            message.disabled = "";
            document.getElementById("btn_submit").disabled = "";
            var msgs = msg.split("||");
            if (msgs[0] != "true") {
                alert(msgs[1]);
                return false;
            }
            alert(msgs[1]);
            document.location = "contact.aspx";
        },
        error: function() { alert("Bad Request."); }
    });
}

function show_table() {
    var div_scheduling = document.getElementById('Div_Scheduling');
    var div_message = document.getElementById('Div_message');
    var subject = document.getElementById("ctl00_Content_ddl_subject");

    if (subject.value == "Scheduling") {
        div_scheduling.style.display = 'block';
        div_message.style.display = 'none';
    }
    else {
        div_scheduling.style.display = 'none';
        div_message.style.display = 'block';
    }
}

function closeDIV(divName) {
    document.getElementById("LoadDiv").style.display = 'none';

}

function LoadVoucherDIV(evt) {
    var ObjDiv = document.getElementById("LoadDiv");
    var loadContent = document.getElementById("loadContent");
    ObjDiv.style.display = '';

    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";

    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=VoucherFailedTimes",
        success: function(msg) {
            if (msg != "") {
                if (msg >= 3) {
                    loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />This function has been disabled.</span>";
                } else {
                    loadContent.innerHTML = "Please input your voucher card #:<br /><br />";
                    loadContent.innerHTML += "<input id=\"txtVoucherCardID\" type=\"text\" />";
                    loadContent.innerHTML += "<div style=\"width: 100%; text-align: center; top: 15px; position: relative;\">";
                    loadContent.innerHTML += "<input id=\"btnsub\" type=\"button\" value=\"Submit\" style=\"cursor: pointer;\" onclick=\"return getVoucher();\" />";
                    loadContent.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    loadContent.innerHTML += "<input id=\"btncancel\" type=\"button\" value=\"Cancel\" style=\"cursor: pointer;\" onclick=\"closeDIV('LoadDIV');\" /></div>";
                }
            } else {
                loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
            }
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
        }
    });

}

function LoadCardDIV(cartid) {
    var ObjDiv = document.getElementById("LoadDiv");
    var loadContent = document.getElementById("loadContent");
    var height = document.body.clientHeight;
    var width = document.body.clientWidth;

    var newX = 460;

    var newY = 400;


    ObjDiv.style.left = newX + "px";

    ObjDiv.style.top = newY + "px";
    ObjDiv.style.width = "200px";
    ObjDiv.style.height = "180px";
    ObjDiv.style.display = '';

    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";

    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=EditCard&CartID=" + cartid,
        success: function(msg) {
            var msgs = msg.split("||");
            if (msgs[0] == "true") {
                loadContent.innerHTML = "<br /><b>Card Number:</b><br />";
                loadContent.innerHTML += "<br /><input type=\"text\" id=\"tbxCardID\" value=\"" + msgs[1] + "\" /><br />";
                loadContent.innerHTML += "<br /><input type=\"button\" id=\"btnsub\" value=\"Submit\" style=\"cursor:pointer;\" onclick=\"return EditCardNumber(" + cartid.toString() + ");\"/>";
                loadContent.innerHTML += "&nbsp;&nbsp;<input type=\"button\" id=\"btncancel\" value=\"Cancel\" style=\"cursor:pointer;\" onclick=\"closeDIV('LoadDIV');\"/>";
            }
            else {
                loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
            }
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
        }
    });

}

function EditCardNumber(cartid) {
    var cardid = document.getElementById("tbxCardID").value;

    if (cardid.length <= 0) {
        alert("Please input a card number.");
        return false;
    }
    if (cardid.length < 12 || !IsNumeric(cardid)) {
        alert("Invalid Card number.");
        return false;
    }

    var loadContent = document.getElementById("loadContent");
    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";

    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=EditCardNumber&CardID=" + cardid + "&CartID=" + cartid.toString(),
        success: function(msg) {
            var msgs = msg.split("||");
            if (msgs[0] == "true") {
                closeDIV("LoadDIV");
                alert("Edit card number successfully.");
                window.location.href = window.location.href;
            }
            else {
                loadContent.innerHTML = "<span style=\"text-align:left;color:red;\">" + msgs[1] + "</span>";
                loadContent.innerHTML += "<br /><b>Card Number:</b><br />";
                loadContent.innerHTML += "<br /><input type=\"text\" id=\"tbxCardID\" value=\"" + cardid + "\" /><br />";
                loadContent.innerHTML += "<br /><input type=\"button\" id=\"btnsub\" value=\"Submit\" style=\"cursor:pointer;\" onclick=\"return EditCardNumber(" + cartid.toString() + ");\"/>";
                loadContent.innerHTML += "&nbsp;&nbsp;<input type=\"button\" id=\"btncancel\" value=\"Cancel\" style=\"cursor:pointer;\" onclick=\"closeDIV('LoadDIV');\"/>";
            }
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />* There are some errors, please try again.</span>";
            loadContent.innerHTML += "<br /><b>Card Number:</b><br />";
            loadContent.innerHTML += "<br /><input type=\"text\" id=\"tbxCardID\" value=\"" + cardid + "\" /><br />";
            loadContent.innerHTML += "<br /><input type=\"button\" id=\"btnsub\" value=\"Submit\" style=\"cursor:pointer;\" onclick=\"return EditCardNumber(" + cartid.toString() + ");\"/>";
            loadContent.innerHTML += "&nbsp;&nbsp;<input type=\"button\" id=\"btncancel\" value=\"Cancel\" style=\"cursor:pointer;\" onclick=\"closeDIV('LoadDIV');\"/>";
        }
    });

}





function getVoucher() {
    var voucherCard = document.getElementById("txtVoucherCardID").value;
    //var matchID = document.getElementById("tbxmatchID").value;
    var teamID = document.getElementById("tbxteamID").value;

    if (voucherCard.length <= 0) {
        alert("Please input a voucher card id.");
        return false;
    }
    if (voucherCard.length < 12 || !IsNumeric(voucherCard)) {
        alert("You input the voucher card id is invalid.");
        return false;
    }
    var loadContent = document.getElementById("loadContent");
    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";

    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=VoucherLogin&cardid=" + voucherCard + "&teamID=" + teamID,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] != "true") {
                if (msgs[0] == "forbid") {
                    loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />" + msgs[1] + "</span>";
                    return false;
                }
                else {
                    loadContent.innerHTML = "<span style=\"color: Red;\">" + msgs[1] + "</span><br />";
                    loadContent.innerHTML += "Please input your voucher card #:<br /><br />";
                    loadContent.innerHTML += "<input id=\"txtVoucherCardID\" type=\"text\" />";
                    loadContent.innerHTML += "<div style=\"width: 100%; text-align: center; top: 15px; position: relative;\">";
                    loadContent.innerHTML += "<input id=\"btnsub\" type=\"button\" value=\"Submit\" style=\"cursor: pointer;\" onclick=\"return getVoucher();\" />";
                    loadContent.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    loadContent.innerHTML += "<input id=\"btncancel\" type=\"button\" value=\"Cancel\" style=\"cursor: pointer;\" onclick=\"closeDIV('LoadDIV');\" /></div>";

                    return false;
                }
            }
            loadContent.innerHTML = "<span style=\"text-align:left;color:blue;\"><br />" + msgs[1] + "</span>";
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
        }
    });
}


function UseVoucher(ConfirmValue) {
    var loadContent = document.getElementById("loadContent");
    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=UseVoucher&ConfirmValue=" + ConfirmValue,
        success: function(msg) {
            var msgs = msg.split("||");
            if (msgs[0] == "true") {
                alert(msgs[1]);
                document.location = msgs[2];
                return;
            }
            else {
                loadContent.innerHTML = "<span style=\"text-align:left;color:blue;\"><br />" + msg + "</span>";
            }
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
        }
    });
    return false;
}

function ConfirmUseUGC() {
    var loadContent = document.getElementById("loadContent");
    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=ConfirmUseUGC",
        success: function(msg) {
            var msgs = msg.split("||");
            if (msgs[0] == "true") {
                alert(msgs[1]);
                document.location = msgs[2];
                return;
            }
            else {
                loadContent.innerHTML = "<span style=\"text-align:left;color:blue;\"><br />" + msg + "</span>";
            }
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
        }
    });
    return false;
}


function AttachVoucher(cardid, attachcardid, teamid) {
    var loadContent = document.getElementById("loadContent");
    loadContent.innerHTML = "<p style=\"text-align:center; margin-top:40px;\">Please wait for processing:<br /><img src=\"images/loading.gif\" width=\"170px\" /></p>";
    $.ajax({
        type: "post",
        url: "ServerAjax.aspx",
        datatype: "html",
        data: "name=AttachVoucher&CardID=" + cardid + "&AttachCardID=" + attachcardid + "&TeamID=" + teamid,
        success: function(msg) {
            var msgs = msg.split("|");
            if (msgs[0] == "true") {
                alert(msgs[1]);
                document.location = msgs[2];
                return;
            }
            loadContent.innerHTML = "<span style=\"text-align:left;color:blue;\">" + msg + "</span>";
        },
        error: function() {
            loadContent.innerHTML = "<span style=\"text-align:left;color:red;\"><br /><br />Error.</span>";
        }
    });
    return false;

}

function DeliveryMethod(ddlmethod, lbmethod, ordertype, cardid, tbxmethod) {
    var lblmethod
    if (navigator.userAgent.indexOf("Firefox") > 0) {
        lblmethod = document.getElementById(lbmethod);
    }
    else {
        lblmethod = lbmethod;
    }
    lblmethod.style.display = "";
    tbxmethod.style.display = "";

    if (ddlmethod.value == "0") {
        lblmethod.innerHTML = "18 Digit Card Number:";
        tbxmethod.value = "";
        tbxmethod.disabled = "";
    }
    else if (ddlmethod.value == "3") {
        //        if(ordertype=="seasonticket")
        //        {
        //            lblmethod.innerHTML="12 Digit Card Number:";
        //            tbxmethod.value=cardid;
        //            tbxmethod.disabled="true";
        //        }
        //        else
        //        {
        lblmethod.innerHTML = "Full Name For Will-Call Pickup (ID Required):";
        tbxmethod.value = "";
        tbxmethod.disabled = "";
        //        }
    }
    else if (ddlmethod.value == "2") {
        lblmethod.style.display = "none";
        tbxmethod.style.display = "none";
        //lblmethod.innerHTML="Email Address To Send Printable (PDF) Ticket To:";
        //tbxmethod.value="";
        //tbxmethod.disabled="";
    }
    else if (ddlmethod.value == "1") {
        //lblmethod.style.display = "none";
        //tbxmethod.style.display = "none";
        lblmethod.innerHTML = "Full Name For The New Card:";
        tbxmethod.value = "";
        tbxmethod.disabled = "";
    }
}

function DeliveryMethod_Package(ddlmethod, lbmethod, ordertype, tbxmethod) {
    var lblmethod
    if (navigator.userAgent.indexOf("Firefox") > 0) {
        lblmethod = document.getElementById(lbmethod);
    }
    else {
        lblmethod = lbmethod;
    }
    lblmethod.style.display = "";
    tbxmethod.style.display = "";

    if (ddlmethod.value == "7") {
        lblmethod.innerHTML = "Card Number:";
        tbxmethod.value = "";
        tbxmethod.disabled = "";
    }
    else if (ddlmethod.value == "8") {
        lblmethod.style.display = "none";
        tbxmethod.style.display = "none";
    }
}


