$(function(){
	$('#logout a').bind('mouseover',function(){
		$(this).css('background-position', 'bottom');
	}).bind('mouseout',function(){
		$(this).css('background-position', 'top');
	});
})

function jump(to){
	switch(to){
		case 'main':
			location.href = "bone1.asp";
			break;
	}
}

function debug(str){
	if($('#debugDIV').length==0){
		$('body').append('<div id="debugDIV" style="position:absolute; top: 100px; backgronud: #ccc; left: 50px; padding: 5px; color: #333"></div>')
	}
	$('#debugDIV').html(str);
}

function alert_login(id){
	var currentPathName = location.pathname.match(/\/([^\/]+)$/)[0].replace('/','');
	$.ajax({
		url: 'sessionCheck.asp',
		async: true,
		dataType: 'json',
		type: 'GET',
		cache: false,
		timeout: 10000,
		data: "id=" + id + "&url=" + currentPathName,
		error: function(e, e2, e3){
			alert('error'+ id);
		},
		success: function(json){
			if(typeof json.data!="undefined"){
				if(json.data.url.search('javascript')==-1){
					if(json.data.target=="_blank"){
						window.open(RESOURCES_PATH.replace('_resources/', '')+json.data.url);
						return false;
					}else{
						location.href = RESOURCES_PATH.replace('_resources/', '')+json.data.url;
						return false;
					}
				}
			}
			if($('#div_overlay_bg:visible').length==0){
				showAnnouncement('', json.data.urlAdd);
			}
		}
	});
}

function showAnnouncement(str, urlAdd, cssModify){
	var isIe6 = false;
	if(typeof document.body.style.maxHeight === "undefined") {
		isIe6 = true;
	}
	var prefix = ''
	if(isIe6) {
		// IE 6 issues
		var $win = $(document);
		$('#div_overlay_bg').css({
			height: $win.height()*1,
			position: 'absolute'
		});
		$('#announcement_close').css({
		});
	}
	var $win = $(window);
	var $div = $('#announcement-wrapper-wrapper');
	$('#div_overlay_bg').css({
		display: 'block',
		opacity: 0.4
	});
	if(typeof str=='undefined' || str==''){
		str = "請<a href='login.asp"+((typeof urlAdd=='undefined' || urlAdd =='')?'':'?referurl='+urlAdd)+"'>登入</a>以便瀏覽本部分有關「邦維亞」的資料。";
	}else if(str.match(/^id=(.*)$/)){
		str = $('#'+str.replace('id=','')).html();
	}
	$('#announcement div.section h2').html(str);
	$('#announcement-wrapper-wrapper').css({
		left: ($win.width() - $div.width()) / 2 + 'px',
		top: ($win.height() - $div.height()) / 2 + ((typeof cssModify!='undefined')?cssModify.offset().top-250:'') + 'px',
		display: "block"
	});
	return false;
}