// Version 1.1 by Shaun

/**
 * DisplayContent - Displays the content only if 
 * the $_GET is correct.
 * 
 * @param attrContents	- The name of the id of 
 * which to insert for the div container which will 
 * be placed within the contents container.
 * @param content		- the contents if any of which
 * the block will contain.
 */
var $x = jQuery.noConflict();

function DisplayContent(attrContents, content)
{
	$x("div#content").append("<div id=\"" + attrContents + "\">" + 
							content + "</div>");
	
	// Set the height if it's smaller than the div ^^			
	if($x("div#content").height() < $x("#" + attrContents).height())
	{
		$x("div#content").height(790);
	}
	
	// Lets set the height now.
	setTimeout(function(){
		if($x("#" + attrContents).height() > $x("#content").height())
		{
			$x("#" + attrContents).height($x("#content").height() + 10);
		}
	}, 100);
	
	$x("#" + attrContents).show();
	
	setTimeout(function(){
		$x("#" + attrContents).fadeOut(1500);
	
		setTimeout(function(){
			$x("#" + attrContents).remove();
		}, 1500);
	}, 2000);
}

// Check to see if the current document is completed 
// with loading up the script
$x(document).ready(function(){
	
	// The Id's of which to append in the contents.
	var attributes = new Array();
	attributes[0] = "furniturePicture";
	attributes[1] = "officePicture";
	attributes[2] = "schoolPlayPicture";
	attributes[3] = "officeAccessoriesPicture";
	
	//$x(".vnavInner").hide();
	
	//$x("#vnav li a img").each(function(e){
	//	$x(this).parent().attr("href", "#");
	//});
	
	//$x("#vnav li").click(function(){
	//	$x(this).find(".vnavInner").toggle(300);
	//});
	
	// set the new GET to get rid of any conflicts ^^
	$x(".vnavInner li a").each(function(i){
		var curHref = $x(this).attr("href");
		
		// set the new GET attribute.
		$x(this).attr("href", curHref + "&show=t");
	});
	
	
	// Lets get the $_GET value
	var getCat  = $x.query.get("s");
	var getShow = $x.query.get("show");
	
	
	// is it set?
	if((getCat > 0) && (getShow == 't'))
	{
		// lets check for the catgory we've selected
		if($x.query.get("c") > 0)
		{
			switch($x.query.get("c"))
			{
				case 1:
					$x(".pageFurniture").parent().find(".vnavInner").show();
					break;
				case 2:
					$x(".pageOffice").parent().find(".vnavInner").show();
					break;
				case 3:
					$x(".pageSchoolPlay").parent().find(".vnavInner").show();
					break;
				case 4:
					$x(".pageOfficeAccessories").parent().find(".vnavInner").show();
					break;
			}
		}
		
		// Is it the one we want?
		if($x("#vnav .pageFurniture").parent().find(".vnavInner li a").length > 0)
		{
			DisplayContent(attributes[0], "");
			return;
		}
		
		if($x("#vnav .pageOffice").parent().find(".vnavInner li a").length > 0)
		{
			DisplayContent(attributes[1], "");
			return;
		}
		
		if($x("#vnav .pageSchoolPlay").parent().find(".vnavInner li a").length > 0)
		{
			DisplayContent(attributes[2], "");
			return;
		}
		
		if($x("#vnav .pageOfficeAccessories").parent().find(".vnavInner li a").length > 0)
		{
			DisplayContent(attributes[3], "");
			return;
		}
	}
});
