// JavaScript Document
	

window.onload = function(e) {
  onLoadInit();
}
	
	
// --------------------------------------------------------
// set up events
// --------------------------------------------------------

function onLoadInit() {
if( !document.links )
    {
    document.links = document.getElementsByTagName("a");
    }
    for (var ti=0;ti<document.links.length;ti++) 
	{
    var lnk = document.links[ti];
	if(window.addEventListener)
	{
		lnk.addEventListener("focus", removeDottedLine, false);
	}
	else if (window.attachEvent)
	{
		lnk.attachEvent("onfocus", removeDottedLine);
	}
	else
	{
		return null;
	}
		
	}	

// START BANNER IMAGE SWAP	
	
    if(document.getElementById("hpIntroBox")) {changeimg();}
	
// set up google maps
	
	if(document.getElementById("map")) {gmapLoad();}
	
}

// --------------------------------------------------------

// --------------------------------------------------------
// stops dotted lines appearing around clicked links in certain browsers (firefox, camino etc)
// --------------------------------------------------------

function removeDottedLine(e) {
	var target;
	if (window.event && window.event.srcElement)
	target = window.event.srcElement;
	else if (e && e.target)
	target = e.target;
	if(target){
	if(target.blur)target.blur();
	}
	else
	return null;
	}
		
// --------------------------------------------------------
// IMAGE SWAP
// --------------------------------------------------------

var startcount=1;
var pass=1;
function changeimg()
{
var imgdelay=10000;
window.setTimeout( "changeimg()", imgdelay);
var newimg="url(img/intro_img/"+startcount+".jpg)";
if (pass>1){document.getElementById("hpIntroBox").style.backgroundImage=newimg;}
pass=2;
startcount++;
if (startcount>6) startcount=1;
}

// --------------------------------------------------------
// GOOGLE MAPS STUFF
// --------------------------------------------------------


//<![CDATA[
function gmapLoad() {
if (GBrowserIsCompatible()) {
var map = new GMap(document.getElementById('map')); 
map.id='themap';
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(50.856107, 0.579218), 16,  G_NORMAL_MAP); 

// Create marker icon

var icon = new GIcon();
icon.image = "http://www.uch.ac.uk/img/gmap_icon.gif";
icon.shadow = "http://uch.wave.coop/img/mapiconshadow.png";
icon.iconSize = new GSize(37, 26);
icon.shadowSize = new GSize(60, 26);
icon.iconAnchor = new GPoint(17, 25);
icon.infoWindowAnchor = new GPoint(37, 0);

// markers here

var point_a = new GPoint(0.579218, 50.856107);
var marker_a = new GMarker(point_a,icon);
map.addOverlay(marker_a, 1);
var html_a= "<p><b>University Centre Hastings<br>Havelock Road</b><br>Hastings<br>East Sussex TN34 1DQ</p>";
GEvent.addListener(marker_a, 'click', function() {marker_a.openInfoWindowHtml(html_a);});


}}
//]]>
