String.prototype.makeSearchString= function() {
		return("*"+this.replace(/\s+/g,'*').replace(/([a-z](?=[0-9]))|([0-9](?=[a-z]))/ig,"$1$2\*").replace(/^\*+|\*+$/g,'')+"*");
	}
	String.prototype.trim = function () {  
		return this.replace(/(^\s*)|(\s*$)/g, ""); 
	}
function checkSubmitNonLoginForm(formName,fieldName,alertMsg,action){
		if (document.forms[formName].elements[fieldName].value == "" || document.forms[formName].elements[fieldName].value == "Product Name/Number")
		{
			alert(alertMsg);
			return false;
		}
        else
		{			
			var original = document.forms[formName].elements[fieldName].value;
			original = original.trim();
			if (original !="")
			{
				original=original.makeSearchString();
			}
			document.forms[formName].elements[fieldName].value=original;
			document.forms[formName].action=action;
			document.forms[formName].target="_blank";			
		}		
	}
	function checkForms(formName,action)
	{		
		for (i=0;i<document.forms[formName].elements.length;i++) 
		{	
			if ((document.forms[formName].elements[i].value=="" || document.forms[formName].elements[i].value=="Product Name" || document.forms[formName].elements[i].value=="Batch Number" ) &&
				document.forms[formName].elements[i].type=="text" )  
			{
				alert ("Please complete all fields.");
				return false;
			}
		}
		if (formName=="analysis_search" && (navigator.appVersion.indexOf("Win") != -1))
		{
			var orig_P_MAKTX = document.forms[formName].P_MAKTX.value;
			orig_P_MAKTX = orig_P_MAKTX.trim();
			if (orig_P_MAKTX !="")
			{
				orig_P_MAKTX=orig_P_MAKTX.makeSearchString();
			}
			document.forms[formName].P_MAKTX.value=orig_P_MAKTX;
			document.forms[formName].action = action + "&P_MAKTX=" + document.forms[formName].P_MAKTX.value + "&P_CHARG=" + document.forms[formName].P_CHARG.value;			
			document.forms[formName].target="_blank";
		}		
	}