function verifyEmailAddress() {
	email = document.getElementById('email').value.toLowerCase();
	verifyEmail = document.getElementById('verifyEmail').value.toLowerCase();
	if (email != verifyEmail)
		alert('Email addresses do not match\nPlease ensure \'Email\' and \'Confirm Email\' match.');
	else if (email.indexOf('hotmail.com.au') != -1 ||
	 		 email.indexOf('gmail.com.au') != -1 ||
	 		 email.indexOf('con.au') != -1 ||
	 		 email.indexOf('bidpond') != -1)
	 	alert('Invalid Email Addresses\nPlease check the email address you have entered.');
	else
		document.getElementById('createAccountForm').submit();
}

function displayInformation(divArea) {
	if (document.getElementById('toc') != null) {
		document.getElementById('toc').style.display= 'none';
		document.getElementById('toc-link').style.background = "#a5c49d";
	}
	if (document.getElementById('product-description') != null) {
		document.getElementById('product-description').style.display= 'none';
		document.getElementById('product-description-link').style.background = "#a5c49d";
	}
	if (document.getElementById('reviews') != null) {
		document.getElementById('reviews').style.display= 'none';
		document.getElementById('reviews-link').style.background = "#a5c49d";
	}
	if (document.getElementById('look-inside') != null) {
		document.getElementById('look-inside').style.display= 'none';
		document.getElementById('look-inside-link').style.background = "url('http://images.booktopia.com.au/gbs_preview_sticker.gif')";
	}
	document.getElementById('details').style.display= 'none';
	document.getElementById('details-link').style.color = '#000000';
	document.getElementById('details-link').style.background = '#a5c49d';
	
	document.getElementById(divArea).style.display = 'block';
	
	if (divArea == 'look-inside') {
		document.getElementById(divArea+'-link').style.background = "url('http://images.booktopia.com.au/gbs_preview_sticker_active.gif')";
		showLookInside();
	}
	else {
		document.getElementById(divArea+'-link').style.background = '#DBE8D7';
	}
	
}

function giftWrappingChecked() {
   if (document.getElementById('giftWrapping').checked)
   	 document.getElementById('giftMessage').style.display='block';
   else
     document.getElementById('giftMessage').style.display='none';
}

function disable(element) {
	element.disabled = true;
}

function popupWindow(url, width, height) {
	window.open(url,'','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width='+width+', height='+height);
}
function createMessage() {
	popupWindow('create-message.ep',680,420);
}

function productPopups(binding, preOrder) {
	return (checkFormat(binding) && (!preOrder || checkPreOrder()));
}

function checkFormat(binding) {
	bindingStr = binding;
    if ("CD" == binding || "CR" == binding || "MP3" == binding || "M3" == binding || "C3" == binding) {
       if ("CR" == binding)
           bindingStr = "CD-ROM";
       else if ("C3" == binding)
           bindingStr = "CD MP3";
       if ("M3" == binding)
           bindingStr = "MP3";
       return confirm("This title is NOT A BOOK.  The format is " + bindingStr + ".\n\nPurchase of this product is on a firm-sale, non-returnable basis.\n\nPlease click 'OK' if you wish to add this product to your Shopping Basket, otherwise click 'Cancel' to continue browsing.");
    }
    return true;
}

function checkPreOrder() {
    return confirm("This title is not yet published.\n\nPlease pay attention to the publication date of this title.\n\nBooktopia is taking pre-orders at the moment. An up-front payment is required to place a pre-order.\n\nPress \"OK\" to place a pre-order for this title.\nPress \"Cancel\" if you wish to wait until closer to the publication date to place your pre-order.");
}

function actionMessage(message) {
	return message == '' || confirm(message);
}	
function popup2ue(url) {
	newWindow=window.open(url,'MediaPlayer','height=500,width=340');
	if (window.focus) {
		newWindow.focus();
	}
	return false;
} 

/**
 * toggled - a boolean, if true, enables the checkboxes, else disables
 */
function toggleNewsletterPreferences(toggled) {
	checkbox = null;
	
	for (var i = 1; i <= 12; i++) {
		checkbox = document.getElementById("newsletter" + i);
		checkbox.disabled=!toggled;
	}
}