// JavaScript Document

var tempX = 0;
var tempY = 0;
var IE = document.all?true:false;

function show_tip(text) {
	obj = document.getElementById('tipw');
	obj.innerHTML = text;
	obj.style.display = 'block';
	if (document.addEventListener != null) {
		document.addEventListener("mousemove", move_tip, true);
	} else {
		document.attachEvent("onmousemove", move_tip);
	}
	document.body.style.cursor = 'help';
}

function hide_tip() {
	obj = document.getElementById('tipw');
	obj.innerHTML = '';
	obj.style.display = 'none';
	if (document.removeEventListener != null)
	{
		document.removeEventListener("mousemove", move_tip, true);
	} else {
		document.detachEvent("onmousemove", move_tip);
	}
	document.body.style.cursor = 'auto';
}

function move_tip(e) {
	if (IE) {
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	} else {
		tempX = e.pageX;
		tempY = e.pageY;
	}
	if (tempX < 0){tempX = 0};
	if (tempY < 0){tempY = 0};
	obj.style.left = (tempX + 10) + 'px';
	obj.style.top = (tempY + 20) + 'px';
}

function thousand_dots(obj) {
	var num = obj.value;
	num = num.split('.').join('');
	if (parseInt(num).toString() == num) {
		var new_num = '';
		var ss, se;
		for (var i = 0; i < Math.ceil(num.length / 3); i++) {
			num.length - ((i + 1) * 3) >= 0 ? ss = num.length - ((i + 1) * 3) : ss = 0;
			se = num.length - (i * 3);
			new_num = num.substring(ss, se) + '.' + new_num;
		}
		obj.value = new_num.substring(0, new_num.length - 1);
	} else {
		obj.value = num.substring(0, num.length - 1);
		thousand_dots(obj);
	}
}
function integer_input(obj) {
	var num = obj.value.replace(",",".");
	if ((parseFloat(num) != num - 0 && num.substring(num.length - 1, num.length) != ",") || num.split(",").length > 1) {
		obj.value = num.substring(0, num.length - 1).split(".").join(",");
	} else {
		obj.value = num.split(".").join(",");
	}
}

function turkish_encode(text) {
	text = text.split('Þ').join('&#350;');
	text = text.split('Ü').join('&#220;');
	text = text.split('Ö').join('&#214;');
	text = text.split('Ð').join('&#286;');
	text = text.split('Ç').join('&#199;');
	text = text.split('Ý').join('&#304;');
	text = text.split('ç').join('&#231;');
	text = text.split('ð').join('&#287;');
	text = text.split('ö').join('&#246;');
	text = text.split('ü').join('&#252;');
	text = text.split('ý').join('&#305;');
	text = text.split('þ').join('&#351;');
	return text;
}

function text_focus(obj,txt) {
	if (obj.value == txt) {
		obj.value = '';
	}
}

function text_blur(obj,txt) {
	if (obj.value == '') {
		obj.value = txt;
	}
}
