function showhide()
{
	if(document.getElementById('package')[4].selected == true)
	{
		document.getElementById('otheramount').style.display = 'block';	
	}
	else
	{
		document.getElementById('otheramount').value = '0.00';
		document.getElementById('otheramount').style.display = 'none';	
	}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ValidateQuote()
{
	if(document.getElementById('_fname').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
	{
		alert('Please enter your First Name');
		document.getElementById('_fname').focus();
		return false;
	}
	if(document.getElementById('_lname').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
	{
		alert('Please enter your Last Name');
		document.getElementById('_lname').focus();
		return false;
	}
	if(document.getElementById('_email').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
	{
		alert('Please enter your Email address');
		document.getElementById('_email').focus();
		return false;
	}
	if(document.getElementById('_phone').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
	{
		alert('Please enter your phone number');
		document.getElementById('_phone').focus();
		return false;
	}
	if(document.getElementById('_photo').value.replace(/^\s*/, '').replace(/\s*$/, '') == "")
	{
		alert('Please select a photo to upload');
		document.getElementById('_photo').focus();
		return false;
	}
	return true
}


function ValidateOrder()
{
	if(document.getElementById('package')[0].selected == true)
	{
		alert('Please select the package');
		document.getElementById('package').focus();
		return false;
	}
	else
	{
		if((document.getElementById('package')[4].selected == true) && (document.getElementById('amount_other').value.replace(/^\s*/, '').replace(/\s*$/, '') == ""))
		{
			alert('Please enter the amount');
			document.getElementById('amount_other').focus();
			return false;
		}
		else
		{
			if(!validChars('form1','amount_other','1234567890.'))
				{
					alert('Please enter a valid amount. - E.g. $100.00');
					document.form1.amount_other.select();
					return false
				}
		}
		moneyFormat(document.form1.amount_other);	
	}
	if(document.getElementById('amount_other').value.replace(/^\s*/, '').replace(/\s*$/, '') != "0.00")
		{
			
			document.getElementById('chargetotal').value = document.getElementById('amount_other').value;
		}
	else
		{
		document.getElementById('chargetotal').value = document.getElementById('package')[document.getElementById('package').selectedIndex].value;
		}
	return true;
}

//#############################################
// ONLY VALID CHARACTERS
function validChars(formName,fieldName,validChars)
{
	var ok = 'yes';
	var strName = eval('document.' + formName + '.' + fieldName + '.value');
	var temp;
	for (var i=0; i<strName.length; i++)
		{
			temp = eval('document.' + formName + '.' + fieldName + '.value.substring(i, i+1);')
			if (validChars.indexOf(temp) == "-1")
				{
					return false
				}
		}
	return true;
}
//#############################################
//#############################################
// FORMAT CURRENCY
function moneyFormat(textObj)
{ 
			var newValue = textObj.value 
			var decAmount = "" 
			var dolAmount = "" 
			var decFlag = false 
			var aChar = "" 

		// ignore all but digits and decimal points 
			for (i=0; i < newValue.length; i++) { 
						aChar = newValue.substring(i,i+1) 
						if(aChar >= "0" && aChar <= "9") { 
									if(decFlag) { 
												decAmount = "" + decAmount + aChar 
									} 
									else { 
												dolAmount = "" + dolAmount + aChar 
									} 
						} 
						if(aChar == ".") { 
									if(decFlag) { 
												dolAmount = "" 
												break 
									} 
									decFlag=true 
						} 
			} 
			// Ensure that at least a zero appears for the dollar amount. 
			if(dolAmount == "") { 
						dolAmount = "0" 
			} 
			// Strip leading zeros. 
			if(dolAmount.length > 1) { 
						while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") { 
									dolAmount = dolAmount.substring(1,dolAmount.length) 
						} 
			} 
			// Round the decimal amount. 
			if(decAmount.length > 2) { 
						if(decAmount.substring(2,3) > "4") { 
									decAmount = parseInt(decAmount.substring(0,2)) + 1 
												if(decAmount < 10) { 
															decAmount = "0" + decAmount 
												} 
												else { 
														   decAmount = "" + decAmount 
												} 
									} 
									else { 
												decAmount = decAmount.substring(0,2) 
									} 
									if (decAmount == 100) { 
												decAmount = "00" 
												dolAmount = parseInt(dolAmount) + 1 
									} 
						} 
						// Pad right side of decAmount 
						if(decAmount.length == 1) { 
									decAmount = decAmount + "0" 
						} 
						if(decAmount.length == 0) { 
									decAmount = decAmount + "00" 
						} 
			// Check for negative values and reset textObj 
			if(newValue.substring(0,1) != '-' || (dolAmount == "0" && decAmount == "00")) { 
						textObj.value = dolAmount + "." + decAmount 
			} 
			else{ 
						textObj.value = '-' + dolAmount + "." + decAmount 
			} 
}
//#############################################
