
var DHTML = (document.getElementById || document.all || document.layers);


//-------------------------------------------------------------------------------------------------------------------------

function submitForm(form_id, form_action, form_task) {
	
	var my_form = document.getElementById(form_id);
	if (form_action) {
		my_form.action = form_action;
	}
	if (form_task) {
		my_form.task.value = form_task;
	}
	
	my_form.submit();
}

//-------------------------------------------------------------------------------------------------------------------------

function getObj(name) {
	if (document.getElementById) {
	      this.obj = document.getElementById(name);
	      this.style = document.getElementById(name).style;
	}
	else if (document.all) {
	      this.obj = document.all[name];
	      this.style = document.all[name].style;
	}
	else if (document.layers) {
	      this.obj = document.layers[name];
	      this.style = document.layers[name];
	}
}

//-------------------------------------------------------------------------------------------------------------------------

function validateForm_BillShip(the_form) {
	
	var is_valid = true;	// we assume it is a valid form
	// custom code can be added to this fucntion if form specific actions are required
	
	// call the standard form validation function
	is_valid = validateForm(the_form);
	
	return is_valid;

}


//-------------------------------------------------------------------------------------------------------------------------

function validateForm_CustServ(the_form) {
	
	var is_valid = true;	// we assume it is a valid form
	// custom code can be added to this fucntion if form specific actions are required
	
	// call the standard form validation function
	is_valid = validateForm(the_form);
	
	return is_valid;

}

//-------------------------------------------------------------------------------------------------------------------------

function validateAddToCart(the_form) {
	
	var is_valid = true;	// we assume it is a valid form
	// custom code can be added to this fucntion if form specific actions are required
	
	// call the standard form validation function
	is_valid = validateForm(the_form);
	
	return is_valid;

}

//-------------------------------------------------------------------------------------------------------------------------


//==================================================
// BEGIN BILL SHIP INFO 
//==================================================

var billInputs = new Array('fname', 'lname', 'address', 'address2', 'city', 'zip', 'phone');
var billSelects = new Array('state');
var shipInputs = new Array('shipFirst', 'shipLast', 'shipAddress', 'shipAddress2', 'shipCity', 'shipZip', 'shipPhone');
var shipSelects = new Array('shipState');


function fillShipInfo(obj) {
	if (obj.checked == true) {
		setShipInfo('bill');
	} else {
		setShipInfo('reset');
	}
}

//------------------------------------------------------------------------------------------------------------------------------------

function setShipInfo(data) {
	var form = document.orderForm;
	var limitInputs = billInputs.length;
	var limitSelects = billSelects.length;
	if(data == 'bill'){
		for(var x=0; x<limitInputs; x++) {
			form[ shipInputs[x] ].value = form[ billInputs[x] ].value;
		}
		for(var x=0; x<limitSelects; x++) {
			form[ shipSelects[x] ].options.selectedIndex = form[ billSelects[x] ].options.selectedIndex
		}
	}else{
		for(var x=0; x<limitInputs; x++) {
			form[ shipInputs[x] ].value = '';
		}
		for(var x=0; x<limitSelects; x++) {
			form[ shipSelects[x] ].options.selectedIndex = 0;
		}
	}
}

//==================================================
// END BILL SHIP INFO 
//==================================================

	