// JavaScript Document
function swap_image(image_name,image_id)
{
	image_id.src = "/images/"+image_name;
}

function popup(file,winName,w,h)
{
	window_top = (screen.height/2) - (w/2);
	window_left = (screen.width/2) - (h/2);
    window.open(file,winName,'width='+w+',height='+h+',title=yes,toolbar=no,status=no,scrollbars=yes,location=no,left='+window_left+',top='+window_top);
	return false;
}

function enableFields(area)
{
	checkForm = document.checkout;
	
	if (area == 1) {
		checkForm.firstName.disabled = false;
		checkForm.firstName.className = 'form';
		checkForm.lastName.disabled = false;
		checkForm.lastName.className = 'form';
		checkForm.company.disabled = false;
		checkForm.company.className = 'form';
		checkForm.email.disabled = false;
		checkForm.email.className = 'form';
		checkForm.phone.disabled = false;
		checkForm.phone.className = 'form';
		checkForm.mobile.disabled = false;
		checkForm.mobile.className = 'form';
	} else {
		checkForm.ship_address1.disabled = false;
		checkForm.ship_address1.className = 'form';
		checkForm.ship_city.disabled = false;
		checkForm.ship_city.className = 'form';
		checkForm.ship_state.disabled = false;
		checkForm.ship_state.className = 'form';
		checkForm.ship_zip.disabled = false;
		checkForm.ship_zip.className = 'form';
		checkForm.ship_country.disabled = false;
		checkForm.ship_country.className = 'form';
	}
}

function enableSubmit()
{
	document.reseller.edit.disabled = false;
	document.reseller.edit.className = 'basketSubmit';
}

function setShipToMail()
{
	form = document.reseller;
	shipClass = (form.mail_same.checked) ? 'doneGray' : 'form';
	
	// class name and value settings
	form.ship_address1.className = shipClass;
	form.ship_address1.value = form.mail_address1.value;
	
	form.ship_city.className = shipClass;
	form.ship_city.value = form.mail_city.value;
	form.ship_state.className = shipClass;
	form.ship_state.value = form.mail_state.value;
	form.ship_postcode.className = shipClass;
	form.ship_postcode.value = form.mail_postcode.value;
	form.ship_country.className = shipClass;
	form.ship_country.value = form.mail_country.value;
}

function updateShip()
{
	form = document.reseller;
	if(form.mail_same.checked) {
		form.ship_address1.value = form.mail_address1.value;
		form.ship_city.value = form.mail_city.value;
		form.ship_state.value = form.mail_state.value;
		form.ship_postcode.value = form.mail_postcode.value;
		form.ship_country.value = form.mail_country.value;
	}
}

function emptyValue(field)
{
	if (field.value == 'Username' || field.value == 'password') {
		field.value = '';
	}
}

function qtyChange(fld, change)
{
	field = document.getElementById(fld);
	
	if (change == '+') {
		newValue = Number(field.value) + 1;
	}
	if (change == '-') {
		newValue = field.value - 1;
	}
	
	if (newValue < 0) {
		field.value = 0;
	} else {
		field.value = newValue;
	}
}

function process()
{
	if(confirm('Plase confirm your wish to send this order?')) {
		window.location= '/cart.php?s=3';
	}
}

function remove(urlstr)
{
	response = confirm("Are you sure you want to remove this item?");

	if(response==true)
	window.location = urlstr;
}

function confAction(msg, url)
{
	response = confirm(msg);

	if(response==true)
	window.location = url;
}

function showDiv(div)
{
	e = document.getElementById(div);
	e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}