/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */


$(document).ready(function() {

$("ul#nav ul").hide();
$('ul#nav li:has(ul)').each(function(i) {
$(this).children().slideUp(400);
});

$("ul#nav2 ul").hide();
$('ul#nav2 li:has(ul)').each(function(i) {
$(this).children().slideUp(400);
});

$('li:has(ul)')	.hover(function(){
$(this)					.css("background", "#969696");$(this).css("color", "#DA2D27");
},function(){
if (this.className.indexOf('clicked') == -1) {
$(this).css("background", "#b1b1b1");$(this).css("color", "#ffffff");
}
if (this == current || this == currentNiv1 || this == currentNiv2) {
$(this).css("background", "#969696");$(this).css("color", "#DA2D27");
}
});

$('li.p1:has(ul)').click(function(event){
		if (this == event.target) {
		current = this; currentNiv1 = this;
		$('ul#nav li:has(ul)').each(function(i) {
		if (this != current) {$(this).children().slideUp(400);$(this).css("background", "#b1b1b1");$(this).css("color", "#ffffff");}
		});
		$('ul#nav2 li:has(ul)').each(function(i) {
		if (this != current) {$(this).children().slideUp(400);$(this).css("background", "#b1b1b1");$(this).css("color", "#ffffff");}
		});
		$(this).children("ul:eq(0)").slideToggle(400);
		$(this).css("background", "#969696");$(this).css("color", "#DA2D27");
		}
	});
	


/*$('li.p2:has(ul)')	.hover(function(){
$(this)					.css("background", "#969696");
},function(){
if (this.className.indexOf('clicked') == -1) {
$(this).css("background", "#b1b1b1");
}
if (this == current) {
$(this).css("background", "#969696");
}
});*/
$('li.p2:has(ul)').click(function(event){
		if (this == event.target) {
		current = this; currentNiv2 = this;
		$('li.p2:has(ul)').each(function(i) {
		if (this != current) {$(this).children().slideUp(400);$(this).css("background", "#b1b1b1");$(this).css("color", "#ffffff");}
		});
		$('li.p3:has(ul)').each(function(i) {
		if (this != current) {$(this).children().slideUp(400);$(this).css("background", "#b1b1b1");$(this).css("color", "#ffffff");}
		});
		$(this).children("ul:eq(0)").slideToggle(400); 
		$(this).css("background", "#969696");$(this).css("color", "#DA2D27");


		}
	});

/*$('li.p3:has(ul)')	.hover(function(){
$(this)					.css("background", "#969696");
},function(){
if (this.className.indexOf('clicked') == -1) {
$(this).css("background", "#b1b1b1");
}
if (this == current) {
$(this).css("background", "#969696");
}
});*/

$('li.p3:has(ul)').click(function(event){
		if (this == event.target) {
		current = this;
		$('li.p3:has(ul)').each(function(i) {
		if (this != current) {$(this).children().slideUp(400);$(this).css("background", "#b1b1b1");$(this).css("color", "#ffffff");}
		});
		$(this).children("ul:eq(0)").slideToggle(400); 
		$(this).css("background", "#969696");$(this).css("color", "#DA2D27");

		}
	});

});

