// ==UserScript==
// Version 20070406
// @name          "music.j-total.net"+"youtube.com"+"guitar chord diagrams viewer"
// @namespace     http://queltide.com/
// @description	  "music.j-total.net"+"youtube.com"+"guitar chord diagrams viewer"
// @include       http://music.j-total.net/data/*
// ==/UserScript==

(function(){
	function show_code(e){
		var code_path = this.innerHTML;
		code_path = code_path.replace("M","mag");
		code_path = code_path.replace("A\u266Dadd9","G$add9_A$$$add9");
		code_path = code_path.replace("B\u266Dadd9","A$add9_B$$$add9");
		code_path = code_path.replace("D\u266Dadd9","C$add9_D$$$add9");
		code_path = code_path.replace("E\u266Dadd9","D$add9_E$$$add9");
		code_path = code_path.replace("G\u266Dadd9","F$add9_G$$$add9");
		code_path = code_path.replace("A\u266Dsus4","G$sus4_A$$$sus4");
		code_path = code_path.replace("B\u266Dsus4","A$sus4_B$$$sus4");
		code_path = code_path.replace("D\u266Dsus4","C$sus4_D$$$sus4");
		code_path = code_path.replace("E\u266Dsus4","D$sus4_E$$$sus4");
		code_path = code_path.replace("G\u266Dsus4","F$sus4_G$$$sus4");
		code_path = code_path.replace("A\u266Ddim","G$dim_A$$$dim");
		code_path = code_path.replace("B\u266Ddim","A$dim_B$$$dim");
		code_path = code_path.replace("D\u266Ddim","C$dim_D$$$dim");
		code_path = code_path.replace("E\u266Ddim","D$dim_E$$$dim");
		code_path = code_path.replace("G\u266Ddim","F$dim_G$$$dim");
		code_path = code_path.replace("A\u266Dm7","G$m7_A$$$m7");
		code_path = code_path.replace("B\u266Dm7","A$m7_B$$$m7");
		code_path = code_path.replace("D\u266Dm7","C$m7_D$$$m7");
		code_path = code_path.replace("E\u266Dm7","D$m7_E$$$m7");
		code_path = code_path.replace("G\u266Dm7","F$m7_G$$$m7");
		code_path = code_path.replace("A\u266Dm6","G$m6_A$$$m6");
		code_path = code_path.replace("B\u266Dm6","A$m6_B$$$m6");
		code_path = code_path.replace("D\u266Dm6","C$m6_D$$$m6");
		code_path = code_path.replace("E\u266Dm6","D$m6_E$$$m6");
		code_path = code_path.replace("G\u266Dm6","F$m6_G$$$m6");
		code_path = code_path.replace("A\u266Dm","G$m_A$$$m");
		code_path = code_path.replace("B\u266Dm","A$m_B$$$m");
		code_path = code_path.replace("D\u266Dm","C$m_D$$$m");
		code_path = code_path.replace("E\u266Dm","D$m_E$$$m");
		code_path = code_path.replace("G\u266Dm","F$m_G$$$m");
		code_path = code_path.replace("A\u266D7","G$7_A$$$7");
		code_path = code_path.replace("B\u266D7","A$7_B$$$7");
		code_path = code_path.replace("D\u266D7","C$7_D$$$7");
		code_path = code_path.replace("E\u266D7","D$7_E$$$7");
		code_path = code_path.replace("G\u266D7","F$7_G$$$7");
		code_path = code_path.replace("A\u266D","G$_A$$$");
		code_path = code_path.replace("B\u266D","A$_B$$$");
		code_path = code_path.replace("D\u266D","C$_D$$$");
		code_path = code_path.replace("E\u266D","D$_E$$$");
		code_path = code_path.replace("G\u266D","F$_G$$$");

		code_path = code_path.replace("C#add9","C$add9_D$$$add9");
		code_path = code_path.replace("F#add9","F$add9_G$$$add9");
		code_path = code_path.replace("G#add9","G$add9_A$$$add9");
		code_path = code_path.replace("C#sus4","C$sus4_D$$$sus4");
		code_path = code_path.replace("F#sus4","F$sus4_G$$$sus4");
		code_path = code_path.replace("G#sus4","G$sus4_A$$$sus4");
		code_path = code_path.replace("C#dim","C$dim_D$$$dim");
		code_path = code_path.replace("F#dim","F$dim_G$$$dim");
		code_path = code_path.replace("G#dim","G$dim_A$$$dim");
		code_path = code_path.replace("C#m7","C$m7_D$$$m7");
		code_path = code_path.replace("F#m7","F$m7_G$$$m7");
		code_path = code_path.replace("G#m7","G$m7_A$$$m7");
		code_path = code_path.replace("C#m6","C$m6_D$$$m6");
		code_path = code_path.replace("F#m6","F$m6_G$$$m6");
		code_path = code_path.replace("G#m6","G$m6_A$$$m6");
		code_path = code_path.replace("C#7","C$7_D$$$7");
		code_path = code_path.replace("F#7","F$7_G$$$7");
		code_path = code_path.replace("G#7","G$7_A$$$7");
		code_path = code_path.replace("C#m","C$m_D$$$m");
		code_path = code_path.replace("F#m","F$m_G$$$m");
		code_path = code_path.replace("G#m","G$m_A$$$m");
		code_path = code_path.replace("C#","C$_D$$$");
		code_path = code_path.replace("F#","F$_G$$$");
		code_path = code_path.replace("G#","G$_A$$$");

		document.body.style.backgroundImage = "url('http://music.j-total.net/cd/img/" + code_path + ".gif')";
		document.body.style.backgroundRepeat = "no-repeat";
		document.body.style.backgroundAttachment = "fixed";
	}

	var nodes = document.getElementsByTagName('A');
	for(var i=0; i<nodes.length; i++){
		if(nodes[i].href.match(/^JavaScript:jump_1/i)){
			nodes[i].addEventListener('mouseover', show_code, false);
		}
	}

	var tag = document.title;
	tag = tag.replace("J-Total Music\uFF0D","");
	tag = tag.replace("\uFF08","@@@");
	tag = tag.replace("\uFF09","");

	var script = document.createElement('script');
	script.charset = 'utf-8';
	script.src = 'http://queltide.com/kigretube/youtube.html?tag='+encodeURIComponent(tag);
	document.body.appendChild(script);

})();