function showDiv($divid)
{	var div=document.getElementById($divid);
	div.style.display="block";
}

function hideDiv($divid)
{	var div=document.getElementById($divid);
	div.style.display="none";
}

var expired=false;
function expstart(date)
{	var d=new Date(date);
	var nw=new Date();
	if((d-nw)<=0)
	{	expired=true;
		document.write('<div class="expired">');
	}
}
function expend()
{	if(expired)
	    document.write("</div>");
	expired=false;
}

function countdwn(endate,stdate)
{
	var ONE_DAY=1000*60*60*24;
    var usest=(stdate!==undefined);
    var sd=new Date(stdate);
	var nd=new Date(endate);
	var nhrs=nd.getHours();
    if(nhrs<10) nhrs="0" + nhrs;
    var nmins=nd.getMinutes();
    if(nmins<10) nmins="0" + nmins;
	var shrs=sd.getHours();
    if(shrs<10) shrs="0" + shrs;
    var smins=sd.getMinutes();
    if(smins<10) smins="0" + smins;
        
	var nw=new Date();
	if(nd<nw) return;
	
    if(usest)
    {   if((nd-sd)<=ONE_DAY)
        {   if((nw-sd)>0)
            {   document.write("<div class=\"count\">One Day Only! Ends at "+nhrs+":"+nmins+"</div>\r\n");
                return;
            }
        }
        if(sd>=nw)
        {   document.write("<div class=\"countstart\">Coming soon! Valid from ");
            if((sd-nw)>ONE_DAY)
            {   document.write(sd.getDate()+"/"+(sd.getMonth()+1)+"/"+sd.getYear()+" at "+shrs+":"+smins);
                if((nd-sd)<=ONE_DAY)
                    document.write(" For one day only!");
            }
            else
            {   if(sd.getDate()==nw.getDate())
                    document.write("Today at "+shrs+":"+smins);
                else
                    document.write("Tomorrow at "+shrs+":"+smins);
                if((nd-sd)<=ONE_DAY)
                    document.write(" Until "+nhrs+":"+nmins);
            }                
            document.write("</div>\r\n");
            return;
        }
    }
	var cnt=Math.floor((nd-nw)/ONE_DAY);
	if((cnt>0) && (cnt<5))
	{	document.write("<div class=\"count\">Only "+cnt+" Day");
        if(cnt>1) document.write("s");
        document.write(" remaining</div>\r\n");
    }
	else if(cnt==0)
    {   var day=((nw.getMinutes()+nw.getHours()*60) >= (nd.getMinutes()+nd.getHours()*60))?"Tomorrow":"Today";
        document.write("<div class=\"count\">Ends "+day+" at "+nhrs+":"+nmins+"!</div>\r\n");
	}
}

function countdwns(date1,date2)
{   countdwn(date1,date2);
}
