
$(document).ready(function(){
	/*$(function() { 
		$("a.fadeimg img").css("opacity","1")
		.hover(
			function () {
				$(this).stop().animate({opacity: 0}, 'normal');},
			function () {
				$(this).stop().animate({opacity: 1}, 'normal');}
		);
	});*/
	simple_tooltip("a","tooltip");
	$(function() {
		$("#spbtn1 img").click(function() {fancyboxVideo();});
		$("#spbtn2 img").click(function() {fancyboxMessage();})
	});
});

function fancyboxOST(num) {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'showCloseButton': false,
			'hideOnOverlayClick': false,
			'width'		: 610,
			'height'		: 267,
			'href'			: 'swf/disc' + num + '.swf',
			'type'			: 'swf',
			'swf'			: {
				'wmode'		: 'transparent',
				'allowfullscreen'	: 'true',
				'allowscriptaccess': 'always'
			}
		});

		return false;
}
		
function fancyboxPB(tracknum) {
		if (!!document.getElementById('bgmfla'))	{swfName("bgmfla").flabgmoff();};
		if (tracknum == "26") {
			$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'fade',
				'transitionOut'	: 'fade',
				'showCloseButton': false,
				'hideOnOverlayClick': false,
				'width'			: 320,
				'height'		: 484,
				'href'			: 'swf/player_sp1.swf',
				'type'			: 'swf',
				'swf'			: {
					'wmode'				: 'transparent',
					'menu'				: 'false',
					'allowfullscreen'	: 'true',
					'allowscriptaccess'	: 'always',
					'FlashVars'			: 'track=' + tracknum
				}
			});
		} else if (tracknum == "27") {
			$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'fade',
				'transitionOut'	: 'fade',
				'showCloseButton': false,
				'hideOnOverlayClick': false,
				'width'			: 320,
				'height'		: 484,
				'href'			: 'swf/player_sp2.swf',
				'type'			: 'swf',
				'swf'			: {
					'wmode'				: 'transparent',
					'menu'				: 'false',
					'allowfullscreen'	: 'true',
					'allowscriptaccess'	: 'always',
					'FlashVars'			: 'track=' + tracknum
				}
			});		
		} else {
			$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'fade',
				'transitionOut'	: 'fade',
				'showCloseButton': false,
				'hideOnOverlayClick': false,
				'width'			: 661,
				'height'		: 216,
				'href'			: 'swf/player.swf',
				'type'			: 'swf',
				'swf'			: {
					'wmode'				: 'transparent',
					'menu'				: 'false',
					'allowfullscreen'	: 'true',
					'allowscriptaccess'	: 'always',
					'FlashVars'			: 'track=' + tracknum
				}
			});
		}

		return false;
}


function fancyboxVideo() {
		if (!!document.getElementById('bgmfla'))	{swfName("bgmfla").flabgmoff();};
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'showCloseButton': false,
			'hideOnOverlayClick': false,
			'width'			: 675,
			'height'		: 438,
			'href'			: 'swf/vplayer.swf',
			'type'			: 'swf',
			'swf'			: {
				'wmode'				: 'transparent',
				'menu'				: 'false',
				'allowfullscreen'	: 'true',
				'allowscriptaccess'	: 'always'
			}
		});
}


function fancyboxMessage() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'showCloseButton': false,
			'hideOnOverlayClick': false,
			'width'			: 650,
			'height'		: 450,
			'href'			: 'swf/message.swf',
			'type'			: 'swf',
			'swf'			: {
				'wmode'				: 'transparent',
				'menu'				: 'false',
				'allowfullscreen'	: 'true',
				'allowscriptaccess'	: 'always'
			}
		});
}


function fancyboxChaku() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'showCloseButton': false,
			'hideOnOverlayClick': false,
			'width'			: 500,
			'height'		: 300,
			'href'			: 'swf/chaku.swf',
			'type'			: 'swf',
			'swf'			: {
				'wmode'				: 'transparent',
				'menu'				: 'false',
				'allowfullscreen'	: 'true',
				'allowscriptaccess'	: 'always'
			}
		});
}
	
		
function swfName(str) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[str];
	}else {
		return document[str];
	}
}

function fancyboxDelegateClose() {
	parent.$.fancybox.close();
	return false;
}

function fancyboxDelegateCloseOn(track) {
	parent.$.fancybox.close();
	swfName("bgmfla").flabgmon(track);
	return false;
}

function jsbgstart() {
	//alert(window[bgmfla].length);
	if(navigator.userAgent.indexOf("MSIE") != -1) {
		if ($("#bgmfla").length) {
			swfName("bgmfla").flabgmstart();
		}
	}
	//return false;
}

function browsercheck() {
	if(navigator.userAgent.indexOf("MSIE") != -1){
		if (typeof document.documentElement.style.maxHeight != "undefined") {
			return "IE";
		} else {
			return "IE6";
		}
	} else {
		return "Other";
	}
}

function simple_tooltip(target_items, name){
 $(target_items).each(function(i){
		$("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+$(this).attr('title')+"</p></div>");
		var my_tooltip = $("#"+name+i);
		
		if($(this).attr("title") != "" && $(this).attr("title") != "undefined" ){
		
		$(this).removeAttr("title").mouseover(function(){
					my_tooltip.css({opacity:0.9, display:"none"}).fadeIn(400);
		}).mousemove(function(kmouse){
				var border_top = $(window).scrollTop(); 
				var border_right = $(window).width();
				var left_pos;
				var top_pos;
				var offset = 20;
				if(border_right - (offset *2) >= my_tooltip.width() + kmouse.pageX){
					left_pos = kmouse.pageX+offset;
					} else{
					left_pos = border_right-my_tooltip.width()-offset;
					}
					
				if(border_top + (offset *2)>= kmouse.pageY - my_tooltip.height()){
					top_pos = border_top +offset;
					} else{
					top_pos = kmouse.pageY-my_tooltip.height()-offset;
					}	
				
				
				my_tooltip.css({left:left_pos, top:top_pos});
		}).mouseout(function(){
				my_tooltip.css({left:"-9999px"});				  
		});
		
		}

	});
}

