function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function getTimeZone() {
	var tz = new Date().getTimezoneOffset()/60;
	return -tz;
}	

function writeFlashApp(divId, movie, bgColor, flashVars, width, height) {

  	var s = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
			' id="Main" height="' + height + '" width="' + width + '" ' +
			' codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">' + 
			' <param name="movie" value="' + movie + '" /> '+
			' <param name="quality" value="high" /> ';
	if (bgColor) {
		s+=	' <param name="bgcolor" value="' + bgColor + '" /> ';
	}
	else {
		s+= ' <param name="wmode" value="transparent" /> ';		
	}
		s+=	' <param name="allowNetworking" value="all" /> '+
			' <param name="allowScriptAccess" value="always" /> '+
			' <param name="flashvars" value="' + flashVars + '"/> '+
			' <embed src="' + movie + '" quality="high" ';
	if (bgColor) {		
		s+=	'   bgcolor="' + bgColor + '" ';
	}
	else {
		s+=	' 	wmode="opaque" ';	
	}
		s+=	' 	height="' + height + '" width="' + width + '" id="Main" name="Main" align="middle" '+
			' 	play="true" '+
			' 	loop="false" '+
			' 	quality="high" '+
			' 	flashvars="' + flashVars + '" '+
			' 	allowNetworking="all" '+
			' 	allowScriptAccess="always" '+
			' 	type="application/x-shockwave-flash" '+
			' 	pluginspage="http://www.adobe.com/go/getflashplayer"> '+
			' </embed> '+
	' </object> ';
//alert(s);	
	document.getElementById(divId).innerHTML = s;
}

function getFrameDocument(frameName) {
	var formFrame = document.getElementById(frameName);
	var iframeDocument = null;
	if (formFrame.contentDocument) { // For NS6 and Firefox
	   iframeDocument = formFrame.contentDocument; 
	} else if (formFrame.contentWindow) { // For IE5.5 and IE6
	   iframeDocument = formFrame.contentWindow.document;
	} else if (formFrame.document) { // For IE5
	   iframeDocument = formFrame.document;
	} 
	return iframeDocument;		
}

function getXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function trim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function trimZeroPrefix(sString)
{
	while (sString.substring(0,1) == '0')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function containsSpecialChars(sString) {
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

  for (var i = 0; i < sString.length; i++) {
  	if (iChars.indexOf(sString.charAt(i)) != -1) return true;
  }	
  return false;
}

function isNumber(sString) {
	var nums = /^[0-9]*$/;
	var check = sString;
	
	if (sString.charAt(0) == '-') 
		check = sString.substring(1);
	var period = sString.indexOf('.');
	if (period >= 0) {
		check = sString.substring(0, period) + sString.substring(period+1);
	}
	return nums.test(check);
}

function isValidEmail(sString) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(sString);
}

function getParameter (parameterName ) {
	var queryString = window.location.search.substring(1);
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
		begin = queryString.indexOf ( parameterName );
		if ( begin != -1 ) {
			begin += parameterName.length;
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length;	
			}
			// Return the string
			return unescape ( queryString.substring ( begin, end ) );
		}
		return "";
	}
	return "";
} 

function checkUserNameForQuotes (userName ) {
	if ( userName.length > 0 ) {
		begin = userName.indexOf ( '\'' );
		if ( begin == -1 ) {
			begin = userName.indexOf ( '\"' );
				if (begin == -1) { return false; } else {return true;}
			return false;		
		} else {
			return true;
		}
	}
return false;
} 