/*HM_Loader.js
* by Peter Belesis. v4.1.3 011108
* Copyright (c) 2001 Peter Belesis. All Rights Reserved.
*/

   HM_DOM = (document.getElementById) ? true : false;
   HM_NS4 = (document.layers) ? true : false;
    HM_IE = (document.all) ? true : false;
   HM_IE4 = HM_IE && !HM_DOM;
   HM_Mac = (navigator.appVersion.indexOf("Mac") != -1);
  HM_IE4M = HM_IE4 && HM_Mac;
 HM_Opera = (navigator.userAgent.indexOf("Opera")!=-1);
 HM_Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

HM_IsMenu = !HM_Opera && !HM_Konqueror && !HM_IE4M && (HM_DOM || HM_NS4 || HM_IE4);

HM_BrowserString = HM_NS4 ? "NS4" : HM_DOM ? "DOM" : "IE4";


if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;


HM_GL_MenuWidth          = 80;
HM_GL_FontFamily         = "Arial,sans-serif";
HM_GL_FontSize           = 8;
HM_GL_FontBold           = 1;
HM_GL_FontItalic         = false;
HM_GL_FontColor          = "#6666CC";
HM_GL_FontColorOver      = "#FFCC33";
HM_GL_BGColor            = "#CCCCFF";
HM_GL_BGColorOver        = "#9999FF";
HM_GL_ItemPadding        = 3;

HM_GL_BorderWidth        = 1;
HM_GL_BorderColor        = "#666699";
HM_GL_BorderStyle        = "solid";
HM_GL_SeparatorSize      = 1;
HM_GL_SeparatorColor     = "#666699";

HM_GL_ImageSrc = "HM_More_black_right.gif";
HM_GL_ImageSrcLeft = "HM_More_black_left.gif";

HM_GL_ImageSrcOver = "HM_More_white_right.gif";
HM_GL_ImageSrcLeftOver = "HM_More_white_left.gif";

HM_GL_ImageSize          = 5;
HM_GL_ImageHorizSpace    = 5;
HM_GL_ImageVertSpace     = 5;

HM_GL_KeepHilite         = false;
HM_GL_ClickStart         = false;
HM_GL_ClickKill          = 0;
HM_GL_ChildOverlap       = 40;
HM_GL_ChildOffset        = 10;
HM_GL_ChildPerCentOver   = null;
HM_GL_TopSecondsVisible  = .9;
HM_GL_ChildSecondsVisible = .3;
HM_GL_StatusDisplayBuild = 1;
HM_GL_StatusDisplayLink  = 1;
HM_GL_UponDisplay        = null;
HM_GL_UponHide           = null;

HM_GL_RightToLeft      = false;
HM_GL_CreateTopOnly      = HM_NS4 ? true : false;
HM_GL_ShowLinkCursor     = true;

// the following function is included to illustrate the improved JS expression handling of
// the left_position and top_position parameters introduced in 4.0.9
// and modified in 4.1.3 to account for IE6 standards-compliance mode
// you may delete if you have no use for it

function HM_f_CenterMenu(topmenuid) {
	var MinimumPixelLeft = 0;
	var TheMenu = HM_DOM ? document.getElementById(topmenuid) : HM_IE4 ? document.all(topmenuid) : eval("window." + topmenuid);
	var TheMenuWidth = HM_DOM ? parseInt(TheMenu.style.width) : HM_IE4 ? TheMenu.style.pixelWidth : TheMenu.clip.width;
	var TheWindowWidth = HM_IE ? (HM_DOM ? HM_IEcanvas.clientWidth : document.body.clientWidth) : window.innerWidth;
	return Math.max(parseInt((TheWindowWidth-TheMenuWidth) / 2),MinimumPixelLeft);
}



//////////////////////////////////
// form validation methods library

// string is valid email
function isEmail(s) {
  var apos = s.indexOf('@');
  var dpos = s.indexOf('.');
  if (apos<=0 || dpos<=0) {
	return false; 
  }
  if (dpos+1>=s.length) {
	return false; 
  }
  return true;
}				

// string contains only whitespace
function isBlank(s) {
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c!=' ') && (c!='\n') && (c!='\t')) return false;
	}
	return true;
}		

// string is empty or only whitespace
function isEmpty(s) {
	if (!(s.value==null || s.value=="" || isBlank(s.value)))return false;
	return true;	
}	

// string is numeric
function isNumber(s) {
 if (isEmpty(s)) {
  return false;
 }	
 for (var i = 0; i < s.value.length; i++) {
   var ch = s.value.substring(i, i + 1);
   if((ch!=' ') && (ch!='\n') && (ch!='\t')) 
     if (ch < "0" || "9" < ch)return false;
 }
 return true;
}		

// string is numeric
function isFloat(s) {
 if (isEmpty(s)) {
  return false;
 }
 if (isNaN(parseFloat(s))) {
  return false;
 }
 for (var i = 0; i < s.value.length; i++) {
   var ch = s.value.substring(i, i + 1);
   if((ch!=' ') && (ch!='\n') && (ch!='\t') && (ch!='.')) 
     if (ch < "0" || "9" < ch)return false;
 }
 return true;
}


var i,y;
function loadImageSet(i) {
if (document.images)  {
 this.name = i;
 this.onImage = new Image();
 this.onImage.src = '../imgs/l-' + i + '-on.gif';
 this.offImage = new Image();
 this.offImage.src = '../imgs/l-' + i + '-off.gif';
 this.pickedImage = new Image();
 this.pickedImage.src = '../imgs/l-' + i + '-on.gif';
	}
}

var pick = -1;
var imageSets = new Array();

function doClick(i) {
i -=1;
if (document.images) {
 if (pick != -1) {
   self.document.images[imageSets[pick].name].src = imageSets[pick].offImage.src;
 }
 pick = i;
 self.document.images[imageSets[pick].name].src = imageSets[pick].pickedImage.src;
	}
}


function doMouseOver(i) {
 if (document.images) {
 if (i != pick) {
  self.document.images[imageSets[i].name].src = imageSets[i].onImage.src;
  }
 }
}

function doMouseOut(i) {
 if (document.images) {
 if (i != pick) {
  self.document.images[imageSets[i].name].src = imageSets[i].offImage.src;
  }
 }
}



// EMAIN NAVIGATION BAR
imageSets[0] = new loadImageSet('about');
imageSets[1] = new loadImageSet('members');
imageSets[2] = new loadImageSet('news');
imageSets[3] = new loadImageSet('events');
imageSets[4] = new loadImageSet('pub');
imageSets[5] = new loadImageSet('links');
imageSets[6] = new loadImageSet('bigt');
imageSets[7] = new loadImageSet('contact');
imageSets[9] = new loadImageSet('mfb');
imageSets[10] = new loadImageSet('bff');
imageSets[11] = new loadImageSet('benefits');
imageSets[12] = new loadImageSet('careers');

function formPublicEventVerify() {
	var msg;
	var empty_fields = "";
	var err = "";

  // you
  if (isEmpty(document.publiceventform.TITLE))
    empty_fields += "\n  - the title";
  if (isEmpty(document.publiceventform.EVENTTIME))
    empty_fields += "\n  - the time of the event";
  if (isEmpty(document.publiceventform.LOCATION))
    empty_fields += "\n  - the location";
  if (isEmpty(document.publiceventform.CONTACT))
    empty_fields += "\n  - the contact details";
  if (!isEmail(document.publiceventform.EMAIL.value))
    err += "\n  - your email";
  if (isEmpty(document.publiceventform.YOURNAME))
    empty_fields += "\n  - your name";
  if (isEmpty(document.publiceventform.YOURPHONE))
    empty_fields += "\n  - your email or phone";   

	if (!empty_fields && !err) return true;

	msg = "The form was not submitted because of the following error(s).\n";
	msg += "Please correct these error(s) and re-submit.\n";
	msg += "\n\n";

	if ( (empty_fields.length > 1) || (err.length > 1) )
	{
		msg += "The following required field(s) are incomplete or incorrectly formatted:" + empty_fields + err + "\n";
		msg += "\n";
	}

	alert(msg);

  return false;
}

function formNewsCastVerify() {
	var msg;
	var empty_fields = "";
	var err = "";

  // you
  if (isEmpty(document.newscastform.TITLE))
    empty_fields += "\n  - your title";
  if (isEmpty(document.newscastform.FORENAME))
    empty_fields += "\n  - your forename";
  if (isEmpty(document.newscastform.SURNAME))
    empty_fields += "\n  - your surname";
  if (isEmpty(document.newscastform.COMPANY))
    empty_fields += "\n  - your company";
  if (!isEmail(document.newscastform.EMAIL.value))
    err += "\n  - your email";

	if (!empty_fields && !err) return true;

	msg = "The form was not submitted because of the following error(s).\n";
	msg += "Please correct these error(s) and re-submit.\n";
	msg += "\n\n";

	if ( (empty_fields.length > 1) || (err.length > 1) )
	{
		msg += "The following required field(s) are incomplete or incorrectly formatted:" + empty_fields + err + "\n";
		msg += "\n";
	}

	alert(msg);

  return false;
}



function goEvent(loc,id,siteid) {
	self.document.eventform.ID.value = id;
	self.document.eventform.SITE_ID.value = siteid;
	self.document.eventform.action = loc;
    self.document.eventform.submit();	
}

function goPress(loc,id,siteid) {
	self.document.pressform.PRESS_ID.value = id;
	self.document.pressform.SITE_ID.value = siteid;
	self.document.pressform.action = loc;
    self.document.pressform.submit();	
}

function goMailshot(loc,id) {
	self.document.mailshotform.ID.value = id;
	self.document.mailshotform.action = loc;
    self.document.mailshotform.submit();	
}

function goMember(loc,id,siteid) {
	self.document.memberform.MEMBER_ID.value = id;
	self.document.memberform.SITE_ID.value = siteid;
	self.document.memberform.action = loc;
    self.document.memberform.submit();	
}

function goMenu(loc,id,site_id) {
	self.document.secondlevel.ID.value = id;
	self.document.secondlevel.SITE_ID.value = site_id;
	self.document.secondlevel.action = loc;
    goButton(loc);
}

var ms = navigator.appVersion.indexOf("MSIE");
var ie5 = (parseInt(navigator.appVersion.substring(ms+5)) >= 5) ? true : false;
var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;


document.write("<link REL='STYLESHEET' TYPE='text/css' HREF='../remotes/styles-pc.css'>");

function printwin() {
if (isMac) {
if(ie5) {
alert("This function does not work with your browser\nplease use your usual method for printing");
} else {
self.window.print();
}
} else {
self.window.print();
}
}


function OpWin(i,x,y) {
win = open(i, '', 'width='+x+',height='+y+',resizable=1,toolbar=0,scrollbars=0,location=0,menubar=0,status=0,titlebar=1,top=0,left=0');
}
