// JavaScript Document
// GLOBAL functions

function FlashMessage() {
	$("div#flashMessage")
	.animate( {opacity: 1.0}, 3000 )
	.fadeOut(2000, function(){
		$(this).remove();
	});
}



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




function stripe_list() {
	$('ol.striped').find('li:even').addClass("striped_even");
	$('ol.striped').find('li:odd').addClass("striped_odd");
	$('ul.striped').find('li:even').addClass("striped_even");
	$('ul.striped').find('li:odd').addClass("striped_odd");
	
	// hover state
	$('ol.striped li').hover(function(){
		$(this).addClass("striped_hover");
	},function(){
		$(this).removeClass("striped_hover");								  
	});
	$('ul.striped li').hover(function(){
		$(this).addClass("striped_hover");
	},function(){
		$(this).removeClass("striped_hover");								  
	});
}


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




function insert_link_icons() {
	var domain = document.domain;
	
	// Prepend Doc-Type icons before links
	$('a[@href$=pdf]').prepend('<img src="http://'+domain+'/icon/page_white_acrobat.png" border="0" alt="PDF" />&nbsp;');
	$('a[@href$=doc]').prepend('<img src="http://'+domain+'/icon/page_white_word.png" border="0" alt="MS Word" />&nbsp;');
	$('a[@href$=xls]').prepend('<img src="http://'+domain+'/icon/page_white_excel.png" border="0" alt="MS Excel" />&nbsp;');
	$('a[@href$=csv]').prepend('<img src="http://'+domain+'/icon/page_white_excel.png" border="0" alt="CSV" />&nbsp;');
	$('a[@href$=txt]').prepend('<img src="http://'+domain+'/icon/page_white_text.png" border="0" alt="Plain Text" />&nbsp;');
	$('a[@href$=rtf]').prepend('<img src="http://'+domain+'/icon/page_white_text.png" border="0" alt="Rich Text" />&nbsp;');
	$('a[@href$=jpg]').prepend('<img src="http://'+domain+'/icon/page_white_picture.png" border="0" alt="JPG" />&nbsp;');
	$('a[@href$=jpeg]').prepend('<img src="http://'+domain+'/icon/page_white_picture.png" border="0" alt="JPEG" />&nbsp;');
	$('a[@href$=ppt]').prepend('<img src="http://'+domain+'/icon/page_white_powerpoint.png" border="0" alt="MS Powerpoint" />&nbsp;');
	
	// Append off-site icon to off-site links
	$('a[@href^=http://]').not('a[@href*='+domain+']').append('&nbsp;<img src="http://'+domain+'/icon/application_double.png" border="0" alt="new window" />');
}







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

