
// Version 1 [ 13 June 2003 - 14:54]


var imageDir="images/";			// path to background image and 'red-square'
var myName="online.js";			// name of this file for nesting purposes
var good;

var ePost="inf" + "o@hta" + "mortgages.net";

// -------------------------------

// Remember to addd mouse click



// -------------------------------

	//checks that data are valid 
	function checkNumber(input, min, max, msg) {

		msg = msg + " field has invalid data: " + input.value;

		//this makes sure that the number is a number
		var str = input.value;
		for (var i = 0; i < str.length; i++) {
			var ch = str.substring( i, i + 1)
			if ((ch < "0" || "9" < ch) && ch != '.') {
				alert(msg);
				return false;
			}
		}

		//this makes sure that the number lies between the min and max values allowed
		var num = 0 + str
		if (num < min || max < num) {
			alert(msg + " not in range [" + min + ".." + max + "]");
			return false;
		}
		input.value = str;
		return true;
	}

	function computeField(input) {
		if (input.value != null && input.value.length != 0)
		{
			input.value = "" + eval(input.value);
		}
		computeForm(input.form);
	}

	function computeForm(form) {
		var A=form.A.value;
		var T=form.T.value;
		var R=form.R.value;

		//making sure that an entry has been made in each field.
		if ((A == null || A.length == 0) ||
			(R == null || R.length == 0)) 
		{
			//alert('not all fields filled in');
			return;
		}

		// making sure that entries are valid by using check number
		if (!checkNumber(form.A, 1, 999999, "Amount") ||
			!checkNumber(form.R, .001, 1000, "Interest Rate") ||
			!checkNumber(form.T, 5, 25, "Period")) 
		{
			form.Cm.value = "Invalid";
			return;
		}

		// maths et al to be computed
		R = R / 100;
		var P = ((A*R)/12) * (1/(1-(Math.pow(1/(1+R),T))));
		form.Cm.value = poundsPence( P );
		P = ((A*0.12)/12) * (1 / (1-(Math.pow((1/1.12),T))));
		//form.CCm.value = poundsPence( P );
		P = (A*R)/12;
		form.CI.value = poundsPence( P );
		//P = (A*0.12)/12;
		//form.CCI.value = poundsPence( P );
	}

	function poundsPence( N ) {
		// don't try this with ie3 because it's rubbish
		if ((navigator.appName.indexOf('Microsoft')>-1)
			&& (navigator.appVersion.indexOf('3.0')>-1) )
		{
			return N;
		}
		S = new String( N );
		var i = S.indexOf('.');
		if (i != -1) {
			S = S.substr( 0, i+3 );
			if (S.length-i < 3)
				S = S + '0';
		}
		return S;
	}

	//clears form
	function clearForm(form) {
		form.A.value = "";
		form.T.value = "";
		form.R.value = "";
	}


function meLink( text, subject) {
   nn="";
   nn+='<a href="mailto:' + ePost;
   if (subject!="" && subject!=null) { nn+='?Subject=' + subject }
   nn+='">' + text + '</a>';
   return nn;
}

function vLink(subject) {
   nn="";
   nn+='<a href="mailto:' + ePost;
   if (subject!="" && subject!=null) { nn+='?Subject=' + subject }
   nn+='"><img src="images/mail.gif" width=32 height=32 border=0 vspace=0></a>';
   return nn;
}

function captionStyle(txt) {
   while (txt.indexOf("{#")>0) {		// replace custom format commands {#?} with <p class="CF?>
      txtP=txt.indexOf("{#");
      txtL=txt.substring(0, txtP);
      txtS=txt.charAt(txtP+2);
      txtR=txt.substring(txtP+4);
      txt=txtL + '<p class="CF' + txtS + '">' + txtR;
   }
   while (txt.indexOf("{/#}")>0) {		// replace custom format end commands {/#} with </p>
      txtP=txt.indexOf("{/#}");
      txtL=txt.substring(0, txtP);
      txtR=txt.substring(txtP+4);
      txt=txtL + '</p>' + txtR;
   }
   return txt;
}

function popBig(filename, winname, description, imageW, imageH, closeParent) {
   if (description.indexOf("|")>0) { var describe = description.split("|"); description=describe[1] }
   description=captionStyle(description);
   nn="";
   nn+='<html><head><title>Blackpool Tramways Image Library - Picture ' + winname + '</title>';
   nn+='<meta http-equiv="imagetoolbar" content="no">';
   nn+='<meta name="MSSmartTagsPreventParsing" content="TRUE">';
   nn+='<style type="text/css">';
   nn+=' BODY { background-image: url(' + imageDir + '75.gif); margin: 5px; }';
   nn+=' .descriptive { font-family: "Trebuchet MS", sans-serif; font-size: 24px; font-weight: bold; text-align: center; color: #804000; }';
   if (description.indexOf('<h6>')>0) { nn+=' h6 { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; text-align: justify; color: #804000; margin: 4px 30px 0; }'; }
   if (description.indexOf('class="CFj"')>0) { nn+=' .CFj { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; text-align: justify; color: #804000; margin: 4px 30px 0; }'; }
   if (description.indexOf('class="CFc"')>0) { nn+=' .CFc { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; text-align: center; color: #804000; margin: 0 0 0; }'; }
   nn+='</style></head><body LINK="#000000" ALINK="#000000" VLINK="#000000"><center>';
   nn+='<table border=0 cellpadding=0 cellspacing=0 align="center" width="100%">';
   nn+=' <tr>';
   nn+='  <td align="center"><a href="javascript:window.close()"><img src="' + filename + '" width=' + imageW + ' height=' + imageH + ' border=1 alt=" Click to close window "></a></td>';
   nn+=' </tr>';
   nn+=' <tr valign="middle">';
   nn+='  <td height=50 class="descriptive">' + description + '</td>';
   nn+=' </tr>';
   nn+='</table></center></body></html>';
   window2=window.open("", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=0,top=0,width=" + (screen.availWidth-10) + ",height=" + (screen.availHeight-30));
   window2.document.open();
   window2.document.write(nn);
   window2.document.close();
   if (closeParent) { parent.window.close() };
   window2.focus()
}

function popUp(filename, winname, description, imageW, imageH) {
   bigURL="popBig('" + filename + "', '" + winname + "', '" + description + "', " + imageW + ", " + imageH + ", ";
   if (description.indexOf("|")>0) { var describe = description.split("|"); description=describe[0] }
   if (navigator.appName=="Opera" || document.layers || (screen.availWidth>=imageW && screen.availHeight>=imageH)) { eval(bigURL+"false)"); return } else { bigURL+= "true)" }
   winH=screen.availHeight-28;			// set popup window height to max available
   winW=screen.availWidth-9;			// set popup window width to max available
   imgH=winH-52;					// calculate maximum image height
   imgW=parseInt(imageW*(imgH/imageH));		// calculate proportional image width
   if (imgW>(winW-8)) {				// if resulting image is too wide
      imgW=winW-8;				// reduce image width
      imgH=parseInt(imageH*(imgW/imageW));		// calculate proportional image height
   }
   nn="";
   nn+='<html><head><title>Blackpool Tramways Image Library - Picture ' + winname + '</title>';
   nn+='<meta http-equiv="imagetoolbar" content="no">';
   nn+='<meta name="MSSmartTagsPreventParsing" content="TRUE">';
   nn+='<style type="text/css">';
   nn+=' BODY { background-image: url(' + imageDir + '75.gif); margin: 5px; }';
   nn+=' .descriptive { font-family: "Trebuchet MS", sans-serif; font-size: 24px; font-weight: bold; text-align: center; color: #804000; }';
   nn+=' .click { font-family: Arial, sans-serif; font-size: 11px; font-weight: normal; text-align: left; color: #000000; }';
   nn+='</style></head><body><center>';
   nn+='<script language="JavaScript" type="text/javascript" src="' + myName + '"></script>';
   nn+='<table border=0 cellpadding=0 cellspacing=0 align="center" width=' + (winW-14) + '>';
   nn+=' <tr>';
   nn+='  <td height=' + imgH + ' colspan=2 align="center"><a href="javascript:window.close()"><img src="' + filename + '" width=' + imgW + ' height=' + imgH + ' border=0 alt=" Picture ' + winname + ' "></a></td>';
   nn+=' </tr>';
   nn+=' <tr valign="bottom">';
   nn+='  <td width=' + (winW-214) + ' height=40 class="descriptive">' + description + '</td>';
   nn+='  <td width=200 class="click">Click on the image to close this window<br><a href="javascript:' + bigURL + '"><img src="' + imageDir + 'redsq.gif" width=9 height=9 border=0 alt=""></a> &nbsp; See image at maximum resolution</td>';
   nn+=' </tr>';
   nn+='</table></center></body></html>';
   window1=window.open('', '', "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=0,top=0,width=" + winW + ",height=" + winH);
   window1.document.open();
   window1.document.write(nn);
   window1.document.close();
   window1.focus()
}

function lastMod() {
  var x = new Date (document.lastModified);
  Modif = new Date(x.toGMTString());
  Year = takeYear(Modif);
  Month = Modif.getMonth();
  Day = Modif.getDate();
  Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
  x = new Date();
  today = new Date(x.toGMTString());
  Year2 = takeYear(today);
  Month2 = today.getMonth();
  Day2 = today.getDate();
  now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
  daysago = now - Mod;
  if (daysago < 0) return '';
  unit = 'days';
  if (daysago > 730)
  {
  daysago = Math.round(daysago/365);
  unit = 'years';
  }
  else if (daysago > 60)
  {
  daysago = Math.round(daysago/30);
  unit = 'months';
  }
  else if (daysago > 14)
  {
  daysago = Math.round(daysago/7);
  unit = 'weeks'
  }
  towrite = '<br>Page last updated ';
  if (daysago == 0) towrite += 'today';
  else if (daysago == 1) towrite += 'yesterday';
  else towrite += daysago + ' ' + unit + ' ago';
  towrite += '. &nbsp; &copy; ' + Year +  ' David Bradley';
  return towrite;
}

function takeYear(theDate) {
  x = theDate.getYear();
  var y = x % 100;
  y += (y < 38) ? 2000 : 1900;
  return y;
}

function popUpold(filename, winname, description, width) {
   nn="";
   nn+='<html><head><title>Blackpool Tramways Image Library - Picture '+ winname + '</title>';
   nn+='<meta http-equiv="imagetoolbar" content="no">';
   nn+='<meta name="MSSmartTagsPreventParsing" content="TRUE">';
   nn+='</head>';
   nn+='<body background="' + imageDir + '75.gif" topmargin=5 leftmargin=2 rightmargin=2 marginheight=5 marginwidth=2>';
   nn+='<a href="javascript:window.close()"><img src="' + filename + '" border=0 alt=" Click to close window "></a>';
   nn+='<center><font color="#804000" size=5 face="Trebuchet MS">';
   nn+='<p><b>' + description + '</b></p><p>&nbsp;</p></font></center>';
   nn+='</body></html>';
   window2 = window.open("", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=0,top=0,width="+ width);
   window2.document.open();
   window2.document.write(nn);
   window2.document.close();
   window2.focus()
}

function pagebase() {
   nn="";
   nn+='<center>';
   nn+='<p class="mailme">';
   nn+=document.title;
   nn+='<br>If you wish to provide further background information please <a href="mailto:' + ePost + '?Subject=' + document.title + '">email me</a>';
   nn+='<br>Site visitors input is always appreciated<br>';
   nn+='<br>URL: ' + location.toString();
   nn+=lastMod();
   nn+='</center><br>';
   nn+='</p>';
   return nn;
}

function w3c() {
   nn="";
   nn+='<br><span class="reg">Free Consultation &bull; Buy To Let &bull; Self Cert &bull; ';
   nn+='Fee&#39;s-Free Mortgages<br><br>';
   nn+='Howard Taylor Associates<br>';
   nn+='79 Victoria Road, Farnborough, Hampshire, GU14 7PL<br>';
   nn+='</span><br>';
   nn+='<a href="http://validator.w3.org/check/referer" target="_w3c" onmouseover="self.status=\'This WEB page has been designed to work under all operating sytems and with all WEB Browsers\'; return true" onmouseout="self.status=\'\'; return true"><img src="' + imageDir + 'w3c-401.gif" alt="Web page with valid HTML 4.01 markup" border="0" height="31" width="93" hspace="0"></a>';
   nn+='<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_w3c" onmouseover="self.status=\'This site uses Cascading Style Sheets [CSS] which is a mechanism for adding style [e.g. fonts, colors, spacing] to our pages\'; return true" onmouseout="self.status=\'\'; return true"><img src="' + imageDir + 'w3c-css.gif" alt="This site uses Cascading Style Sheets [CSS] which is a simple mechanism for adding style [e.g. fonts, colors, spacing] to our pages. Hyperlink checks for design errors." border="0" height="31" width="93" hspace="0"></a>';
   return nn;
}

// -------------Clock--START----------




function zclock() {
            var xdt = new Date(), xtz = "GMT";
            if (xdt.getTimezoneOffset() == -60) { xtz += "0100" };
            obj = new Object;obj.clockfile = "0018-silver.swf";obj.TimeZone = xtz;obj.width = 75;obj.height = 75;
            obj.wmode = "transparent";showClock(obj);
}

function zshowClock(obj){
	var str = '<embed src="http://www.clocklink.com/clocks/'
		+ obj.clockfile;
	str += "?";
		
	for( prop in obj ) {
		if( 'clockfile' == prop 
			|| 'width' == prop
			|| 'height' == prop
			|| 'wmode' == prop
			|| 'type' == prop
		) continue;
		str += ( prop + "=" + _escape(obj[prop]) + "&" );
	}
	str += '" ';
	str += ' width="' + obj.width + '"';
	str += ' height="' + obj.height + '"';
	str += ' wmode="' + obj.wmode + '"';
	str += ' type="application/x-shockwave-flash">';
	
	document.write( str );
}






function clock() {
            var xdt = new Date(), xtz = "GMT";
            if (xdt.getTimezoneOffset() == -60) { xtz += "0100" };
            obj = new Object;obj.clockfile = "0001-blue.swf";obj.TimeZone = xtz;obj.width = 150;obj.height = 150;
            obj.wmode = "transparent";showClock(obj);
}

function showClock(obj){
	var str = '<embed src="http://www.clocklink.com/clocks/'
		+ obj.clockfile;
	str += "?";
		
	for( prop in obj ) {
		if( 'clockfile' == prop 
			|| 'width' == prop
			|| 'height' == prop
			|| 'wmode' == prop
			|| 'type' == prop
		) continue;
		str += ( prop + "=" + _escape(obj[prop]) + "&" );
	}
	str += '" ';
	str += ' width="' + obj.width + '"';
	str += ' height="' + obj.height + '"';
	str += ' wmode="' + obj.wmode + '"';
	str += ' type="application/x-shockwave-flash">';
	
	document.write( str );
}

function _escape(str){
	str = str.replace(/ /g, '+');
	str = str.replace(/%/g, '%25');
	str = str.replace(/\?/, '%3F');
	str = str.replace(/&/, '%26');
	return str;
}

function showBanner(BannerLink){
	document.write(BannerLink);
}

// -------------Clock--END-----------

