
function show(close_id, className1, className2) 
{	var close = document.getElementById(close_id);		
	if (close.className == className1) 
	{		close.className = className2;	}
	else
	{ 		close.className = className1;	}};
	
function wait_for_jquery()
{	
if(typeof jQuery == 'function') 
{		setTimeout(menu_selector, 100);	}
else{		setTimeout(wait_for_jquery, 100);	}}

wait_for_jquery();function menu_selector()
{	$(document).ready(function()
{		var loc = window.location.pathname;		
	var itemSelected = false;		
$(".menu>ul>li>ul>li>a").each(function(){
	if( loc == $(this).attr("href")){
	$(this).parent().parent().parent().removeClass('implicit-block').addClass('drop-block');
	$(this).children("span").addClass("sub-selected");
	itemSelected = true;
	return;	
	}
	});		
	if(itemSelected)return;		/* Crazy amount of code to deal with the fact that there is code in CMS which should be on server		 *  And code which is on server and should be in CMS		 */		
	if($("h2").length == 0 || itemSelected)	
	return;		var parts = $("h2").html().split(/<br[^>]*>/im);		
	var level1 = parts[0].replace(/<span>/i, "").match(/[^<]+/).toString();		
	var level2 = jQuery.trim(parts[1]);		if(level2.match(/Fancy/))			
	level2 = 'Fancy Diamonds';		
	else if(level2.match(/Signature/i))	
	level2 = 'signature';	
	$(".menu>ul>li>a").each(function(){	
	if($(this).children("span").html() == level2 + " Education"){
	$(this).parent().addClass('head-selected');	}			
	if(!level2.match(/(gold|silver|platinum)/i)){
	if($(this).parent().hasClass("drop-down")){	
	$(this).parent().attr('class', '');	
	if( $(this).children("span").html() == level1|| ($(this).children("span").html().match(/ring/i)	&& level1.toString().match(/ring/i))){$(this).parent().addClass('drop-down').addClass('drop-block');}	
	else{	$(this).parent().addClass('drop-down').addClass('implicit-block');	}}
	else{if( $(this).children("span").html() == level1 ){
	$(this).parent().addClass('head-selected');	}}}	});		
	$(".menu>ul>li>ul>li>a>span").each(function(){			var rx = RegExp($(this).html().toLowerCase());			
	if(level2 == "Engagement Rings"){ if($(this).html() == "Ring Guide")	
	$(this).addClass("sub-selected");}else if(level2 == "Wedding Ring Guide"){ if($(this).html() == "Wedding Ring Guide")
	$(this).addClass("sub-selected");}
	else if( ( level2.toString().toLowerCase().match(rx)|| $(this).html().toLowerCase().match(RegExp(level2))))
	{var p = $("#" + this.parentNode.parentNode.parentNode.parentNode.id).children("a").children("span").html();
	if(level1.indexOf(p) >= 0)$(this).addClass("sub-selected");	}});});}
