/**
* @file common.modal.js
*
* Javascript Modal library v2 -
* LenderStreet's Modal Library modified for StorageFront.
*
* Make sure that any file using this library also includes
* - common.modal.css
* - common.fieldvalidation.js
* - common.rdebug.js
* - jquery
*
* @author	Rachel
* @date 05/19/2010
*
* Documentation can be found here:
* http://superawesomeninjasquad.info/documentation/doku.php?id=js_modal_dialogs
*/


/******************************************************************************************************************/
/******************************************************************************************************************/
/********************** global variables - easily change values outside of functions, such as *********************/
/************************** the border's image dimensions, height of the header, etc... ***************************/
/******************************************************************************************************************/
/******************************************************************************************************************/

// Width/height of the images for the border corners
var BORDER_W = 48, BORDER_H = 48;
// Minimum size a modal can be without looking funny
var MIN_MODAL_W = BORDER_W*2, MIN_MODAL_H = BORDER_H*2;
// Header height
var MODAL_HEADER_HEIGHT = 50;
// Asset path - to be specified by user
var ASSET_PATH = -1, POLICY_PATH = -1;
// Position of error div on the modals
var ERROR_DIV_POS_Y = 40;

// Used to reset modal size
var modal_original_w, modal_original_h, error_last_resize = -1;

// Name of bot-check field
var botCheckField = "Grilled_Cheese_Sandwich";

// Global arguments, for navigating from one modal to another
var GLOBAL_ARGS = { "empty" : "empty" };


/******************************************************************************************************************/
/************************************************* Preload images *************************************************/
/******************************************************************************************************************/
/* 	preload_image_object = new Image();
    image_url = new Array();
    image_url[0] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_topleft.png";
    image_url[1] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_left.png";
    image_url[2] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_bottomleft.png";
    image_url[3] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_bottom.png";
    image_url[4] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_bottomright.png";
    image_url[5] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_right.png";
    image_url[6] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_topright.png";
    image_url[7] = "<? echo($_PAGE['asset_path']); ?>/images/corner_diag2_close.png";
    image_url[8] = "<? echo($_PAGE['asset_path']); ?>/images/modal_border_top.png";
    image_url[9] = "<? echo($_PAGE['asset_path']); ?>/images/modal_header_default.png";
    image_url[10] = "<? echo($_PAGE['asset_path']); ?>/images/llamastomp_3.gif";
    image_url[11] = "<? echo($_PAGE['asset_path']); ?>/images/ajax-loader.gif";

     var i = 0;
     for(i=0; i<=11; i++)
       preload_image_object.src = image_url[i]; */

// Preload borders
function PreloadModelBorders()
{
	if ( ASSET_PATH == "" )
	{
		alert( "You need to call Modal_SetAssetPath before preloading the borders." );
		return;
	}

	var preloadMe = document.createElement( "div" );
	var inner = "";
	var assetList = new Array();

	assetList[0] = "modal_border_topleft.png";
	assetList[1] = "modal_border_left.png";
	assetList[2] = "modal_border_bottomleft.png";
	assetList[3] = "modal_border_bottom.png";
	assetList[4] = "modal_border_bottomright.png";
	assetList[5] = "modal_border_right.png";
	assetList[6] = "modal_border_topright.png";
	assetList[7] = "corner_diag2_close.png";
	assetList[8] = "modal_border_top.png";
	assetList[9] = "modal_header_default.png";

	for ( asset in assetList )
	{
		inner += "<img src='"+ASSET_PATH+"/images/"+assetList[asset]+"' />";
	}

	preloadMe.innerHTML = inner;
	preloadMe.style.display = "none";
	document.body.appendChild( preloadMe );
}


/******************************************************************************************************************/
/******************************************************************************************************************/
/******************************************************************************************************************/
/******************* "public" functions - to be called by other pages to generate modal dialogs *******************/
/******************************************************************************************************************/
/******************************************************************************************************************/
/******************************************************************************************************************/

/**
* Modal_SetAssetPath()
* Used to set the asset path, so we can use images and such.
* @param	path	URL of the asset path
*/
function Modal_SetAssetPath( path )
{
	ASSET_PATH = path;
}

/**
* Modal_SetPrivacyPolicyPath()
* Used to set the asset path, so we can use images and such.
* @param	path	URL of the privacy policy page
*/
function Modal_SetPrivacyPolicyPath( path )
{
	POLICY_PATH = path;
}

/**
* Modal_Close()
* search-code FXCLOSE
* @date 5/25/10 - Rach
* Closes and destroys any open modals, resets some global variables back to their
* default, resets the validation and debug logs.
*/
function Modal_Close()
{
	$('#div_modal_container').fadeOut( 'slow', function()
	{
		// Destroy super container
		var dialog = document.getElementById( "super_container" );
		if ( dialog != null )
		{
			dialog.style.display = "none";
			dialog.parentNode.removeChild( dialog );
		}

		// Destroy veil
		dialog = document.getElementById( "veil" );
		if ( dialog != null )
		{
			dialog.style.display = "none";
			dialog.parentNode.removeChild( dialog );
		}
	} );

	error_last_resize = -1;

	// Clear out field validation
	try { ClearValidationLog(); }
	catch ( error ) { ; }
} /**************************** Modal_Close() *********************************/

/**
* Modal_EditNotes()
* search-code FXNOTES FXEDITNOTES
* @date 08/10/2010 Rachel
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param 	args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Text
* @param	args.text_header 			"Add new note for this lead"
* @param	args.text_instructions
* @param	args.text_save
* @param	args.current_notes		What the notes are currently set as.
* ------------------------------------------------------------------------------
* Input values
* @param	args.input_notes
* @param	args.hidden_name
* @param 	args.hidden_value
*/
function Modal_EditNotes( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : 400, "height" : 350 } );

	Modal_CreateLabel( { "text" : args.text_instructions, 					"x" : "center", 		"y" : "70", 	"label_class" : "textbox_label", "horiz_align" : "center" } );

	Modal_CreateTextarea( { "name" : args.input_notes, 					"x" : "40", 		"y" : "100", 	"w" : "236", "h" : "100",	"size" : "medium", "default_text" : args.current_notes } );
	// Send
	Modal_CreateButton( { "name" : "save", 							"x" : "210", 		"y" : "220", "value" : args.text_save, "text" : args.text_save, "button_class" : "button_M green_M", "type" : "submit" } );
	// Hidden element
	Modal_CreateHiddenElement( { "name" : args.hidden_name, "value" : args.hidden_value } );
	Modal_CreateHiddenElement( { "name" : args.hidden_name2, "value" : args.hidden_value2 } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_Custom()
* search-code FXCUSTOM
* @date 5/28/2010 Rachel
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param 	args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Variable information
* @param 	args.lender_address							Lender's address
* ------------------------------------------------------------------------------
* Language support
* @param	args.code												Code to go into the innerHTML.
*/
function Modal_Custom( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : args.modal_w, "height" : args.modal_h } );

	var parentModal = document.getElementById( "modal_body" );
	var container = document.createElement( "div" );
	container.className = "modal_div " + args.custom_container_class;
	container.name = "custom_modal";

	PositionElement( { "container" : container, "x" : "0", "y" : "80" } );
	container.innerHTML = args.code;

	try { parentModal.appendChild( container ); }
	catch ( error ) { RD_Append_Log( "Error appending custom data to modal:\n" + error ); }

	RD_Display_Log();	// displays the debug log if rDebug is set to true
} /************************** Modal_Custom() **********************************/

/**
* Modal_ContactUs()
* search-code FXCONTACTUS
* @date 6/3/2010
* @author Rach
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header								"ASDFASDF"
* @param 	args.text_privacy1							"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2							"privacy policy"
* @param 	args.text_name									"Name (optional):"
* @param 	args.text_email									"Email (optional):"
* @param 	args.text_phone									"Phone (optional):"
* @param 	args.text_subject								"Subject:"
* @param 	args.text_message								"Message:"
* @param 	args.text_send									"Send"
* ------------------------------------------------------------------------------
* Input field name/ids (if any)
* @param	args.input_name									ID of the textbox for entering their name
* @param	args.input_email								ID of the email textbox
* @param	args.input_phone								ID of the phone textbox
* @param	args.input_subject							ID of the subject textbox
* @param	args.input_message							ID of the message textarea
* @param	args.submit_name								ID of the submit button
* @param	args.hidden_name								ID of the hidden object
* @param	args.hidden_value								Value of the hidden object
*/
function Modal_ContactUs( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "550", "height" : "550" } );
	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : ERROR_DIV_POS_Y, "w" : "100%" } );
	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	// Name field
	Modal_CreateLabel( { "text" : args.text_name, 								"x" : "10%", 		"y" : "120", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_name, 							"x" : "40%", 		"y" : "120",	"size" : "medium", "validation_flags" : "alphabet_field" } );

	Modal_CreateLabel( { "text" : args.text_email, 								"x" : "10%", 		"y" : "160", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_email, 						"x" : "40%", 		"y" : "160",	"size" : "medium", "validation_flags" : "email_field" } );

	Modal_CreateLabel( { "text" : args.text_phone, 								"x" : "10%", 		"y" : "200", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_phone, 						"x" : "40%", 		"y" : "200",	"size" : "medium", "validation_flags" : "phone_field" } );

	Modal_CreateLabel( { "text" : args.text_subject, 							"x" : "10%", 		"y" : "240", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_subject, 					"x" : "40%", 		"y" : "240",	"size" : "medium", "validation_flags" : "required_field" } );

	Modal_CreateLabel( { "text" : args.text_message, 							"x" : "10%", 		"y" : "280", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextarea( { "name" : args.input_message, 					"x" : "40%", 		"y" : "280", 	"w" : "236", "h" : "100",	"size" : "medium", "validation_flags" : "required_field" } );
	// Send
	Modal_CreateButton( { "name" : args.submit_name, 							"x" : "80%", 		"y" : "400", "value" : args.text_send, "text" : args.text_send, "button_class" : "button_M green_M", "type" : "submit" } );
	// Hidden element
	Modal_CreateHiddenElement( { "name" : args.hidden_name, "value" : args.hidden_value } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Get information from user before giving them the coupon on the MarketPro pages
* search-code FXCOUPON
* @date 6/3/2010
* @author Rach
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header								"Print Coupon"
* @param 	args.text_summary								"We need your email..."
* @param 	args.text_privacy1							"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2							"privacy policy"
* @param 	args.text_name									"Name:"
* @param 	args.text_email									"Email:"
* @param 	args.text_send									"Get Coupon"
* ------------------------------------------------------------------------------
* Input field name/ids (if any)
* @param	args.input_name									ID of the textbox for entering their name
* @param	args.input_email								ID of the email textbox
* @param	args.submit_name								ID of the submit button
* @param	args.hidden_name								Name of the hidden object
* @param	args.hidden_value								Value of the hidden object
*/
function Modal_Coupon( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "500", "height" : "360" } );
	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : ERROR_DIV_POS_Y, "w" : "100%" } );

	Modal_CreateLabel( { "text" : args.text_summary, 							"x" : "0%", 	"y" : "70", "w" : "400", "label_class" : "textbox_label", "horiz_align" : "center" } );

	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "110", "label_class" : "privacy_policy", "horiz_align" : "center" } );

	// Name field
	Modal_CreateLabel( { "text" : args.text_name, 								"x" : "15%", 		"y" : "150", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_name, 							"x" : "30%", 		"y" : "150",	"size" : "medium", "validation_flags" : "required_field alphabet_field" } );

	Modal_CreateLabel( { "text" : args.text_email, 								"x" : "15%", 		"y" : "190", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_email, 						"x" : "30%", 		"y" : "190",	"size" : "medium", "validation_flags" : "required_field email_field" } );

	// Send
	Modal_CreateButton( { "name" : args.submit_name, 							"x" : "70%", 		"y" : "230", "value" : args.text_send, "text" : args.text_send, "button_class" : "button_M green_M", "type" : "submit" } );
	// Hidden element
	Modal_CreateHiddenElement( { "name" : args.hidden_name, "value" : args.hidden_value } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_Feedback()
* search-code FXFEEDBACK, FXSENDFEEDBACK
* @date 6/3/2010
* @author Rach
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header								"ASDFASDF"
* @param 	args.text_privacy1							"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2							"privacy policy"
* @param 	args.text_name									"Name (optional):"
* @param 	args.text_email									"Email (optional):"
* @param 	args.text_phone									"Phone (optional):"
* @param 	args.text_comments							"Comments:"
* @param 	args.text_message								"Message:"
* @param 	args.text_send									"Send"
* ------------------------------------------------------------------------------
* Input field name/ids (if any)
* @param	args.input_name									ID of the textbox for entering their name
* @param	args.input_email								ID of the email textbox
* @param	args.input_phone								ID of the phone textbox
* @param	args.input_comments							ID of the comments textbox
* @param	args.submit_name								ID of the submit button
* @param	args.hidden_name								ID of the hidden object
* @param	args.hidden_value								Value of the hidden object
*/
function Modal_Feedback( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "550", "height" : "500" } );
	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : ERROR_DIV_POS_Y, "w" : "100%" } );
	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	// Name field
	Modal_CreateLabel( { "text" : args.text_name, 								"x" : "10%", 		"y" : "120", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_name, 							"x" : "40%", 		"y" : "120",	"size" : "medium", "validation_flags" : "alphabet_field required_field" } );

	Modal_CreateLabel( { "text" : args.text_email, 								"x" : "10%", 		"y" : "160", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_email, 						"x" : "40%", 		"y" : "160",	"size" : "medium", "validation_flags" : "email_field required_field" } );

	Modal_CreateLabel( { "text" : args.text_phone, 								"x" : "10%", 		"y" : "200", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_phone, 						"x" : "40%", 		"y" : "200",	"size" : "medium", "validation_flags" : "phone_field" } );

	Modal_CreateLabel( { "text" : args.text_comments, 						"x" : "10%", 		"y" : "240", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextarea( { "name" : args.input_comments, 				"x" : "40%", 		"y" : "240", 	"w" : "236", "h" : "100",	"size" : "medium", "validation_flags" : "required_field" } );
	// Sheep image
	Modal_CreateImage( { "filename" : "feedBackSheep.png", 				"x" : "0", "y" : "265" } );
	// Send
	Modal_CreateButton( { "name" : args.submit_name, 							"x" : "80%", 		"y" : "360", "value" : args.text_send, "text" : args.text_send, "button_class" : "button_M green_M", "type" : "submit" } );
	// Hidden element
	Modal_CreateHiddenElement( { "name" : args.hidden_name, "value" : args.hidden_value } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );


	RD_Display_Log();	// displays the debug log if rDebug is set to true
}
/*
	var args = 	{
										"header_class" : 			"none",
										"text_header" : 			"<? T('feedback_text_8'); ?>",
										"text_thank_you" : 		"<? T('feedback_text_10'); ?>",
										"text_important" :		"<? T('feedback_text_11'); ?>",
										"text_close" :				"<? T('feedback_text_9'); ?>",
									};
*/
function Modal_FeedbackConfirm( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "550", "height" : "250" } );

	Modal_CreateLabel( { "text" : args.text_thank_you,				"x" : "center", "y" : "65", 	"label_class" : "textbox_label" } );
	Modal_CreateLabel( { "text" : args.text_important,				"x" : "center", "y" : "85", 	"label_class" : "textbox_label" } );

	Modal_CreateButton( { "name" : "close", 									"x" : "center", "y" : "125", "value" : args.submit_value, "text" : args.text_close, "button_class" : "button_M", "type" : "close" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_SendToFriend()
* search-code FXSENDTOFRIEND FXSHARE FXFRIEND
* @date 5/28/2010
* @author Rach
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header								"Find this page useful?"
* @param 	args.text_privacy1							"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2							"privacy policy"
* @param	args.text_name									"Your name:"
* @param	args.text_friends_email					"Friends email:"
* @param	args.text_subject								"Subject"
* @param	args.text_send									"Send" - for button
* ------------------------------------------------------------------------------
* Input field name/ids (if any)
* @param	args.input_name									ID of the textbox for entering their name
* @param	args.input_email								ID of textbox for entering friend's email
* @param	args.input_subject							ID of the subject textbox
* @param	args.submit_name								ID of the submit button
*/
function Modal_SendToFriend( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "525", "height" : "400" } );
	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : ERROR_DIV_POS_Y, "w" : "100%" } );
	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	// Name field
	Modal_CreateLabel( { "text" : args.text_name, 							"x" : "10%", 		"y" : "120", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_name, 						"x" : "40%", 		"y" : "120",	"size" : "medium", "validation_flags" : "required_field alphabet_field" } );
	// Friends email
	Modal_CreateLabel( { "text" : args.text_friends_email, 			"x" : "10%", 		"y" : "160", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_email, 					"x" : "40%", 		"y" : "160",	"size" : "medium", "validation_flags" : "required_field email_field" } );
	// Subject
	Modal_CreateLabel( { "text" : args.text_subject, 						"x" : "10%", 		"y" : "200", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_subject, 				"x" : "40%", 		"y" : "200",	"size" : "medium", "validation_flags" : "required_field" } );
	// Send
	Modal_CreateButton( { "name" : args.submit_name, 						"x" : "80%", 		"y" : "250", "value" : args.text_send, "text" : args.text_send, "button_class" : "button_M", "type" : "submit" } );
	// Hidden element
	Modal_CreateHiddenElement( { "name" : "command", "value" : "send_page" } );
	Modal_CreateHiddenElement( { "name" : "send_url", "value" : args.send_url } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
} /************************* Modal_SendToFriend() *****************************/

/**
* Modal_SendToFriendConfirm( args )
* Displays a confirmation modal to let user know that the email to their friend has been sent
* @date 6/3/2010
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class						Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Variable information
* @param 	args.recipient_email				Email address it was sent to
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header						"Your message is being processed." (header text)
* @param 	args.text_message_sent			"We've sent your email to"
* @param 	args.text_close							"Close Window"
*/
function Modal_SendToFriendConfirm( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "525", "height" : "250" } );
	//"Your message has been sent"
	Modal_CreateLabel( { "text" : args.text_message_sent,				"x" : "center", "y" : "65", 	"label_class" : "textbox_label" } );
	// Recipient Email
	Modal_CreateLabel( { "text" : args.recipient_email, 				"x" : "center", "y" : "85", 	"label_class" : "textbox_label" } );
	// Send button
	if ( args.submit_value == undefined ) { args.submit_value = args.text_close; }
	Modal_CreateButton( { "name" : "close", 										"x" : "center", "y" : "125", "value" : args.submit_value, "text" : args.text_close, "button_class" : "button_M", "type" : "close" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_Inquiry()
* Creates an inquiry form for users to submit a question to a facility owner
*
* Requires privacy policy to be linked!
*
* @date 6/10/2010
* @author Rachel
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class						Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header						"Send us an inquiry!"
* @param 	args.text_privacy1					"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2					"privacy policy"
* @param 	args.text_name_first				"First name:"
* @param 	args.text_name_last					"Last name:"
* @param 	args.text_email							"Email:"
* @param 	args.text_phone							"Daytime phone:"
* @param 	args.text_questions					"Questions?"
* @param 	args.text_send							"Send"
* ------------------------------------------------------------------------------
* Input field name/ids
* @param	args.input_name_first
* @param	args.input_name_last
* @param	args.input_email
* @param	args.input_phone
* @param	args.input_questions
* @param	args.submit_name						ID of the submit button
*/
function Modal_Inquiry( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "525", "height" : "550" } );

	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : ERROR_DIV_POS_Y, "w" : "100%" } );
	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	// First name field
	Modal_CreateLabel( 		{ "text" : args.text_name_first, 							"x" : "10%", 		"y" : "120", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_name_first, 						"x" : "40%", 		"y" : "120",	"size" : "medium", "validation_flags" : "required_field alphabet_field" } );
	// Last name field
	Modal_CreateLabel( 		{ "text" : args.text_name_last, 							"x" : "10%", 		"y" : "160", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_name_last, 						"x" : "40%", 		"y" : "160",	"size" : "medium", "validation_flags" : "required_field alphabet_field" } );
	// Email field
	Modal_CreateLabel( 		{ "text" : args.text_email, 							"x" : "10%", 		"y" : "200", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_email, 						"x" : "40%", 		"y" : "200",	"size" : "medium", "validation_flags" : "required_field email_field" } );
	// Phone field
	Modal_CreateLabel( 		{ "text" : args.text_phone, 							"x" : "10%", 		"y" : "240", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_phone, 						"x" : "40%", 		"y" : "240",	"size" : "medium", "validation_flags" : "required_field phone_field" } );
	// Question field
		Modal_CreateLabel( { "text" : args.text_questions, 						"x" : "10%", 		"y" : "280", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextarea( { "name" : args.input_questions, 				"x" : "40%", 		"y" : "280", 	"w" : "236", "h" : "100",	"size" : "medium", "validation_flags" : "required_field" } );
	// Send button
	if ( args.submit_value == undefined ) { args.submit_value = "submit"; }
	Modal_CreateButton( { "name" : "submit", 										"x" : "80%", "y" : "400", "value" : args.submit_value, "text" : args.text_send, "button_class" : "button_M", "type" : "submit" } );

	Modal_CreateHiddenElement( { "name" : "command", "value" : "question_guest" } );
	Modal_CreateHiddenElement	( { "name" : "subject", "value" : "&nbsp;" } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_InquiryConfirm( args )
* Displays a confirmation modal to let user know that the inquiry was sent to the owner.
* @date 6/10/2010
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class						Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header						"Your inquiry is being processed." (header text)
* @param 	args.text_message1
* @param 	args.text_message2
* @param 	args.text_close							"Close Window"
*/
function Modal_InquiryConfirm( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "525", "height" : "250" } );
	Modal_CreateLabel( { "text" : args.text_message1,				"x" : "center", "y" : "65", 	"label_class" : "textbox_label" } );
	Modal_CreateLabel( { "text" : args.text_message2,				"x" : "center", "y" : "85", 	"label_class" : "textbox_label" } );
	// Send button
	if ( args.submit_value == undefined ) { args.submit_value = args.text_close; }
	Modal_CreateButton( { "name" : "close", 										"x" : "center", "y" : "115", "value" : args.submit_value, "text" : args.text_close, "button_class" : "button_M", "type" : "close" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

function Modal_AdminUpdates( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "600", "height" : "550" } );


   var box = document.getElementById('modal_body');
   var a = document.createElement('div');
   a.className = ('update_box');
   box.appendChild(a);

   a.innerHTML =    "<div>"+args.text_content+"</div>";


/*    Modal_CreateLabel( { "text" : args.text_message1,				"x" : "0", "y" : "85", 	"label_class" : "owner_admin_header_1"} );
    Modal_CreateLabel( { "text" : args.text_message2,				"x" : "0", "y" : "100", 	"label_class" : "owner_admin_text_1" } );
    Modal_CreateLabel( { "text" : args.text_message3,				"x" : "0", "y" : "120", 	"label_class" : "owner_admin_text_2" } );*/



	// Send button
	if ( args.submit_value == undefined ) { args.submit_value = args.text_close; }
	Modal_CreateButton( { "name" : "close",   "x" : "50", "y" : "400", "value" : args.submit_value, "text" : args.text_close, "button_class" : "button_M green_M", "type" : "close" } );
    	Modal_CreateImage( { "filename" : "ice_cream_sheep.png", "x" : "310", "y" : "316" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_Reserve_NoApi()
* Create a reservation form that sends an email to the facility owner.
* This is used when there is no Api functionality set up.
*
* Requires privacy policy to be linked!
*
* @date 6/10/2010
* @author Rachel
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class						Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header						"Send us an inquiry!"
* @param 	args.text_privacy1					"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2					"privacy policy"
* @param 	args.text_first_name				"First name:"
* @param 	args.text_last_name					"Last name:"
* @param 	args.text_email							"Email:"
* @param 	args.text_phone							"Daytime phone:"
* @param 	args.text_send							"Send"
* ------------------------------------------------------------------------------
* Input field name/ids
* @param	args.input_name_first
* @param	args.input_name_last
* @param	args.input_email
* @param	args.input_phone
* @param	args.submit_name						ID of the submit button
* ------------------------------------------------------------------------------
* Other values (facility info)
* @param args.what			Size of the facility.  Will be set as "N/A" if not given.
* @param args.price			Price of the facility.  Will be set as "N/A" if not given.
* @param args.desc			Description of the facility.  Will be set as "N/A" if not given.
* @param args.features	Features of the facility.  Will be set as "N/A" if not given.
*/
function Modal_Reserve_NoApi( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "525", "height" : "400" } );

	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : ERROR_DIV_POS_Y, "w" : "100%" } );
	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	// First name field
	Modal_CreateLabel( 		{ "text" : args.text_name_first, 							"x" : "10%", 		"y" : "120", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_name_first, 						"x" : "40%", 		"y" : "120",	"size" : "medium", "validation_flags" : "required_field alphabet_field" } );
	// Last name field
	Modal_CreateLabel( 		{ "text" : args.text_name_last, 							"x" : "10%", 		"y" : "160", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_name_last, 						"x" : "40%", 		"y" : "160",	"size" : "medium", "validation_flags" : "required_field alphabet_field" } );
	// Email field
	Modal_CreateLabel( 		{ "text" : args.text_email, 							"x" : "10%", 		"y" : "200", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_email, 						"x" : "40%", 		"y" : "200",	"size" : "medium", "validation_flags" : "required_field email_field" } );
	// Phone field
	Modal_CreateLabel( 		{ "text" : args.text_phone, 							"x" : "10%", 		"y" : "240", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox(	{ "name" : args.input_phone, 						"x" : "40%", 		"y" : "240",	"size" : "medium", "validation_flags" : "required_field phone_field" } );
	// Send button
	if ( args.submit_value == undefined ) { args.submit_value = "submit"; }
	Modal_CreateButton( { "name" : "submit", 										"x" : "80%", "y" : "275", "value" : args.submit_value, "text" : args.text_send, "button_class" : "button_M", "type" : "submit" } );

	if ( args.what == undefined ) 		{ args.what = "N/A"; }
	if ( args.price == undefined ) 		{ args.price = "N/A"; }
	if ( args.desc == undefined ) 		{ args.desc = "N/A"; }
	if ( args.features == undefined ) { args.features = "N/A"; }

	Modal_CreateHiddenElement	( { "name" : "command", 	"value" : "reserve_guest" } );
	Modal_CreateHiddenElement	( { "name" : "what", 		 	"value" : args.what } );
	Modal_CreateHiddenElement	( { "name" : "miscinfo", 	"value" : "general" } );
	Modal_CreateHiddenElement	( { "name" : "price", 		"value" : args.price } );
	Modal_CreateHiddenElement	( { "name" : "desc", 		 	"value" : decodeURI( args.desc ) } );
	Modal_CreateHiddenElement	( { "name" : "features",  "value" : args.features } );

	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_ReserveConfirm( args )
* Displays a confirmation modal to let user know that the inquiry was sent to the owner.
* @date 6/10/2010
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class						Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header						"Your reservation is being processed." (header text)
* @param 	args.text_message
* @param 	args.text_close							"Close Window"
*/
function Modal_ReserveConfirm( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "525", "height" : "250" } );
	Modal_CreateLabel( { "text" : args.text_message,				"x" : "center", "y" : "65", 	"label_class" : "textbox_label" } );
	// Send button
	if ( args.submit_value == undefined ) { args.submit_value = args.text_close; }
	Modal_CreateButton( { "name" : "close", 										"x" : "center", "y" : "115", "value" : args.submit_value, "text" : args.text_close, "button_class" : "button_M", "type" : "close" } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_QS_Reservation()
* @date 6/7/2010
* @author RR
*
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Variable information
* @param 	args.lender_phone								Lender phone number
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_send_email						"Send Email" (header text)
* @param 	args.text_thank_you							"Thank you for the email"
* @param 	args.text_feel_free_to_call			"Also, feel free to call if you would like to chat"
* @param 	args.text_privacy1							"We take your privacy very seriously at LenderStreet.  View our"
* @param 	args.text_privacy2							"privacy policy"
* @param 	args.text_name									"Name:"
* @param 	args.text_phone									"Phone:"
* @param 	args.text_email									"Email:"
* @param 	args.text_address								"Address:"
* @param 	args.text_send									"Send" for the Submit button
* ------------------------------------------------------------------------------
* Input field name/ids (if any)
* @param	args.input_name									ID of textbox for entering your name
* @param	args.input_email								ID of textbox for entering your email
* @param	args.input_phone								ID of textbox for entering your phone
* @param	args.input_address							ID of textbox for entering your address
* @param	args.submit_name								ID of the submit button
* ------------------------------------------------------------------------------
* Other
* @param	args.submit_value								Value of the submit textbox
* @param	args.hidden_name								Hidden input name/id
* @param	args.hidden_value								Hidden input value
* @param unitID												The unit's ID #
* @param size												The unit's size
* ------------------------------------------------------------------------------
*/
function Modal_QS_Reservation( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	//required_field as a class flag
	
	//switch CreateWindows functions when
	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "550", "height" : "530" } );	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	// Error div
	Modal_CreateErrorContainer( { "x" : "center", "y" : "40", "w" : "100%" } );
	// Name field
	Modal_CreateLabel( { "text" : args.text_name, "x" : "10%", 		"y" : "120", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_name, "x" : "40%", 		"y" : "120",	"size" : "medium", "validation_flags" : "required_field" } );

	Modal_CreateLabel( { "text" : args.text_email, "x" : "10%", 		"y" : "160", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_email, "x" : "40%", 		"y" : "160",	"size" : "medium", "validation_flags" : "required_field"  } );

	Modal_CreateLabel( { "text" : args.text_phone, "x" : "10%", 		"y" : "200", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_phone, "x" : "40%", 		"y" : "200",	"size" : "medium", "validation_flags" : "required_field" } );

	Modal_CreateLabel( { "text" : args.text_address, "x" : "10%", 		"y" : "240", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_address, "x" : "40%", 		"y" : "240",	"size" : "medium", "validation_flags" : "required_field"  } );
		
	Modal_CreateLabel( { "text" : args.text_city, "x" : "10%", 		"y" : "280", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_city, "x" : "40%", 		"y" : "280",	"size" : "medium", "validation_flags" : "required_field"  } );
	
	Modal_CreateLabel( { "text" : args.text_state, "x" : "10%", 		"y" : "320", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_state, "x" : "40%", 		"y" : "320",	"size" : "medium", "validation_flags" : "required_field"  } );
	
	Modal_CreateLabel( { "text" : args.text_zip, "x" : "10%", 		"y" : "360", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateTextbox( { "name" : args.input_zip, "x" : "40%", 		"y" : "360",	"size" : "medium", "validation_flags" : "required_field"  } );
	
	// Send
	Modal_CreateButton( { "name" : args.submit_name, "x" : "80%", 		"y" : "400", "value" : args.text_send, "text" : args.text_send, "button_class" : "button_M green_M", "type" : "submit" } );

	// Hidden element
	Modal_CreateHiddenElement( { "name" : args.hidden_name, "value" : args.hidden_value } );
	Modal_CreateHiddenElement( { "name" : "unitID", "value" : args.unitID } );
	Modal_CreateHiddenElement( { "name" : "size", "value" : args.size } );
	Modal_CreateHiddenElement( { "name" : "addressDEBUG", "value" : "debug" } );
	Modal_CreateHiddenElement( { "name" : botCheckField, "value" : "" } );
	Modal_CreateHiddenElement( { "name" : "price", "value" : args.price } );
	Modal_CreateHiddenElement( { "name" : "features", "value" : args.features } );
	Modal_CreateHiddenElement( { "name" : "desc", "value" : args.desc } );

	RD_Display_Log();	// displays the debug log if rDebug is set to true
}

/**
* Modal_PleaseWait()
* @author RReeves
* @date 6/7/2010
* http://superawesomeninjasquad.info/documentation/storagefrontv2_modal_pleasewait
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header								Header text ("please wait")
* ------------------------------------------------------------------------------
* Other
* @param 	args.no_validation							Turns on/off form validation for debugging.
*/
function Modal_PleaseWait( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "325", "height" : "250", "no_validation" : args.no_validation } );
	
	Modal_CreateImage( { "filename" : "ajax-loader.gif", "x" : "100", "y" : "100" } );
	
	RD_Display_Log();
}


/**
* Modal_PleaseWait()
* @author RReeves
* @date 6/7/2010
* http://superawesomeninjasquad.info/documentation/storagefrontv2_modal_pleasewait
* Arguments are stored in a JSON object
* ------------------------------------------------------------------------------
* Styling
* @param args.header_class								Name of a class that specifies a background color or image, for use with the header
* ------------------------------------------------------------------------------
* Language support
* @param 	args.text_header								Header text ("please wait")
* ------------------------------------------------------------------------------
* Other
* @param 	args.no_validation							Turns on/off form validation for debugging.
*/
function Modal_ResError( args )
{
	if ( args.header_class == "" || args.header_class == "none" )
		args.header_class = "default_header";

	Modal_CreateWindow( { "header_text" : args.text_header, "header_class" : args.header_class, "width" : "550", "height" : "280" } );	// Privacy Policy
	Modal_CreatePrivacyPolicy( { "text1" : args.text_privacy1, "text2" : args.text_privacy2, "x" : "center", "y" : "80", "label_class" : "privacy_policy", "horiz_align" : "center" } );
	Modal_CreateLabel( { "text" : args.text_name, "x" : "10%", 		"y" : "80", 	"label_class" : "textbox_label", "horiz_align" : "left" } );
	Modal_CreateButton( { "name" : args.submit_name, "x" : "85%", 		"y" : "150", "value" : args.text_send, "text" : args.text_send, "button_class" : "button_M green_M", "type" : "submit" } );
	
	RD_Display_Log();
}


/******************************************************************************************************************/
/******************************************************************************************************************/
/********************* "private" functions - for use by the library's Generate functions only *********************/
/****************************** Do not call from the pages, use the public functions ******************************/
/******************************************************************************************************************/
/******************************************************************************************************************/

/******************************************************************************/
/*********************************************************** ELEMENT CREATION */
/******************************************************************************/

/**
* @param 	args.name
* @param	args.value
*/
function Modal_CreateHiddenElement( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating hidden element:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className 			= "modal_div";
	container.name = "modal_div-hidden_element";
	container.style.display 	= "none";

	PositionElement( { "container" : container, "x" : "0", "y" : "0" } );

	container.innerHTML = "<input type='hidden' name='"+args.name+"' id='"+args.name+"' value='"+args.value+"' />";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending hidden div to modal:\n" + error );
	}
}

/**
* Modal_CreatePrivacyPolicy( args )
* search-code FXCREATEPRIVACYPOLICY FXPRIVACYPOLICY
*
* @param	args.text1					"We take your privacy very seriously at LenderStreet.  View our" text
* @param	args.text2					"privacy policy" text
* @param	args.x							X position : can be a number ("30"), a percent ("50%"), or say ("center")
* @param	args.y							Y position
* @param	args.label_class		Label class for font styling
* @param	args.horiz_align		Horizontal alignment for text
*/
function Modal_CreatePrivacyPolicy( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) 	{ RD_Append_Log( "Error creating privacy policy statement:\nCannot find parent div '#modal_body'." ); return; }

	if ( POLICY_PATH == -1 ) 		{ RD_Append_Log( "Error creating privacy policy:\nNo privacy policy url path specified.  Please call Modal_SetPrivacyPolicyPath( path )." ); return; }

	var container = document.createElement( "div" );
	container.className 			= "modal_div";
	container.name = "modal_div-privacy_policy";

	if ( args.horiz_align == "left" ) 			{ container.className += " align_h_left"; }
	else if ( args.horiz_align == "right" ) { container.className += " align_h_right"; }
	else 																		{ container.className += " align_h_center"; }

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y } );

	container.innerHTML = 	"<label class='"+args.label_class+"'>"+args.text1+" <a href='"+POLICY_PATH+"'>"+args.text2+"</a></label>";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending privacy policy div to modal:\n" + error );
	}
} /*********************** Modal_CreatePrivacyPolicy() ************************/

/**
* Modal_CreateImage( args )
* search-code FXCREATEIMAGE FXIMAGE
*
* @param 	args.filename		 		Filename of the image (ex, "llama.png")
* @param	args.x							X Position
* @param	args.y							Y Position
*/
function Modal_CreateImage( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating image:\nCannot find parent div '#modal_body'." ); return; }

	if ( ASSET_PATH == -1 ) { RD_Append_Log( "Error creating image:\nNo asset path specified.  Please call Modal_SetAssetPath( path )." ); return; }

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.name = "modal_div-image";

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y } );

	var path = ASSET_PATH + "/images/" + args.filename;
	container.innerHTML = "<img src='"+path+"' />";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending label div to modal:\n" + error );
	}
} /************************* Modal_CreateImage() ******************************/
function Modal_CreateAdminLabel( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating label:\nCannot find parent div '#modal_body'." ); return; }

    var container = document.createElement( "div" );
	container.className 			= "test_div";
	container.name = "test_div-label";

	var container = document.createElement( "div" );
	container.className 			= "modal_div";
	container.name = "modal_div-label";

	if ( args.horiz_align == "left" ) 			{ container.className += " align_h_left"; }
	else if ( args.horiz_align == "right" ) { container.className += " align_h_right"; }
	else 																		{ container.className += " align_h_center"; }

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y, "w" : args.w, "h" : args.h } );

	container.innerHTML = 	"<label class='"+args.label_class+"'>"+args.text+"</label>";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending label div to modal:\n" + error );
	}
}

/**
* Modal_CreateLabel()
* search-code FXCREATELABEL FXLABEL
*
* @param	args.text						What the label says
* @param	args.x							X position : can be a number ("30"), a percent ("50%"), or say ("center")
* @param	args.y							Y position
* @param	args.w							Width of the text block (optional)
* @param	args.label_class		Label class for font styling
* @param	args.horiz_align		Horizontal alignment for text
*/
function Modal_CreateLabel( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating label:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className 			= "modal_div";
	container.name = "modal_div-label";

	if ( args.horiz_align == "left" ) 			{ container.className += " align_h_left"; }
	else if ( args.horiz_align == "right" ) { container.className += " align_h_right"; }
	else 																		{ container.className += " align_h_center"; }

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y, "w" : args.w, "h" : args.h } );

	container.innerHTML = 	"<label class='"+args.label_class+"'>"+args.text+"</label>";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending label div to modal:\n" + error );
	}
} /************************* Modal_CreateLabel() ******************************/

/**
* Modal_CreateTextbox()
* search-code FXCREATETEXTBOX FXTEXTBOX
*
* @param	args.name					 		Name and ID of the textbox
* @param	args.x								X position : can be a number ("30"), a percent ("50%"), or say ("center")
* @param	args.y								Y position
* @param	args.size							Textbox size ("medium")
* @param	args.validation_flags	For the Field Validation script
*/
function Modal_CreateTextbox( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating textbox:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.name = "modal_div-textbox";

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y } );

	var h = 25;

	container.innerHTML =	"<div class='field_textbox'>"+
													/* Styled textbox border */
													"<div class='textbox_wrapper_"+args.size+"'>"+
														"<input type='text' name='"+args.name+"' id='"+args.name+"' class='"+args.validation_flags+"' />"+
													"</div>"+
												"</div>";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending textbox div to modal:\n" + error );
	}
} /************************* Modal_CreateTextbox() ****************************/

/**
* Modal_CreateTextarea()
* search-code FXCREATETEXTAREA FXTEXTAREA
*
* @param	args.name					 		Name and ID of the textarea
* @param	args.x								X position : can be a number ("30"), a percent ("50%"), or say ("center")
* @param	args.y								Y position
* @param	args.w								Textbox width
* @param	args.h								Textbox height
* @param	args.validation_flags	For the Field Validation script
* @param	args.default_text			Default text
*/
function Modal_CreateTextarea( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating textarea:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.name = "modal_div-textarea";

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y, "w" : args.w, "h" : args.h } );

	var b = 10; // textarea border w/h for a corner piece.
	var p = 10; // padding

	if ( args.default_text == null )
		args.default_text = "";

	container.innerHTML =	"<div class='field_textbox'>"+
													"<textarea name='"+args.name+"' id='"+args.name+"' class='"+args.validation_flags+"' style='height:"+(args.h-p)+"px; width:"+(args.w-p)+"px;'>"+args.default_text+"</textarea>"+
													/* Styled textbox border */
													"<div class='textarea_top' 		style='width:"+(args.w-2*b)+"px; left:"+b+"px;'></div>"+
													"<div class='textarea_bottom' style='width:"+(args.w-2*b)+"px; left:"+b+"px;''></div>"+
													"<div class='textarea_left'		style='height:"+(args.h-2*b)+"px; top:"+b+"px;''></div>"+
													"<div class='textarea_right'	style='height:"+(args.h-2*b)+"px; top:"+b+"px;''></div>"+

													"<div class='textarea_topleft'></div>"+
													"<div class='textarea_topright'></div>"+
													"<div class='textarea_bottomleft'></div>"+
													"<div class='textarea_bottomright'></div>"+
												"</div>";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending textarea div to modal:\n" + error );
	}
} /************************* Modal_CreateTextarea() ****************************/

/**
* Modal_CreateVideo()
* search-code FXCREATEVIDEO FXVIDEO
*
* @param	args.x								X position : can be a number ("30"), a percent ("50%"), or say ("center")
* @param	args.y								Y position
* @param	args.w								Width
* @param	args.h								Height
* @param	args.url							URL to video
* @param	args.from							Where the video is from (Supported: "youtube")
*/
/*
	DON'T USE THIS, USE THE Modal_Custom() FUNCTION INSTEAD.  SEE DOCUMENTATION ON DOKU FOR HELP.
*/
function Modal_CreateVideo( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating video:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.name = "modal_div-depreciated-video";

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y, "w" : args.w, "h" : args.h } );

	// Doesn't seem like I can give these variables through Javascript, but I can hard-code in dimensions...
	if ( args.from == "youtube" )
	{
		container.innerHTML = "<object width='425' height='355'>"+
														"<param name='movie' value='http://www.youtube.com/v/"+args["video_id"]+"'></param>"+
														"<param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param>"+
														//"<embed src='http://www.youtube.com/v/rktiigc7VbM&hl=en_US&fs=1&' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='425' height='355'></embed>"+
														"<embed src='http://www.youtube.com/v/"+args.url+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='425' height='355'></embed>"+
										 		"</object>";
	}
	else if ( args.from == "vimeo" )
	{
		container.innerHTML = "<object width='425' height='355'>"+
														"<param name='allowfullscreen' value='true' />"+
														"<param name='allowscriptaccess' value='always' />"+
														"<param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=5497155&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' />"+
														"<embed src='http://vimeo.com/moogaloop.swf?clip_id=5497155&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='425' height='355'></embed>"+
													"</object>";
	}
	else
	{
		RD_Append_Log( "Error appending video div to modal:\nInvalid video type, must be from YouTube or Vimeo." );
	}

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending video div to modal:\n" + error );
	}
} /************************** Modal_CreateVideo() *****************************/

/**
* Modal_CreateButton()
* search-code FXCREATEBUTTON FXBUTTON
*
* @param	args.name					 		Name and ID of the button
* @param	args.value					 	Value of the button
* @param	args.text					 		Text on button
* @param	args.x								X position : can be a number ("30"), a percent ("50%"), or say ("center")
* @param	args.y								Y position
* @param	args.type							Type of button ("submit", "close", "link")
* @param	args.button_class			Button class specs
* @param	args.url							URL to another page, for use when type is "link"
*/
function Modal_CreateButton( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating button:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.name = "modal_div-button";

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y } );

	var buttonType;
	/*
	"<button class='"+buttonOptions+"' type='submit' id='"+buttonid+"' name='"+buttonid+"'><em>" +
													"<span></span>" + buttonText +
												"</em></button>";
	*/
	if ( args.type == "submit" )
	{
		container.innerHTML =	"<button type='submit' class='"+args.button_class+"' value='"+args.value+"'>"+
														"<em><span></span>"+args.text+"</em>"+
													"</button>";
	}
	else if ( args.type == "close" )
	{
		container.innerHTML =	"<button type='button' class='"+args.button_class+"' value='"+args.value+"' onclick='javascript:Modal_Close()'>"+
														"<em><span></span>"+args.text+"</em>"+
													"</button>";
	}
	else if ( args.type == "link" )
	{
		// Check for target
		var target = "";
		if (args.target && args.target.length > 0)
			target = args.target;

		// Button will be an a href to link elseware.
		container.innerHTML = 	"<a class='no_underline nounderline' href='"+args.url+"' target='"+target+"'>"+
															"<div class='"+args.button_class+"'>"+
																"<em><span></span>"+args.text+"<img src='"+ASSET_PATH+"/images/icon_arrowright.png' style='margin-left:10px;' />"+
																"</em>"+
															"</div>"+
														"</a>";
	}
	else if ( args.type == "new_modal" )
	{
		// Navigates to new modal
		container.innerHTML =	"<button type='button' class='"+args.button_class+"' onclick='Modal_GetDirections()' value='"+args.value+">"+
														"<span>"+args.text+"</span><em>&nbsp;</em>"+
													"</button>";
	}
	else
	{
		// Just show a button that does nothing
		container.innerHTML =	"<button type='button' class='"+args.button_class+"' value='"+args.value+">"+
														"<span>Invalid button type</span><em>&nbsp;</em>"+
													"</button";
	}

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending button div to modal:\n" + error );
	}
} /************************* Modal_CreateButton() ****************************/

/**
* Modal_CreateErrorContainer()
* search-code FXCREATEERRORCONTAINER FXERROR
*
* @param	args.x					X position
* @param	args.y					Y position
* @param	args.w			 		Width of the div
*/
function Modal_CreateErrorContainer( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating error container:\nCannot find parent div '#modal_body'." ); return; }

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.name = container.id = "modal_div-error_container";

	PositionElement( { "container" : container, "x" : args.x, "y" : args.y, "w" : args.w } );

	container.innerHTML = "<div class='error_dialog' name='validation_error' id='validation_error' style='display:none;'></div>";

	try { parentModal.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending error container div to modal:\n" + error );
	}
} /********************* Modal_CreateErrorContainer() *************************/

/**
* Modal_CreateMap()
* search-code FXCREATEMAP FXMAP FXGOOGLEMAP FXGMAP
*
* @param	args.x								X position
* @param	args.y								Y position
* @param	args.lender_address		Lender address
* @param	args.lat							Lender address latitude
* @param	args.long							Lender address longitude
*/
function Modal_CreateMap( args )
{
	var parentModal = document.getElementById( "modal_body" );
	if ( parentModal == null ) { RD_Append_Log( "Error creating error container:\nCannot find parent div '#modal_body'." ); return; }

	// dhowe 5/30/10 - need to add a second container for scrolling, use this as the parent for the two containers below
	var scrollContainer = document.createElement( "div" );
	scrollContainer.className = "modal_div_scroll_container";
	scrollContainer.id = scrollContainer.name = "scroll_container";
	scrollContainer.style.position = "relative";
	scrollContainer.style.width = "624px";
	scrollContainer.style.height = "465px";
	scrollContainer.style.top = "60px";
	scrollContainer.style.overflowY = "auto";
	scrollContainer.style.overflowX = "hidden";
	scrollContainer.name = "modal_div-map";

	try { parentModal.appendChild( scrollContainer ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending scroll container container &nbsp;div to modal:\n" + error );
	}

	var container = document.createElement( "div" );
	container.className = "modal_div";
	container.id = container.name = "map_canvas";
	container.style.width = "600px";
	container.style.height = "300px";
	container.style.border = "2px solid #E5E3DF";

	//PositionElement( { "container" : container, "x" : args.x, "y" : args.y } );

	try { scrollContainer.appendChild( container ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending map container div to modal:\n" + error );
	}

	var directionSteps = document.createElement( "div" );
	directionSteps.className = "modal_div";
	directionSteps.name = directionSteps.id = "directions_steps";
	directionSteps.style.width = "600px";
	directionSteps.style.position = "absolute";
	directionSteps.style.top = "300px";

 //	PositionElement( { "container" : directionSteps, "x" : args.x, "y" : (args.y + 300) } );

	try { scrollContainer.appendChild( directionSteps ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending directions container div to modal:\n" + error );
	}

	/********************************/
	/*********** MAPS CODE **********/
	/********************************/

	var map = new GMap2( document.getElementById( "map_canvas" ) )
	var directions = new GDirections( map, document.getElementById( "directions_steps" ) );

	// Setup the map
	map.addControl( new GSmallMapControl() );
	map.addControl( new GScaleControl() );
	map.disableScrollWheelZoom();
	map.setCenter(new GLatLng(args.to_lat, args.to_long), 13);

	if ( args.want_directions != "no" )
	{
		// todo: get from_address from user
		var from = "66049";//args.from_address;//$("#"+GLOBAL_ARGS.input_from_address).val();
		var to = args.lender_address;
		var directionString = "from: " + from + " to: " + to;
		alert(directionString);
		var a = window.setTimeout("window.print();",2000);
	}
	else
	{
		// Only drop a pin for the location if we aren't rendering directions
		map.addOverlay( new GMarker(new GLatLng(args.to_lat, args.to_long)) );
	}

	directions.load( directionString );
} /********************* Modal_CreateErrorContainer() *************************/


/**
* Modal_CreateWindow()
* search-code FXCREATEWINDOW FXWINDOW
*
* @param	args.header_text		The text that will be displayed on the modal's header
* @param	args.header_class		The class name of the header - should be stored in the template's css file.
* @param	args.width					Width of the modal
* @param	args.height			 		Height of the modal
* @param	args.no_validation
*/
function Modal_CreateWindow( args )
{
	var header_text = args.header_text, header_class = args.header_class, w = args.width, h = args.height;
	RD_Set_Log( false );
	// Make sure that the modal is big enough; else it will look weird
	if ( w < MIN_MODAL_W || h < MIN_MODAL_H )
	{
		RD_Append_Log( "Error creating base window:\nWidth or Height is below minimum dimensions." );
	}

	var veil = document.createElement("div");
	veil.className = "veil";
	veil.id = "veil";
	veil.name = "veil";

	var superContainer							= document.createElement("div");
	superContainer.className				= "super_modal_container";
	superContainer.id								= "super_container";
	superContainer.name							= "super_container";

	var modal 					= document.createElement("div");
  modal.id 						= "div_modal_container";
  modal.name 					= "div_modal_container";
  modal.className 		= "modal_container";
  modal.style.width 	= w + "px";
  modal.style.height 	= h + "px";
	modal.style.top			= "50px";

	var inner;
	var pad = 27; // padding due to border
	if ( args.no_validation == true || args.no_validation == "true" )
	{
 		inner =  "<form method='post'><fieldset>";
	}
	else
	{
		inner =  "<form method='post' onSubmit='return ValidateRequiredFields()'><fieldset>";
	}
	//modal.innerHTML =  "<form method='post'><fieldset>" +
	inner += 							"<div class='border_top'          id='border_top' 		name='border_top'			style='left:"+BORDER_W+"px;		width:"+(w-(2*BORDER_W))+"px;  height:"+BORDER_H+"px'></div>" +
			                  "<div class='border_bottom'       id='border_bottom' 	name='border_bottom'	style='left:"+BORDER_W+"px;		width:"+(w-(2*BORDER_W))+"px;  height:"+BORDER_H+"px'></div>" +
			                  "<div class='border_left'         id='border_left' 		name='border_left'		style='top:"+BORDER_H+"px;		width:"+BORDER_W+"px;          height:"+(h-(2*BORDER_H))+"px'></div>" +
			                  "<div class='border_right'        id='border_right' 	name='border_right'		style='top:"+BORDER_H+"px;		width:"+BORDER_W+"px;          height:"+(h-(2*BORDER_H))+"px'></div>" +

			                  "<div class='border_topleft'      style='width:"+BORDER_W+"px;  height:"+BORDER_H+"px'></div>" +
			                  "<div class='border_topright'     style='width:"+BORDER_W+"px;  height:"+BORDER_H+"px'></div>" +
			                  "<div class='border_bottomleft'   style='width:"+BORDER_W+"px;  height:"+BORDER_H+"px'></div>" +
			                  "<div class='border_bottomright'  style='width:"+BORDER_W+"px;  height:"+BORDER_H+"px'></div>" +

												/* Main body */
			                  "<div class='modal_background' id='modal_body' name='modal_body' style='left:"+BORDER_W+"px;	top:"+BORDER_H+"px;	width:"+(w-(2*BORDER_W))+"px; height:"+(h-(BORDER_H*2))+"px;'>"+
													/* Header */
													"<div class='modal_header "+header_class+"'	style='left:"+(pad-BORDER_W)+"px; top:"+(pad-BORDER_H)+"px; width:"+(w-2*pad)+"px;'>"+
													"<div name='corner_a' style='position:absolute; left:0px; top:0px; width:3px; height:1px; background:#FFFFFF;'></div>"+
													"<div name='corner_b' style='position:absolute; left:0px; top:0px; width:1px; height:3px; background:#FFFFFF;'></div>"+
														/* Circle "X" button */
														"<a class='button_x' href='javascript:Modal_Close()' style='right:-38px; top:-38px;'></a>"+
														/* Header text */
														"<h2>"+header_text+"</h2>"+
													"</div>"+
												"</div>" +
											"</fieldset></form>";

	modal.innerHTML = inner;

	// Stick things together and throw it on the page- and hope it works. (It should, but who knows.)
	try { document.body.appendChild( veil ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending veil to document:\n" + error );
	}
	try { superContainer.appendChild( modal ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending inner div to super container:\n" + error );
	}
	try { document.body.appendChild( superContainer ); }
	catch ( error )
	{
		RD_Append_Log( "Error appending super container to document:\n" + error );
	}

	$('#div_modal_container').fadeIn( 'slow', function() { ; } );
} /************************* Modal_CreateWindow() *****************************/


/**
* Creates a custom modal window with an iframe interior
*/
function Modal_IFrame( args )
{
   var w = args.modal_w - 54;
   var h = args.modal_h - 118;
   var code = "<iframe id=\""+args.name+"\" name=\""+args.name+"\" width=\""+w+"\" height=\""+h+"\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"auto\" frameborder=\"0\" src=\""+args.url+"\"></iframe>";
   args.code = code;
   Modal_Custom(args);
}


/******************************************************************************/
/*********************************************************** HELPER FUNCTIONS */
/******************************************************************************/

/**
* @param 	args.error_count
* search-code FXRESIZE
*/
function Modal_ResizeWindow( args )
{
	var container = document.getElementById( "div_modal_container" );
	var diff = args.error_count*12 + 65;
	var newH = parseInt( container.style.height ) + diff;

	if ( error_last_resize == -1 )	// no errors have been displayed yet.
	{
		// Push the window up
		container.style.top = ( parseInt( container.style.top ) - ( diff/2 ) ) + "px";
		container.style.height = newH + "px";
		var newW = parseInt( container.style.width );

		// Resize border
		var borderDiv = document.getElementById( "border_top" );
			borderDiv.style.width = ( newW - ( 2 * BORDER_W ) ) + "px";
		var borderDiv = document.getElementById( "border_bottom" );
			borderDiv.style.width = ( newW - ( 2 * BORDER_W ) ) + "px";
		var borderDiv = document.getElementById( "border_left" );
			borderDiv.style.height = ( newH - ( 2 * BORDER_H ) ) + "px";
		var borderDiv = document.getElementById( "border_right" );
			borderDiv.style.height = ( newH - ( 2 * BORDER_H ) ) + "px";

		// Resize background
		borderDiv = document.getElementById( "modal_body" )
				RD_Append_Log( "Old modal background height: " + borderDiv.style.height );
			borderDiv.style.height = ( ( newH - 2 * BORDER_H ) - MODAL_HEADER_HEIGHT + BORDER_H+5 )+ "px";
				RD_Append_Log( "New modal background height: " + borderDiv.style.height );
			borderDiv.style.width = ( newW - ( 2 * BORDER_W ) ) + "px";

		// Push fields down
		var fields = $(".modal_div");
		for ( var index=0; index < fields.length; index++ )
		{
			var windowShift = parseInt( fields[index].style.top, 10) + ( diff );
			windowShift += "px";

			try
			{
				if ( fields[index].name != "modal_div-error_container" ) // don't move the error dialog
					fields[index].style.top = windowShift;
			}
			catch ( error )
			{
				RD_Append_Log( "Error trying to resize modal, moving field " + fields[index].name + ": " + error );
			}
		}
	}

	error_last_resize = diff;
}

/**
* Positions an element's parent div based on the values stored in X and Y.
* search-code FXPOSITIONELEMENT
*
* @param 	container		HTML div object
* @param	x						X value given
* @param	Y						Y value given
* @param	W						W value given
* @param	H						H value given
*/
function PositionElement( args )
{
	var container = args.container;

	try
	{
		if ( args.x != undefined )
		{
			if ( args.x.toString() == "center" )		// Centered
			{
				//container.style.marginLeft = container.style.marginRight = "auto";
				container.style.width = "100%";
				container.style.textAlign = "center";
				container.style.left = "0px";
			}
			else if ( args.x.toString().indexOf( "%" ) >= 0 )			// Relative
				container.style.left = args.x;
			else																				// Absolute
				container.style.left = args.x + "px";
		}
	}
	catch ( error )
	{
		RD_Append_Log( "Error positioning element '" + container.name + "'s X Position:\n" + error + "\nargs.x = " + args.x );
	}

	try
	{
		if ( args.y != undefined )
		{
			if ( args.y.toString() == "center" )										// Centered
			{
			}
		  else if ( args.y.toString().indexOf( "%" ) >= 0 )			// Relative
				container.style.top = args.y;
			else																				// Absolute
				container.style.top = args.y + "px";
		}
	}
	catch ( error )
	{
		alert( container.name );
		//RD_Append_Log( "Error positioning element " + container.name "s Y Position:\n" + error + "\nargs.y = " + args.y );
	}

	try
	{
		if ( args.w != undefined )
		{
			if ( args.w.toString().indexOf( "%" ) >= 0 )						// Relative
				container.style.width = args.w;
			else if ( args.w != "" )	 															// Absolute
				container.style.width = args.w + "px";
		}
	}
	catch ( error )
	{
		//RD_Append_Log( "Error positioning element '" + container.name "'s W attribute:\n" + error + "\nargs.w = " + args.w );
	}

	try
	{
		if ( args.h != undefined )
		{
			if ( args.h.toString().indexOf( "%" ) >= 0 )						// Relative
				container.style.height = args.h;
			else if ( args.h != "" )																// Absolute
				container.style.height = args.h + "px";
		}
	}
	catch ( error )
	{
		//RD_Append_Log( "Error positioning element '" + container.name + "'s H attribute:\n" + error + "\nargs.h = " + args.h );
	}
} /*************************** PositionElement() ******************************/






