// JavaScript Document


function autofillbutton() {
	
	if (!document.getElementsByTagName) return;
	if (!document.getElementById("sameAddress")) return;
	var elem = document.getElementById("sameAddress");
	var whichForm = document.getElementById("deliverydiv");
	
	if(elem.checked) {
		whichForm.style.display = "none";
	}
	
	elem.onclick = function() {
		
		if(whichForm.style.display == "none") {
			whichForm.style.display = "block";
		} else {
			whichForm.style.display = "none";
		}
	};
	
/*	var lbl = document.createElement('label');
	lbl.setAttribute('for', "radio-auto");
	lbl.setAttribute('class', "checkbox");
	lbl.setAttribute('id', "lbl-radio-auto");
	lbl.innerHTML = "<input type='checkbox' class='checkbox' id='lbl-radio-auto' name='lbl-radio-auto' onclick='autoFill(this)' />Is invoice address same as delivery address?";
	elem.appendChild(lbl);*/
	
	/*var theLbl = document.getElementById("lbl-radio-auto");
	
	var inp = document.createElement('input');
	inp.setAttribute('type', "checkbox");
	inp.setAttribute('class', "checkbox");
	inp.setAttribute('id', "lbl-radio-auto");
	inp.setAttribute('name', "lbl-radio-auto");
	inp.setAttribute('onclick', "autoFill(this);");
	theLbl.appendChild(inp);*/
}




/*
function autoFill(the) {
	if (the.checked == false) {
		//do nothing?
	} else {
		//Get All fields from the delivery address and add them in
		var add1 = document.getElementById("add1-txt");
		var add2 = document.getElementById("add2-txt");
		var city = document.getElementById("city-txt");
		var post = document.getElementById("post-txt");
									
		var Iadd1 = document.getElementById("invoice-add1-txt");
		var Iadd2 = document.getElementById("invoice-add2-txt");
		var Icity = document.getElementById("invoice-city-txt");
		var Ipost = document.getElementById("invoice-post-txt");
		
		Iadd1.value = add1.value;
		Iadd2.value = add2.value;
		Icity.value = city.value;
		Ipost.value = post.value;
	}
}
*/
addLoadEvent(autofillbutton);
