function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf('#')!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var bType;
var bleft;
var bleft2;
var bleft3;
var bleft4;
var bleft5;
var btop;
var blnMenuOn = false;
function browserType ()
{
if (navigator.userAgent.indexOf('Opera')!=-1 && document.getElementById)
return 'OP'; // Opera
if (navigator.userAgent.indexOf('Safari')!=-1)
return 'SA'; // Safari
if (document.all)
return 'IE'; // Internet Explorer
if (document.layers)
return 'NN'; //Netscape 4
if (!document.all && document.getElementById)
return 'MO'; // Mozilla (Netscape 6+, etc)
}
function setLayerVisibility (pstrID, pstrVisibility)
{
if (bType == "IE")
eval("document.all." + pstrID + ".style.visibility='" + pstrVisibility + "'"); 
if (bType == "NN")
eval("document." + pstrID + ".visibility='" + pstrVisibility + "'"); 
if (bType == "MO" || bType == "OP" || bType == "SA") 
eval("document.getElementById('" + pstrID + "').style.visibility='" + pstrVisibility + "'"); 
}
function setPosition (pstrID, pstrPOS)
{
if (bType == "IE")
eval("document.all." + pstrID + ".style.left='" + pstrPOS + "'"); 
if (bType == "NN")
eval("document." + pstrID + ".left='" + pstrPOS + "'"); 
if (bType == "MO" || bType == "OP" || bType == "SA") 
eval("document.getElementById('" + pstrID + "').style.left='" + pstrPOS + "'"); 
}
var a;
a = '';
var b;
b = '';
var c;
c = '';
function loadcontent()
{
document.getElementById("newcontent").innerHTML = document.getElementById("content").innerHTML
document.getElementById("content").innerHTML = ""
}
function doMenuClose ()
{
if(a.length > 1)
{
setLayerVisibility(a, 'hidden');
}
if(b.length > 1)
{
setLayerVisibility(b, 'hidden');
}
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
}
function doMenuCloseB ()
{
if(b.length > 1)
{
setLayerVisibility(b, 'hidden');
}
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
}
function doMenuCloseC ()
{
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
}
function doMenuOn (pstrID, pstrSubID)
{
if(a.length > 1)
{
setLayerVisibility(a, 'hidden');
}
if(b.length > 1)
{
setLayerVisibility(b, 'hidden');
}
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
a = pstrSubID;
setPosition(a, bleft3);
setLayerVisibility(pstrSubID, 'visible');
}
function doMenuOnB (pstrID, pstrSubID)
{
if(b.length > 1)
{
setLayerVisibility(b, 'hidden');
}
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
b = pstrSubID;
setPosition(b, bleft4);
setLayerVisibility(pstrSubID, 'visible');
}
function doMenuOnC (pstrID, pstrSubID)
{
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
c = pstrSubID;
setPosition(c, bleft5);
setLayerVisibility(pstrSubID, 'visible');
}
function offLayer (pstrLayer)
{
if (pstrLayer == 'Layer1')
{
if(a.length > 1)
{
setLayerVisibility(a, 'hidden');
}
if(b.length > 1)
{
setLayerVisibility(b, 'hidden');
}
if(c.length > 1)
{
setLayerVisibility(c, 'hidden');
}
}
}
function windowchange()
{
if (bType == 'IE')
{
bleft = document.body.clientWidth;
if (bleft <= 782)
{
bleft = 782;
}
bleft = bleft / 2 - 180;
bleft2 = bleft - 201;
setLayerVisibility('date', 'hidden');
setLayerVisibility('header', 'hidden');
setLayerVisibility('breadcrumbs', 'hidden');
eval('document.all.date.style.top=12');
eval('document.all.header.style.top=37');
eval('document.all.breadcrumbs.style.top=171');
eval('document.all.date.style.left=' + bleft2);
eval('document.all.header.style.left=' + bleft2);
eval('document.all.breadcrumbs.style.left=' + bleft2);
setLayerVisibility('date', 'visible');
setLayerVisibility('header', 'visible');
setLayerVisibility('breadcrumbs', 'visible');
}

if (bType == "NN")
	{
	bleft = window.innerWidth;
	if (bleft <= 782)
		{
		bleft = 782;
		}
	bleft = bleft / 2 - 224;
	bleft2 = bleft - 148;
	bleft3 = bleft2 + 184;
	bleft4 = bleft3 + 184;
	bleft5 = bleft4 + 184;

setLayerVisibility('date', 'hidden');
setLayerVisibility('header', 'hidden');
setLayerVisibility('breadcrumbs', 'hidden');
eval('document.date.left=' + bleft2);
eval('document.header.left=' + bleft2);
eval('document.breadcrumbs.left=' + bleft2);
setLayerVisibility('date', 'visible');
setLayerVisibility('header', 'visible');
setLayerVisibility('breadcrumbs', 'visible');
}
if (bType == "MO")
	{
	bleft = window.innerWidth;
	if (bleft <= 798)
		{
			bleft = 798;
		}
	bleft = bleft / 2 - 233;
	bleft2 = bleft - 158;
	bleft3 = bleft2 + 184;
	bleft4 = bleft3 + 184;
	bleft5 = bleft4 + 184;
setLayerVisibility('date', 'hidden');
setLayerVisibility('header', 'hidden');
setLayerVisibility('breadcrumbs', 'hidden');
eval("document.getElementById('date').style.left=" + bleft2);
eval("document.getElementById('header').style.left=" + bleft2);
eval("document.getElementById('breadcrumbs').style.left=" + bleft2);
setLayerVisibility('date', 'visible');
setLayerVisibility('header', 'visible');
setLayerVisibility('breadcrumbs', 'visible');
	}
if (bType == "SA")
	{
	bleft = window.innerWidth;
	if (bleft <= 798)
		{
			bleft = 798;
		}
	bleft = bleft / 2 - 223;
	bleft2 = bleft - 158;
	bleft3 = bleft2 + 184;
	bleft4 = bleft3 + 184;
	bleft5 = bleft4 + 184;
setLayerVisibility('date', 'hidden');
setLayerVisibility('header', 'hidden');
setLayerVisibility('breadcrumbs', 'hidden');
eval("document.getElementById('date').style.left=" + bleft2);
eval("document.getElementById('header').style.left=" + bleft2);
eval("document.getElementById('breadcrumbs').style.left=" + bleft2);
setLayerVisibility('date', 'visible');
setLayerVisibility('header', 'visible');
setLayerVisibility('breadcrumbs', 'visible');
	}
if (bType == "OP")
	{
	bleft = window.innerWidth;
	if (bleft <= 782)
		{
		bleft = 782;
		}
	bleft = bleft / 2 - 224;
	bleft2 = bleft - 148;
	bleft3 = bleft2 + 184;
	bleft4 = bleft3 + 184;
	bleft5 = bleft4 + 184;
setLayerVisibility('date', 'hidden');
setLayerVisibility('header', 'hidden');
setLayerVisibility('breadcrumbs', 'hidden');
eval("document.getElementById('date').style.left=" + bleft2);
eval("document.getElementById('header').style.left=" + bleft2);
eval("document.getElementById('breadcrumbs').style.left=" + bleft2);
setLayerVisibility('date', 'visible');
setLayerVisibility('header', 'visible');
setLayerVisibility('breadcrumbs', 'visible');
	}
}

function PostcodeCheck(Postcode, Match) {
  var re = new RegExp(Match);
  if (Postcode.match(re)) {
    return true;
  } else {
    return false;
  }
}

function checkcode() {
 var a = document.getElementById("form1");
 a.action = ""
 a.submit();
}
function checkagree() {
	var tt = document.getElementById("checker");
	if (tt.checked) {
		var tt = document.getElementById("continue");
		tt.disabled = false;
	} else {var tt = document.getElementById("continue");tt.disabled = true;}
}

function GetFranchise() {
var postcode = document.getElementById("Postcode").value

 if (postcode == "P21 8IP") {
  document.getElementById("Franchise").innerHTML = "<p><b>You didn't think it was going to be that simple.... did you?<br><br>Your next clue is SUB DOMAIN</b></p>"
 } else 


	var tstring = "";
	postcode = '' + postcode;
	splitstring = postcode.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	postcode = tstring;





 postcode = postcode.substr(0, 3);
 postcode = postcode.toUpperCase();

 if ( PostcodeCheck(postcode, "AB[0-9]") ||  PostcodeCheck(postcode, "DD[0-9]") || PostcodeCheck(postcode, "DG[0-9]") || PostcodeCheck(postcode, "EH[0-9]") || PostcodeCheck(postcode, "FK[0-9]") || PostcodeCheck(postcode, "G[0-9][0-9]") || PostcodeCheck(postcode, "IV[0-9]") || PostcodeCheck(postcode, "KA[0-9]") || PostcodeCheck(postcode, "KW[0-9]")|| PostcodeCheck(postcode, "KY[0-9]") || PostcodeCheck(postcode, "ML[0-9]") || PostcodeCheck(postcode, "PA[0-9]") || PostcodeCheck(postcode, "PH[0-9]") || PostcodeCheck(postcode, "TD[0-9]") || PostcodeCheck(postcode, "ZE[0-9]")) {


  document.getElementById("Franchise").innerHTML = "<p><b>Tom Nolan<br>NCS Office Systems (Scotland) Ltd</b><br>Glasgow<br>65 Rodney Street<br>Glasgow<br>G4 9SQ<br><br>Tel: 0141 353 0000<br>Fax: 0141 353 0011<br>Service: 0870 050 2233<br><br>Edinburgh<br>2nd Floor<br>44 Melville Street<br>Edinburgh<br>EH3 7HF<br><br><p>Tel: 0131 225 5505<br>Fax: 0131 225 5255</p>"
 } else 

if (PostcodeCheck(postcode, "BB[0-9]") || PostcodeCheck(postcode, "BD[0-9]") || PostcodeCheck(postcode, "BL[0-9]") || PostcodeCheck(postcode, "FY[0-9]") || PostcodeCheck(postcode, "HD[0-9]") || PostcodeCheck(postcode, "HX[0-9]") || PostcodeCheck(postcode, "L[0-9][0-9]") || PostcodeCheck(postcode, "LA[0-9]") || PostcodeCheck(postcode, "OL[0-9]") || PostcodeCheck(postcode, "PR[0-9]") || PostcodeCheck(postcode, "WA[0-9]") || PostcodeCheck(postcode, "WN[0-9]") || PostcodeCheck(postcode, "CA[0-9]") || PostcodeCheck(postcode, "DH[0-9]") || PostcodeCheck(postcode, "DL[0-9]") || PostcodeCheck(postcode, "DN[0-9]") || PostcodeCheck(postcode, "HG[0-9]") || PostcodeCheck(postcode, "HU[0-9]") || PostcodeCheck(postcode, "LN[0-9]") || PostcodeCheck(postcode, "LS[0-9]") || PostcodeCheck(postcode, "NE[0-9]") || PostcodeCheck(postcode, "S[0-9][0-9]") || PostcodeCheck(postcode, "SR[0-9]") || PostcodeCheck(postcode, "TS[0-9]") || PostcodeCheck(postcode, "WF[0-9]") || PostcodeCheck(postcode, "YO[0-9]") || PostcodeCheck(postcode, "CH[0-9]") || PostcodeCheck(postcode, "CW[0-9]") || PostcodeCheck(postcode, "DE[0-9]") || PostcodeCheck(postcode, "LL[0-9]") || PostcodeCheck(postcode, "M[0-9][0-9]") || PostcodeCheck(postcode, "SK[0-9]") || PostcodeCheck(postcode, "ST[0-9]") || PostcodeCheck(postcode, "SY[0-9]")) {


  document.getElementById("Franchise").innerHTML = "<p>George W. Bevan<br><br>FP Mailing (North West) Ltd<br>Southerly 7<br>Waterfold Business Park<br>Bury<br>Manchester<br>BL9 7BR<br><br>Tel: 0161 797 7778<br>  Fax: 0161 797 7797<br>Mobile: 07740 617915<br>Email: enquiries@fpmailingnorthwest.co.uk</p>"
 } else





if (PostcodeCheck(postcode, "CV[0-9]") || PostcodeCheck(postcode, "LE[0-9]") || PostcodeCheck(postcode, "NG[0-9]") || PostcodeCheck(postcode, "B1[0-9]") || PostcodeCheck(postcode, "B2[0-9]") || PostcodeCheck(postcode, "B3[0-9]") || PostcodeCheck(postcode, "B4[0-9]") || PostcodeCheck(postcode, "B5[0-9]") || PostcodeCheck(postcode, "B6[0-9]") || PostcodeCheck(postcode, "B7[0-9]") || PostcodeCheck(postcode, "B8[0-9]") || PostcodeCheck(postcode, "B9[0-9]") || PostcodeCheck(postcode, "B0[0-9]") || PostcodeCheck(postcode, "DY[0-9]") || PostcodeCheck(postcode, "TF[0-9]") || PostcodeCheck(postcode, "WR[0-9]") || PostcodeCheck(postcode, "WS[0-9]") || PostcodeCheck(postcode, "WV[0-9]")) {
  document.getElementById("Franchise").innerHTML = "<p><b>Steve Suckling<br><br>FP Mailing (Central) Ltd</b><br>Central House<br>89 High Street<br>Bassingbourn<br>Hertforshire<br>SG8 5OF<br><br>Tel: 0871 230 4488<br>Fax: 0871 230 4489<br>Email: admin@fpcentral.co.uk</p>"
 } else 





if (PostcodeCheck(postcode, "AL[0-9]") || PostcodeCheck(postcode, "HA[0-9]") || PostcodeCheck(postcode, "HP[0-9]") || PostcodeCheck(postcode, "LU[0-9]") || PostcodeCheck(postcode, "OX[0-9]") || PostcodeCheck(postcode, "SL[0-9]") || PostcodeCheck(postcode, "UB[0-9]") || PostcodeCheck(postcode, "WD[0-9]") || PostcodeCheck(postcode, "GU[0-9]") || PostcodeCheck(postcode, "KT[0-9]") || PostcodeCheck(postcode, "NW[0-9]") || PostcodeCheck(postcode, "PO[0-9]") || PostcodeCheck(postcode, "TW[0-9]") || PostcodeCheck(postcode, "W[0-9][0-9]")) {
  document.getElementById("Franchise").innerHTML = "<p><b>Bob Good<br><br>FP Mailing (Windsor) Ltd</b><br>40 Alexandra Road<br>Windsor<br>Berkshire<br>SL4 1HU<br><br>Tel: 01753 621868<br>Fax: 01753 862566<br>Mobile: 07970 846868<br>Email: sales@fpwindsor.co.uk</p>"
 } else 






if (PostcodeCheck(postcode, "BA[0-9]") ||  PostcodeCheck(postcode, "BS[0-9]") ||  PostcodeCheck(postcode, "CF[0-9]") ||  PostcodeCheck(postcode, "EX[0-9]") ||  PostcodeCheck(postcode, "GL[0-9]") ||  PostcodeCheck(postcode, "HR[0-9]") ||  PostcodeCheck(postcode, "LD[0-9]") ||  PostcodeCheck(postcode, "NP[0-9]") ||  PostcodeCheck(postcode, "PL[0-9]") ||  PostcodeCheck(postcode, "SA[0-9]") ||  PostcodeCheck(postcode, "TA[0-9]") ||  PostcodeCheck(postcode, "TQ[0-9]") ||  PostcodeCheck(postcode, "TR[0-9]") ||  PostcodeCheck(postcode, "BH[0-9]") ||  PostcodeCheck(postcode, "DT[0-9]") ||  PostcodeCheck(postcode, "RG[0-9]") ||  PostcodeCheck(postcode, "SN[0-9]") ||  PostcodeCheck(postcode, "SO[0-9]") ||  PostcodeCheck(postcode, "SP[0-9]") || PostcodeCheck(postcode, "BH[0-9]") || PostcodeCheck(postcode, "DT[0-9]") || PostcodeCheck(postcode, "EX[0-9]") || PostcodeCheck(postcode, "PL[0-9]") || PostcodeCheck(postcode, "RG[0-9]") || PostcodeCheck(postcode, "SO[0-9]") || PostcodeCheck(postcode, "SP[0-9]") || PostcodeCheck(postcode, "TA[0-9]") || PostcodeCheck(postcode, "TQ[0-9]") || PostcodeCheck(postcode, "TR[0-9]")) {
  document.getElementById("Franchise").innerHTML = "<p><b>John Lafferty<br><br>FP - IMS Southern Ltd</b><br>Unit 4<br>Saturn House<br>Calleva Park<br>Aldermaston<br>RG7 8HA<br><br>Tel: 0118 982 0988 <br>Fax: 0118 982 0924<br>Email: info@ims-franking.co.uk</p>"
 } else 

if (PostcodeCheck(postcode, "E[0-9][0-9]") || PostcodeCheck(postcode, "SE[0-9]") || postcode == "EC3" || postcode == "EC4") {
  document.getElementById("Franchise").innerHTML = "<p>FP Premier<br>9 Gunnery Terrace<br>The Royal Arsenal<br>London<br>SE18 6SW<br><br>Tel: 0870 042 9000<br>Fax: 0870 042 9001</p>"
 } else




if (PostcodeCheck(postcode, "CB[0-9]") || PostcodeCheck(postcode, "CM[0-9]") || PostcodeCheck(postcode, "CO[0-9]") || PostcodeCheck(postcode, "EN[0-9]") || PostcodeCheck(postcode, "IG[0-9]") || PostcodeCheck(postcode, "IP[0-9]") || PostcodeCheck(postcode, "MK[0-9]") || PostcodeCheck(postcode, "NN[0-9]") || PostcodeCheck(postcode, "NR[0-9]") || PostcodeCheck(postcode, "PE[0-9]") || PostcodeCheck(postcode, "RM[0-9]") || PostcodeCheck(postcode, "SG[0-9]") || PostcodeCheck(postcode, "SS[0-9]") || PostcodeCheck(postcode, "EC[0-9]") || PostcodeCheck(postcode, "N[0-9][0-9]") || PostcodeCheck(postcode, "WC[0-9]")) {
  document.getElementById("Franchise").innerHTML = "<p><b>Nick Clement<br>Steve Rogers<br><br>FP Mailing (City) Ltd</b><br>Unit 15, Swan Business Park<br>Sandpit Road<br>Dartford<br>Kent<br>DA1 5ED<br><br>Tel: 01322 288 890<br>Fax: 01322 288 866<br>Mobile: 07976 931281 (Nick)<br>Mobile: 07956 454730 (Steve)<br>Email: enquiries@fpmailingcity.co.uk</p>"
 } else

if (PostcodeCheck(postcode, "BN[0-9]") || PostcodeCheck(postcode, "BR[0-9]") || PostcodeCheck(postcode, "CR[0-9]") || PostcodeCheck(postcode, "CT[0-9]") || PostcodeCheck(postcode, "DA[0-9]") || PostcodeCheck(postcode, "ME[0-9]") || PostcodeCheck(postcode, "RH[0-9]") || PostcodeCheck(postcode, "SM[0-9]") || PostcodeCheck(postcode, "SW[0-9]") || PostcodeCheck(postcode, "TN[0-9]")) {
  document.getElementById("Franchise").innerHTML = "<p><b>Steve Rogers<br><br>FP Mailing (South)</b><br>Unit 15, Swan Business Park<br>Sandpit Road<br>Dartford<br>Kent<br>DA1 5ED<br><br>Tel: 01322 288890<br>Fax: 01322 2888664<br>Mobile: 07976 931281<br>Email: enquiries@fpmailingcity.co.uk</p>"
 } else 

if (PostcodeCheck(postcode, "BT[0-9]")) {
  document.getElementById("Franchise").innerHTML = "<p>Paul Hughes<br><br>Copytext<br>29 Irish Street<br>Dungannon<br>Co. Tyrone<br>N.Ireland<br>BT70 1DB<br><br>Tel: 02887 729277<br>Fax: 02887 753929<br>Mobile: 07970 777744<br>Email: phughes@copytextni.co.uk</p>"
 } 

};
var sTarget;
var sInput;
sInput = ""
sTarget = ""
function doPostcode(ID)
	{
	if (ID == "Outcode") {sInput = "Outcode";sTarget = "calender";}
	var d = frm.Outcode.value;
	var e = frm.Incode.value;
  	frm1.action = "diary.asp?Outcode=" + d + "&Incode=" + e;
  	frm1.target = "HDiary";
	frm1.submit();
	}

function Loading()
	{
	sInput = "Outcode";sTarget = "calender";
  	frm1.action = "loading.asp"
  	frm1.target = "HDiary";
	frm1.submit();
	}
var theInterval;
function doLoadCalender(newData) {
    if( theInterval ) { clearInterval(theInterval); }
    var d = document.getElementById(sTarget);
		d.style.display = 'none';
	d.innerHTML = newData;
		d.style.display = 'block';
}
function doSelect(dateSelected)
	{
	var d = document.getElementById(sInput);
	d.value = dateSelected;
	var d = document.getElementById(sTarget);
	d.style.display = 'none';
	}
