/**
 * @version $Id$
 * @author Giao
 */

// Centered Pop-Up Window
var newWin;

function centeredWindow(url,winname,s,w,h) {
	windowleft = (screen.width - w)/2;
	windowtop = (screen.height - h)/2;
	settings = '"toolbar=no,directories=no,menubar=no,scrollbars='+s+',resizable=no,status=no,width='+w+',height='+h+',left='+windowleft+',top='+windowtop+'"';
	closeWindow();
	newWin = window.open(url,winname,settings);
	newWin.focus();
}
function centeredWindowResize(url,winname,s,w,h) {
	windowleft = (screen.width - w)/2;
	windowtop = (screen.height - h)/2;
	settings = '"toolbar=no,directories=no,menubar=no,scrollbars='+s+',resizable=yes,status=no,width='+w+',height='+h+',left='+windowleft+',top='+windowtop+'"';
	closeWindow();
	newWin = window.open(url,winname,settings);
	newWin.focus();
}

function closeWindow() {
	if (newWin && !newWin.closed) {
			newWin.close();
	}
}

jQuery(function($) {

	$("#mainmenu ul.menu > li").hover(
		function(){
			if($(this).hasClass("parent")){
				$(this).find("a:eq(0)").css("padding-bottom","15px");
				$(this).find("ul:eq(0)").css("top","48px");
			}
			$(this).addClass("sfhover");
			
		},
		function(){
			if($(this).hasClass("parent")){
				$(this).find("a:eq(0)").css("padding-bottom","10px");
			}
			$(this).removeClass("sfhover");
		}
	);
	
	// apply rounded corner html 
	$('.rounded-corner-js').wrap('<div class="dialog"><div class="content clearfix"></div></div>');
	$('.rounded-corner-js').before('<div class="t"></div>');
	$('.rounded-corner-js').parent().after('<div class="b"><div></div></div>');
	
	$('.slide-body').hide();
	$('.slide-handler').click(function() {
		$(this).next('.slide-body').slideToggle("fast");
	});
	$('.slide-handler1').click(function() {
		$(this).parent().next('.slide-body').slideToggle("fast");
	});
	
	// attach event to show dialog
	$('#sitedialog').jqm({
		ajax: '@href',
		trigger: '.dialog-trigger',
		target: 'div.jqmContent'
	});
	
	
	if (qs_gpa.isHome) {
		var mh = Math.max($('ul.latestnews_com').height(), $('ul.latestnews_fqa').height(), $('ul.latestnews_tip').height());
		$('ul.latestnews_com, ul.latestnews_fqa, ul.latestnews_tip').css('height', mh+'px');
	}
});
