function LoginValidate(ctrlEmail, ctrlPassword)
{
	var Email = document.getElementById(ctrlEmail);
	var Password = document.getElementById(ctrlPassword);
	var send = true;
	var strVal ="";
	if (Email.value.length == 0)
	{
		send = false;
		strVal = "Please enter an email\r";
		// set the emailtextbox class
	
	}
	else
	{
		var filter=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
		var str = Email.value;
		if (filter.test(str)){	send=true; }
		else
		{
			strVal =strVal + "Please enter a valid email\r";
			send=false;
		}
	}
	if (Password.value.length == 0 )
	{
		strVal =strVal + "Please enter a Password";
		send = false;
		// set the Password textbox class
	}
	
	
	if ( send == false )
	{
		alert(strVal);
		return false;
		
	}
	else
	{
	return true
	}
	
}


function checkChange(ctrl1,ctrl2)
{

	var ddlMiles = document.getElementById(ctrl1);
	var ddlMonths = document.getElementById(ctrl2); 
	
	if ((ddlMonths.selectedValue == -1) )
	{
		return false;
	}
	else
	{	
		return true;
	}
	
	
}

function detectCookies()
        {
            if(navigator.cookieEnabled)
            {
            
            }
            else
            {
			 alert('Cookies are required in order to use this site correctly.');
            }
        }

function termsChecked(ctrl1, ctrl2)
{
	
	var terms = document.getElementById(ctrl1);
	
	if (terms.checked == true )
	{		
		return true;
	}
	else
	{
		var Val  = document.getElementById(ctrl2);
		Val.style.visibility = 'visible';	
		return false;
	}
	
}

function validateCallBack(ctrl1, ctrl2, ctrl3)
{

	var name = document.getElementById(ctrl1);
	var email = document.getElementById(ctrl2);
	var Phone = document.getElementById(ctrl3);
	var strVal= "";
	var send = true;
	
	if ((email.value == 'Email') && (Phone.value == 'Telephone') )
		{
			strVal = strVal + "Please enter a contact detail\r";
			email.className = 'error';
			Phone.className = 'error';
			send = false;	
		}
		
		else if ((email.value.length > 0) &&  !(email.value == 'Email') )
		{
			var filter=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
			var str = email.value;
			if (filter.test(str)){	send=true; }
			else
			{
				strVal = strVal + "Please enter a valid email\r";
				send=false;
			}
		
		
	}	
	
	if ((name.value.length  < 1) || (name.value == 'Name'))
	{
		strVal = strVal + "Please enter your name\r";
		name.className = 'error';
		send = false;
	}
	
	
	
	
	
	if (send)
	{
	}
	else
	{
		alert(strVal);
	}
	
	return send;
}



function changeUCLocation(ctrl1,ctrl2)
{
	var ddlColl = document.getElementById(ctrl1);
	var ddlRet = document.getElementById(ctrl2);
	ddlRet.selectedIndex = ddlColl.selectedIndex;
	
	
}



function locationValidation(ctrl1,ctrl2, val1, val2)
{
	var ddlColl = document.getElementById(ctrl1);
	var ddlRet = document.getElementById(ctrl2);
	var collVal = document.getElementById(val1);
	var retVal = document.getElementById(val2);
	var send = true;
	var valMsg = "";
	
	if (ddlColl.selectedIndex == 0)
	{
		collVal.style.display = '';
		send = false;
	}
	if (ddlRet.selectedIndex == 0)
	{
		retVal.style.display= '';
		send = false;
	}
	
	return send;
}


function ShowDetails(vehicleID)
{ 
	NewWindow=window.open('VehicleDetails.aspx?ID=' + vehicleID,'vehDetails','width=503,height=280,left=300,top=200,toolbar=No,location=No,scrollbars=yes,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);
 }


function toggleDetailsDiv(divName, divLink)
{
	var elm = document.getElementById(divName);
	var elm2 = document.getElementById(divLink);
	if (elm.style.display == 'block') 
	{
		elm.style.display='none';
		elm2.innerHTML = 'More Details.';
	}
	else 
	{
		elm.style.display='block'; 
		elm2.innerHTML = 'Less Details.';
	}
}

function toggleSearchDiv(ctrl1, ctrl2, ctrl3)
{

	var elm = document.getElementById(ctrl1);
	var elm2 = document.getElementById(ctrl2);
	var elm3 = document.getElementById(ctrl3);
	
	if (elm.style.display == 'block') 
	{
		elm.style.display='none';
		elm2.innerHTML = 'Edit Search';	
	}
	else 
	{
		elm.style.display='block';
		elm2.innerHTML = 'Hide Search'; 		
		window.scrollTo(0,document.body.scrollHeight);
		elm3.focus();
		self.scrollBy( 0,-250);	
	}
}

function termsChange(cbxID, btnID)
{
	var cbx = document.getElementById(cbxID);
	var btn = document.getElementById(btnID);
	if(cbx.checked == true)
    {
        btn.disabled = false;
		btn.src="images/btnSubmit.jpg";
    }
    else
    {
        btn.disabled = true;
		btn.src="images/btnSubmitOff.jpg";
    }
}




function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=1, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}