function showWelcomeDialog() {
	
		$(document).ready(function(){
								   
			if($.cookie("welcometext") != "shown") {
				
				$("#dialog").css("display", "block");
				
				$("#dialog").dialog({
					bgiframe: true,
					buttons: {
						'I understand': function() {
							$.cookie("welcometext", "shown", { expires: 1 });
							$(this).dialog('close');
						}
					},
	
					modal: true,
					draggable: true,
					resizable: false,
					closeOnEscape: false,
					hide: 'slide',
					width: 680,
					height: 530,
					overlay: { background: '#000', opacity: 0.6 }
				});
			}
		});
}

function addZodiac($id) {
	if($id == "all") {
		for($i = 1; $i <= 12; $i++) {
			$("#zodiac_" + $i).css("display","block");
			$("#frm_content_zodiac_" + $i).val("1");
		}
	}
	else {
		$("#zodiac_" + $id).css("display","block");
		$("#frm_content_zodiac_" + $id).val("1");
	}
}

function removeZodiac($id) {
	$("#zodiac_" + $id).css("display","none");
	$("#frm_content_zodiac_" + $id).val("0");
}

//If no signs, add at least one.
function firstZodiac($id) {
	$populated = false;
	for($i = 1; $i <= 12; $i++) {
		//$("#zodiac_" + $i).css("display","block");
		if( $("#frm_content_zodiac_" + $i).val() == "1" ) {
			$populated = true;
			break;
		}
	}
	
	if(!$populated)
		addZodiac($id);
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//  ALERTS AND SOUNDS
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function toggleAlerts($taxonomyId) {
	if( $("#a" + $taxonomyId + ":checked").val() == "on" ) {
		$flag = true;
	}
	else {
		$flag = false;
	}
	
	$("input[@id^='a" + $taxonomyId + "_']").each(function () {
		if(!$(this).is(':disabled')) {
    		$(this).attr("checked", $flag);
		}
	}); 

// If alert is OFF then all sounds must be set OFF as well.
	if($flag == false) {
		$("input[@id^='s" + $taxonomyId + "_']").each(function () {
			if(!$(this).is(':disabled')) {
				$(this).attr("checked", $flag);
			}
		});
	}
	
	setSoundParent($taxonomyId);
	
}

function toggleSounds($taxonomyId) {
	if( $("#s" + $taxonomyId + ":checked").val() == "on" ) {
		$flag = true;
	}
	else {
		$flag = false;
	}
	
	$("input[@id^='s" + $taxonomyId + "_']").each(function () {
		if(!$(this).is(':disabled')) {
    		$(this).attr("checked", $flag);
		}
	}); 
	
	// If sound is ON then all alerts must be set as well.
	if($flag == true) {
		$("input[@id^='a" + $taxonomyId + "_']").each(function () {
			if(!$(this).is(':disabled')) {
				$(this).attr("checked", $flag);
			}
		});
	}
	
	setAlertParent($taxonomyId);
}


// If all ALERT children of a taxonomy is true, check the parent, otherwise uncheck the parent.
function setAlertParent($taxonomyId) {
	
	$flag = false;
	
	$("input[@id^='a" + $taxonomyId + "_']").each(function () {
    	if($(this).is(':checked')) {
			$flag = true;
		}
		else {
			$flag = false;
			return false;
		}
	});

	$("#a" + $taxonomyId).attr("checked", $flag);
}

// If all SOUND children of a taxonomy is true, check the parent, otherwise uncheck the parent.
function setSoundParent($taxonomyId) {
	
	$flag = false;
	
	$("input[@id^='s" + $taxonomyId + "_']").each(function () {
    	if($(this).is(':checked')) {
			$flag = true;
		}
		else {
			$flag = false;
			return false;
		}
	});

	$("#s" + $taxonomyId).attr("checked", $flag);
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//  SUBSCRIPTION
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

// Toggle children checkboxes based on parent.
function toggleTaxonomy($taxonomyId) {
	
	if( $("#t" + $taxonomyId + ":checked").val() == "on" ) {
		$flag = true;
	}
	else {
		$flag = false;
	}
	
	$("input[@id^='t" + $taxonomyId + "_']").each(function () {
		if(!$(this).is(':disabled')) {
    		$(this).attr("checked", $flag);
		}
	}); 
}

// If all children of a taxonomy is true, check the parent, otherwise uncheck the parent.
function setTaxonomyParent($taxonomyId) {
	
	$flag = false;
	
	$("input[@id^='t" + $taxonomyId + "_']").each(function () {
    	if($(this).is(':checked')) {
			$flag = true;
		}
		else {
			$flag = false;
			return false;
		}
	});

	$("#t" + $taxonomyId).attr("checked", $flag);
}

function initializeToggles($taxonomyId) {
	setTaxonomyParent($taxonomyId);
	setAlertParent($taxonomyId);
	setSoundParent($taxonomyId);
}
























