var totalsecs=300;  //total number of seconds to decrement from
var isIE = document.layers?false:true;

function showCountdown()
{

 code = "<span name=number id=number style=\"position:relative\">"+getTime(totalsecs)+"</span>";
 if(!isIE){
  code = "<form name=numberForm><input type=text name=number align=right size=7 value="+getTime(totalsecs)+"></form>";
 }
 if(isIE){
  document.write(code);
 }
 else{
  document.open();
  document.write(code);
  document.close();
 }
 decrement();
}

function getTime(totalsecs){
 hours=Math.floor(totalsecs/60/60);
 minutes=Math.floor((totalsecs-(hours*3600))/60);
 secs = Math.floor((totalsecs-(hours*3600)-(minutes*60)));
 return (minutes<10?(minutes<1?"00":minutes):minutes)+" minutes and "+(secs<10?(secs<1?"00":"0"+secs):secs)+" seconds";
}

function decrement(){
 next=getTime(totalsecs);
 if(isIE){
  document.getElementById('number').innerHTML=next;
 }
 else{
  document.forms.numberForm.number.value=next;
 }
 totalsecs--;
 if(totalsecs>-1)setTimeout("decrement();",1000);

}


var wantcookie="1";

function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {
    begin = document.cookie.indexOf(NameOfCookie+"=");
    if (begin != -1) {
      begin += NameOfCookie.length+1;
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    }
  }
  return null;
}

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) +
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}



function redirect()
{
    alert('Sorry, times up. You just lost a chance of a lifetime. This offer won\'t be shown again');
	document.location='confirmorder.php';

}


function start()
{


visited=getCookie('cookieid');



	if (visited==null)
	{

	 setCookie('cookieid','yes',30);
	 setTimeout('redirect()',totalsecs*1000);
	}
else
{
redirect();
}



}

start();
