// JavaScript Document

// scroll to same-page anchors
$(document).ready(function(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000, 'easeInOutCirc');
			  return false;
			}
		}
	});
});


// init navigation dropdown menus
function initMenus(){
	// top menu
	$('#nav-top li').hover( 
	function(){
		$(this).addClass('over');
	},
	function(){
		$(this).removeClass('over');
	}
	);
}



// Confirm Delete
function confirmDelete() {
	var agree = confirm("Are you sure you wish to delete this record?");
	if (agree)
		return true;
	else
		return false;
}


// Stripe tables
function stripe_table() {
	$('table.striped').find('tbody tr:even').addClass("striped_even");
	$('table.striped').find('tbody tr:odd').addClass("striped_odd");
	$('table.striped').find('tbody tr').hover(function(){
		$(this).addClass("striped_hover");
		},function(){
		$(this).removeClass("striped_hover");
	});
}


// insert link icons
function insert_link_icons() {
	var domain = document.domain;
	
	// Prepend Doc-Type icons before links
	$('a[@href$=pdf]').addClass('icon_pdf');
	$('a[@href$=doc]').addClass('icon_word');
	$('a[@href$=xls]').addClass('icon_excel');
	$('a[@href$=csv]').addClass('icon_excel');
	$('a[@href$=txt]').addClass('icon_text');
	$('a[@href$=rtf]').addClass('icon_text');
	$('a[@href$=ppt]').addClass('icon_ppt');
	$('a[@href$=mp3]').addClass('icon_ipod_sound');
	
	$('#content-1 a[@target=_blank]').addClass('offsite');
	$('#content-1 a[@href^=#]').addClass('down');
	$('#content-1 a.noscroll').removeClass('down');
}


$(document).ready(function(){
   stripe_table();
   insert_link_icons();
	 initMenus();
});