window.onload = function(){

	if (document.getElementById) {

////////external links to open in a new window
		var anchors = document.getElementsByTagName("a");
		for (var z=0; z<anchors.length; z++){
			var anchor = anchors[z];
			if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "nofollow" || anchor.getAttribute("rel") == "pdf")) anchor.target = "_blank";
		}

//// random team picture on the side
		if(document.getElementById('mtt')){
			var holder = document.getElementById('mtt').getElementsByTagName('span')[0];
			var the_team = new Array('Jane','Peter','Diane','Holly','Kerry','Tina');
			var rnd_no = Math.floor(the_team.length*Math.random());
			var lowerC = the_team[rnd_no].toLowerCase()
			holder.innerHTML = '<a href="instructors.php#'+ lowerC +'"><img src="img/instructors/side/'+ lowerC +'.png" alt="'+ the_team[rnd_no] +'" class="roll" /></a>';
		}

		if(document.getElementById('clientssay')){
			var testiD = document.getElementById('clientssay');
			var text = new Array("<blockquote><p>The ECG training provided our pharmacists with an opportunity to learn and practice the skill of injection technique, resuscitation and anaphylaxis in a comfortable and supportive environment [...]</p></blockquote><cite>Boots UK</cite>",
								"<blockquote><p>[...] I consider ECG's training to be of excellent quality, and it is highly scored by the course participants. [...]<br /> This contributes to the clinical governance of our service and the control of business risk. For these reasons I greatly value the relationship we have with ECG Training. And they are great colleagues to work with.</p></blockquote><cite>Dr Bill Holmes FRCP FRCGP DOccMed - Chief Exec., EVG</cite>",
								"<blockquote><p>I have found this company is one of the best providers of training that I have been involved with.</p></blockquote><cite>Clinical Training &amp; Development Manager, Buckinghamshire PCT</cite>",
								"<blockquote><p>Feedback from staff attending any of the training sessions has always been very positive. We have built a strong, mutually respectful working partnership over the years.</p></blockquote><cite>Clinical Effectiveness Manager, BUPA Roding Hospital</cite>",
								"<blockquote><p>ECG are professional in their approach and are clearly active in clinical practice today, which is evident in their trainers and their approach to training in this field</p></blockquote><cite>Learning Management Coordinator, Luton Teaching PCT</cite>"
								);
			var l = text.length;
			var rnd_no = Math.floor(l*Math.random());
			testiD.innerHTML = text[rnd_no]
		}

////////rollover effect on some images
		var images = document.getElementsByTagName("img");
		for (var y=0; y<images.length; y++){
			//alert(images[y].className)
			if(images[y].className == 'roll'){
				images[y].onmouseover = function(){
					if(this.src.match('.gif')){ this.src = this.src.replace(/.gif/, "_o.gif"); }
					else if(this.src.match('.jpg')){ this.src = this.src.replace(/.jpg/, "_o.jpg");}
					else if(this.src.match('.png')){ this.src = this.src.replace(/.png/, "_o.png");}
				}
				images[y].onmouseout = function(){ 
					if(this.src.match('.gif')){ this.src = this.src.replace(/_o.gif/, ".gif"); }
					else if(this.src.match('.jpg')){ this.src = this.src.replace(/_o.jpg/, ".jpg");}
					else if(this.src.match('.png')){ this.src = this.src.replace(/_o.png/, ".png");}
				}
			}
		}

// contact form form onfocus cleaning
	if(document.getElementById('contact')){
		var ffields = document.getElementById('contact').getElementsByTagName('input');
		var tafields = document.getElementById('contact').getElementsByTagName('textarea');
		for (f in ffields){
			ffields[f].onfocus = function () { if(this.value == this.defaultValue){ this.value=''; }};
			ffields[f].onblur = function () { if(this.value.replace(/\s+/g,"") == '' ){ this.value=this.defaultValue; }};
		}
		for (t in tafields){
			tafields[t].onfocus = function () { if(this.value == this.defaultValue){ this.value=''; }};
			tafields[t].onblur = function () { if(this.value.replace(/\s+/g,"") == '' ){ this.value=this.defaultValue; }};
		}
	}

	if(document.getElementById('googlemap')){
		if(GBrowserIsCompatible()){
			var map = new GMap2(document.getElementById('googlemap'));
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(52.07583,-0.84534), 13);
			map.panBy(new GSize(10,70));
			// Place a marker at the right coordinate
			var marker = new GMarker(new GLatLng(52.07583,-0.84534));	
			var maptext = "<div id=\"maptext\"><img src=\"/img/map.jpg\" alt=\"ECG Training\" /></div>";
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(maptext);
			});
			map.addOverlay(marker);
			marker.openInfoWindowHtml(maptext);
		}//end if GBrowserIsCompatible
	}
	window.onunload = function() { GUnload() }

	}//end if (document.getElementById)
}// end window.onload

sfHover = function() {
	var sfEls = document.getElementById("leftcol").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

