function MM_preloadImages()
{ //v3.0
	var d = document;
	if( d.images )
	{
		if( !d.MM_p )
			d.MM_p = new Array();
		var i,
			j = d.MM_p.length,
			a = MM_preloadImages.arguments;
		for( i = 0;  i < a.length;  i++ )
		{
			if( a[ i ].indexOf( "#" ) != 0 )
			{
				d.MM_p[ j ] = new Image;
				d.MM_p[ j++ ].src = a[ i ];
			}
		}
	}
}

function MM_swapImage()
{ //v3.0
	var i,
		j = 0,
		x,
		a = MM_swapImage.arguments;
	document.MM_sr = new Array();
	for( i = 0;  i < a.length - 2;  i += 3 )
	{
		if( ( x = MM_findObj( a[ i ] ) ) != null )
		{
			document.MM_sr[ j++ ] = x;
			if( !x.oSrc )
				x.oSrc = x.src;
			x.src = a[ i + 2 ];
		}
	}
}

function MM_swapImgRestore()
{ //v3.0
	var i,
		x,
		a = document.MM_sr;
	for( i = 0;
		 a  &&
		   i < a.length  &&
		   ( x = a[ i ] )  &&
		   x.oSrc;
		 i++ )
		x.src = x.oSrc;
}

function MM_findObj( n, d)
{ //v4.01
	var p,
		i,
		x;
	if( !d )
		d = document;
	if( ( p = n.indexOf( "?" ) ) > 0  &&  parent.frames.length )
	{
		d = parent.frames[ n.substring( p + 1 ) ].document;
		n = n.substring( 0, p );
	}
	if( !( x = d[ n ] )  &&  d.all )
		x = d.all[ n ];
	for( i = 0;
		 !x  &&
		   i < d.forms.length;
		 i++ )
		x = d.forms[ i ][ n ];
	for( i = 0;
		 !x  &&
		   d.layers  &&
		   i < d.layers.length;
		 i++ )
		x = MM_findObj( n, d.layers[ i ].document );
	if( !x  &&  d.getElementById )
		x = d.getElementById( n );
	return x;
}

function MM_openBrWindow( theURL, winName, features ) { //v2.0
	window.open( theURL, winName, features );
}

function openNewWindow( URL, winName, winProps )
{
	window.open( URL, winName, winProps );
}

function back_func() {
	window.history.back();
		/* Returning 'false' is essential to prevent the <a> element
		 * from following the link given in the 'href' attribute (and
		 * the 'href' attribute MUST be specified to make the link
		 * look like a link).
		 */
	return false;
}

/*
function login()
{
	var regex = /\.novaflow\.com$/
	var un = document.login_form.username.value;
	if( un.search( regex ) == -1 )
		un = un + ".novaflow.com";
	var pw = document.login_form.password.value;
	var cmd = "ftp://" + un + ":" + pw + "@ftp.novaflow.com";
	var props =
		"scrollbars"
		+ "," + "width=817"
		+ "," + "height=600"
		+ "," + "resizable";
	openNewWindow( cmd, "ftpWindow", props );
}
*/

function login( f )
{
	var regex = /\.novaflow\.com$/
	var un = f.username.value;
	if( un.search( regex ) == -1 )
		un = un + ".novaflow.com";
	var pw = f.password.value;
	var cmd = "ftp://" + un + ":" + pw + "@ftp.novaflow.com";
	f.action = cmd;
	f.submit();
	return true;
}

function joinsession( f )
{
	var cmd = "https://novaflow.webex.com/novaflow/sc30/t.php?I=" + f + "&RT=NCMxMQ%3D%3D";
	window.location.href = "https://novaflow.webex.com/novaflow/sc30/t.php?I=" + f + "&RT=NCMxMQ%3D%3D";
}

function ulogin( f )
{
	var regex = /\.novaflow\.com$/
	var un = f.username.value;
	if( un.search( regex ) == -1 )
		un = un + ".novaflow.com";
	var pw = f.password.value;
		//var cmd = "ftp://" + un + ":" + pw + "@ftp.novaflow.com";

	var cmd = "http://www.novaflow.com/ftp/index.html?username=" + un + "&password=" + pw;
	//f.action = cmd;
	//f.submit();
	var props =
		"scrollbars"
		+ "," + "width=817"
		+ "," + "height=600"
		+ "," + "resizable";
	openNewWindow( cmd, "ftpWindow", props );
	return true;
}

	//	If you're dealing with a FORM, you need .value
	//	If you're dealing with an OBJECT (class Object), you don't

function encode( form )
{
	for( var i = 0;  i < form.elements.length;  ++i )
		form.elements[ i ].value = encodeURIComponent( form.elements[ i ].value );
}

function CSF_set_form( form, argsObj )
{
	if( argsObj.layout == "A" )
	{
		form.Comment.value = argsObj.productType;
		form.SubjectSelection.selectedIndex = argsObj.requestCategory;
		form.MessageType[ argsObj.requestType ].checked = true;
	}
	if( argsObj.layout == "B" )
	{
		form.Comment.value = argsObj.productType;
		form.SubjectSelection.selectedIndex = argsObj.requestCategory;
		form.MessageType[ argsObj.requestType ].checked = true;
	}
}

function submit_args( form )
{
	encode( form );
	form.submit();
	return false;
}

function retrieve_args()
{
	var s = window.location.search;
//	alert( 'retrieve_args(): s after "search" = "' + s + '"' );
	if( s == "" )
		s = window.opener.document.URL
//	alert( 'retrieve_args(): s after URL = "' + s + '"' );
	var pos = s.search( /\?/i );
//	alert( 'retrieve_args(): pos = ' + pos );
	var retVal = pos != -1 ? s.substring( pos + 1 ) : "";
//	alert( 'retrieve_args(): retVal = "' + retVal + '"' );
	return retVal;
}

function submit_form( form )
{
	var result = CustomerServiceForm_Validator( form );
//	alert( "submit_form: result = " + result );
	return result;
}

	//	THE DECODING PROCESS
	//	The form does an encoding of the data in which it encodes spaces
	//	as '+' signs. However, if there's a '+' sign in the text, it is
	//	indistinguishable from an "encoded" '+' sign. Therefore, I use
	//	encodeURIComponent to encode the original text. (This causes
	//	spaces to be replaced by %20.) Now the form encodes the encoded
	//	text and converts the '%' into %25. Hence, I have to decode the
	//	text twice to get back to the original.
function get_args( s )
{
	var argsObj = null;
//	alert( 'get_args(): s = "' + s + '"' );
	if( s != "" )
	{
		argsObj = new Object();
		var pairs = s.split( "&" );
	
		for( var i = 0;  i < pairs.length;  ++i )
		{
			var pos = pairs[ i ].indexOf( "=" );
			if( pos != -1 )
			{
				var argname = pairs[ i ].substring( 0, pos );
				var value = pairs[ i ].substring( pos + 1 );
				value = decodeURIComponent( decodeURIComponent( value ) );
				argsObj[ argname ] = value;
			}
		}
	}
	return argsObj;
}

function set_form( form )
{
	var argsObj = get_args( retrieve_args() );
	if( argsObj != null )
	{
		if( argsObj.target == "CSF" )
			CSF_set_form( form, argsObj );
	}
}

function get_sorted_args( argsObj )
{
	var list = new Array();
	var i = 0;
	for( var name in argsObj )
		list[ i++ ] = name;
	list.sort();

	var propsString = "Args:\n";	
	for( i = 0; i < list.length;  ++i )
	{
		propsString +=
			">  " +
			list[ i ] +
			"=" +
			argsObj[ list[ i ] ] + "\n";
	}
	return propsString;
}




