function open_voucher(f){
	window_tips = window.open(f,"","width=650,height=570,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,status=no,location=no,directories=no");
	window_tips.creator=self;
}

function open_coupon(f){
	window_tips = window.open(f,"","width=650,height=600,scrollbars=yes,resizable=yes,toolbar=no,menubar=yes,status=no,location=no,directories=no");
	window_tips.creator=self;
}

function open_tellfriend(f){
	window_tips = window.open(f,"","width=490,height=400,scrollbars=yes,resizable=yes,toolbar=no,menubar=yes,status=no,location=no,directories=no");
	window_tips.creator=self;
}

function open_instructions(f){
	window_tips = window.open(f,"","width=450,height=400,scrollbars=yes,resizable=yes,toolbar=no,menubar=yes,status=no,location=no,directories=no");
	window_tips.creator=self;
}
function open_youtube(f){
	window_tips = window.open(f,"","width=440,height=350,scrollbars=yes,resizable=yes,toolbar=no,menubar=yes,status=no,location=no,directories=no");
	window_tips.creator=self;
}
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function toggle_display(elementname, display_status){
	if(is.ns4){
		eval("document."+elementname+".display='"+display_status+"'");
	}else{
		eval("document.getElementById('"+elementname+"').style.display='"+display_status+"'");
	}
}

//turn hidden asterisks on and off. Params are (name of the element, visibility)
function toggle_visibility(elementname, v_status){
	if(is.ns4){
		eval("document."+elementname+".visibility='"+v_status+"'");
	}else{
		eval("document.getElementById('"+elementname+"').style.visibility='"+v_status+"'");
	}
}

//sets the first letter of any given string to be uppercase.
function format_input_name(objname){
	var firstletter = objname.charAt(0);
	var remainder = objname.substr(1);
		if(remainder.search(/name/g) != -1){
			remainder = remainder.replace(/name/i, " Name");
		}
	var result = firstletter.toUpperCase() + remainder;
	return result;
}