var current_dir = '/img/templates/general/img/'; var rest_pic = '';
function check() {
if (document.globe.country.value == ''){alert (lng_01);return false;}
else {if (document.globe.city.selectedIndex == 0){alert (lng_02);return false;}
else {document.globe.submit();}}
}
function chCity(cno) {
if (cno.value == '') {var selectedArray = document.globe.city; ClearCity (); selectedArray.options[0] = new Option(lng_03, "");selectedArray.options[0].selected = true;selectedArray.disabled = true;} 
else {var selectedArray = document.globe.city; ClearCity (); selectedArray.options[0] = new Option(lng_04, "");selectedArray.options[0].selected = true;selectedArray.disabled = true;
goHttp('/tools/getcitieslist.php?cid='+cno.value);
}}
function ClearCountry () {var selectedArray = document.globe.country; var col = selectedArray.options.length - 1; for (var i=col;i>=0;i--) {selectedArray.options[i] = null;}}
function ClearCity () {var selectedArray = document.globe.city; var col = selectedArray.options.length - 1; for (var i=col;i>=0;i--) {selectedArray.options[i] = null;}}
function InsCountry (i,namez,idz,is_select) {if (is_select) document.globe.country.options[i] = new Option(namez, idz, false, true); else document.globe.country.options[i] = new Option(namez, idz, false, false);}
function InsCity (i,namez,idz,is_select) {if (is_select) document.globe.city.options[i] = new Option(namez, idz, false, true); else document.globe.city.options[i] = new Option(namez, idz, false, false);}
function ChPic(_obj, _src) {rest_pic = _obj.src; _obj.src = current_dir + _src;}
function RsPic(_obj) {if (rest_pic != '') _obj.src = rest_pic; rest_pic = '';}
function goHttp (_url) {
var old_s = document.getElementById('dataloader'); if (old_s){old_s.parentNode.removeChild(old_s);} var s = document.createElement('script'); s.setAttribute('type', 'text/javascript'); s.src = _url; s.id = 'dataloader'; document.getElementsByTagName('head')[0].appendChild(s);
}

$(function()
{
	var hideDelay = 500;  
	var currentID;
	var hideTimer = null;
	
	/*
	if ( $.browser.msie ) {
		alert( parseInt($.browser.version, 10) );
	}
	*/

	// One instance that's reused to show info for the current person
	var container = $('<div id="PopupContainer">'
		+ '<table border="0" ' + (($.browser.msie) ? 'width="550"' : '') + ' cellspacing="0" cellpadding="0" align="center" class="PopupWindow">'
		+ '<tr>'
		+ '   <td class="corner topLeft"></td>'
		+ '   <td class="top"></td>'
		+ '   <td class="corner topRight"></td>'
		+ '</tr>'
		+ '<tr>'
		+ '   <td class="left">&nbsp;</td>'
		+ '   <td><div id="PopupContent"></div></td>'
		+ '   <td class="right">&nbsp;</td>'
		+ '</tr>'
		+ '<tr>'
		+ '   <td class="corner bottomLeft">&nbsp;</td>'
		+ '   <td class="bottom">&nbsp;</td>'
		+ '   <td class="corner bottomRight"></td>'
		+ '</tr>'
		+ '</table>'
		+ '</div>');

	$('body').append(container);

	$('.PopupTrigger').live('mouseover', function() {
		
		var settings = $(this).attr('rel').split(',');
		var hintID = settings[0];

		if (hintID == '')
			return;

		if (hideTimer)
			clearTimeout(hideTimer);

		var pos = $(this).offset();
		var width = $(this).width();
		container.css({
			left: (pos.left + width) + 'px',
			top: pos.top - 5 + 'px'
		});

		$('#PopupContent').html('<center><img src="/img/loading1.gif"></center>');
		
		$.ajax({
			type: 'GET',
			url: '/tools/gethint.php',
			data: 'hintid=' + hintID,
			success: function(data) {
				$('#PopupContent').html(data);
			}
		});

		container.css('display', 'block');
		
	});

	$('.PopupTrigger').live('mouseout', function() {
		if (hideTimer)
			clearTimeout(hideTimer);
		hideTimer = setTimeout(function() {
			container.css('display', 'none');
		}, hideDelay);
	});

	// Allow mouse over of details without hiding details
	$('#PopupContainer').mouseover(function() {
		if (hideTimer)
			clearTimeout(hideTimer);
	});

	// Hide after mouseout
	$('#PopupContainer').mouseout(function() {
		if (hideTimer)
			clearTimeout(hideTimer);
		
		hideTimer = setTimeout(function() {
			container.css('display', 'none');
		}, hideDelay);
	});
	
	$('.inp').focus(function() {
		$(this).addClass('inp_focus');
	});
	
	$('.inp').blur(function() {
		$(this).removeClass('inp_focus');
	});
});
