this.sortTable = function(table, col, dir) {
	if($(table).length > 0 && $(table +' tbody td').size() > 1) {
		$(table).tablesorter({sortList: [[col, dir]] }); 
		$(table).bind("sortEnd",function() { 
			var i = 0;
			var rowClass;
			$(table + " tr").each(function() {
				$(this).removeClass("hchTr1 hchTr2");
				rowClass = (i%2 == 1) ? "hchTr1" : "hchTr2";
				$(this).addClass(rowClass);
				i++;
			});
		 })
	}
	
}

function placeH1Swf(txt,col) {
	var intRandNo =Math.floor(Math.random()*7979);
	var strDiv = "h1_" + intRandNo;
	document.write('<div class="h1"><h1 id="'+strDiv+'">'+txt+'</h1></div>');
	var flashvars = {};
	flashvars.txt = txt;
	flashvars.txt_color = col;
	var params = {};
	params.wmode = 'transparent';
	var attributes = {};
	swfobject.embedSWF('/000__nexus3/flash/h1.swf', strDiv, '400', '20', '8.0.0', false, flashvars, params, attributes);
}

this.placeTip = function(id,txt,title) {
	if (document.getElementById(id) != null) {
		$('#'+id).qtip({
			content: {
      	title: {
        	text: title
        },
      	text: txt
    	},
			style: {
         width: { max: 220 },
         padding: 6,
         border: {
            width: 2,
            radius: 2,
            color: '#cccccc'
         },
         name: 'light',
				 title: {'padding':'4px','padding-bottom':'6px'}
      },
			position: {
				adjust: {
					screen: true
				}
			}
		});
	}
}

function openMap(URLtoOpen) {
	window.open(URLtoOpen,'hchMap','width=762,height=425,toolbar=no,scrollbars=no,resizable=no,status=no');
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
     anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}


function doubleConfirm(msg) {
	if (confirm(msg)) {
			return confirm('Are you sure?');
	}
	return false;
}


this.showModal = function(id) {
    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set height and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});
    $('#mask').fadeIn("fast");

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $(id).css('top',  winH/2-$(id).height()/2);
    $(id).css('left', winW/2-$(id).width()/2);

    //transition effect
    $(id).fadeIn(400);

    $('#mask').click(function () {
        $(this).hide();
        $('.window').hide();
    });

    //if close button is clicked
    $('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();
        $('#mask, .window').hide();
    });
}






