var oBody = null;
var nFlashLeft = 0;
var nFlashTop = 0;
var nFlashWidth = 0;
var nFlashHeight = 0;
var bFn_HtmlLoaded = false
var bFn_FlashLoaded = false
var oFn_LoadingMessage = null

//===========================================================================================

function COMMON_ExitSite ()
//       ~~~~~~~~~~~~~~~~
{   
   window.close();     
}
//----------------------------------------------------------------

function SetFlashPosition(oFlash)
//       ~~~~~~~~~~~~~~~~
{
  var oBody = GetBodyProperties();   
  oFlash.style.position = 'absolute';      
  oFlash.style.width = nFlashWidth;            
  oFlash.style.height = nFlashHeight;     
  oFlash.style.left = nFlashLeft = (oBody.clientWidth - nFlashWidth) / 2;    
  oFlash.style.top = nFlashTop = (oBody.clientHeight - nFlashHeight) / 2;      
  return oBody
}
//===========================================================================================

function GetBodyProperties()
//       ~~~~~~~~~~~~~~~~~
{  
  for(nBody = 0; nBody < document.all.length; nBody++)
  {
    if(document.all[nBody].tagName == 'BODY')
    {
      nFlashWidth = Math.floor(Math.min(document.all[nBody].clientWidth, document.all[nBody].clientHeight * 4 / 3));            
      nFlashHeight = Math.floor(Math.min(document.all[nBody].clientWidth * 3 / 4, document.all[nBody].clientHeight));            
      oBody = document.all[nBody];
      break;
    }
  }
  return oBody
}

//===========================================================================================

function SetXmlMessages (oFlash, sPath)
//       ~~~~~~~~~~~~~~
{  
   oFlash.SetVariable("/LoadedMovie/cForm:sXMLPath", sPath);   
   oFlash.SetVariable("/LoadedMovie/cForm/cConfirm:tooltipsFiles", "sounds//tooltips//yes.mp3,sounds//tooltips//no.mp3");    
}
//===============================================================

function hyperlink(sURL)
//       ~~~~~~~~~
{
  window.open(sURL, "_blank",  "scrollbars=1, width=" + Math.floor(screen.width * 0.8) + ", height=" + Math.floor(screen.height * 0.8) + ", left=20, top=20, status=1, location=1, menubar=1, titlebar=1, toolbar=1, resizable=1");
}
//===============================================================

function getXmlMessage ()
//       ~~~~~~~~~~~~~
{

}
//===============================================================

function CallAjax(sUrl)
//       ~~~~~~~~
{
  var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  var sXmlData = "<root></root>"          
  xmlhttp.open("POST" , sUrl, false);      
  xmlhttp.setRequestHeader("Content-Type", "charset=utf-8")      
  xmlhttp.send(sXmlData);
  //alert("CallAjax" + sUrl)
  if (xmlhttp.readyState==4)
  { 
    if (xmlhttp.status==200)
    {     
      //alert("CallAjax res: " + xmlhttp.responseText)
      return (xmlhttp.responseText)
    }
  }          
}
//----------------------------------------
    
function LoadXmlAndDo(sFile, func)
//       ~~~~~~~~~~~~
{
//alert("LoadXmlAndDo")
	var bLoaded;
	var oXML = new ActiveXObject("Microsoft.XMLDOM");
	oXML.async = false;
	oXML.load(sFile);
	if(oXML.readyState == 4){
		func(oXML);
		bLoaded = true;
	}
	oXML.onreadystatechange = function () {
		if (oXML.readyState == 4 && bLoaded){
			func(oXML);
		}
	}
}
// -----------------------------------------------------------

function __OpenActivityPage(oIfrm, sUrl)
//       ~~~~~~~~~~~~~~~~~~
{ 
  oIfrm.style.left = nFlashLeft;
  oIfrm.style.top = nFlashTop;
  oIfrm.style.width = nFlashWidth;
  oIfrm.style.height = nFlashHeight;
  oIfrm.style.visibility = "visible";
  oIfrm.src = sUrl;
} 
//--------------------------------------------------------

function __HideActiveIframe(oIfrm)
//       ~~~~~~~~~~~~~~~~~~
{ 
  oIfrm.style.visibility = "hidden";
  oIfrm.src = "";
} 
//--------------------------------------------------------


function ShowFlash(oFlash, sFrom, bSetFlashPosition)
//       ~~~~~~~~~
{
  if (sFrom == 'main')
    bFn_HtmlLoaded = true
  else
    bFn_FlashLoaded = true
    
  if (bFn_FlashLoaded && bFn_HtmlLoaded)
  {
    document.all.loadingMessageID.style.display = "none"
    if (bSetFlashPosition)
      SetFlashPosition(oFlash);
    else
    {
      oFlash.height = "100%"
      oFlash.width =  "100%"
    }
  }
}
//--------------------------------------------------------

function  IsResolution(oMovie, nWidth, nHeight, sScale)
//        ~~~~~~~~~~~~
{
  if (screen.width == nWidth && screen.height == nHeight)
    setScale(oMovie, sScale);
  else
    setScale(oMovie, "noScale");
}
//-------------------------------------------------------

function setScale(oMovie, sScale)
//       ~~~~~~~~
{
  if (oMovie!=null)
   oMovie.SetVariable("Stage.scaleMode", sScale);
}
//-------------------------------------------------------
 function OpenWindow(sURL, width, height)
  {
    var leftPoint = (window.screen.availWidth-width)/2; 
    var topPoint = (window.screen.availHeight-height)/2; 
    var oWin = window.open(sURL, "_blank", "width=" + width + ", height=" + height + ", left=" + leftPoint + ", top=" +  topPoint + ", status=0, location=0, menubar=0, titlebar=1, toolbar=0, resizable=0, scrollbars=0");
  }
//-------------------------------------------------------
