//	Function for the registration form
function copyBilling() {
	var r = document.registration;
	if(r['Data[billingaddress1]'].value) { r['Data[deladdress1]'].value = r['Data[billingaddress1]'].value; }
	if(r['Data[companyname]'].value) { r['Data[delcompanyname]'].value = r['Data[companyname]'].value; }
	if(r['Data[billingaddress2]'].value) { r['Data[deladdress2]'].value = r['Data[billingaddress2]'].value; }
	if(r['Data[billingcity]'].value) { r['Data[delcity]'].value = r['Data[billingcity]'].value; }
	if(r['Data[billingcounty]'].value) { r['Data[delcounty]'].value = r['Data[billingcounty]'].value; }
	if(r['Data[billingpostcode]'].value) { r['Data[delpostcode]'].value = r['Data[billingpostcode]'].value; }
	if(r['Data[billingcountryid]'].value) { r['Data[delcountryid]'].value = r['Data[billingcountryid]'].value; }
	r['Data[billingpostcode]'].focus();
}

function checkDeletion(title, name)
{
	var tstr = "You have chosen to DELETE the " + title + " '" + name + "'!\n\nAre you sure that you want to do this?";
	return confirm(tstr);
}


function markDespatched(formID) {
	var children = document.getElementsByTagName('input');
	for (var i = 0; i < children.length; i++) {
		if(children[i].className=="despatch") {
			children[i].setAttribute("checked", "checked");
		}
	}
}

function markLabels(formID) {
	var children = document.getElementsByTagName('input');
	for (var i = 0; i < children.length; i++) {
		if(children[i].className=="label") {
			children[i].setAttribute("checked", "checked");
		}
	}
}

function leaveReview(inputForm) {
	var u="/reviewAccept.php";
	var d=$('replaceForm');

	var handlerFunc = function(t) {

		if(t.responseText=="okay") {
			d.innerHTML = "<p>Thank you for your review.  It will be checked by our website staff and added to the reviews for this product as soon as possible.</p>";
		} else {
			d.innerHTML = "<p>There was a problem submitting the review.  Please try again later.</p>";
		}
	}

	new Ajax.Request(u, {method:"post", onSuccess:handlerFunc, parameters:Form.serialize(inputForm)});
}

function showSendFriendWindow(prodid) {

	url = "/sendFriend.php?prodid=" + prodid;

	var win = new Window({className: "alphacube", title: "Send to Friend", maxWidth: 1000, maxHeight: 750, width: 400, height: 220, recenterAuto: true, url: url, showEffectOptions: {duration:1.5}});
	win.showCenter();
}

function showReviewWindow(prodid) {
	var win = new Window({className: "alphacube", title: "Leave a Review", width:500, height:350, url: "/reviewForm.php?prodid="+prodid, showEffectOptions: {duration:1.5}})
	win.showCenter();
}