var varClickObj = 1

 // =============================================
function updateCart(thisForm) {

	iDiv = $('cartInfoPanel')
	var url = 'ajax_gateway_cartUpdate.asp?action=update';
	var myAjax = new Ajax.Updater(iDiv, url, { asynchronous:true, parameters:Form.serialize(thisForm),
	onComplete: function(transport)
	{

		if ($('cartTable') == null)
			$('cartActionsPanel').style.display = "none"
	}
	});

	}



function computeTotal(varIndex){
	var i=0, iTotal = 0, iTemp

	if (isNaN($F("txt_quantity" + varIndex)) || trim($F("txt_quantity" + varIndex)) == '')
		document.getElementById("txt_quantity" + varIndex).value = '0'

	iTemp = parseFloat($F("txt_quantity" + varIndex)) * parseFloat($F("hidPrice" + varIndex))

	$('prodTotal' + varIndex).innerHTML = "$" + iTemp.toFixed(2)

	while ($("txt_quantity" + i ) != null)
	{

		iTemp = parseInt($F("txt_quantity" + i)) * parseFloat($F("hidPrice" + i))
		iTotal = iTotal + iTemp
		i++;
	}
	$('totalBill').innerHTML = "$" + iTotal.toFixed(2).toString()
}


function purchase(varBuyMode)
{
	if ($('txt_quantity0') == null)
	{
		alert("Cart is empty")
		return;
	}

	document.forms[0].action = "buydetails.asp"
	document.forms[0].hid_orderType.value = varBuyMode
	document.forms[0].submit();
}

function checkNumeric(event)
{
	var keyCode
	if (event.which != null)
		keyCode = event.which
	else
		keyCode = event.keyCode


	if (!((keyCode >=48 && keyCode <=57) || keyCode == 8 || keyCode ==0))
			return false;

}

//checking on customers contact details for buying and ordering
function goCheckOut()
{
	if (trim($('txt_fname').value) == "")
	{
		alert("Please enter your First name.")
		$('txt_fname').focus()
		return false;
	}

	if (trim($('txt_lname').value) == "")
	{
		alert("Please enter your Last name.")
		$('txt_lname').focus()
		return false;
	}

	if (trim($('txt_phone').value) == "")
	{
		alert("Please enter your Phone number.")
		$('txt_phone').focus()
		return false;
	}

	if (trim($('txt_email').value) == "")
	{
		alert("Please enter your Email address.")
		$('txt_email').focus()
		return false;
	}else
	{
		 if (validateEmail($('txt_email')) == false)
			return false;
	}

	
	if (trim($('txt_address1').value) == "")
	{
		alert("Please enter your Address.")
		$('txt_address1').focus()
		return false;
	}

	if (trim($('txt_town').value) == "")
	{
		alert("Please enter your Town/suburb.")
		$('txt_town').focus()
		return false;
	}

	if (trim($('txt_postcode').value) == "")
	{
		alert("Please enter your Postcode.")
		$('txt_postcode').focus()
		return false;
	}
}

function savePurchase()
{
/*
	if ($('sel_Day').value == "0")
	{
		alert("Please choose preferred delivery day.")
		$('sel_Day').focus()
		return false;
	}

	if ($('sel_Time').value == "0")
	{
		alert("Please choose preferred delivery time.")
		$('sel_Time').focus()
		return false;
	}
*/
	/*
	if ($('txt_cardNumber') != null)
	{
		if (trim($('txt_cardNumber').value) == "")
		{
			alert("Please enter Credit Card Number.")
			$('txt_cardNumber').focus()
			return false;
		}
	}
	*/
	/*if ($('txtIns') != null)
	{
		if (trim($('txt_fname').value) == "")
		{
			alert("Please enter your First Name.")
			$('txt_fname').focus()
			return false;
		}

		if (trim($('txt_lname').value) == "")
		{
			alert("Please enter your Last Name.")
			$('txt_lname').focus()
			return false;
		}

		if (trim($('txt_email').value) == "")
		{
			alert("Please enter your email address.")
			$('txt_email').focus()
			return false;
		}


	}*/
	document.forms[0].hid_checkoutStatus.value = "dbsave"

}

function changeDetail()
{

	var url = 'ajax_gateway_contact.asp?action=update';
	var myAjax = new Ajax.Updater( $('contactPanel'), url, { asynchronous:true, parameters:Form.serialize(document.forms[0]) });

}

function submitProductEnquiry()
{
	if (trim(document.frmContactUs.txt_fname.value) == "")
	{
		alert("Please enter your First Name.")
		document.frmContactUs.txt_fname.focus()
		return false;
	}

	if (trim(document.frmContactUs.txt_lname.value) == "")
	{
		alert("Please enter your Last Name.")
		document.frmContactUs.txt_lname.focus()
		return false;
	}

	if (trim(document.frmContactUs.txt_email.value) == "")
	{
		alert("Please enter your email address.")
		document.frmContactUs.txt_email.focus()
		return false;
	}else
	{
		 if (validateEmail(document.frmContactUs.txt_email) == false)
			return false;
	}

	//document.frmContactUs.hid_EnquiryType.value = document.frmContactUs.sel_enquiry.options[document.frmContactUs.sel_enquiry.selectedIndex].text
	//document.frmContactUs.hid_detail.value = document.frmContactUs.txa_detail.value
	//document.frmContactUs.submit();
}

function zoomPic()
{
	var win

	win = window.open("", "winClient", "")

	if (win != null)
		win.focus();

	/*document.forms[0].hidZoomImage.value = varImgPath
	document.forms[0].target = "winClient"
	document.forms[0].action = "zoomImg.asp"
	document.forms[0].submit();*/
}


function loadPDF(varPDFPath)
{
	var win


	window.name = "winMain"
	win = window.open(varPDFPath, "winClient", "")

	if (win != null)
		win.focus();

}

function submitEnquiry()
{
	if (trim($('txt_fname').value) == "")
	{
		alert("Please enter your First Name.")
		$('txt_fname').focus()
		return false;
	}

	if (trim($('txt_lname').value) == "")
	{
		alert("Please enter your First Name.")
		$('txt_lname').focus()
		return false;
	}

	if (trim($('txt_phone').value) == "")
	{
		alert("Please enter your Daytime contact number.")
		$('txt_phone').focus()
		return false;
	}


	if (trim($('txt_email').value) != "")
	{
		if (validateEmail($('txt_email')) == false)
			return false;
	}

	if ($('sel_enquiry').value == "")
	{
		alert("Please choose the nature of your enquiry.")
		$('sel_enquiry').focus()
		return false;
	}



}

function subscribe()
{
	if (trim(document.frmSubscribe.txt_fname.value) == "")
	{
		alert("Please enter your First Name.")
		document.frmSubscribe.txt_fname.focus()
		return false;
	}

	if (trim(document.frmSubscribe.txt_lname.value) == "")
	{
		alert("Please enter your Last Name.")
		document.frmSubscribe.txt_lname.focus()
		return false;
	}

	if (trim(document.frmSubscribe.txt_email.value) == "")
	{
		alert("Please enter your email address.")
		document.frmSubscribe.txt_email.focus()
		return false;
	}else
	{
		 if (validateEmail(document.frmSubscribe.txt_email) == false)
			return false;
	}

}

function unsubscribe()
{
	if (trim(document.frmSubscribe.txt_email.value) == "")
	{
		alert("Please enter your email address.")
		document.frmSubscribe.txt_email.focus()
		return false;
	}else
	{
		 if (validateEmail(document.frmSubscribe.txt_email) == false)
			return false;
	}

}

function getClick(varClick)
{

	varClickObj = varClick
}

function displayStaticMessage(messageContent,cssClass)
{
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(300,150);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes
	messageObj.display();


}
function processCart(thisForm)
{


	if (varClickObj == 3)
	{
		updateCart(thisForm)
		return false;
	}else
	{
		document.forms[0].hid_orderType.value = varClickObj
	}

	return true;
}


function button_mouseover(thisButton, varImage)
{
	thisButton.src = varImage
}

function button_mouseout(thisButton, varImage)
{
	thisButton.src = varImage
}
