//////*count down timer*//////

var clientTime = new Date(); //get current time according to client's browser
var offset = clientTime.getTimezoneOffset(); //get the number of minutes that the client's time differs from UTC
offset = offset - 300; //calibrate offset to be relative to EST (5 hours less than UTC)
var deadline = new Date(2010,1,19,23,59,59);//set the deadline date to February 17 2010 at 11:59:59 p.m.
finish = deadline.getTime(); //get the number milliseconds since JAN 1 1970 to the deadline according to the client's browser
finish =  finish - (offset*60000); // take that number and subtract the offset (converted to milliseconds)

function countDown(){
var now = new Date(); //get current time according to client's browser
//alert("You are "+(offset/60)+" hours different than EST."); //see, now you can divide offset by 60 and get the number of hours off of EST
var start = now.getTime(); //get the number of milliseconds since JAN 1 1970 to the current time according to the client's browser
var timeLeft = finish - start; //calculate the number of milliseconds left between the current time and the deadline
return timeLeft; //send out the number of milliseconds remaining
}

function displayCountDown(){
var t = countDown(); //gets number of milliseconds remaining from the countDown function
if(t>0){ //(checks that there is still time left)
var days = Math.floor(t/86400000); //divides t by 86,400,000 (the number of milliseconds in a day) to get the number of days, and rounds it down to integer
document.getElementById("days").innerHTML = days;
var hours = Math.floor(t/3600000); //divides t by 3,600,000 (the number of milliseconds in an hour) to get the total number of hours remaining, & rounds it down
realHours = hours - days*24; //subtracts the hours already accounted for in the days. This pattern is repeated to get the minutes and seconds.
document.getElementById("hours").innerHTML = realHours;
var minutes = Math.floor(t/60000);
realMinutes = minutes - hours*60;
document.getElementById("minutes").innerHTML = realMinutes;
var seconds = Math.floor(t/1000);
realSeconds = seconds - minutes*60;
realSeconds < 10 ? realSeconds = "0"+realSeconds : realSeconds = realSeconds;
document.getElementById("seconds").innerHTML = realSeconds;
a=setTimeout(displayCountDown,100); //call this function every 10th of a second
	}else{ //(if there is no time left, set all values to zero
	document.getElementById("days").innerHTML = 0;
	document.getElementById("hours").innerHTML = 0;
	document.getElementById("minutes").innerHTML = 0;
	document.getElementById("seconds").innerHTML = "00";
	}
}


//////*other functions*//////

var result = false;

function sniffIE(){
var browser = navigator.appName;
var re = /Internet Explorer/gi;
result = re.test(browser);
//alert (result);
//alert (browser);
}


function setDisplay(ID,value){
if (result == true && ID == 'blackOut'){ID = 'blackOutIE';} //IE handles the blackOut div differently, so I made a special one, just for it!
value == 1 ? value = "block" : value = "none";
document.getElementById(ID).style.display = value;
}

function returnQueryString(){
var query = location.search;
return query;
}

function setSpecialPage(){
var query = returnQueryString();
switch (query){
	case "?soldout":
		setDisplay('soldOutDiv',1);
		setDisplay('blackOut',1);
		break;
	case "?help":
		setDisplay('helpDiv',1);
		setDisplay('blackOut',1);
		break;
	}
}

function notify(){
alert("Thank you to all who helped make this mission a success! If you are interested in scheduling some design or print work, please contact me any time. -Adam");
}