/* Calculation functions */function roundcurrency(number) {	if (number == 0) {		return '0.00';	} else {		var dol = number*100;		dol = Math.round(dol);		// dol = Math.abs(dol);		var dolstring = ""+dol;		var len = dolstring.length;		var endFig = dolstring.substring(0,len-2)+"."+dolstring.substring(len-2,len);		return endFig;	}}function calcTotal() {		var frmName = document.avMemberfrm;		frmName.Pay_Donation.value  = (frmName.Pay_Donation.value == "") ? "" : frmName.Pay_Donation.value;	frmName.Pay_Pins.value  = (frmName.Pay_Pins.value == "") ? "" : parseInt(frmName.Pay_Pins.value);		frmName.Pay_WristBands.value  = (frmName.Pay_WristBands.value == "") ? "" : parseInt(frmName.Pay_WristBands.value);		// var amount = frmName.Pay_Amount.value;	var amount = frmName.Orig_Amount.value;	// var origamount = frmName.Orig_Amount.value;		//donation value	donateValue = (frmName.Pay_Donation.value == "") ? 0 : frmName.Pay_Donation.value;		//pins value	pinsValue = (frmName.Pay_Pins.value == "") ? 0 : frmName.Pay_Pins.value;		//wristbands value	wristValue = (frmName.Pay_WristBands.value == "") ? 0 : frmName.Pay_WristBands.value;		// frmName.Pay_Amount.value = roundcurrency(parseFloat(amount) + parseFloat(donateValue) + (pinsValue*3) + (pensValue*3));	var totalCost = parseFloat(amount) + parseFloat(donateValue) + (pinsValue*3) + (wristValue*3);		frmName.Pay_Amount.value = totalCost.toFixed(2);	// var totalCheck = totalCost.split(".");	// alert(totalCheck[1].length);	// if (totalCheck[1].length == 2)	// {		// frmName.Pay_Amount.value = totalCost;	// }	// else	// {		// frmName.Pay_Amount.value = totalCost+'0';	// }			// if (isNaN(frmName.Pay_Amount.value))	// {		// frmName.Pay_Amount.value = origamount;	// }}function calcProductTotal() {	var frmName = document.frmProduct;	    //set null values to 0	if (frmName.PFDKN_FindingADifferentKindOfNormal.value == "") {    	pPFDKN = 0;    }    if (frmName.VUAS_UnderstandingAsperger.value == "") {    	pVUAS = 0;    }    if (frmName.VATY_AutismTeenVideo.value == "") {    	pVATY = 0;    }    if (frmName.PLP_AVPin.value == "") {    	pPLP = 0;    }		/*if (frmName.PSP_AVPen.value == "") {    	pPSP = 0;    }*/		if (frmName.PCKB_TogetherWeCook.value == "") {    	pCKB = 0;    }		if (frmName.PCKTM_CookingManual.value == "") {    	pCKTM = 0;    }		if (frmName.PLC_LibraryCat.value == "") {    	pPLC = 0;    }		if (frmName.PEB_EntertainmentBook.value == "") {    	pEB = 0;    }    if (frmName.AT2_AngelsTrees.value == "") {    	pAT2 = 0;    }     if (frmName.CB4_ChildrenBoxes.value == "") {     	pCB4 = 0;     }    if (frmName.KI3_KingsCard.value == "") {    	pKI3 = 0;    }    if (frmName.RE5_Reindeers.value == "") {    	pRE5 = 0;    }    if (frmName.BD1_BlueDove.value == "") {    	pBD1 = 0;    }		if (frmName.KO6_Koala.value == "") {    	pKO6 = 0;    }    if (frmName.SG7_SeasonsGreetings.value == "") {    	pSG7 = 0;    }    if (frmName.AS8_Assortment.value == "") {    	pAS8 = 0;    }        //Define and calculate the product sub-total	pPFDKN = roundcurrency(parseFloat(frmName.PFDKN_FindingADifferentKindOfNormal.value*40.95));    pVUAS = roundcurrency(parseFloat(frmName.VUAS_UnderstandingAsperger.value*71.50));    pVATY = roundcurrency(parseFloat(frmName.VATY_AutismTeenVideo.value*22.00));    pPLP = roundcurrency(parseFloat(frmName.PLP_AVPin.value*3.50));	/*pPSP = roundcurrency(parseFloat(frmName.PSP_AVPen.value*2.50));*/    pPLC = roundcurrency(parseFloat(frmName.PLC_LibraryCat.value*10.00));	pCKB = roundcurrency(parseFloat(frmName.PCKB_TogetherWeCook.value*57.00));	pCKTM = roundcurrency(parseFloat(frmName.PCKTM_CookingManual.value*29.95));	pEB = roundcurrency(parseFloat(frmName.PEB_EntertainmentBook.value*67.00));    pAT2 = roundcurrency(parseFloat(frmName.AT2_AngelsTrees.value*0.60));    pCB4 =roundcurrency(parseFloat(frmName.CB4_ChildrenBoxes.value*0.60));    pKI3 = roundcurrency(parseFloat(frmName.KI3_KingsCard.value*0.65));    pRE5 = roundcurrency(parseFloat(frmName.RE5_Reindeers.value*0.70));    pBD1 = roundcurrency(parseFloat(frmName.BD1_BlueDove.value*0.75));    pKO6 = roundcurrency(parseFloat(frmName.KO6_Koala.value*0.65));    pSG7 = roundcurrency(parseFloat(frmName.SG7_SeasonsGreetings.value*0.70));    pAS8 = roundcurrency(parseFloat(frmName.AS8_Assortment.value*5.50));//parseFloat(pPSP)	frmName.Pay_Amount.value = roundcurrency(parseFloat(pPFDKN) + parseFloat(pVUAS) + parseFloat(pVATY) + parseFloat(pPLP) + parseFloat(pPLC) + parseFloat(pCKB) + parseFloat(pCKTM) + parseFloat(pEB) + parseFloat(pAT2) + parseFloat(pCB4) + parseFloat(pKI3) + parseFloat(pRE5) + parseFloat(pBD1) + parseFloat(pKO6) + parseFloat(pSG7) + parseFloat(pAS8));}/* Search box funtions */function focusSearch() {	var d = document;	var frmTerms = d.getElementById('sp-q');		if (frmTerms.value == frmTerms.defaultValue) {		frmTerms.value = "";	}	frmTerms.focus();	return;}function init() {	var d = document;	var frmTerms = d.getElementById('sp-q');	frmTerms.value = 'Search Autism Victoria';	frmTerms.defaultValue = 'Search Autism Victoria';	frmTerms.onfocus = focusSearch;}if (document.getElementById) window.onload = init;function newWin(pName, pWidth, pHeight){	LeftPos=(screen.width)?(screen.width-pWidth)/2:100;	TopPos=(screen.height)?(screen.height-pHeight)/2:100;//	LeftPos=(screen.width/2)-w;//	TopPos=(screen.height/2)-h;		window.open('../home/'+pName,'newWindow','status=yes,scrollbars=yes,width='+pWidth+',height='+pHeight+',left='+LeftPos+',top='+TopPos);}function profileWin(pName){	LeftPos=(screen.width)?(screen.width-560)/2:100;	TopPos=(screen.height)?(screen.height-500)/2:100;//	LeftPos=(screen.width/2)-w;//	TopPos=(screen.height/2)-h;		window.open('profiles/'+pName,'newWindow','status=yes,scrollbars=yes,width=560,height=500,left='+LeftPos+',top='+TopPos);}function checkPayType(){	var frmName = document.frmProduct;    if (frmName.Payment_Type[0].checked == false && frmName.Payment_Type[1].checked == false)    {      alert("Please choose a payment type.");      return false;    }     return true;}function launchConference(){	/*avConf = new window();*/    sWidth = screen.width * .75;    sHeight = screen.height * .75;        LeftPos=(screen.width)?(screen.width-sWidth)/2:100;	TopPos=(screen.height)?(screen.height-sHeight)/2:100;	avConf = window.open('/conference/index.php','confWin','height='+sHeight+',width='+sWidth+',scrollbars=yes,status=yes,toolbar=yes,left='+LeftPos+',top='+TopPos);    avConf.focus();}function togglePayWindow(payOption){	if (payOption == "online")	{		document.getElementById('payOnline').style.display = "block";	}	else	{		document.getElementById('payOnline').style.display = "none";	}}function checkForm(form_name){  // specify field names to check  var fields_to_check = new Array('Card_Number', 'Expiry_Date', 'Cardholder_Name'); // CHANGE TO THE ONES YOU HAVE IN YOUR FORM  // loop through each field specified above, if length = 0, show alert msg and focus to that particular field.  for (i=0; i < fields_to_check.length; i++)  {    if ( eval('document.' +form_name+ '.' +fields_to_check[i]+ '.value.length') == 0)    {      var field_name = fields_to_check[i].replace('_', " ");      alert ('Please enter a valid ' +field_name+ '.');      eval('document.' +form_name+ '.' +fields_to_check[i]+ '.focus()');      eval('document.' +form_name+ '.' +fields_to_check[i]+ '.select()');      return false;    }  }		var cardCheck = -1;	  // Start checking special fields each with specific rules	for (i=eval('document.'+form_name+'.Card_Type.length')-1;i>-1; i--)	{		if (eval('document.'+form_name+'.Card_Type[i].checked'))		{			cardCheck = i;		}	}  	if (cardCheck == -1)	{		alert("Please choose a card type.");    return false;	}		/*if (eval('document.' +form_name+ '.Card_Type.selectedIndex') < 1 )  {    alert("Please choose a card type.");    eval('document.' +form_name+ '.Card_Type.focus()');    return false;  }*/    // seek confirmation  if ( !confirm("Click 'OK' if you are sure all the details you entered are correct... otherwise press 'Cancel' to correct them.") )  {    return false;  }}// change it to false if you do not want//the credit card number to be encryptedvar encrypt_it = true;function isCreditCard(st) {  // Encoding only works on cards with less than 19 digits  if (st.length > 19)    return (false);  sum = 0; mul = 1; l = st.length;  for (i = 0; i < l; i++) {    digit = st.substring(l-i-1,l-i);    tproduct = parseInt(digit ,10)*mul;    if (tproduct >= 10)      sum += (tproduct % 10) + 1;    else      sum += tproduct;    if (mul == 1)      mul++;    else      mul--;  }  if ((sum % 10) == 0)    return (true);  else    return (false);}function getCCNum(default_val) { msg = 'Please enter your credit card number here. '  + 'It will be '  + ((encrypt_it) ? "encrypted and then " : "")  + 'put into the credit card field of the form '  + 'after it is validated.'; return prompt(msg,default_val);}function encrypt(val) { val = "" + val; var result = ""; for (i=0;i<val.length;i++) {  character = val.charAt(i);  if ("0123456789".indexOf(character) != -1) {   character = parseInt(character);   character = (character+1)%10;  }  result += character; } if (result != "")  result += "e"; return result;}function unencrypt(val) { val = "" + val; for (n=0;n<9;n++)  val = encrypt(val); return (val.substring(0,val.indexOf('e')));}function strip(val) { val = "" + val; if (!val)  return ""; var result = ""; for (i=0;i<val.length;i++) {  character = val.charAt(i);  if ("0123456789".indexOf(character) != -1)   result += character; } return result;}function hideCC(val){	var newVal = val.substr(0,4);		for (i=4;i<val.length;i++)	{		newVal += "*";	}		document.avMemberfrm.Card_Number.value = val;	document.avMemberfrm.Card_Numbertmp.value = newVal;}var last_entry = "";function doCCStuff(form_element) { if (blur_reset) {   last_entry = form_element.value;   if (last_entry && last_entry.indexOf('e') != -1)     last_entry = unencrypt(last_entry);     entry = getCCNum(last_entry);     stripped_entry = strip(entry);     while (entry && (!isCreditCard(stripped_entry))) {       alert('The credit card number you entered could not be '       + 'validated. Please check the number and try again.');       last_entry = entry;       entry = getCCNum(last_entry);       stripped_entry = strip(entry);     }    if (entry) {      if (encrypt_it)			{        form_element.value = encrypt(entry);				hideCC(entry);			}      else			{        form_element.value = entry;			}    }    blur_form(form_element);  }  return false;}var blur_reset = true;function blur_form(form_element) {  form_element.blur();  blur_reset = false;  setTimeout("blur_reset=true",2000);}function submitIt() {  if (validatecard()  == false)    return false;    }function stripNonNumbers (InString) {  OutString = "";  for (Count=0; Count < InString.length; Count ++) {    TempChar = InString.substring(Count, Count+1);    Strip = false;    CharString="0123456789";      for (Countx = 0; Countx < CharString.length; Countx++) {        StripThis =         CharString.substring(Countx, Countx+1)        if (TempChar == StripThis) {          Strip = true;          break;        }     }     if (Strip)       OutString = OutString+TempChar;  }  return (OutString);}function validatecardfunc() {  validcard = false;  var CardNo = document.paymentfrm.ccnumber.value;  ret = stripNonNumbers(CardNo);  if (document.paymentfrm.cctype[0].checked)    result = "Visa";  else if (document.paymentfrm.cctype[1].checked)    result = "Mastercard";  else if (document.paymentfrm.cctype[2].checked)    result = "Diners";  else if (document.paymentfrm.cctype[3].checked)    result = "Bankcard";  else if (document.paymentfrm.cctype[4].checked)    result = "American Express";  if  (result == "Visa") {    if ((ret.length == 16) && (ret.substring(0, 1) == "5"))      validcard = true;  }  if (result == "American Express") {    if (ret.length == 15)      if ((ret.substring (0,2) == "45") || (ret.substring (0,2) == "48"))        validcard = true;  }  if (result == "Mastercard") {    if ((ret.length == 13) || (ret.length == 16))      if ((ret.substring (0,2) > "61") && (ret.substring (0,2) <= "66"))        validcard = true;  }  if (result == "Bankcard") {    if ((ret.length == 0))      validcard = false;    else      validcard = true;  }  if (result == "Diners") {    if ((ret.length == 0))      validcard = false;    else      validcard = true;  }  return(validcard)}function setDel(itemID){	document.frmProduct.del.value = itemID;	return true;}