/**
 * Untz Framework
 *
 * @category   Untz
 * @package    JavaScript
 * @version $Id: form.js 783 2011-04-21 01:46:02Z jeremy $
 */

/*******************************************************************************

Helpers

*******************************************************************************/

/**
 * isset
 *
 */
function isset(varname){
    if (typeof(varname) == "undefined")
    {
        return false;
    }
    else {
        return true;
    }
}

/**
 * empty
 *
 */
function empty(value) {

    var key;
 
    if (value === '' || value === 0 || value === '0' || value === null || value === false || typeof value === 'undefined') {
        return true;
    }
    else if (typeof value == 'object') {
        for (key in value) {
            return false;
        }
        return true;
    }
 
    return false;
}

/*******************************************************************************

Validate Elements

*******************************************************************************/

function validateElementArtistName(options) {
    $().ready(function() {

        var memberId = '';
        if (options.memberId != '') {
            memberId = options.memberId;
        }

        var artistId = '';
        if (options.artistId != '') {
            artistId = options.artistId;
        }

        var location = '';
        if (options.location != '') {
            location = options.location;
        }
        $("#art_name").rules("add", 
            {
				required: true,
                remote: "/validate.php?action=validate_unregistered_artist&memberId=" + memberId + "&artistId=" + artistId + "&location=" + location,
                messages: {
                    remote: "The artist name already exists.",
                    required: "Please enter your artist name",
                }
            }
        );
    });
}

function validateElementArtistRelationship(options) {
    $().ready(function() {

        $("#relationship").rules("add", 
            {
				required: true,
            }
        );
    });
}

function validateElementBehalfCheck(options) {
    $().ready(function() {

        $("#behalf_chk").rules("add", 
            {
                required: true,
                messages: {
                    required: " Required: ",
                }
            }
        );
    });
}

function validateElementBio(options) {
    $().ready(function() {

        $("#bio").rules("add", 
            {
                required: true,
                messages: {
                    required: " Please enter a bio.",
                }
            }
        );
    });
}

function validateElementCompany(options) {

    $().ready(function() {

        var memberId = '';
        if (options.memberId != '') {
            memberId = options.memberId;
        }

        var userType = '';
        if (options.userType != '') {
            userType = options.userType;
        }

        var location = '';
        if (options.location != '') {
            location = options.location;
        }
        //alert('userType: ' + userType);

        //v = $("span.name").html().replace(/,/g,'');
        //$("span.name").html(v);
        //*
        $('#company').blur( function() {
                //alert('$("#' + sefuParseField + '").val(): ' + $("#" + sefuParseField).val());
            if($("#sefu").val() == "") {
                //alert('$("#' + sefuParseField + '").val(): ' + $("#" + sefuParseField).val());
                //alert('$(company).val(): ' + $(company).val());
                var valueCompany = $('#company').val().replace(/[^a-zA-Z0-9'\-\_\.]/g,'');
                //alert('valueCompany' + valueCompany);
                $("#sefu").val(valueCompany);
            }
        });
        //*/
        $("#company").rules("add", 
            {
                required: true,
                remote: "/validate.php?action=validate_unregistered_company&memberId=" + memberId + "&userType=" + userType + "&location=" + location,
                //minlength: 2,
                messages: {
                    remote: "The company name is not available.",
                    required: "Please enter your company name",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementDescription(options) {
    $().ready(function() {

        var useTextEditor = false;
        if (isset(options.useTextEditor)) {
            useTextEditor = !!options.useTextEditor;
        }

        var toolbar = 'UntzSimple';
        if (isset(options.toolbar)) {
            toolbar = options.toolbar;
        }

        if (useTextEditor) {

            var optionsTextEditor = {
                toolbar: toolbar,
            }
            textEditor('description', optionsTextEditor);	
        }
        
        var required = false;
        if (isset(options.required)) {
            required = !!options.required;
        }
            
        $("#description").rules("add", 
            {
                required: required,
                messages: {
                    required: "You must enter a description.",
                }
            }
        );
    });
}

function validateElementEmail(options) {
    $().ready(function() {

        $("#email").rules("add", 
            {
				required: true,
				email: true,
                messages: {
                    required: "Please enter your email address",
                }
            }
        );
    });
}

function validateElementGenres(options) {
    $().ready(function() {
        
        var untzController = '';
        if (options.untzController != '') {
            untzController = options.untzController;
        }

        if (untzController == 'events') {

            $("#genres").rules("add", 
                {
                    required: true,
                    maxlength: 5,
                    messages: {
                        required: "Please select at least one (1) genre, but no more than five (5).",
                    }
                }
            );
        }
        else {

            $("#genres").rules("add", 
                {
                    required: true,
                    messages: {
                        required: "Please select at least one (1) genre.",
                    }
                }
            );
        }
    });
}

function validateElementLocation(options) {

    $().ready(function() {

        var userType = '';
        if (options.userType != '') {
            userType = options.userType;
        }
        
        $("#city").rules("add", 
            {
                required: true,
                messages: {
                    required: "Please enter your city.",
                }
            }
        );
        
        $("#country").rules("add", 
            {
                required: true,
                messages: {
                    required: "Please select a country.",
                }
            }
        );
        
        //$("#not_local").click();
        //$('#not_local').removeAttr('checked')
        if ($('#not_local').is(':checked')) {
            
        }
        else {
            
        }
        
        //alert('userType: ' + userType);
        if (userType != 'promoter' && userType != 'fan') {
            $("#country").change(function () {
                if ($("#country").val() == 'US' || $("#country").val() == 'CA') {
                    //alert('local: ' + $("#country").val());
                    if ($('#not_local').is(':checked')) {
                        $('#not_local').click();
                    }
                    //alert('not_local: unchecking - Add: \nState\nZip\nMiles');
                    $("#state").rules("remove");
                    
                    if ($("#miles").length) {
                        $("#miles").rules("remove");
                    }
                    
                    if ($("#zip").length) {
                        $("#zip").rules("remove");
                    }
                    
                    $("#state").rules("add", 
                        {
                            required: true,
                            messages: {
                                required: "Please select your state/province.",
                            }
                        }
                    );
                    
                    if ($("#zip").length) {
                        $("#zip").rules("add", 
                            {
                                required: true,
                                messages: {
                                    required: "Please enter your postal/zip code.",
                                }
                            }
                        );
                    }
                    
                    if ($("#miles").length) {
                        $("#miles").rules("add", 
                            {
                                required: true,
                                messages: {
                                    required: "Please enter a search radius for your zip code.",
                                }
                            }
                        );
                    }
                }
                else {
                    //alert('not local: ' + $("#country").val());
                    $("#state").rules("remove");

                    if ($("#miles").length) {
                        $("#miles").rules("remove");
                    }
                    
                    if ($("#zip").length) {
                        $("#zip").rules("remove");
                    }

                    if (!$('#not_local').is(':checked')) {
                        //alert('not_local: clicking');
                        $('#not_local').click();
                    }
                }
            });
            //$('#not_local').attr('checked', false);
        }
        else {
             $("#state").rules("add", 
                {
                    required: true,
                    messages: {
                        required: "Please select your state/province.",
                    }
                }
            );
            
            if ($("#zip").length) {
                $("#zip").rules("add", 
                    {
                        required: true,
                        messages: {
                            required: "Please enter your postal/zip code.",
                        }
                    }
                );
            }
            
            if ($("#miles").length) {
                $("#miles").rules("add", 
                    {
                        required: true,
                        messages: {
                            required: "Please enter a search radius for your zip code.",
                        }
                    }
                );
            }
       }

    });
}

function validateElementPassword(options) {
    $().ready(function() {

        var location = '';
        if (options.location != '') {
            location = options.location;
        }

        if (location == 'sign-up') {
            $("#password").rules("add", 
                {
                    required: true,
                    minlength: 6,
                    messages: {
                        required: "Please provide a password"
                    }
                }
            );
    
            $("#password1").rules("add", 
                {
                    required: true,
                    minlength: 6,
                    equalTo: "#password",
                    messages: {
                        required: "Please provide a password",
                        equalTo: "Please enter the same password as above"
                    }
                }
            );
        }
    });
}

function validateElementPerson(options) {
    $().ready(function() {

        $("#firstname").rules("add", 
            {
				required: true,
                messages: {
                    required: "Please enter your first name",
                }
            }
        );

        $("#lastname").rules("add", 
            {
				required: true,
                messages: {
                    required: "Please enter your last name",
                }
            }
        );
    });
}

function validateElementTicketPrice(options) {
    $().ready(function() {

        $('.money').rules("add", 
            {
                number: true,
                messages: {
                    number: "You must enter a valid number without the $. For example: 19.95",
                }
            }
        );
    });
}

function validateElementTicketPriceRule(options) {
    var id = options.id;

    $('#' + id).rules("add", 
        {
            number: true,
            messages: {
                number: "You must enter a valid number without the $. For example: 19.95",
            }
        }
    );
}

function validateElementRsvpUntz(options) {
    $().ready(function() {

        var action = '';
        if (options.action != '') {
            action = options.action;
        }

        if ($('#rsvp_untz').is(':checked')) {
            $('#rsvp_guests').show();
            $('#elementRsvpOffer').show();
            if (action == 'edit') {
                $('#elementRsvpEnd').show();
                $('#rsvpGuestExport').show();
            }
        }
        else {
            $('#rsvp_guests').hide();
            $('#elementRsvpOffer').hide();
            if (action == 'edit') {
                $('#elementRsvpEnd').hide();
                $('#rsvpGuestExport').hide();
            }
        }

        $("#rsvp_untz").change(function () {
            if ($('#rsvp_untz').is(':checked')) {
                $('#rsvp_guests').show();
                $('#elementRsvpOffer').show();
                if (action == 'edit') {
                    $('#elementRsvpEnd').show();
                    $('#rsvpGuestExport').show();
                }
            }
            else {
                $('#rsvp_guests').hide();
                $('#elementRsvpOffer').hide();
                if (action == 'edit') {
                    $('#elementRsvpEnd').hide();
                    $('#rsvpGuestExport').hide();
                }
            }
        });

    });
}

function validateElementRsvpUrl(options) {
    $().ready(function() {

        $("#rsvp_url").rules("add", 
            {
                url: true,
                messages: {
                    url: "You must enter a full URL like http://theuntz.com",
                }
            }
        );
    });
}

function validateElementSecurityQuestion(options) {
    $().ready(function() {

        $("#sec_question").rules("add", 
            {
                required: true,
                messages: {
                    required: "Please select a security question.",
                }
            }
        );

        $("#sec_answer").rules("add", 
            {
                required: true,
                messages: {
                    required: "Please enter an answer to the security question.",
                }
            }
        );
    });
}

function validateElementSefu(options) {
    $().ready(function() {

        var location = '';
        if (options.location != '') {
            location = options.location;
        }
        
        if (location != 'sign-up') {
            $.validator.addMethod("sefu", function(value, element) { 
                //var re = new RegExp("/^[a-zA-Z'\-\_\.\s]+$/");
                //alert('re.test(value): ' + re.test(value));
                return this.optional(element) || /^[a-zA-Z0-9'\-\_\.]+$/.test(value); 
            }, "You must use alphanumeric characters"); 
                
            var sefuId = '';
            if (options.sefuId != '') {
                sefuId = options.sefuId;
            }    
            
            var url = "/validate.php?action=validate_sefu&code=" + sefuId;
            //alert('url: ' + url);
            
            $("#sefu").rules("add", 
                {
                    required: true,
                    remote: url,
                    sefu: true,
                    //minlength: 2,
                    messages: {
                        remote: "That custom url is already taken. Please try another.",
                        required: "You must have a Custom The Untz URL",
                        //minlength: jQuery.format("Please, at least {0} characters are necessary")
                    }
                }
            );
        }
            
    });
}

function validateElementSefuTypes(options) {
    $().ready(function() {

        $.validator.addMethod("sefuTypes", function(value, element) { 
            //var re = new RegExp("/^[a-zA-Z'\-\_\.\s]+$/");
            //alert('re.test(value): ' + re.test(value));
            return this.optional(element) || /^[a-zA-Z0-9'\-\_]+$/.test(value); 
        }, "You must use alphanumeric characters"); 
            
        var sefuTypesId = '';
        if (options.sefuTypesId != '') {
            sefuTypesId = options.sefuTypesId;
        }    
        
        var url = "/validate.php?action=validate_sefu_types&code=" + sefuTypesId;
        //alert('url: ' + url);
        
        $("#sefu_types").rules("add", 
            {
                required: true,
                remote: url,
                sefuTypes: true,
                //minlength: 2,
                messages: {
                    remote: "That sefu type is already in use. Please try another.",
                    required: "You must enter a name for the Sefu Type.",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementSefuTypesSections(options) {
    $().ready(function() {

        $.validator.addMethod("sefuTypesSections", function(value, element) { 
            //var re = new RegExp("/^[a-zA-Z'\-\_\.\s]+$/");
            //alert('re.test(value): ' + re.test(value));
            return this.optional(element) || /^[a-zA-Z0-9'\-\_]+$/.test(value); 
        }, "You must use alphanumeric characters"); 
            
        var sefuTypesSectionsId = '';
        if (options.sefuTypesSectionsId != '') {
            sefuTypesSectionsId = options.sefuTypesSectionsId;
        }    

        var url = "/validate.php?action=validate_sefu_types_sections&code=" + sefuTypesSectionsId + '&sefu_types_id=' + $("#sefu_types_id").val();
        //alert('url: ' + url);
        
        $("#sefu_types_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type.",
                }
            }
        );
        
        $("#sefu_types_sections").rules("add", 
            {
                required: true,
                remote: url,
                sefuTypesSections: true,
                //minlength: 2,
                messages: {
                    remote: "That sefu type is already in use. Please try another.",
                    required: "You must enter a name for the Sefu Type.",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementSefuTypesTabs(options) {
    $().ready(function() {

        $.validator.addMethod("sefuTypesTabs", function(value, element) { 
            //var re = new RegExp("/^[a-zA-Z'\-\_\.\s]+$/");
            //alert('re.test(value): ' + re.test(value));
            return this.optional(element) || /^[a-zA-Z0-9'\-\_]+$/.test(value); 
        }, "You must use alphanumeric characters"); 
            
        var sefuTypesTabsId = '';
        if (options.sefuTypesTabsId != '') {
            sefuTypesTabsId = options.sefuTypesTabsId;
        }    

        var url = "/validate.php?action=validate_sefu_types_tabs&code=" + sefuTypesTabsId + '&sefu_types_id=' + $("#sefu_types_id").val();
        //alert('url: ' + url);
        
        $("#sefu_types_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type.",
                }
            }
        );
        
        $("#sefu_types_tabs").rules("add", 
            {
                //required: true,
                remote: url,
                sefuTypesTabs: true,
                //minlength: 2,
                messages: {
                    remote: "That sefu type is already in use. Please try another.",
                    required: "You must enter a name for the Sefu Type.",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementSefuTypesSectionsDescription(options) {
    $().ready(function() {

        var sefuTypesSectionsDescriptionId = '';
        if (options.sefuTypesSectionsDescriptionId != '') {
            sefuTypesSectionsDescriptionId = options.sefuTypesSectionsDescriptionId;
        }    

        var url = "/validate.php?action=validate_sefu_types_sections_description&code=" + sefuTypesSectionsDescriptionId + '&sefu_types_id=' + $("#sefu_types_id").val() + '&sefu_types_sections_id=' + $("#sefu_types_sections_id").val();
        //alert('url: ' + url);
        $("#sefu_types_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type.",
                }
            }
        );
        
        $("#sefu_types_sections_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type Section.",
                }
            }
        );
        
        $("#sefu_types_sections_description").rules("add", 
            {
                required: true,
                //remote: url,
                //minlength: 2,
                messages: {
                    //remote: "That sefu type is already in use. Please try another.",
                    required: "You must enter a description.",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementSefuTypesSectionsTitle(options) {
    $().ready(function() {

        var sefuTypesSectionsTitleId = '';
        if (options.sefuTypesSectionsTitleId != '') {
            sefuTypesSectionsTitleId = options.sefuTypesSectionsTitleId;
        }    

        var url = "/validate.php?action=validate_sefu_types_sections_title&code=" + sefuTypesSectionsTitleId + '&sefu_types_id=' + $("#sefu_types_id").val() + '&sefu_types_sections_id=' + $("#sefu_types_sections_id").val();
        //alert('url: ' + url);
        $("#sefu_types_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type.",
                }
            }
        );
        
        $("#sefu_types_sections_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type Section.",
                }
            }
        );
        
        $("#sefu_types_sections_title").rules("add", 
            {
                required: true,
                //remote: url,
                //minlength: 2,
                messages: {
                    //remote: "That title is already in use. Please try another.",
                    required: "You must enter a title.",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementSefuTypesSectionsKeywords(options) {
    $().ready(function() {

        var sefuTypesSectionsKeywordsId = '';
        if (options.sefuTypesSectionsKeywordsId != '') {
            sefuTypesSectionsKeywordsId = options.sefuTypesSectionsKeywordsId;
        }    

        var url = "/validate.php?action=validate_sefu_types_sections_keywords&code=" + sefuTypesSectionsKeywordsId + '&sefu_types_id=' + $("#sefu_types_id").val() + '&sefu_types_sections_id=' + $("#sefu_types_sections_id").val();
        //alert('url: ' + url);
        $("#sefu_types_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type.",
                }
            }
        );
        
        $("#sefu_types_sections_id").rules("add", 
            {
                required: true,
                messages: {
                    required: "You choose a Sefu Type Section.",
                }
            }
        );
        
        $("#sefu_types_sections_keywords").rules("add", 
            {
                required: true,
                //remote: url,
                //minlength: 2,
                messages: {
                    //remote: "That keywords is already in use. Please try another.",
                    required: "You must enter a keywords.",
                    //minlength: jQuery.format("Please, at least {0} characters are necessary")
                }
            }
        );
    });
}

function validateElementTicketUrl(options) {
    $().ready(function() {

        $("#ticket_url").rules("add", 
            {
                url: true,
                messages: {
                    url: "You must enter a full URL like http://theuntz.com",
                }
            }
        );
    });
}

function validateElementUrl(options) {
    $().ready(function() {

        $("#url").rules("add", 
            {
                required: true,
                messages: {
                    required: "You must enter a relative or full URL.",
                }
            }
        );
    });
}

function validateElementUsername(options) {
    $().ready(function() {

        var memberId = '';
        if (options.memberId != '') {
            memberId = options.memberId;
        }

        $.validator.addMethod("userName", function(value, element) { 
            return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value); 
        }, "Invalid username."); 
        
        $("#username").rules("add", 
            {
				required: true,
				userName: true,
				remote: "/validate.php?action=validate_username&memberId=" + memberId,
                messages: {
                    required: "Please enter a user name.",
                    remote: "User name already exist.",
                }
            }
        );
    });
}

function validateElementValidateCode(options) {
    $().ready(function() {


        var location = '';
        if (options.location != '') {
            location = options.location;
        }
        
        if (location == 'sign-up') {
            $("#validate_code").rules("add", 
                {
                    required: true,
                    messages: {
                        required: "Please enter the validation code",
                    }
                }
            );
        }
    });
}

function validateElementVenueName(options) {
    $().ready(function() {

        $("#name").rules("add", 
            {
                required: true,
                messages: {
                    required: "You must enter a name for the Venue.",
                }
            }
        );
    });
}

function validateElementWebsite(options) {
    $().ready(function() {

        $("#website").rules("add", 
            {
                url: true,
                messages: {
                    url: "You must enter a full URL like http://theuntz.com",
                }
            }
        );
    });
}

function validateElementWhatsNew(options) {
    $().ready(function() {

        $("#whats_new").rules("add", 
            {
                required: true,
                messages: {
                    required: "You must enter text for What's New",
                }
            }
        );
    });
}

/*******************************************************************************

Validate Element Groups

*******************************************************************************/

function validateArtist(options) {

    options.untzController = 'artists';
    options.userType = 'artist';

    var unregistered = '';
    if (options.unregistered !== '' && options.unregistered !== null) {
        unregistered = options.unregistered;
    }

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    //alert('userType: ' + userType);
    if (location == 'backend' && unregistered) {
        validateElementArtistName(options);    
        validateElementSefu(options);
    }
    else if (location == 'backend') {
        validateElementArtistName(options);    
        
        //validateElementArtistRelationship(options);    
        //validateElementEmail(options);    
        //validateElementGenres(options);
        //validateElementLocation(options);
        //validateElementPerson(options);    
        validateElementSefu(options);
    }
    else if (location == 'update-add') {
        //validateElementArtistName(options);    
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementSefu(options);
        validateElementBio(options);
    }
    else if (location == 'update') {
        //validateElementArtistName(options);    
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        //validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
    }
    else if (location == 'artist-add') {
        validateElementArtistName(options);    
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        //validateElementLocation(options);
        //validateElementPerson(options);    
        validateElementBehalfCheck(options);
        validateElementBio(options);
    }
    else if (location == 'artist-edit') {
        //validateElementArtistName(options);    
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        //validateElementLocation(options);
        //validateElementPerson(options);    
        //validateElementBehalfCheck(options);
        validateElementBio(options);
        validateElementSefu(options);
    }
    else if (location == 'sign-up-add') {
        validateElementArtistName(options);    
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementBehalfCheck(options);
        validateElementBio(options);
    }
    else if (location == 'sign-up') {
        validateElementArtistName(options);    
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPassword(options);    
        validateElementPerson(options);    
        validateElementSecurityQuestion(options);    
        validateElementValidateCode(options);    
        validateElementUsername(options);    
    }
    else {
        validateElementArtistName(options);
        //return;
        //validateElementArtistRelationship(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPassword(options);    
        validateElementPerson(options);    
        validateElementSecurityQuestion(options);    
        validateElementValidateCode(options);    
        validateElementUsername(options);    
    }
}

function validateArtistRepresentive(options) {

    options.untzController = 'artist-representives';

    options.userType = 'artist_rep';

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend') {
        validateElementUsername(options);    
        
        //validateElementEmail(options);    
        //validateElementGenres(options);
        //validateElementLocation(options);
        //validateElementPerson(options);    
    }
    else if (location == 'update') {
        validateElementEmail(options);    
        validateElementArtistRelationship(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
    }
    else {
        validateElementEmail(options);    
        validateElementArtistRelationship(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPassword(options);    
        validateElementPerson(options);    
        validateElementSecurityQuestion(options);    
        validateElementValidateCode(options);    
        validateElementUsername(options);    
    }
}

function validateContest(options) {

    options.untzController = 'contests';

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend-edit') {
        //validateElementLocation(options);
        validateElementSefu(options);
        options.location = 'edit';
        validateElementRsvpUntz(options)
    }
    else if (location == 'backend-add') {
        //validateElementLocation(options);
        //validateElementSefu(options);
    }
    else if (location == 'update') {
        //validateElementLocation(options);
        validateElementSefu(options);
    }
    else {
        //validateElementLocation(options);
    }
}

function validateEvent(options) {

    options.untzController = 'events';

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location);
    if (location == 'backend-edit') {
        validateElementWebsite(options);
        validateElementTicketUrl(options);
        validateElementRsvpUrl(options);
        validateElementRsvpUntz(options);
        validateElementSefu(options);
        validateElementTicketPrice(options);

        //validateElementDescription(options);
        //validateElementLocation(options);
    }
    else if (location == 'backend-add') {
        validateElementWebsite(options);
        validateElementTicketUrl(options);
        validateElementRsvpUrl(options);
        validateElementRsvpUntz(options);
        validateElementTicketPrice(options);
        //validateElementLocation(options);
        //validateElementSefu(options);
        //validateElementDescription(options);
    }
    else if (location == 'event-edit') {
        validateElementWebsite(options);
        validateElementTicketUrl(options);
        validateElementRsvpUrl(options);
        validateElementRsvpUntz(options);
        //validateElementLocation(options);
        validateElementSefu(options);
        validateElementDescription(options);
        validateElementTicketPrice(options);
        validateElementGenres(options);
    }
    else if (location == 'event-add') {
        validateElementWebsite(options);
        validateElementTicketUrl(options);
        validateElementRsvpUrl(options);
        validateElementRsvpUntz(options);
        validateElementDescription(options);
        //validateElementLocation(options);
        validateElementTicketPrice(options);
        validateElementGenres(options);
    }
    else if (location == 'update') {
        validateElementWebsite(options);
        validateElementTicketUrl(options);
        validateElementRsvpUrl(options);
        validateElementRsvpUntz(options);
        //validateElementLocation(options);
        validateElementDescription(options);
        validateElementSefu(options);
        validateElementTicketPrice(options);
    }
    else {
        validateElementWebsite(options);
        validateElementTicketUrl(options);
        validateElementTicketPrice(options);
        validateElementRsvpUrl(options);
        validateElementRsvpUntz(options);
        validateElementDescription(options);
        //validateElementLocation(options);
    }
}

function validateFan(options) {

    options.untzController = 'fans';
    options.userType = 'fan';

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend') {
        //validateElementEmail(options);    
        //validateElementGenres(options);
        //validateElementLocation(options);
        //validateElementPerson(options);    
    }
    else if (location == 'update') {
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
    }
    else {
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPassword(options);    
        validateElementPerson(options);    
        validateElementSecurityQuestion(options);    
        validateElementValidateCode(options);    
        validateElementUsername(options);    
    }
}

function validateLabel(options) {

    options.untzController = 'labels';
    options.userType = 'label';

    var unregistered = '';
    if (options.unregistered !== '' && options.unregistered !== null) {
        unregistered = options.unregistered;
    }

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend' && unregistered) {
        validateElementSefu(options);
        validateElementCompany(options);    
    }
    else if (location == 'backend') {
        validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementSefu(options);
    }
    else if (location == 'update') {
        //validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementSefu(options);
        validateElementBio(options);
    }
    else if (location == 'label-edit') {
        //validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        //validateElementPerson(options);    
        validateElementSefu(options);
        validateElementBio(options);
    }
    else if (location == 'label-add') {
        //validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementBio(options);
    }
    else {
        validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPassword(options);    
        validateElementPerson(options);    
        validateElementSecurityQuestion(options);    
        validateElementValidateCode(options);    
        validateElementUsername(options);    
        validateElementSefu(options);
        validateElementBio(options);
    }
}

function validateNews(options) {

    options.untzController = 'news';
    
    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend-edit') {
        //validateElementLocation(options);
        validateElementSefu(options);
    }
    else if (location == 'backend-add') {
        //validateElementLocation(options);
        //validateElementSefu(options);
    }
    else if (location == 'update') {
        //validateElementLocation(options);
        validateElementSefu(options);
    }
    else {
        //validateElementLocation(options);
    }
}

function validatePromoter(options) {

    options.untzController = 'promoters';

    options.userType = 'promoter';

    var unregistered = '';
    if (options.unregistered !== '' && options.unregistered !== null) {
        unregistered = options.unregistered;
    }

    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend' && unregistered) {
        validateElementCompany(options);    
        validateElementSefu(options);
    }
    else if (location == 'backend') {
        validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementSefu(options);
    }
    else if (location == 'update') {
        validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPerson(options);    
        validateElementSefu(options);
        validateElementBio(options);
    }
    else {
        validateElementCompany(options);    
        validateElementEmail(options);    
        validateElementGenres(options);
        validateElementLocation(options);
        validateElementPassword(options);    
        validateElementPerson(options);    
        validateElementSecurityQuestion(options);    
        validateElementValidateCode(options);    
        validateElementUsername(options);    
        validateElementSefu(options);
        validateElementBio(options);
    }
}

function validateSefu(options) {
    
    options.untzController = 'sefus';
    
    validateElementSefu(options);    
    
    //validateElementUrl(options);    
}

function validateSefuTypes(options) {
    
    options.untzController = 'sefus-types';
    
    validateElementSefuTypes(options);    
}

function validateSefuTypesSections(options) {
    
    options.untzController = 'sefus-types-sections';
    
    validateElementSefuTypesSections(options);    
}

function validateSefuTypesTabs(options) {
    
    options.untzController = 'sefus-types-tabs';
    
    validateElementSefuTypesTabs(options);    
}

function validateSefuTypesSectionsDescription(options) {
    
    options.untzController = 'sefus-types-sections-description';
    
    validateElementSefuTypesSectionsDescription(options);    
}

function validateSefuTypesSectionsTitle(options) {
    
    options.untzController = 'sefus-types-sections-title';
    
    validateElementSefuTypesSectionsTitle(options);    
}

function validateSefuTypesSectionsKeywords(options) {
    
    options.untzController = 'sefus-types-sections-keywords';
    
    validateElementSefuTypesSectionsKeywords(options);    
}

function validateVenues(options) {

    options.untzController = 'venues';
    
    var location = '';
    if (options.location != '') {
        location = options.location;
    }
    //alert('location: ' + location + ' - unregistered: ' + unregistered);
    if (location == 'backend-edit') {
        validateElementVenueName(options);
        validateElementLocation(options);
        validateElementSefu(options);
    }
    else if (location == 'backend-add') {
        validateElementVenueName(options);
        validateElementLocation(options);
        //validateElementSefu(options);
    }
    else if (location == 'update') {
        validateElementVenueName(options);
        validateElementLocation(options);
        validateElementSefu(options);
    }
    else {
        validateElementVenueName(options);
        validateElementLocation(options);
        //validateElementSefu(options);
    }
}

function validateWhatsNew(options) {
    
    options.untzController = 'whats-news';

    validateElementUrl(options);    

    validateElementWhatsNew(options);    
}

/*******************************************************************************

Validate Element Groups

*******************************************************************************/

function validateFormUntz(options) {

    var formId = '';
    if (options.formId != '') {
        $("#" + options.formId).validate();
    }

    var location = '';
    if (options.location != '') {
        location = options.location;
    }

    var userType = '';
    if (options.userType != '') {
        userType = options.userType;
    }
    //alert('location: ' + location + ' - userType: ' + userType);
    //return;

    if (userType == 'artist_add' || userType == 'artist') {
        validateArtist(options);
    }
    else if (userType == 'artist_rep') {
        validateArtistRepresentive(options);    
    }
    else if (userType == 'fan') {
        validateFan(options);    
    }
    else if (userType == 'label') {
        validateLabel(options);    
    }
    else if (userType == 'promoter') {
        validatePromoter(options);    
    }
   
}

/*******************************************************************************

Autocomplete

*******************************************************************************/

function untzAutocomplete(id, options) {
    $().ready(function() {

        var untzType = '';
        if (options.untzType != '') {
            untzType = options.untzType;
        }

        var untzTypeKey = '';
        if (options.untzTypeKey != '') {
            untzTypeKey = options.untzTypeKey;
        }

        var untzTypeText = '';
        if (options.untzTypeText != '') {
            untzTypeText = options.untzTypeText;
        }

        var hide = '';
        if (options.hide != '') {
            hide = options.hide;
        }

        var appendTo = 'body';
        if (options.appendTo != '') {
            appendTo = options.appendTo;
        }
        //alert('appendTo: ' + appendTo);

        var url = "/json.php?action=" + untzType;

        if (untzType == 'labels' || untzType == 'promoters') {

            if (options.unregistered) {
                url += '&unregistered=true'
            }

            if (hide) {
                url += '&hide=1'
            }
        }
        else if (untzType == 'artists') {

            if (hide) {
                url += '&hide=1'
            }
        }
        
        var mySelector = "#" + id;
        //alert('url: ' + url + ' - mySelector: ' + mySelector);
        if (isset(options.mySelector)) {
            mySelector = options.mySelector;
        }
        
        //alert('url: ' + url);
        //alert('url: ' + url + ' - mySelector: ' + mySelector);
        $(mySelector).autocomplete({
            source: url,
            json: true,
            width: 260,
            appendTo: appendTo,
            //*
            select: function(event, ui) {
                if (isset(ui.item)) {
                    if (untzTypeKey != '') {
                        $('#' + untzTypeKey).val(ui.item.id);
                    }

                    if (untzTypeText != '') {
                        $('#' + untzTypeText).html(ui.item.id);
                   }
                }
                //log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value);
            }//*/
            //mustMatch: true,
            //formatItem: formatItem,
            //formatResult: formatResult
        });
        //.data( "autocomplete" )._renderItem = function( ul, item ) {
        //    return $( "<li></li>" )
        //        .data( "item.autocomplete", item )
        //        .append( item.label + " (" + item.id + ")" )
        //        .appendTo( ul );
        //};
    });

}


function untzDropdown(id, options) {
    $().ready(function() {
    
        
        $("#sefu_types_id").change(function () {

            var untzType = '';
            if (options.untzType != '') {
                untzType = options.untzType;
            }

            var untzTypeFilter = '';
            if (options.untzTypeFilter != '') {
                untzTypeFilter = options.untzTypeFilter;
            }
        
            var untzTypeKey = '';
            if (options.untzTypeKey != '') {
                untzTypeKey = options.untzTypeKey;
            }
        
            var untzTypeText = '';
            if (options.untzTypeText != '') {
                untzTypeText = options.untzTypeText;
            }
        
            var hide = '';
            if (options.hide != '') {
                hide = options.hide;
            }
        
            var url = "/json.php?action=" + untzType;
    
            if (untzType == 'sefu_types_sections') {
                url += '&sefu_types_id=' + $("#sefu_types_id").val();
                
                if (untzTypeFilter == 'description') {
                    url += '&type_filter=' + untzTypeFilter;
                }
                else if (untzTypeFilter == 'keywords') {
                    url += '&type_filter=' + untzTypeFilter;
                }
                else if (untzTypeFilter == 'title') {
                    url += '&type_filter=' + untzTypeFilter;
                }
            }
    
            //alert('url: ' + url);

            $.getJSON(url, function(data){
            
                var html = '';
                //var options = [];
                //alert('html: ' + html);
                //alert('$(id).id: ' + $(id).id);
                //alert('$(id).html(): ' + $(id).html());
                //$(id).html(html);
                html += '<option value=""></option>';
                for (var i = 0; i < data.length; i++) {
                    html += '<option value="' + data[i].id + '">' +    data[i].label + '</option>';
                    //options.push('<option value="', data[i].id, '">', data[i].label, '</option>');
                }
                //alert('id: ' + id);
                //alert('html: ' + html);
                //$(id).html(options.join(''));
                $('#' + id).html(html);
            });
        });
        
        $("#polls_id").change(function () {

            var untzType = '';
            if (options.untzType != '') {
                untzType = options.untzType;
            }

            var url = "/json.php?action=" + untzType;
    
            url += '&polls_id=' + $("#polls_id").val();

            $.getJSON(url, function(data){
            
                var html = '';
                //var options = [];
                //alert('html: ' + html);
                //alert('$(id).id: ' + $(id).id);
                //alert('$(id).html(): ' + $(id).html());
                //$(id).html(html);
                html += '<option value=""></option>';
                for (var i = 0; i < data.length; i++) {
                    html += '<option value="' + data[i].id + '">' +    data[i].label + '</option>';
                    //options.push('<option value="', data[i].id, '">', data[i].label, '</option>');
                }
                //alert('id: ' + id);
                //alert('html: ' + html);
                //$(id).html(options.join(''));
                $('#' + id).html(html);
            });
        });
    });
}
/*******************************************************************************

Text Editor

*******************************************************************************/

/**
 * Drop in a text editor into forms
 *
 */
function textEditor(id, options) {
    $(function()
        {

            var toolbar = '';
            if (options.toolbar == '') {
                options.toolbar = 'UntzSimple';
            }
            
            /*
            var options = {
                //skin: 'v2',
                //skin: 'kama',
                //skin: 'office2003',
                //width: '50%',
            };
            */
            $('#' + id).ckeditor(function() { /* callback code */ }, options);   
        }
    );
}

/**
 * Drop in a text editor into forms
 *
 */
function setTextEditor(mySelector, options) {
    $(function()
        {

            var toolbar = '';
            if (options.toolbar == '') {
                options.toolbar = 'Simple';
            }
            
            /*
            var options = {
                //skin: 'v2',
                //skin: 'kama',
                //skin: 'office2003',
                //width: '50%',
            };
            */
            $(mySelector).ckeditor(function() { /* callback code */ }, options);   
        }
    );
}

/*******************************************************************************

Date & Time Functions

*******************************************************************************/

/**
 * Drop in a datetime picker
 *
 */
function dateTimePicker() {
    $(function()
        {
            var options = {
                //format: "%Y-%m-%d %H:%i",
                //formatUtcOffset: "%: (%@)",
                //hideInput: true,
                //dateFormat: 'yyyy-mm-dd HH:MM:ss',
                dateFormat: "isoDateTime",
                //dateFormat: "fullDate",
                changeMonth: true,
                changeYear: true,
                numberOfMonths: 2,
                showButtonPanel: true,
            }

            $('.datetimepicker').datetimepicker(options);
        }
    );
}

/*******************************************************************************

Banners

*******************************************************************************/

/**
 * Load Banner
 *
 */
function untzLoadBanner(myFlashUpload, options) {
    //alert('options.id: ' + options.id);
    //alert('options.width: ' + options.width);
    if (!isset(options)) {
        var options = {};
    }
    
    if (!isset(options.id)) {
        options.id = 'flashPlayer';
    }
    
    if (!isset(options.width)) {
        options.width = 200;
    }
    
    if (!isset(options.height)) {
        options.height = 200;
    }

    $(function()
        {
            var html = '';

            if (myFlashUpload == '' || myFlashUpload == null) {
                html = 'NO FLASH FILE';
                return html;
            }

            var so = new SWFObject(myFlashUpload, "mymovie", options.width, options.height, "7", "#FFFFFF");
            //so.addVariable("autoPlay", "no");
            so.write(options.id);
        }
    );
}

/*******************************************************************************

Tickets

*******************************************************************************/

function untzAddTicketLevel(options) {
/*
<tr>
  <td ><label for="price_<{$myEventTicketNextLevel}>">Ticket Level <{$myEventTicketNextLevel}> Price</label></td>
  <td colspan="2"><input name="price_<{$myEventTicketNextLevel}>" type="text" id="price_<{$myEventTicketNextLevel}>" size="45" value="" /></td>
</tr>
<tr>
  <td><label for="events_tickets_<{$ticket.level}>">Ticket Level <{$myEventTicketNextLevel}> Description</label></td>
  <td colspan="2"><input name="events_tickets_<{$myEventTicketNextLevel}>" type="text" id="events_tickets_<{$myEventTicketNextLevel}>" size="45" value="" /></td>
</tr>

*/
    var levels = 10;
    var level = Math.ceil($("#ticketTable").attr('rows').length / 2) + 1;
    //alert('level: ' + level);
    if (level <= levels) {
        $("#ticketTable").find('tbody')
            .append($('<tr>')
                .append($('<td>')
                    .append($('<label>')
                        .attr('for', 'price_' + level)
                        .text('Ticket Level ' + level +  ' Price')
                    )
                )
                .append($('<td>')
                    .append($('<input>')
                        .attr('id', 'price_' + level)
                        .attr('name', 'price[' + level + ']')
                        .attr('size', 45)
                        .attr('class', 'money')
                    )
                )
            )
            .append($('<tr>')
                .append($('<td>')
                    .append($('<label>')
                        .attr('for', 'events_tickets_' + level)
                        .text('Ticket Level ' + level +  ' Description')
                    )
                )
                .append($('<td>')
                    .append($('<input>')
                        .attr('id', 'events_tickets_' + level)
                        .attr('name', 'events_tickets[' + level + ']')
                        .attr('size', 45)
                    )
                )
            )
        ;
        
        validateElementTicketPriceRule({id: 'price_' + level});
    }
    else {
    alert('Sorry, you cannot add more than ' + levels + ' levels');
    }
    // Return false to prevent the form from being submitted.
    return false;
    /*
    $("#ticketTable").find('tbody')
    .append($('<tr'>)
        .append($('<td>')
            .append($('<label>')
                .attr('for', 'img.png')
                .text('Image cell')
            )
        )
    );
    //*/
}

/*******************************************************************************

RSVP

*******************************************************************************/

function untzRsvp(options) {
    
    if (options.id == '' || options.id == null) {
        alert('Unable to RSVP, no event was selected.');
        return false;
    }

    $(function() {
        $("#rsvpNow").click(function () { 
           
            var guests = $("#rsvp_guests").val();      
            var dataString = '&rsvp=yes&guests=' + guests;
            //alert('dataString: ' + dataString);return false;
            $.ajax({
                type: "GET",
                url: "/event-detail?id=" + options.id,
                data: dataString,
                dataType: 'json',
                success: function(data) {
                    $('#rsvp').html("<div id='message'></div>");
                    if (data.status == false) {
                        $('#message').html("<img style='float: left;' src='/images/warning.png' />")
                        .append(data.message);
                    }
                    else {
                    $('#message').html("<img style='float: left;' src='/images/ok.png' />")
                        .append(data.message);
                    }
                }
            });
        });
    });
  
}

/*******************************************************************************

Cycle

*******************************************************************************/

/**
 * untzCycle
 *
 */
function untzCycle(options) {
/*
var options = {
    untzType: 'whats-new',
    untzType: '',
    untzType: '',
}
untzCycle('owner_name_label', options);
*/


    // Slide show controls
    $().ready(function() {

        var mySelector = '';
        if (options.mySelector != '') {
            mySelector = options.mySelector;
        }

        var untzType = '';
        if (options.untzType != '') {
            untzType = options.untzType;
        }

        if (empty(untzType) && empty(mySelector)) {
            return false;
        }
        else if (!empty(untzType) && empty(mySelector)) {
            mySelector = '#cycle-' + untzType;
        }
            
        $(mySelector).cycle({ 
            fx:    'fade', 
            pause:  0,
            //startingSlide: 1,
            speed:  5000,
            prev:   '#controls-previous', 
            next:   '#controls-next',
        });
        
        $('#controls-stop').click(function() { 
            $('#ticker-tape').cycle('pause'); 
            $('.controls li.play').show(); 
            $('.controls li.stop').hide(); 
        });
        
        $('#controls-play').click(function() { 
            $('#ticker-tape').cycle('resume'); 
            $('.controls li.play').hide(); 
            $('.controls li.stop').show(); 
        });
    });
}

/*******************************************************************************

Login

*******************************************************************************/
/**
 * login
 *
 * Process the login form for the user
 */
function login() {

    var password = $('#r_password').val();
    var login = $('#r_username').val();
    
    if (empty(login)) {
        $('#login_msg').html('You must enter a user name.');
        $('#login_msg').css('display','');
        return false;
    }
    
    if (empty(password)) {
        $('#login_msg').html('You must enter a password.');
        $('#login_msg').css('display','');
        return false;
    }
    
    var options = {
        url:        '/login_chk.php',
        type:       'post',
        data:       {
            uname:  login,
            pwd:    password,
            remb:   $('#remb:checked').val()
        },
        success:    function(msg) {
            if (msg == 0) {
                $('#login_msg').html('This account was not found. Please try again or <a href="/contact">contact us</a> if you feel this is in error.');
                $('#login_msg').css('display','');
            }
            else if (msg == 1) {
                $('#login_msg').html('This account is disabled. Please <a href="/contact">contact us</a> if you feel this is in error.');
                $('#login_msg').css('display','');
            }
            else if (msg == 2) {
                $('#login_msg').html('Invalid password.');
                $('#login_msg').css('display','');
            }
            else if (msg == 3) {
                $('#login_msg').html('You have successfully logged in.');
                location.reload();
            }
            else {
                $('#login_msg').html('Login error');
                $('#login_msg').css('display','');
            }
        },
    }

    $.ajax(options); 
}

/**
 * showLogin
 * 
 */
function showLogin() {
    $('#welcome1').fadeIn('slow', function() {
        $('#r_username').focus();
        // Animation complete
    });
}

/**
 * setupLogin
 *
 * Process the login form for the user
 */
function setupLogin() {

    $().ready(function() {

        $('#show_login').click(function() { 
            if($('#welcome1').css('display')=='none'){
                showLogin();
            }
            else{
                $('#welcome1').fadeOut('slow', function() {
                    // Animation complete
                });
            }
        });
            

        $('#login_form').submit(function() {
            return false;
        });    

        $('#r_username').focus(function() {
            if( this.value == this.defaultValue ) {
                this.value = '';
            }
        }).blur(function() {
            if( !this.value.length ) {
                this.value = this.defaultValue;
            }

            //$('#untz-search div.results').hide();
            
        });
    });
}

/*******************************************************************************

Sampler

*******************************************************************************/

/**
 * Load Sampler page
 *
 * Some mobile platforms do not render flash and do not support html5 properly.
 * 
 * We will only support items that render javascript.
 *
 * Problem platforms:
 * - Blackberry
 * - Android 2.2
 */
function loadSampler() {
    $(function()
        {
            // If Flash is supported, load SoundCloud, otherwise the list.
            var playerVersion = swfobject.getFlashPlayerVersion();

            if (playerVersion.major >= 9) {
                $('#sampler div.soundcloud').show(); 
                $('#music-release-list').hide(); 
            }
            else {
                $('#sampler div.soundcloud').hide(); 
                $('#music-release-list').show(); 
            }
        }
    );
}

/*******************************************************************************

Deprecated - still in production

*******************************************************************************/
/*
function FormCheck() {
    return true;
	if($("#not_local").attr('checked')) {
		$("#zip").rules("remove");
		$("#city").rules("remove");
		$("#state").rules("remove");
		$("#country").rules("remove");
		$("#miles").rules("remove");
	} else {
		if($("#zip").val() != "") {
			$("#zip").rules("add", {
				required: true
			});
			$("#city").rules("remove");
			$("#state").rules("remove");
			$("#country").rules("remove");
		} else {
			$("#city").rules("add", {
				required: true
			});
			$("#state").rules("add", {
				required: true
			});
			$("#country").rules("add", {
				required: true
			});
		}
		$("#miles").rules("add", {
			required: true
		});
	}
	return true;
}
*/

/* - Old {
$("#city").blur( function() {
    if($("#city").val() != "" && $("#state").val() != "" && $("#country").val() != "") {
        $("#zip").rules("remove");
    } else {
        $("#zip").rules("add", {
            required: true
        });
    }
});
$("#state").blur( function() {
    if($("#city").val() != "" && $("#state").val() != "" && $("#country").val() != "") {
        $("#zip").rules("remove");
    } else {
        $("#zip").rules("add", {
            required: true
        });
    }
});
$("#country").blur( function() {
    if($("#city").val() != "" && $("#state").val() != "" && $("#country").val() != "") {
        $("#zip").rules("remove");
    } else {
        $("#zip").rules("add", {
            required: true
        });
    }
});

$("#zip").blur( function() {
    if($("#zip").val() != "") {
        $("#city").rules("remove");
        $("#state").rules("remove");
        $("#country").rules("remove");
    } else {
        $("#city").rules("add", {
            required: true
        });
        $("#state").rules("add", {
            required: true
        });
        $("#country").rules("add", {
            required: true
        });
    }
} ); 
}*/

/*
	// validate signup form on keyup and submit
	$.validator.addMethod("sefu", function(value, element) { 
        var re = new RegExp("/^[a-zA-Z'.\s]{1,40}$/");
        alert('re.test(value): ' + re.test(value));
		return this.optional(element) || re.test(value); 
	}, "You must use alphanumeric characters"); 

	$.validator.addMethod("userName", function(value, element) { 
		return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value); 
	}, "Invalid username."); 

	$("#signupForm").validate({
		rules: {
			username: {
				required: true,
				userName: true,
				remote: "/validate.php?action=validate_username"
			},
			password: {
				required: true,
				minlength: 6
			},
			password1: {
				required: true,
				minlength: 6,
				equalTo: "#password"
			},
			sec_question: "required",
			sec_answer: "required",
			firstname: "required",
			lastname: "required",
			relationship: "required",
			multiple: "required",
			//gender: "required",
			email: {
				required: true,
				email: true
			},

			art_name: {
				required: true,
				//required: "#art_type_1:checked",
				remote: "/validate.php?action=validate_unregistered_artist",
			},
			
			//multiple: {
			//	required: "#art_type_2:checked",
			//},
			
			city: {required: "#not_local:unchecked",},
			state: {required: "#not_local:unchecked",},
			country: {required: "#not_local:unchecked",},
			zip: "required",
			miles: {required: "#not_local:unchecked",},
			
			validate_code: {
				required: true,
				remote: "/validate.php?action=validate_code"
			}
		},
		messages: {
			username: {
				remote: "User name already exist"
			},
			password: {
				required: "Please provide a password"
			},
			password1: {
				required: "Please provide a password",
				equalTo: "Please enter the same password as above"
			},
			firstname: "Please enter your firstname",
			lastname: "Please enter your lastname",
            art_name: {
                remote: "The artist name already exists.",
                required: "Please enter your artist name",
                //minlength: jQuery.format("Please, at least {0} characters are necessary")
            }
		}
	});
*/


