// JavaScript Document

$(document).ready(function(){ 

	$.get("services.xml", {}, function(xml){
		$('service',xml).each(function(i) {
			var sName = $(this).find("name").text();
			var sDesc = $(this).find("description").text();
			$("<li id='service" + i + "'></li>").click( function () {
				$("#service-list > ul > li").removeClass("active");
				$(this).addClass("active");
				$("#service-content").html("<h2>" + sName + "</h2>" + "<p>" + sDesc + "</p>");
			}).appendTo("#service-list > ul").html("<a href='#'>" + sName + "</a>");
		});
		$("#service0").trigger("click");		
	});

	$("#terms-content").hide();
	$("#terms-lnk").click( function () {
		$("#terms-content").toggle( );
		return false;
	});

	$.get("plans.xml", {}, function(xml){
		$('plan',xml).each(function(i) {
			var sName = $(this).find("name").text();
			var sPrice = $(this).find("price").text();
			var sDesc = $(this).find("description").text();
			$("<li id='plan" + i + "'></li>").click( function () {
				$("#plan-list > ul > li").removeClass("active");
				$(this).addClass("active");
				$("#plan-content").html("<h2>" + sPrice + "</h2>" + "<p>" + sDesc + "</p>");
			}).appendTo("#plan-list > ul").html("<a href='#'>" + sName + "</a>");
		});
		$("#plan0").trigger("click");		
	});
																	
	$.get("reasons.xml", {}, function(xml){
		$('reason',xml).each(function(i) {
			var sName = $(this).find("name").text();
			var sTitle = $(this).find("title").text();
			var sDesc = $(this).find("description").text();
			$("<li id='reason" + i + "'></li>").click( function () {
				$("#reason-list > ul > li").removeClass("active");
				$(this).addClass("active");
				$("#reason-content").html("<h2>" + sTitle + "</h2>" + "<p>" + sDesc + "</p>");
			}).appendTo("#reason-list > ul").html("<a href='#'>" + sName + "</a>");
		});
		$("#reason0").trigger("click");		
	});

/*
	$.get("top_reasons.xml", {}, function(xml){
		$('reason',xml).each(function(i) {
			var sTitle = $(this).find("title").text();
			var sDesc = $(this).find("description").text();
			$("<li></li>").mouseover( function () {
				$("#reasons-list > li").removeClass("active");
				$(this).addClass("active");
				$("#reason-desc").fadeOut("normal", function () {
					$(this).html("<div class='span-8 box'><h3>" + sTitle + "</h3><p>" + sDesc + "</p></div>").fadeIn();
				});

			}).appendTo("#reasons-list").html("<a id='reason" + i + "' href='#'>" + sTitle + "</a>");
		});
	});
*/
/****
 *  mouseover/delay method
 *
 
	$("#faq-list > li > div.content").hide();
	$("#faq-list > li > h4 > a").mouseover( function () {
		var eCurrent = $(this).parent().parent();
		var sCurrentId = eCurrent.attr("id");
		var t = setTimeout(function() {
																
			$("#faq-list > li").each(function(i) {
				$(this).removeClass("active");
				if ($(this).attr("id") != sCurrentId) {
					$(this).find("div.content").hide();
				}
			});
			eCurrent.find("div.content").slideDown();
			eCurrent.addClass("active");
    }, 500);
		$(this).mouseout( function () {
			clearTimeout(t);
		});	
	})
*/

	$("#faq-list > li > div.content").hide();
	$("#faq-list > li > a").click( function () {
		var eCurrent = $(this).parent();
		var sCurrentId = eCurrent.attr("id");
		$("#faq-list > li").each(function(i) {
			$(this).removeClass("active");
			if ($(this).attr("id") != sCurrentId) {
				$(this).find("div.content").hide();
			}
		});
		eCurrent.find("div.content").show();
		eCurrent.addClass("active");
	})

/*
	var helpDlg = $("#get-help-dlg").dialog({ 
		autoOpen: false,
		modal: true,
		width: 400,
		overlay: { 
				opacity: 0.3, 
				background: "black" 
		} 
	});
	$("#get-help-btn > a").click(function () { 
		helpDlg.dialog("open");
	});
*/	
});
