function setFordModel(mod,page) {
	window.location=page+'?mod='+mod;
}

function setEnquiryDate() {

	if(document.getElementById) {
  		var today = new Date();
  		var day = today.getDate();
  		var month = today.getMonth();
  		var year = today.getFullYear();
		month++;
		day = day+"";
		month = month + "";
		year = year + "";
  		if(day.length == 1) day = "0" + day;
  		if(month.length == 1) month = "0" + month;
  		document.getElementById("contactOn__day").value = day;
  		document.getElementById("contactOn__month").value = month;
  		document.getElementById("contactOn__year").value = year;
  	}
}

function doPostBack(e) {
    if(!e) e = window.event;
    var ok = wFORMS.behaviors['validation'].run(e);

	// custom validation - if time set then we need to validate date and time - and must be in future

    var postcode = document.getElementById('postcode');
    var phone  = document.getElementById('phone');
	var contactTimeType = document.getElementById('contactTimeType');

    if(contactTimeType.value != 'Within 24 Hours') {
    	var errorMessage = "Please specify a valid date and time below";

		if(!chkDate("contactOn") || document.getElementById("contactTime").value.length == 0) {

    		wFORMS.behaviors['validation'].showError(contactTimeType, errorMessage);
    		// prevent the submission:
    		return wFORMS.helpers.preventEvent(e);
    	}
    }
    return true;
}

function chkDate(f)
{
	var	vdate = true;
	if(gebi(f+"__day").value.length == 0) vdate = false;
	if(gebi(f+"__month").value.length == 0) vdate = false;
	if(gebi(f+"__year").value.length == 0) vdate = false;
	if(vdate) vdate = checkDate(gebi(f+"__day").value,gebi(f+"__month").value,gebi(f+"__year").value);
	var today = new Date();


	return vdate;
}

function stripZero(str)
{
	if(str.substring(0,1) == "0") str = str.substring(1);
	str = str - 0;
	return str;
}

function checkDate(d,m,y)
{
	d = stripZero(d);
	m = stripZero(m);
	y = stripZero(y);
	m--;
	try
	{
		var myDate = new Date(y, m, d, 00, 00, 00);
	}
	catch(err)
	{
		return false;
	}
	return((d==myDate.getDate()) && (m==myDate.getMonth()) && (y==myDate.getFullYear()));
}

var hiRow = null;
function hilightRowBD(r) {
	if (document.getElementById) {

		if (hiRow) {
			hiRow.className = "searchResultBD";
			var ns = hiRow.nextSibling;
			while (ns.tagName != "TR")
				ns = ns.nextSibling;

			ns.className = "searchResultBtnsBD";
		}

		hiRow = r;

		if (hiRow) {
			hiRow.className = "searchResultBD redrow";

			var ns = hiRow.nextSibling;
			while (ns.tagName != "TR")
				ns = ns.nextSibling;

			ns.className = "searchResultBtnsBD redrow";
		}
	}
}

function hilightPrevRowBD(r) {
	if (document.getElementById) {
		if (r) {
			var ps = r.previousSibling;
			while (ps.tagName != "TR")
				ps = ps.previousSibling;
		}else
			ps = r;

		hilightRowBD(ps);
	}
}