var houses = new Array(11);
houses[0] = "Camborne Road (Ref. NBSL001)";
houses[1] = "Hunters Way (Ref. NBSL002)";
houses[2] = "Kenmore Drive (Ref. NBSL003)";
houses[3] = "Locleaze Road (Ref. NBSL004)";
houses[4] = "Locleaze Road (Ref. NBSL005)";
houses[5] = "Monks Park Avenue (Ref. NBSL006)";
houses[6] = "Northville Road (Ref. NBSL007)";
houses[7] = "Northville Road (Ref. NBSL008)";
houses[8] = "Sandown Road (Ref. NBSL009)";
houses[9] = "Sandown Road (Ref. NBSL010)";
houses[10] = "Third Avenue (Ref. NBSL011)";

//StatCounter variables
var sc_project=1350176;
var sc_invisible=1;
var sc_partition=12;
var sc_security="f23fc679";

//this is used in the drop down list
var subPage = "";

//The site url used for building links
var siteURL = "http://www.northbristolstudentlets.co.uk";

//store type of browser;
var browserName = navigator.appName;

//function to build house drop-down
function buildDropDown()
{
 	if(houses.length == 0) return false;
 		var x;
 		var y = 0;
 
 		for(x in houses)
 			{
  			y++;
  			document.write("<option value='" + siteURL + "/house" + y + "/?id=" + y + "'>" + houses[x] + "</option>");
 			}
 		return true;
}

function gotoLink()
{
	if(document.getElementById("houses").selectedIndex > 0)
	{
		window.location = subPage + "house" + document.getElementById("houses").selectedIndex + "?id=" + document.getElementById("houses").selectedIndex;
	}
}

function addEmailLink()
{
	document.getElementById("contact").href = document.getElementById("contact").href + "&body=I%20am%20interested%20in%20the%20following%20houses%20(" + ref + ").%0A%0AMy%20contact%20details%20are%20as%20follows:%20--------";
}

//functions to add bullet points
function bullet(data)
{
	if(data.length == 0) return false;
	var x;
	
	for(x in data)
	{
		document.write("<li>" + data[x] + "</li>");
	}
	return true;
}

function bulletEstablishents(data)
{
	if(data.length == 0) return false;
	var x;
	
	for(x in data)
	{
		if(data[x].indexOf("@") == -1)
		{
			document.write("<li>" + data[x] + "</li>");
		}else
		{
			document.write("<li>" + data[x].substring(0, data[x].indexOf("@")) + "<img onClick='map.centerAndZoom(new GPoint(" + data[x].substring(data[x].indexOf("@") + 1, data[x].lastIndexOf(",")) + ", " + data[x].substring(data[x].lastIndexOf(",") + 1, data[x].length) + "), 2);' src='../locate.gif' width='16' height='16' alt='Display on map' class='locateIcon' border='0'></li>");
		}
	}
	return true;
}

//Google Map functions
function displayGoogleMapLink()
{
	document.write("<a href='http://www.google.co.uk/maps?ll=" + latLong + "&hl=en' class='mapLink'>View Larger Map</a>");
}

//slide show functions
var step;
step = 0;

function displaySlideShow()
{
	document.images.slideshow.src = slideImages[0] + ".jpg";
}

function slideIt(next)
{
	if(browserName=="Microsoft Internet Explorer") document.images.slideshow.filters.blendTrans.apply();

	if(next)
	{
		step++;
		if(step == slideImages.length) step = 0;
	}else
	{
		step--;
		if(step == -1) step = slideImages.length - 1;
	}

	document.images.slideshow.src = slideImages[step] + ".jpg";
	if(browserName=="Microsoft Internet Explorer") document.images.slideshow.filters.blendTrans.play();
}

function slideTo(slide)
{
	if(browserName=="Microsoft Internet Explorer") slideshow.filters.blendTrans.apply();
	document.images.slideshow.src = slideImages[slide] + ".jpg";
	if(browserName=="Microsoft Internet Explorer") slideshow.filters.blendTrans.play();
}

function preloadPicts()
{
	var x;
	for(x in slideImages)
	{
		document.write("<img src='" + slideImages[x] + ".jpg' class='hiddenPic'>");
	}
}

function displayThumbs()
{
	var x;
	for(x in slideImages)
	{
		if(x > 0) document.write("<img src='../blank.gif' width='1' height='1' alt='' border='0'>");
		document.write("<img align='middle' src='" + slideImages[x] + ".jpg' width='51' height='38' alt='' class='imgBorderClear' onMouseOver='this.className=\"imgBorderBlack\";' onMouseOut='this.className=\"imgBorderClear\";' onClick='slideTo(" + x + ");'>");
	}
}

function getCoordinates(event)
{
	if(event.keyCode == 113)
	{
		alert(map.getCenterLatLng());
	}
}