/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
/* <![CDATA[ */
$(document).ready(function(){
/* CONFIG */
/* set start (sY) and finish (fY) heights for the list items */

sY = 27; /* height of li.sub */
fY = 340; /* height of maximum sub lines * sub line height */
/* end CONFIG */

/* open first list item */
animate (fY)

$("#slide .sub").click(function() {
	if (this.className.indexOf('clicked') != -1 ) {
		animate(sY)
		$(this)			.removeClass('clicked')
						.css("background", "url(menu-img/bullet6-down.png) no-repeat 3px 12px")
						.css("color", "inherit");
		}
		else {
		animate(sY)
		$('.clicked')	.removeClass('clicked')
						.css("background", "url(menu-img/bullet6-down.png) no-repeat 5px 12px")
						.css("color", "inherit");
		$(this)			.addClass('clicked');
		animate(fY)
	}
});

function animate(pY) {
$('.clicked').animate({"height": pY + "px"}, 500);
}

$("#slide .sub")		.hover(function(){
$(this)					.css("background", "url(menu-img/bullet6-down.png) no-repeat 3px 12px")
						.css("color", "#636363");
},function(){
if (this.className.indexOf('clicked') == -1) {
$(this)					.css("background", "url(menu-img/bullet6.png) no-repeat 5px 10px")
						.css("color", "inherit");
}
});

sY_2 = 27; /* height of li.sub_2 */
fY_2 = 125; /* height of maximum sub_2 lines * sub_2 line height */
/* end CONFIG */

/* open first list item */
animate (fY_2)

$("#slide .sub_2").click(function() {
	if (this.className.indexOf('clicked') != -1 ) {
		animate(sY_2)
		$(this)			.removeClass('clicked')
						.css("background", "url(menu-img/bullet6-down.png) no-repeat 3px 12px")
						.css("color", "inherit");
		}
		else {
		animate(sY_2)
		$('.clicked')	.removeClass('clicked')
						.css("background", "url(menu-img/bullet6-down.png) no-repeat 5px 12px")
						.css("color", "inherit");
		$(this)			.addClass('clicked');
		animate(fY_2)
	}
});

function animate(pY_2) {
$('.clicked').animate({"height": pY_2 + "px"}, 500);
}

$("#slide .sub_2")		.hover(function(){
$(this)					.css("background", "url(menu-img/bullet6-down.png) no-repeat 3px 12px")
						.css("color", "#636363");
},function(){
if (this.className.indexOf('clicked') == -1) {
$(this)					.css("background", "url(menu-img/bullet6.png) no-repeat 5px 10px")
						.css("color", "inherit");
}
});

});
/* ]]> */
// JavaScript Document ----- NOTIFICATION BOXES

$(document).ready(function() {
	
			$('.notification').hover(function() {
 				$(this).css('cursor','pointer');
 			}, function() {
 					$(this).css('cursor','auto');
				});

            $('.notification span').click(function() {
                $(this).parent().fadeOut(800);
            });
			
			$('.notification').click(function() {
                $(this).fadeOut(800);
            });
			
        });
		
// Home Nav Sprite
// JavaScript Document
$(document).ready(function(){
	
		// remove link background images since we're re-doing the hover interaction below 
		// (doing it this way retains the CSS default hover states for non-javascript-enabled browsers)
		// we also want to only remove the image on non-selected nav items, so this is a bit more complicated
		$(".nav").children("li").each(function() {
			var current = "nav current-" + ($(this).attr("class"));
			var parentClass = $(".nav").attr("class");
			if (parentClass != current) {
				$(this).children("a").css({backgroundImage:"none"});
			}
		});	


		// create events for each nav item
		attachNavEvents(".nav", "home");
		attachNavEvents(".nav", "leads");
		attachNavEvents(".nav", "count");
		attachNavEvents(".nav", "order");
	

		function attachNavEvents(parent, myClass) {
			$(parent + " ." + myClass).mouseover(function() {
				$(this).append('<div class="nav-' + myClass + '"></div>');
				$("div.nav-" + myClass).css({display:"none"}).fadeIn(500);
			}).mouseout(function() {
				$("div.nav-" + myClass).fadeOut(500, function() {
					$(this).remove();
				});
			}).mousedown(function() {
				$("div.nav-" + myClass).attr("class", "nav-" + myClass + "-click");
			}).mouseup(function() {
				$("div.nav-" + myClass + "-click").attr("class", "nav-" + myClass);
			});
		}



	});

// Table hover JavaScript
	
/* 
	Javascript to style odd/even table rows
	Derived from 'Zebra Tables' by David F. Miller (http://www.alistapart.com/articles/zebratables/)
	
	Modified by Jop de Klein, february 2005
	jop at validweb.nl
	http://validweb.nl/artikelen/javascript/better-zebra-tables/
*/

	var stripe = function() {
		var tables = document.getElementsByTagName("table");	

		for(var x=0;x!=tables.length;x++){
			var table = tables[x];
			if (! table) { return; }
			
			var tbodies = table.getElementsByTagName("tbody");
			
			for (var h = 0; h < tbodies.length; h++) {
				var even = true;
				var trs = tbodies[h].getElementsByTagName("tr");
				
				for (var i = 0; i < trs.length; i++) {
					trs[i].onmouseover=function(){
						this.className += " ruled"; return false
					}
					trs[i].onmouseout=function(){
						this.className = this.className.replace("ruled", ""); return false
					}
					
					if(even)
						trs[i].className += " even";
					
					even = !even;
				}
			}
		}
	}

	window.onload = stripe;
	
