function openPopup()
{
	newwin = window.open("popup.html","popup","width=400,height=350,scrollbars=no");
}
function ImageThumbnailsGranville(imageID){
	newwin = window.open("granville_thumbnail.html?image=" + imageID,"aerialview","width=708,height=540,scrollbars=no");
}
function ImageThumbnailsOther(imageID){
	newwin = window.open("other_thumbnail.html?image=" + imageID,"aerialview","width=708,height=540,scrollbars=no");
}
function ImageThumbnailsRail(imageID){
	newwin = window.open("rail_thumbnail.html?image=" + imageID,"aerialview","width=708,height=540,scrollbars=no");
}
function ImageThumbnailsGal(imageID){
	newwin = window.open("gal_thumbnail.html?image=" + imageID,"aerialview","width=708,height=540,scrollbars=no");
}
function navOver(imgName)
{
	var theImage = document.getElementById(imgName);
	
	if(theImage.src.indexOf("_off.gif") != -1)
	{
		theImage.src = theImage.src.replace("_off.gif","_over.gif");
	}
	else if(theImage.src.indexOf("_on.gif") != -1)
	{
		theImage.src = theImage.src.replace("_on.gif","_off.gif");
	}
	else
	{
		theImage.src = theImage.src.replace("_over.gif","_off.gif");
	}
}
function navDown(imgName)
{
	var theImage = document.getElementById(imgName);
	
	if(theImage.src.indexOf("_over.gif") != -1)
	{
		theImage.src = theImage.src.replace("_over.gif","_on.gif");	
	}
}


function getDealerLocation(state){
	
	var dealerElement = document.getElementById("dealerAddress");
	
	if(state == 'qld'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>Queensland</span><br/><br/>Contact your nearest Elders branch or click to contact Reid Rural directly.</div>";
	}
	if(state == 'nsw'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>New South Wales</span><br/><br/>Click to contact Reid Rural directly.</div>";
	}
	if(state == 'vic'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>Victoria</span><br/><br/>Click to contact Reid Rural directly.</div>";
	}
	if(state == 'tas'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>Tasmania</span><br/><br/>Click to contact Reid Rural directly.</div>";
	}
	if(state == 'sa'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>South Australia</span><br/><br/>Click to contact Reid Rural directly.</div>";
	}
	if(state == 'wa'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>Western Australia</span><br/><br/>Click to contact Reid Rural directly.</div>";
	}
	if(state == 'nt'){		
		dealerElement.innerHTML = " <div class='setDealerHeight'><span class='stateName'>Northern Territory</span><br/><br/>Click to contact Reid Rural directly.</div>";
	}	
}

function validateForm(theForm)
{
	valid = true;
	message = "So we can deal with your enquiry: \n\n";
	if(theForm.elements["firstname"].value == "")
	{
		message += "  Please enter your first name\n";
		valid = false;
	}
	if(theForm.elements["lastname"].value == "")
	{
		message += "  Please enter your last name\n";
		valid = false;
	}
	if(theForm.elements["phone"].value == "")
	{
		message += "  Please enter your phone number\n";
		valid = false;
	}
	
	var supEmail = theForm.elements["email"].value;
	var emLen = supEmail.length;
	var posAt = supEmail.indexOf('@')
	var posDot = supEmail.lastIndexOf('.')
	if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
	{
		message += "  Please enter a valid email address\n";
		valid = false;
	}
	if(valid)
	{
		return true;
	}
	else
	{
		alert(message);
		//createCustomAlert(message);
		return false;
	}
}


