// JavaScript Document



Date.prototype.getNextWkDay = function(iWkDay){
	if (typeof iWkDay != "number" || iWkDay < 0){
		// next Monday is the default
		iWkDay = 1;
	}

	iWkday = Math.floor(iWkDay) % 7;

	var x = (iWkDay - this.getDay() + 7) % 7, d = this;
	if (x != 0){
		var iDate = this.getDate();

		d = new Date(
			this.getFullYear(),
			this.getMonth(),
			iDate,
			this.getHours(),
			this.getMinutes(),
			this.getSeconds(),
			this.getMilliseconds());

		d.setDate(iDate + x);
	}

	return d;
};

var dNextFriday = new Date().getNextWkDay(5);
var dNextSaturday = new Date().getNextWkDay(6);
var dNextWednesday = new Date().getNextWkDay(3);
var today= new Date().getDay();


function getNextDraw(lotto){
	
	if (lotto==0) 
		getND(dNextFriday);
	
	if (lotto==1) {
		if((today>=0) && (today<4)){
			getND(dNextWednesday);
		}
		else {
			getND(dNextSaturday);
		}		
	}
}

function CDC(lotto){

	if (lotto==0) 
		countdown_clock(dNextFriday.getFullYear()-2000,dNextFriday.getMonth()+1,dNextFriday.getDate(),19,60,1,0);
	
	if (lotto==1) {
		if((today>=0) && (today<4)){
			countdown_clock(dNextWednesday.getFullYear()-2000,dNextWednesday.getMonth()+1,dNextWednesday.getDate(),20,60,1,1);
		}
		else {
			countdown_clock(dNextSaturday.getFullYear()-2000,dNextSaturday.getMonth()+1,dNextSaturday.getDate(),20,60,1,1);
		}		
	}
}

function countdown_clock(year, month, day, hour, minute, format,type)
         {
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
		if (type==0){
	        html_code = '<span id="countdown"></span>';
			document.write(html_code);
			countdown(year, month, day, hour, minute, format);
		}
		
		if (type==1){
	        html_code = '<span id="countdown1"></span>';
			document.write(html_code);
			countdown1(year, month, day, hour, minute, format);
		}
         
}
		 
         
function countdown(year, month, day, hour, minute, format)
         {
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth() + 1;                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
								                                  
         Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
//alert(Todays_Date+"  "+Target_Date);         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1:
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
                    
					
	                    document.all.countdown.innerHTML = days + ' day' + dps + ' ';
						
						document.all.countdown.innerHTML += hours + ':';
	                    document.all.countdown.innerHTML += minutes + ':';
	                    document.all.countdown.innerHTML += seconds;
					
						
	                //    document.all.countdown.innerHTML += hours + ' hr' + hps + ' ';
	                //    document.all.countdown.innerHTML += minutes + ' min' + mps + ' ';
	                //    document.all.countdown.innerHTML += seconds + ' sec' + sps;
					
					
                    break;
               default: 
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
               }
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
         }
		 
		 
		 function countdown1(year, month, day, hour, minute, format)
         {
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth() + 1;                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
								                                  
         Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
//alert(Todays_Date+"  "+Target_Date);         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.all.countdown1.innerHTML = Time_Left + ' seconds';
                    break;
               case 1:
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
                    
					document.all.countdown1.innerHTML = days + ' day' + dps + ' ';
					document.all.countdown1.innerHTML += hours + ':';
	                  document.all.countdown1.innerHTML += minutes + ':';
	                    document.all.countdown1.innerHTML += seconds;

//	                    document.all.countdown1.innerHTML += hours + ' hr' + hps + ' ';
//	                    document.all.countdown1.innerHTML += minutes + ' min' + mps + ' ';
//	                    document.all.countdown1.innerHTML += seconds + ' sec' + sps;
						
                    break;
               default: 
                    document.all.countdown1.innerHTML = Time_Left + ' seconds';
               }
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown1(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
         }
		 
		 function getND(dND){
			 document.write('<b>Next Draw:<br> ');
			 document.write(dND.toLocaleDateString());
 			 document.write('</b>');
		 }
		 
		  function getVWDheader1(dNF){
			 
				document.write('<table width="95%" border="0" cellspacing="0" cellpadding="2"><tr><td class="txtNDraw"><span class="style3">Next Draw:</span><br> <span class="style2">Fri, ');
				document.write(dNF.toLocaleDateString());
				document.write('</span></td><td class="txtNDraw"><span class="style3">Estimated Jackpot: <span class="style2">&#8364; 24 MILLION</span></span></td></tr><tr>');
				document.write('<td class="txtNDraw"><span class="style3">Remaining: </span><span class="style2">');
		  }

			function getVWDheader2(){
			  	document.write('</span></td><td align="center" class="txtNDraw"><a href="http://www.v-w-d.com/redir.asp?m=uklotto649&target=/default.asp?goto=/vwdguest/signup.asp?rp=L" target="_blank" class="btnPlayNow"><strong>PLAY Now!</strong></a></td></tr></table>');
		  }
		  
		  function getJackpot(){
			document.write('<table width="180" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#C60000"><tr><td><img src="../images/bdlu_w.gif" width="15" height="30"></td><td width="150" align="center" class="headerWhite">Estimated Jackpot</td><td><img src="../images/bdru_w.gif" width="15" height="30"></td></tr><tr><td>&nbsp;</td><td width="150" bgcolor="#FFFFFF"><div class="row">&euro;24 million EUR</div><div class="row1">£16 million   	 GBP</div><div class="row">$30 million  	USD</div><div class="row1">$34 million  	CAD</div><div class="row">$40 million  	AUD</div></td><td>&nbsp;</td></tr><tr><td><img src="../images/bdld_w.gif" width="15" height="30"></td><td width="150" align="center"><span class="btnPlayNow"><a href="http://www.v-w-d.com/redir.asp?m=uklotto649&target=/default.asp?goto=/vwdguest/signup.asp?rp=L" target="_blank" class="btnPlayNow"><strong>PLAY Now!</strong></a></span></td><td><img src="../images/bdrd_w.gif" width="15" height="30"></td></tr></table>');					  
		  }
