//Javascript functions that makes links on the 
//right side of the webpage, show and hide

//function to show/hide whole courses section
function linksshow(){
$("#RHS_but").click(function () {
      $("#RHS_links").show();
	  $('#RHS_but').hide();
	  $('#RHS_but_close').show();
    });
$("#RHS_but_close").click(function () {
      $("#RHS_links").hide();
	  $('#RHS_but').show();
	  $('#RHS_but_close').hide();
    });
}

//expand all
function expandAl(){
$('#expand').click(function(){
	$('#colapse').show();
	$('#expand').hide();
	$('ul.tag_container').slideDown("slow");
	$('h2.trigger').addClass("active");	
});
}

//colapse all function
function colapseAl(){
$('#colapse').click(function(){
	$('#colapse').hide();
	$('#expand').show();
	$('ul.tag_container').slideUp("slow");
	$('h2.trigger').removeClass("active");
});
}
//function for each category
function categoryshow () {
$('ul.tag_container').hide();

$('h2.trigger').toggle(function(){
	$(this).addClass("active");
	}, function(){
	$(this).removeClass("active");	
});


$('h2.trigger').click(function(){
	$(this).next('ul.tag_container').slideToggle("slow");
});
}


function linksshowie(){
$("#RHS_but").click(function () {
      $("#RHS_links").show();
	  $('#RHS_but').hide();
	  $('#RHS_but_close').show();
    });
$("#RHS_but_close").click(function () {
      $("#RHS_links").hide();
	  $('#RHS_but').show();
	  $('#RHS_but_close').hide();
    });
}

//expand all
function expandAlie(){
$('#expand').click(function(){
	$('#colapse').show();
	$('#expand').hide();
	$('ul.tag_container').show();
	$('h2.trigger').addClass("active");	
});
}

//colapse all function
function colapseAlie(){
$('#colapse').click(function(){
	$('#colapse').hide();
	$('#expand').show();
	$('ul.tag_container').hide();
	$('h2.trigger').removeClass("active");
});
}
//function for each category
function categoryshowie () {
$('ul.tag_container').hide();

$('h2.trigger').toggle(function(){
	$(this).addClass("active");
	}, function(){
	$(this).removeClass("active");	
});


$('h2.trigger').click(function(){
	$(this).next('ul.tag_container').toggle();
});


}

$(document).ready(function()
{
	$('head').append('<link rel="stylesheet" type="text/css" href="rhs/rhs.css" />');	

	var ie = false;
	jQuery.each(jQuery.browser, function(i) 
	{
	  if($.browser.msie)
	  {
		 $('head').append('<link rel="stylesheet" type="text/css" href="rhs/ie_RHS.css" />');
		 ie = true;
	  }
	});
	
	var data = '<div id="RHS_content"><div id="RHS_but"></div><div id="RHS_but_close" style="display:none;"></div><div id="RHS_links"style="display:none;"><div id="rhs_categories" class="RHS_catagory"></div></div></div>';
	$(document.body).append(data);
	
	//if(ie == true)
	//{
		$("#rhs_categories").load("rhs/rhs_categories.html",{},function(){expandAlie();colapseAlie();linksshowie();categoryshowie();});
	//}
	//else
	//{
	//	$("#rhs_categories").load("http://www.hearandplay.com/rhs/rhs_categories.html",{},function(){expandAl();colapseAl();linksshow();categoryshow ();});
	//}
	
});