
/**
 * On load
 * @param {Object} '#tableColumn tbody'
 */
$(document).ready(function() {

	//hide all tbodys
	$('#tableColumn tbody').fadeOut();
	var firstTbody = $('#tableColumn table').children()[2];
	//show the body of thefirst element
	$(firstTbody).fadeIn();

	//change to a minus
	var firstHead 		= $('#tableColumn table').children()[1];
	var firstTH 		= $(firstHead).children().children()[0];
	var firstExpander 	= $(firstTH).children()[0];
 	$(firstExpander).children().attr('src', '/images/tableColumn_expander_minus.gif');

	//bind shopwtable to all the functions
	$(".expander").each(function() {
		//get head
		$(this).bind('click', function() {
			showTableInfo(this);
		});
	});

	//change the fucntion bound to the first element
	$(firstExpander).unbind().bind('click', function() {
		console.log('working');
			hideTableInfo(this);
		});

});




/**
 * Allows the user to show the tbody relative to the link
 * @param {Object} linkElement
 */
function showTableInfo(linkElement) {
		//change the image

		var img = $(linkElement).children();
		$(img).attr('src', '/images/tableColumn_expander_minus.gif');
//alert('show table');
		//get head
		var thead = $(linkElement).parents()[2];
		//get body

		var tbody = $(thead).next();

		//alert('showTable');
		tbody.fadeIn();


		$(linkElement).unbind().bind("click", function() {
                hideTableInfo(linkElement);
        });
}




/**
 * Allows the user hide the table relative to the link
 * @param {Object} linkElement
 */
function hideTableInfo(linkElement) {
		//change the image on the link
		var img = $(linkElement).children();
		$(img).attr('src', '/images/tableColumn_expander_plus.gif');


		//get head
		var thead = $(linkElement).parents()[2];
		//get body
		var tbody = $(thead).next();

		//fade it out
		$(tbody).fadeOut();

		//alert('here');
		//unbind the click, bind a new click
		$(linkElement).unbind().bind("click", function() {
               showTableInfo(linkElement);
        });
}





/*$(document).ready(function() {

	//hide all tbodys
	$('#tableColumn tbody').fadeOut(0);

	$(".expander").each(function() {
		//get head
		var thead = $(this).parents()[2];
		//get body
		var tbody = $(thead).next();
		//add the class hidden
		$(tbody).addClass('hidden');
		$(this).click(function(){
			var thead = $(this).parents()[2];
			//grab the next sibling
			var tbody = $(thead).next();
			//call toggleside on sibling
			console.log(tbody);

			var tbodyClasses = $(tbody).attr('class');

			//console.log(test[1]);

			//if hidden


			//$(tbody).fadeIn($(tbody).fadeOut(400));

		});
	});
});
*/
function showTableBody() {

	//look where the a is
}

function hideTableBody() {
	console.log('This should show when an item is clicked. In funtion');

}


/**
* Pulls the login section out and fades in the form
* @author Rob & Tony
* @see ready() hideLogin()
**/
/**function showLogin() {
    $("#slider").animate( { width:"375px", height:"65px" }, 2000, "linear", function() {
        $("#formLogin").fadeIn("slow");
            $('#tab').unbind().bind("click", function() {
                hideLogin();
            });
        });
    }*/

/**
* Fades the form and then pulls the login section in
* @author Rob & Tony
* @see showLogin()
**/
/**function hideLogin() {
    $("#formLogin").fadeOut("slow", function() {
        $("#slider").animate( { width:"0px", height:"65px" }, 2000, "linear", function() {
            $('#tab').unbind().bind("click", function() {
      			showLogin();
      		});
       	});
    });
}**/

/**
* Ready function - called after the document has been loaded
* As the login box will start open the first thing we need to do is close it
* @author Rob & Tony
* @see showLogin()
**/
/**$(document).ready(function() {
    $('#tab').bind("click", function() {
        showLogin();
    });

    $("div.rounded").corner();
});**/
