/* Author information for includes.js
----------------------------------------------- */
/* Script file by Keith W Bell
   Sunday, April 24, 2005
   www.campanile.uk.net
----------------------------------------------- */

var isDOM = (document.getElementById && document.createTextNode) ? true:false;

isIE = (document.all) ? true:false;


function abbrIE() {
	var oldTag, newTag, regX;
	if (isIE) {
		oldTag = document.body.innerHTML;
		regX = /<ABBR([^>]*)>([^<]*)<\/ABBR>/g;
		newTag = oldTag.replace(regX, '<abbr $1><span class=\"abbr\" $1>$2</span></abbr>');
		document.body.innerHTML = newTag;
	}
}


function statusTitle() {
   if (document.getElementsByTagName) {
      window.defaultStatus = document.title;
   }
   else {
      window.defaultStatus = 'G8 Marketing';
   }
}


function clearInput(box) {
	if (document.getElementById(box).value !== '') {
		document.getElementById(box).value = '';
	}
}


function makeEmail() {
	if (isDOM) {
		var domain, spaces, spans, defaultText, classes, address, linkText, x, i, a;
		domain = 'g8marketing.co.uk';
		x = 'email';
		spaces = /\s+/;
		spans = document.getElementsByTagName('span');
		for (i=0; i<spans.length; i++) {
			if(spans[i].className.match(x)) {
				defaultText = spans[i].firstChild;
				classes = spans[i].className.split(spaces);
				if (classes[1]) {
					address = classes[1] + '@' + domain;
					a = document.createElement('a');
					a.href = 'mailto:' + address;
					linkText = document.createTextNode(address);
					a.appendChild(linkText);
					spans[i].replaceChild(a, defaultText);
				}
			}
		}
	}
}


function popWin(url, type, wide, high) {
	var newwin;
	var features;

	if (type=='fixed') {
		features='scrollbars,screenX=0,screenY=0,left=0,top=0,width='+wide+',height='+high;
	}
	if (type=='console') {
		features='resizable,scrollbars,screenX=0,screenY=0,left=0,top=0,width='+wide+',height='+high;
	}
	if (type=='full') {
		features='toolbar,menubar,location,status,resizable,scrollbars,screenX=0,screenY=0,left=0,top=0,width='+wide+',height='+high;
	}
	newwin = window.open(url, 'popup', features);
	setTimeout('newwin.focus();',250);
}


function closePop() {
   if (window.opener) {
      document.write('<p class="centre"><a href="#" onclick="self.close();">close this window</a><br />to return to the main G8 Marketing website</p>');
   }
}


window.onload = function(e) {
	abbrIE();
	statusTitle();
	makeEmail();
};


