﻿function ValidateForm()
{
    var message = "";
    if($('#txtMayContact').val().length == 0)
        message="Please specify whether you may be contacted.";
        
    if($('.sc-ref').attr("selectedIndex") == 0)
        message="Please specify where you have heard about Small Capital.";
    
    if(industry = $('.industry').val().length == 0)
        message="Please specify your industry.";

    if($('.business').val().length == 0)
        message="Please specify the name of your business.";
    
    if($('#txtHaveExistingBusiness').val().length == 0)
        message="Please specify whether you have an existing business or is starting a new one.";
    
    if($('#txtIsExistingCustomer').val().length == 0)
        message="Please specify whether you are an existing Standard Bank customer.";
    
    if($('.office').val().length == 0)
        message="Please specify your office number.";
    
    if($('.cell').val().length == 0)
        message="Please specify your cell number.";
    
    if($('.address').val().length == 0)
        message="Please specify your address.";
    
    if($('.email').val().length == 0)
        message="Please specify your email address.";
    
    if($('.surname').val().length == 0)
        message="Please specify your surname.";
    
    if($('.name').val().length == 0)
        message="Please specify your name.";
    
    if(message.length > 0)
    {
       $('#pnlMessage').attr("innerHTML", "<h2>" + message + "</h2>");
       $('#pnlMessageContainer').modal();
       return false;
    }
    else
    {
        $('#pnlSaving').modal();
        return true;
    }
}

function SetRadioValue(radioID, valueContainerClass)
{
    while(radioID.indexOf("_") > -1)
        radioID = radioID.replace("_", "$");
    var target = document.getElementsByName(radioID);
    valueContainerClass = "."+valueContainerClass;
    for (var i = 0; i < target.length; i++)
        if (target[i].checked)
            $(valueContainerClass).val(target[i].value);
}

function SaveComplete()
{
    $.modal.close();
    $('#pnlThankYou').modal();
}

function RefreshScreen()
{
    var docLoc = document.location.toString();
    docLoc = docLoc.replace("Signup", "Default");
    document.location = docLoc;
}