// Javascript Functions
// Written by Ben Smeeton
// 26/07/2007

// DISPLAY STATEMENTS FUNCTION
var randomnumber=Math.floor(Math.random()*15)
var statement=new Array(15)
var constant = "datefrom";

// EDITABLE STATEMENTS
statement[0]="A great flat from PSA. Excellent service and would highly recommend them to anyone."
statement[1]="Fantastic! The apartment had everything I needed & it was so convenient."
statement[2]="Absolute courtesy and professionalism all around."
statement[3]="Everything you could ever want is included in the apartment along with excellent friendly service. Would highly recommend to others."
statement[4]="Highly recommend! Look forward to our next trip over! A great value for the business traveler!"
statement[5]="Excellent level of service, it's not only the big things - laptop, DVD, broadband etc but the little things - the brolly, fresh milk, even a shoe shine!!"
statement[6]="PSA offers the best alternative to hotels for short and long term stays."
statement[7]="Thank you again for supplying this wonderful home away from home."
statement[8]="So much more comfortable than staying in a hotel, and much more convenient"
statement[9]="Wonderful experience - no more hotels for me!"
statement[10]="Thanks for the accommodation and help in settling us back into the UK, your assistance made a big difference!"
statement[11]="Can't thank you enough for being so flexible and helpful, fantastic service!"
statement[12]="Just to say thanks for dealing with the insurance people and helping make a difficult situation so much easier."
statement[13]="Not only is my boss chuffed at the savings we've made but the guys in the apartments are over the moon."
statement[14]="Really glad I found you guys, the thought of 5 months in a hotel made me think twice about taking the contract."

function display_statement(){document.write(statement[randomnumber])}


// IMAGE SLIDESHOW FUNCTION

// EDITABLE IMAGES
var image1=new Image()
image1.src="images/homepage_image.jpg"
var image2=new Image()
image2.src="images/homepage_image2.jpg"
var image3=new Image()
image3.src="images/homepage_image3.jpg"
var image4=new Image()
image4.src="images/homepage_image4.jpg"
var image5=new Image()
image5.src="images/homepage_image5.jpg"
var image6=new Image()
image6.src="images/homepage_image6.jpg"
var image7=new Image()
image7.src="images/homepage_image7.jpg"
var image8=new Image()
image8.src="images/homepage_image8.jpg"
var image9=new Image()
image9.src="images/homepage_image9.jpg"
var image10=new Image()
image10.src="images/homepage_image10.jpg"


// ADDING AN IMAGE
// var image4=new image()
// image4.src="MY IMAGE LOCATION.jpg"
// Then change "if (number<3)" on the line below to "if (number<4)"
// Or to however images there are now in total in the slideshow

// CHANGING THE SPEED OF THE SLIDESHOW
// Change the four figure number in the line:
// "setTimeout("image_slideshow()",6000)"
// To the number of required microseconds
// 6 Seconds = 6000, 10 seconds = 10000 etc

var number=1

function image_slideshow(){
if (!document.images)
return
document.images.homepage_image.src=eval("image"+number+".src")
if (number<10)
number++
else
number=1
setTimeout("image_slideshow()",4000)
}

// TIME & DATE FUNCTION
function showdate(){
var date = new Date()
var hours = date.getHours()
var minutes = date.getMinutes()

if (minutes < 10){
var minutes = "0" + minutes
}

if(hours > 11){
var timeending = "pm"
} else {
var timeending = "am"
}

if(date.getDate() == 1 || date.getDate() == 21 || date.getDate() == 31 ){
var ending = "st"
}

if(date.getDate() == 2 || date.getDate() == 22 ){
var ending = "nd"
}

if(date.getDate() == 3 || date.getDate() == 23 ){
var ending = "rd"
}

else {
var ending = "th"
}


var dayname=new Array(7)
dayname[0]="Sunday"
dayname[1]="Monday"
dayname[2]="Tuesday"
dayname[3]="Wednesday"
dayname[4]="Thursday"
dayname[5]="Friday"
dayname[6]="Saturday"

var monthname=new Array(12)
monthname[0]="January"
monthname[1]="February"
monthname[2]="March"
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"

document.write("It's " + hours + ":" + minutes + " " + timeending + " on " + dayname[date.getDay()] + " " + date.getDate() + ending + " " + monthname[date.getMonth()] +".")
}


// CREATED BY BENJAMIN SMEETON
// 12/01/2008
// COPYRIGHT MEDWAY DESIGN 2008


// DEFAULTS THE CALENDAR TO THE CURRENT MONTH
function setCurrentMonth(){
var ddd=new Date();
var currentMonth = ddd.getMonth();
document.getElementById('month').options[currentMonth].selected = true;
}


// CHANGES THE FIRST DAY OF THE WEEK
function change(){
	
// DETERMINE THE FIRST DAY OF THE MONTH
var month = document.getElementById('month').value
var year = document.getElementById('year').value
var d=new Date(year, month-1, 1);
var day=d.getDay();
if (day == 0){day = 7};

// DETERMINE THE LAST DAY OF THE MONTH
var dd=new Date(year, month, 0);
var lastday = dd.getDate();

// CLEANS UP PREVIOUS STATES
var j=0;

for (j=1;j<=42;j++)
{
document.getElementById(j).className = 'dateunlive';
document.getElementById(j).innerHTML = ' ';
}

// CHANGES START DAY
var i=0;
var start=day;
var end=start+lastday-1;
var difference=1-start;

for (i=start;i<=end;i++)
{
document.getElementById(i).className = 'datelive';
document.getElementById(i).innerHTML = i+difference;
}
}


// SENDS DATE TO TEXT BOX
function sendDay(a){

var day = document.getElementById(a).innerHTML;
var month = document.getElementById('month').value
var year = document.getElementById('year').value
	
if(document.getElementById(a).innerHTML == " " || document.getElementById(a).innerHTML == null || document.getElementById(a).innerHTML == 0 ){}
	
else{

var d_names = new Array("Sun", "Mon", "Tue","Wed", "Thu", "Fri", "Sat");
var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug","Sep","Oct", "Nov", "Dec");

var dddd=new Date(year, month-1, day);
var curr_day = dddd.getDay();
var curr_date = dddd.getDate();
var sup = "";

if (curr_date == 1 || curr_date == 21 || curr_date ==31)
	{
	sup = "st";
	}
else if (curr_date == 2 || curr_date == 22)
	{
   sup = "nd";
   	}
else if (curr_date == 3 || curr_date == 23)
   {
   sup = "rd";
   }
else
   {
   sup = "th";
   }

var curr_month = dddd.getMonth();
var curr_year = dddd.getFullYear();

document.getElementById(constant).value = (d_names[curr_day] + " " + curr_date + sup + " " + m_names[curr_month] + " " + curr_year);
	
// HIDE CALENDAR AFTER CLICK
document.getElementById('calendar').style.display='none';

}
}

// SHOW CALENDAR
function show(a){
	constant = a;
	document.getElementById('calendar').style.display='block';}