$(document).ready(function(){

//toggle the blocks
$("#block_tab_img, #block_tab_txt").css("cursor", "pointer");
$("#block_tab_img, #block_tab_txt").click(function(event){
	var $target = $(event.target);
	if($target.is('div'))
	{
		$(this).next().slideToggle();
	}
})

//decorate the search form text field
//$("form input[name=q]").css("height", "13px");

//remove the slideToggle from no slide blocks
$("div#block_tab_txt.noslide").unbind('click');
$("div#block_tab_txt.noslide").css('cursor', 'auto');

//add the opacity to the AFP tabs
	$('div#afp_tabs_block table table')
	   .hover(function(){
			$(this).css('opacity', '1');
		},
		function()
		{
			if(!$(this).hasClass('sel'))
				$(this).css('opacity', '0.5');
		})
	    .not('.sel')
		.css('opacity', '0.5')
		.end()
		.click(function(){
			$(this)
				.parent().parent()
					.find('table[class=sel]')
					.removeClass('sel')
					.trigger('mouseout')
				.end().end()
			.end()
			.addClass('sel')
			.trigger('mouseover')
		})

});

//load AFP function for loading the afp results
function load_afp(myurl, code)
{
	$.ajax({
		type: 'GET',
		beforeSend: function(){$("#ajax_loader").show()},
		data: 'code=' + code,
		dataType: 'html',
		url: myurl,
	    success: function(msg)
	    {
	        $("#ajax_loader").hide();
			$("div#afp_container").html(msg);
	    }
	});
}

function popwin(url, width, height)
{
	var w = width;
	var h = height;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	wint = wint - 40;
	var settings  ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no,';
	settings +='location=no,';
	settings +='menubar=no,';
	settings +='status=no,';
	settings +='toolbar=no,';
	settings +='directories=no,';
	settings +='resizable=no';

	var mywin = window.open(url, 'getscorenet', settings);
}

function pause(millis)
{
        var date = new Date();
        var curDate = null;

        do { curDate = new Date(); }
        while(curDate-date < millis)
}
