// JavaScript Document
$(document).ready(function(){
		
		$("#loading").hide();
		$('a.poplight[href^=#]').click(function() {
    	var popID = $(this).attr('rel'); 
   	 	var popURL = $(this).attr('href'); 

    	var query= popURL.split('?');
    	var dim= query[1].split('&');
    	var popWidth = dim[0].split('=')[1]; 
		
    	$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="website/template/images/cancel.png" class="btn_close" title="Close Window" alt="Close" /></a>');

    	
   		var popMargTop = ($('#' + popID).height() + 80) / 2;
    	var popMargLeft = ($('#' + popID).width() + 80) / 2;

   	 	$('#' + popID).css({
        	'margin-top' : -popMargTop,
       	 'margin-left' : -popMargLeft
    	});

    	$('body').append('<div id="fade"></div>'); 
    	$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); 

   		 return false;
	    });
		
		$('a.close, #fade').live('click', function() { 
   		$('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  
    	});
    	return false;
		});

});
function show(selection)
{
	$.ajax({
			type:"POST",
			url:"website/function/tab.php",  
			data:({type:'tab_center_main', selection:selection}),
			success:function(data){
				if((data.result)=='true')
					$('#tab_center_main').html(data.output);
				}, 
			dataType:"json"});
			return false;
}

function show_class_program(center)
{
	var term=document.getElementById('term').value;
	var level=document.getElementById('level').value;
	var category=1;
	var year=document.getElementById('year').value;
	$.ajax({
			type:"POST",
			url:"website/function/class.php",  
			data:({center:center, term:term,level:level,year:year}),
			success:function(data){
				if((data.result)=='true')
					$('#result_program').html(data.output);
				}, 
			dataType:"json"});
			return false;
}
