var startDate = new Date("2011","06","31","06");
var endDate = new Date("2011","08","01","06");
var theDate = new Date();
//var theDate = new Date("2011","06","31","06","01");
var today = theDate.getDate();
if (today == 31) {
	today = 1;
}

//alert(startDate < nzDate && nzDate < endDate);

var days = new Array();
days[0] = "Pray for Muslims in 2011";
days[1] = "Spiritual Realities - Part I";
days[2] = "Spiritual Realities - Part II";
days[3] = "Mecca's Working Class";
days[4] = "Saudi Arabian Tribes";
days[5] = "Seeking Freedom!";
days[6] = "Kolai People of Pakistan";
days[7] = "Muslims in New York City";
days[8] = "Al Jadida,Morocco";
days[9] = "Awan of Pakistan";
days[10] = "Balrampur";
days[11] = "Palestinian Territories";
days[12] = "Al-Masjid Al-Aqsa";
days[13] = "Hezbollah";
days[14] = "The Pakistan Floods";
days[15] = "Surat in Gujarat,India";
days[16] = "Libya";
days[17] = "Kangean People";
days[18] = "Kerinci of Indonesia";
days[19] = "Touba and the Mourides";
days[20] = "Malaysia";
days[21] = "Muslims in Moscow";
days[22] = "Tajikistan";
days[23] = "The Shuwa Arabs in Chad";
days[24] = "The Back to Jerusalem Movement";
days[25] = "Istanbul,Turkey";
days[26] = "The Night of Power";
days[27] = "The Changing Tide in Central Asia";
days[28] = "Turks in Berlin";
days[29] = "Qizilbash of Afghanistan";
days[30] = "The Tablighi Jamaat Movement";

var t;

$(document).ready(function () {

	if (startDate < theDate && theDate < endDate) {

		$("#theme_instructions").hide();

		$("#day_list").find("li").eq(today-1).css("background-color","#000");
		$("#theme").html("Day " + today + ": <b>" + days[today] + "</b>  <i>&rarr; Get today's prayer theme</i>");
		$("#theme").mouseover(function(){$(this).css("cursor","pointer");});
		$("#theme").click(function(){document.location = "get_theme.php?day="+today;});
		$("#theme").slideDown("fast");
		$(".number").mouseover(function(){ 
			if ($(this).text() != today) {
				$(this).css({"cursor":"pointer","background-color":"#000"});
			}
		});
		$(".number").click(function(){
			if ($(this).text() != today) {
				if ($("#theme").is(":visible")) { clearTimeout(t); $("#theme").hide(); }
				var day = $(this).text();
				if (day < today + 2) {
					$("#theme").html("PRAYER THEME DAY " + day + ": <b>" + days[day] + "</b> <i>&rarr; Get today's prayer theme</i>");
					$("#theme").click(function(){document.location = "get_theme.php?day=" + day;});
				} else {
					$("#theme").html("PRAYER THEME DAY " + day + ": <b>" + days[day] + "</b> &mdash; Get the Prayer Booklet");
					$("#theme").click(function(){document.location = "http://www.worldchristian.com/productdetails.php?product_id=35809";});
				}
				$("#theme").slideDown("fast",function(){
					t = setTimeout("themeHide()",3000);
				});
			}
		});
		$(".number").mouseout(function(){ 
			if ($(this).text() != today) {
				$(this).css({"background-color":""});
			}
		});
	} else {
		$("#theme_instructions").mouseover(function(){ 
			$(this).css({"cursor":"pointer","background-color":"#e0e0e0","border-left":"1px solid #333","border-right":"1px solid #333"}); 
			$("#theme_instructions_full").fadeIn("fast");
		});
		$("#theme_instructions").mouseout(function(){ 
			$(this).css({"background-color":"#fff","border-left":"1px solid #fff","border-right":"1px solid #fff"}); 
			$("#theme_instructions_full").fadeOut("fast"); 
		});
	
		$("#theme").mouseover(function(){$(this).css("cursor","pointer");});
		$("#theme").click(function(){document.location = "http://www.worldchristian.com/productdetails.php?product_id=35809";});
		$(".number").mouseover(function(){ $(this).css({"cursor":"pointer","background-color":"#000"});});
		$(".number").click(function(){
			if ($("#theme").is(":visible")) { clearTimeout(t); $("#theme").hide(); }
			var day = $(this).text();
			$("#theme").html("PRAYER THEME DAY " + day + ": <b>" + days[day] + "</b> &mdash; Get the Prayer Booklet");
			$("#theme").slideDown("fast",function(){
				t = setTimeout("themeHide()",3000);
			});
		});
		$(".number").mouseout(function(){ 
			$(this).css({"background-color":""});
		});
	}
});

function themeHide() {
	if (startDate < theDate && theDate < endDate) {
		$("#theme").slideUp("fast");
		$("#theme").html("Day " + today + ": <b>" + days[today] + "</b>  <i>&rarr; Get today's prayer theme</i> ");
		$("#theme").mouseover(function(){$(this).css("cursor","pointer");});
		$("#theme").click(function(){document.location = "get_theme.php";});
		$("#theme").slideDown("fast");
	} else {
		$("#theme").slideUp("fast");
	}
}

