function alphafix()
{
	//empty function runs if PNG transparency supported
}

function makeEmail(getName,getDomain)
{
	str = "<a href=\"mailto:"+getName+"@"+getDomain+"\">"+getName+"@"+getDomain+"</a>";
	document.write(str);
}

function checkService()
{
	getService = document.getElementById('services');
	getSel = getService.selectedIndex;
	getVal = getService.options[getSel].value;
	getP = document.getElementById('skipHireMenu');
	
	if (getVal == "Skip Hire")
	{
		strSkips = "<p>";
		strSkips = strSkips + "	<label for=\"skipHire\">Skip sizes</label>";
		strSkips = strSkips + "	<select name=\"skipHire\" id=\"skipHire\">";
		strSkips = strSkips + "		<option value=\"0\" selected=\"selected\">Please select a skip size</option>";
		strSkips = strSkips + "		<option value=\"5 Yard Midi\">5 Yard Midi</option>";
		strSkips = strSkips + "		<option value=\"8 Yard Builders\">8 Yard Builders</option>";
		strSkips = strSkips + "		<option value=\"8 Yard Enclosed\">8 Yard Enclosed</option>";
		strSkips = strSkips + "		<option value=\"14 Yard High Sides\">14 Yard High Sides</option>";
		strSkips = strSkips + "		<option value=\"14 Yard Enclosed\">14 Yard Enclosed</option>";
		strSkips = strSkips + "		<option value=\"20 Yard Roll On Roll Off\">20 Yard Roll On Roll Off</option>";
		strSkips = strSkips + "		<option value=\"35 Yard Roll On Roll Off\">35 Yard Roll On Roll Off</option>";
		strSkips = strSkips + "		<option value=\"40 Yard Roll On Roll Off\">40 Yard Roll On Roll Off</option>";
		strSkips = strSkips + "	</select>";
		strSkips = strSkips + "</p>";
		strSkips = strSkips + "<p>";
		strSkips = strSkips + "	* Please see Skip Hire page for more information on skip sizes.";
		strSkips = strSkips + "</p>";
		
		getP.innerHTML = strSkips;
		getP.style.display = "block";
	}
	else
	{
		getP.innerHTML = "";
		getP.style.display = "none";
	}
}

function checkQuote()
{
	chkErr = 0;
	strErr = "";
	
	getService = document.getElementById('services');
	getSel = getService.selectedIndex;
	getVal = getService.options[getSel].value;
	
	getEmail = document.getElementById('email').value;
	getCode = document.getElementById('security_code').value;
	
	if (document.getElementById('name').value == "")
	{
		chkErr = 1;
		strErr = strErr + "Please enter your name in the field provided\n";
	}
	if (document.getElementById('address').value == "")
	{
		chkErr = 1;
		strErr = strErr + "Please enter your address in the field provided\n";
	}
	if (document.getElementById('services').selectedIndex == 0)
	{
		chkErr = 1;
		strErr = strErr + "Please choose a service from the list provided\n";
	}
	if ((getVal == "Skip Hire") && (document.getElementById('skipHire').selectedIndex == 0))
	{
		chkErr = 1;
		strErr = strErr + "Please choose a skip size from the list provided\n";
	}
	if ((getEmail == "") || (!isValidEmail(getEmail)))
	{
		chkErr = 1;
		strErr = strErr + "Please enter a valid email address in the field provided.\n";
	}
	if (document.getElementById('contactNumber').value == "")
	{
		chkErr = 1;
		strErr = strErr + "Please enter your contact number in the field provided\n";
	}
	if (document.getElementById('description').value == "")
	{
		chkErr = 1;
		strErr = strErr + "Please enter a description of the work needed in the field provided\n";
	}
	
	if (getCode == "")
	{
		chkErr = 1;
		strErr = strErr + "Please enter the security code in the field provided\n\r";
	}
	if (chkErr == 1)
	{
		alert(strErr);
	}
	else
	{
		checkCaptcha();
	}
}

function isValidEmail(emailStr)
{
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray == null)
	{
		return false;
	}
	
	var user = matchArray[1];
	var domain = matchArray[2];
	
	if (user.match(userPat) == null)
	{
		 return false;
	}
	
	var IPArray = domain.match(ipDomainPat);
	
	if (IPArray != null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				return false;
			}
		}
		return true;
	}
	
	var domainArray = domain.match(domainPat);
	if (domainArray == null)
	{
		return false;
	}
	
	var atomPat = new RegExp(atom,"g");
	var domArr = domain.match(atomPat);
	var len = domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
		return false;
	}
	
	if (len<2)
	{
		return false;
	}
	
	return true;
}