//plugin - swiped from http://davidwalsh.name/jquery-top-link
jQuery.fn.topLink = function(settings) {
	settings = jQuery.extend({
		min: 1,
		fadeSpeed: 200
	}, settings);
	return this.each(function() {
		//listen for scroll
		var el = $(this);
		el.hide(); //in case the user forgot
		$(window).scroll(function() {
			if($(window).scrollTop() >= settings.min)
			{
				el.fadeIn(settings.fadeSpeed);
			}
			else
			{
				el.fadeOut(settings.fadeSpeed);
			}
		});
	});
};

//plugin - swiped from http://davidwalsh.name/jquery-top-link
jQuery.fn.topLink = function(settings) {
		settings = jQuery.extend({
			min: 1,
			fadeSpeed: 200,
			ieOffset: 50
		}, settings);
		return this.each(function() {
			//listen for scroll
			var el = $(this);
			el.css('display','none'); //in case the user forgot
			$(window).scroll(function() {
				//stupid IE hack
				if(!jQuery.support.hrefNormalized) {
					el.css({
						'position': 'absolute',
						'top': $(window).scrollTop() + $(window).height() - settings.ieOffset
					});
				}
				if($(window).scrollTop() >= settings.min)
				{
					el.fadeIn(settings.fadeSpeed);
				}
				else
				{
					el.fadeOut(settings.fadeSpeed);
				}
			});
		});
	};

// Anchor Slider by Cedric Dugas === Http://www.position-absolute.com
$(document).ready(function() {
	anchor1.init()
});
anchor1 = {
	init : function()  {
		$("a.slider").click(function () {	
			elementClick = $(this).attr("href")
			destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 800 );
		  	return false;
		})
	}
}

$(document).ready(function() {
	anchor2.init()
});
anchor2 = {
	init : function()  {
		$("#top-link").click(function () {	
			elementClick = $(this).attr("href")
			destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 800 );
		  	return false;
		})
	}
}


/*	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
	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 = false;
			var trs = tbodies[h].getElementsByTagName("tr");
			
			for (var i = 0; i < trs.length; i++) {
				
				if(even)
					trs[i].className += " alt";
				
				even = !even;
			}
		}
	}
}

window.onload = stripe;



$(document).ready(function() {
	//set the link
	$('#top-link').topLink({
		min: 400,
		fadeSpeed: 500
	});
	$("#hd ul").jMenu({
		ulWidth : '220',
		effects : {
		  effectSpeedOpen : 300,
		  effectSpeedClose : 200,
		  effectTypeOpen : 'fade',
		  effectTypeClose : 'fade',
		  effectOpen : 'linear',
		  effectClose : 'linear'
		  },
		TimeBeforeOpening : 100,
		TimeBeforeClosing : 700,
		animatedText : true,
		paddingLeft: 5
    });
});
