/*After the latest IE update, FLASH objects require spacebar/enter/click to get activated */
//-------------------------------------------------------------------------
function writeFlash(swfPath, width, height)
{
	document.write('<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+'" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="'+swfPath+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="bgcolor" value="#00000" />\n');
	document.write('<embed src="'+swfPath+'" quality="high" bgcolor="#000000" width="'+width+'" height="'+height+'" wmode="transparent"\n');
	document.write('align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"\n');
	document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>');
}

function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//------------------------------------------------------------------------------------
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);
		}
	}
}
//------------------------------------------------------------------------------------
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));
}

//------------------------------------------------------------------------------------
//Checks URL against pattern
function chkURL(tmpStr)
{
	var url_pat = /^(http|https|ftp):\/\/([\w-]+\.)+[\w-]+(\/[\w-\.\/?%&amp;,=#@\/:]*)?/;
	return(url_pat.test(tmpStr));
}
//------------------------------------------------------------------------------------
function isFloat(tmpStr)
{
	var price_pat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
	return(price_pat.test(tmpStr));
}

//------------------------------------------------------------------------------------
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;
}
//------------------------------------------------------------------------------------
function NewWindow(pageName)
{
	window.open(pageName, '', 'width=520,height=450,toolbar=0,menubar=0,location=0,left=0,top=0,scrollbars=1,resize=0');
}

//Display picture in new window
function showPicture(imagePath, width, height, alt)
{
	alt = alt.replace(/SQ/, "'");
	width = parseInt(width) + 40;
	height = parseInt(height) + 20;
	var optIE='scrollbars=yes,width='+width+',height='+height+',left='+50+',top='+50;
	newWindow = window.open("","newWindow",optIE);
	//var width,height;
	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="10" topmargin="10" marginheight="10" marginwidth="10" ondblclick="self.close();" onblur="self.close();"">\n');
	doc.write('<img src="'+imagePath+'" alt="'+alt+'\n(Double-click to close this window)" title="'+alt+'\n(Double-click to close this window)" border="0">\n');
	doc.write('</body>\n');
	doc.write('</html>\n');
	doc.close();
	newWindow.focus();
}

