//<script language="JavaScript">
//Copyright 2003 Kyma.  All rights reserved.

var w3c = (document.getElementById) ? 1:0;
var ie = (navigator.appName.indexOf("Microsoft") != -1) ? 1:0;
var ie4 = (document.all) ? 1:0;
var ie5 = (navigator.userAgent.indexOf("MSIE 5.0") != -1) ? 1:0;
var ns = (!ie) ? 1:0;
var ns6 = ((!ie) && (w3c)) ? 1:0;
var ns4 = ((ns) && (!ns6)) ? 1:0;
var mac = (navigator.platform.indexOf("Mac") != -1) ? 1:0;

var show = (ns4) ? "show" : "visible";
var hide = (ns4) ? "hide" : "hidden";

var siteName = "guildfordtyres";

function getObjectRef(obj) {

	var objref;

	if (w3c) {
		if (document.getElementById(obj)) objref = document.getElementById(obj).style;
	} else if (ie) {
		objref = document.all(obj).style;
	} else if (ns4) {
		objref = document[obj];
	}

	return objref;

}

function roll(s,o){
  
  var img = o.firstChild;
  var on = "_on";
  var off = "_off";

  if (s)
  {
	img.src = img.src.replace(off,on);
  } else{
	img.src = img.src.replace(on,off);
  }
}

var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function updateWelcomeBarDateTime()
{
  var dt = new Date();
  var fdt = "";
  if (wbDT)
  {
	fdt=dt.getHours() + "." + dt.getMinutes() + " | " + dt.getDate() + dateSuffix(dt.getDate()) + " " + months[dt.getMonth()] + ", " + dt.getFullYear();
	wbDT.innerText = fdt;
  }
}

function dateSuffix(date)
{
  switch (date)
  {
	case 1:
	case 21:
	case 31:
	  return "st";
	  break;
	case 2:
	case 22:
	  return "nd";
	  break;
	case 3:
	case 23:
	  return "rd";
	  break;
	default:
	  return "th";
	  break;
  }
}

var wbDT;
function init()
{
  wbDT = document.getElementById("wbDT");
  updateWelcomeBarDateTime();
  setInterval("updateWelcomeBarDateTime()",5000);
}
window.onload=init;

function launchRemote(frameURL, winName, pxwidth, pxheight, pxtop, pxleft, options)  {
	
	var toolbar = "no";
	var location = "no";
	var directories = "no";
	var status = "no";
	var menubar = "no";
	var scrollbars = "0";
	var resizable = "no";

	if (pxheight==null)	pxheight= 550;
	if (pxwidth==null)	pxwidth	= 790;
	
	if (pxleft==null)	pxleft	= Math.floor((screen.width - pxwidth) / 2);
	if (pxtop==null)	pxtop	= Math.floor((screen.height - pxheight) /2);

	if (screen.width==800) {
		pxleft=0;
		pxtop=0;
	}

	if (options) {
		if (options.indexOf('status')!=-1) {
			status = "yes";
		}
		if (options.indexOf('menubar')!=-1) {
			menubar = "yes";
		}
		if (options.indexOf('scrollbar')!=-1) {
			scrollbars = "1";
		}
		if (options.indexOf('scrollbars')!=-1) {
			scrollbars = "2";
		}
	}

	features =  "toolbar=" + toolbar + ",";
	features += "location=" + location + ",";
	features += "directories=" + directories + ",";
	features += "status=" + status + ","; 
	features += "menubar=" + menubar + ",";
	features += "scrollbars=" + scrollbars + ",";
	features += "resizable=" + resizable + ",";
	features += "top=" + pxtop + ",";
	features += "left=" + pxleft + ",";
	features += "width=" + pxwidth + ",";
	features += "height=" + pxheight;
	
	//debug:
	//alert("Parameter values for launchRemote function:-\n\nURL: " + frameURL + "\n" + "Name: " + winName + "\n\n" + "Features: " + features);
	
	winName = siteName + winName;
	
	dlg = window.open (frameURL, winName, features)

}

var cookies = document.cookie;
function readCookie(name) {

	var start = cookies.indexOf(name + "=");
	if (start == -1) {
		return false;
	}
	start = cookies.indexOf("=", start) + 1;
	var end = cookies.indexOf(";", start);
	if (end == -1) {
		end = cookies.length;
	}
	var value = unescape(cookies.substring(start, end));
	if (value == null) {
		return false;
	} else {
		return value;
	}

}

function writeCookie(name, value, years, path, domain) {

	var fulldate = new Date();
	var year = fulldate.getFullYear();
	var month = fulldate.getMonth();
	var date = fulldate.getDate();
	if (years) year = year + years;
	var expirydate = new Date(year,month,date);
		
	var thecookie;
	
	thecookie = name + "=" + value + ";";
	if (path) thecookie = thecookie + "path=" + path + ";";
	if (domain) thecookie = thecookie + "domain=" + domain + ";";
	thecookie = thecookie + "expires=" + expirydate.toString() + ";";
	
	document.cookie = thecookie;

}

function regExpSupported()
{
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr))
	  return true;
	else
	  return false;
  }
}

function isNumber(str){
  var r1 = new RegExp("[a-z]|[A-Z]");
  return (!r1.test(str));
}

function isTelephone(str) {
  if (!regExpSupported())
    return (true);
  var r1 = new RegExp("[0-9]");
  return (r1.test(str));
}

function isEmail(str) {
  if (!regExpSupported()) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

//</script>
