// JScript File

function ConfReg()
{
    var self = this;
    $(document).ready(function()
    {        
    	
        if($(".Occupation").find(":selected").text() == "Other")
        {
            $(".OccupationOther").show();
        }
        else
        {
            $(".OccupationOther").hide();
            $(".txtOccupationOther").val("");
        }
        
//        if($(".isPublished").find(":checked").val() == "Yes") 
//        {
//            $(".PubOnly").show();              
//        }
//        else
//        {
//            $(".PubOnly").hide();
//	                            
//        }
        
        if($(".ddlCountry").find(":selected").val() == "")
        {
            $(".ddlState").hide();
            $(".ddlCanada").hide();
            $(".txtState").show();
        }
        else if($(".ddlCountry").find(":selected").val() == "USA")
        {
            $(".ddlCanada").hide();
            $(".ddlState").show();
            $(".txtState").hide();
        }
        else if($(".ddlCountry").find(":selected").val() == "Canada")
        {
            $(".ddlCanada").show();   
            $(".ddlState").hide();
            $(".txtState").hide();
        }
        else
        {
            $(".ddlState").hide();
            $(".ddlCanada").hide();
            $(".txtState").show();
        }
                
        self.ToggleWorkshop();
//        if($(".EarlyMemberAttendanceOption").find("input[type=radio]").attr("checked"))
//            $(".WorkshopSection").show();
//        else if($(".EarlyNonMemberAttendanceOption").find("input[type=radio]").attr("checked"))
//            $(".WorkshopSection").show();
//        else if($(".MemberAttendanceOption").find("input[type=radio]").attr("checked"))
//            $(".WorkshopSection").show();
//        else if($(".NonMemberAttendanceOption").find("input[type=radio]").attr("checked"))
//            $(".WorkshopSection").show();
//        else
//        {
//            if($(".displayWorkshops input[type='checkbox']:checked").size() > 0)
//                {
//                    $(".WorkshopSection").show();   
//                }
//                else
//                    $(".WorkshopSection").hide();
//         }        
    });
    
    this.ToggleOccupationOther = function()
    {
        if($(".Occupation").find(":selected").text() == "Other")
        {
            $(".OccupationOther").show();
        }
        else
        {
            $(".OccupationOther").hide();
            $(".txtOccupationOther").val("");
        }
    }
    
//    this.TogglePubOnly = function()
//    {             
//    
//        if($(".isPublished").find(":checked").val() == "Yes")   
//        {
//		$(".FullTime").each(function(i)
//		{
//		    $(this).find("input[type='radio']").each(function() {
//			if($(this).attr("checked") == true)
//			{
//				$(".PubOnly").css("display", "block");
//			}
//		    });
//		}); 

//		$(".PartTime").each(function(i) 
//		{        
//		    $(this).find("input[type='checkbox']").each(function(){                    
//			if($(this).attr("checked") == true)
//			{
//$(".PubOnly").css("display", "block");
//			}                
//		    });
//		});
//		
//        	
//            //$(".PubOnly").show(); 
//        }
//        else
//        {                        
//            $(".PubOnly").each(function(i) 
//            {        
//                $(this).find(".WorkshopChbx input[type='checkbox']").each(function(){                    
//                    if (this.checked)
//                        $(this).click();
//                });
//            });
//            
//            $(".PubOnly").hide();
//        }                    
//    }
    
    this.GetInternationalRegions = function()
    {        
        if($(".ddlCountry").find(":selected").val() == "USA")
        {
            $(".ddlCanada").hide();
            $(".ddlState").show();
            $(".txtState").hide();
        }   
        else if($(".ddlCountry").find(":selected").val() == "Canada")
        {
            $(".ddlCanada").show();
            $(".ddlState").hide();
            $(".txtState").hide();
        }     
        else
        {
            $(".ddlCanada").hide();
            $(".txtState").show();
            $(".ddlState").hide();
        }   
    }
    
    this.ToggleWorkshop = function()
    {
    	
        $(".Workshops").each(function(i)
        {
            $(this).hide();
        });
        
        $(".FullTime").each(function(i)
        {
            $(this).find("input[type='radio']").each(function() {
                if($(this).attr("checked") == true)
                {
                    var myClasses = $(this).parent().attr("class");                    
                    myClasses = myClasses.replace('FullTime ', '').replace('Option', '');
                    
                    $(".Workshops."+myClasses).each(function(i)
                    {
                        $(this).show();
                        if($(this).find(".WorkshopChbx input[type='checkbox']").hasClass("required"))
                        {
                            $(this).find(".WorkshopChbx input[type='checkbox']").each(function(i)
                            {
                                this.checked = true;
                                //this.disabled = "disabled";
                                var cell = $(this).parent().parent().next().next();                
                                cell.find(".WorkshopOption").show();
                            });
                            
                        }
                    });
                }
            });
        }); 
            
        $(".PartTime").each(function(i) 
        {        
            $(this).find("input[type='checkbox']").each(function(){                    
                if($(this).attr("checked") == true)
                {
                    var myClasses = $(this).parent().attr("class");
                    myClasses = myClasses.replace('PartTime PartTime', '');

                    $(".Workshops."+myClasses).each(function(i)
                    {
                        $(this).show();
                        if($(this).find(".WorkshopChbx input[type='checkbox']").hasClass("required"))
                        {
                            $(this).find(".WorkshopChbx input[type='checkbox']").each(function(i)
                            {
                                this.checked = true;
                                //this.disabled = "disabled";
                                var cell = $(this).parent().parent().next().next();                
                                cell.find(".WorkshopOption").show();
                            });
                            
                        }
                    });
                }                
            });
        }); 
        
        $(".Workshops").each(function(i)      
        {
            if($(this).is(':hidden'))
            {
                $(this).find(".WorkshopChbx input[type='checkbox']").each(function(i) 
                {                            
                    if(this.checked)
                    {                        
                        this.checked = false;
                        var cell = $(this).parent().parent().next().next();                
                        cell.find(".WorkshopOption").hide();
                    }
                });
            }
            
        });
        
        //this.TogglePubOnly();
        
//        if(e == "PartTime")
//        {
//            if($(".Workshops input[type='checkbox']:checked").size() > 0)
//            {
//                  $(".WorkshopSection").show(); 
//            }
//            else
//            {
//                $(".WorkshopSection").hide();
//                $(".WorkshopChbx input[type='checkbox']").each(function(i) 
//                {        
//                    if(this.checked)
//                    {
//                        this.checked = false;
//                        var cell = $(this).parent().parent().next().next();                
//                        cell.find(".WorkshopOption").hide();
//                    }
//                });
//            }
//        }
//        else
//        {
//            if($(".displayWorkshops input[type='radio']:checked").size() > 0)
//            {
//                $(".WorkshopSection").show();   
//            }
//            else
//            {
//                $(".WorkshopSection").hide();
//                $(".WorkshopChbx input[type='radio']").each(function(i) 
//                {        
//                    if(this.checked)
//                    {
//                        this.checked = false;
//                        var cell = $(this).parent().parent().next().next();                
//                        cell.find(".WorkshopOption").hide();
//                    }
//                });
//            }
//        }
    }
    
    this.ToggleAttendance = function(e)
    {
        if(e == "PartTime")
        {            
            $(".FullTime").each(function(i)
            {
                $(this).find("input[type='radio']").each(function() {
                   if($(this).attr("checked") == true)
                    $(this).attr("checked", false);
                });
            });         
        }
        else if(e == "FullTime")
        {
            $(".PartTime").each(function(i) 
            {        
                $(this).find("input[type='checkbox']").each(function(){                    
                    if($(this).attr("checked") == true)
                    $(this).attr("checked", false);
                });
            });
        }
    }
    
    this.Uncheckable = function(e)
    {        
        
        e.checked = true;
        var cell = $(e).parent().parent().next().next();                
        cell.find(".WorkshopOption").show();
    }
}

var ConfReg = new ConfReg();