// JavaScript Document
/**
* jquery window.onload but no onload fantastic plastic super duper woopidoo function
*/
$(document).ready(function(){
	// highlight the current section
	highlightSection();
	// add an onclick to the body to hide any open menu
	$("body").click(function(){
		hideAnyOldChild();
	});
});
/**
* menu/navigation stuff
*/
var thisFamily = null;
var oldChild = null;
var delay = 5000;
var timer = null;
families = Array('jewelry_and_collections','fashion_and_trends','you_and_your_gold_jewelry')
function highlightSection(){
	path = document.location.pathname;
	chunks = path.split('/');
	family = chunks[1];
	for(c=0;c<families.length;c++){
		if(families[c] == family){
			thisFamily = c+1;	
		}
	}
	linkHref =  $('#link'+thisFamily);
	linkHref.addClass('ddHrefTopHighlight');
}
function showChild(idnum){
	container = $('#parent'+idnum);
	linkHref =  $('#link'+idnum);
	linkHref.addClass('ddHrefTopOver');
	menuChild = $('#child'+idnum);
	menuChild.width(container.width());
	menuChild.show();
	if(timer != null){
		clearTimeout(timer);
	}
	if(oldChild != idnum && oldChild != null){
		// turn off old child here
		hideChild(oldChild);
	}
	oldChild = idnum;
	timer=setTimeout("hideAnyOldChild()",delay);	
}
function hideChild(idnum){
	menuChild = $('#child'+idnum);
	linkHref =  $('#link'+idnum);
	linkHref.removeClass('ddHrefTopOver');
	menuChild.hide();
}
function hideAnyOldChild(){
	if(oldChild != null){	
		menuChild = $('#child'+oldChild);
		linkHref =  $('#link'+oldChild);
		linkHref.removeClass('ddHrefTopOver');
		menuChild.hide();
		oldChild = null;
	}
	if(timer != null){
		clearTimeout(timer);
	}
}

