$(document).ready(function(){

	$(".nav-header ul.menu li").dropdown();
	$("a[href$='.pdf']").addClass("pdf");
	$("a[href$='.doc'], a[href$='.docx']").addClass("doc");
	$("a[href$='.xls'], a[href$='.xlsx']").addClass("xls");
	$("a[href$='.ppt']").addClass("ppt");

	//You might also want to set the _target attribute to blank
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
		return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external").attr("target", "_blank");

	var tax_div = $("#tax_exempt_text");
	var tax_check = $("#tax_exempt").change(function(){
		tax_div.toggle($(this).attr('checked'));
	});
	if(!tax_check.attr('checked')) tax_div.toggle();
});

$.fn.dropdown = function() {

	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .menu-item',this).addClass("open");
		$('ul:first',this).css('display', 'block');
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('display', 'none');
	});
};

//table highlight:
window.onload=function()
{
init();
}
function init()
{
if (document.getElementById('highlight')) {
var table=document.getElementById('highlight');
function highlight(row, col, state)
{
for(var i=0; i<table.rows.length; i++)
{
if(state=='off')
{
for(var j=0; j<table.rows[i].cells.length; j++)
{
table.rows[i].cells[j].className='';
}
}
if(state=='on')
{
table.rows[i].cells[col].className='cur_col';
}
}
for(var i=0; i<table.rows[row].cells.length; i++)
{
if(state=='on')
{
table.rows[row].cells[i].className='cur_row';
table.rows[row].cells[col].className='cur_cell';
}
}
}
// end function highlight
// detect cursor position
for(var i=0; i<table.rows.length; i++)
{
table.rows[i].row_index=i;
for(var j=0; j<table.rows[i].cells.length; j++)
{
table.rows[i].cells[j].column_index=j;
table.rows[i].cells[j].onmouseover=function()
{
highlight(this.parentNode.row_index, this.column_index, 'on');
}
table.rows[i].cells[j].onmouseout=function()
{
highlight(this.parentNode.row_index, this.column_index, 'off');
}
}
}
}
}
