// JavaScript Document

// Copyright the Website - Stop Right Hand Clicks
var message="Copyright 2008 Huddersfieldmc.co.uk";

function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;


//for the status bar at base of screen
function writestatus(say) {
self.status="Huddersfieldmc.co.uk [" + say + "]";
}
function clearstatus() {
self.status="Huddersfieldmc.co.uk";
}
clearstatus();

//the time that is used in the left hand menu
 
function gettimedate() {
	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if (year < 2000)
	year = year + 1900;
	document.write(date + " - ");
	document.write(lmonth + " - " + year);
}


//the random image function in the left hand menu bar ++ 1 ++
function randomimage1() {										
var currentdate = 0
var core = 0
function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
image = new StringArray(26)
image[0] = 'images/random/1.jpg'
image[1] = 'images/random/2.jpg'
image[2] = 'images/random/3.jpg'
image[3] = 'images/random/4.jpg'
image[4] = 'images/random/5.jpg'
image[5] = 'images/random/6.jpg'
image[6] = 'images/random/7.jpg'
image[7] = 'images/random/8.jpg'
image[8] = 'images/random/9.jpg'
image[9] = 'images/random/10.jpg'
image[10] = 'images/random/11.jpg'
image[11] = 'images/random/12.jpg'
image[12] = 'images/random/13.jpg'
image[13] = 'images/random/14.jpg'
image[14] = 'images/random/15.jpg'
image[15] = 'images/random/16.jpg'
image[16] = 'images/random/17.jpg'
image[17] = 'images/random/18.jpg'
image[18] = 'images/random/19.jpg'
image[19] = 'images/random/20.jpg'
image[20] = 'images/random/21.jpg'
image[21] = 'images/random/22.jpg'
image[22] = 'images/random/23.jpg'
image[23] = 'images/random/24.jpg'
image[24] = 'images/random/25.jpg'
image[25] = 'images/random/26.jpg'
var ran = 60/image.length

function ranimage() {
  currentdate = new Date()
  core = currentdate.getSeconds()
  core = Math.floor(core/ran)
    return(image[core])
}
document.write("<a href='gallerymain.asp'><img border='0' src='" +ranimage()+ "'></a>")

}


//the random image function in the left hand menu bar ++ 2 ++
function randomimage2() {										
var currentdate = 0
var core = 0
function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
image = new StringArray(13)
image[0] = 'images/random/13.jpg'
image[1] = 'images/random/14.jpg'
image[2] = 'images/random/15.jpg'
image[3] = 'images/random/16.jpg'
image[4] = 'images/random/17.jpg'
image[5] = 'images/random/18.jpg'
image[6] = 'images/random/19.jpg'
image[7] = 'images/random/20.jpg'
image[8] = 'images/random/21.jpg'
image[9] = 'images/random/22.jpg'
image[10] = 'images/random/23.jpg'
image[11] = 'images/random/24.jpg'
image[12] = 'images/random/25.jpg'
var ran = 60/image.length

function ranimage() {
  currentdate = new Date()
  core = currentdate.getSeconds()
  core = Math.floor(core/ran)
    return(image[core])
}
document.write("<img src='" +ranimage()+ "'>")
}



// For the dreamweaver objects
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;
}


//For Dreamweaver To Validate A Form
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 == '');
}


//for the text in the status bar

msg = "Welcome to Huddersfield Motor Club!";
timeID = 10;
stcnt = 16;
wmsg = new Array(33);
        wmsg[0]=msg;
        blnk = "                                                               ";
        for (i=1; i<32; i++)
        {
                b = blnk.substring(0,i);
                wmsg[i]="";
                for (j=0; j<msg.length; j++) wmsg[i]=wmsg[i]+msg.charAt(j)+b;
        }
function wiper()
{
        if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
        if (stcnt-- < -40) stcnt=31;
        status = str;
        clearTimeout(timeID);
        timeID = setTimeout("wiper()",100);
}

// the go-to-url command


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


// remainng characters in a text box
// fieldname, warningname, remainingname, maxchars
function CheckFieldLength(fn,wn,rn,mc) {
  var len = fn.value.length;
  if (len > mc) {
    fn.value = fn.value.substring(0,mc);
    len = mc;
  }
  document.getElementById(wn).innerHTML = len;
  document.getElementById(rn).innerHTML = mc - len;
}