$(document).ready(function(){
	
	//listticker
	var first1 = 0;
	var speed1 = 300;
	var pause1 = 3500;
	
	function removeFirst1(){
		first1 = $('ul#listticker li:first').html();
		$('ul#listticker li:first')
		.animate({opacity: 0}, speed1)
		.fadeOut('slow', function() {$(this).remove();});
		addLast1(first1);
	}
	
	function addLast1(first1){
		last1 = '<li style="display:none">'+first1+'</li>';
		$('ul#listticker').append(last1)
		$('ul#listticker li:last')
		.animate({opacity: 1}, speed1)
		.fadeIn('slow')
	}
	
	interval1 = setInterval(removeFirst1, pause1);

	//listticker2
	var first2 = 0;
	var speed2 = 100;
	var pause2 = 2000;
	
	function removeFirst2(){
		first2 = $('ul#listticker2 li:first').html();
		$('ul#listticker2 li:first')
		.animate({opacity: 0}, speed2)
		.fadeOut('slow', function() {$(this).remove();});
		addLast2(first2);
	}
	
	function addLast2(first2){
		last2 = '<li style="display:none">'+first2+'</li>';
		$('ul#listticker2').append(last2)
		$('ul#listticker2 li:last')
		.animate({opacity: 1}, speed2)
		.fadeIn('slow')
	}
	
	interval2 = setInterval(removeFirst2, pause2);

});

//table column toggler
function toggle(columnClass){
	if(document.forms['hider'].elements[columnClass].checked){
		  $('table .'+columnClass).each(function(index) {
			    $(this).show();
			  });
	}
	else{
		  $('table .'+columnClass).each(function(index) {
			    $(this).hide();
			  });	
	}
}
function toggle_init(){	
	document.hider.width="100%";
	var f_length=document.hider.elements.length;
	
	for (i=0;i<f_length;i++){
		toggle(document.hider.elements[i].name);
	}
}


//popup javascript
$(document).ready(function(){
	$('a.help').css('cursor', 'pointer'); // force the cursor for all the help links to be a pointer
	$('a.help').mouseover(function(){
		var content = $( '#'+$(this).removeClass('help').attr('class').replace('help_', '') );
		var width = $(window).width()*.62;
		var height = $(window).height()*.62;
		$(this).qtip({
			content: {
				title: {
					text: 'Help',
					button: 'Close'
				},
				text: content
			},
			position: {
		    	target: $(document.body), // Position it via the document body...
		    	corner: 'center' // ...at the center of the viewport
			},
			show: {
	    		when: 'click', // Show it on click
			    solo: true // And hide all other tooltips
			},
			hide: {
				when: 'unfocus'
			},
			style: {
				width: { max: width },
				padding: '14px',
				border: {
					width: 9,
					radius: 9,
					color: '#666666'
				},
				name: 'light',
				'max-height': height,
				overflow: 'auto'
			},
			api: {
				beforeShow: function()
				{
					// $('.qtip:not(:last)').remove() // doesn't work in IE
					// Fade in the modal "blanket" using the defined show speed
					$('#qtip-blanket').fadeIn(this.options.show.effect.length);
				},
				beforeHide: function()
				{
					// Fade out the modal "blanket" using the defined hide speed
					$('#qtip-blanket').fadeOut(this.options.hide.effect.length);
					$('[qtip]').remove();
				}
			}
		});
	});
	
	$('<div id="qtip-blanket">').css({
	      position: 'absolute',
	      top: $(document).scrollTop(),
	      left: 0,
	      height: $(document).height(),
	      width: '100%',
	      opacity: 0.7,
	      backgroundColor: 'black',
	      zIndex: 5000}).appendTo(document.body).hide();
});
