//	DateAndTime 1.0
//	Created by Johan Eriksson
//	Copyright Outpostone.com
//	Email: johan@outpostone.com
//		
//	Description:	Functions are made in object-oriented style.
//	Genarating date and time, then returning values. Clock is updating 
//	to keep correct time.





////////////////////////////////Class DateAndTime ///////////////////////


function DateAndTime()	//Class Consructor
{
	this.todaysDate = todaysDate;
	this.stopTime = stopTime;
	this.startTime = startTime;
	this.initTime = initTime;
	
	this.timer = null;
	
}

//Date method returns a string with current date.
//In English(ENG) or Swedish(SE).
function todaysDate(lang) 
{
	var newDate = new Date();
	var weekday = new Array();
	var monthName = new Array();
	var theDate;
	
	if(lang == "ENG")
	{
		weekday[0] = "Sunday";
		weekday[1] = "Monday";
		weekday[2] = "Tuesday";
		weekday[3] = "Wednesday";
		weekday[4] = "Thursday";
		weekday[5] = "Friday";
		weekday[6] = "Satuday";
		
		monthName[0] = "January";
		monthName[1] = "February";
		monthName[2] = "Mars";
		monthName[3] = "April ";
		monthName[4] = "May";
		monthName[5] = "June";
		monthName[6] = "July";
		monthName[7] = "August";
		monthName[8] = "September";
		monthName[9] = "October";
		monthName[10] = "November";
		monthName[11] = "December";
		
	}	
	else
	{
		weekday[0] = "S&ouml;ndagen";
		weekday[1] = "M&aring;ndagen";
		weekday[2] = "Tisdagen";
		weekday[3] = "Onsdagen";
		weekday[4] = "Torsdagen";
		weekday[5] = "Fredagen";
		weekday[6] = "L&ouml;rdagen";
		
		monthName[0] = "Januari";
		monthName[1] = "Februari";
		monthName[2] = "Mars";
		monthName[3] = "April ";
		monthName[4] = "Maj";
		monthName[5] = "Juni";
		monthName[6] = "Juli";
		monthName[7] = "Augusti";
		monthName[8] = "September";
		monthName[9] = "Oktober";
		monthName[10] = "November";
		monthName[11] = "December";
	
	}
	//Constructing date
	theDate = weekday[newDate.getDay()] + " den ";
	theDate = theDate + newDate.getDate() + " ";
	theDate = theDate + monthName[newDate.getMonth()] + " ";
	theDate = theDate + newDate.getFullYear();
	
	return theDate;
}


function stopTime()//Stop Clock
{
	clearTimeout(this.timer);
}


function startTime()//Start time (looping until stoped)
{
	var time = new Date();
	var hours = time.getHours();
	var minutes = time.getMinutes();
	var clock = hours;
	
	if(minutes < 10)
	{
		clock = clock + ":0" + minutes;
	}
	else
	{
		clock = clock + ":" + minutes;
	}
	
	
	//return newDateAndTime.todaysDate("SE");
	//timeL.innerHTML = newDateAndTime.todaysDate("SE");
	//this.timer = setTimeout("newDateAndTime.startTime();",1000);
	
}


function initTime()//Starting dateAndTime 
{
	
	newDateAndTime.startTime();
	//dateL.innerHTML = newDateAndTime.todaysDate("SE");
	
}

newDateAndTime = new DateAndTime();//new DateAndTime object
