gc_HomeHref = "";

function CurrentItemSelectionHilightDiv(pcID)
{
	this.label = '';
	this.count = '';
	this.DaDiv = $(pcID)
	this.LeftGutterWidth = $('.leftGutter').width()
	this.ThisMouseOverSpan = $('#MouseOverSpan',this.DaDiv)
	this.ThisMouseOverCount = $('#MouseOverCount',this.DaDiv)
	this.setLabel = function(pclabel){
		this.ThisMouseOverSpan.text(pclabel)
	}
	this.setCount = function(pcCount){ 
		this.ThisMouseOverCount.text(pcCount);
	}
	this.getDaDiv = function(){return this.DaDiv}
	this.setY = function(y){ 
		this.DaDiv.css('top',y - 2)	
	}
	this.setHeight = function(pHeight){
		this.DaDiv.height(pHeight+4)
	}
	this.setWidth = function(){
		this.DaDiv.width(this.LeftGutterWidth)
	}
	this.setFontWeight = function(pWeight){
		this.ThisMouseOverSpan.css('font-weight',pWeight)
	}
	this.show = function(){
		this.DaDiv.show()
	}
	this.hide = function(){
		this.DaDiv.hide()
	}
	this.setOnclick = function(pHref){
		this.DaDiv.click(function(){
			document.location.href = pHref
		})
	}
}
function loader()
{	
	
	$("#MainHeaderRow").click(function(){document.location.href=gc_HomeHref}).css('cursor','pointer')
	//TheMouseOverDiv = new CurrentItemSelectionHilightDiv('#mouseOverDiv')
	TheCurrentItemDiv = new CurrentItemSelectionHilightDiv('#CurrentItemSelectionHilight')
	$('ul.category li a').hover(OverItTest,function(){})
	$('ul.pages li a').mouseover(OverItTest)
	$('#mouseOverDiv').hover(function(){},function(){
			$(this).hide()
		}
	)
	$('.CenterContent').mouseover(function(){if(LASTOVER !== null){LASTOVER.hide()}})
}

function CreatingTheOvers(pTarget)
{
	//this creates a mouse over DIV that is absolutley positions over the A element that triggered the mouseover.
	var DaMouseOverDiv = $('#mouseOverDiv')
	var daTarget = pTarget
	var newDIV_ID = "DIV_" + parseInt(10000000 * Math.random())
	daTarget.attr('DIV_ID',newDIV_ID)
	var newDiv = DaMouseOverDiv.clone()
	newDiv.attr('id',newDIV_ID)
	newDiv.appendTo('body').hover(function(){},function(){$(this).hide()}).height(daTarget.height()).width($('.leftGutter').width()).css({'top':daTarget.offset().top -2	,'left':'0'})
	$('#MouseOverSpan',newDiv).text(daTarget.text())
	if(daTarget.parent().get(0).childNodes.length > 1)
	{
		$('#MouseOverCount',newDiv).text(daTarget.parent().get(0).childNodes[1].nodeValue)
	}
	newDiv.click(function(){document.location.href = daTarget.attr('href')})
	newDiv.css('display','none')
	newDiv.addClass('MouseOverDiv_Test')
}
LASTOVER = null;
function OverItTest(pEvent)
{
	if(LASTOVER !== null)
	{
		LASTOVER.hide()
	}
	daTarget = $(pEvent.target);
	if(daTarget.attr('DIV_ID') == undefined)
	{
		CreatingTheOvers(daTarget)
	}
	var daID = daTarget.attr('DIV_ID')
	LASTOVER = $('#'+daID).show()
}

function BuildCurrentSelector()
{
	var daTarget = $('.current_page_item, .current-cat').find("a").eq(0)
	if(!daTarget.length){
		if(document.location.href == gc_HomeHref+"/")
		{
			daTarget = $('#HomeLink')	
		}
	}
	TheCurrentItemDiv.setY(daTarget.offset().top)
	TheCurrentItemDiv.setHeight(daTarget.height())
	TheCurrentItemDiv.setWidth()
	TheCurrentItemDiv.setLabel(daTarget.text())
	var daText = ' '
	if(daTarget.parent().get(0).childNodes.length > 1)
	{
		daText = daTarget.parent().get(0).childNodes[1].nodeValue
	}
	TheCurrentItemDiv.setCount(daText) 
	TheCurrentItemDiv.setFontWeight('bold')
	TheCurrentItemDiv.setOnclick(daTarget.attr('href'))
	TheCurrentItemDiv.show()
	
}
function OverPages(pEvent)
{
	var daTarget = $(pEvent.target)
	TheMouseOverDiv.setY(daTarget.offset().top)
	TheMouseOverDiv.setHeight(daTarget.height())
	TheMouseOverDiv.setWidth()
	TheMouseOverDiv.setLabel(daTarget.text())
	TheMouseOverDiv.setCount(' ')
	TheMouseOverDiv.setFontWeight('bold')
	TheMouseOverDiv.setOnclick(daTarget.attr('href'))
	TheMouseOverDiv.show()
	
}
function OverCategory(pEvent)
{
	var daTarget = $(pEvent.target)
	TheMouseOverDiv.setY(daTarget.offset().top)
	TheMouseOverDiv.setHeight(daTarget.height())
	TheMouseOverDiv.setWidth()
	TheMouseOverDiv.setLabel(daTarget.html())
	TheMouseOverDiv.setCount(daTarget.parent().get(0).childNodes[1].nodeValue)
	TheMouseOverDiv.setFontWeight(daTarget.css('font-weight'))
	TheMouseOverDiv.setOnclick(daTarget.attr('href'))
	TheMouseOverDiv.show()
}