//map variables
var map;

//get element by ID shortcut
function $(theBtnId) {
	return document.getElementById(theBtnId);
}
//window load script
window.onload = function() {
	// training print form button
	if($('trainPrinting') && window.print) {
		$('formBtnPara').innerHTML = '<a href="trainform.php" title="Click to print this form" onclick="window.print();return false;">Print Application Form</a>';
	}
	// check for get elements by tag name
	if (!document.getElementsByTagName) return false;
	// ATTACH SCROLL TOP SCRIPTS
	theList = document.getElementsByTagName('p');
	listLength = theList.length
	for (var n = 0; n < listLength; n++) {
		if (theList.item(n).getAttribute("class") == 'topBtn') {
			theList.item(n).getElementsByTagName('a').item(0).onclick = function() {
				self.scroll(0,0);
				return false;
			}
		}
	}
	// product literature functions
/*	if ($('no_pdf')) {
		$('no_pdf').title = 'Coming Soon...';
		$('no_pdf').onclick = function() {
			alert("Coming Soon...");
			return false;
		}
	} */
	// search button states
	/*if ($('gobtn')) {
		var theGoBtn = $('gobtn');
		theGoBtn.onmouseover = function() {
			this.style.backgroundColor = '#ccc';
			this.style.color = '#900';
		}
		theGoBtn.onmouseout = function() {
			this.style.backgroundColor = '#f00';
			this.style.color = '#fff';
		}
		theGoBtn.onmousedown = function() {
			this.style.backgroundColor = '#fff';
			this.style.color = '#900';
		}
	}*/
	
	//map function - draws google map
	if($('map')) {
		map = new GMap2($("map"));
		map.clearOverlays();
		var point = new GLatLng(51.449182, 0.174345);
		map.addControl(new GSmallZoomControl());
		map.setCenter(point, 15);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		
        map.addControl(new GMapTypeControl());

		//var html = "<p style=\"width:91px;height:39px;padding:0;margin:0;\"><img src=\"g\/maplogo.gif\" alt=\"Triton\" width=\"91\" height=\"39\" \/><\/p>";
		//marker.openInfoWindowHtml(html);
	
		//map.addControl(new GOverviewMapControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT));
	}
	
	
	
	//temp title disable function
	if ($('bodyContent').getElementsByTagName('a')) {
		theBodyLinks = $('bodyContent').getElementsByTagName('a');
		for(var i=0; i<theBodyLinks.length; i++) {
			theBodyLinks[i].title = '';
		}
	}
	//Open windows script
	if ($('nbsTable')) {
		var winLinksArr = $('nbsTable').getElementsByTagName('a');
		for (var n = 0; n < winLinksArr.length; n++) {
			winLinksArr[n].onclick = function() {
				var tabWindow = window.open(this.getAttribute('href'), 'myWin', 'width=700,height=500,scrollbars=1,resizable=1');
				tabWindow.focus();
				tabWindow.opener.onfocus = function() {
					tabWindow.close();
				}
				return false;
			}
		}
	}
	//Open windows from product pages script
	if (document.getElementsByTagName('a')) {
		var winOtherLinksArr = document.getElementsByTagName('a');
		for (var n = 0; n < winOtherLinksArr.length; n++) {
			if (winOtherLinksArr[n].getAttribute('class') == 'nbsanchor') {
				winOtherLinksArr[n].onclick = function() {
					var tabWindow = window.open(this.getAttribute('href'), 'myWin', 'width=700,height=500,scrollbars=1,resizable=1');
					tabWindow.focus();
					tabWindow.opener.onfocus = function() {
						tabWindow.close();
					}
					return false;
				}
			}
		}
	}
	//----
	for (var n = 1; n < 10; n++) {
		if (!$('pdf_'+n)) return false; //if no pdf_n id abort following code
		$('pdf_'+n).onmouseover = function() {
			//extract pdf name from link href
			var urlArray = this.href.split('pdf/');
			urlArray = urlArray[1].split('.');
			//use pdf name for jpg url
			var imgURL = urlArray[0];
			$('img_1').innerHTML = '<img src="g/' + imgURL + '.gif" alt="" width="167" />';
		}
		$('pdf_'+n).onmouseout = function() {
			$('img_1').innerHTML = '<img src="g/coprofile_005.jpg" alt="" width="167" height="124" class="botrule" />';
		}
	}
}

