if (document.images) {
	highlightoff = new Image();
	highlightoff.src = "/images/dot_clear.gif";
	highlighton = new Image();
	highlighton.src = "/images/highlight.gif";
}

var newWindow;

function img_act(imgName) {
	if (document.images){
		imgOn = highlighton.src;
   	    document [imgName].src = imgOn;
    }
}

function img_end(imgName) {
	if (document.images){
		imgOff = highlightoff.src;
   	    document [imgName].src = imgOff;
    }
}

function showMenu(menuName)
{
	if (document.getElementById(menuName).style.display == "none")
		document.getElementById(menuName).style.display = "block";
	else
		document.getElementById(menuName).style.display = "none";
}

function popWindow(image,width,height){
	width = parseInt(width) + 25;
	height = parseInt(height) + 40;
	newpage = "/showImage.php?image="+image;
	if (window.newWindow && !window.newWindow.closed){
		newWindow = window.open(newpage,"aoImage","height="+height.toString()+",width="+width.toString()+",status=no,toolbar=no,menubar=no,location=no,resizable=no");
		newWindow.resizeTo(width,height);
		newWindow.blur();
		newWindow.focus();
	} else
		newWindow = window.open(newpage,"aoImage","height="+height.toString()+",width="+width.toString()+",status=no,toolbar=no,menubar=no,location=no,resizable=no");	
}

function SubmitForm(mode){
	switch (mode){
		
		case "preview":
			document.forms['items'].target = "_blank";
			document.forms['items'].action = "/admin/preview.php"+document.location.search;
			var bUsePostFld = document.createElement("input");
			bUsePostFld.type = "hidden";
			bUsePostFld.name = "bUsePost";
			bUsePostFld.value = "1";
			document.forms['items'].appendChild(bUsePostFld);
			break;

		case "save":
			document.forms['items'].target = "_self";
			document.forms['items'].action = "/admin/admin_module.php"+document.location.search;
			var bSaveFld = document.createElement("input");
			bSaveFld.type = "hidden";
			bSaveFld.name = "bSave";
			bSaveFld.value = "1";
			document.forms['items'].appendChild(bSaveFld);
			break;
	}
	document.forms['items'].submit();
}

function spinUp(formname,elementname,unit,idx){
	var inputBox = document.forms[formname].elements[elementname+idx];
	var myValue = parseFloat(inputBox.value);
	if (isNaN(myValue))
		myValue = 0;
	myValue += parseFloat(unit);
	inputBox.value = myValue.toString();	
}

function spinDown(formname,elementname,unit,idx){
	var inputBox = document.forms[formname].elements[elementname+idx];
	var myValue = parseFloat(inputBox.value);
	if (isNaN(myValue))
		myValue = 0;
	if (myValue > 0){
		myValue -= parseFloat(unit);		
	}
	inputBox.value = myValue.toString();	
}