﻿/// <reference path="jquery-1.4.1-vsdoc.js"/>
$(document).ready(function() {

});

function MobileOptin(value, mobileRFVID, carrierRFVID) {
    if (value) {
        $(".mobileOptin").show();
        ValidatorEnable(document.getElementById(mobileRFVID), true);
        ValidatorEnable(document.getElementById(carrierRFVID), true);
    }
    else {
        $(".mobileOptin").hide();
        ValidatorEnable(document.getElementById(mobileRFVID), false);
        ValidatorEnable(document.getElementById(carrierRFVID), false);
    }
}

function SetMobileOptin(mobileCheckboxId, mobileRFVID, carrierRFVID) {
    var checked = document.getElementById(mobileCheckboxId).checked;
    if (checked) {
        $(".mobileOptin").show();
        ValidatorEnable(document.getElementById(mobileRFVID), true);
        ValidatorEnable(document.getElementById(carrierRFVID), true);
    }
    else {
        $(".mobileOptin").hide();
        ValidatorEnable(document.getElementById(mobileRFVID), false);
        ValidatorEnable(document.getElementById(carrierRFVID), false);
    }
}

function ShowDialog(dialogID) {
    if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
        $("select").hide();
    }

    $("#formHolder").fadeTo("slow", 0.25, function() {
        $.scrollTo("#formTop", "slow", function() {
            $(dialogID).slideDown("slow");
        });
    });
}

function HideDialog(dialogID) {
    $(dialogID).slideUp("slow", function() {
        $("#formHolder").fadeTo("slow", 1);
        if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
            $("select").show();
        }
    });
}

function ShowVoteConfirm() {
    ShowDialog("#voteSubmit");
}

function HideVoteConfirm() {
    $("#voteSubmit").slideUp("slow", function() {
        $("#formHolder").fadeTo("slow", 1);
        if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
            $("select").show();
        }
        window.location.href = "default.aspx";
    });    
}

function ShowVoteDeny() {
    ShowDialog("#voteDeny");
}

function HideVoteDeny() {
    $("#voteDeny").slideUp("slow", function() {
        $("#formHolder").fadeTo("slow", 1);
        if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
            $("select").show();
        }
        window.location.href = "default.aspx";
    });
}

function ShowConfirm() {
    ShowDialog("#submitConfirm");
}

function HideConfirm() {
    HideDialog("#submitConfirm");
}

function ShowDeny() {
    ShowDialog("#submitDeny");
}

function HideDeny() {
    HideDialog("#submitDeny");
}

function limitText(limitField, limitCount, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } else {
        $(limitCount).html(limitNum - limitField.value.length);
    }
}

/*tell a friend related */

function ClearField(object, text, color) {
    if (document.getElementById(object.id).value == text) {
        
        document.getElementById(object.id).value = "";
    }
    document.getElementById(object.id).style.color = color;
}

function RestoreField(object, text, color) {
    if (document.getElementById(object.id).value == "") {
        document.getElementById(object.id).style.color = color;
        document.getElementById(object.id).value = text;
    }
}

function CheckField(id, text) {
    if (document.getElementById(id).value == text) {
        document.getElementById(id).value = "";
    }
}

function ShowTF() {
    //votingHomeLeft
    //votingHomeRight
    //headerHolder
    //$("#votingHomeLeft").fadeTo("slow", .25);
    //$("#votingHomeRight").fadeTo("slow", .25);
    //$("#headerHolder").fadeTo("slow", .25);
    //defaultTop
    $.scrollTo("#defaultTop", "slow", function() { 
        $("#tfFormHolder").fadeIn("slow");
    });
}

function HideTF() {
    $("#tfFormHolder").fadeOut("slow", function() {
        TFReset();
    });
}

function ShowTFPostBack() {
    $("#tfFormHolder").show();
}

function TFSubmit() {
    $(".tfButton").slideUp("slow");
    $("#tfFields").slideUp("slow");
    $("#tfOpen").slideUp("slow", function() {
        $("#tfSuccess").slideDown("slow");
    });
}

function TFReset() {
    $(".tfButton").show();
    $("#tfFields").show();
    $("#tfOpen").show();
    $("#tfSuccess").hide();
}