//*----------------------------------------------------------------------------*/
//*     (c)Copyright 2010 Gifts And Things, All Rights Reserved                */
//*                                                                            */
//*     This document contains proprietary and confidential information. The   */
//*     contents of this document may not be disclosed to third parties,       */
//*     copied, or duplicated in any form, in whole or in part, without the    */
//*     prior written permission of 1st4Eve-Online.                            */
//*                                                                            */
//*     This software is protected by the copyright laws and international     */
//*     copyright treaties, as well as other intellectual property laws and    */
//*     treaties.                                                              */
//*----------------------------------------------------------------------------*/

function ReloadPage()
{
    location.reload(true);
}

function StartCountDown(CountdownDiv,EndDateTime)
{
    var dateenddatetime = new Date(EndDateTime);
    var datenow = new Date();
    dateendnowdiff = new Date(dateenddatetime-datenow);
    gsecs = Math.floor(dateendnowdiff.valueOf()/1000);
    CountBack(CountdownDiv, gsecs);
}

function CalculateTimeToGo(secs, num1, num2)
{
    s = ((Math.floor(secs/num1))%num2).toString();
    if (s.length < 2) 
    { 
        s = "0" + s;
    }
    return (s);
}

function CountBack(CountdownDiv, secs)
{
    var DisplayString;
    var DisplayFormat = "Time Left %%D%%d %%H%%h %%M%%m %%S%%s";
    
    DisplayString = DisplayFormat.replace(/%%D%%/g, CalculateTimeToGo(secs,86400,100000));
    DisplayString = DisplayString.replace(/%%H%%/g, CalculateTimeToGo(secs,3600,24));
    DisplayString = DisplayString.replace(/%%M%%/g, CalculateTimeToGo(secs,60,60));
    DisplayString = DisplayString.replace(/%%S%%/g, CalculateTimeToGo(secs,1,60));

    if(secs > 0)
    { 
        document.getElementById(CountdownDiv).innerHTML = DisplayString;
        setTimeout("CountBack('" + CountdownDiv + "'," + (secs-1) + ");", 990);
    }
    else
    {
        document.getElementById(CountdownDiv).innerHTML = "Item Ended";
        location.reload(true);
    }
}


