var aBtn=new Array();
var aBtnOv=new Array();

addButton(0,105,22,"home");
addButton(1,105,22,"magazine");
addButton(2,104,22,"chapels");
addButton(3,109,22,"weddings");
addButton(4,104,22,"receptions");
addButton(5,106,22,"hotels");
addButton(6,105,22,"shop");

function addButton(idx,w,h,stub) {
	aBtn[idx]=new Image(w,h); aBtn[idx].src="img/nav3/off/"+stub+".gif";
	aBtnOv[idx]=new Image(w,h); aBtnOv[idx].src="img/nav3/on/"+stub+".gif";
}
function mOv(idx) {
	var img=getImage("iNav"+idx);
	if (img) img.src=aBtnOv[idx].src;
}
function mOut(idx) {
	var img=getImage("iNav"+idx);
	if (img) img.src=aBtn[idx].src;
}
function subOv(idx) {
	var ele=getElement("sb"+idx);
	if (ele) ele.style.borderColor="#bcd5ec";
}
function subOut(idx) {
	var ele=getElement("sb"+idx);
	if (ele) ele.style.borderColor="#f9429e";
}

function PicSwitch(imgID,picPosID) {
	this.imgID=imgID;
	this.picPosID=picPosID;
	this.current=0;
	this.aPics=null;
	this.sURL=null;
	
	this.gallery=function(url) {
		this.sURL=url;
	}
	
	this.loadPic=function(fname,iw,ih) {
		if (this.aPics==null) this.aPics=new Array();
		var iPos=this.aPics.length;
		this.aPics[iPos]=new Image(iw,ih);
		this.aPics[iPos].src="content/"+fname;
	}
	this.nextPic=function() {
		this.current++;
		if (this.current>=this.aPics.length) this.current=0;
		this.switchPic(this.current);
	}
	this.prevPic=function() {
		this.current--;
		if (this.current<0) this.current=this.aPics.length-1;
		this.switchPic(this.current);
	}
	this.switchPic=function(idx) {
		if (document.images) {
			var img=document.images[this.imgID];
			if (img) img.src=this.aPics[idx].src;
			
			var txt=document.getElementById(this.picPosID);
			if (txt) txt.innerHTML="Image "+(this.current+1)+" of "+this.aPics.length;
		}
	}
	this.goGallery=function() {
		var gallery=window.open(this.sURL+"&img="+this.current,"gallery","width=700,height=590,toolbar=no,location=no,directories=no,margin=0,status=no,menubar=no,scrollbars=no,resizable=no");
		gallery.focus();
	}
}

function getImage(id) {
	if (document.images && document.images[id])
		return document.images[id];
	else
		return null;
}
function getElement(sName) {
	return document.getElementById(sName);
}
function pop(win,w,h) {
	var wclwin=window.open("",win,"toolbar=no,location=no,directories=no,margin=0,status=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h);
	wclwin.focus();
}
function isInteger(sName) {
	var sVal=getElement(sName).value;
	var re=/(^\d+$)/;
	return (re.test(sVal));
}
String.prototype.ltrim=new Function("return this.replace(/^\\s+/,'')");
String.prototype.rtrim=new Function("return this.replace(/\\s+$/,'')");
String.prototype.trim=new Function("return this.replace(/^\\s+|\\s+$/g,'')");
function makeElink(user,host) {
	var domain = ".co.uk";
	var atsign = "&#64;";
	var addr = user + atsign + host + domain;
	document.write("<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + addr + "<\/a>");
}

function doLoad() {
	if (typeof(GLoad)!='undefined') GLoad();
}
function doUnload() {
	if (typeof(GUnload)!='undefined') GUnload();
}