<!-- Hide from old browsers
// Unless otherwise noted, all JavaScript is copyright 
// (c) SilverDisc Ltd 1996-2003: all rights reserved. 

// Handle screen redraw problems in Navigator
if (navigator.appName=="Netscape")
{
  window.captureEvents(Event.RESIZE);
  window.onresize=function (evt){location.reload(); };
}

		var mousex,mousey
		if (!document.all) {
			document.onmousemove = getMousePos;
		}
		
		function getMousePos(event) {
			ev = event || window.event;
			mousex = ev.pageX
			mousey = ev.pageY
			
		}
		
		function showCMCommit(objname) {
			theObj = document.getElementById(objname)
			if (document.all) {
				mousex = window.event.clientX + document.body.scrollLeft
				mousey = window.event.clientY + document.body.scrollTop
			}
			theObj.style.position = "absolute"
			theObj.style.top = mousey
			theObj.style.left = mousex
			theObj.style.display = "block"
		}
		
		function hideCMCommit(objname) {
			theObj = document.getElementById(objname)
			theObj.style.display = "none"
		}

function newWindow(name,url,width,height,controls) 
{
  var param="width="+width+",height="+height;
  var winref;
  param=param+",resizable";
  if (controls =="SCROLL")
  {
    param=param+",scrollbars";
  }
  if (controls =="ALL")
  {
    param=param+",menubar,toolbar,location,status,scrollbars";
  }
  if (controls =="PRINT")
  {
    param=param+",menubar,scrollbars";
  }
  winref=window.open(url,name,param);
}

function doMailto()
{
var str="%0d%0d";
if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1)
{
 //alert("Version:"+navigator.appVersion+" , "+navigator.appName);
 
 if (navigator.appVersion.indexOf("5.5") == -1) str="%250d%250d";
}
document.write('<A HREF="mailto:?subject=Auridian Consulting&body=Hi, '+str+'I think you will find this IT training company of interest: '+str+'http://www.auridian.com/ '+str+'The page I was looking at was called: '+str+'\''+document.title+'\' '+str+'and is at: '+str+escape(window.location.href)+' '+str+'Regards">');

}

function add2FavoritesHome(rootURL)
{
    if ((navigator.appName.indexOf("Microsoft Internet Explorer") != -1) && 
        (parseInt(navigator.appVersion) > 3)) 
    {
        document.write('<A class="spmenuentry" HREF="#" onclick="window.external.AddFavorite(window.location.href,document.title);return false;">Add to Favorites</A>');
    }
}

function add2Favorites(rootURL)
{
    if ((navigator.appName.indexOf("Microsoft Internet Explorer") != -1) && 
        (parseInt(navigator.appVersion) > 3)) 
    {
        document.write('<A HREF="#" onclick="window.external.AddFavorite(window.location.href,document.title);return false;"><IMG SRC="'+rootURL+'gifs/add2fav.gif" BORDER="0" ALT="Click here to add this page to your favorites"></A>');
    }
}

function showUKTime()
{
  var now= new Date();
  var ukTime=now.toGMTString();

  document.write("<CENTER>UK TIME<BR>" + ukTime + "</CENTER>");
}
function selectAll(theForm)
{
 for (var i=0; i < theForm.elements.length; i++)
 {
  if ( theForm.elements[i].type=="checkbox" )
  {
       theForm.elements[i].checked=true;
  }
 }
 return false;
}

function invertAll(theForm)
{
 for (var i=0; i < theForm.elements.length; i++)
 {
  if ( theForm.elements[i].type=="checkbox" )
  {
       if (theForm.elements[i].checked)
       {
           theForm.elements[i].checked=false;
       }
       else
       {
           theForm.elements[i].checked=true;
       }
  }
 }
 return false;
}

var nextVacantSlot=0;
var maxImageSlots=4;
var theSlotMapping= new Array(maxImageSlots);
var maxImageRange=4;
var thePictureNames= new Array(maxImageRange);
var preloadedImages = new Array();

var theDoc = null;
var timerID = null;
var timerRunning = false;
var timerInt = 1; // Timer interval in seconds

function findImages(doc, theImageName,img1,img2,img3, clientID)
{
  // PS Motors script for finding images may be up to 4
  // Look for the optional additional images
  var theBaseURL="http://portal.motorplex.co.uk/image/";
  var imageNum=0;
  if ((theImageName != "") && (theImageName != "nopic.jpg") && (img1!=""))
  {
  if ((navigator.appName.indexOf("Microsoft Internet Explorer") != -1)&&(parseInt(navigator.appVersion) >= 4))
  {
    // IE4 or greater so go ahead and support multi image
    thePictureNames[0]=theImageName;
    thePictureNames[1]=img1;
    thePictureNames[2]=img2;
    thePictureNames[3]=img3;
    for (var imgIdx=0; imgIdx<maxImageRange; imgIdx++)
    {
      if (thePictureNames[imgIdx] !="")
      {
        preloadedImages[imgIdx]=new Image;
        preloadedImages[imgIdx].src=theBaseURL+thePictureNames[imgIdx]+".med";
        // alert(thePictureNames[imgIdx]);
      }
    }
    theDoc=doc;
    checkPictures();
    timerRunning = true;
    timerID = setInterval("checkPictures()",timerInt*1000)
  }
  }
}

function writeImages(doc, theImageName,img1,img2,img3, clientID)
{
  if ((navigator.appName.indexOf("Microsoft Internet Explorer") != -1)&&(parseInt(navigator.appVersion) >= 4))
  {

 if ((theImageName!="")&&(img1!=""))
 {
 doc.write('<TABLE CELLPADDING="2" BORDER="0" CELLSPACING="0">');
 if (theImageName!="") {doc.write('<TR><TD><A HREF="#" onClick="return setImage(document,0);"><IMG BORDER="1" NAME="pic0" WIDTH="64" HEIGHT="48" SRC="../gifs/clear.gif"></A></TD></TR>');}
 if (img1!="") {doc.write('<TR><TD><A HREF="#" onClick="return setImage(document,1);"><IMG BORDER="1" NAME="pic1" WIDTH="64" HEIGHT="48" SRC="../gifs/clear.gif"></A></TD></TR>');}
 if (img2!="") {doc.write('<TR><TD><A HREF="#" onClick="return setImage(document,2);"><IMG BORDER="1" NAME="pic2" WIDTH="64" HEIGHT="48" SRC="../gifs/clear.gif"></A></TD></TR>');}
 if (img3!="") {doc.write('<TR><TD><A HREF="#" onClick="return setImage(document,3);"><IMG BORDER="1" NAME="pic3" WIDTH="64" HEIGHT="48" SRC="../gifs/clear.gif"></A></TD></TR>');}
 doc.write('</TABLE>');
 }
 else
 {
 doc.write('&nbsp;');
 }

  }
}

function setImage(doc,num)
{
  if (nextVacantSlot > num)
  {
    if ((navigator.appName.indexOf("Microsoft Internet Explorer") != -1)&&(parseInt(navigator.appVersion) >= 4))
    {
      doc.images["picMain"].src=preloadedImages[theSlotMapping[num]].src;
    }
  }
  return false;
}

function checkPictures()
{
  if ((nextVacantSlot < maxImageSlots) && (preloadedImages[0].complete!=null))
  {
   for (imgIdx=0; imgIdx<maxImageRange; imgIdx++)
   {
     //alert(preloadedImages[imgIdx].complete)
     if (thePictureNames[imgIdx] != "")
     {
       if ((preloadedImages[imgIdx].complete) && (nextVacantSlot < maxImageSlots))
       {
        var imgName="pic"+nextVacantSlot.toString(10);
        var imgRef=theDoc.images[imgName];
        //alert(imgName);
        imgRef.src=preloadedImages[imgIdx].src;
        theSlotMapping[nextVacantSlot] = imgIdx;
        nextVacantSlot=nextVacantSlot+1;
        thePictureNames[imgIdx] = "";
       }
     }
   }
  }
  else
  {
    // Found 4 images so stop timer
    timerRunning = false;
    clearInterval(timerID);
    timerID = null;
  }
}

function writeNewUsed(win, doc, newDesc, usedDesc)
{
 if (win.location.href.indexOf("new") != -1)
 {
  newImage="new_cars_hi.gif";
 }
 else
 {
  newImage="new_cars_low.gif";
 }
 if (win.location.href.indexOf("used") != -1)
 {
  usedImage="used_cars_hi.gif";
 }
 else
 {
  usedImage="used_cars_low.gif";
 }
 doc.write('<TD><a href="/new"><IMG SRC="/gifs/'+newImage+'" BORDER="0" ALT="'+newDesc+'"></A></TD>');
 doc.write('<TD><a href="/used"><IMG SRC="/gifs/'+usedImage+'" BORDER="0" ALT="'+usedDesc+'"></A></TD>');
}

function showTel(doc, weekendTel, weekdayTel)
{
  var now= new Date;
  var today=now.getDay();
  var theTime=now.getHours();
  var tel=weekdayTel;
  if ((today==0) || (today==6))
  {
    if (today==6)
    {
      // It is Saturday
      if ((theTime > 9) && (theTime < 17))
      {
        // show week day number between 10am and 5pm
        tel=weekdayTel;
      }
      else
      {
        // It is Sunday
        tel=weekendTel;
      }
    }
    else
    {
      tel=weekendTel;
    }
  }
  doc.write(tel);
}
   
// Data validation functions:

// Check whether string is empty or all white-space
function IsEmptyString(s)
{
    var i;

    // Quick checks for complete emptiness
    if(s == null) return true;
    if(s.length == 0) return true;
    
    // Look for non-whitespace in the string
    for(i = 0; i < s.length; i++)
    {
        // Check next character isn't empty
        var c = s.charAt(i);
        if(c != " " || c != "\t" || c != "\n" || c != "\r")
        {
            // Non-white space found - it's non-empty
            return false;
        }
    }
    // No non-space characters found - string is empty
    return true;
}


// Check for valid email address. Expect to see something like
// [A-Za-z0-9.]@[A-Za-z0-9].[A-Za-z0-9.] (i.e. xxx@yyy.zzz will do
// fine). To check this quickly, walk through looking for an '@'.
// Once found, start looking for a '.'.
function IsValidEmail(s)
{
    var i;
    
    // Quick check - is it empty?
    if(IsEmptyString(s))
    {
        return false;
    }

    // Look for @ 
    for(i = 0; i < s.length; i++)
    {
        if(s.charAt(i) == "@") break;
    }
    // Then look for .
    for( ; i < s.length; i++)
    {
        if(s.charAt(i) == ".") return true;

    }
    // Off the end? Missed either @ or .
    return false;
}

// Check for valid phone number. First character can be "+" (for
// international dialling). After that we only allow [0-9()[]- ]
function IsValidPhone(s)
{
    var i;

    // Quick check...
    // if(IsEmptyString(s)) return false;  // Check if empty

    // Check first character...
    i = 0;
    if(s.charAt(i) == "+")
    {
        i = 1;      // That's OK, don't check it again
    }

    // Check the rest...
    var validChars = "0123456789 -()[]";
    for( ; i < s.length; i++)
    {
        var c = s.charAt(i);
        if(validChars.indexOf(c) == -1)
        {
            return false;       // Invalid character
        }       
    }

    return true;    // If we get here the number is OK
}

function ValidatePhone(number, prompt, item)
{
    if(!IsValidPhone(number))
    {
        // Get the user to confirm he has no such number
        var msg;
        msg = "You have not entered a valid " + 
                    prompt + " number. ";
        msg += "Press 'OK' if you want to " +
                    (IsEmptyString(number) ? "enter" : "edit") +
                    " the number " +
                    "before submitting your details";

        if(confirm(msg))
        {
            if(item != null)
            {
                item.focus();
                item.select();
            }
            return false;
        }
    }
    return true;    // OK if we get out here
}


function validateContact(frm)
{

    // Check that some sensible data has been entered
    // in key fields

    if(IsEmptyString(frm.contact.value))
    {
        alert("Please tell us your name.");
        frm.contact.focus();
        frm.contact.select();
        return false;
    }

    if ((IsEmptyString(frm.phone.value)) && (IsEmptyString(frm.email.value)))
    {
        alert("Please specify an email address and/or phone number.");
        return false;
    }

    // If phone number given, check it.
    if (!IsEmptyString(frm.phone.value))
    {
        if(!ValidatePhone(frm.phone.value, "phone number", frm.phone))
        {
            return false;
        }
    }

    // If email given, check it.
    if (!IsEmptyString(frm.email.value))
    {
        if(!IsValidEmail(frm.email.value))
        {
            alert("Please specify a valid email address. e.g. yourname@company.com");
            frm.email.focus();
            frm.email.select();
            return false;
        }
    }

    // OK! Let the form submit itself
    return true;
}

function createCookie(name,value,secs)
{
        if (secs)
        {
                var date = new Date();
                date.setTime(date.getTime()+(secs*1000));
                var expires = "; expires="+date.toGMTString();

        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
        var nameEQ = name + "=";

        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++)
        {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);

                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function eraseCookie(name)
{
        createCookie(name,"",-1);



}


// End hiding -->
