$(document).ready(function()
{
	var result=''
	//hide the sub navigation panels
	colorTable()
	$('.inner').hide()

	//when a main category is clicked, execute this function	
	$('#sideNav span').live('click',function()
	{
	//store span in variable
	var category=$(this).next('ul')
	
	if(category.is(':hidden'))
	{
	category.show(200)
	}
	else
	{
	category.hide(200)
	}

	
	});
	
	function colorTable()
	{
	$('#blue li:nth-child(odd)').css("background-color","#ccc")	
	}


//validation

	$('#required input[type=text]').focus(function()
	{
		if($(this).val()=="Please Check This Field")
		{
		$(this).val('')
		$(this).parent().find('img').remove()
		}
	});


	$('#required input[type=text]').blur(function()
	{
		
		checkField(this)
	})
	
	
	
	$('input[type=submit]').click(function()
	{

		$("#required input[type=text]").each(function()
		{
	
		result=checkField(this)
	
		})	
	
	
	if(result==false)
	{
	return false;	
	}
	});
	
	$('.reset').click(function()
	{
		$("input[type=text]").each(function()
		{
			$(this).val('')
			$(this).parent().find('img').remove()
		})
	});
	
	
	function checkField(obj)
	{
		if($(obj).val()=='' || $(obj).val()=='Please Check This Field')
		{	
		$(obj).val('Please Check This Field')
		$(obj).parent().find('img').remove()
		$(obj).parent().prepend("<img src='../images/error.gif'/>")
		return false;
		}
		else
		{
		$(obj).css({background:'#fff'})
		return true;	
		}
		
	}
});