/* jQuery+link.active */
$(document).ready(function() {
	if (location.pathname.split("/")[1])
	$('#nav-primary a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});
$(document).ready(function() {
	$('#nav-secondary a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});



/* ktai-sim */
function myKSKeyPress(key) {
	var elem = document.getElementById('ktai-sim-swf');
	elem.TCallLabel('/base', 'K_' + key);
	return false;
}

function myKtaiSimReload() {
	var elem = document.getElementById('ktai-sim-swf');
	var newFile = elem.getAttribute('data');
	
	elem.parentNode.innerHTML = 
	  '<object id="ktai-sim-swf" name="ktai-sim-swf" data="' + newFile + '" width="240" height="266" type="application/x-shockwave-flash">'
	+ '<param name="movie" value="'+ newFile + '" />'
	+ '<param name="wmode" value="transparent" />'
	+ '</object>';
	return false;
}

function myKtaiSimLink() {
	var elem = document.getElementById('ktai-sim-swf');
	var oldFile = elem.getAttribute('data');
	var tmpls = [1,3,4,5,6,7,9];
	var colors = [1,2,3];
	var tmpl = tmpls[Math.floor(Math.random()*tmpls.length)];
	var color = colors[Math.floor(Math.random()*colors.length)];
	var newFile = '/flash/' + tmpl + '_c' + color + '.swf';
	
	elem.parentNode.innerHTML = 
	  '<object id="ktai-sim-swf" name="ktai-sim-swf" data="' + newFile + '" width="240" height="266" type="application/x-shockwave-flash">'
	+ '<param name="movie" value="'+ newFile + '" />'
	+ '<param name="wmode" value="transparent" />'
	+ '</object>';
	return;
}

function myPopQr() {
	var elem = document.getElementById('ktai-sim-swf');
	var path = elem.getAttribute('data');
	path = path.replace('.swf', '.qr.jpg');
	
	
	window.open(path, 'QRcode', 'width=120,height=120');
	
	/*location.href = path;*/
	return false;
}


