function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=426,left = 400,top = 237');");
}


function getY(oElement){
	currId = oElement;
	var theElement = oElement;
	var oElement = (typeof oElement == "string") ? document.getElementById(oElement) : oElement;
	var yVal = 0;
	var xVal = 0;
	while( oElement != null ) {
		yVal += oElement.offsetTop;
		xVal += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	var vals = new Array();
	vals[0] = yVal;
	vals[1] = xVal;
	var form = document.getElementById('formDiv');
	//alert("form is " +form.id + " yVal = " +yVal+ "\n xVal = " +xVal);
	form.style.top = yVal+"px";
	form.style.left = xVal+"px";
	form.style.display = "inline";
	
}


function showTransfer(hide,show){
	var itemType = document.dataInput.itemType.value;
	var hideElement = document.getElementById(hide);
	var showElement = document.getElementById(show);
	hideElement.style.display = "none";
	showElement.style.display = "block";
	document.dataInput.method="post";
	switch(itemType){
		case 'shotgun':
			//document.dataInput.action="addGun.php";
		break;
		case 'rifle':
			//document.dataInput.action="addRifle.php";
		break;
		case 'spurs':
			//document.dataInput.action="addGun.php";
		break;
		case 'trophy':
			//document.dataInput.action="addGun.php";
		break;
	}
	
	//document.dataInput.submit();
	return false;
}

function handleForm(formType, formName){
	var fm = document.getElementById(formName);
	alert(fm.itemType.value);
	fm.method="post";
	switch(formType){
		case 'data':
			//fm.action="editGun.php";
			break;
		case 'editPrimary':
			//fm.action="editGun.php";
			break;
		case 'addDetail':
			//fm.action="editGun.php";
			break;
		default:
			break;
	}
	//fm.submit();
}
function closeForm(){
	var form = document.getElementById('formDiv');
	form.style.display = "none";
}


function submitOffer(){
	//alert('Curr id = ' + currId );
	var form = document.forms[0];
	var name = form.name.value;
	var eAddress = form.email.value;
	var off = form.offer.value;
	var id = currId;
	//
	//
	form.method = "post";
	form.action = 'http://www.lakecreekranch.com';
	// rewrite thnk you
	//
	//
	var img = document.getElementById(currId);
	var new_el = document.createElement("P");
	
	new_el.appendChild(document.createTextNode("Your offer has been submitted."));
	var imgParent = document.getElementById('img1Anchor');
	//alert('the parent of the img node is '+imgParent.id);
	var mDiv = imgParent.parentNode;
	//alert('Number of children for : '+mDiv.id+' are : '+mDiv.childNodes.length);
	//alert('Child Nodes of '+a.id+' are: '+cNodes);
	//alert('Parent node of img is '+a.id);
	//alert('previous sibling node of img is '+img.previousSibling);
	//a.removeChild(a.childNodes[3]);
	//alert('replacing '+imgParent.id+' with '+new_el.id);
	//alert('mDiv = '+mDiv.id+' number of nodes it holds are '+mDiv.childNodes.length);
	//mDiv.removeChild(document.getElementById('img1Anchor'));
	/*for(var i = 1; i<=mDiv.childNodes.length-1; i++){
		if(mDiv.childNodes[i].id){
	 		var nds = mDiv.childNodes[i].id;
	 		alert("found id "+nds);
		}else{
			var nds = mDiv.childNodes[i].nodeValue;
			nds = nds.toString()
			alert("NO id -> value: "+nds);
		}
	}*/
	//mDiv.insertBefore(new_el,imgParent);
	//div.replaceChild(new_el,imgParent);
	//mDiv.appendChild(new_el);
	
	//form.write('Thank You. Your offer has been submitted.');
}
