﻿addResizeEvent(ShowProgressResize);
addScrollEvent(ShowProgressResize);
addResizeEvent(ShowDialogResize);
addScrollEvent(ShowDialogResize);
addScrollEvent(ShowUploadFormResize);
addResizeEvent(ShowUploadFormResize);

//-------------------------------------------------------------------------------------------------
//--  ShowUpload FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function ShowUploadFormResize()
{    
    var ele = document.getElementById('egalDialogPromptShim');
    if(ele != null && ele.style.visibility == "visible")
    {
	    ele.style.width = MaxWidth() + 'px';
	    ele.style.height = MaxHeight() + 'px';
     	CenterLayer('earthGalleryUploadLayerId');
    }
}
function ShowUploadForm()
{
    var albumid = new Querystring().get("album");
    var ifr = document.getElementById('earthGalleryUploadIFrame');  
    var url = earthGallery_UploadPageUrl;
    if(albumid != '')   url = url + '?album=' + albumid;
    ifr.setAttribute('src', url, null); 
    
    document.getElementById('earthGalleryUploadOkId').disabled = false;
    document.getElementById('earthGalleryUploadOkId').value = LocEarthGallery.Upload;
    document.getElementById('earthGalleryUploadOkId').onclick = function()
    { 
        document.getElementById('earthGalleryUploadOkId').disabled = true;
        document.getElementById('earthGalleryUploadCancelId').style.display = 'none';
        OnUploadPhoto();
    };
    document.getElementById('earthGalleryUploadCancelId').value = LocEarthGallery.Close;
    document.getElementById('earthGalleryUploadCancelId').onclick = function()
    { 
        earthGallery_HideLayer('earthGalleryUploadLayerId'); 
    };
    document.getElementById('earthGalleryUploadHeading').innerHTML = LocEarthGallery.UploadFormHeading;
    var ele = document.getElementById('earthGalleryUploadLayerId');
    ele.className = 'earthGalleryFormLayerExternalBorder';    
    ele.style.display = '';  
    CenterLayer('earthGalleryUploadLayerId'); 
    ShowBase('egalDialogPromptShim', 'white');
    Fade('egalDialogPromptShim', 0);
}
function HideUploadForm()
{
    document.getElementById('earthGalleryUploadLayerId').style.display = '';  
    HideBase('egalDialogPromptShim');
}
//-------------------------------------------------------------------------------------------------
//--  ShowDialog FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function ShowDialogResize()
{    
    var ele = document.getElementById('egalDialogPromptShim');
    if(ele != null && ele.style.visibility == "visible")
    {
	    ele.style.width = MaxWidth() + 'px';
	    ele.style.height = MaxHeight() + 'px';
     	CenterLayer('earthGalleryDialogId');
    }
}
function ShowDialog(title, content)
{
    document.getElementById('earthGalleryDialogId').style.display = '';
    document.getElementById('earthGalleryDialogTitleId').innerHTML = title;
    document.getElementById('earthGalleryDialogContentId').innerHTML = content;
    document.getElementById('earthGalleryDialogOkId').onclick = function()
    {
        HideDialog();
    }
    ShowBase('egalDialogPromptShim', 'gray');
    Fade('egalDialogPromptShim', 0);
    CenterLayer('earthGalleryDialogId');   
}
function HideDialog()
{
    document.getElementById('earthGalleryDialogId').style.display = 'none';
    HideBase('egalDialogPromptShim');
}

//-------------------------------------------------------------------------------------------------
//--  ShowPrompt FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function ShowPrompt(title, content, okFunc)
{
    document.getElementById('earthGalleryPromptLayerId').style.display = '';
    document.getElementById('earthGalleryPromptTitleId').innerHTML = title;
    document.getElementById('earthGalleryPromptContentId').innerHTML = content;
    document.getElementById('earthGalleryPromptOkId').value = LocEarthGallery.Delete;
    document.getElementById('earthGalleryPromptCancelId').value = LocEarthGallery.Cancel;
    document.getElementById('earthGalleryPromptOkId').onclick = okFunc;
    document.getElementById('earthGalleryPromptCancelId').onclick = function()
    {
        HidePrompt();
    }
    ShowBase('egalDialogPromptShim', 'gray');
    Fade('egalDialogPromptShim', 70);
    CenterLayer('earthGalleryPromptLayerId');   
}
function HidePrompt()
{
    document.getElementById('earthGalleryPromptLayerId').style.display = 'none';
    HideBase('egalDialogPromptShim');
}
//-------------------------------------------------------------------------------------------------
//--  ShowProgress FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function ShowProgressResize()
{    
    var ele = document.getElementById('egalDialogPromptShim');
    if(ele != null && ele.style.visibility == "visible")
    {
	    ele.style.width = MaxWidth() + 'px';
	    ele.style.height = MaxHeight() + 'px';
     	CenterLayer('egalProgressId');
    }
}
function ShowProgress2(message, fadeNo)
{
    ShowBase('egalDialogPromptShim', 'gray');
    Fade('egalDialogPromptShim', fadeNo);
    document.getElementById('egalProgressMsgId').innerHTML = message;
    document.getElementById('egalProgressId').style.display = '';
    CenterLayer('egalProgressId');   
}
function ShowProgress(message)
{
    ShowBase('egalDialogPromptShim', 'gray');
    Fade('egalDialogPromptShim', 70);
    document.getElementById('egalProgressMsgId').innerHTML = message;
    document.getElementById('egalProgressId').style.display = '';
    CenterLayer('egalProgressId');   
}
function HideProgress()
{
    document.getElementById('egalProgressId').style.display = 'none';
    HideBase('egalDialogPromptShim');
}
//-------------------------------------------------------------------------------------------------
//--  ShowError FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function ShowError(err)
{
    document.getElementById('egalErrorMsgId').innerHTML = err;
    document.getElementById('egalErrorId').style.display = '';
    CenterLayer('egalErrorId'); 
    ShowBase('egalDialogPromptShim', 'white');
    Fade('egalDialogPromptShim', 70);
}
function HideError()
{
    var ele = document.getElementById('egalErrorId');
    ele.style.display = 'none';
    HideBase('egalDialogPromptShim');
}
//-------------------------------------------------------------------------------------------------
//--  ShowBase FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function ShowBase(shimid, color)
{
	var shim = document.getElementById(shimid).style;
	shim.position = 'absolute';
	shim.width = MaxWidth() + 'px';
	shim.height = MaxHeight()+ 'px';
	shim.left = '0px';
	shim.top = '0px';
	shim.backgroundcolor = color; //'white';
	shim.visibility="visible";
}
function HideBase(shimid)
{
     document.getElementById(shimid).style.visibility="hidden";	
}
function earthGallery_HideLayer(eleId)
{
    var ele = document.getElementById(eleId);
    ele.style.display = 'none';
    HideBase('egalDialogPromptShim');
}
//-------------------------------------------------------------------------------------------------
//--  SYSTEM FUNCTION  ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
    window.onload = func;
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
        oldonload();
      func();
    }
  }
}
function addResizeEvent(func) 
{
    var oldonresize = window.onresize;
    if (typeof window.onresize != 'function')
        window.onresize = func;
    else
    {
        window.onresize = function()
        {
            if (oldonresize)
                oldonresize();
            func();
        }
    }
}
function addScrollEvent(func) 
{
    var oldonscroll = window.onscroll;
    if (typeof window.onscroll != 'function')
        window.onscroll = func;
    else
    {
        window.onscroll = function()
        {
            if (oldonscroll)
                oldonscroll();
            func();
        }
    }
}
function Fade(id, opacity)
{
    var object = document.getElementById(id).style;
    object.filter = "alpha(opacity=" + opacity + ")"; 
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100); 
}