function openPopup(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function popup (href, name, width, height) {
	var winW = width
	var winH = height
	var winName = name
	var winL = (screen.width - winW) / 2;
    var winT = (screen.height - winH) / 2;
	theWindow = window.open(href, winName, 'location=no, toolbar=no, status=no, directories=no, scrollbars=yes, menubar=0, resizable=yes, left=' + winL + ', top=' + winT +', width=' + winW + ', height=' + winH);
	theWindow.focus();
}

function AddToSelect(TheOption, TheSelect) {
	TheSelect.options[TheSelect.length] = new Option(TheOption.text, TheOption.value);
}

function openPopupConfirm(sMessage) {
	return confirm(sMessage);
}

function openPopupAddItemsConfirm(iMaxItems, iCurrentItems, iCurrentQty, iInputQty) {
	//check if at limit of input
	if (iInputQty > iCurrentQty) {
		//check if at all items limit
		if ((iCurrentItems + (iInputQty - iCurrentQty)) > iMaxItems) {
			return confirm('You have reached the maximum number of items for this packaging, do you want to continue adding items into another package?');
		} else {
			return true;
		}
	} else {
		//new value is less, so it will be okay
		return true;
	}
}

function popup_size (obj,iW,iH) {
	var winW = iW;
	var winH = iH;
	var winName = '_blank';
	var winL = (screen.width - winW) / 2;
	var winT = (screen.height - winH) / 2;
	window.open(obj.href, winName, 'location=no, toolbar=no, status=no, directories=no, scrollbars=no, menubar=0, resizable=yes, left=' + winL + ', top=' + winT +', width=' + winW + ', height=' + winH);
}

function printWindow(sOrientation) {
	var printPage = confirm ('Do you wish to print this page?')
	if (printPage) {
		//MeadCo ScriptX, http://www.meadroid.com/scriptx/index.asp
		scriptx.printing.header = '';
		scriptx.printing.footer = '';
		if (sOrientation == 'landscape') {
			scriptx.printing.portrait = false;
		} else {
			scriptx.printing.portrait = true;
		}
		scriptx.printing.leftMargin = 1.0;
		scriptx.printing.topMargin = 1.0;
		scriptx.printing.rightMargin = 1.0;
		scriptx.printing.bottomMargin = 1.0;
		scriptx.printing.Print(false);
		//opener.window.location.reload();
	}
	window.close();
}

function Length_TextField_Validator(iMin, iMax, oForm)
{
// Check the length of the value of the element named text_name
// from the form named form_name if it's < 3 and > 10 characters
// display a message asking for different input
    if ((oForm.value.length < iMin) || (oForm.value.length > iMax)) {
    // Build alert box message showing how many characters entered
    //mesg = "You have entered " + form_name.text_name.value.length + " character(s)\n"
    //mesg = mesg + "Valid entries are between 3 and 10 characters.\n"
    //mesg = mesg + "Please verify your input and submit again."
    //alert(mesg);
        alert('Your personal message us is too long (' + oForm.value.length + ' characters), please reduce to ' + iMax + ' characters or less');
        // Place the cursor on the field for revision
        oForm.focus();
        // return false to stop further processing
        return (false);
    }
    // If text_name is not null continue processing
	return (true);
}
function toggle( targetId ){   
	if (document.getElementById){         
	target = document.getElementById( targetId );            
		if (target.className == "noDisplay"){               
		target.className = "";
	} else {               
		target.className = "noDisplay"; 
	}      
	} 
}