﻿$(document).ready
(
    function() 
    {
        //debugger;
        $(".datepicker").datepicker(
        {
            dateFormat: siteJqueryDateickerFormat,           //"d M yy" formats to Wednesday 17 September 2008
            showOn: "both", 
            buttonImage: imagesiteroot + "/_images/date.png", 
            buttonImageOnly: true, 
            yearRange:'-1:+3',
            defaultDate:'0'
        });
        //setTimeout('btnEditHide()',100);
    }
);

function btnEditHide()
{
        $(".btnEdit").attr("style","float:left;display:none");
}

function ValidateForm()
{
    var blnError = false;
    //debugger;
    try
    {
     



        //2nd: If user has blanked the owned by then blank the iD also
        $('.txtClub').each(function() {
            //if its blank set warning in the warning span immediately after the textbox
            //debugger;
            if ($(this).attr("value")=='') 
            {
                //debugger;
                $('.hidClubID').attr("value","");
            } 
        })
        
      
        
        //2nd: ensure one of the radios is selected
        $('.rdoUserType').each(function() {
            //if its blank set warning in the warning span immediately after the textbox
            //debugger;
            if ($('.rdoUser')[0].firstChild.checked==false) 
            {
                if ($('.rdoGolfPro')[0].firstChild.checked==false) 
                {
                    //debugger;
                    //debugger;
                    blnError = true;
                    
                } 
                else
                {
                    // check they have selected a club
                    if ($(".hidClubID").attr("value")=='' && $(".txtClub").attr("value")=='')
                    {
                        
                        $('.lblClub').text("Required");
                    }
                }
            } 
            if (blnError==true)
            {
                $('.lblUserType').text("Required");
            }
            else
            {
                $('.lblUserType').text("");
            }
        })
            
    }
    catch (e) {
    }
    
    if (blnError) 
    {
        //debugger;
        $('.divMessages').attr("innerText","Please correct the entries in red below.");
        return false;
    } else {
        $('.status').text("");
        return true;
    }
}



function ShowClubSelection()
{
    
    //debugger;
    if ($('.rdoGolfPro')[0].firstChild.checked==true) 
    {
        $('.divClub').attr("style","display:block;");
    } 
    else
    {
        $('.divClub').attr("style","display:none;");
    } 
    
    
    //var x=$('.divAdvancedSearch').attr("currentStyle").display;
//    if(x=='block')
//    {
//        
//        
//    }
//    else
//    {
//        $('.divAdvancedSearch').attr("style","display:block;");
//        $('.lnkMoreOptions').attr("innerHTML","<b>Less Search Options...</b>");
//        $('.hidfield').attr("value","block");
//    }
        
}



