	$(document).ready(function() {

		$(".home_chooseApp img").bind("click", function() { var divToChange = $(this).parent("div").attr("id"); homeChooseAppSwitch(divToChange); });

		$(".home_Manufacturers_list span").bind("click", function() { var hm = $(this).attr("id"); homeShowManufacturerDetails(hm); });

		$("a.menuWithDrop").bind("mouseover", function() { var id = $(this).attr("id"); changeMenu(id); });

		$("a.menuWithoutDrop").bind("mouseover", function() { hideMenus(); });

		$("div.home_spotlightOn_Container").bind("mouseover", function() { hideMenus(); });

		$("div.home_chooseApp_Container").bind("mouseover", function() { hideMenus(); });

		$("div.content_holder").bind("mouseover", function() { hideMenus(); });

		createAccordion();

	});



// GLOBALLY AVAILABLE VARIABLES

	var currentSelectedSecondaryNavContainer = 'none';

	var currentPage = '';





// HOMEPAGE AJAX FUNCTIONS

	function homeChooseAppSwitch(divToChange)

	{

		var realHeight = $("#" + divToChange).height();

	    var topHeightToUse = (realHeight / 2) - 5;

	    var bottomHeightToUse = (realHeight / 2) - 6;

	    $("#" + divToChange).html('<center><img src="images/spacer.gif" border="0" height="' + topHeightToUse + '" width="1"><br><img src="images/indicator.gif" border="0"><br><img src="images/spacer.gif" border="0" height="' + bottomHeightToUse + '" width="1"></center>');



	    $.ajax({ type: "POST", url: "ajax/" + divToChange + ".php", data: '',

			success: function(msg) {

				$("#" + divToChange).fadeOut("normal",function() {

					$("#" + divToChange).html( msg ); $("#" + divToChange).fadeIn("normal");

				});

			}

		});

	}

	function homeShowManufacturerDetails(id)

	{

		$(".home_Manufacturers_list span").removeClass("hmSelected");

		$("#" + id).addClass("hmSelected");



	    $("#homeManufacturerDetails").html('<center><img src="images/indicator.gif" border="0"></center>');

		$.ajax({ type: "POST", url: "ajax/hm_details.php", data: 'manufacturer=' + id,

			success: function(msg) {

				$("#homeManufacturerDetails").fadeOut("normal",function() {

					$("#homeManufacturerDetails").html( msg ); $("#homeManufacturerDetails").fadeIn("normal");

				});

			}

		});

		setTimeout("initiateThickbox()",1000);

	}

	function initiateThickbox() { tb_init('a.thickbox'); }







// NAVIGATION STUFF

	var oldMenu = 'NULL';



	function changeMenu(id)

	{

		var currentState = $("#" + id + "_dropMenu").css("display");

		if (currentState == 'none')

		{

			if (oldMenu != 'NULL') { $("#" + oldMenu).slideUp("fast"); }

			$("#" + id + "_dropMenu").slideDown("normal");

			oldMenu = id + "_dropMenu";

		}

	}

	function hideMenus()

	{

		if (oldMenu != 'NULL') { $("#" + oldMenu).slideUp("fast"); }

		oldMenu = 'NULL';

	}





	function createAccordion()

	{

		// PRIMARY SECTIONS HEADLINES

		$(".leftLinks_primary").bind("click", function(){

			$(".leftLinks_primary").removeClass("leftLinks_primary_selected");

			$(".leftLinks_secondary").removeClass("leftLinks_secondary_selected");

			$(this).addClass("leftLinks_primary_selected");

			if (currentSelectedSecondaryNavContainer == 'none')

			{

				var category = $(this).attr("id");

				$("#" + category + "_holder").slideDown("normal");

				currentSelectedSecondaryNavContainer = category + "_holder";

			} else {

				var category = $(this).attr("id");

				thisCategory = category + "_holder";



				$("#" + currentSelectedSecondaryNavContainer).slideUp("normal");

				if (currentSelectedSecondaryNavContainer == thisCategory)

				{

					currentSelectedSecondaryNavContainer = 'none';

				} else {

					$("#" + thisCategory).slideDown("normal");

					currentSelectedSecondaryNavContainer = thisCategory;

				}

			}

		});

		// SECONDARY LINKS

		$(".leftLinks_secondary").bind("click", function(){

			var content = $(this).attr("id");

			loadStaticContent(content);



			$(".leftLinks_secondary").removeClass("leftLinks_secondary_selected");

			$(this).addClass("leftLinks_secondary_selected");

		});

	}





	function loadStaticContent(content) {

		var realHeight = $("#appContentHolder").height();

	    var topHeightToUse = (realHeight / 2) - 5;

	    var bottomHeightToUse = (realHeight / 2) - 6;

	    $("#appContentHolder").html('<center><img src="images/spacer.gif" border="0" height="' + topHeightToUse + '" width="1"><br><img src="images/contentindicator.gif" border="0"><br><img src="images/spacer.gif" border="0" height="' + bottomHeightToUse + '" width="1"></center>');



	    $.ajax({ type: "POST", url: "ajax/" + currentPage + "_contents.php", data: 'category=' + content,

			success: function(msg) {

				$("#appContentHolder").fadeOut("slow",function() {

					$("#appContentHolder").html( msg ); $("#appContentHolder").fadeIn("normal");

					var setHeight = $("#appContentHolder").height();

					setHeight = setHeight + 60;

					if (setHeight < 400 ) { setHeight = 400; }

					
					$(".content_holder").css('min-height', setHeight);

					$(".qs_table tr:odd").addClass("alt");

					$(".qs_table tr").mouseover(function() { $(this).addClass("over"); });

					$(".qs_table tr").mouseout(function() { $(this).removeClass("over"); });

				});

			}

		});

		setTimeout("initiateThickbox()",1500);

	}
