$(document).ready(function() {
	refreshheader();
	$("#header img").hover(function(){
	$(this).stop().fadeTo(200, 0.8);},function(){$(this).stop().fadeTo(300, 1.0); });
	
	function megaHoverOver() { $(this).find(".sub").stop().fadeTo('fast', 1).show(); }
	function megaHoverOut() {
	 $(this).find(".sub").stop().fadeTo('fast', 0, function() {
	     $(this).hide();
	 });
	}
	var config = {
	 sensitivity: 2,   
	 interval: 50,    
	 over: megaHoverOver,   
	 timeout: 0,  
	 out: megaHoverOut    
	};
	
	$("ul#nav li .sub").css({ 'opacity': '0' });
	$("ul#nav li").hoverIntent(config);
});

function closebox(){
	$.fancybox.close();
}

function refreshheader(){
	$.ajax({
		type: "get",
		url: "/User/getheader.html",
		success: function(data, textStatus){
			$("#headLinks").html(data);
			$("a#btnlogin").fancybox({
				titleShow:false,
				autoDimensions:false,
				width:500,
				height:320,
				scrolling:'no',
				overlayOpacity:0.5,
				overlayColor:'#000',
				type:'iframe',
				padding:15,
				onClosed:function(){
					refreshheader();
				}
			});
		},
		error: function(){
		
		}
	});
}



