﻿$(document).ready(function () {

    $('#TermsSubmit').click(function () {
        if ($('#TermsCheck').attr('checked') === false) {
            alert("You must accept the Terms and Conditions to continue.");
            return false;
        }
    });
});


// Workers Comp Operations Questions Functions

$(document).ready(function() {
    $("input[class='OpsQuestions']").change(function () {
        if ($('#Operations9').attr('checked')) {
            $('#opsDescription').show();
        } else {
            $('#opsDescription').hide();
        }
    });
});

$(document).ready(function () {
    if ($('#Operations9').is(":checked"))
    { $('#opsDescription').show(); }
    else
    { $('#opsDescription').hide(); }
});



$(document).ready(function () {
    $("#wcflag").click(function () {
        if ($('#wcflag').attr('checked')) {
            $('#WCFlagdiv').show("blind");
        } else {
            $('#WCFlagdiv').hide("blind");
        }
    });
});

$(document).ready(function () {
    if ($('#wcflag').is(":checked"))
    { $('#WCFlagdiv').show(); }
    else
    { $('#WCFlagdiv').hide(); }
});


$(document).ready(function () {
    $("#IsProperty").click(function () {
        if ($('#IsProperty').attr('checked')) {
            $('#IsPropertydiv').show("blind");
        } else {
            $('#IsPropertydiv').hide("blind");
        }
    });
});

$(document).ready(function () {
    if ($('#IsProperty').is(":checked"))
    { $('#IsPropertydiv').show(); }
    else
    { $('#IsPropertydiv').hide(); }
});

$(document).ready(function () {
    $("#IsDirectors").click(function () {
        if ($('#IsDirectors').attr('checked')) {
            $('#IsDirectorsdiv').show("blind");
        } else {
            $('#IsDirectorsdiv').hide("blind");
        }
    });
});

$(document).ready(function () {
    if ($('#IsDirectors').is(":checked"))
    { $('#IsDirectorsdiv').show(); }
    else
    { $('#IsDirectorsdiv').hide(); }
});



$(document).ready(function () {
    $("#IsUmbrella").click(function () {
        if ($('#IsUmbrella').attr('checked')) {
            $('#IsUmbrelladiv').show("blind");
        } else {
            $('#IsUmbrelladiv').hide("blind");
        }
    });
});

$(document).ready(function () {
    if ($('#IsUmbrella').is(":checked"))
    { $('#IsUmbrelladiv').show(); }
    else
    { $('#IsUmbrelladiv').hide(); }
});


$(document).ready(function () {
    $("#IsBond").click(function () {
        if ($('#IsBond').attr('checked')) {
            $('#IsBonddiv').show("blind");
        } else {
            $('#IsBonddiv').hide("blind");
        }

    });
});

$(document).ready(function () {
    if ($('#IsBond').is(":checked"))
    { $('#IsBonddiv').show(); }
    else
    { $('#IsBonddiv').hide(); }
});

 


$(document).ready(function () {
    if ($('#IsManagement_Yes').is(":checked")) {
        $('#GQIsManagement').css('height', '70px')
        $('#IsManagementdiv').show();        
    }
    else
    { $('#IsManagementdiv').hide(); }
});


$(document).ready(function () {
    $("input[name='WorkersComp.IsManagement']").click(function () {
        if ($('#IsManagement_Yes').attr('checked')) {
            $('#GQIsManagement').css('height', '70px')
            $('#IsManagementdiv').show("slide");
        } 
        else {
            $('#GQIsManagement').css('height', '30px')
            $('#IsManagementdiv').hide();
        }

    });
});

$(document).ready(function () {
    if ($('#Trips_Yes').is(":checked")) {
        $('#GQTrips').css('height', '70px')
        $('#Tripsdiv').show();
        
    }
    else
    { $('#Tripsdiv').hide(); }
});

$(document).ready(function () {
    $("input[name='WorkersComp.Trips']").click(function () {
        if ($('#Trips_Yes').attr('checked')) {
            $('#GQTrips').css('height', '70px')
            $('#Tripsdiv').show("slide");
        }
        else {
            $('#GQTrips').css('height', '40px')
            $('#Tripsdiv').hide();
        }
    });
});

// Prior Injury Dialog - Start

//$(document).ready(function () {
//    if ($('#PriorInjury_Yes').is(":checked")) {        
//        $('#PriorInjurylink').show();        
//    }
//    else
//    { $('#PriorInjurylink').hide(); }
//});

//$(document).ready(function () {
//    $('#PriorInjury_No').click(function () {
//        $('#PriorInjurylink').hide();
//    });
//});

//$(document).ready(function () {
//    $('#PriorInjurylink').click(function () {
//        $("#PriorInjurydiv").dialog({
//            height: 480,
//            width: 620,
//            modal: false,
//            open: function(event, ui) {
//                    var cssObj = {
//                        'margin-top': '20px',
//                        'margin-left': '35px',
//                        'height': '300',
//                        'width': '500'
//                    }
//                    $('#PriorInjuryTemp').css(cssObj)
//                    var temp;
//                    temp = $('#WorkersComp_PriorInjuryExplanation').val();
//                    $('#PriorInjuryTemp').val(temp);   
//                },
//                buttons: {
//                    "OK": function () {
//                        $('#PriorInjurylink').show();
//                        temp = $('#PriorInjuryTemp').val();
//                        $('#WorkersComp_PriorInjuryExplanation').val(temp);
//                        $(this).dialog("close")
//                    }
//            }
//        }); return false;
//    });
//});



//$(document).ready(function () {
//    $('#PriorInjury_Yes').click(function () {
//        if ($('#PriorInjury_Yes').attr('checked')) {
//             $("#PriorInjurydiv").dialog({
//                height: 480,
//                width: 620,
//                modal: false,
//                open: function (event, ui) {
//                    var cssObj = {
//                        'margin-top': '20px',
//                        'margin-left': '35px',
//                        'height': '300',
//                        'width': '500'
//                    }
//                    $('#PriorInjuryTemp').css(cssObj)
//                    var temp;
//                    temp = $('#WorkersComp_PriorInjuryExplanation').val();
//                    $('#PriorInjuryTemp').val(temp);
//                },
//                buttons: {
//                    "OK": function () {
//                        $('#PriorInjurylink').show();                       
//                        temp = $('#PriorInjuryTemp').val();                        
//                        $('#WorkersComp_PriorInjuryExplanation').val(temp);
//                        $(this).dialog("close")
//                    }
//                }
//            });

//        }
//        else {
//            $('#PriorInjurylink').hide();
//        }
//    });
//});

// Prior Injury Dialog - End

// Prior Loss Dialog - Start

$(document).ready(function () {
    if ($('#PriorLoss_Yes').is(":checked")) {
        $('#PriorLosslink').show();
    }
    else
    { $('#PriorLosslink').hide(); }
});

$(document).ready(function () {
    $('#PriorLoss_No').click(function () {
        $('#PriorLosslink').hide();
    });
});

//$(document).ready(function () {
//    $('#PriorLosslink').click(function () {
//        $("#PriorLossdiv").dialog({
//            height: 480,
//            width: 620,
//            modal: false,
//            open: function (event, ui) {
//                var cssObj = {
//                    'margin-top': '20px',
//                    'margin-left': '35px',
//                    'height': '300',
//                    'width': '500'
//                }
//                $('#PriorLossTemp').css(cssObj)
//                var temp;
//                temp = $('#WorkersComp_PriorLossExplanation').val();
//                $('#PriorLossTemp').val(temp);
//            },
//            buttons: {
//                "OK": function () {
//                    $('#PriorLosslink').show();
//                    temp = $('#PriorLossTemp').val();
//                    $('#WorkersComp_PriorLossExplanation').val(temp);
//                    $(this).dialog("close")
//                }
//            }
//        }); return false;
//    });
//});



//$(document).ready(function () {
//    $('#PriorLoss_Yes').click(function () {
//        if ($('#PriorLoss_Yes').attr('checked')) {            
//            $("#PriorLossdiv").dialog({
//                height: 480,
//                width: 620,
//                modal: false,
//                open: function (event, ui) {
//                    var cssObj = {
//                        'margin-top': '20px',
//                        'margin-left': '35px',
//                        'height': '300',
//                        'width': '500'
//                    }
//                    $('#PriorLossTemp').css(cssObj)
//                    var temp;
//                    temp = $('#WorkersComp_PriorLossExplanation').val();
//                    $('#PriorLossTemp').val(temp);
//                },
//                buttons: {
//                    "OK": function () {
//                        $('#PriorLosslink').show();
//                        temp = $('#PriorLossTemp').val();
//                        $('#WorkersComp_PriorLossExplanation').val(temp);
//                        $(this).dialog("close")
//                    }
//                }
//            });

//        }
//        else {
//            $('#PriorLosslink').hide();
//        }
//    });
//});

// SPecial Trips Dialog - Start

$(document).ready(function () {
    if ($('#Trips_Yes').is(":checked")) {
        $('#Tripslink').show();
    }
    else
    { $('#Tripslink').hide(); }
});

$(document).ready(function () {
    $('#Trips_No').click(function () {
        $('#Tripslink').hide();
    });
});

$(document).ready(function () {
    $('#Tripslink').click(function () {
        $("#Tripsdiv").dialog({
            height: 480,
            width: 620,
            modal: false,
            open: function (event, ui) {
                var cssObj = {
                    'margin-top': '20px',
                    'margin-left': '35px',
                    'height': '300',
                    'width': '500'
                }
                $('#TripsTemp').css(cssObj)
                var temp;
                temp = $('#WorkersComp_TripsExplanation').val();
                $('#TripsTemp').val(temp);
            },
            buttons: {
                "OK": function () {
                    $('#Tripslink').show();
                    temp = $('#TripsTemp').val();
                    $('#WorkersComp_TripsExplanation').val(temp);
                    $(this).dialog("close")
                }
            }
        }); return false;
    });
});

$(document).ready(function () {
    $('#Trips_No').click(function () {
        if ($('#Trips_No').attr('checked')) {
            setEnabledButtons();
        }
    });
});
//$(document).ready(function () {
//    $('#Trips_Yes').click(function () {
//        if ($('#Trips_Yes').attr('checked')) {
//            setEnabledButtons();
//            $("#Tripsdiv").dialog({
//                height: 480,
//                width: 620,
//                modal: false,
//                open: function (event, ui) {
//                    var cssObj = {
//                        'margin-top': '20px',
//                        'margin-left': '35px',
//                        'height': '300',
//                        'width': '500'
//                    }
//                    $('#TripsTemp').css(cssObj)
//                    var temp;
//                    temp = $('#WorkersComp_TripsExplanation').val();
//                    $('#TripsTemp').val(temp);
//                },
//                buttons: {
//                    "OK": function () {
//                        $('#Tripslink').show();
//                        temp = $('#TripsTemp').val();
//                        $('#WorkersComp_TripsExplanation').val(temp);
//                        $(this).dialog("close")
//                    }
//                }
//            });

//        }
//        else {
//            $('#Tripslink').hide();
//        }
//    });
//});

// Special Trips Dialog - End

$(document).ready(function () {
    if ($('#PriorLoss_Yes').is(":checked")) {
        $('#GQPriorLoss').css('height', '70px')
        $('#PriorLossdiv').show();
        
    }
    else
    { $('#PriorLossdiv').hide(); }
});

$(document).ready(function () {
    $("input[name='WorkersComp.PriorLoss']").click(function () {
        if ($('#PriorLoss_Yes').attr('checked')) {
            $('#GQPriorLoss').css('height', '70px')
            $('#PriorLossdiv').show("slide");
            setEnabledButtons();
           
        }
        else {
            setEnabledButtons();
            $('#GQPriorLoss').css('height', '30px')
            $('#PriorLossdiv').hide();
        }

    });
});

$(document).ready(function () {
    if ($('#PriorInjury_Yes').is(":checked")) {
        $('#GQPriorInjury').css('height', '70px')
        $('#PriorInjurydiv').show();
        setEnabledButtons();
    }
    else {
        setEnabledButtons();
        $('#PriorInjurydiv').hide(); 
     }
});

$(document).ready(function () {
    $("input[name='WorkersComp.PriorInjury']").click(function () {
        if ($('#PriorInjury_Yes').attr('checked')) {
            $('#GQPriorInjury').css('height', '70px')
            $('#PriorInjurydiv').show("slide");
            setEnabledButtons();
        }
        else {
            setEnabledButtons();
            $('#GQPriorInjury').css('height', '30px')
            $('#PriorInjurydiv').hide();
        }

    });
});
$(document).ready(function () {
    if ($("input[name='LocationFlag']").is(":checked")) {
            $('#PhysLocation').hide();
       // $("input[name='WorkersComp.Address']").valueOf('sdfkj');
    }
    else
    { $('#PhysLocation').show(); }
});


$(document).ready(function () {
    $("input[name='LocationFlag']").click(function () {

        $("input[name='WorkersComp.Address']").val($("input[name='Insured.Address']").val());
        $("input[name='WorkersComp.Address2']").val($("input[name='Insured.Address2']").val());
        $("input[name='WorkersComp.City']").val($("input[name='Insured.City']").val());
        $("input[name='WorkersComp.State']").val($("input[name='Insured.State']").val());
        $("input[name='WorkersComp.Zip']").val($("input[name='Insured.Zip']").val());
        $("#PhysLocation").toggle();
            var optionlimits = "";
        var State = $("#LocationState").val();
        if (State === "CA")
            optionlimits = "<option value='2'>$1,000,000/$1,000,000/$1,000,000</option>";
        else if (State === "AZ" || State === "DE" || State === "FL" || State === "IL" || State === "MD" || State === "NV" || State === "NJ" || State === "VA" || State === "DC")
            optionlimits = "<option value='0'>$100,000/$500,000/$100,000</option><option value='1'>$500,000/$500,00/$500,000</option><option value='2'>$1,000,000/$1,000,000/$1,000,000</option>";
        else if (State === "OR")
            optionlimits = "<option value='1'>$500,000/$500,00/$500,000</option>";
        else
            optionlimits = "<option value='0'>$100,000/$500,000/$100,000</option><option value='1'>$500,000/$500,00/$500,000</option>";

        $("#WCLiabilityLimitations").html(optionlimits);
    });
});

$(document).ready(function () {    
    $("input[name='Quote.EffectiveDate']").datepicker({
         minDate: '0',
        numberOfMonths: 2,
        onSelect: function (dateText) {
            var newDate = new Date(dateText);
            var mm = newDate.getMonth();
            mm++;
            var dd = newDate.getDate();
            var yyyy = newDate.getFullYear();
            var expyyyy = newDate.getFullYear() + 1;
            var date = pad(mm, 2) + '/' + pad(dd, 2) + '/' + yyyy;
            var expdate = pad(mm, 2) + '/' + pad(dd, 2) + '/' + expyyyy;
            $("input[name='Quote.EffectiveDate']").val(date);
            $("input[name='Quote.ExpirationDate']").val(expdate);
            }
      });
});

$(document).ready(function () {
    $(".dp").datepicker({
        //        minDate: '0',
        numberOfMonths: 2
        
    });
});

//$(document).ready(function () {
//    $("input[name='WorkersComp.WCEffectiveDate']").datepicker({
////        minDate: '0',
//        numberOfMonths: 2,
//        onSelect: function (dateText) {
//            var newDate = new Date(dateText);
//            var mm = newDate.getMonth();
//            mm++;
//            var dd = newDate.getDate();
//            var yyyy = newDate.getFullYear() + 1;
//            var date = pad(mm, 2) + '/' + pad(dd, 2) + '/' + yyyy;
//            $("input[name='WorkersComp.WCEffectiveDate']").val(date);
//        }
//    });
//});

$(document).ready(function () {    
    $("input[name='WorkersComp.PropertyEffectiveDate']").datepicker({
//        minDate: '0',
        numberOfMonths: 2,
        onSelect: function (dateText) {
            var newDate = new Date(dateText);
            var mm = newDate.getMonth();
            mm++;
            var dd = newDate.getDate();
            var yyyy = newDate.getFullYear() + 1;
            var date = pad(mm, 2) + '/' + pad(dd, 2) + '/' + yyyy;
            $("input[name='WorkersComp.PropertyEffectiveDate']").val(date);
        }
    });
});

$(document).ready(function () {
     $("input[name='WorkersComp.UmbrellaEffectiveDate']").datepicker({
        //        minDate: '0',
        numberOfMonths: 2,
        onSelect: function (dateText) {
            var newDate = new Date(dateText);
            var mm = newDate.getMonth();
            mm++;
            var dd = newDate.getDate();
            var yyyy = newDate.getFullYear() + 1;
            var date = pad(mm, 2) + '/' + pad(dd, 2) + '/' + yyyy;
            $("input[name='WorkersComp.UmbrellaEffectiveDate']").val(date);
        }
    });
});

$(document).ready(function () {
    $("input[name='WorkersComp.BondEffectiveDate']").datepicker({
        //        minDate: '0',
        numberOfMonths: 2,
        onSelect: function (dateText) {
            var newDate = new Date(dateText);
            var mm = newDate.getMonth();
            mm++;
            var dd = newDate.getDate();
            var yyyy = newDate.getFullYear() + 1;
            var date = pad(mm, 2) + '/' + pad(dd, 2) + '/' + yyyy;
            $("input[name='WorkersComp.BondEffectiveDate']").val(date);
        }
    });
});

$(document).ready(function () {
    $("input[name='WorkersComp.DirectorsEffectiveDate']").datepicker({
        //        minDate: '0',
        numberOfMonths: 2,
        onSelect: function (dateText) {
            var newDate = new Date(dateText);
            var mm = newDate.getMonth();
            mm++;
            var dd = newDate.getDate();
            var yyyy = newDate.getFullYear() + 1;
            var date = pad(mm, 2) + '/' + pad(dd, 2) + '/' + yyyy;
            $("input[name='WorkersComp.DirectorsEffectiveDate']").val(date);
        }
    });
});

/* Empty field backgrounds */

$(document).ready(function () {
    $('input[type="text"]').addClass("idleField");
    $('input[type="text"]').focus(function () {
        $(this).removeClass("idleField").addClass("focusField");
    });
    $('input[type="text"]').blur(function () {
        $(this).removeClass("focusField").addClass("idleField");
    });
});

/* Menu Effects */

//function submenu() {
//    $(" #submenu ul ").css({ display: "none" }); // Opera Fix
//    $(" #submenu li").hover(function () {
//        $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(400);
//    }, function () {
//        $(this).find('ul:first').css({ visibility: "hidden" });
//    });
//}
//$(document).ready(function () {
//    submenu();
//});


/* Button Effects */

  $(document).ready(function() {
    $("button").button("widgets");
});

$(document).ready(function() {
    $(".fg-button").hover(
	function(){ 
		$(this).addClass("ui-state-hover"); 
	},
	function(){ 
		$(this).removeClass("ui-state-hover"); 
	} )
});

$(document).ready(function () {
    $(".gg-button").hover(
	function () {
	    
	},
	function () {
	    $(this).removeClass("gg-button-hover");
	})
});

// TABS

//----------------------------------------------------------------------------------------------------------------     
//  Agency Home Page
//----------------------------------------------------------------------------------------------------------------
$(function () {
    $("#subTabs").tabs();
});

// JQGRIDS

//----------------------------------------------------------------------------------------------------------------     
//  Agency Home Page
//----------------------------------------------------------------------------------------------------------------


      


      //----------------------------------------------------------------------------------------------------------------     
      //  Masking Functions
      //----------------------------------------------------------------------------------------------------------------

      jQuery(document).ready(function () {
          $(".phone").mask("(999) 999-9999");
      });
      jQuery(document).ready(function () {
          $(".fein").mask("99-9999999");
      });

      jQuery(document).ready(function () {
          $(':radio').buttonset();
      });

//      jQuery(document).ready(function () {
//          $("#DirectEmployees_No").buttonset();

//      });

      //----------------------------------------------------------------------------------------------------------------     
      //  Get Zip Functions
      //----------------------------------------------------------------------------------------------------------------

//      $(document).ready(function () {
//        $("#PrintQuote").click (function(){
//            var qc = $("#QuoteCode").val();
//                if (zip == null) { return }
//                else {
                    
      
      //------Insured---------------------------------------------------------------------------------------------------
      $(document).ready(function () {
          $("#LocationZip").blur(function () {
              var zip = $("#LocationZip").val();
              if (zip == null) { return }
              else {
                  var path = "/WorkersComp/GetZip/" + zip;
                  $.getJSON(path, null, function (json) {
                      $.each(json, function () {
                          if (this.State == null) {
                              alert(zip + " is not a valid zipcode!");
                          } else {
                              $("#LocationState").val(this.State);
                              $("#LocationCity").val(this.City);
                              //need to populate the correct rate options
                              var State = $("#LocationState").val();
                              var optionlimits = "";
                              if (State === "CA")
                                  optionlimits = "<option value='2'>$1,000,000/$1,000,000/$1,000,000</option>";
                              else if (State === "AZ" || State === "DE" || State === "FL" || State === "IL" || State === "MD" || State === "NV" || State === "NJ" || State === "VA" || State === "DC")
                                  optionlimits = "<option value='0'>$100,000/$500,000/$100,000</option><option value='1'>$500,000/$500,00/$500,000</option><option value='2'>$1,000,000/$1,000,000/$1,000,000</option>";
                              else if (State === "OR")
                                  optionlimits = "<option value='1'>$500,000/$500,00/$500,000</option>";
                              else
                                  optionlimits = "<option value='0'>$100,000/$500,000/$100,000</option><option value='1'>$500,000/$500,00/$500,000</option>";

                              $("#WCLiabilityLimitations").html(optionlimits);

                          }
                      });
                  });
              }
          });
      });
      $(document).ready(function () {
          $("#FederalID").blur(function () {
            var pathname = window.location.pathname;
              if (pathname.toUpperCase().indexOf("CREATE") > 0) {
                  var fein = $("#FederalID").val();
                  if (fein == null) { return }
                  else {
                      $.ajax({
                          url: "/WorkersComp/CheckFEIN/",
                          data: { fein: fein },
                          success: function (data) {
                              if (data == "1") {
                                  alert("A Quote or Policy Already Exists for Federal ID " + fein + ".  Please contact our office at 888-833-4158.");
                                  
                                      $("#FederalID").val("");
                                      $("#FederalID").focus();
                            
                              }
                          }
                      });

                  }
              }
          });
      });

      $(document).ready(function () {
          $("#InsuredZip").blur(function () {
              var zip = $("#InsuredZip").val();
              if (zip == null) { return }
              else {
                  var path = "/WorkersComp/GetZip/" + zip;                  
                  $.getJSON(path, null, function (json) 
                    { $.each(json, function()
                      {                          
                          

                        
                        if (this.State == null || this.State == "" || this.State == " ") {
                                alert(zip + " is not a valid zipcode!");
                          } else {
                                $("#InsuredState").val(this.State);
                              $("#InsuredCity").val(this.City);
                          }
                          if($("input[name='LocationFlag']").attr('checked')) {
                   
                              $("input[name='WorkersComp.Address']").val($("input[name='Insured.Address']").val());
                                $("input[name='WorkersComp.Address2']").val($("input[name='Insured.Address2']").val());
                                    $("input[name='WorkersComp.City']").val($("input[name='Insured.City']").val());
                                $("input[name='WorkersComp.State']").val($("input[name='Insured.State']").val());
                                $("input[name='WorkersComp.Zip']").val($("input[name='Insured.Zip']").val());
                         }
                          var State = $("#LocationState").val();
                          if (State === "CA")
                              optionlimits = "<option value='2'>$1,000,000/$1,000,000/$1,000,000</option>";
                          else if (State === "AZ" || State === "DE" || State === "FL" || State === "IL" || State === "MD" || State === "NV" || State === "NJ" || State === "VA" || State === "DC")
                              optionlimits = "<option value='0'>$100,000/$500,000/$100,000</option><option value='1'>$500,000/$500,00/$500,000</option><option value='2'>$1,000,000/$1,000,000/$1,000,000</option>";
                          else if (State === "OR")
                              optionlimits = "<option value='1'>$500,000/$500,00/$500,000</option>";
                          else
                              optionlimits = "<option value='0'>$100,000/$500,000/$100,000</option><option value='1'>$500,000/$500,00/$500,000</option>";
                          $("#WCLiabilityLimitations").html(optionlimits);
                    });                   
                 });
              }
          });
      });

      $(document).ready(function () {
          $("#Agency_Zip").blur(function () {
              var zip = $("#Agency_Zip").val();
              if (zip == null) { return }
              else {
                  var path = "/WorkersComp/GetZip/" + zip;
                  $.getJSON(path, null, function (json) {
                      $.each(json, function () {
                          if (this.State == null) {
                              alert(zip + " is not a valid zipcode!");
                          } else {
                              $("#Agency_State").val(this.State);
                              $("#Agency_City").val(this.City);
                          }
                      });
                  });
              }
          });
      });

      //------Workers Comp Location-------------------------------------------------------------------------------------------

      $(document).ready(function () {
          $("#LocationZip").blur(function () {
              var zip = $("#LocationZip").val();
              if (zip == null) { return }
              else {
                  var path = "/WorkersComp/GetZip/" + zip;
                  $.getJSON(path, null, function (json) {
                      $.each(json, function () {                          
                          if (this.State == null) {
                              alert(zip + " is not a valid zipcode!");
                          } else {
                              $("#LocationState").val(this.State);
                              $("#LocationCity").val(this.City);
                          }
                      });
                  });
              }
          });
      });

      $(document).ready(function () {
          $("#Zip").blur(function () {
              var zip = $("#Zip").val();
              if (zip == null) { return }
              else {
                  var path = "/WorkersComp/GetZip/" + zip;
                  $.getJSON(path, null, function (json) {
                      $.each(json, function () {
                          if (this.State == null) {
                              alert(zip + " is not a valid zipcode!");
                          } else {
                              $("#State").val(this.State);
                              $("#City").val(this.City);
                              
                          }
                      });
                  });
              }
          });
      });
     
      //----------------------------------------------------------------------------------------------------------------     
      //  Validation Functions
      //----------------------------------------------------------------------------------------------------------------


//$(document).ready(function () {
//      $.validator.setDefaults({
//          submitHandler: function () { alert("submitted!"); },
//          highlight: function (input) {
//              $(input).addClass("ui-state-highlight");
//          },
//          unhighlight: function (input) {
//              $(input).removeClass("ui-state-highlight");
//          }
//      });

      //  });

      $(document).ready(function () {
          if (window.location.pathname.indexOf("Admin") < 0) {
              $("#InsuredCity").attr('disabled', true);
              $("#LocationCity").attr('disabled', true);
              $("input[name='Quote.ExpirationDate']").attr('disabled', true);
          }
          else {
              $("#ExpirationDate").removeAttr('disabled');
          }
          $("#InsuredState").attr('disabled', true);
          $("#LocationState").attr('disabled', true);
          $("#wcPremium").attr('disabled', true);
          $("#wcTotalCharges").attr('disabled', true);
          $("#wcTotalPremium").attr('disabled', true);
          $("#wccharges").attr('disabled', true);
         

          $("#errorFS").hide();
          $("#SubmitSuccess").hide();
      });

//  $(document).ready(function () {
//      $("#wc_submit").click(function () {
//          $("#InsuredCity").removeAttr('disabled'); 
//          $("#InsuredState").removeAttr('disabled'); 
//          $("#LocationCity").removeAttr('disabled');
//          $("#LocationState").removeAttr('disabled');
//          $("input[name='Quote.ExpirationDate']").removeAttr('disabled'); 
//                     
//      });
//  });

  $(document).ready(function () {
//      $("#WorkersCompForm").submit(function () {
//          $("#InsuredCity").removeAttr('disabled');
//          $("#InsuredState").removeAttr('disabled');
//          $("#LocationCity").removeAttr('disabled');
//          $("#LocationState").removeAttr('disabled');
////          $("input[name='WorkersComp.PriorInjuryExplanation']").removeAttr('display: none');
//          $("input[name='Quote.ExpirationDate']").removeAttr('disabled');
//        
//      });
  });


  $(document).ready(function () {
      $("#WCForm").validate(
            {
		    rules: {
			    InsuredName: "required"
		    },
		    messages: {
			    InsuredName: "Please enter your firstname"
			    }
            });
       });


$(document).ready(function () {
    $("ul.sf-menu").supersubs({
        minWidth: 12,   // minimum width of sub-menus in em units 
        maxWidth: 27,   // maximum width of sub-menus in em units 
        extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
        // due to slight rounding differences and font-family 
    }).superfish();  // call supersubs first, then superfish, so that subs are 
    // not display:none when measuring. Call before initialising 
    // containing tabs for same reason. 
});

//$(document).ready(function () {
//    $('ul.sf-menu').superfish();  
//});
$(document).ready(function () {
    $("#boardofdirectors").colorbox({
        width: "50%",
        inline: true,
        href: "#inline_board",
        speed: 300
    });
});

$(document).ready(function () {
    $("#contactus").colorbox({
        width: "50%",
        inline: true,
        href: "#inline_contact",
        speed: 300
    });
});

$(document).ready(function () {
    $("#execteam").colorbox({
        width: "50%",
        inline: true,
        href: "#inline_execteam",
        speed: 300
    });
});

$(document).ready(function(){
    $("#historylink").colorbox({
       width: "50%",
       inline: true,
       href: "#inline_history",
       speed: 300 
      });
   });

$(document).ready(function () {
    $("#joinlink").colorbox({ width: "50%", inline: true, href: "#inline_join", speed: 300 });
        });

//$(document).ready(function () {
//    $("#chargesdetail").click(function () {
//        if ($('#chargesdetail').attr('checked')) {
//            $('#wcCharges').show("drop");
//        }
//        else {
//            $('#wcCharges').hide("fast");
//        }
//    });
//});

$(document).ready(function () {
    $("#chargesdetail").click(function () {
         $("#wcCharges").toggle();
          return false;
       });
  });

  $(document).ready(function () {
      $("#DirectEmployees_Yes").click(function () {
          if ($('#DirectEmployees_Yes').attr('checked')) {
              setEnabledButtons();
              $("#HOAdialog").dialog({              
              modal: true,
              buttons: {
                  Ok: function () { $(this).dialog("close"); }
                },
              width: 480,
              height: 250
              });
          }
      });
  });
  $(document).ready(function () {
      $("#DirectEmployees_No").click(function () {

          setEnabledButtons();
      });
  });
  $(document).ready(function () {
      $("#Trips_Yes").click(function () {

          setEnabledButtons();
      });
  });
  $(document).ready(function () {
      $("#Operations1").click(function () {
          setEnabledButtons();
          $("#TimeSharedialog").dialog({
              modal: true,
              buttons: {
                  Ok: function () { $(this).dialog("close"); }
              },
              width: 480,
              height: 250
          });
      });
  });
  $(document).ready(function () {
      $("#Operations2").click(function () {
          setEnabledButtons();
          
      });
  });
  $(document).ready(function () {
      $("#Operations3").click(function () {
          setEnabledButtons();

      });
  });
  $(document).ready(function () {
      $("#Operations4").click(function () {
          setEnabledButtons();

      });
  });
  $(document).ready(function () {
      $("#Operations8").click(function () {
          setEnabledButtons();

      });
  });

  $(document).ready(function () {
      $("#Operations5").click(function () {
          setEnabledButtons();
          $("#CommPUD").dialog({
              modal: true,
              buttons: {
                  Ok: function () { $(this).dialog("close"); }
              },
              width: 480,
              height: 250
          });
      });
  });
  $(document).ready(function () {
      $("#Operations6").click(function () {
          setEnabledButtons();
          $("#CommPUD").dialog({
              modal: true,
              buttons: {
                  Ok: function () { $(this).dialog("close"); }
              },
              width: 480,
              height: 250
          });
      });
  });

 $(document).ready(function () {
     $("#Operations7").click(function () {
         $("#CommPUD").dialog({
             modal: true,
             buttons: {
                 Ok: function () { $(this).dialog("close"); }
             },
             width: 480,
             height: 250
         });
     });
 });
 $(document).ready(function () {
     $("#Operations9").click(function () {
         setEnabledButtons()
     });
 });
  function setEnabledButtons() {
      if ($('#DirectEmployees_Yes').attr('checked') || $('#OtherStates_Yes').attr('checked') || $('#HasSubcontracts_No').attr('checked') || $('#Operations1').attr('checked')) {

          $("#wc_saveandsubmit").attr("disabled", "true");
          $("#wc_saveandsubmit").css("background-color", "gray");
          $("#wc_refer").attr("disabled", "true");
          $("#wc_refer").css("background-color", "gray");
          $("#wc_saveandsubmit2").attr("disabled", "true");
          $("#wc_saveandsubmit2").css("background-color", "gray");
          $("#wc_refer2").attr("disabled", "true");
          $("#wc_refer2").css("background-color", "gray");
          $("#wc_saveandsubmitB").attr("disabled", "true");
          $("#wc_saveandsubmitB").css("background-color", "gray");
          $("#wc_referB").attr("disabled", "true");
          $("#wc_referB").css("background-color", "gray");
          $("#wc_saveandsubmitB2").attr("disabled", "true");
          $("#wc_saveandsubmitB2").css("background-color", "gray");
          $("#wc_referB2").attr("disabled", "true");
          $("#wc_referB2").css("background-color", "gray");
      }
      else if ($('#PriorLoss_Yes').attr('checked') || $('#PriorInjury_Yes').attr('checked') || $('#NumberOfUnits').val() > 1000 || $('#Operations9').attr('checked') || $('#Operations5').attr('checked') || $('#Operations6').attr('checked') || $('#Operations7').attr('checked') || $('#Trips_Yes').attr('checked')) {
          $("#wc_saveandsubmit").attr("disabled", "true");
          $("#wc_saveandsubmit").css("background-color", "gray");
          $("#wc_refer").removeAttr('disabled');
          $("#wc_refer").css("background-color", "#CC7A22");
          $("#wc_saveandsubmit2").attr("disabled", "true");
          $("#wc_saveandsubmit2").css("background-color", "gray");
          $("#wc_refer2").removeAttr('disabled');
          $("#wc_refer2").css("background-color", "#CC7A22");
          $("#wc_saveandsubmitB").attr("disabled", "true");
          $("#wc_saveandsubmitB").css("background-color", "gray");
          $("#wc_referB").removeAttr('disabled');
          $("#wc_referB").css("background-color", "#CC7A22");
          $("#wc_saveandsubmitB2").attr("disabled", "true");
          $("#wc_saveandsubmitB2").css("background-color", "gray");
          $("#wc_referB2").removeAttr('disabled');
          $("#wc_referB2").css("background-color", "#CC7A22");
      }
      else {

          $("#wc_saveandsubmit").removeAttr('disabled');
          $("#wc_saveandsubmit").css("background-color", "#CC7A22");

          $("#wc_saveandsubmit2").removeAttr('disabled');
          $("#wc_saveandsubmit2").css("background-color", "#CC7A22");
          $("#wc_refer2").attr("disabled", "true");
          $("#wc_refer2").css("background-color", "gray");
          $("#wc_refer").attr("disabled", "true");
          $("#wc_refer").css("background-color", "gray");
          $("#wc_saveandsubmitB").removeAttr('disabled');
          $("#wc_saveandsubmitB").css("background-color", "#CC7A22");

          $("#wc_saveandsubmitB2").removeAttr('disabled');
          $("#wc_saveandsubmitB2").css("background-color", "#CC7A22");
          $("#wc_referB2").attr("disabled", "true");
          $("#wc_referB2").css("background-color", "gray");
          $("#wc_referB").attr("disabled", "true");
          $("#wc_referB").css("background-color", "gray");
      }


  };
  $(document).ready(function () {
      $('#NumberOfUnits').blur(function () {
          setEnabledButtons();

      });

  });
  $(document).ready(function () {
      $("#OtherStates_Yes").click(function () {
          if ($('#OtherStates_Yes').attr('checked')) {
              setEnabledButtons();

              $("#HOALocdialog").dialog({
                  modal: true,
                  buttons: {
                      Ok: function () { $(this).dialog("close"); }
                  },
                  width: 480,
                  height: 250
              });
          }
      });
  });

  $(document).ready(function () {
      $("#OtherStates_No").click(function () {
          setEnabledButtons();
      });
  });

//  $(document).ready(function () {
//      $("#PriorLoss_Yes").click(function () {
//          if ($('#PriorLoss_Yes').attr('checked')) {
//              $("#PriorLossDialog").dialog({ height: 150, modal: true, buttons: {
//                  Ok: function () { $(this).dialog("close"); }
//              }, width: 480,
//                  height: 250
//              }
//);
//          }
//      });
//  });

//  $(document).ready(function () {
//      $("#PriorInjury_Yes").click(function () {
//          if ($('#PriorInjury_Yes').attr('checked')) {
//              $("#PriorInjuryDialog").dialog({ height: 150, modal: true, buttons: {
//                  Ok: function () { $(this).dialog("close"); }
//              }, width: 480,
//                  height: 250
//              }
//);
//          }
//      });
//  });

  $(document).ready(function () {
      $("#HasSubcontracts_No").click(function () {
          if ($('#HasSubcontracts_No').attr('checked')) {
              setEnabledButtons();
              $("#HasSubcontractsDialog").dialog({
                 modal: true,
                 buttons: {
                  Ok: function () { $(this).dialog("close"); }
                        },
                 width: 480,
                 height: 250
              });
            }
        });
    });

     $(document).ready(function () {
      $("#HasSubcontracts_Yes").click(function () {
          setEnabledButtons();
      });
  });

//  $(document).ready(function () {
//      $("#PrintQuote_App").click(function () {
//          var quote = $("#QuoteCode").val();
//          if (quote == null) { return }
//          else {
//              var path = "/WorkersComp/PrintQuote/" + quote;
//               window.open(path);
//                   return false;
//                  
//               }
//           });

//       });

//       $(document).ready(function () {
//           $("#PrintBrokerIns").click(function () {
//               var quote = $("#QuoteCode").val();
//               if (quote == null) { return }
//               else {
//                   var path = "/WorkersComp/PrintQuote/" + quote;
//                   window.open(path);
//                   return false;

//               }
//           });

//       });

//       $(document).ready(function () {
//           $("#PrintCover").click(function () {
//               var quote = $("#QuoteCode").val();
//               if (quote == null) { return }
//               else {
//                   var path = "/WorkersComp/PrintQuote/" + quote;
//                   window.open(path);
//                   return false;

//               }
//           });

//       });

  $(document).ready(function () {
      $("#PrintQuote_App").click(function () {
          var id = $("#QuoteCode").val();          
          if (id == null || id == '') { alert('Please save and create the quote before trying to print it.'); }
          else {
              var querystring = "?id=" + id + "&type=QA";
              var path = "/WorkersComp/Print/" + querystring;
              var width = 1024;
              var height = 768;
              var left = (screen.width - width) / 2;
              var top = (screen.height - height) / 2;
              var params = 'width=' + width + ', height=' + height;
              params += ', top=' + top + ', left=' + left;
              params += ', directories=no';
              params += ', location=no';
              params += ', menubar=no';
              params += ', resizable=no';
              params += ', scrollbars=no';
              params += ', status=no';
              params += ', toolbar=no';

              window.open(path, "MGAlive", params);
          }
          return false;
      });

  });

  $(document).ready(function () {
      $("#PrintBrokerIns").click(function () {
          var id = $("#QuoteCode").val();
            if (id == null) { return }
          else {
              var querystring = "?id=" + id + "&type=I";
              var path = "/WorkersComp/Print/" + querystring;
              var width = 1024;
              var height = 768;
              var left = (screen.width - width) / 2;
              var top = (screen.height - height) / 2;
              var params = 'width=' + width + ', height=' + height;
              params += ', top=' + top + ', left=' + left;
              params += ', directories=no';
              params += ', location=no';
              params += ', menubar=no';
              params += ', resizable=no';
              params += ', scrollbars=no';
              params += ', status=no';
              params += ', toolbar=no';

              window.open(path, "MGAlive", params);
          }
          return false;
      });

  });

  $(document).ready(function () {
      $("#PrintCover").click(function () {
          var id = $("#QuoteCode").val();          
          if (id == null) { return }
          else {
              var querystring = "?id=" + id + "&type=C";
              var path = "/WorkersComp/Print/" + querystring;
              var width = 1024;
              var height = 768;
              var left = (screen.width - width) / 2;
              var top = (screen.height - height) / 2;
              var params = 'width=' + width + ', height=' + height;
              params += ', top=' + top + ', left=' + left;
              params += ', directories=no';
              params += ', location=no';
              params += ', menubar=no';
              params += ', resizable=no';
              params += ', scrollbars=no';
              params += ', status=no';
              params += ', toolbar=no';

              window.open(path, "MGAlive", params);
          }
          return false;
      });

  });

  $(document).ready(function () {
      $("#PrintBrokerBind").click(function () {
          var id = $("#QuoteCode").val();          
          if (id == null) { return }
          else {
              var querystring = "?id=" + id + "&type=B";
              var path = "/WorkersComp/Print/" + querystring;
              var width = 1024;
              var height = 768;
              var left = (screen.width - width) / 2;
              var top = (screen.height - height) / 2;
              var params = 'width=' + width + ', height=' + height;
              params += ', top=' + top + ', left=' + left;
              params += ', directories=no';
              params += ', location=no';
              params += ', menubar=no';
              params += ', resizable=no';
              params += ', scrollbars=no';
              params += ', status=no';
              params += ', toolbar=no';

              window.open(path, "MGAlive", params);
              }
              return false;          
      });

      });

      $(document).ready(function () {
          $("#PrintBrokerBind").click(function () {
              var id = $("#QuoteCode").val();
              if (id == null) { return }
              else {
                  var querystring = "?id=" + id + "&type=B";
                  var path = "/WorkersComp/Print/" + querystring;
                  var width = 1024;
                  var height = 768;
                  var left = (screen.width - width) / 2;
                  var top = (screen.height - height) / 2;
                  var params = 'width=' + width + ', height=' + height;
                  params += ', top=' + top + ', left=' + left;
                  params += ', directories=no';
                  params += ', location=no';
                  params += ', menubar=no';
                  params += ', resizable=no';
                  params += ', scrollbars=no';
                  params += ', status=no';
                  params += ', toolbar=no';

                  window.open(path, "MGAlive", params);
              }
              return false;
          });

      });


      $(document).ready(function () {
        $("#WcRefer").click(function () {
//            $("#UpdateStatus").attr('checked', true);            
//            $("#**WorkersCompForm").submit();
        });
    });


    
