
// ***** Begin Copyright-protect *****
var message="Taking this copyrighted material is prohibited.";
document.oncontextmenu=new Function("alert(message);return false")
function clickIE4(){
	if (event.button==2){
		alert(message);
		return false;
	}
}
function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(message);
		return false;
		}
	}
}
// ***** End Copyright-protect *****


function addToFavorites() 

{ 

	// if the browser is IE open the add favorite window

	if (window.external) 

	{

		external.AddFavorite(location.href, document.title)

	}

	else 

	{

		// Display and alert box for any other browser.

		alert("Sorry, your browser doesn't support this feature." + 

		"\nPlease use the bookmark feature of your browser to save the location of this page.");

	}

}


function emailFriend() 

{ 

	var url = "/mb_emailfriend.php?u=" + location.href + "&t=" + document.title;

	window.open(url,'','width=500, height=250, menubar=0, scrollbars=1, statusbar=0, resizable=1');

}


function disablePartials()
{
	if(document.form1.partialbox1)
	{
		document.form1.partialbox1.disabled = true;
		document.form1.partialbox1.checked = false;
	}
	if(document.form1.partialbox2)
	{
		document.form1.partialbox2.disabled = true;
		document.form1.partialbox2.checked = false;
	}
	if(document.form1.partialbox3)
	{
		document.form1.partialbox3.disabled = true;
		document.form1.partialbox3.checked = false;
	}
	if(document.form1.partialbox4)
	{
		document.form1.partialbox4.disabled = true;
		document.form1.partialbox4.checked = false;
	}
	if(document.form1.partialbox5)
	{
		document.form1.partialbox5.disabled = true;
		document.form1.partialbox5.checked = false;
	}
}

function enablePartials()
{
	if(document.form1.partialbox1)
		document.form1.partialbox1.disabled = false;
	if(document.form1.partialbox2)
		document.form1.partialbox2.disabled = false;
	if(document.form1.partialbox3)
		document.form1.partialbox3.disabled = false;
	if(document.form1.partialbox4)
		document.form1.partialbox4.disabled = false;
	if(document.form1.partialbox5)
		document.form1.partialbox5.disabled = false;
}

function validatePartials()
{
	if(document.form1.partial && (document.form1.partial.checked))
	{
		var enabled = 0;
		var checked = 0;

		// count number of boxes we have
		if(document.form1.partialbox1)
		{
 			enabled++;
			if(document.form1.partialbox1.checked) checked++;
		}
		if(document.form1.partialbox2)
		{
 			enabled++;
			if(document.form1.partialbox2.checked) checked++;
		}
		if(document.form1.partialbox3) 
		{
 			enabled++;
			if(document.form1.partialbox3.checked) checked++;
		}
		if(document.form1.partialbox4) 
		{
 			enabled++;
			if(document.form1.partialbox4.checked) checked++;
		}
		if(document.form1.partialbox5) 
		{
 			enabled++;
			if(document.form1.partialbox5.checked) checked++;
		}


		// make sure at least 1 box is checked
		if(enabled > 0 && checked == 0)
	{
			alert("Please select a design from the set.");
			return false;
		}

		// only 1 or 2 allowed on a 4-set
		if((enabled == 4) && (checked == 3))
		{
			alert("Uh-oh!  We can't do 3 designs on 4 sheets of labels, please choose just 1 or 2 designs!");	
			return false;
		}
	}

	document.form1.submit();
	return true;
}

// convertToDecimal converts a number to ####.## format
function convertToDecimal(val)
{

	// check for blank
	if (val == "") return "0.00";

	var wholeNumber = true;
	var newValue = "";

	var tempnum = String(Math.round(val*Math.pow(10,2))/Math.pow(10,2));
	for (i=0;i<tempnum.length;i++){
		if (tempnum.charAt(i)==".")
		{
			wholeNumber = false;
			break;
		}
	}
	if (wholeNumber)
		// whole number
		newValue = tempnum+".00";
	else{
		if (tempnum.charAt(tempnum.length-3)=="."){
			// already in #.## format
			newValue = tempnum;
		}
		else
		{
			if (tempnum.charAt(tempnum.length-2)=="."){
				// #.# format, add last zero
				newValue = tempnum + "0";
			}
			else{
				tempnum = Math.round(tempnum*100)/100;
				newValue = tempnum;
			}
		}
	}
	
	if (newValue == "0") newValue += ".00";

	
	return newValue;
}

function setMaxLengthLeft(p_len1, p_len2, p_len3, p_len4, p_len5)
{
	document.form1.line1.maxLength = p_len1;
	document.form1.line2.maxLength = p_len2;
	document.form1.line3.maxLength = p_len3;

	document.form1.line4.maxLength = p_len4;

	document.form1.line5.maxLength = p_len5;
}
function setMaxlengthHoriz(p_len1, p_len2)

{

	document.form1.line1.maxLength = p_len1;

	document.form1.line2.maxLength = p_len2;

}

