/*
20071002
Imagine Domestic Interiors

Questions:
djk@daimi.au.dk

Revisions:
20071005 - jsImagine_main.js
20071002 - jsImagine_main.js
*/

/*=============== GLOBAL VARIABLES ===============*/
var x = 10;
var y = 1;

/*=============== IMAGINE functions ===============*/
function initIndex(){
	//initData();
	//initLayout();
}

function initPage(){
	//initData();
	//initLayout();
}

function initData(){
	greetDate();
	startClock();
	mudInit();
}

function initLayout(){
	//alert("test: initLayout()");
}

function startClock(){
	x = x-y
	//document.frm.clock.value = x
	setTimeout("startClock()", 1000)
	if(x==0){
		//alert("timer... randomize()");
		//x=10;
	}
}

function fisherYates ( myArray ) {
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}

function greetDate(){
	d = new Date();
	dateText = "";
	dayValue = d.getDay();
	if (dayValue == 0)
		dateText += "Sunday";
	else if (dayValue == 1)
    	dateText += "Monday";
	else if (dayValue == 2)
    	dateText += "Tuesday";
	else if (dayValue == 3)
    	dateText += "Wednesday";
	else if (dayValue == 4)
    	dateText += "Thursday";
	else if (dayValue == 5)
    	dateText += "Friday";
	else if (dayValue == 6)
    	dateText += "Saturday";

	monthValue = d.getMonth();
	dateText += " "
	if (monthValue == 0)
    	dateText += "January";
	if (monthValue == 1)
    	dateText += "February";
	if (monthValue == 2)
    	dateText += "March";
	if (monthValue == 3)
    	dateText += "April";
	if (monthValue == 4)
    	dateText += "May";
	if (monthValue == 5)
    	dateText += "June";
	if (monthValue == 6)
    	dateText += "July";
	if (monthValue == 7)
   	dateText += "August";
	if (monthValue == 8)
    	dateText += "September";
	if (monthValue == 9)
    	dateText += "October";
	if (monthValue == 10)
    	dateText += "November";
	if (monthValue == 11)
    	dateText += "December";

	if (navigator.appName.indexOf('Microsoft') != -1)
		dateText += " " + d.getDate() + ", " + (0000 + d.getYear());
	else if (navigator.appName.indexOf('Netscape') != -1)
		dateText += " " + d.getDate() + ", " + (1900 + d.getYear());

	minuteValue = d.getMinutes();
	if (minuteValue < 10)
   	minuteValue = "0" + minuteValue

	hourValue = d.getHours();
	if (hourValue < 12){
   	greeting = "Good morning!";
    	timeText = " at " + hourValue + ":" + minuteValue + " AM. Welcome to our site.";
   }
	else if (hourValue == 12){
   	greeting = "Good afternoon!";
   	timeText = " at " + hourValue + ":" + minuteValue + " PM. Welcome to our site.";
   }
	else if (hourValue < 17){
    	greeting = "Good afternoon!";
    	timeText = " at " + (hourValue-12) + ":" + minuteValue + " PM. Welcome to our site.";
   }
	else{
    	greeting = "Good evening!";
    	timeText = " at " + (hourValue-12) + ":" + minuteValue + " PM. Welcome to our site.";
   }
	//document.open();
	//document.write(greeting + " It's " + dateText + timeText);
	//document.write(dateText);
	putData("DATA_date", dateText);
}

function putData(tagID, varValue){
	element = document.getElementById(tagID);
	element.innerHTML = varValue;	
}

function addToFavorites(){
	//window.external.AddFavorite(location.href, document.title);
	if (window.external){
   	if (arguments.length < 1)
			window.external.AddFavorite(location.href, document.title);
    	if (arguments.length == 1)
      	window.external.AddFavorite(location.href, arguments[0]);
    	if (arguments.length == 2)
      	window.external.AddFavorite(arguments[0], arguments[1]);
  	}
  	else
    	alert("Your browser does not support automated bookmarks.\nPlease add bookmark manually.");
}

function randomize_01(){
	alert("N O T\n\nA C T I V A T E D\n\n");
}
function randomize(){
	alert("I L L E G A L\n\nA C T I O N\n\n");
}

function handleLink(linkID){
	//alert("handleLink start");
	
	switch(linkID){
		case 1: //about
			document.getElementById('ifrText').src="./html/imagine_page_01.html";
			break;
		case 2: //workshop
			document.getElementById('ifrText').src="./html/imagine_page_02.html";
			break;
		case 3: //participation
			document.getElementById('ifrText').src="./html/imagine_page_03.html";
			break;
		case 4: //practicalities
			document.getElementById('ifrText').src="./html/imagine_page_04.html";
			break;
		case 5: //contact
			document.getElementById('ifrText').src="./html/imagine_page_05.html";
			break;
		case 6: //call
			document.getElementById('ifrText').src="./html/imagine_page_06.html";
			break;
		case 10: //imagine
			document.getElementById('ifrText').src="./html/imagine_page_00.html";
			break;
		default: 
			alert("ERROR: Unknown link");
	}
	
	//alert("handleLink end");	
}


/*=============== TEMP js ===============*/
/*
var timer = 30;
function countdown()
{
  if(timer > 0)
  {
    document.cdtime.countdown.value = timer;
    timer -= 1;
    setTimeout("countdown()",1000);
  }
  else
  {
    location.href="http://ken.webster.org/";
  }
}
countdown();
*/
