//Trims a string from both sides
function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//Trims all fields in a form
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}
//Checks email against pattern
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*[a-z]+$/i;
	return(email_pat.test(tmpStr))
}
//Validates text-area length
function validateTALength(strField, cntlName, maxChar)
{
	if(obj.elements[cntlName].value.length > maxChar)
	{
		alert(strField+" should be within "+maxChar+" characters.");
		obj.elements[cntlName].focus();
		obj.elements[cntlName].select();
		return false;
	}
	return true;
}
//Opens a picture window
function openPictureWindow(imageName,imageWidth,imageHeight,alt)
{
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left=100,top=100, scrollbars=1");
	var doc = newWindow.document;
	doc.open();
	doc.write('<html>\n');
	doc.write('<head>\n');
	doc.write('<title>'+alt+'</title>\n');
	doc.write('<meta http-equiv="imagetoolbar" content="no">\n');
	doc.write('</head>\n');
	doc.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" ondblclick="self.close();" onblur="self.close();">\n');
	doc.write('<img src=\"'+imageName+'\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\" alt=\"'+alt+'\n(Double Click to Close)\" border="0">\n');
	doc.write('</body>\n');
	doc.write('</html>\n');
	doc.close();
	newWindow.focus();
}
function show_msg(name, val)
{
	document.getElementById(name).innerHTML = val;
}
function launch_upload_chooser(cntl_name)
{
	newWindow = window.open('popup.php?val='+cntl_name,"newWindow","width=710,height=500,left=0,top=0, scrollbars=1");
	newWindow.focus();
}
//---------------------------
function enfFlash(path, bgcolor, width, height)
{
	var homeFlash;
	homeFlash = '<center><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="intro" align="middle">';
	homeFlash+= '<param name="allowScriptAccess" value="sameDomain" />';
	homeFlash+= '<param name="wmode" value="transparent">';
	homeFlash+= '<param name="movie" value="'+path+'" /><param name="quality" value="high" /><param name="bgcolor" value="#'+bgcolor+'" />';
	homeFlash+= '<embed wmode="transparent" src="'+path+'" quality="high" bgcolor="#'+bgcolor+'" width="'+width+'" height="'+height+'" name="intro" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	homeFlash+= '</object></center>';
	document.write(homeFlash);
}
//-------------------------------
function goto1(par)
{
	window.open('search_result.php?txtSearch='+par,"pathway_browser");
}
//-------------------------------
function show_elisa_star()
{
	window.open("show_elisa_star.php","","height=320,width=500,location=0,resizable=1,toolbar=0, menubar=1, status=1,scrollbars=1,top=50,left=100,screenX=50,screenY=50");
}
//-------------------------------
function showmsds(par)
{
	window.open("msds_preview.php?id="+par,"","height=405,width=500,location=0,resizable=1,toolbar=0, menubar=1, status=1,scrollbars=1,top=50,left=100,screenX=50,screenY=50");
}

function full_screen_window()
{
	window.open('pb_full_screen.html',"pbrowser","height="+screen.height+",width="+screen.width+",location=0,resizable=1,toolbar=0, menubar=0, status=1,scrollbars=0,top=0,left=0");
}

