$(document).ready(function() {
						   
	$("form.product-variants").submit(function (event) {
            if ($(event.target).find("input:checked").length === 1
             || $(event.target).find("option:selected").length === 1)
            {
                return true;
            }
        alert("Please choose a Date & Location");
        return false;
        });
	
	$("#stateListing").change(function () {
            var baseUrl = 'http://www.adjusterpro.com/insurance-adjuster-career/states';
            var suffix = 'Insurance-Adjuster.html';

            var stateName = $("#stateListing option:selected").text();
            if (stateName == "District of Columbia") {
                stateName = "WashingtonDC";
            }
            stateName = stateName.replace(' ', '-');

            window.location = baseUrl + '/' + stateName + '-' + suffix;
        });


	$("#AllStates").click(function () { 
      $("#LicensingMap").attr('src', '/images/map-default.gif');
    });
	$("#licensing_required").click(function () { 
      $("#LicensingMap").attr('src', '/images/map-Licensing_Required.gif');
    });
	$("#non-licensing").click(function () { 
      $("#LicensingMap").attr('src', '/images/map-Non_licensing.gif');
    });
	$("#reciprocating").click(function () { 
      $("#LicensingMap").attr('src', '/images/map-Reciprocating.gif');
    });

	$("#navII").hover(
		function () { $(".hovII").show(); },
		function () { $(".hovII").hide(); }
	);

	$("#navIII").hover(
		function () { $(".hovIII").show(); },
		function () { $(".hovIII").hide(); }
	);

	$("#navIV").hover(
		function () { $(".hovIV").show(); },
		function () { $(".hovIV").hide(); }
	);


	$(".hovII").hover(
		function () { $(".hovII").show(); },
		function () { $(".hovII").hide(); }
	);

	$(".hovIII").hover(
		function () { $(".hovIII").show(); },
		function () { $(".hovIII").hide(); }
	);

	$(".hovIV").hover(
		function () { $(".hovIV").show(); },
		function () { $(".hovIV").hide(); }
	);

	binders = function() {
		$("#modalCloser").click(function() {
			$("#modal").remove();
		});
		$("#modalPrinter").click(function() {
			alert('Print only contents of popup, specifically: only contents of #targetContent')
		});
	};

	showModal = function() {
		$("#modal").remove();
		$('#main').append('<div id="modal"> <span id="modalPrinter" title="Print"></span> <span id="modalCloser" title="Close"></span> <div id="modalInner"> <div class="modal"> <div class="modalInner" id="targetContent"> </div> </div> </div> </div>')
		binders();
	}
	$(".targetModal").click(function() {
		showModal();
		$("#targetContent").load(this.href,function(){  });
		return false;
	});
	$(".deleteThis").click(function() {
		alert('Delete this <li> node.\nNote this item may show up on left if drop-down selection warrants it')
	});
	$(".addThis").click(function() {
		alert('Delete this node from here and\ninsertin "My Licenses"')
	});
	$(document).keyup(function(event){
	    if (event.keyCode == 27) {
			$("#modal").remove();
	    }
	});
	
    $(".editing .credentialList li").hover(
      function () {
		$(this).addClass('licenseHover')
      }, 
      function () {
		$(this).removeClass('licenseHover')
      }
    );
    $("#choices .credentialList li").hover(
      function () {
		$(this).addClass('licenseHover')
      }, 
      function () {
		$(this).removeClass('licenseHover')
      }
    );

	$('.foundationRow td i').html('aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa')
	$("#chooseMulti").click(function() {
		$("#stateX").attr('multiple','multiple');
		$("#stateX").attr('style','height:100px');
		$('#chooseMultiText').html('Hold down the Control key (or Command on a Mac) to select more than one')
		$('#chooseMultiText').attr('style', 'font-weight:bold;color:#000;line-height:15px;margin-top:5px;')
	});
	$.fn.setAllToMaxHeight = function(){
		return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
	}
	$('div.homeFeature').setAllToMaxHeight();		
	$('div.bottomFeatures').setAllToMaxHeight();		

    /**
     * Make "Chat Live" bold if it's not offline.
     */
    var boldChatText = $('.phone a').text();
    if (boldChatText.indexOf('Offline') === -1) {
        $('.phone a').css('font-weight', 'bold');
    }

});
