// requires: update_header_menu_footer.js, common.js 
//           & variables: gisLoaded, gisLoadedPageAlready
//
//
// prefix by opn
//
// opn_changeOpeningLanguage(strLang)
// opn_showWebsite()

var objTextDate = document.createTextNode((new Date()).toLocaleString());
document.getElementById("fntTodaysDate").appendChild(objTextDate);
			
function opn_changeOpeningLanguage(strLang)
{
    var e;
    
    try 
    {
        document.getElementById("div_en").style.display = "none";
        document.getElementById("div_ga").style.display = "none";

        gstrLang = strLang;

        document.getElementById("div_"+strLang).style.display = "block";

        gintCountToDisplay = 2;
        init_preloadPages();
        uhmf_updateMenu();
        uhmf_updateHeader();
        uhmf_updateFooter();
        
    }
    catch (e)
    {}
}

function opn_redirectIfPageNotLoadedYet()
{
    if (!gisLoadedPageAlready)
    {
        window.location.replace("xmlXslNotSupported.html");
    }
}

function opn_showWebsite()
{
    var e;
    
    try
    {
        if (!gisLoaded)
        {
            window.setTimeout("opn_showWebsite()", 250); //try again in .25 secs if not yet loaded common functions
            return;
        }
        
        if (document.getElementById(gstrTdCurrentMenuItemId)) // check it exists yet!
        {
    
            if (!gisLoadedPageAlready)
            {
                if (window.location.href.indexOf("compusquad.com") == -1)
                {
                    //removing french
                    var objTdFr = document.getElementById("td_fr");
                    objTdFr.parentNode.removeChild(objTdFr);

	   		    var objTdEs = document.getElementById("td_es");
			    objTdEs.parentNode.removeChild(objTdEs);

			    var objTdPt = document.getElementById("td_pt");
			    objTdPt.parentNode.removeChild(objTdPt);

			  //var objTdPl = document.getElementById("td_pl");
			    //objTdPl.parentNode.removeChild(objTdPl);
                }
    
                window.title="CompuSquad Ltd. - Page Loading ... / Is atá an Láithreán á Loadáil ... ";
                document.getElementById('divFooter').style.display = "block";
                document.getElementById('divOpeningPage').style.display = "none";
                document.getElementById('divMainPage').style.display = "block";
                window.setTimeout("cmm_moveOverCompuSquadTitleAndChangeMainContent()",300);
                document.getElementById(gstrTdCurrentMenuItemId).style.backgroundColor = "#089F99";
            
                gisLoadedPageAlready = true;
            }
        }
        else
        {
            window.setTimeout("opn_showWebsite()", 250); //try again in .25 secs if not yet loaded common functions
            window.setTimeout("opn_redirectIfPageNotLoadedYet", 2250); //may be an error occurring
        }
    
    }
    catch (e)
    {
            window.setTimeout("opn_redirectIfPageNotLoadedYet", 2000);
    }
    
    
}