/***********************************************
* Bullet Link script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//Write out bullet image. Change "mybullet.gif" below to desired image path:
var bulletimg='<img id="bullet" style="position:absolute; left: -300px" src="../images/arrow.gif">'

var bulletoffX=2 //Set horizontal offset of bullet image from link's root. (ie: -2 or 5)
var bulletoffY=5 //Set vertical offset of bullet image from link's root. (ie: -2 or 5)

function caloffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function displaybullet(linkobj){
bulletobj.style.left=caloffset(linkobj, "left")-bulletobj.width-bulletoffX+"px"
bulletobj.style.top=caloffset(linkobj, "top")-bulletoffY+linkobj.offsetHeight/3+"px"
bulletobj.style.visibility="visible"
}

function modifylinks(){
bulletobj=document.all? document.all.bullet : document.getElementById("bullet")
for (i=0; i<document.links.length; i++){
if (document.links[i].className=="linkcell3"){
document.links[i].onmouseover=function(){displaybullet(this)}
document.links[i].onmouseout=function(){bulletobj.style.visibility="hidden"}
}
}
}

if (document.all || document.getElementById)
document.write(bulletimg)

if (window.addEventListener)
window.addEventListener("load", modifylinks, false)
else if (window.attachEvent)
window.attachEvent("onload", modifylinks)
else if (document.getElementById || document.all)
window.onload=modifylinks


	function CheckChoice(whichbox)
	{
		with (whichbox.form)
		{
			//Handle differently, depending on type of input box.
			if (whichbox.type == "radio")
			{
				//First, back out the prior radio selection's price from the Amount:
				hiddenAmount.value = eval(hiddenAmount.value) - eval(hiddenpriorradio.value);
				//Then, save the current radio selection's price:
				hiddenpriorradio.value = eval(whichbox.price);
				//Now, apply the current radio selection's price to the Amount:
				hiddenAmount.value = eval(hiddenAmount.value) + eval(whichbox.price);
			}
			else
			{
				//If box was checked, accumulate the checkbox value as the form Amount,
				//Otherwise, reduce the form Amount by the checkbox value:
				if (whichbox.checked == false)
					{ hiddenAmount.value = eval(hiddenAmount.value) - eval(whichbox.value); }
				else 	{ hiddenAmount.value = eval(hiddenAmount.value) + eval(whichbox.value); }
			}

			//Ensure the Amount never goes negative (some browsers allow radiobutton to be deselected):
			if (hiddenAmount.value < 0)
				{
				InitForm();
				}

			//Now, return with formatted Amount:
			return(formatCurrency(hiddenAmount.value));
		}
	}

	//Define function to format a value as currency:
	function formatCurrency(num)
	{
	   // Courtesy of http://www7.brinkster.com/cyanide7/
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		   num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		    cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		    num = num.substring(0,num.length-(4*i+3))+','+
		          num.substring(num.length-(4*i+3));
  	    return (((sign)?'':'-') + '$' + num + '.' + cents);
	}

	//Define function to init the form on reload:
	function InitForm()
		{
		//Reset the displayed Amount on form:
		document.form.Amount.value='$0.00';
		document.form.hiddenAmount.value=0.00;
		document.form.hiddenpriorradio.value=0.00;

		//Set all checkboxes and radio buttons on form-1 to unchecked:
		for (xx=0; xx < document.form.elements.length; xx++)
		{
		   if (document.form.elements[xx].type == 'checkbox' | document.form.elements[xx].type == 'radio')
			{
			document.form.elements[xx].checked = false;
			}
		}
	}

//  End -->

var Service_Street = "";
var Service_Suburb = "";
var Service_State = 0;
var Service_Postcode = "";
var Service_Phone = "";

function InitSaveVariables(form) {
Service_Street = form.Service_Street.value;
Service_Suburb = form.Service_Suburb.value;
Service_StateIndex = form.Service_State.selectedIndex;
Service_State = form.Service_State[Service_StateIndex].value;
Service_Postcode = form.Service_Postcode.value;
Service_Phone = form.Service_Phone.value;
}

function DSLaddress(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.Service_Street.value = form.Customer_Street.value;
form.Service_Suburb.value = form.Customer_Suburb.value;
form.Service_State.selectedIndex = form.Customer_State.selectedIndex;
form.Service_Postcode.value = form.Customer_Postcode.value;
form.Service_Phone.value = form.Customer_Phone.value;
}
else {
form.Service_Street.value = Service_Street;
form.Service_Suburb.value = Service_Suburb;
form.Service_State.selectedIndex = Service_StateIndex;
form.Service_Postcode.value = Service_Postcode;
form.Service_Phone.value = Service_Phone;
   }
}
//  End -->

//AUTOMATIC JUMP FIELD BEGIN
var downStrokeField;
function autojump(fieldName,nextFieldName,fakeMaxLength)
{
var myForm=document.forms[document.forms.length - 1];
var myField=myForm.elements[fieldName];
myField.nextField=myForm.elements[nextFieldName];

if (myField.maxLength == null)
myField.maxLength=fakeMaxLength;
myField.onkeydown=autojump_keyDown;
myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown()
{
this.beforeLength=this.value.length;
downStrokeField=this;
}

function autojump_keyUp()
{
if (
	(this == downStrokeField) &&   (this.value.length > this.beforeLength) &&   (this.value.length >= this.maxLength)
)
this.nextField.focus();
downStrokeField=null;
}
//-->

function validateform()
{
if ((document.form.realname.value==""))
{
window.alert ("Please enter your name.")
return false;
}
if ((document.form.email.value==""))
{
window.alert ("Please enter your e-mail address.")
return false;
}
}
//-->

