// This file contains the javascript part of the Countdown

// All you have to do is to correct the Date in the following few variables.

// for the reason of validation, please don't put an 0 in front of the numbers from 1 - 9. (write 9 instead of 09).







// You may enter your date here

//first the year

var year  = 2011; 

//next the month

var month = 6;

//.. and the day

var day   = 25; 

//if you want to be more specific, you can add hours, minutse and seconds (the exact time):

//hours:

var hour   = 20;

//minutes

var minute = 18;

//seconds

var second = 56;



//you can change the following images to your own ones, if you like to. There is always one plural and one singular (eg days and day)

var strDaysBig  = ' <img src="images/text/daysleft.png" /> ';

var strDayBig   = ' <img src="images/text/dayleft.png" /> ';

var strDays     = ' <img src="images/text/days.png" /> ';

var strDay      = ' <img src="images/text/day.png" /> ';

var strHours    = ' <img src="images/text/hours.png" /> ';

var strHour     = ' <img src="images/text/hour.png" /> ';

var strMinutes  = ' <img src="images/text/minutes.png" /> ';

var strMinute   = ' <img src="images/text/minute.png" /> ';

var strSeconds  = ' <img src="images/text/seconds.png" /> ';

var strSecond   = ' <img src="images/text/second.png" /> ';



//this is the message users will see when the countdown is finished. of course you can replace it with your own one.

var strTimesUp  = ' Time is up but we still are not available. We are sorry. Please stay tuned!';



//configuration

var showIfEZero = true ; // change to true if you want to have the full date displayed. Default is false

						 // example if true: 0 days 0 hours 0 minutes 20 seconds

						 // example if false: 20 seconds 

						 // NOTE: this only affects the second countdown. The big days counter will always be shown!















//DO NOT CHANGE ANYTHING FROM NOW ON, IF YOU DON'T KNOW WHAT YOU ARE DOING!

var countTo = new Date(year, month-1,day,hour,minute,second);



function countdown() {



fromNow=new Date();



if(fromNow<countTo)  {



  var daysLeft=0, hoursLeft=0, minutesLeft=0, secondsLeft=0;



  while(fromNow.getTime() + (24 * 60 * 60 * 1000) < countTo) {

	  daysLeft++;

	  fromNow.setTime(fromNow.getTime() + (24 * 60 * 60 * 1000));

  }

  daysLeftBig = numberToImage(daysLeft, 'big');

  daysLeft    = numberToImage(daysLeft, 'small');



  hoursLeft = Math.floor((countTo - fromNow) / (60 * 60 * 1000));

  fromNow.setTime(fromNow.getTime() + hoursLeft * 60 * 60 * 1000);

  hoursLeft    = numberToImage(hoursLeft, 'small');



  minutesLeft = Math.floor((countTo - fromNow) / (60 * 1000));

  fromNow.setTime(fromNow.getTime() + minutesLeft * 60 * 1000);

  minutesLeft    = numberToImage(minutesLeft, 'small');



  secondsLeft = Math.floor((countTo - fromNow) / 1000);

  secondsLeft    = numberToImage(secondsLeft, 'small');	



  var showDayBig     = true;

  var showDay     = true;

  var showHour 	  = true;

  var showMinute  = true;

  var showSecond  = true;	



  

  if(!showIfEZero) {

	 showDay    = (daysLeft    == 0) ? false : true;

	 showHour   = (hoursLeft   == 0) ? false : true;

	 showMinute = (minutesLeft == 0) ? false : true;

	 showSecond = (secondsLeft == 0) ? false : true;

  }



  (daysLeftBig != 1) ? daysLeftBig = daysLeftBig + strDaysBig : daysLeftBig = daysLeftBig + strDayBig;

  (daysLeft    != 1) ? daysLeft    = daysLeft    + strDays    : daysLeft    = daysLeft    + strDay;

  (hoursLeft   != 1) ? hoursLeft   = hoursLeft   + strHours   : hoursLeft   = hoursLeft   + strHour;

  (minutesLeft != 1) ? minutesLeft = minutesLeft + strMinutes : minutesLeft = minutesLeft + strMinute;

  (secondsLeft !=1 ) ? secondsLeft = secondsLeft + strSeconds : secondsLeft = secondsLeft + strSecond;

 

  //big countdown

  var showStrBig = '';

  var showStrBig = (showDayBig) ? showStrBig + daysLeftBig : showStrBig;

  

  //small countdown

  var showStr = '';

  var showStr = (showDay)    ? showStr + daysLeft    : showStr;

  var showStr = (showHour)   ? showStr + hoursLeft   : showStr;

  var showStr = (showMinute) ? showStr + minutesLeft : showStr;

  var showStr = (showSecond) ? showStr + secondsLeft : showStr;

	  

	  

  //display string in element with ID "countdown".

  document.getElementById('countdown').innerHTML = showStr;

  document.getElementById('countdownBig').innerHTML = showStrBig;

  

  



  setTimeout('countdown()',200);

}



// set Time is Up message

else document.getElementById('countdown').innerHTML = strTimesUp;

}



//this function changes the numbers into images

function numberToImage (number, type) {

	number = number.toString();

	string = '';

	for(i=0;i<number.length;i++) {

	  display = number.split('');

		if(type == 'big') {

			string = string + '<img src="images/numbers/'+type+'/'+display[i]+'.png" style="width: 81px; height: 107px;" />';

		}else {

			string = string + '<img src="images/numbers/'+type+'/'+display[i]+'.png" style="width: 13px; height: 27px;" />';

		}

		

	}

	return string;

}
