
var submitcount=0; 



function validate_checkout() {

document.form.title.style.backgroundColor='ffffff';
document.form.name.style.backgroundColor='ffffff';
document.form.surname.style.backgroundColor='ffffff';
document.form.email.style.backgroundColor='ffffff';
document.form.phone.style.backgroundColor='ffffff';
document.form.address_one.style.backgroundColor='ffffff';
document.form.suburb.style.backgroundColor='ffffff';
document.form.postcode.style.backgroundColor='ffffff';
document.form.state.style.backgroundColor='ffffff';
document.form.country.style.backgroundColor='ffffff';
document.form.recipient_name.style.backgroundColor='ffffff';
document.form.saddress_one.style.backgroundColor='ffffff';
document.form.ssuburb.style.backgroundColor='ffffff';
document.form.spostcode.style.backgroundColor='ffffff';
document.form.sstate.style.backgroundColor='ffffff';
document.form.day.style.backgroundColor='ffffff';
document.form.month.style.backgroundColor='ffffff';
document.form.year.style.backgroundColor='ffffff';

Fname=form.email_login.value;
if (Fname=='') {

Fname=form.title.value;
if (Fname=='') {
document.form.title.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.shipping.value;
if (Fname=='') {
document.form.shipping.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.name.value;
if (Fname=='') {
document.form.name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.surname.value;
if (Fname=='') {
document.form.surname.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.email.value;
if (Fname=='') {
document.form.email.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.phone.value;
if (Fname=='') {
document.form.phone.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.address_one.value;
if (Fname=='') {
document.form.address_one.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.suburb.value;
if (Fname=='') {
document.form.suburb.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

if (form.country.value == 'Australia') {

Fname=form.postcode.value;
if (Fname=='') {
document.form.postcode.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.state.value;
if (Fname=='') {
document.form.state.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}
}



Fname=form.country.value;
if (Fname=='') {
document.form.country.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}




Fname=form.recipient_name.value;
if (Fname=='') {
document.form.recipient_name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.saddress_one.value;
if (Fname=='') {
document.form.saddress_one.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.ssuburb.value;
if (Fname=='') {
document.form.ssuburb.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.spostcode.value;
if (Fname=='') {
document.form.spostcode.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.sstate.value;
if (Fname=='') {
document.form.sstate.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}


Fname=form.day.value;
if (Fname=='') {
document.form.day.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.month.value;
if (Fname=='') {
document.form.month.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.year.value;
if (Fname=='') {
document.form.year.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}


}

if (Alert =='yes') {
alert('You must complete all required entries.');
event.returnValue=false;
}

}



function billtoship() {



if (document.form.country.value == 'Australia') {

document.form.saddress_one.value = document.form.address_one.value;
document.form.saddress_two.value = document.form.address_two.value;
document.form.ssuburb.value = document.form.suburb.value;
document.form.sstate.value = document.form.state.value;
document.form.spostcode.value = document.form.postcode.value;
document.form.scountry.value = document.form.country.value;


document.form.recipient_name.focus();







}
else {
alert('You can only ship to an Australian Address.');
document.form.same.checked = false;

}

}


function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}






function validate_login() {

document.form.email_login.style.backgroundColor='ffffff';
document.form.password_login.style.backgroundColor='ffffff';

Fname=form.password_login.value;
if (Fname=='') {
document.form.password_login.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.email_login.value;
if (Fname=='') {
document.form.email_login.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}


if (Alert =='yes') {
alert('Please enter both a valid email address and your password.');
event.returnValue=false;
}

}




function validate_register() {

document.form.title.style.backgroundColor='ffffff';
document.form.name.style.backgroundColor='ffffff';
document.form.surname.style.backgroundColor='ffffff';
document.form.email.style.backgroundColor='ffffff';
document.form.phone.style.backgroundColor='ffffff';
document.form.address_one.style.backgroundColor='ffffff';
document.form.suburb.style.backgroundColor='ffffff';
document.form.postcode.style.backgroundColor='ffffff';
document.form.state.style.backgroundColor='ffffff';
document.form.country.style.backgroundColor='ffffff';
document.form.password.style.backgroundColor='ffffff';
document.form.emailtwo.style.backgroundColor='ffffff';

Fname=form.emailtwo.value;
if (Fname=='') {
document.form.emailtwo.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.title.value;
if (Fname=='') {
document.form.title.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.name.value;
if (Fname=='') {
document.form.name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.surname.value;
if (Fname=='') {
document.form.surname.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.email.value;
if (Fname=='') {
document.form.email.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.phone.value;
if (Fname=='') {
document.form.phone.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.address_one.value;
if (Fname=='') {
document.form.address_one.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.suburb.value;
if (Fname=='') {
document.form.suburb.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}



Fname=form.country.value;
if (Fname=='') {
document.form.country.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.password.value;
if (Fname=='') {
document.form.password.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}



if (Alert =='yes') {
alert('You must complete all required entries.');
event.returnValue=false;
}

}




function validate_register_modify() {

document.form.title.style.backgroundColor='ffffff';
document.form.name.style.backgroundColor='ffffff';
document.form.surname.style.backgroundColor='ffffff';
document.form.email.style.backgroundColor='ffffff';
document.form.phone.style.backgroundColor='ffffff';
document.form.address_one.style.backgroundColor='ffffff';
document.form.suburb.style.backgroundColor='ffffff';
document.form.postcode.style.backgroundColor='ffffff';
document.form.state.style.backgroundColor='ffffff';
document.form.country.style.backgroundColor='ffffff';
document.form.password.style.backgroundColor='ffffff';

Fname=form.title.value;
if (Fname=='') {
document.form.title.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}



Fname=form.name.value;
if (Fname=='') {
document.form.name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.surname.value;
if (Fname=='') {
document.form.surname.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.email.value;
if (Fname=='') {
document.form.email.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.phone.value;
if (Fname=='') {
document.form.phone.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.address_one.value;
if (Fname=='') {
document.form.address_one.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.suburb.value;
if (Fname=='') {
document.form.suburb.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.postcode.value;
if (Fname=='') {
document.form.postcode.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.state.value;
if (Fname=='') {
document.form.state.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.country.value;
if (Fname=='') {
document.form.country.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.password.value;
if (Fname=='') {
document.form.password.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}




if (Alert =='yes') {
alert('You must complete all required entries.');
event.returnValue=false;
}

}






function validate_payment() {

document.form.type.style.backgroundColor='ffffff';
document.form.card_name.style.backgroundColor='ffffff';
document.form.card_number.style.backgroundColor='ffffff';
document.form.card_exp_year.style.backgroundColor='ffffff';
document.form.card_exp_month.style.backgroundColor='ffffff';


Fname=form.type.value;
if (Fname=='') {
document.form.type.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}
Fname=form.card_name.value;
if (Fname=='') {
document.form.card_name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}
Fname=form.card_number.value;
if (Fname=='') {
document.form.card_number.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}
Fname=form.cvn.value;
if (Fname=='') {
document.form.cvn.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.card_exp_month.value;
if (Fname=='') {
document.form.card_exp_month.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.card_exp_year.value;
if (Fname=='') {
document.form.card_exp_year.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

if (Alert =='yes') {
alert('You must complete all required entries.');
event.returnValue=false;
}
else {
if (submitcount == 0) 
{ submitcount++; return true; } 
else 
{ alert('Please wait processing your payment.' ); return false; } 
}

}



function validate_register_event() {

document.form.day.style.backgroundColor='ffffff';
document.form.month.style.backgroundColor='ffffff';
document.form.name.style.backgroundColor='ffffff';
document.form.event.style.backgroundColor='ffffff';


Fname=form.title.value;
if (Fname=='') {
document.form.name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}



Fname=form.name.value;
if (Fname=='') {
document.form.name.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.day.value;
if (Fname=='') {
document.form.day.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.month.value;
if (Fname=='') {
document.form.month.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}

Fname=form.event.value;
if (Fname=='') {
document.form.event.style.backgroundColor='FEE2F5';
var Alert = 'yes';
}


if (Alert =='yes') {
alert('You must complete all required entries.');
event.returnValue=false;
}

}


function copyover() {

document.form.shipping.value = document.form.phone.value;
document.form.saddress_one.value = document.form.address_one.value;
document.form.saddress_two.value = document.form.address_two.value;
document.form.ssuburb.value = document.form.suburb.value;
document.form.sstate.value = document.form.state.value;
document.form.spostcode.value = document.form.postcode.value;


var myindex=document.form.country.selectedIndex;
if (document.form.country.options[myindex].value != "0") {   	
var One = document.form.country.options[myindex].value;

document.form.scountry.options[0]=new Option(One, One, true, true);
}


document.form.recipient_name.focus();

}







function UpdateTotal(price) {
document.orderform.ntotal.value = price;

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber;


}



function get_radio_value()
{
for (var i=0; i < document.orderform.split.length; i++)
   {
   if (document.orderform.music[i].checked)
      {
      var rad_val = document.orderform.music[i].value;
      }
   }
}

function ChooseC(CFone) {

var fone = CFone.split(":");
document.orderform.c_cat_id.value = fone[0];
document.orderform.c_price.value = fone[1];
document.orderform.c_name.value = fone[2];
document.orderform.c_description.value = fone[3];

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);


var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

document.getElementById('chocolates').style.display = "block";
document.getElementById('chocolates').innerHTML   = "<p>" + fone[2] + " \$ " + fone[1] + " <a href='javascript:RemoveC()'>remove</a></p>";


}

function ChooseV(VFone) {

var fone = VFone.split(":");
document.orderform.v_cat_id.value = fone[0];
document.orderform.v_price.value = fone[1];
document.orderform.v_name.value = fone[2];
document.orderform.v_description.value = fone[3];

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

document.getElementById('vases').style.display = "block";
document.getElementById('vases').innerHTML   = "<p>" + fone[2] + " \$ " + fone[1] + " <a href='javascript:RemoveV()'>remove</a></p>";


}

function ChooseT(TFone) {

var fone = TFone.split(":");
document.orderform.t_cat_id.value = fone[0];
document.orderform.t_price.value = fone[1];
document.orderform.t_name.value = fone[2];
document.orderform.t_description.value = fone[3];

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

document.getElementById('teddy').style.display = "block";
document.getElementById('teddy').innerHTML   = "<p>" + fone[2] + " \$ " + fone[1] + " <a href='javascript:RemoveT()'>remove</a></p>";


}

function ChooseB(BFone) {

var fone = BFone.split(":");
document.orderform.b_cat_id.value = fone[0];
document.orderform.b_price.value = fone[1];
document.orderform.b_name.value = fone[2];
document.orderform.b_description.value = fone[3];

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

document.orderform.total.value = TotalValue; 

document.getElementById('balloons').style.display = "block";
document.getElementById('balloons').innerHTML   = "<p>" + fone[2] + " \$ " + fone[1] + " <a href='javascript:RemoveB()'>remove</a></p>";


}

function ChooseW(BFone) {

var fone = BFone.split(":");
document.orderform.w_cat_id.value = fone[0];
document.orderform.w_price.value = fone[1];
document.orderform.w_name.value = fone[2];
document.orderform.w_description.value = fone[3];

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber;  

document.getElementById('wine').style.display = "block";
document.getElementById('wine').innerHTML   = "<p>" + fone[2] + " \$ " + fone[1] + " <a href='javascript:RemoveW()'>remove</a></p>";


}

function ChooseG(BFone) {

var fone = BFone.split(":");
document.orderform.g_cat_id.value = fone[0];
document.orderform.g_price.value = fone[1];
document.orderform.g_name.value = fone[2];
document.orderform.g_description.value = fone[3];

var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

document.getElementById('glass').style.display = "block";
document.getElementById('glass').innerHTML   = "<p>" + fone[2] + " \$ " + fone[1] + " <a href='javascript:RemoveG()'>remove</a></p>";


}

function RemoveC() {

document.orderform.c_cat_id.value = "";
document.orderform.c_price.value = "";
document.orderform.c_name.value = "";
document.orderform.c_description.value = "";
document.getElementById('chocolates').style.display = "none";
var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

document.orderform.total.value = TotalValue; 

}

function RemoveV() {


document.orderform.v_cat_id.value = "";
document.orderform.v_price.value = "";
document.orderform.v_name.value = "";
document.orderform.v_description.value = "";
document.getElementById('vases').style.display = "none";
var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

}

function RemoveT() {


document.orderform.t_cat_id.value = "";
document.orderform.t_price.value = "";
document.orderform.t_name.value = "";
document.orderform.t_description.value = "";
document.getElementById('teddy').style.display = "none";
var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

}

function RemoveB() {


document.orderform.b_cat_id.value = "";
document.orderform.b_price.value = "";
document.orderform.b_name.value = "";
document.orderform.b_description.value = "";
document.getElementById('balloons').style.display = "none";
var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

}

function RemoveW() {


document.orderform.w_cat_id.value = "";
document.orderform.w_price.value = "";
document.orderform.w_name.value = "";
document.orderform.w_description.value = "";
document.getElementById('wine').style.display = "none";
var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber; 

}

function RemoveG() {


document.orderform.g_cat_id.value = "";
document.orderform.g_price.value = "";
document.orderform.g_name.value = "";
document.orderform.g_description.value = "";
document.getElementById('glass').style.display = "none";
var TotalValue = Number(document.orderform.ntotal.value) + Number(document.orderform.b_price.value) + Number(document.orderform.c_price.value) + Number(document.orderform.w_price.value) + Number(document.orderform.t_price.value) + Number(document.orderform.g_price.value);

var roundedNumber = roundNumber(TotalValue,2)

document.orderform.total.value = roundedNumber;  
}


function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

