function LinkSubmit(Link)
{		
	var Link = document.getElementById(Link);
	
	this.AddHook = function(Id)
	{
		var Element = document.getElementById(Id);

		Element.onkeydown = function(e)
		{
			if (window.event)
			{
				Keynum = window.event.keyCode;
			}
			else if(e)
			{
				Keynum = e.which;
			}
			
			if (Keynum == 13)
			{
				Link.onclick();
			}
		}
	}
}

function PopupMenu()
{
	var _CountryMenu = null;
	var _LanguageMenu = null;
	var _PopupMenu = null;
	var _Initialize = false;
	
	this.Init = function(CountryMenuId, LanguageMenuId)
	{
		_CountryMenu = document.getElementById(CountryMenuId);
		_LanguageMenu = document.getElementById(LanguageMenuId);
		_Initialize = true;
	}
	
	this.PopupCountryMenu = function()
	{
		if (_Initialize  == false)
		{
			return;
		}
		_LanguageMenu.style.display = "none";
		
		_CountryMenu.style.display = (_CountryMenu.style.display == "none") ? "block" : "none";
		_PopupMenu = _CountryMenu;
	}
	
	this.PopupLanguageMenu = function()
	{
		if (_Initialize  == false)
		{
			return;
		}
		_CountryMenu.style.display = "none";
		_LanguageMenu.style.display = (_LanguageMenu.style.display == "none") ? "block" : "none";
		_PopupMenu = _LanguageMenu;
	}
	
	this.Hide = function()
	{
		if (_PopupMenu != null)
		{
			_PopupMenu.style.display = "none";
		}
	}
}

function InitMenu()
{
	_PopupMenu.Init("CountryMenu", "LanguageMenu");
}
		
function OnLoad()
{
	InitMenu();
	for (var Id in _GoogleMap)
	{
		_GoogleMap[Id].showGoogleMap();
	}
	IsSiteLoaded = true;
}

function OnUnload()
{
	if (_GoogleMap.length > 0)
	{
		GUnload();
	}			
}

document.onmousedown = function(e)
{
	var Target;
	
	if (e == null)
	{
		e = window.event;
	}

	if (e.target != null)
	{
		Target = e.target;
	}
	else if (e.srcElement != null)
	{
		Target = e.srcElement;
	}
	
	// For Safari
	if (Target.nodeType == 3)
	{
		Target = e.parentNode;
	}
	
	if (Target.tagName != "A")
	{
		_PopupMenu.Hide();
	}
}

function OpenPage(Url)
{
	window.location = Url;
}

function EditorAction(Id)
{
	document.getElementById("action").value = Id;
	document.editorform.submit();
}

function LoadVideo(VideoId, aElementId, aFile, aWidth, aHeight, aBackground)
{
	if (DetectFlash2(aElementId))
	{
		var so = new SWFObject(WebUrl + 'flvplayer.swf','player' + VideoId, aWidth,aHeight,'8');
		so.addVariable('file', aFile);
		so.addVariable('searchbar','false');
		if(aBackground != '')
		{
			so.addVariable('image',aBackground);
		}
		so.addVariable("width",aWidth);
		so.addVariable("height",aHeight);
		so.addParam("wmode","transparent");
	  	so.addVariable('javascriptid', VideoId);
		so.addVariable('enablejs','true');
		so.addParam('allowscriptaccess','always'); 
		so.addParam("allowFullScreen", "true");
		
		AutoPlay = "false";
		if (LoadVideo.arguments.length == 7)
		{
			AutoPlay = LoadVideo.arguments[6];
		}
		
		so.addVariable('autostart', AutoPlay);
		
		so.write(aElementId);
	}
	else
	{
		document.getElementById(aElementId).innerHTML = "Please install the Adobe Flash Player to view this website. <a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank'>Get Flash</a>";
	}
}

function DetectFlash()
{
	var requiredMajorVersion = 8;
	var requiredMinorVersion = 0;
	var requiredRevision = 0;
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

	if(hasRightVersion == false)
	{
		alert("Please install the Adobe Flash Player to view this website");
	}
}

function getUpdate(Type, Param1, Param2, Id) 
{ 
	if (Type == 'state' && Param1 == "2" && PlayVideo[_ActiveVideoId] == null)
	{
		PlayVideo[_ActiveVideoId] = true;
		
		var VideoPlayCountObj = document.getElementById("VideoPlayCount" + _ActiveVideoId);
		
		if (VideoPlayCountObj != null)
		{
			VideoPlayCountObj.innerHTML = parseInt(VideoPlayCountObj.innerHTML) + 1;
		}

		_Request.Get(WebUrl + "service/index.php?func=videostat&language="+ LangId +"&id=" + _ActiveVideoId, function(Response){});
	}
}

function InitAudio(File, AutoStart, Repeat)
{
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', '32',
		'height', '24',
		'src', 'audio',
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'scale', 'showall',
		'wmode', 'transparent',
		'devicefont', 'false',
		'id', 'player',
		'bgcolor', '#ffffff',
		'name', 'audio',
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess','sameDomain',
		'movie', WebUrl + 'audio',
		'salign', '',
		"flashvars", 'sound_url=' + File + '&auto_start=' + AutoStart + '&repeat=' + Repeat
		);
}

function ExhibitionVideo(Id, AutoStart, PlayList)
{
	if (DetectFlash2("ExhibVideo"))
	{
		var so = new SWFObject(WebUrl + 'flvplayer1.swf', 'ExhibitionPlayer', 290, 218, '8');
		so.addVariable('searchbar','false');
		so.addParam("wmode","window");
		so.addParam("allowfullscreen","true");
		so.addParam("allowscriptaccess","always");
		//so.addParam("flashvars","autostart=" + AutoStart + "&file=" + PlayList);
		so.addParam("flashvars","file=" + PlayList);
		so.write(Id);
	}
}

function playerReady()
{
	if (typeof(ExhibitionPlayer) == "undefined")
	{
		ExhibitionPlayer = document.getElementById("ExhibitionPlayer");
	}
	
	//ExhibitionPlayer.addModelListener("STATE", "ExhibitionStateVideo");
	ExhibitionPlayer.addControllerListener("ITEM", "ExhibitionPlayListItem");
	
	//IsExhibitionPlayerReady = true;
}

function ExhibitionStateVideo(obj) 
{ 
	/*if (obj.newstate == "COMPLETED" && ExhibitionIgnoreNext == false)
	{
		ExhibitionPlayer.sendEvent("NEXT");
	}*/
}

function ExhibitionPlayListItem(obj)
{
	var Switcher = document.getElementById("ExhibitionVideoSwitcher");
	Switcher.innerHTML = ((obj.index == 0) ?  '<span>' + ExhibitionLinks.Link1 + '</span>' : '<a href="#" onclick="SwitchExhibitionVideo(0);">' + ExhibitionLinks.Link1 + '</a>') + 
						 ((obj.index == 1) ?  '<span>' + ExhibitionLinks.Link2 + '</span>' : '<a href="#" onclick="SwitchExhibitionVideo(1);">' + ExhibitionLinks.Link2 + '</a>');
}

function SwitchExhibitionVideo(Id)
{
	if (ExhibitionPlayer != null)
	{
		ExhibitionIgnoreNext = true;
		ExhibitionPlayer.sendEvent("ITEM", Id);
	}
}

function DetectFlash2(ElementId)
{
	var requiredMajorVersion = 8;
	var requiredMinorVersion = 0;
	var requiredRevision = 0;
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if (hasRightVersion == false)
	{
		document.getElementById(ElementId).innerHTML = "Please install the Adobe Flash Player to view this website. <a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank'>Get Flash</a>";
		return false;
	}
	return true;
}

function SetBanner(Params)
{
	if (DetectFlash2('Banner' + Params.Id))
	{
		var so = new SWFObject(Params.Url, 'Banner' + Params.Id, Params.Width, Params.Height, '8');
		/*so.addParam("wmode","transparent"); */
		so.write("Banner" + Params.Id);
	}
}

function virtualTour(params)
{
    var so = new SWFObject(params.url, "virtualtour", "100%", "100%", '8', "#ffffff");
    so.addParam("wmode","transparent");
    so.addParam("flashvars", params.flashVars);
    so.write(params.id);
}

function saveSettings(id, val)
{
    _Request.Get(WebUrl + "service/index.php?func=settings&language=9&id=" + id + "&val=" + val , function(Response){});
}

var ExhibitionLinks = { Link1 : "", Link2 : "", Link3 : "" };
//var IsExhibitionPlayerReady = false;
//var ExhibitionIgnoreNext = false;
var PlayVideoLine = 0;
var PlayVideo = new Array();
var _Request = new HttpRequest();
var WebUrl = "";
var LangId = 0;
var _GoogleMap = new Array();
var _GoogleMapCount = 0;
var IsSiteLoaded = false;