﻿var obj, a, ua=true, x, y, mwidth;
var UserAgent = navigator.userAgent.toLowerCase();

if(UserAgent.indexOf('msie')!=-1){
    ua = true;
}else{
    ua = false;
}


function moveIt(c){
	
	obj = true;
	a=c;
	
	if(!ua){
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = move;
	}else{
		window.onmousemove = move();
	}
}

function move(e){
	
	if(obj){
		
		if(ua){
			x = window.event.clientX;
			y = window.event.clientY;
		}else{
			x = e.pageX;
			y = e.pageY;
		}
		
		document.getElementById(a).style.top = y+20;
		if((mwidth/2)<x){
			document.getElementById(a).style.left = x-130;
		}else{
			document.getElementById(a).style.left = x-10;
		}
		document.getElementById(a).style.display = 'block';
	}
}

function stopIt(c){
	obj = false;
	if(!ua)
		window.releaseEvents(Event.MOUSEMOVE);
	document.getElementById(c).style.display='none';
}

function set_pad(){
	i=0;
	a = document.getElementById('td_top').offsetWidth;
	
	mwidth = document.getElementById('main_w').offsetWidth;
	
	while(document.getElementById('td_com_'+i)){
		document.getElementById('td_com_'+i).style.width = a - 10;
		i++;
	}
}

var div_fr="";
function get_dig(digit, color, fraze){
	var a = digit.split('|');
	document.write('<div onmouseover="moveIt(\'alt_'+digit+'\')" onmouseout="stopIt(\'alt_'+digit+'\')">');
	for(i=0; i<(a.length); i++){
		document.write('<img src="/images/'+a[i]+'_'+color+'.png" alt="" width="9" height="16" class="png" />');
	}
	document.write('</div>');
	
	if((mwidth/2)<x){
		div_fr+='<div style="position: absolute; display: none;" id="alt_'+digit+'"><table width="148"><tr><td class="bg_top"></td></tr><tr><td class="bg_cen" align="center">'+fraze+'</td></tr><tr><td class="bg_bot"></td></tr></table></div>';
	}else{
		div_fr+='<div style="position: absolute; display: none;" id="alt_'+digit+'"><table width="148"><tr><td class="bg_top_l"></td></tr><tr><td class="bg_cen" align="center">'+fraze+'</td></tr><tr><td class="bg_bot"></td></tr></table></div>';
	}
}

function get_fraze(){
	document.write(div_fr);
}


var onloadHandler = (typeof window.onload == "function") ? window.onload : function() {};

window.onload = function () {
	onloadHandler();
	set_pad();
}
