var menuTimer1, menuTimer2;

// 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)
	{
		navigator.f = parseInt(plugin.description.substring(plugin.description.indexOf(".")-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.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;
}
//
function flashConditionWrite(IfFlash, IfNotFlash, NeedFlashVersion)
{
    var f;
    f = flashVersion();
	if (f >= NeedFlashVersion)
	{
		document.write(IfFlash);
	}
	else
	{
		document.write(IfNotFlash);
	}
}
function onjavamenu(pid)
{
	if (pid==0)
	{				
		setProp('javamenu', 'display', "'none'");
	}
	else 
	{
		clearTimeout(menuTimer1);
		clearTimeout(menuTimer2);
		setProp('javamenu', 'display', "'block'");
	}
}
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);
	}
}
// set element property (cross-browser)
function setProp(Name, Param, Val) {
	if(navigator.appName.indexOf("Microsoft")!=-1) {
	// IE
		if(!eval('document.all("'+Name+'")')) return 0; else eval('document.all("'+Name+'").style.'+Param+'='+Val);
  	}
  	else {
	// NN & others
    		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(navigator.appName.indexOf("Microsoft")!=-1) {
	// IE
		if(!eval('document.all("'+Name+'")'))
			return 0;
		else
			return eval('document.all("'+Name+'").style.'+Param);
  	}
  	else {
	// NN & others
    		if(!eval('document.'+Name))  {
			if (document.getElementById) {
				return eval('document.getElementById("'+Name+'").style.'+Param);
			} else
			return 0;
    		}
    		else
		return eval('document.'+Name+'.'+Param);
	}
}

function imgsearch(str)
{
	var re = new RegExp("/images/porto_on_main/img([0-9]+)\.jpe?g","ig");
	var arr = re.exec(str);
	return RegExp.$1;
}

function imgmove(pid,col)
{
	var b = 0;
	if (pid==1)
	{
		var o = elementById('img1');
		var	a = o.src;
		var i = parseInt(imgsearch(a));
		for (var j=1;j<=4;j++)
		{
			if (i+j>col)
			{
				b=i+j-col;
			}
			else b=i+j;
			var o = elementById('img'+j);
			o.src = '/images/porto_on_main/img'+b+'.jpg';
		}
	}
	else 
	{
		var o = elementById('img4');
		var	a = o.src;
		var i = parseInt(imgsearch(a));
		for (var j=4;j>=1;j--)
		{
			if (i-(5-j)<1)
			{
				b=i-(5-j)+col
			}
			else b=i-(5-j);
			var o = elementById('img'+j);
			o.src = '/images/porto_on_main/img'+b+'.jpg';
		}
	}
}

function setText()
{
	try
	{
	    document.getElementById("snizu").innerHTML = elementById("sverhu").innerHTML;
	}
	catch (err)
	{
	}
}
