// set element property (cross-browser)
function setProp(Name, Param, Val) {
    		if(!eval('document.'+Name))  {
			if (document.getElementById) {
				eval('document.getElementById("'+Name+'").style.'+Param+'='+Val);
			} else
			return 0;
    		}
    		else
		eval('document.'+Name+'.'+Param+'='+Val);
}
// get element property (cross-browser)
function getProp(Name, Param) {
    		if(!eval('document.'+Name))  {
			if (document.getElementById) {
				return eval('document.getElementById("'+Name+'").style.'+Param);
			} else
			return 0;
    		}
    		else
		return eval('document.'+Name+'.'+Param);
}
// get element of page by id (cross-browser)
function elementById(Name) {
	if(navigator.appName.indexOf("Microsoft")!=-1) {
	// IE
		if(!eval('document.all("'+Name+'")')) return 0; else return document.all(Name);
  	}
  	else {
	// NN & others
    		if(!eval('document.'+Name))  {
			if (document.getElementById) {
				return eval('document.getElementById("'+Name+'")');
			} else
			return 0;
    		}
    		else
		return eval('document.'+Name);
	}
}
// for admin
function pclick(s)
{
	var state = (getProp('cb'+s, 'display')=='none') ? "''" : "'none'";
	var i = elementById('ci'+s);
	setProp('cb'+s, 'display', state);
		x = i.src;
	if (x.search('_down')!=-1)
		i.src = urlToImg + 'images/catitem.gif';
	else
		i.src = urlToImg + 'images/catitem_down.gif';
}
// open url in new window
function openUrl(s) 
{
	window.open(s);
}
// detect flash version
function flashVersion()
{
    if (!navigator.f)
    {
    	navigator.f = '0';
    }
	var plugin = 0;

	plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

	if (plugin)
	{
		var re = /(\d+)\.\d+/;
		var out = re.exec(plugin.description);
		if (out.length>1) navigator.f = parseInt(out[1]);
	}
	else    
	    if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows XP")>=0))
	    {
	        navigator.f = '0';
	        document.write('<SCRIPT LANGUAGE=VBScript>\n');
	        document.write(' FlashMode = false\n');
	        document.write(' on error resume next\n');
	        document.write(' FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))\n');
	        document.write(' If FlashMode = True Then\n');
	        document.write('    navigator.f = "10"\n');
	        document.write(' Else\n');
	        document.write(' FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))\n');
	        document.write(' If FlashMode = True Then\n');
	        document.write('    navigator.f = "9"\n');
	        document.write(' Else\n');
	        document.write(' FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))\n');
	        document.write(' If FlashMode = True Then\n');
	        document.write('    navigator.f = "8"\n');
	        document.write(' Else\n');
	        document.write('    FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))\n');
	        document.write('    If FlashMode = True Then\n');
	        document.write('        navigator.f = "7"\n');
	        document.write('    Else\n');
	        document.write('        FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))\n');
	        document.write('        If FlashMode = True Then\n');
	        document.write('            navigator.f = "6"\n');
	        document.write('        Else\n');
	        document.write('            FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))\n');
	        document.write('            If FlashMode = True Then\n');
	        document.write('                navigator.f = "5"\n');
	        document.write('            Else\n');
	        document.write('                FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))\n');
	        document.write('                If FlashMode = True Then\n');
	        document.write('                    navigator.f = "4"\n');
	        document.write('                Else\n');
	        document.write('                    FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))\n');
	        document.write('                    If FlashMode = True Then\n');
	        document.write('                        navigator.f = "3"\n');
	        document.write('                    Else\n');
	        document.write('                        navigator.f = "0"\n');
	        document.write('                    End If\n');
	        document.write('                End If\n');
	        document.write('            End If\n');
	        document.write('        End If\n');
	        document.write('    End If\n');
	        document.write(' End If\n');
	        document.write('</SCRIPT>\n');
	    }
	    else
	    {
	        navigator.f = '0';
	    }

	return navigator.f;
}
// flash cond. write
function flashConditionWrite(IfFlash, IfNotFlash, NeedFlashVersion)
{
    var f;
    f = flashVersion();
	if (f >= NeedFlashVersion)
	{
		document.write(IfFlash);
	}
	else
	{
		document.write(IfNotFlash);
	}
}
// close sities
function closeCities()
{
	setProp('cities', 'display', "'none'");
	if(elementById('com'))
		{
			setProp('com', 'display', "''");
		}
}
// close login
function closeLogon()
{	if(elementById('loginform'))
	{
		setProp('loginform', 'display', "'none'");
	}
}

// cities
function changeCity()
{
	closeLogon();
	var cities = elementById('cities');
	var state = (getProp('cities', 'display')=='none') ? "''" : "'none'";
	setProp('cities', 'display', state);
	if(elementById('com'))
		{
			var comfirms = elementById('com');
			var state3 = (getProp('com', 'display')=='none') ? "''" : "'none'";
			//setProp('com', 'display', state3);
		}
	
}
// login form
function loginForm()
{
	closeCities();
	var flogin = elementById('loginform');
	var state = (getProp('loginform', 'display')=='none') ? "''" : "'none'";
	setProp('loginform', 'display', state);
	setProp('goodsbox', 'display', ((state=="''")?"'none'":"''"));
	
}
// set vacancies search
function setRVSearch(t)
{	
	var a = elementById('advsearch');
	var l = elementById('lnk');
	var j = elementById('job');
	var o = elementById('rvsearchform');
	var v = elementById('vacsearch');
	var r = elementById('ressearch');
	var f = elementById('rvsearchform');
	if (t=='v')
	{	
		a.href = 'advsearchvac/';
		l.href = 'vacancies/';
		j.href = 'addvacancies/';
		o.action = 'search/vac/';
		v.className = 'vacsearcha';
		r.className = 'ressearch';
		f.textfield.focus();
	}
	else
	{	
		a.href = 'advsearchres/';
		l.href = 'rescat/';
		j.href = 'addresume/';
		o.action = 'search/res/';
		v.className = 'vacsearch';
		r.className = 'ressearcha';
		f.textfield.focus();
	}
}

//citySelect
function citySelect(citycombo)
{
	var idcity = "";
	var streetcombo = elementById('select3');
	streetcombo.options.length = 0;
	
	if(citycombo.selectedIndex != -1)
	{	
		idcity = citycombo.options[citycombo.selectedIndex].value;
	}

	var src = citycombo.form.buffer.value;
	var res = src.match(/%(.*?);/ig);	
	cnt=0;
	
	for (var key in res)
		{	
			if(key!="input" && key!="index" && key!="lastIndex")
				{	
					arr = /([0-9]*)-([0-9]*)-(.*);/.exec(res[key]);
					if(arr[2] == idcity)
						{	
							streetcombo.options[streetcombo.options.length] = new Option(arr[3], arr[1]);
							cnt=cnt+1;
						}	
				}
						

		}
}
function citySelect2(citycombo)
{
	var idcity = "";
	var streetcombo = elementById('select3');
	streetcombo.options.length = 0;
	streetcombo.options[streetcombo.options.length] = new Option(" -- // -- // -- // -- " , "-1");
	if(citycombo.selectedIndex != -1)
	{	
		idcity = citycombo.options[citycombo.selectedIndex].value;
	}

	var src = citycombo.form.buffer.value;
	var res = src.match(/%(.*?);/ig);	
	cnt=0;
	
	for (var key in res)
		{	
			if(key!="input" && key!="index" && key!="lastIndex")
				{	
					arr = /([0-9]*)-([0-9]*)-(.*);/.exec(res[key]);
					if(arr[2] == idcity)
						{	
							streetcombo.options[streetcombo.options.length] = new Option(arr[3], arr[1]);
							cnt=cnt+1;
						}	
				}
						

		}
}
function partSelect(partcombo)
{
	var idpart = "";
	var rubriccombo = elementById('nazv17');
	rubriccombo.options.length = 0;
	
	if(partcombo.selectedIndex != -1)
	{	
		idpart = partcombo.options[partcombo.selectedIndex].value;
	}

	var src = partcombo.form.buffer2.value;
	var res = src.match(/%(.*?);/ig);	
	cnt=0;
	
	for (var key in res)
		{	
			if(key!="input" && key!="index" && key!="lastIndex")
				{	
					arr = /([0-9]*)-([0-9]*)-(.*);/.exec(res[key]);
					if(arr[2] == idpart)
						{	
							rubriccombo.options[rubriccombo.options.length] = new Option(arr[3], arr[1]);
							cnt=cnt+1;
						}	
				}
						

		}
}
function partSelect2(partcombo)
{
	var idpart = "";
	var rubriccombo = elementById('nazv17');
	rubriccombo.options.length = 0;
	rubriccombo.options[rubriccombo.options.length] = new Option(" -- // -- // -- // -- " , "-1");
	if(partcombo.selectedIndex != -1)
	{	
		idpart = partcombo.options[partcombo.selectedIndex].value;
	}

	var src = partcombo.form.buffer2.value;
	var res = src.match(/%(.*?);/ig);	
	cnt=0;
	
	for (var key in res)
		{	
			if(key!="input" && key!="index" && key!="lastIndex")
				{	
					arr = /([0-9]*)-([0-9]*)-(.*);/.exec(res[key]);
					if(arr[2] == idpart)
						{	
							rubriccombo.options[rubriccombo.options.length] = new Option(arr[3], arr[1]);
							cnt=cnt+1;
						}	
				}
						

		}
}
function hid2(diffcity)
{
	var citycombo = elementById('select5');
	var city = elementById('city');
	var city = elementById('dcity');
	if(diffcity.value=="") 
		{
			citycombo.disabled = false; 
			setProp('city', 'display', "''");
			setProp('dcity', 'display', "'none'");
		}
		else
		{
			citycombo.disabled = true; 
			setProp('city', 'display', "'none'");
			setProp('dcity', 'display', "''");
		}
}
function hid(diffcity)
{	
	var citycombo = elementById('select2');
	var streetcombo = elementById('select3');
	var diffstreet = elementById('diffstreet');
	var selstr = elementById('selstr');
	var city = elementById('city');
	var city = elementById('diffcity');
	
	
	if(diffcity.value=="") 
		{
			streetcombo.disabled = false; 
			citycombo.disabled = false; 
			setProp('diffstreet', 'display', "'none'");
			setProp('selstr', 'display', "''");
			setProp('city', 'display', "''");
			setProp('diffcity', 'display', "'none'");
			

		}
		else
		{
			streetcombo.disabled = true;
			citycombo.disabled = true; 
			setProp('diffstreet', 'display', "''");	
			setProp('selstr', 'display', "'none'");
			setProp('city', 'display', "'none'");
			setProp('diffcity', 'display', "''");
		}

}

function remFirm(t, id)
{
	n = 'hr'+id;
	var ssilko = elementById(n);
	var h = window.location.href;
	v = t.options[t.selectedIndex].value;
	if(t.options[t.selectedIndex].value=='0') {ssilko.href=h+'&delete='+id+'&reason=0';}
	if(t.options[t.selectedIndex].value=='1') {ssilko.href=h+'&delete='+id+'&reason=1';}
	
}
function remFirm2(tt, id)
{
	n = 'hr'+id;
	
	var ssilko = elementById(n);
	var t = elementById(tt);

	var h = window.location.href;
	v = t.options[t.selectedIndex].value;
	if(t.options[t.selectedIndex].value=='0') {ssilko.href=h+'&delete='+id+'&reason=0';}
	if(t.options[t.selectedIndex].value=='1') {ssilko.href=h+'&delete='+id+'&reason=1';}
	
}

function remFirm3(t, id)
{
	n = 'hr'+id;
	var ssilko = elementById(n);
	var res = window.location.href;
	var h = res.replace(/(edit=[0-9]*&)/i, "");
	v = t.options[t.selectedIndex].value;
	if(t.options[t.selectedIndex].value=='0') {ssilko.href=h+'&delete='+id+'&reason=0';}
	if(t.options[t.selectedIndex].value=='1') {ssilko.href=h+'&delete='+id+'&reason=1';}
	if(t.options[t.selectedIndex].value=='2') {ssilko.href=h+'&delete='+id+'&reason=2';}
	
}
function remFirms(bu, bufid)
{	
	var  b = elementById(bu);
	var  c = elementById(bufid);
	var str = b.value;
	var str2 = c.value;
	var arrid = str.split(',');
	var arr2 = str2.split(',');

	for (var key in arrid)
	{
		if(key!="input" && key!="index" && key!="lastIndex")
			{
				remFirm2( arrid[key], arr2[key]);
			}
	}
	
}
String.prototype.printAddr = 
function (_hamper,_prefix,_postfix,_face)
{
  _hamper=
  _prefix+
  "@"+
  this+
  (_postfix || '')
  document.write((_face||_hamper).link("mailto:"+_hamper));
}
function printMail(a, z, b)
{	
	if(a=='')	document.write('');
	else
	document.write('<a href="mailto:'+a+'@'+b+'">'+a+'@'+b+'</a>');

}
function printMailTo(a, z, c, b)
{	
	if(a=='')	document.write('');
	else
	document.write('<a href="mailto:'+a+'@'+b+'">'+c+'</a>');
	
}