// creating the liQuidprint global namespace
if (typeof(LQP) === "undefined") {
	var LQP = {};
}
// add to the window.onload without disrupting other onload functions.
LQP.oldOnLoad = window.onload;
if (typeof window.onload != 'function') {
	window.onload = function() {
		LQP.register.showHideSections();
		LQP.register.initBuyingActivity();
	};
}
else {
   	window.onload = function() {
     	LQP.oldOnLoad();
     	LQP.register.showHideSections();
		LQP.register.initBuyingActivity();
	};
}
LQP.register =  {
	initBuyingActivity: function() {
	
		var showHideFieldSet = function() {
			if (bitActivityBuying.checked  || bitActivityRelocating.checked) {
				buyingActivityFieldSet.style.display = "block";
			}
			else {
				buyingActivityFieldSet.style.display = "none";
			}
		};
		
		var bitActivityBuying = document.getElementById("bitActivityBuying");
		var bitActivityRelocating = document.getElementById("bitActivityRelocating");
		var buyingActivityFieldSet = document.getElementById("buyingActivityFieldSet");
		showHideFieldSet();
		bitActivityBuying.onclick = showHideFieldSet;
		bitActivityRelocating.onclick = showHideFieldSet;
		$("input[@name='areaGuids']").click(function () {
			if ($("input[@name='areaGuids']:checked").length > 5) {
				$(this).attr("checked","");
			}
		});
		//$("input[@name='areaGuids' checked=true]")
	},
	showHideDiv: function (idParam, displayStyle) {
		document.getElementById(idParam).style.display = displayStyle;
		// set the associate to nothing if user selects 'no'
		if (idParam == "jameson-yes" && displayStyle == "none") {
			document.getElementById("guiAssociateID").selectedIndex = 0;
		}
		if (idParam == "other-yes" && displayStyle == "none") {
			document.getElementById("szOtherAgentName").value = "";
			document.getElementById("szOtherAgentCompany").value = "";
		}
	},
	showHideSections: function() {
		if (document.getElementById("bitWorkingWithAgent-yes").getAttribute("checked")) {
			this.showHideDiv("other-yes", "block");
		}
		else {
			this.showHideDiv("other-yes", "none");
		}	
		if (document.getElementById("bitWorkingWithCompanyAgent-yes").getAttribute("checked")) {
			this.showHideDiv("jameson-yes", "block");
		}
		else {
			this.showHideDiv("jameson-yes", "none");
		}
	}
};
