try	{

/*
var cssNode2 = document.createElement ("link");
cssNode2.setAttribute ("rel", "stylesheet");
cssNode2.setAttribute ("type", "text/css");
cssNode2.setAttribute ("href", "calendar_sapir.css");

document.getElementsByTagName ("head")[0].appendChild (cssNode2);
*/

//window.onload = f_sapir_onload;
//window.onbeforeunload = f_sapir_nocat_unload_before_handler;

//var g_sapir_nocat_window_before_unload_done = false;

// constants
var const_scroller_details_show = "1"; // matches n_cst_scroller_serv.ici_SHOW
var const_scroller_details_hide = "0"; // matches n_cst_scroller_serv.ici_HIDE
var g_sapir_scroller_please_wait_popup = null;

// global variables
var g_sapir_trace_win = null;

var g_sapir_browser_type = "";
var g_sapir_browser_is_ie = false;
var g_sapir_ie_ver = 0;
var g_sapir_location_replace_timeout_id = null;

var g_sapir_lang = "";

var g_sapir_dev_mode = false;
var	g_sapir = true;


var g_sapir_is_popup = false;
var g_sapir_is_ie_modal = false;
var g_sapir_popup_opener;
var g_sapir_popup_ref = null;
var g_sapir_popup_close_notify = false;

var g_sapir_page_id = "";
var g_sapir_page_title = "";

var g_sapir_tif_split_size = "500";

var g_sapir_unload_before = false;
var g_sapir_unload_confirm = true;
var g_sapir_unload_popup = false;
//var g_sapir_unload_popup_cancel = false;
var g_sapir_unload_called_by_app = false;

var	g_sapir_wrapper_el_id = "";

var g_sapir_scroller_debug = "";
var g_sapir_cat_from_scroller_props = null;
var g_sapir_cat_from_scroller_debug = "";

var g_sapir_reader_reg_props = null;
var g_sapir_reader_update_props = null;

var	g_sapir_dataform_names = new Array ();

var	g_sapir_debugger = "1";
//var g_sapir_debugger_breakpoints = new Array ();
//var sapir_breakpoints = new Array ();

var g_sapir_garbage_readystate_timeout_id = null;

var g_sapir_cat_ui_active = false;

var g_sapir_post_onload_timeout_id = null;
//var g_sapir_url = "";
var g_sapir_focus_field = "";

var g_sapir_login_ret = "";
var g_sapir_login_mode = "";
var g_sapir_login_register_url = "";
var g_sapir_re_login_timeout_id = null;

var g_sapir_reader_reg_timeout_id = null;
var g_sapir_reader_update_timeout_id = null;

var g_sapir_item_delete_props= null;

var g_sapir_basket_download_props= null;

var g_sapir_server_check = null;
var g_sapir_server_check_iframe = null;
var g_sapir_server_check_timeout_id = null;

var g_sapir_server_check_iframe_timeout_id = null;
var g_sapir_server_check_iframe_wait_counter = 0;

var g_sapir_split_state = "off";
var g_sapir_splitter = null;
var g_sapir_split_media_url = "";
var g_sapir_split_page = null;

var g_test_split_page_name = "";

var g_sapir_textrea_list = new Array ();

var g_sapir_scroller_width = 0;
var g_sapir_scroller_height = 0;
var g_sapir_media_scroller_width = 0;
var g_sapir_media_scroller_height = 0;

var	/*g_sapir_media_scroller_width = "", */ /*g_sapir_media_scroller_height = "", */ g_sapir_media_scroller_page_size = 0,
		g_sapir_media_upload_width = "", g_sapir_media_upload_height = "";

var g_sapir_is_rte = false;

var g_sapir_stateman_iframe_el = null;

var g_sapir_dbg = true;
var g_sapir_1st_debug = true;
function f_dbg (msg) {	
	/*
	if (g_sapir_1st_debug == true) {
		g_sapir_1st_debug = false;
		parent.document.title = "";
	}
	parent.document.title += msg + ";";
	*/
}

/*
// includes : js
f_sapir_js_load ("user_info.js");
f_sapir_js_load ("entity_dot_net.js");
//f_sapir_js_load ("pb10_htmldw.js");
f_sapir_js_load ("scroller_utils.js");
//document.write("<script LANGUAGE=\"javaScript\"" + " src=\"user_info.js\"" + "><\/script>");
//document.write("<script LANGUAGE=\"javaScript\"" + " src=\"entity_dot_net.js\"" + "><\/script>");
//document.write("<script LANGUAGE=\"javaScript\"" + " src=\"pb10_htmldw.js\"" + "><\/script>");
//document.write("<script LANGUAGE=\"javaScript\"" + " src=\"scroller_utils.js\"" + "><\/script>");

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var contractsymbol='images/minus.gif' //Path to image to represent contract state.
var expandsymbol='images/plus.gif' //Path to image to represent expand state.
*/

// includes : css
/*
var cssNode1 = document.createElement ("link");
cssNode1.setAttribute ("rel", "stylesheet");
cssNode1.setAttribute ("type", "text/css");
cssNode1.setAttribute ("href", "idea.css");
document.getElementsByTagName ("head")[0].appendChild(cssNode1);
*/

/*
function do_onload(){
	if (!g_sapir_cat_ui_active) {
		uniqueidn=window.location.pathname+"firsttimeload"
		var alltags=document.all? document.all : document.getElementsByTagName("*")
		ccollect=getElementbyClass(alltags, "switchcontent")
		statecollect=getElementbyClass(alltags, "showstate")
		if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
		revivecontent()
		if (ccollect.length>0 && statecollect.length>0)
		revivestatus()
		
		if (window.addEventListener)
			window.addEventListener("load", do_onload, false)
		else if (window.attachEvent)
			window.attachEvent("onload", do_onload)
		else if (document.getElementById)
			window.onload=do_onload
		
		if (enablepersist=="on" && document.getElementById)
			window.onunload=saveswitchstate
		
		// Disable posibility to locate picture file name thruegh the browser //
		if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);}
		
		document.onmousedown = rtclickcheck
	}
}
*/

function f_sapir_alert (a_msg) {
	return;
}

function dwdynamic_fields_ItemChanged (row, columnName, newValue) {
	if (columnName == "code" && newValue == "") {
		f_dbg ("setitem_E");
		dwdynamic_fields.SetItem (row, "descr", "");
	}
}

function dwitem_dynamic_ItemChanged (row, columnName, newValue) {
	if (columnName == "code" && newValue == "") {
		f_dbg ("setitem_F");
		dwitem_dynamic.SetItem (row, "descr", "");
	}
}

function f_sapir_flat_ex_scripts_check () {
	// verify all external scripts are available

	if (g_sapir_flat_scripts_counter < g_sapir_flat_scripts_count) {
		return false;
	}
	
	/*
	if (typeof (g_sapir_flat_ex_script_sapir_gen) != "undefined") {
		if (g_sapir_flat_ex_script_sapir_gen == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_scroller_utils) != "undefined") {
		if (g_sapir_flat_ex_script_scroller_utils == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_sapir_breakpoints) != "undefined") {
		if (g_sapir_flat_ex_script_sapir_breakpoints == false) {
			return false;
		}
	}
	
	//if (typeof (g_sapir_flat_ex_script_sapirjsfile) != "undefined") {
	//	if (g_sapir_flat_ex_script_sapirjsfile == false) {
	//		return false;
	//	}
	//}	
	
	if (typeof (g_sapir_flat_ex_script_scripts) != "undefined") {
		if (g_sapir_flat_ex_script_scripts == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_pb10_htmldw) != "undefined") {
		if (g_sapir_flat_ex_script_pb10_htmldw == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_sapir_cat_env) != "undefined") {
		if (g_sapir_flat_ex_script_sapir_cat_env == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_sapir_cat) != "undefined") {
		if (g_sapir_flat_ex_script_sapir_cat == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_sapir_ajax) != "undefined") {
		if (g_sapir_flat_ex_script_sapir_ajax == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_sapir_forms) != "undefined") {
		if (g_sapir_flat_ex_script_sapir_forms == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_calendar_flat) != "undefined") {
		if (g_sapir_flat_ex_script_calendar_flat == false) {
			return false;
		}
	}
	if (typeof (g_sapir_flat_ex_script_richtext) != "undefined") {
		if (g_sapir_flat_ex_script_richtext == false) {
			return false;
		}
	}
	*/
	return true;
}

function f_sapir_dialog_reload (a_dialog_ref) {
	a_dialog_ref.location.replace (a_dialog_ref.location);
	//a_dialog_ref.location.reload (false);
}

function f_sapir_onload (a_page /*, a_title*/ /*, a_event*/) {
	var onload_exception;
	
	//try {
	if (typeof (a_page) != "undefined") {
		g_sapir_page_id = a_page;
	}

	// popup
	g_sapir_is_popup = f_sapir_is_popup ();

	if (g_sapir_is_popup == true) {
		g_sapir_is_ie_modal = f_sapir_is_ie_modal ();
		g_sapir_popup_opener = f_sapir_popup_opener ();

		/*
		if (g_sapir_is_ie_modal) {
			window.opener = g_sapir_popup_opener;
		}
		*/
	}

	//if (g_sapir_page_id == "scroller" || g_sapir_page_id == "field_scroller" || g_sapir_page_id == "cat_scroller" || g_sapir_page_id == "item") {
		// scroller : close "please wait" msg
		if (g_sapir_is_popup == true) {
			var l_parent_wait_typoef  = typeof g_sapir_popup_opener.f_sapir_scroller_please_wait_close;
			if ((l_parent_wait_typoef == "object" || l_parent_wait_typoef == "function")) {
				g_sapir_popup_opener.f_sapir_scroller_please_wait_close ();
			}
		}
	//}
	if (g_sapir_page_id == "scroller_details") {
		parent.f_sapir_please_wait_popup (false, null, "", null, true, "onload : scroller_details");
	}
	
	var l_dataform_count, lidx, l_dw_submit_form, l_param2;
	var l_wrapper_el , l_layoutTable_el, l_content_el, l_form_div_el;
	var l_scr_container_el, l_scr_search_type, l_details_iframe_el, l_info_wrapper_el, l_scr_height_factor;
	var l_flat_calendar_count, l_flat_calendar_idx, l_calendar_lang;
	var l_flat_dw_count, l_flat_dw_idx, l_flat_button_count, l_flat_button_idx, l_navigator_appname, l_logged_user_validation_interval;

	if (typeof (g_sapir_flat_scripts_count) != "undefined") {
		if (g_sapir_onload_timeout_id != null) {	
			clearTimeout (g_sapir_onload_timeout_id);
			g_sapir_onload_timeout_id = null;
		}

		/*
		if (f_sapir_flat_ex_scripts_check () == false) {
			l_navigator_appname = new String (navigator.userAgent).toLowerCase ();

			// script error : let page load, so user will see the error
			// script not loaded : alert and reload
			if (g_sapir_js_error_file.length == 0) {
				if (g_sapir_is_ie_modal == true) {
					self.close ();
				} else {
					if (confirm ("page error, reload ?")) {
						f_sapir_location_reload ();						
					}					 
				}
			} else {
				var l_script_error_msg, l_script_error_idx, l_script_error_count;
				l_script_error_msg = "script error :\r\n" ;
				l_script_error_count = g_sapir_js_error_file.length;
				for (l_script_error_idx = 0; l_script_error_idx < l_script_error_count; l_script_error_idx++) {
					l_script_error_msg += g_sapir_js_error_descr [l_script_error_idx] + " (" + g_sapir_js_error_file [l_script_error_idx] + ")\r\nplease refresh the page\r\n";
				}
			}			
			return;
		}
		*/
	}

	// flats
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	if (typeof (g_sapir_flat_scripts_count) != "undefined") {
		// config keys
		if (f_sapir_is_implemented ("f_sapir_flat_conf")) {
			f_sapir_flat_conf ();
		}
		
		// dict keys
		if (f_sapir_is_implemented ("f_sapir_flat_dict")) {
			f_sapir_flat_dict ();
		}
		
		// tab
		if (f_sapir_is_implemented ("f_sapir_flat_tab")) {
			f_sapir_flat_tab ();
		}

		// embeds
		var l_flat_iframes = window.document.getElementsByTagName ("IFRAME");
		var l_flat_iframes_count = l_flat_iframes.length;
		//for (var l_flat_iframes_idx = 0; l_flat_iframes_idx < l_flat_iframes_count; l_flat_iframes_idx++) {
		//}
		
		if (typeof (g_sapir_flat_embed) != "undefined") {
			var l_flat_embed_count, l_flat_embed_idx;
			l_flat_embed_count = g_sapir_flat_embed.length;
			for (l_flat_embed_idx = 0; l_flat_embed_idx < l_flat_embed_count; l_flat_embed_idx++) {
				eval ("f_idea_flat_prepareEmbed_" + g_sapir_flat_embed [l_flat_embed_idx] + " ()");
			}
		}

		// datawindows
		if (typeof (g_sapir_flat_dw_control) != "undefined") {			
			l_flat_dw_count = g_sapir_flat_dw_control.length;
			for (l_flat_dw_idx = 0; l_flat_dw_idx < l_flat_dw_count; l_flat_dw_idx++) {
				eval ("f_sapir_flat_dw_control_" + g_sapir_flat_dw_control [l_flat_dw_idx] + " ()");
				
				if (f_sapir_is_implemented ("f_sapir_flat_dw_columns_" + g_sapir_flat_dw_columns [l_flat_dw_idx])) {
					eval ("f_sapir_flat_dw_columns_" + g_sapir_flat_dw_columns [l_flat_dw_idx] + " ()");
				}
				
				if (f_sapir_is_implemented ("f_sapir_flat_dw_rows_" + g_sapir_flat_dw_rows [l_flat_dw_idx])) {
					eval ("f_sapir_flat_dw_rows_" + g_sapir_flat_dw_rows [l_flat_dw_idx] + " ()");
				}
				
				eval ("f_sapir_flat_dw_rows2_" + g_sapir_flat_dw_rows2 [l_flat_dw_idx] + " ()");
				
				if (f_sapir_is_implemented ("f_sapir_flat_dview_register_" + g_sapir_flat_dview_register [l_flat_dw_idx])) {
					eval ("f_sapir_flat_dview_register_" + g_sapir_flat_dview_register [l_flat_dw_idx] + " ()");
				}

				if (f_sapir_is_implemented ("f_sapir_flat_rte_init_" + g_sapir_flat_dview_register [l_flat_dw_idx] + "_rte")) {
					eval ("f_sapir_flat_rte_init_" + g_sapir_flat_dview_register [l_flat_dw_idx] + "_rte" + " ()");
					eval ("f_sapir_flat_rte_init2_" + g_sapir_flat_dview_register [l_flat_dw_idx] + "_rte" + " ()");
				}

			}		
		}

		// buttons
		l_flat_button_count, l_flat_button_idx
		if (typeof (g_sapir_flat_button) != "undefined") {
			l_flat_button_count = g_sapir_flat_button.length;
			for (l_flat_button_idx = 0; l_flat_button_idx < l_flat_button_count; l_flat_button_idx++) {
				eval ("f_sapir_flat_button_" + g_sapir_flat_button [l_flat_button_idx] + " ()");
			}		
		}

		// form dw
		if (f_sapir_is_implemented ("f_sapir_flat_dw_control_sapir_form_dw")) {
			f_sapir_flat_dw_control_sapir_form_dw ();
		}
		
		if (f_sapir_is_implemented ("f_sapir_flat_dw_rows2_sapir_form_dw")) {
			f_sapir_flat_dw_rows2_sapir_form_dw ();
		}
		
		if (f_sapir_is_implemented ("f_sapir_flat_form_register")) {
			f_sapir_flat_form_register ();
		}

		// multimedia
		if (f_sapir_is_implemented ("f_sapir_flat_ddlb_register")) {
			f_sapir_flat_ddlb_register ();
		}
		
		// calendar
		if (typeof (g_sapir_flat_calendar) != "undefined") {
			// load language-specific calendar
			var l_calendar_headID = document.getElementsByTagName("head")[0];         
			var l_calendar_newScript = document.createElement('script');
			l_calendar_newScript.type = 'text/javascript';
			
			/*
			if (g_sapir_lang.toLowerCase () == "heb") {
				l_calendar_lang = "heb";
			} else {
				l_calendar_lang = "en";
			}
			*/
			l_calendar_newScript.src = g_sapir_calendar_locale_folder + "/calendar-" + g_sapir_lang + ".js";
			
			l_calendar_headID.appendChild(l_calendar_newScript);
			
			l_flat_calendar_count = g_sapir_flat_calendar.length;
			for (l_flat_calendar_idx = 0; l_flat_calendar_idx < l_flat_calendar_count; l_flat_calendar_idx++) {
				eval ("f_sapir_flat_calendar_" + g_sapir_flat_calendar [l_flat_calendar_idx] + " ()");
			}
		}
		
		// textarea
		if (typeof (g_sapir_flat_textarea) != "undefined") {
			var l_flat_textarea_count, l_flat_textarea_idx;
			l_flat_textarea_count = g_sapir_flat_textarea.length;
			for (l_flat_textarea_idx = 0; l_flat_textarea_idx < l_flat_textarea_count; l_flat_textarea_idx++) {
				eval ("f_sapir_flat_textarea_" + g_sapir_flat_textarea [l_flat_textarea_idx] + " ()");
			}
		}
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	// stateman iframe : init
	g_sapir_stateman_iframe_el = f_sapir_get_element_by_id (window.document, "stateman");
	
	// list : initialize Lytebox
	if  (a_page == "list" || a_page == "next_list" || a_page == "notebook") {
		initLytebox ();
	}
	
	// cat split
	g_sapir_split_page = f_sapir_split_page ();
	
	// if internal iframe and not cataloging : delegate url to parent
	if (a_page && a_page != "cat" && a_page != "cat_media" && a_page != "cat_split") {
		if (f_sapir_exists (g_sapir_split_page)) {
			f_sapir_location_replace (f_sapir_window_location (), parent);
			return;
		}
	}

	// media split : turn "please_wait" off
	if (a_page == "cat_media" || a_page == "cat_media_url_frame") {
		parent.f_sapir_please_wait_popup (false, null, "", null, true, "onload : cat_media or cat_media_url_frame");
	}	
	
	/*
	// cat split : "please_wait" msg
	if (a_page == "cat_split") {
		f_sapir_please_wait_popup (true, null, "", null, true, "onload : cat_split");
	}
	*/
	
	/*
	if (a_page == "cat_split") {
		var l_split_main_frame_el;
		f_sapir_resize_iframe ("main_frame", window.document.documentElement.clientWidth, window.document.documentElement.clientHeight);
		l_split_main_frame_el = f_sapir_get_element_by_id (window.document, "main_frame");
		f_sapir_class_prepend (l_split_main_frame_el, "main_frame");
		f_sapir_class_remove (l_split_main_frame_el, "sapir_hide");
	}
	*/
	
	/*
	if (g_sapir_dev_mode) {
		f_sapir_breakpoint_match ();
	}
	*/
	
	/*
	if (a_page == "criteria") {
		window.document.body.style.pixelHeight = "100%;";
	}
	*/

	//if (g_sapir_nocat_window_before_unload_done) {
	//	g_sapir_nocat_window_before_unload_done = false;
	//}
	
	/*
	if (a_title) {
		g_sapir_page_title = a_title;
		document.title = g_sapir_page_title;
	}
	*/

	//l_event = null;	
	/*
	if (a_event) {
		l_event = a_event;
	} else {
		l_event = window.event;
	}
	*/
	
	if (f_sapir_is_implemented ("f_sapir_onload_per_page")) {
		f_sapir_onload_per_page ();
	}

	// login & scroller : complete focus of user_id (flat...)

	if (typeof (g_sapir_flat_scripts_count) != "undefined") {
		//if (a_page == "getreader_dialog") {
		//	htmldw.itemGainFocus(0,1,f_sapir_get_element_by_id (window.document, "user_id_0"), htmldw.gobs.user_id);
		//}
		//if (typeof (g_sapir_scroller_state) != "undefined") {			
			//htmldw.itemGainFocus(0,14,f_sapir_get_element_by_id (window.document, "get_var_0"), htmldw.gobs.get_var);
		//}
	}
	
	l_dataform_count = g_sapir_dataform_names.length;
	for (lidx = 0; lidx < l_dataform_count; lidx++) {
		eval (g_sapir_dataform_names [lidx] + ".dataForm = \"" + f_sapir_form_get_by_name (g_sapir_dataform_names [lidx] + "_dataForm") + "\"");
	}
	
	if (f_sapir_is_implemented ("f_sapir_cat_ui")) {
		f_sapir_cat_ui (/*l_event*/);
	}

	
	// cataloging + scroller : login-state info for re-login
	if (typeof (g_sapir_logged_user_state) != "undefined") {
		//alert ("g_sapir_logged_user_state : init");
		g_sapir_logged_user_state = new sapir_logged_user_state (g_sapir_logged_user_validation_interval);
	}	
	
	/*
	if (g_sapir_cat_ui_active) {
		if (g_sapir_form.save_pre_check == "1") {
			g_sapir_server_check_iframe = f_sapir_get_frame ("sapir_server_check_iframe");
		}
	}
	*/
	
	g_sapir_measure_unit = "px";

	// page changes
	
	if (typeof (g_sapir_flat_dw_control) != "undefined") {
		l_flat_dw_count = g_sapir_flat_dw_control.length;
		for (l_flat_dw_idx = 0; l_flat_dw_idx < l_flat_dw_count; l_flat_dw_idx++) {
			f_sapir_changes_restore (g_sapir_flat_dw_control [l_flat_dw_idx]);
		}
	}

	l_layoutTable_el = f_sapir_get_element_by_id (window.document, "layoutTable");
	l_wrapper_el = f_sapir_get_element_by_id (window.document, "wrapper");

	// cataloging : match dviews height to screen height
	if (a_page == "cat") {
		parent.f_sapir_please_wait_popup (false, null, "", null, true, "onload : cat");
		var l_cat_numeric_height, l_cat_height;
		//ie = currentStyle, ff = getComputedStyle ()

		l_cat_numeric_height = window.document.documentElement.clientHeight - f_sapir_element_get_offsetTop (l_wrapper_el);
		// cat dialog : reduce height
		//if (g_sapir_form.cat_mode == "scroller" || g_sapir_form.cat_mode == "reader_reg") {
			if (g_sapir_is_ie_modal == true) {
				// ie modal
				l_cat_numeric_height -= 30;
			} else {
				l_cat_numeric_height -= 10;
			}
		//}
		l_cat_height = f_sapir_measure  (l_cat_numeric_height, 1, window.document.documentElement.clientHeight);

		l_wrapper_el.style.height = l_cat_height;
		f_sapir_get_element_by_id (window.document, "content").style.height = l_wrapper_el.style.height;

		/*
		//l_layoutTable_el.style.position = "absolute";

		//l_layoutTable_el.setOffsetHeight (window.document.documentElement.clientHeight  - f_sapir_element_get_offsetTop (l_layoutTable_el));
		l_layoutTable_el.style.height = f_sapir_measure  (window.document.documentElement.clientHeight  - f_sapir_element_get_offsetTop (l_layoutTable_el), 
																										1, window.document.documentElement.clientHeight) ;

		////l_layoutTable_el.style.height = new String ((f_sapir_get_numeric_measure (l_layoutTable_el.style.height) / window.document.documentElement.clientHeight) * 100) + "%";
		
		//l_layoutTable_el.height = l_layoutTable_el .style.height;
		
		//l_layoutTable_el.style.height = "300px;";

		l_content_el= f_sapir_get_element_by_id (window.document, "content");

		l_form_div_el = f_sapir_get_element_by_id (window.document, "form");
		*/
	}

	// scroller : match results height & details_frame to actual free area
	if (g_sapir_page_id == "scroller" || g_sapir_page_id == "field_scroller" || g_sapir_page_id == "cat_scroller") {
		g_sapir_unload_popup = true;
		//l_dw_submit_form = f_sapir_form_get_by_name ("htmldw_submitForm");
		//l_param2 = new String (f_sapir_selflinkarg (l_dw_submit_form, "param2"));
		//l_scr_search_type = f_sapir_param_get_key (l_param2, "search_type");
		//l_scr_container_el = f_sapir_get_element_by_id (window.document, "scr_container_" + l_scr_search_type);

		l_scr_container_el = f_sapir_get_element_by_id (window.document, "scr_container");
		if (f_sapir_exists (l_scr_container_el)) {
			// height factor : different for ie modal dialog and standard page
			if (g_sapir_is_ie_modal == false) {
				l_scr_height_factor = 15;
			} else {
				l_scr_height_factor = 40;
			}

			l_scr_container_el.style.height = f_sapir_measure  (	window.document.documentElement.clientHeight  
																														- f_sapir_element_get_offsetTop (l_scr_container_el) - l_scr_height_factor, 
																														1, window.document.documentElement.clientHeight) ;
		}

		/*
		l_info_wrapper_el =  f_sapir_get_element_by_id (window.document, "info_wrapper");
		if (f_sapir_exists (l_info_wrapper_el )) {
			l_info_wrapper_el.style.height = f_sapir_measure  (window.document.documentElement.clientHeight  - f_sapir_element_get_offsetTop (l_info_wrapper_el) , 
																											1, window.document.documentElement.clientHeight) ;
		}
		*/
		/*
		//l_details_iframe_el  = f_sapir_get_frame ("scr_details");
		l_details_iframe_el  = f_sapir_get_element_by_id (window.document, "scr_details");
		if (f_sapir_exists (l_details_iframe_el )) {
			l_details_iframe_el.style.height = f_sapir_measure  (window.document.documentElement.clientHeight  - f_sapir_element_get_offsetTop (l_details_iframe_el), 
																										1, window.document.documentElement.clientHeight) ;
		}
		*/
		
		self.focus ();
	}

	if (a_page == "login") {
		f_sapir_login_ref_opener ();
	}
	
	if (f_sapir_is_implemented ("setupZoom")) {
		setupZoom ();
	}

	if (typeof (g_sapir_trace_active) != "undefined") {
		f_sapir_trace_init ();
	}
	
	if (typeof (g_sapir_re_login) != "undefined") {
		//alert("f_sapir_onload : re-login");
		f_sapir_re_login ();
	}

	if (typeof (g_sapir_popup_login) != "undefined") {
		f_sapir_flat_popup_login ();		
	}
	
	if (g_sapir_cat_ui_active) {
		if (f_sapir_is_implemented ("f_sapir_cat_init")) {
			f_sapir_cat_init ();
		}
		/*
		if (f_sapir_is_implemented ("f_ajax_init")) {
			f_ajax_init ();
		}
		*/
		if (f_sapir_is_implemented ("f_sapir_keyboard_mapping")) {
			f_sapir_keyboard_mapping ();
		}

		//if (f_sapir_is_implemented ("f_sapir_feedback_init")) {
		//	f_sapir_feedback_init ();
		//}

		// post onload
		if (f_sapir_is_implemented ("f_sapir_post_onload")) {
			g_sapir_post_onload_timeout_id = window.setTimeout ("f_sapir_post_onload ()", 150);	
		}
	}

	if (a_page == "item_delete_confirm" || a_page == "item_delete") {
		//if (f_sapir_is_implemented ("f_sapir_delete_confirm_main")) {
		if (g_sapir_is_ie_modal == false) {
			f_sapir_delete_confirm_main ();			
		} else {
			f_sapir_delete_confirm_main (g_sapir_popup_opener);
		}
		//}
	}

	if (f_sapir_is_implemented ("f_sapir_basket_download_confirm_main")) {
		if (g_sapir_is_ie_modal == false) {
			f_sapir_basket_download_confirm_main ();			
		} else {
			f_sapir_basket_download_confirm_main (g_sapir_popup_opener);
		}
	}

	if (f_sapir_is_implemented ("f_sapir_cat_scroller_main")) {
		if (g_sapir_is_ie_modal == false) {
			f_sapir_cat_scroller_main ();
		} else {
			f_sapir_cat_scroller_main (g_sapir_popup_opener);
		}
	}
	if (f_sapir_is_implemented ("f_sapir_media_scroller_main")) {
		if (g_sapir_is_ie_modal == false) {
			f_sapir_media_scroller_main ();
		} else {
			f_sapir_media_scroller_main (g_sapir_popup_opener);
		}
	}

	if (!f_sapir_is_empty (g_sapir_focus_field)) {
		f_sapir_focus_default_field (g_sapir_focus_field);
	}
	if (f_sapir_is_implemented ("ide_setfocus")) {
		ide_setfocus ();
	}
	
	if (f_sapir_exists (g_sapir_split_page)) {
		//parent.nof5 ();
		f5_frame_level ();
	}
	
	//if (a_page == "cat" || a_page == "scroller" || a_page == "field_scroller" || a_page == "cat_scroller") {
	//if (a_page != "cat_split") {
		if (g_sapir_browser_type == "chrome") {
			// *** should be an IFRAME condition
			//if (f_sapir_exists (g_sapir_split_page)) {
			//} else {
				//f_sapir_event_add (window, "beforeunload", f_sapir_unload_before_handler);
				window.onbeforeunload = f_sapir_unload_before_handler;
			//}
		} else {
			//f_sapir_event_add (window, "beforeunload", f_sapir_unload_before_handler);
			window.onbeforeunload = f_sapir_unload_before_handler;
		}
		f_sapir_event_add (window, "unload", f_sapir_unload_handler);
		//window.onunload = f_sapir_unload_handler;
	//}
	
	//if (a_page == "cat") {
		// *** relevant only if split_mode == "2"
		f_sapir_progress_bar_fix ();
	//}

	// feedback popup
	if (typeof (g_sapir_feedback_popup_title) != "undefined") {
		f_sapir_feedback_popup ();
	}
	
	return;
	
	//} catch (onload_exception) {
	//	//debugger;
	//	f_sapir_exception ("sapirjsfile", "onload", onload_exception);
	//}
}

function f_sapir_exception (a_file_name, a_function_name, a_ex) {
	//debugger;
	var l_msg;
	l_msg = a_function_name + " error : \r\n" + a_ex.description + " (";
	if (typeof (a_ex.fileName) != "undefined") {
		l_msg += a_ex.fileName;
	} else {
		l_msg += a_file_name;
	}
	if (typeof (a_ex.lineNumber) != "undefined") {
		l_msg += "." + a_ex.lineNumber;		
	}
	l_msg += ")" + "\n\nPlease Refresh the Page";
	alert (l_msg);
}

//function f_sapir_nocat_unload_before_handler () {
	//g_sapir_nocat_window_before_unload_done = true;
	//return;
//}

function f_sapir_list_set_sort (a_sort_by) {
	var l_param, l_param_new, l_newrl;
	l_newrl = f_sapir_url_param_set_key (g_sapir_url,"rsort", a_sort_by); 
	f_sapir_location_replace (l_newrl);
	//window.location.replace (l_newrl);
}

function f_sapir_param_get_key (a_param, a_key) {
	var l_param, l_key, l_key_begin, l_key_end, l_key_begin_pos, l_key_end_pos, l_value;
	
	l_param = new String (a_param).toLowerCase ();
	l_key = new String (a_key).toLowerCase ();

	l_new_key = false;

	l_key_begin = "<" + l_key + ">";
	l_key_begin_pos = l_param.indexOf (l_key_begin);
	
	if (l_key_begin_pos >= 0) {
		l_key_end = "</" + l_key + ">";	
	} else {
		l_key_begin = "&lt;" + l_key + "&gt;";
		l_key_end = "&lt;/" + l_key + "&gt;";
		l_key_begin_pos = l_param.indexOf (l_key_begin);
	}
	if (l_key_begin_pos < 0) {
		return "";
	}

	l_key_end_pos = l_param.indexOf (l_key_end, l_key_begin_pos);
	if (l_key_end_pos < 0) {
		return "";
	}

	l_value	= l_param.substring (l_key_begin_pos + l_key_begin.length, l_key_end_pos);

	return l_value	;
}

function f_sapir_dw_param_get_key (a_htmldw_name, a_key) {
	var l_param, l_key, l_key_begin, l_key_end, l_key_begin_pos, l_key_end_pos, l_value, l_dw_submit_form;
	
	l_dw_submit_form = f_sapir_form_get_by_name (a_htmldw_name + "_submitForm");

	l_param = new String (f_sapir_selflinkarg (l_dw_submit_form, "param")).toLowerCase ();
	l_key = new String (a_key).toLowerCase ();

	l_value = f_sapir_param_get_key (l_param, l_key);
	
	return l_value;

	/*

	//f_sapir_log ("f_sapir_dw_param_get_key", "param = " + l_param, 3);

	l_key_begin = "<" + a_key + ">";
	l_key_begin_pos = l_param.indexOf (l_key_begin);
	if (l_key_begin_pos >= 0) {
		l_key_end = "</" + a_key + ">";	
	} else {
		l_key_begin = "&lt;" + a_key + "&gt;";
		l_key_end = "&lt;/" + a_key + "&gt;";
		l_key_begin_pos = l_param.indexOf (l_key_begin);
	}
	//f_sapir_log ("f_sapir_dw_param_get_key", "l_key_begin_pos of " + a_key + " = " + l_key_begin_pos, 3);
	if (l_key_begin_pos < 0) {
		f_sapir_log ("f_sapir_dw_param_get_key", "error : key_begin_pos of " + a_key + " not found", 3);
		return "";
	}

	l_key_end_pos = l_param.indexOf (l_key_end, l_key_begin_pos);
	//f_sapir_log ("f_sapir_dw_param_get_key", "l_key_end_pos of " + a_key + " = " + l_key_end_pos, 3);
	if (l_key_end_pos < 0) {
		f_sapir_log ("f_sapir_dw_param_get_key", "error : key_end_pos of " + a_key + " not found", 3);
		return "";
	}

	l_value	 = l_param.substring (l_key_begin_pos + l_key_begin.length, l_key_end_pos);
	//f_sapir_log ("f_sapir_dw_param_get_key", "value of " + a_key + " = " + l_value, 3);
	return l_value;
	*/
}

function f_sapir_url_param_set_key (a_url, a_key, a_new_value) {
	var l_key, l_param, l_param_new, l_param_is_new, l_url_new, l_key_begin, l_key_end, l_key_begin_pos, l_key_end_pos;

	// get param from url
	l_key = "param=";
	l_param_is_new = false;

	l_key_begin = l_key;
	l_key_begin_pos = a_url.indexOf (l_key_begin);
	if (l_key_begin_pos < 0) {
		l_param_is_new = true;
	}

	if (l_param_is_new) {
		l_param	 = "";
	} else {
		l_key_end = "&";	
		l_key_end_pos = a_url.indexOf (l_key_end, l_key_begin_pos);
		if (l_key_end_pos < 0) {
			l_key_end_pos = a_url.length - 1;
		}
		l_param	 = a_url.substring (l_key_begin_pos + l_key_begin.length, l_key_end_pos);
	}
	
	// set key \ value in param
	l_param_new = f_sapir_param_set_key (l_param, a_key, a_new_value);

	if (l_param_is_new) {
		l_url_new = a_url
		if (a_url.indexOf ("?") < 0) {
			l_url_new += "?";
		}
		l_url_new += l_param_new;
	} else {
		l_url_new = a_url.substring (0, l_key_begin_pos + l_key_begin.length) 
				+ l_param_new 
				+ a_url.substring (l_key_end_pos);
	}
	return l_url_new;
}

function f_sapir_url_set_arg (a_url, a_arg_name, a_arg_value) {
	var l_key, l_arg_is_new, l_arg, l_url_new, l_key_begin, l_key_end, l_key_begin_pos, l_key_end_pos, l_post_char;
	
	l_post_char = "";

	l_key = "&" + a_arg_name + "=";
	l_arg_is_new = false;

	l_key_begin = l_key;
	l_key_begin_pos = a_url.indexOf (l_key_begin);
	if (l_key_begin_pos < 0) {
		l_key = "?" + a_arg_name + "=";
		l_arg_is_new = false;
		l_key_begin = l_key;
		l_key_begin_pos = a_url.indexOf (l_key_begin);
		if (l_key_begin_pos < 0) {
			l_arg_is_new = true;
		}
	}

	if (l_arg_is_new) {
		l_arg	 = "";
	} else {
		l_key_end = "&";	
		l_key_end_pos = a_url.indexOf (l_key_end, l_key_begin_pos + 1);
		
		if (l_key_end_pos >= 0) {
			l_post_char = "&";
		} else {		
			l_key_end_pos = a_url.length - 1;
		}
		l_arg	 = a_url.substring (l_key_begin_pos + l_key_begin.length, l_key_end_pos);
	}
	
	if (l_arg_is_new) {
		l_url_new = a_url
		if (l_url_new.indexOf ("?") < 0) {
			l_url_new += "?";
		} else {
			l_url_new += "&";
		}
		l_url_new += a_arg_name + "=" + a_arg_value;
	} else {
		l_url_new = a_url.substring (0, l_key_begin_pos) 
				+ l_key + a_arg_value + l_post_char
				+ a_url.substring (l_key_end_pos + 1);
	}

	return l_url_new;
}

function f_sapir_param_remove_key (a_param, a_key) {
	var l_key, l_param, l_param_search, l_param_new, l_key_begin, l_key_end, l_key_begin_pos, l_key_end_pos, l_value;
	
	l_key = a_key.toLowerCase ();
	l_param = a_param;
	l_param_search = l_param.toLowerCase ();

	/*
	l_key_begin = "<" + a_key + ">";
	l_key_begin_pos = l_param.indexOf (l_key_begin);
	if (l_key_begin_pos < 0) {
		return a_param;
	}

	l_key_end = "</" + a_key + ">";
	*/

	l_key_begin = "<" + l_key + ">";
	l_key_begin_pos = l_param.indexOf (l_key_begin);
	
	if (l_key_begin_pos >= 0) {
		l_key_end = "</" + l_key + ">";	
	} else {
		l_key_begin = "&lt;" + l_key + "&gt;";
		l_key_end = "&lt;/" + l_key + "&gt;";
		l_key_begin_pos = l_param_search.indexOf (l_key_begin);
	}

	l_key_end_pos = l_param_search.indexOf (l_key_end, l_key_begin_pos);
	if (l_key_end_pos < 0) {
		return a_param;
	}
	
	l_param_new = l_param.substring (0, l_key_begin_pos) + l_param.substring (l_key_end_pos + l_key_end.length);

	return l_param_new;
}

function f_sapir_param_set_key (a_param, a_key, a_new_value, a_encoded) {
	var l_key, l_param, l_param_search, _param_new, l_key_begin, l_key_end, l_key_begin_pos, l_key_end_pos, l_value, l_new_key, l_open_key, l_close_key;
	

	if (typeof (a_encoded) == "undefined") {
		l_encoded = false;
	} else {
		l_encoded = a_encoded;
	}

	l_key = a_key.toLowerCase ();
	
	l_param = a_param;
	l_param_search = l_param.toLowerCase ();

	l_new_key = false;

	// להכין תוי פתיחה וסגירה לפי קידוד כ/ל

	if (l_encoded) 	{
		l_open_key = "&lt;";
		l_close_key = "&gt;";
	} else {
		l_open_key = "<";
		l_close_key = ">";
	}

	l_key_begin = l_open_key + l_key + l_close_key;
	l_key_end = l_open_key + "/" + l_key + l_close_key;

	l_key_begin_pos = l_param_search.indexOf (l_key_begin);
	if (l_key_begin_pos < 0) {
		l_new_key = true;
	}
	if (!l_new_key) {
		l_key_end_pos = l_param_search.indexOf (l_key_end, l_key_begin_pos);
		if (l_key_end_pos < 0) {
			return "";
		}
	}
	
	if (!l_new_key) {
		l_value	 = l_param.substring (l_key_begin_pos + l_key_begin.length, l_key_end_pos);
	}
	
	if (l_new_key) {
		l_param_new = l_param 
				+ l_key_begin
				+ a_new_value 
				+ l_key_end;
	} else {
		l_param_new = l_param.substring (0, l_key_begin_pos + l_key_begin.length) 
				+ a_new_value 
				+ l_param.substring (l_key_end_pos);
	}
	return l_param_new;
}

function f_sapir_collector_expand_by_class (a_el, a_collected_identifier, a_collected_el_type, a_more_el_id, a_more_label, a_close_label, a_img_el_id, a_more_img, 																						a_close_img, a_hide_class) {
	var l_collector_state, l_collected_el_type, l_more_el; 

	if (!a_hide_class || f_sapir_is_empty (a_hide_class)) {
		a_hide_class = "sapir_hide";
	}

	if (f_sapir_is_empty (a_collected_el_type)) {
		l_collected_el_type = "tr";
	} else {
		l_collected_el_type = new String (a_collected_el_type).toLowerCase ();
	}
	if (f_sapir_class_find (a_el, "sapir_expanded")) {
		l_collector_state = "expanded";
	} else {
		l_collector_state = "collapsed";
	}

	if (l_collector_state == "expanded") {
		if (a_close_img) {
			if (a_el.src) {
				a_el.src = a_close_img;
			}
		} else {
			f_sapir_class_replace (a_el, "open", "close");
		}

		f_sapir_class_replace (a_el, "sapir_expanded", "sapir_collapsed");

	} else {
		if (a_close_img) {
			if (a_el.src) {
				a_el.src = a_more_img;
			}
		} else {
			f_sapir_class_replace (a_el, "close", "open");
		}
		f_sapir_class_replace (a_el, "sapir_collapsed", "sapir_expanded");
	}

	f_sapir_collected_show_by_class (a_el, l_collector_state, a_collected_identifier, l_collected_el_type, a_hide_class);

	// toggle the "more..." anchor

	if (a_more_el_id){
		l_more_el = f_sapir_get_element_by_id (window.document, a_more_el_id);
		if (f_sapir_exists (l_more_el)) {
			if (l_more_el.childNodes [0].nodeValue == a_more_label) {
				l_more_el.childNodes [0].nodeValue = a_close_label;
				if (a_more_img) {
					f_sapir_get_element_by_id (window.document, a_img_el_id).src = a_more_img;
				}
			} else {
				l_more_el.childNodes [0].nodeValue = a_more_label;
				if (a_close_img) {
					f_sapir_get_element_by_id (window.document, a_img_el_id).src = a_close_img;
				}
			}
		}
	}
}

function f_sapir_collected_show_by_class (a_el, a_collector_state, a_collected_identifier, a_collected_el_type, a_hide_class) {
	var l_row_count, l_rows, l_row;
	
	if (!a_hide_class || f_sapir_is_empty (a_hide_class)) {
		a_hide_class = "sapir_hide";
	}

	l_rows = window.document.getElementsByTagName (a_collected_el_type);
	l_row_count = l_rows.length;
	for (var idx=0; idx < l_row_count; idx++) {
		l_row = l_rows [idx];
		if (!f_sapir_class_find (l_row, a_collected_identifier)) {
			continue;
		}
		if (a_collector_state == "collapsed") {
			f_sapir_class_remove (l_row, a_hide_class);
		} else {
			f_sapir_class_prepend (l_row, a_hide_class);
		}
	}	
}

function f_sapir_scroller_delete (a_book_id, a_page, a_lang, a_data_lang, a_site, a_param, a_item_descr, a_confirm_msg, a_lif_type, a_row_no) {
	// do not allow deleing from cat_from_scroller
	if (typeof (g_sapir_form) != "undefined") {
		if (g_sapir_form.cat_mode == "scroller") {
			//if (window.opener.g_sapir_cat_from_scroller_props.mode == "update") 	{
				return true;
			//}
		}
	}
	f_sapir_delete_item (a_book_id, a_page, a_lang, a_data_lang, a_site, a_param, a_item_descr, a_confirm_msg, a_lif_type, a_row_no);
	return true;
}

function delete_item (a_book_id, a_page, a_lang, a_data_lang, a_site, a_param, a_item_descr, a_confirm_msg, a_lif_type) {
	// do not allow deleing from cat_from_scroller
	if (typeof (g_sapir_form) != "undefined") {
		if (g_sapir_form.cat_mode == "scroller") {
			//if (window.opener.g_sapir_cat_from_scroller_props.mode == "update") 	{
				return true;
			//}
		}
	}
	f_sapir_delete_item (a_book_id, a_page, a_lang, a_data_lang, a_site, a_param, a_item_descr, a_confirm_msg);
	return true;
}

function f_sapir_delete_item (a_book_id, a_page, a_lang, a_data_lang, a_site, a_param, a_item_descr, a_confirm_msg, a_lif_type, a_row_no) {
	var l_dialog_features, l_dialog_args, l_page_base_args, l_page_url_args, l_args_delimiter, l_htmldw_submitform, l_lang, l_site, l_param, l_module, 
		l_done_msg_div, l_item_descr, l_confirm_msg, l_dialog_ref, l_table_name_param, l_popup_open_ret;
	
	l_args_delimiter = "";
	l_page_base_args = "";
	l_page_url_args = "";

	/*
	l_confirm = confirm (a_confirm_msg);
	
	if (!l_confirm) {
		return false;
	}
	*/
	
	l_lang = a_lang;
	if (!f_sapir_is_empty (l_lang)) {
		l_page_base_args = l_page_base_args + l_args_delimiter + "lang=" + l_lang;
		l_args_delimiter = "&";
	}

	l_site = a_site;
	if (!f_sapir_is_empty (l_site)) {
		l_site = l_site.replace(/&lt;/g, "<");
		l_site = l_site.replace(/&gt;/g, ">");
		l_page_base_args = l_page_base_args + l_args_delimiter + "site=" + l_site;
		l_args_delimiter = "&";
	}
	
	l_page_url_args = l_page_base_args;

	if (g_sapir_cat_ui_active) {
		l_module = "cataloging";
	} else {
		l_module = "search";
	}
	if (!f_sapir_is_empty (l_module)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "module=" + l_module 
		l_args_delimiter = "&";
	}
	
	if (g_sapir_cat_ui_active) {
		a_page = "notebookcat";
	}
	if (!f_sapir_is_empty (a_page)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "page=" + a_page
		l_args_delimiter = "&";
	}
	
	/*
	if (!f_sapir_is_empty (a_rsvr)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "rsvr=" + a_rsvr
		l_args_delimiter = "&";
	}
	*/
	
	l_param = a_param;

	// code table in scroller ?
	if (typeof (g_sapir_scroller_state) != "undefined") {
		if (f_sapir_exists (g_sapir_scroller_state)) {
			if (!f_sapir_is_empty (g_sapir_scroller_state.table_name)) 	{
				//l_table_name_param = "<table_name>" + g_sapir_scroller_state.table_name + "</table_name>";
				//l_param += l_table_name_param;
				g_sapir_cat_from_scroller_props = new sapir_cat_from_scroller_props ("delete", a_book_id, a_row_no);
				l_param = g_sapir_cat_from_scroller_props.ext_param;
			}
		}
	}

	if (!f_sapir_is_empty (a_item_descr)) {
		l_param = f_sapir_param_set_key (l_param, "item_descr", a_item_descr);
		//l_param += "<item_descr>" + a_item_descr + "</item_descr>";
	}

	if (!f_sapir_is_empty (l_param)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "param=" + l_param
		l_args_delimiter = "&";
	}
	
	// item descr + confirm msg
	l_page_url_args = l_page_url_args + l_args_delimiter + "item_id=" + a_book_id;
	l_args_delimiter = "&";
	
	l_item_descr = new String (a_item_descr).substring (0, 120);
	l_item_descr = escape (l_item_descr);
	l_page_url_args = l_page_url_args + l_args_delimiter + "item_descr=" + l_item_descr;
	l_args_delimiter = "&";
	
	l_confirm_msg = escape (a_confirm_msg);
	l_page_url_args = l_page_url_args + l_args_delimiter + "confirm_msg=" + l_confirm_msg;
	l_args_delimiter = "&";
	
	if (!f_sapir_is_empty (l_page_url_args)) {
		l_page_url_args = "?" + l_page_url_args;
	}

	if (g_sapir_cat_ui_active) {
		// confirm changes lost
	}
	
	//window.location = "delete_confirm.asp" + l_page_url_args;
	//return;
	
	g_sapir_item_delete_props = new sapir_item_delete_props (a_book_id, a_item_descr);

	g_sapir_item_delete_props.delete_page_base_args = l_page_base_args;
	/*
	if (g_sapir_browser_is_ie) {
		l_dialog_args = self;
	
		l_dialog_features = "dialogWidth:450px;"
							+ "dialogHeight:80px;"
							+ "help:no;"
							+ "resizable:no;"
							+ "status:no;";
		l_popup_open_ret = f_sapir_ie_modal ("delete_confirm.asp" + l_page_url_args, 
						 l_dialog_args, l_dialog_features);
		//f_sapir_delete_item_back_to_opener ();
		g_sapir_item_delete_props = null;
	} else {			
	*/
		l_popup_open_ret = f_sapir_popup ("delete_confirm.asp" + l_page_url_args /*+ "?" + "ts=" + f_sapir_datetime_get ()*/, 
					"delete_confirm",
					"height=250" /* + g_sapir_measure_unit */
					+ ",width=350" /* + g_sapir_measure_unit */
					+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
					/*+ ",modal=yes"*/
					);
		if (l_popup_open_ret == true) {
			g_sapir_popup_ref.focus ();		
		}
	/*}*/
}

function f_sapir_selflinkarg (a_form, a_arg_name) {
	var l_arg_el, l_arg_value, l_args, lidx, l_arg_count;
	l_arg_value = "";
	
	l_arg_el = f_sapir_selflinkarg_ref (a_form, a_arg_name);
	
	if (!f_sapir_exists (l_arg_el)) {
		return "";
	}
	
	l_arg_value = l_arg_el.value;
	return l_arg_value;
}

function f_sapir_selflinkarg_ref (a_form, a_arg_name) {
	var l_arg_el, l_args, lidx, l_arg_count;
	l_arg_el = null;
	
	// selflink arguments do not have an ID so non-ie might not recognize them
	// so i get all submitForm elements and search them by name
	l_args = a_form.getElementsByTagName ("input");
	l_arg_count = l_args.length;
	for (lidx = 0; lidx < l_arg_count; lidx++) {
		if (l_args [lidx].getAttribute ("name") == a_arg_name) {
			l_arg_el = l_args [lidx];
			break;
		}		
	}
	return l_arg_el;
}

function f_sapir_delete_item_result (a_delete_props) {
	if (a_delete_props.ret.indexOf ("$sapir_delete$failed$/sapir_delete$") >= 0) {
		return false;
	}
	return true;
}

function f_sapir_delete_item_response_msg (a_delete_props) {
	l_error_code_begin_pos = a_delete_props.ret.indexOf ("$error_code$") + new String ("$error_code$").length;
	l_error_code_end_pos = a_delete_props.ret.indexOf ("$/error_code$") - 1;
	l_error_code = a_delete_props.ret.substring (l_error_code_begin_pos, l_error_code_end_pos + 1);
	
	l_error_msg_begin_pos = a_delete_props.ret.indexOf ("$error_text$") + new String ("$error_text$").length;
	l_error_msg_end_pos = a_delete_props.ret.indexOf ("$/error_text$") - 1;
	l_error_msg = a_delete_props.ret.substring (l_error_msg_begin_pos, l_error_msg_end_pos + 1);
	
	if (f_sapir_is_empty (l_error_msg)) {
		l_error_msg = "Delete of item " + a_delete_props.book_id + " failed"
		if (!f_sapir_is_empty (l_error_code)) {
			l_error_msg += "\r\n" + "(error no.  " + l_error_code + ")";
		}
	}
	return l_error_msg;
}

function f_sapir_delete_item_back_to_opener (a_dialog_ref) {
	var l_delete_rc, l_page_base_args, l_error_code_begin_pos, l_error_code_end_pos, l_error_code, l_error_msg_begin_pos, l_error_msg_end_pos, l_error_msg, l_final_msg;

	// delete canceled
	if (g_sapir_item_delete_props.ret == "$sapir_delete$cancel$/sapir_delete$" || f_sapir_is_empty (g_sapir_item_delete_props.ret)) {
		g_sapir_item_delete_props.ret = "";
		if (g_sapir_cat_ui_active) {
			g_sapir_unload_confirm = true;
		}
		g_sapir_item_delete_props = null;
		return;
	}

	l_delete_rc = f_sapir_delete_item_result (g_sapir_item_delete_props);
	// delete failed
	if (l_delete_rc == false) {
		/*
		l_final_msg = f_sapir_delete_item_response_msg (g_sapir_item_delete_props);

		if (a_dialog_ref) {
			f_sapir_get_element_by_id (a_dialog_ref.document, "delete_response_msg").innerHTML = l_final_msg;
		} else {
		}
		*/
		if (g_sapir_cat_ui_active) {
			g_sapir_unload_confirm = true;
		}
		g_sapir_item_delete_props = null;
		return;
	}

	// delete done
	/*
	if (a_dialog_ref) {
		a_dialog_ref.close ();
	}
	*/
	g_sapir_item_delete_props.ret = "";
	if (g_sapir_cat_ui_active) {
		g_sapir_unload_confirm = true;
	}

	g_sapir_unload_popup = true;

	/*
	// info msg
	l_done_msg_div = window.document.createElement ("div");
	l_done_msg_div.setAttribute ("className", "item_delete_done");
	l_done_msg_div.innerHTML = "delete done, returning to search page...";
	//l_done_msg_div.childNodes [0].nodeValue = "delete done, returning to search page...";

	f_sapir_get_element_by_id (window.document, "popupWrap").appendChild (l_done_msg_div);
	*/

	f_sapir_please_wait_popup (true, null, "", null, true, "delete_item_back_to_opener");

	if (g_sapir_page_id == "list") {
		// return to list
		f_sapir_location_replace (g_sapir_url);
		return;	
	} else if (g_sapir_page_id == "notebook") {
		if (g_sapir_browser_is_ie) {
			f_sapir_get_element_by_id (window.document, "back_to_list").click ();
		} else {
			window.history.go(-2);
		}
	} else if (g_sapir_page_id == "cat_scroller" || typeof (g_sapir_scroller_url) != "undefined") {
		f_sapir_event_cancel (window.event);

		l_dw_submit_form = f_sapir_form_get_by_name ("htmldw_submitForm");

		f_sapir_selflinkarg_set (l_dw_submit_form, "lang", g_sapir_scroller_url.lang);
		f_sapir_selflinkarg_set (l_dw_submit_form, "data_lang", g_sapir_scroller_url.data_lang);
		f_sapir_selflinkarg_set (l_dw_submit_form, "module", g_sapir_scroller_url.module);
		f_sapir_selflinkarg_set (l_dw_submit_form, "page", g_sapir_scroller_url.page_id);
		f_sapir_selflinkarg_set (l_dw_submit_form, "rsvr", g_sapir_scroller_url.rsvr);
		f_sapir_selflinkarg_set (l_dw_submit_form, "param", g_sapir_scroller_url.extra_param);
		f_sapir_selflinkarg_set (l_dw_submit_form, "param2", g_sapir_scroller_url.extra_param2);
		f_sapir_selflinkarg_set (l_dw_submit_form, "site", g_sapir_scroller_url.site);
		f_sapir_selflinkarg_set (l_dw_submit_form, "htmldw_action", g_sapir_scroller_url.htmldw_action);
		f_sapir_selflinkarg_set (l_dw_submit_form, "htmldw_context", g_sapir_scroller_url.htmldw_context);

		l_dw_submit_form.submit ();
		return;	
	} else if (g_sapir_page_id == "cat") {
		sapir_form_dw_ButtonClicked (-1, "b_cancel");
		return;	
	} else {
		
		/*
		// return to main page
		if (!f_sapir_is_empty (g_sapir_item_delete_props.delete_page_base_args)) {
			l_page_base_args = "?" + g_sapir_item_delete_props.delete_page_base_args;
		}		
		f_sapir_location_replace ("idea.asp" + l_page_base_args);
		*/
	}
	g_sapir_item_delete_props = null;
	f_sapir_please_wait_popup (false, null, "", null, true, "delete_item_back_to_opener");
	return;
}

function f_sapir_selflinkarg_set (a_form, a_arg_name, a_arg_value) {
	var l_arg_el;

	l_arg_el = f_sapir_selflinkarg_ref (a_form, a_arg_name)
	//l_arg_el = f_sapir_get_element_by_id (a_form, a_arg_name);

	if (!f_sapir_exists (l_arg_el)) {
		return false;		
	}
	l_arg_el.value = a_arg_value;
	return true;
}

function f_sapir_login (a_mode, a_lang, a_module, a_page, a_rsvr, a_param, a_param2, a_site_dtl, a_site) {
	var login_exception;
	try {
	
	//f_sapir_breakpoint_match ();
	
	var l_dialog_features, l_dialog_args, l_page_url_args, l_args_delimiter, l_htmldw_submitform, l_asp_page,	
		l_lang, l_site_dtl, l_site, l_dialog_ref, l_popup_open_ret, l_popup_width, l_popup_height, l_popup_top, l_popup_left;
	
	if (f_sapir_is_empty (a_mode)) {
		a_mode = "login";
	}
	if (a_mode == "login_check") {
		l_asp_page = "re_login.asp";
	} else {
		l_asp_page = "getreader_dialog.asp";
	}
	
	if (f_sapir_is_empty (a_module)) {
		a_module = "security";
	}
	if (f_sapir_is_empty (a_page)) {
		a_page = "login";
	}
	
	l_args_delimiter = "";
	l_page_url_args = "";
	
	if (parent.g_sapir_cat_ui_active) {
		l_htmldw_submitform = g_sapir_form.submit_form;
	}
	
	l_lang = "";
	if (f_sapir_is_empty (a_lang)) {
		if (f_sapir_exists (l_htmldw_submitform)) {
			l_lang = f_sapir_selflinkarg (l_htmldw_submitform, "lang");
		}
	} else {
		l_lang = a_lang;
	}
	if (!f_sapir_is_empty (l_lang)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "lang=" + l_lang;
		l_args_delimiter = "&";
	}
	
	if (!f_sapir_is_empty (a_module)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "module=" + a_module 
		l_args_delimiter = "&";
	}
	
	if (!f_sapir_is_empty (a_page)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "page=" + a_page
		l_args_delimiter = "&";
	}
	if (!f_sapir_is_empty (a_rsvr)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "rsvr=" + a_rsvr
		l_args_delimiter = "&";
	}
	if (!f_sapir_is_empty (a_param)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "param=" + a_param
		l_args_delimiter = "&";
	}
	if (!f_sapir_is_empty (a_param2)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "param2=" + a_param2 
		l_args_delimiter = "&";
	}

	l_site_dtl = "";
	if (f_sapir_is_empty (a_site_dtl)) {
		if (f_sapir_exists (l_htmldw_submitform)) {
			l_site_dtl = f_sapir_selflinkarg (l_htmldw_submitform, "site_dtl");
		}
	} else {
		l_site_dtl = a_site_dtl;
	}
	if (!f_sapir_is_empty (l_site_dtl)) {
		l_site_dtl = l_site_dtl.replace(/&lt;/g, "<");
		l_site_dtl = l_site_dtl.replace(/&gt;/g, ">");
		l_page_url_args = l_page_url_args + l_args_delimiter + "site_dtl=" + l_site_dtl;
		l_args_delimiter = "&";
	}
	
	l_site = "";
	if (f_sapir_is_empty (a_site)) {
		if (f_sapir_exists (l_htmldw_submitform)) {
			l_site = f_sapir_selflinkarg (l_htmldw_submitform, "site");
		}
	} else {
		l_site = a_site;
	}
	if (!f_sapir_is_empty (l_site)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "site=" + l_site;
		l_args_delimiter = "&";
	}
	
	if (!f_sapir_is_empty (l_page_url_args)) {
		l_page_url_args = "?" + l_page_url_args;
	}

	g_sapir_login_mode = a_mode;

	l_popup_width = 400;
	l_popup_height = 250;
	l_popup_top = (screen.availHeight - l_popup_height) / 2;
	l_popup_left = (screen.availWidth - l_popup_width) / 2;

	/*
	if (g_sapir_browser_is_ie) {
		l_dialog_args = self;
		
		l_dialog_features = "dialogWidth:" + l_popup_width + g_sapir_measure_unit + ";" 
												+ "dialogHeight:" + l_popup_height + g_sapir_measure_unit + ";"
												+ "dialogTop:" + l_popup_top + g_sapir_measure_unit + ";" 
												+ "dialogLeft:" + l_popup_left + g_sapir_measure_unit + ";"
												+ "help:no;"
												+ "resizable:no;"
												+ "scroll:no;"
												+ "status:no;";

		//l_dialog_features = "dialogWidth:400px;"
		//					+ "dialogHeight:250px;"
		//						+ "help:no;"
		//						+ "resizable:yes;"
		//						+ "status:no;";

		l_popup_open_ret = f_sapir_ie_modal (l_asp_page + l_page_url_args, 
																				l_dialog_args, l_dialog_features);
		if (l_popup_open_ret == true) {
			f_sapir_login_back_to_opener ();
		}
	} else {
	*/
		l_popup_open_ret = f_sapir_popup (l_asp_page + l_page_url_args /*+ "?" + "ts=" + f_sapir_datetime_get ()*/, 
					"login",
					"height=" + l_popup_height /* + g_sapir_measure_unit */
					+ ",width=" + l_popup_width /* + g_sapir_measure_unit */
					+ ",top=" + l_popup_top
					+ ",left=" + l_popup_left
					+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
					/*+ ",modal=yes"*/,
					false /* non_exclusive : so popup can show up even if another popup is already opened */
					);
		if (l_popup_open_ret == true) {
			g_sapir_popup_ref.focus ();
		}
	/*}*/
	
	} catch (login_exception) {
		f_sapir_exception ("sapirjsfile", "login", login_exception);
	}	
}

function f_sapir_login_back_to_opener () {
	//alert ("f_sapir_login_back_to_opener : " + g_sapir_login_mode + ", " + g_sapir_login_ret);
	var l_mode;
	//debugger;
	l_mode = g_sapir_login_mode;
	g_sapir_login_mode = "";
	if (g_sapir_login_ret == "$sapir_login$ok$/sapir_login$") {
		f_sapir_please_wait_popup (false, null, "", null, true, "login_back_to_opener");
		if (l_mode == "login") {
			if (g_sapir_cat_ui_active) {
					g_sapir_unload_popup = true;
					f_sapir_location_reload ();
					//f_sapir_please_wait ("off");
					return;
			} else {
				if (new String (window.location).indexOf (".asp?")  <= 0) {
					if (typeof (g_sapir_url) != "undefined") {
						//window.location.reload (true);
						f_sapir_location_replace (g_sapir_url);
						return;
					} else {
						f_sapir_location_reload ();
						return;
					}
				} else {
					//if (typeof (g_sapir_url) != "undefined") {
					//	f_sapir_location_replace (g_sapir_url);
					//	return;
					//} else {
						f_sapir_location_reload ();
						return;
					//}
					//return;
				}
			}
			return;
		} else if (l_mode == "login_check") {
			//if (g_sapir_cat_ui_active) {
				f_sapir_login_validation_notify ("resume");
			//}
			//parent.f_sapir_server_check_set_status ("$sapir_login_check$ok$/sapir_login_check$");
			//f_sapir_server_check_off ();
			if (typeof (g_sapir_popup_login) != "undefined") {
				f_sapir_location_reload ();
			}
			return;
		}
	} else if (g_sapir_login_ret == "$sapir_login$register$/sapir_login$") {
		// reader registration popup
		if (g_sapir_popup_ref != null) {
			g_sapir_popup_ref.close ();
			g_sapir_popup_ref = null;
		}
		f_sapir_reader_reg ();
		return;
		/*
		// opening reader registration via Link and not just location-replace, in order to do a proper history.back on closing the registration form
		var l_reader_reg_link_el = f_sapir_get_element_by_id (window.document, "reader_reg_temp_link");
		if (!f_sapir_exists (l_reader_reg_link_el)) {
			var l_reader_reg_link = window.document.createElement ("A");
			l_reader_reg_link.setAttribute ("id", "reader_reg_temp_link");
			l_reader_reg_link.setAttribute ("name", "reader_reg_temp_link");
		

			window.document.body.appendChild (l_reader_reg_link);
			l_reader_reg_link_el = f_sapir_get_element_by_id (window.document, "reader_reg_temp_link");

			if (f_sapir_exists (l_reader_reg_link_el)) {
				if (g_sapir_browser_is_ie) {
					l_reader_reg_link_el.setAttribute ("href", g_sapir_login_register_url);
				} else {
					f_sapir_event_add (l_reader_reg_link_el, "click", new Function ("location.href='" + g_sapir_login_register_url + "'"));
				}
			}
		}
		
		if (f_sapir_exists (l_reader_reg_link_el)) {
			if (f_sapir_exists (g_sapir_popup_ref)) {
				g_sapir_popup_ref.close ();
			}
			//f_sapir_please_wait_popup (true, null, "", null, true, "f_sapir_login_back_to_opener");
			l_reader_reg_link_el.focus ();
			if (g_sapir_browser_is_ie) {
				l_reader_reg_link_el.click ();
			} else {
				f_sapir_location_replace (g_sapir_login_register_url);
			}
		}
		//f_sapir_location_replace (g_sapir_login_register_url);
		return;
		*/		
	} else {
		f_sapir_please_wait_popup (false, null, "", null, true, "login_back_to_opener");
		if (l_mode == "login_check") {
			//if (g_sapir_cat_ui_active) {
				f_sapir_login_validation_notify ("resume");
			//}
			
			//if (f_sapir_exists (parent.g_sapir_server_check)) {
			//	parent.f_sapir_server_check_set_status ("$sapir_login_check$failed$/sapir_login_check$");
			//	//f_sapir_server_check_off ();
			//	return;
			//}
		}
	}
	
	/*
	if (window.location.reload)
		window.location.reload( true );
	else if (window.location.replace)
		window.location.replace(unescape(location.href))
	else
		window.location.href=unescape(location.href)
	*/
}

function f_sapir_login_validation_notify (a_msg) {
	var l_login_validation_iframe = f_sapir_get_frame ("sapir_login_validation_iframe");
	var l_login_validation_iframe_window = f_sapir_frame_window (l_login_validation_iframe);
	if (f_sapir_exists (l_login_validation_iframe_window)) {
		l_login_validation_iframe_window.f_notify ("resume");
	}
}

function f_sapir_reader_update_return () {
	if (g_sapir_is_ie_modal || (f_sapir_exists (g_sapir_popup_opener) && !g_sapir_popup_opener.closed)) {
		if (g_sapir_is_ie_modal != true) {
			g_sapir_popup_opener.f_sapir_reader_update_back_to_opener ();
		}
	}
	self.close();
}

function f_sapir_reader_update_back_to_opener () {
	//if (g_sapir_login_ret == "$sapir_login$ok$/sapir_login$") {
	f_sapir_please_wait_popup (false, null, "", null, true, "login_back_to_opener");
	if (g_sapir_cat_ui_active) {
		return;
	}

	if (new String (window.location).indexOf (".asp?")  <= 0) {
		if (typeof (g_sapir_url) != "undefined") {
			//window.location.reload (true);
			f_sapir_location_replace (g_sapir_url);
			return;
		} else {
			f_sapir_location_reload ();
			return;
		}
	} else {
		//if (typeof (g_sapir_url) != "undefined") {
		//	f_sapir_location_replace (g_sapir_url);
		//	return;
		//} else {
			f_sapir_location_reload ();
			return;
		//}
		//return;
	}
}

function f_sapir_login_return (a_login_ret, a_url_redirect) {
	var l_url_redirect = "";
	if (typeof (a_url_redirect) != "undefined") {
		l_url_redirect = a_url_redirect;		
	}
	if (g_sapir_is_ie_modal || (f_sapir_exists (g_sapir_popup_opener) && !g_sapir_popup_opener.closed)) {
		g_sapir_popup_opener.g_sapir_login_ret = a_login_ret;
		g_sapir_popup_opener.g_sapir_login_register_url = l_url_redirect;
	
		if (g_sapir_is_ie_modal != true) {
			g_sapir_popup_opener.f_sapir_login_back_to_opener ();
		}
	}
	self.close();
}

function f_sapir_login_dialog_init (a_dialogArguments) {
	/*
	if (typeof (a_dialogArguments) != "undefined") {
		window.opener = a_dialogArguments;
	} else {
	}
	*/
}

/*
function f_sapir_logout () {
	f_sapir_ie_modal ("getreader_dialog.asp", l_dialog_args, l_dialog_features);
}
*/
function f_sapir_server_check_timer () {
}

function dwitem_dynamic_ItemChanged (row, columnName, newValue) {
	if (columnName == "code" && newValue == "") {
		f_dbg ("setitem_G");
		dwitem_dynamic.SetItem (row, "descr", "");
	}
}
function dwdynamic_fields_ItemChanged (row, columnName, newValue) {
	if (columnName == "code" && newValue == "") {
		f_dbg ("setitem_H");
		dwdynamic_fields.SetItem (row, "descr", "");
	}
}

function htmldw_ButtonClicked (row, objectName	) {
	if (objectName == "b_print") {
		window.print ();
	}
}

function htmldw_ButtonClicking (row, objectName, a_action) {
	var l_action;
	l_action = new String (a_action);
	if (l_action.toLowerCase () == "pageprior" && objectName == "b_back") {
		// db scroller back
		history.back(1);
		return 1;
	}
	return 0;
}

function f_sapir_server_check_off () {
	g_sapir_server_check = null;
}

function f_sapir_server_check_on (a_action, a_action_info) {
	g_sapir_server_check = null;
	g_sapir_server_check = new sapir_server_check (a_action, a_action_info);
	
	g_sapir_server_check_iframe = f_sapir_get_frame ("sapir_server_check_iframe");
	g_sapir_server_check_iframe.location = "sapir_server_check.htm";

	g_sapir_server_check.check_timeout_id  = window.setTimeout ("f_sapir_server_check_post ()", 100);
}

function f_sapir_server_check_post () {
	if (g_sapir_server_check.check_timeout_id  != null) {
	   clearTimeout (g_sapir_server_check.check_timeout_id );
	   g_sapir_server_check.check_timeout_id  = null;
   	}
	
	//f_sapir_get_iframe_frame (g_sapir_server_check_iframe).style.top = "500px";
	//f_sapir_get_iframe_frame (g_sapir_server_check_iframe).style.left = "200px";
	//f_sapir_get_iframe_frame (g_sapir_server_check_iframe).setAttribute ("height", "200px");
	//f_sapir_get_iframe_frame (g_sapir_server_check_iframe).setAttribute ("width", "500px");
	
	f_sapir_server_check_iframe_go (g_sapir_server_check_iframe);
	
	g_sapir_server_check.check_wait_timeout_id = window.setTimeout ("f_sapir_server_check_wait ()", 100);
}

function f_sapir_server_check_wait () {
	if (g_sapir_server_check.check_wait_timeout_id  != null) {
	   clearTimeout (g_sapir_server_check.check_wait_timeout_id );
	   g_sapir_server_check.check_wait_timeout_id  = null;
   	}

	//g_sapir_server_check.wait_debug_count += 1;
	//if (g_sapir_server_check.wait_debug_count > 3)  {
	//	eval (g_sapir_server_check.action_info.resume_function + "()");
	//	return;
	//}

	if (g_sapir_server_check.check_ret == "") {
		// keep waiting
		g_sapir_server_check.check_wait_timeout_id = window.setTimeout ("f_sapir_server_check_wait ()", 100);
		return;
	}
	// resume the action that asked for checking
	eval (g_sapir_server_check.action_info.resume_function + "()");
}

function f_sapir_server_check_set_status (a_status) {
	if (f_sapir_is_empty (a_status)) {
		a_status = "$sapir_login$failed$/sapir_login$";
	}
	g_sapir_server_check.check_ret = a_status;
}

function f_sapir_server_check_iframe_go (a_iframe) {
	var l_submit_form, l_response_onload_function_field;
	l_submit_form = f_sapir_get_element_by_id (f_sapir_frame_document (a_iframe), "form1");
	l_response_onload_function_field = f_sapir_get_element_by_id (l_submit_form, "response_onload_function");
	l_response_onload_function_field.value = "f_sapir_server_check_iframe_onload";
	l_submit_form.submit ();

	/*
	g_sapir_server_check_iframe_wait_counter = 0;
	g_sapir_server_check_iframe_timeout_id = window.setTimeout ("f_sapir_server_check_iframe_wait ()", 1000);
	*/
}

function sapir_server_check (a_action, a_action_info) {
	this.action = a_action;
	this.action_info = a_action_info
	this.check_ret = "";
	this.check_timeout_id = null;
	this.check_wait_timeout_id = null;
	this.wait_debug_count = 0;
}

function f_sapir_delete_confirm_init (a_dialogArguments) {
	/*
	//f_sapir_log ("f_sapir_delete_confirm_init", "", 3);
	if (typeof (a_dialogArguments) != "undefined") {	
		window.opener = a_dialogArguments;
	} else {
	}
	//window.opener.f_sapir_log ("f_sapir_delete_confirm_init", "", 3);
	*/
}

function f_sapir_delete_confirm_return (a_ret) {
	if (f_sapir_exists (g_sapir_popup_opener) && !g_sapir_popup_opener.closed) {
		g_sapir_popup_opener.g_sapir_item_delete_props.ret = a_ret;
	}
	
	//if (!window.event) {
		g_sapir_popup_opener.f_sapir_delete_item_back_to_opener ();
	//	window.opener.f_sapir_delete_item_back_to_opener (self);
	//	return;
	//}

	self.close();
}

function f_sapir_splitter_mousedown (e) {
	f_sapir_split_trace ("splitter", "down") ;
	var l_event, l_nw_frame_document, l_se_frame_document, l_nw_frame_win, l_se_frame_win;
	
	l_event = e?e:window.event;
	
	if (l_event == null) {
		f_sapir_split_trace ("splitter", "down : null event");
		return;
	}
	
	g_sapir_splitter.is_active = true;

	//f_sapir_split_iframes_freeze (true);

	//f_sapir_split_surface (true);

	g_sapir_splitter.is_mouse_down = true;
	g_sapir_splitter.is_mouse_up = false;
	g_sapir_splitter.is_mouse_move = false;
	//f_sapir_class_remove (g_sapir_splitter.splitter_el, "splitter_move");
	//g_sapir_splitter.splitter_el.onmousemove = f_sapir_splitter_mousemove;

	//g_sapir_splitter.parent.document.onmousemove = f_sapir_splitter_mousemove;
	//g_sapir_splitter.parent.document.onmouseup = f_sapir_splitter_mousemove;
	
	g_sapir_splitter.split_diff = 0;
	g_sapir_splitter.splitter_initial_x = f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left);
	g_sapir_splitter.splitter_initial_y = f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.top);
	f_sapir_split_trace ("splitter", "down : initial x, y = " + g_sapir_splitter.splitter_initial_x + ", " + g_sapir_splitter.splitter_initial_y);

	l_nw_frame_document = f_sapir_frame_document (g_sapir_splitter.nw_frame);
	l_se_frame_document = f_sapir_frame_document (g_sapir_splitter.se_frame);
	
	l_nw_frame_win = f_sapir_frame_window (g_sapir_splitter.nw_frame);
	l_se_frame_win = f_sapir_frame_window (g_sapir_splitter.se_frame);
		
	l_nw_frame_win.f_sapir_event_add (l_nw_frame_document, "mousedown", l_nw_frame_win.f_sapir_split_iframe_mousedown);
	l_nw_frame_win.f_sapir_event_add (l_nw_frame_document, "mousemove", l_nw_frame_win.f_sapir_split_iframe_mousemove);
	l_nw_frame_win.f_sapir_event_add (l_nw_frame_document, "mouseup", l_nw_frame_win.f_sapir_split_iframe_mouseup);	
	l_se_frame_win.f_sapir_event_add (l_se_frame_document, "mousedown", l_se_frame_win.f_sapir_split_iframe_mousedown);
	l_se_frame_win.f_sapir_event_add (l_se_frame_document, "mousemove", l_se_frame_win.f_sapir_split_iframe_mousemove);
	l_se_frame_win.f_sapir_event_add (l_se_frame_document, "mouseup", l_se_frame_win.f_sapir_split_iframe_mouseup);	
	
	//f_sapir_event_add (window, "mousemove", f_sapir_split_win_mousemove);
	//f_sapir_event_add (window, "mouseup", f_sapir_split_win_mouseup);
	
	f_sapir_event_cancel (l_event);
}

function f_sapir_splitter_mouseup (e) {
	f_sapir_split_trace ("splitter", "up") ;

	var  l_event;
	if (window.event) {
		l_event = window.event;
		//l_event = g_sapir_splitter.parent.event;
		if (l_event == null) {
		}
	} else {
		l_event = e;
	}

	f_sapir_split_mouseup_logic (l_event, getMouseX (l_event, g_sapir_splitter.splitter_wrapper_el), getMouseY (l_event, g_sapir_splitter.splitter_wrapper_el));

	f_sapir_event_cancel (l_event);
}

function f_sapir_split_mousemove (e) {
	//f_sapir_split_trace ("split", "move") ;
	var  l_event;
	if (g_sapir_browser_is_ie) {
		l_event = window.event;
		//l_event = g_sapir_splitter.parent.event;
		if (l_event == null) {
		}
	} else {
		l_event = e;
	}
	f_sapir_split_mousemove_logic (l_event, getMouseX (l_event, g_sapir_splitter.parent), getMouseY (l_event, g_sapir_splitter.parent));

	f_sapir_event_cancel (l_event);
}

function f_sapir_split_mousemove_logic (e, a_mouseX, a_mouseY) {
	f_sapir_split_trace ("split", "move_logic") ;
	if (!f_sapir_split_is_active ()) {
		return;
	}
	g_sapir_splitter.is_mouse_move = true;
	if (!g_sapir_splitter.is_mouse_down) {
		return;
	}

	if (isNaN (a_mouseX)) {
		f_sapir_split_trace ("split", "move_logic2 : a_mouseX is NaN");
		return;
	}

	f_sapir_split_trace ("split", "move_logic2");

	//f_sapir_split_iframes_freeze (true);
	
	f_sapir_class_prepend (g_sapir_splitter.splitter_active_el, "splitter_move");
	
	if (g_sapir_splitter.split_direction == "ew") {
		if (isNaN (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left))) {
			//f_sapir_split_trace (g_test_split_page_name, "move_logic2 : g_sapir_splitter.splitter_el.style.left is NaN");
			return;
		}
		g_sapir_splitter.split_diff = a_mouseX - f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left);

		//f_sapir_alert (	g_sapir_splitter.splitter_el.style.left
		//	   	+ ", " + getMouseX (l_event, window) 
		//		+ ", " + g_sapir_splitter.split_diff
		//		+ ", " +  (g_sapir_splitter.nw_frame_el.style.width) 
		//		+ ", " + f_sapir_get_numeric_measure (g_sapir_splitter.se_frame_el.style.width));

		g_sapir_splitter.splitter_wrapper_el.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left)
																+ g_sapir_splitter.split_diff, 1, g_sapir_splitter.parent.document.documentElement.clientWidth - 100);
		//g_sapir_splitter.split_surface_el.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.split_surface_el.style.left)
		//														+ g_sapir_splitter.split_diff);
	}
}

function f_sapir_split_mouseup_logic (e, a_mouseX, a_mouseY) {
	f_sapir_split_trace ("split", "up_logic") ;
	var l_nw_frame_document, l_se_frame_document;
	//f_sapir_alert ("f_sapir_mouseup");

	if (!f_sapir_split_is_active ()) {
		return;
	}

	l_nw_frame_document = f_sapir_frame_document (g_sapir_splitter.nw_frame);
	l_se_frame_document = f_sapir_frame_document (g_sapir_splitter.se_frame);
	
	l_nw_frame_win = f_sapir_frame_window (g_sapir_splitter.nw_frame);
	l_se_frame_win = f_sapir_frame_window (g_sapir_splitter.se_frame);
	
	f_sapir_split_trace ("split", "up_logic : removing events");
	
	l_nw_frame_win.f_sapir_event_remove (l_nw_frame_document, "mousedown", l_nw_frame_win.f_sapir_split_iframe_mousedown);
	l_nw_frame_win.f_sapir_event_remove (l_nw_frame_document, "mousemove", l_nw_frame_win.f_sapir_split_iframe_mousemove);
	l_nw_frame_win.f_sapir_event_remove (l_nw_frame_document, "mouseup", l_nw_frame_win.f_sapir_split_iframe_mouseup);	
	l_se_frame_win.f_sapir_event_remove (l_se_frame_document, "mousedown", l_se_frame_win.f_sapir_split_iframe_mousedown);
	l_se_frame_win.f_sapir_event_remove (l_se_frame_document, "mousemove", l_se_frame_win,f_sapir_split_iframe_mousemove);
	l_se_frame_win.f_sapir_event_remove (l_se_frame_document, "mouseup", l_se_frame_win.f_sapir_split_iframe_mouseup);	
	
	if (g_sapir_splitter.split_direction == "ew") {
		f_sapir_split_trace ("split", "up_logic : ew") ;
		g_sapir_splitter.split_diff = a_mouseX - g_sapir_splitter.splitter_initial_x;
		f_sapir_split_trace ("split", "up_logic : ew diff :" + g_sapir_splitter.split_diff);
		
		if (isNaN (g_sapir_splitter.split_diff)) {
			f_sapir_alert ("f_sapir_split_mouseup_logic : g_sapir_splitter.split_diff is NaN : " + a_mouseX + ", " + g_sapir_splitter.splitter_initial_x);
			return;
		}
		
		f_sapir_split_trace ("split", "up_logic2: " + g_sapir_splitter.split_diff) ;
		//f_sapir_alert (	g_sapir_splitter.splitter_el.style.left
		//	   	+ ", " + getMouseX (l_event, window) 
		//		+ ", " + g_sapir_splitter.split_diff
		//		+ ", " +  (g_sapir_splitter.nw_frame_el.style.width) 
		//		+ ", " + f_sapir_get_numeric_measure (g_sapir_splitter.se_frame_el.style.width));

		g_sapir_splitter.splitter_wrapper_el.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left)
																+ g_sapir_splitter.split_diff, 1, window.document.documentElement.clientWidth - 100);
		//g_sapir_splitter.split_surface_el.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.split_surface_el.style.left)
		//														+ g_sapir_splitter.split_diff);
		
		f_sapir_split_trace ("split", "nw orig =  : " + g_sapir_splitter.nw_frame_el.style.width) ;
		g_sapir_splitter.nw_frame_el.style.width = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left) - 1,
																	1, g_sapir_splitter.parent.document.documentElement.clientWidth - 100);
		f_sapir_split_trace ("split", "nw new =  : " + g_sapir_splitter.nw_frame_el.style.width) ;
		g_sapir_splitter.se_frame_el.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left)
																	+ f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.width), 
																	f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left),
																	g_sapir_splitter.parent.document.documentElement.clientWidth - 1);

		g_sapir_splitter.se_frame_el.style.width = f_sapir_measure (g_sapir_splitter.parent.document.documentElement.clientWidth 
																	- f_sapir_get_numeric_measure (g_sapir_splitter.se_frame_el.style.left),
																	1, g_sapir_splitter.parent.document.documentElement.clientWidth - 100);
		f_sapir_frame_window (g_sapir_splitter.se_frame).f_sapir_split_media_sync_parent_pos ();

	}

	g_sapir_splitter.is_active = false;

	//f_sapir_split_surface (false);
	//f_sapir_split_iframes_freeze (false);

	g_sapir_splitter.is_mouse_up = true;
	g_sapir_splitter.is_mouse_down = false;
	
	f_sapir_class_remove (g_sapir_splitter.splitter_active_el, "splitter_move");
	//f_sapir_alert (g_sapir_splitter.splitter_el.className);

	//g_sapir_splitter.parent.document.onmousemove = null;
	
	g_sapir_splitter.splitter_initial_x = 0;
	g_sapir_splitter.splitter_initial_y = 0;
}

function f_sapir_split_is_active () {
	if (!f_sapir_exists (g_sapir_splitter)) {
		return false;
	}	
	return g_sapir_splitter.is_active;
}

function f_sapir_split (a_close, a_media_url) {
	//debugger;
	var l_main_frame, l_media_frame, l_main_frame_el, l_media_frame_el, l_splitter_wrapper_el, l_splitter_active_el, l_splitter_display_el, 
			/*l_split_surface_el, */ l_document, l_document_el, l_nw_frame_document, l_se_frame_document;

	l_main_frame = f_sapir_get_frame ("main_frame");
	l_media_frame = f_sapir_get_frame ("media_frame");
	if (!f_sapir_exists (l_main_frame) || !f_sapir_exists (l_media_frame)) {
		alert ("frames error");
		return;
	}

	l_splitter_wrapper_el = f_sapir_get_element_by_id (window.document, "splitter_wrapper");
	l_splitter_active_el = f_sapir_get_element_by_id (window.document, "splitter_active");
	l_splitter_display_el = f_sapir_get_element_by_id (window.document, "splitter_display");
	//l_split_surface_el = f_sapir_get_element_by_id (window.document, "splitter_surface");

	l_main_frame_el = f_sapir_get_element_by_id (window.document, "main_frame");
	l_media_frame_el = f_sapir_get_element_by_id (window.document, "media_frame");
	
	if (a_close == false && g_sapir_split_state == "off") {
		g_sapir_splitter = null;
		g_sapir_splitter = new sapir_splitter (l_splitter_wrapper_el, l_splitter_active_el, l_splitter_display_el, /*l_split_surface_el, */"ew",
																					l_main_frame, l_main_frame_el, l_media_frame, l_media_frame_el, window);
	}
	
	l_nw_frame_document = f_sapir_frame_document (g_sapir_splitter.nw_frame);
	l_se_frame_document = f_sapir_frame_document (g_sapir_splitter.se_frame);

	// 1st time : point media frame to the real page
	/*
	if (l_media_frame_el.src.indexOf ("empty.htm") >= 0) {
		f_sapir_please_wait_popup (true, null, "", null);
		f_sapir_location_replace ("split_media_frame.asp?lang=eng", l_media_frame, true);
		//l_media_frame_el.src = "split_media_frame.asp?lang=eng";
		while (l_se_frame_document.readyState != "complete" && l_se_frame_document.readyState != "loaded") {
			var i = 1; ENDLESS LOOP !!!
		}
		
		// now restore media frame pointers
		l_media_frame_el = f_sapir_get_element_by_id (window.document, "media_frame");
		l_se_frame_document = f_sapir_frame_document (g_sapir_splitter.se_frame);
	}
	*/
	
	if (a_close == true || g_sapir_split_state == "on") {
		// turn splitter off
		
		/* debug
		f_sapir_frame_window (g_sapir_splitter.se_frame).location.reload (true);
		while (f_sapir_frame_document (g_sapir_splitter.se_frame).readyState != "complete") {
		}
		f_sapir_alert ("complete");
		return;
		*/

		g_sapir_split_state = "off";
		
		f_sapir_event_remove (l_splitter_active_el, "mousedown", f_sapir_splitter_mousedown);
		f_sapir_event_remove (l_splitter_active_el, "mouseup", f_sapir_splitter_mouseup);
		//l_splitter_active_el.onmousedown = null;
		//l_splitter_active_el.onmouseup = null;

		l_document = g_sapir_splitter.parent.document;
		l_document_el = g_sapir_splitter.parent.document.documentElement;

		//l_document.onmousedown = null;
		//l_document.onmouseup = null;

		f_sapir_split_iframes_freeze (false);

		l_splitter_wrapper_el.style.height = f_sapir_measure (0, -1, -1);
		l_splitter_wrapper_el.style.left = f_sapir_measure (1, -1, -1);
		f_sapir_class_prepend (l_splitter_wrapper_el , "sapir_invisible");
		
		//l_main_frame.scrolling = "yes";
		//l_main_frame.frameborder = "1";
		//g_sapir_splitter.nw_frame.resizeTo (l_document_el.clientWidth, l_document_el.clientHeight);
		g_sapir_splitter.nw_frame_el.style.width = f_sapir_measure (l_document_el.clientWidth);
		g_sapir_splitter.nw_frame_el.style.left = f_sapir_measure (2, -1, -1);
	
		f_sapir_event_add (l_nw_frame_document, "mousedown", g_sapir_splitter.nw_frame_onmousedown_orig);
		f_sapir_event_add (l_nw_frame_document, "mousemove", g_sapir_splitter.nw_frame_onmousemove_orig);
		f_sapir_event_add (l_nw_frame_document, "mouseup", g_sapir_splitter.nw_frame_onmouseup_orig);
		//l_nw_frame_document.onmousedown = g_sapir_splitter.nw_frame_onmousedown_orig;
		//l_nw_frame_document.onmousemove = g_sapir_splitter.nw_frame_onmousemove_orig;
		//l_nw_frame_document.onmouseup = g_sapir_splitter.nw_frame_onmouseup_orig;
		
		f_sapir_event_add (l_se_frame_document, "mousedown", g_sapir_splitter.se_frame_onmousedown_orig);
		f_sapir_event_add (l_se_frame_document, "mousemove", g_sapir_splitter.se_frame_onmousemove_orig);
		f_sapir_event_add (l_se_frame_document, "mouseup", g_sapir_splitter.se_frame_onmouseup_orig);
		//l_se_frame_document.onmousedown = g_sapir_splitter.se_frame_onmousedown_orig;
		//l_se_frame_document.onmousemove = g_sapir_splitter.se_frame_onmousemove_orig;
		//l_se_frame_document.onmouseup = g_sapir_splitter.se_frame_onmouseup_orig;
	
		//g_sapir_splitter.se_frame.scrolling = "yes";
		//g_sapir_splitter.se_frame.frameborder = "1";
		//g_sapir_splitter.se_frame.resizeTo (0, 0);
		g_sapir_splitter.se_frame_el.style.width = f_sapir_measure (0, -1, -1);
		g_sapir_splitter.se_frame_el.style.height = f_sapir_measure (0, -1, -1);
		g_sapir_splitter.se_frame_el.style.left = f_sapir_measure (1, -1, -1);

		// reloading media frame : requires timer until it is available... and re-ref l_media_frame_xxx...
		//f_sapir_frame_window (g_sapir_splitter.se_frame).location.reload (true);
		
		if (f_sapir_frame_window (g_sapir_splitter.nw_frame).f_sapir_is_implemented ("f_sapir_resize_spacer")) {
			f_sapir_frame_window (g_sapir_splitter.nw_frame).f_sapir_resize_spacer ("off");
		}
		
		//f_sapir_split_surface (false);
		
		if (a_close == true) {
			f_sapir_frame_window (g_sapir_splitter.se_frame).f_sapir_location_reload ();
		}
		
		g_sapir_splitter = null;

		f_sapir_progress_bar_fix ();	
	}

	if (a_close == true) {
		return;
	}

	if (!f_sapir_exists (g_sapir_splitter)) {
		g_sapir_splitter = null;
		g_sapir_splitter = new sapir_splitter (l_splitter_wrapper_el, l_splitter_active_el, l_splitter_display_el, /*l_split_surface_el, */"ew",
																					l_main_frame, l_main_frame_el, l_media_frame, l_media_frame_el, window);
	}
	
	// state is off : turn splitter on
	g_sapir_split_state = "on";

	//window.document.body.focus ();
	
	//g_sapir_splitter = null;
	//g_sapir_splitter = new sapir_splitter (l_splitter_wrapper_el, l_splitter_active_el, l_splitter_display_el, /*l_split_surface_el, */"ew",
	//																			l_main_frame, l_main_frame_el, l_media_frame, l_media_frame_el, window);

	l_document = g_sapir_splitter.parent.document;
	l_document_el = g_sapir_splitter.parent.document.documentElement;

	f_sapir_event_add (g_sapir_splitter.splitter_active_el, "mousedown", f_sapir_splitter_mousedown);
	f_sapir_event_add (g_sapir_splitter.splitter_active_el, "mouseup", f_sapir_splitter_mouseup);
	//g_sapir_splitter.splitter_active_el.onmousedown = f_sapir_splitter_mousedown;
	//g_sapir_splitter.splitter_active_el.onmouseup = f_sapir_splitter_mouseup;

	l_splitter_wrapper_el.style.width = "6px";
	l_splitter_active_el.style.width = "3px";
	l_splitter_display_el.style.width = "3px";
	
	f_sapir_class_remove (l_splitter_wrapper_el, "sapir_invisible");
	
	//g_sapir_splitter.nw_frame.resizeTo (900, l_document_el.clientHeight);

	g_sapir_splitter.nw_frame_el.style.width = f_sapir_measure ((l_document_el.clientWidth - 2) / 3 * 2 
																 - f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.width) - 2, -1, -1);
	
	g_sapir_splitter.nw_frame_el.style.left = f_sapir_measure (2);

	l_splitter_wrapper_el.style.top = f_sapir_measure (l_document_el.clientTop, -1, -1);
	l_splitter_wrapper_el.style.height = f_sapir_measure (l_document_el.clientHeight, -1, -1);
	l_splitter_wrapper_el.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.nw_frame_el.style.width) + 1, -1, -1);

	l_splitter_active_el.style.top = l_splitter_wrapper_el.style.top;
	l_splitter_active_el.style.height = f_sapir_measure (40, -1, -1);
	l_splitter_display_el.style.top = f_sapir_measure (f_sapir_get_numeric_measure (l_splitter_active_el.style.height) + 1, -1, -1);
	l_splitter_display_el.style.height = f_sapir_measure (l_document_el.clientHeight - f_sapir_get_numeric_measure (l_splitter_active_el.style.height), -1, -1);

	//g_sapir_splitter.se_frame.scrolling = "yes";
	//g_sapir_splitter.se_frame.frameborder = "1";
	//g_sapir_splitter.se_frame.resizeTo (300, g_sapir_splitter.parent.document.documentElement.clientHeight);

	g_sapir_splitter.se_frame_el.style.top = f_sapir_measure (l_document_el.clientTop, -1, -1);
	g_sapir_splitter.se_frame_el.style.height = f_sapir_measure (l_document_el.clientHeight, -1, -1);
	g_sapir_splitter.se_frame_el.style.width = 
		f_sapir_measure (l_document_el.clientWidth - f_sapir_get_numeric_measure (g_sapir_splitter.se_frame_el.style.left)- 1, -1, -1);
	g_sapir_splitter.se_frame_el.style.left = f_sapir_measure (	f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.left)
																+ f_sapir_get_numeric_measure (g_sapir_splitter.splitter_wrapper_el.style.width) /*+ 7*/, -1, -1);
	
	if (f_sapir_frame_window (g_sapir_splitter.nw_frame).f_sapir_is_implemented ("f_sapir_resize_spacer")) {
		f_sapir_frame_window (g_sapir_splitter.nw_frame).f_sapir_resize_spacer ("on");
	}

	
	// set url in media frame, then reload "url_frame" in media frame
	//debugger;
	f_sapir_frame_window (g_sapir_splitter.se_frame).g_sapir_split_media_url = a_media_url;
	f_sapir_frame_window (g_sapir_splitter.se_frame).f_sapir_frame_window (f_sapir_get_element_by_id (l_se_frame_document, "url_frame")).f_sapir_location_reload ();
	
	//f_sapir_frame_window (g_sapir_splitter.se_frame).f_sapir_split_set_media (a_media_url);
}

function f_sapir_split_iframes_freeze (a_freeze) {
	g_sapir_splitter.iframes_freeze = a_freeze;
	return;
	/*
	var l_nw_frame_document, l_se_frame_document;
	
	l_nw_frame_document = f_sapir_frame_document (g_sapir_splitter.nw_frame);
	l_se_frame_document = f_sapir_frame_document (g_sapir_splitter.se_frame);
	
	if (a_freeze) {
		l_nw_frame_document.onmousedown = f_sapir_iframe_freeze_mousedown;
		//l_nw_frame_document.onmousemove = f_sapir_iframe_freeze_mousemove;
		
		//f_sapir_event_add (l_nw_frame_document, "mouseup", f_sapir_split_iframe_mouseup);
		//l_nw_frame_document.onmouseup = f_sapir_split_iframe_mouseup;
	
		l_se_frame_document.onmousedown = f_sapir_iframe_freeze_mousedown;
		//l_se_frame_document.onmousemove = f_sapir_iframe_freeze_mousemove;
		//l_se_frame_document.onmouseup = f_sapir_split_iframe_mouseup;
	} else {
		l_nw_frame_document.onmousedown = null;
		//l_nw_frame_document.onmousemove = null;
		//l_nw_frame_document.onmouseup = null;
	
		l_se_frame_document.onmousedown = null;
		//l_se_frame_document.onmousemove = null;
		//l_se_frame_document.onmouseup = null;
	}
	*/
}

/*
function f_sapir_iframe_freeze_mousedown (e) {
	//parent.f_sapir_split_trace ("iframe freeze", "down");
	return false;
	
	var l_event;
	if (window.event) {
		l_event = window.event;
	} else {
		l_event = e;
	}
	f_sapir_event_cancel (l_event);
}
*/
/*
function f_sapir_iframe_freeze_mousemove (e) {
	//parent.f_sapir_split_trace ("iframe freeze", "move");
	return false;

	var l_event;
	if (window.event) {
		l_event = window.event;
	} else {
		l_event = e;
	}
	f_sapir_event_cancel (l_event);
}
*/
function f_sapir_split_iframe_mousedown (e) {
	if (parent.g_sapir_splitter == null) {
		return;
	}
	if (parent.g_sapir_splitter.iframes_freeze == true) {
		parent.f_sapir_split_trace (g_sapir_page_id, "down : freeze");
		return;
	}
	parent.f_sapir_split_trace (g_sapir_page_id, "down");
	var l_event, l_mouseX;
	if (window.event) {
		l_event = window.event;
	} else {
		l_event = e;
	}

	if (l_event == null) {
		return false;
	}
	
	/*
	if (f_sapir_exists (parent)) {
		if (parent.g_sapir_split_state == "on") {
			if (parent.f_sapir_split_is_active ()) {
				parent.f_sapir_splitter_mousedown_logic (l_event);
				return;
			}
		}
	}
	*/
	
	l_mouseX = 0;
	
	if (f_sapir_exists (g_sapir_split_page)) {
		if (window.frameElement) {
			l_mouseX += f_sapir_get_numeric_measure (window.frameElement.style.left);
		}
		l_mouseX += getMouseX (l_event, window);
		parent.f_sapir_split_trace ("split", "down : " + new String (l_mouseX));
	}	
	f_sapir_event_cancel (l_event);
}

function f_sapir_split_iframe_mousemove (e) {
	parent.f_sapir_split_trace (g_sapir_page_id, "iframe move");
	if (parent.g_sapir_splitter == null) {
		return;
	}
	if (parent.g_sapir_splitter.iframes_freeze == true) {
		parent.f_sapir_split_trace (g_sapir_page_id, "move : freezed");
		return;
	}
	
	var l_split_frame, l_split_active, l_event, l_mouseX, l_mouseY;
	if (window.event) {
		l_event = window.event;
	} else {
		l_event = e;
	}

	l_split_frame = false;
	l_split_active = false;
	
	if (f_sapir_exists (g_sapir_split_page)) {
		l_split_frame = true;
		if (g_sapir_split_page.f_sapir_split_is_active ()) {
			l_split_active = true;
		}
	}

	if (!l_split_frame) {
		f_sapir_event_cancel (l_event);
		return;
	}
		
	if (!l_split_active) {
		f_sapir_event_cancel (l_event);
		return;
	}

	// *** write a "get_url_page" function
	var l_last_dot_pos = window.location.href.lastIndexOf (".");
	var l_url_page_name = "";
	if (l_last_dot_pos > 0) {
		l_url_page_name = window.location.href.substring (0, l_last_dot_pos);
	}
	
	if (l_event == null) {
		parent.f_sapir_split_trace (l_url_page_name, "move : no event => NOP") ;
		return false;
	}
	
	l_mouseX = 0;
	l_mouseY = 0;
	
	if (window.frameElement) {
		l_mouseX += f_sapir_get_numeric_measure (window.frameElement.style.left);
		l_mouseY += f_sapir_get_numeric_measure (window.frameElement.style.top);
	}

	l_mouseX += getMouseX (l_event, window);
	l_mouseY += getMouseY (l_event, window);
		
	//f_sapir_event_cancel (l_event);
	g_sapir_split_page.f_sapir_split_mousemove_logic (l_event, l_mouseX, l_mouseY);
}

function f_sapir_split_iframe_mouseup (e) {
	parent.f_sapir_split_trace (g_sapir_page_id, "iframe up");
	if (parent.g_sapir_splitter == null) {
		parent.f_sapir_split_trace (g_sapir_page_id, "iframe up : splitter is null");
		return;
	}
	parent.f_sapir_split_trace (g_sapir_page_id, "iframe up : splitter alive");
	if (parent.g_sapir_splitter.iframes_freeze == true) {
				parent.f_sapir_split_trace (g_sapir_page_id, "up : freezed");
		return;
	}
		
	var l_split_frame, l_split_active, l_event, l_mouseX, l_mouseY, l_nw_frame_document, l_se_frame_document;
	if (window.event) {
		l_event = window.event;
	} else {
		l_event = e;
	}

	l_split_frame = false;
	l_split_active = false;

	parent.f_sapir_split_trace (g_sapir_page_id, "iframe up : removing events");

	f_sapir_event_remove (window.document, "mousedown", f_sapir_split_iframe_mousedown);
	f_sapir_event_remove (window.document, "mousemove", f_sapir_split_iframe_mousemove);
	f_sapir_event_remove (window.document, "mouseup", f_sapir_split_iframe_mouseup);	
	f_sapir_event_remove (window.document, "mousedown", f_sapir_split_iframe_mousedown);
	f_sapir_event_remove (window.document, "mousemove", f_sapir_split_iframe_mousemove);
	f_sapir_event_remove (window.document, "mouseup", f_sapir_split_iframe_mouseup);	
	
	if (f_sapir_exists (g_sapir_split_page)) {
		l_split_frame = true;
		if (g_sapir_split_page.f_sapir_split_is_active ()) {
			l_split_active = true;
		}		
	}

	if (!l_split_frame) {
		f_sapir_event_cancel (l_event);
		return;
	}
		
	if (!l_split_active) {
		f_sapir_event_cancel (l_event);
		return;
	}
	
	g_sapir_split_page.f_sapir_split_trace (g_sapir_page_id, "up : " + new String (f_sapir_window_location ()).substring (0, 50) ) ;
	
	if (l_event == null) {
		g_sapir_split_page.f_sapir_split_trace (g_sapir_page_id, "up : no event => NOP") ;
		return false;
	}
	
	l_mouseX = 0;
	l_mouseY = 0;

	if (window.frameElement) {
		l_mouseX += f_sapir_get_numeric_measure (window.frameElement.style.left);
		l_mouseY += f_sapir_get_numeric_measure (window.frameElement.style.top);
	}
	l_mouseX += getMouseX (l_event, window);
	l_mouseY += getMouseY (l_event, window);
				
	g_sapir_split_page.f_sapir_split_mouseup_logic (l_event,l_mouseX, l_mouseY);
}

function f_sapir_split_surface (a_on) {
	var l_splitter_surface;	
	l_splitter_surface = g_sapir_splitter.split_surface_el;

	if (a_on) {
		f_sapir_class_remove (l_splitter_surface, "sapir_invisible");
		l_splitter_surface.style.left = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_el.style.left) - 5);
		l_splitter_surface.style.width = f_sapir_measure (f_sapir_get_numeric_measure (g_sapir_splitter.splitter_el.style.width) + 10);
		l_splitter_surface.style.top = g_sapir_splitter.splitter_el.style.top;
		l_splitter_surface.style.height = g_sapir_splitter.splitter_el.style.height;

		//f_sapir_alert (l_splitter_surface.style.width + ", " + l_splitter_surface.style.left + ", " + l_splitter_surface.style.top + ", " + l_splitter_surface.style.height);
	} else {
		l_splitter_surface.style.width = f_sapir_measure (0);
		l_splitter_surface.style.height = f_sapir_measure (0);
		l_splitter_surface.style.top = f_sapir_measure (1);
		l_splitter_surface.style.left = (1);
		f_sapir_class_prepend (l_splitter_surface, "sapir_invisible");
	}
}

function sapir_splitter (a_splitter_wrapper_el, a_splitter_active_el, a_splitter_display_el, /*a_split_surface_el, */a_split_direction, a_nw_frame, a_nw_frame_el, a_se_frame, a_se_frame_el, a_parent) {
	var l_nw_frame_document, l_se_frame_document;
	
	this.splitter_wrapper_el = a_splitter_wrapper_el;
	this.splitter_active_el = a_splitter_active_el;
	this.splitter_display_el = a_splitter_display_el;

	//this.split_surface_el = a_split_surface_el;

	this.split_direction = a_split_direction;
	this.nw_frame = a_nw_frame;
	this.nw_frame_el = a_nw_frame_el;
	
	l_nw_frame_document = f_sapir_frame_document (this.nw_frame);
	this.nw_frame_onmousedown_orig = l_nw_frame_document.onmousedown;
	this.nw_frame_onmousemove_orig = l_nw_frame_document.onmousemove;
	this.nw_frame_onmouseup_orig = l_nw_frame_document.onmouseup;
	
	this.se_frame = a_se_frame;
	this.se_frame_el = a_se_frame_el;
	
	l_se_frame_document = f_sapir_frame_document (this.se_frame);
	this.se_frame_onmousedown_orig = l_se_frame_document.onmousedown;
	this.se_frame_onmousemove_orig = l_se_frame_document.onmousemove;
	this.se_frame_onmouseup_orig = l_se_frame_document.onmouseup;
	
	this.parent = a_parent;

	this.is_mouse_down = false;
	this.is_mouse_move = false;
	this.is_mouse_up = false;	

	if (this.split_direction == "ew") {
		this.splitter_left = f_sapir_get_numeric_measure (this.splitter_wrapper_el.style.left);
	} else {
		this.splitter_top = f_sapir_get_numeric_measure (this.splitter_wrapper_el.style.top);
	}
	this.split_diff = 0;
	this.is_active = false;
	this.splitter_initial_x = 0;
	this.splitter_initial_y = 0;

	this.iframes_freeze = false;

	this.trace_state = "off";
	this.trace_row = 0;
}

function f_sapir_split_trace (a_frame_name, a_event) {
	if (!f_sapir_exists (g_sapir_splitter)) {
		return;
	}
	if (g_sapir_splitter.trace_state != "on") {
		return;
	}

	var l_media_frame, l_trace_el, l_media_windoc;
	l_media_frame = f_sapir_get_frame ("media_frame");
	
	l_media_windoc = f_sapir_frame_document (l_media_frame)
	
	l_trace_el = f_sapir_get_element_by_id (l_media_windoc, "split_trace");
	if (!f_sapir_exists (l_trace_el)) {
		return;
	}
	
	g_sapir_splitter.trace_row += 1;
	f_sapir_split_trace_addrow (l_media_windoc, g_sapir_splitter.trace_row, a_frame_name + "." + a_event /*+ " (" + g_sapir_splitter.trace_state + ")"*/, "");
}
//new 100126
function f_sapir_split_trace_init (a_windoc) {
	var t1, b1, r1, thl, th2, th3, th1Text, th2Text, th3Text, l_windoc, l_trace_wrapper_el, l_split_trace_table_el;
	
	l_split_trace_table_el = f_sapir_get_element_by_id (a_windoc, "split_trace_table");
	if (f_sapir_exists (l_split_trace_table_el)) {
		return;
	}

	l_windoc = a_windoc;
	
	l_trace_wrapper_el = f_sapir_get_element_by_id (l_windoc, "split_trace");

	t1 = l_windoc.createElement("TABLE");
	t1.setAttribute ("id", "split_trace_table");
	t1.setAttribute ("border", "1");
	t1.setAttribute ("cellSpacing", "1");
	t1.setAttribute ("className", "messages_table");
		
	b1 = l_windoc.createElement("TBODY");

	r1 = l_windoc.createElement("TR");
	
	/*
	th1 = l_windoc.createElement("TH");
	th1Text = l_windoc.createTextNode ("time");
	th1.appendChild (th1Text);
	r1.appendChild (th1);
	*/

	th1 = l_windoc.createElement("TH");
	th1Text = l_windoc.createTextNode ("row");
	th1.appendChild (th1Text);
	r1.appendChild (th1);
	
	th2 = l_windoc.createElement("TH");
	th2Text = l_windoc.createTextNode ("event");
	th2.appendChild (th2Text);	
	r1.appendChild (th2);

	th3 = l_windoc.createElement("TH");
	th3Text = l_windoc.createTextNode ("msg");
	th3.appendChild (th3Text);	
	r1.appendChild (th3);

	b1.appendChild (r1);
	t1.appendChild (b1);
	l_trace_wrapper_el.appendChild (t1);
}
function f_sapir_split_trace_clear () {
	var l_windoc, l_table, tbody, l_rows, l_row_count, lidx;
	l_windoc = window.document;
	
	l_table	= f_sapir_get_element_by_id (l_windoc, "split_trace_table");
	tbody = l_table.getElementsByTagName("tbody")[0];
	l_rows = tbody.getElementsByTagName("TR");
	l_row_count = l_rows.length;
	for (lidx=l_row_count; lidx > 0; lidx--) {
		tbody.removeChild (l_rows [lidx - 1]);
	}
}

function f_sapir_split_trace_stop () {
	if (parent.g_sapir_splitter.trace_state == "on") {
		parent.g_sapir_splitter.trace_state = "off";
	} else {
		parent.g_sapir_splitter.trace_state = "on";
	}
}

function f_sapir_split_trace_addrow (a_windoc, a_row_no, a_event, a_msg) {
	var msgBound, l_table, tbody, row;
	
	f_sapir_split_trace_init (a_windoc);
	
	l_table	= f_sapir_get_element_by_id (a_windoc, "split_trace_table");
	tbody = l_table.getElementsByTagName("tbody")[0];

	row = a_windoc.createElement("TR"); 

	/*
	var l_time_cell = a_windoc.createElement ("TD"); 
	var l_time_cell_text = a_windoc.createTextNode (f_sapir_time_get ());
	l_time_cell.appendChild (l_time_cell_text);
	row.appendChild (l_time_cell); 
	*/
	
	/*
	var l_caller_id_cell = a_windoc.createElement("TD"); 
	var l_caller_id_cell_text = a_windoc.createTextNode (arg_ajax_message.caller_id);
	l_caller_id_cell.appendChild (l_caller_id_cell_text);
	row.appendChild(l_caller_id_cell); 
	*/
	
	var l_rowno_cell = a_windoc.createElement("TD"); 
	var l_rowno_cell_text = a_windoc.createTextNode (a_row_no);
	l_rowno_cell.appendChild (l_rowno_cell_text);
	row.appendChild(l_rowno_cell);
	
	var l_event_cell = a_windoc.createElement("TD"); 
	var l_event_cell_text = a_windoc.createTextNode (a_event);
	l_event_cell.appendChild (l_event_cell_text);
	row.appendChild(l_event_cell); 

	var l_msg_cell = a_windoc.createElement("TD"); 
	var l_msg_cell_text = a_windoc.createTextNode (a_msg);
	l_msg_cell.appendChild (l_msg_cell_text);
	row.appendChild(l_msg_cell); 
	
	tbody.appendChild(row); 	
}

function f_sapir_resize_iframe (a_iframe_name, a_width, a_height) {
	if (document.all) {
		f_sapir_get_frame (a_iframe_name).resizeTo (a_width, a_height);
		return;
	}
	var l_iframe;
	l_iframe = f_sapir_get_frame (a_iframe_name);
	//l_iframe.contentWindow.resizeTo (a_width, a_height);
	//l_iframe.contentWindow.resizeTo (a_width, a_height);
	//l_iframe.contentWindow.resizeTo ("100%", "100%");
	
	//var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
	//var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

	l_iframe.style.width = "100%";
	l_iframe.style.height = "100%";
	
	//l_iframe.contentDocument.defaultView.sizeToContent();
}

function f_sapir_progress_bar_fix () {
	//f_sapir_alert ("f_sapir_progress_bar_fix");
	var l_garbage_frame;

	if (!g_sapir_browser_is_ie) {
		return;
	}

	if (!f_sapir_exists (parent)) {
		//f_sapir_alert ("error 1");
		return;
	}

	if (parent.location == window.location) {
		//f_sapir_alert (parent.location + " == " + window.location);
		return;
	}
	
	//f_sapir_alert (parent.location + " != " + window.location);

	if (typeof (parent.g_sapir) == "undefined") {
		return;
	}
	
	//f_sapir_alert ("sapir_parent");

	l_garbage_frame = parent.f_sapir_get_frame ("garbage_frame");
	if (!f_sapir_exists (l_garbage_frame)) {
		//f_sapir_alert ("f_sapir_progress_bar_fix : " + window.location + " : NOP");
		return;
	}
	//f_sapir_alert ("garbage_frame exists");

	g_sapir_garbage_readystate_timeout_id = parent.setTimeout  ("f_sapir_garbage_frame_readystate (" + "\"garbage_frame\"" + ")", 100);

	/*
	while (f_sapir_frame_document (l_garbage_frame).readyState != "complete") {
	}

	if (typeof (l_garbage_frame.g_sapir) == "undefined") {
		return;
	}

	l_garbage_frame.f_submit ();
	
	//l_garbage_frame.document.write("");
	//l_garbage_frame.close();
	*/
}

function f_sapir_garbage_frame_readystate (a_garbage_frame_name) {
	var garbage_frame_readystate_exception;
	try {
	//f_sapir_alert ("f_sapir_garbage_frame_readystate v222");
	var l_garbage_frame, l_garbage_frame_document;
	l_garbage_frame = f_sapir_get_frame (a_garbage_frame_name);

	l_garbage_frame_document = f_sapir_frame_document (l_garbage_frame);
	if (l_garbage_frame_document.readyState != "complete") {
		//f_sapir_alert ("not complete : " + l_garbage_frame_document.readyState);
		return;
	}
	g_sapir_garbage_readystate_timeout_id = null;
	//f_sapir_alert ("complete : " + l_garbage_frame_document.readyState);

	/*
	if (typeof (f_sapir_frame_window(l_garbage_frame).g_sapir) == "undefined") {
		return;
	}
	*/

	f_sapir_frame_window(l_garbage_frame).f_submit ();
	
	/*
	l_garbage_frame.document.write("");
	l_garbage_frame.close();
	*/
	
	} catch (garbage_frame_readystate_exception) {
		//debugger;
		f_sapir_exception ("sapirjsfile", "garbage_frame_readystate", garbage_frame_readystate_exception);
	}	
}
/*
function f_sapir_breakpoints_register (a_breakpoint_list) {
	var l_breakpoint, l_breakpoint_list, lidx;
	
	g_sapir_debugger_breakpoints = null;
	g_sapir_debugger_breakpoints = new Array;
	
	l_breakpoint_list = new sapir_string_obj (a_breakpoint_list);
	l_breakpoint = f_sapir_get_token (l_breakpoint_list, ";");
	lidx = -1;
	while (!f_sapir_is_empty (l_breakpoint)) {
		lidx += 1;
		g_sapir_debugger_breakpoints [lidx] = l_breakpoint;
		
		// next
		l_breakpoint = f_sapir_get_token (l_breakpoint_list, ";");
	}
}
*/
/*
if (typeof (breakpoint_list) != "undefined") {
	f_sapir_breakpoints_register (breakpoint_list);
}
*/
/*
function f_sapir_breakpoint_match () {
	var l_this_func, l_caller_script, l_caller_name, l_caller_func_index;

	l_this_func = f_sapir_breakpoint_match;
	l_caller_script = l_this_func.caller;
	l_caller_name = l_caller_script.toString().match(/(\s*)function(\s+)(\w+)(\s*)\(/)[3];
	l_caller_func_index = g_sapir_debugger_breakpoints.indexOf (l_caller_name);
	if (l_caller_func_index < 0) {
		return;
	}
	f_sapir_debugger ();
}
*/
function f_sapir_debugger () {
	if (f_sapir_is_empty (g_sapir_debugger) || g_sapir_debugger == "0") {
		return;
	}
	
	debugger;
}

function f_sapir_login_ref_opener () {
	//debugger;
	if (!g_sapir_popup_opener) {
	    window.close();
	}
}
var g_events_debug = false;

function f_sapir_post_onload () {
	//f_sapir_alert ("debug : f_sapir_post_onload");
	if (g_sapir_post_onload_timeout_id != null) {
	   	clearTimeout (g_sapir_post_onload_timeout_id);
	   	g_sapir_post_onload_timeout_id = null;
   	}
	if (f_sapir_is_implemented ("f_sapir_post_onload_by_page")) {
		f_sapir_post_onload_by_page ();
	}
}

function f_sapir_html_name_to_dw_col_name  (a_dview_id, a_html_name) {

	if (f_sapir_is_empty (a_html_name)) {
		return "";
	}

	var l_dw_col_name, l_row_suffix_pos, l_html_name;
	
	l_html_name = new String (a_html_name);
	l_row_suffix_pos = l_html_name.lastIndexOf ("_");
	if (l_row_suffix_pos >= 0) {
		l_dw_col_name = l_html_name.substring (0, l_row_suffix_pos);
	}

	// strip out dview_id from name
	if (!f_sapir_is_empty (a_dview_id)) {
		l_dw_col_name = l_dw_col_name.substring (a_dview_id.length + 1);
	}

	return l_dw_col_name;
}

function f_sapir_element_get_buffer_row_no (a_el_name) {
	var l_suffix_pos, l_buffer_row, l_el_name;
	l_el_name = new String (a_el_name);
	l_suffix_pos = l_el_name.lastIndexOf ("_") + 1;
	l_buffer_row = new Number (l_el_name.substring (l_suffix_pos));
	return l_buffer_row;
}

function f_sapir_element_get_dw_row_no (a_el_name) {
	var l_buffer_row, l_dw_row;	
	l_buffer_row = f_sapir_element_get_buffer_row_no (a_el_name);
	l_dw_row = l_buffer_row + 1;
	return l_dw_row;
}

function f_sapir_date_lookup_selected (calendar, date) {
	//debugger;
	// callback
	var input_field, l_dw_col_name, l_dw_row, l_dview_id;

	if (g_sapir_cat_ui_active) {
		// dview id : take from target element
		l_dview_id = f_sapir_element_dview_get_id (calendar.params.inputField.name);
		f_sapir_log ("f_sapir_date_lookup_selected", calendar.params.inputField.name + " = " + date
					 + ", dview = " + l_dview_id, 3);
	} else {
		l_dview_id = "htmldw";
	}
	
	input_field = f_sapir_get_element_by_id (window.document, calendar.params.inputField.name);

	if (g_sapir_cat_ui_active) {
		l_dw_col_name = f_sapir_html_name_to_dw_col_name  (l_dview_id, calendar.params.inputField.name);
	} else {
		l_dw_col_name = f_sapir_html_name_to_dw_col_name  ("", calendar.params.inputField.name);
	}

	l_dw_row = f_sapir_element_get_dw_row_no (calendar.params.inputField.name);
	f_dbg ("setitem_I");
	eval (l_dview_id + ".SetItem (l_dw_row,\"" + l_dw_col_name + "\",\"" + date + "\")");

	f_sapir_element_set_value (input_field, date);
	//input_field.value = date;
	
	f_sapir_date_changed (l_dview_id, date, input_field, l_dw_row);
	
	// post computing of title_gen
	if (g_sapir_cat_ui_active) {
		if (f_sapir_dw_param_get_key ("sapir_form_dw", "formid") == "8" && l_dview_id == "dview_8_3") {
			g_sapir_title_gen_compute_timeout_id = window.setTimeout ("f_sapir_title_gen_compute (\"" + l_dw_col_name + "\")", 1000);
		}
	}
	
	input_field.focus ();
	
	if (calendar.dateClicked) {
		calendar.callCloseHandler(); // this calls "onClose"
	}
}

function f_sapir_date_changed (a_dview_id, a_new_date, a_date_el, a_dw_row) {
	if (!f_sapir_date_validate (a_new_date, true)) {
		var l_buffer_date = eval (a_dview_id + ".GetItem (a_dw_row, \"value\")");
		if (f_sapir_is_empty (l_buffer_date)) {
			a_date_el.value = "";
		} else {
			a_date_el.value = l_buffer_date;
		}
		return 2;
	}
	if (f_sapir_is_empty (a_date_el.value)) {
		l_el.value = "";
		f_dbg ("setitem_J");
		eval (a_dview_id + ".SetItem (a_dw_row, \"value\", \"\")");
		return 2;
	}
	return 0;
}

function sapir_scroller_url (a_arg_list) {
	//page, lang , data_lang, module, page_id, rsvr, extra_param, extra_param2, site_dtl, htmldw_action, htmldw_context
	//f_sapir_alert ("sapir_scroller_url : " + a_page + ", " + a_lang + ", " + a_data_lang + ", " + a_module + ", " + a_page_id + ", " + a_rsvr);
	//for (var l_args_idx = 0; l_args_idx < a_arg_list.length; l_args_idx++) {
	//	f_sapir_alert ("arg [" + l_args_idx + "] = " + a_arg_list [l_args_idx]);
	//}
	
	//"scroller.asp", "ENG", "", "search", "field_scroller", "2", //"MCLOC&lt;quantity&gt;12&lt;/quantity&gt;&lt;start_entry&gt;1&lt;/start_entry&gt;&lt;num_of_items&gt;0&lt;/num_of_items&gt;", //"&lt;Field&gt;MCLOC&lt;/Field&gt;&lt;Root&gt;&lt;/Root&gt;&lt;PrevRoot&gt;&lt;/PrevRoot&gt;&lt;show_details&gt;false&lt;/show_details&gt;", "", "devg_local", "", ""
	
	this.page = a_arg_list [0];
	this.lang = a_arg_list [1];
	this.data_lang = a_arg_list [2];
	this.module = a_arg_list [3];
	this.page_id = a_arg_list [4];
	this.rsvr = a_arg_list [5];
	this.extra_param	= a_arg_list [6];
	this.extra_param2 = a_arg_list [7];
	// arg_list [8] = site_dtl
	this.site	 = a_arg_list [9];
	this.htmldw_action	 = a_arg_list [10];
	this.htmldw_context	= a_arg_list [11];
}

/*
function sapir_scroller_url (a_page, a_lang , a_data_lang, a_module, a_page_id, a_rsvr, a_extra_param, a_extra_param2, a_site_dtl, a_htmldw_action, a_htmldw_context) {
	f_sapir_alert ("sapir_scroller_url : " + a_page + ", " + a_lang + ", " + a_data_lang + ", " + a_module + ", " + a_page_id + ", " + a_rsvr);
	this.page = 	a_page;
	this.lang = a_lang;
	this.data_lang = a_data_lang;
	this.module = a_module;
	this.page_id = a_page_id;
	this.rsvr = a_rsvr;	
	this.extra_param	= a_extra_param;
	this.extra_param2 = a_extra_param2;
	this.site_dtl	 = a_site_dtl;
	this.htmldw_action	 = a_htmldw_action;
	this.htmldw_context	= a_htmldw_context;
}
*/

function f_sapir_scroller_add_row (a_code, a_descr) {
	var l_newrl, l_links_form, l_dw_submit_form, 
			l_lang_el, l_data_lang_el, l_module_el, l_page_id_el, l_rsvr_el, l_extra_param_el, l_extra_param2_el, l_site_el, l_htmldw_action_el, l_htmldw_context_el,
			l_code, l_descr;

	if (typeof (a_code) == "undefined") {
		l_code = g_sapir_cat_from_scroller_props.returned_code;
	}	else {
		l_code = a_code;
	}
	
	if (typeof (a_descr) == "undefined") {
		l_descr = g_sapir_cat_from_scroller_props.returned_descr;
	}	else {
		l_descr = a_descr;
	}
			
	//f_sapir_event_cancel (window.event);

	l_dw_submit_form = f_sapir_form_get_by_name ("htmldw_submitForm");

	f_sapir_selflinkarg_set (l_dw_submit_form, "lang", g_sapir_scroller_url.lang);
	f_sapir_selflinkarg_set (l_dw_submit_form, "data_lang", g_sapir_scroller_url.data_lang);
	f_sapir_selflinkarg_set (l_dw_submit_form, "module", g_sapir_scroller_url.module);
	f_sapir_selflinkarg_set (l_dw_submit_form, "page", g_sapir_scroller_url.page_id);
	f_sapir_selflinkarg_set (l_dw_submit_form, "rsvr", g_sapir_scroller_url.rsvr);

	g_sapir_scroller_url.extra_param = f_sapir_param_set_key (g_sapir_scroller_url.extra_param, "new_values", 
															g_sapir_info_delimiter + l_code + "==" + l_descr + g_sapir_info_delimiter, true);
	
	f_sapir_selflinkarg_set (l_dw_submit_form, "param", g_sapir_scroller_url.extra_param);
	
	f_sapir_selflinkarg_set (l_dw_submit_form, "param2", g_sapir_scroller_url.extra_param2);
	f_sapir_selflinkarg_set (l_dw_submit_form, "site", g_sapir_scroller_url.site);
	f_sapir_selflinkarg_set (l_dw_submit_form, "htmldw_action", g_sapir_scroller_url.htmldw_action);
	f_sapir_selflinkarg_set (l_dw_submit_form, "htmldw_context", g_sapir_scroller_url.htmldw_context);

	g_sapir_unload_popup = true;

	l_dw_submit_form.submit ();

	// put row data in extra_parm, and re-get the current page, so the new will be added
	/*
	l_newrl = f_sapir_url_param_set_key (g_sapir_url, "new_values", "*^" + a_code + "==" + a_descr + "*^"); 
	//l_newrl = f_sapir_url_param_set_key (new String (window.location),"new_values", "*^" + a_code + "==" + a_descr + "*^"); 

	//l_newrl  = "ggg.htm";
	//f_sapir_location_replace (l_newrl);
	
	//self.target  = "_self";
	//f_sapir_alert (f_sapir_get_element_by_id (window.document, "b_add_value").target);

	//// generic to all anchors :
	//if(evt.target.tagName != “A”) {return true;}

	l_links_form = f_sapir_form_get_by_name ("links_form");
	//f_sapir_alert ("l_links_form = " + l_links_form);
	//l_links_form.setAttribute("target", window.name ? window.name : "SrPopUp");
	l_links_form.setAttribute("action", l_newrl);
	l_links_form.submit();

	//self.location.replace ("test_scroller_search_rtl.htm");
	//self.location.replace (l_newrl);
	//self.location = l_newrl;
	*/

	return false;

	/*
	var l_table, l_tbody, l_tr, l_anchor, l_firstItem_td, l_code_text,  l_descr_text, l_rowcount, l_new_row_no, l_code_td, l_descr_td, l_descr_span, l_select_td, l_select_img,
			l_actions_td, l_actions_a, l_actions;

	l_table = f_sapir_get_element_by_id (window.document, "data_rows");
	
	l_tr = l_table.insertRow (0);
	
	l_rowcount  = new Number (f_sapir_dw_param_get_key ("htmldw", "quantity"));
	l_new_row_no = l_rowcount + 1;

	l_tr.setAttribute ("id", "row_" + new String (l_new_row_no));
	l_tr.setAttribute  ("className", "gray");
	l_tr.onmouseover = f_sapir_scroller_mouseover;
	l_tr.onmouseout = f_sapir_scroller_mouseout;

	l_firstItem_td = l_tr.insertCell (0);
	l_firstItem_td.setAttribute ("id", "firstItem");
	l_firstItem_td.setAttribute  ("className", "icons");
	l_firstItem_td.nodeValue = "&nbsp;";

	l_code_td = l_tr.insertCell (1);
	l_code_td.innerHTML =a_code;

	l_descr_td = l_tr.insertCell (2);
	l_descr_span =  window.document.createElement ("SPAN");
	l_descr_span.setAttribute  ("className", "bidie");
	l_descr_span.innerHTML = a_descr;
	l_descr_td.appendChild (l_descr_span);

	//<td class="buttons">
	//<a href="javascript:void(0);" id="row_note4_title" class="note" onclick="showNote('row_note4','scroller', 'row_4');">
	//<img src="images/rtl/icons/icon_action_off.png" alt="פתיחת רשימת פעולות" id="row_Image4" onmouseover="MM_swapImage('row_Image4','','images/rtl/icons/icon_action_on.png',1) " onmouseout="MM_swapImgRestore()" />
	//</a>

	l_select_td = l_tr.insertCell (3);
	l_select_td.setAttribute  ("className", "buttons ");
	l_anchor = window.document.createElement ("A"); 
	l_select_td.appendChild (l_anchor);
	l_anchor.setAttribute ("href", "#");
	l_anchor.onclick= function () {f_sapir_scroller_return	(a_code, a_descr )};
	
	l_descr_text = window.document.createTextNode (a_descr);
	l_anchor.appendChild  (l_descr_text );

	l_select_img = window.document.createElement ("IMG");
	l_anchor.appendChild  (l_select_img );
	l_select_img.setAttribute ("src","images/rtl/value_selection/chooseIcon_off.gif");
	*/
	/*
	l_tbody = l_table.getElementsByTagName ("tbody") [0];

	l_tr = window.document.createElement ("TR"); 

	l_tr.onmouseover = f_sapir_scroller_mouseover;
	l_tr.onmouseout = f_sapir_scroller_mouseout;
	
	l_td = window.document.createElement ("TD"); 

	// <a href="#" onClick="f_sapir_scroller_return ('1079','cat from scroller 24')">cat from scroller 24</a>
	l_anchor = window.document.createElement ("A"); 
	l_td.appendChild (l_anchor);
	
	
	//l_anchor.createAttribute ("href");
	l_anchor.setAttribute ("href", "#");
	f_sapir_alert (l_anchor.getAttribute ("href"));
	
	l_anchor.onclick= function () {f_sapir_scroller_return	(a_code, a_descr )};
	
	l_descr_text = window.document.createTextNode (a_descr);
	l_anchor.appendChild  (l_descr_text );

	l_tr.appendChild (l_td); 

	l_tbody.appendChild (l_tr); 
	*/
}

function f_sapir_scroller_update_row (a_code, a_descr) {
	var l_code, l_descr, l_descr_el;

	//f_sapir_event_cancel (window.event);

	if (typeof (a_code) == "undefined") {
		l_code = g_sapir_cat_from_scroller_props.returned_code;
	}	else {
		l_code = a_code;
	}
	
	if (typeof (a_descr) == "undefined") {
		l_descr = g_sapir_cat_from_scroller_props.returned_descr;
	}	else {
		l_descr = a_descr;
	}
	
	l_descr_el = f_sapir_get_element_by_id (window.document, "descr_" + new String (g_sapir_cat_from_scroller_props.row_no));

	l_descr_el.innerHTML = l_descr;
	//l_descr_el.childNodes [0].nodeValue = f_sapir_decode_text (a_descr);
	return false;
}

function f_sapir_scroller_mouseover () {
	this.className = "blue";
}
function f_sapir_scroller_mouseout () {
	this.className = "white";
}
function f_sapir_scroller_details_toggle (a_list_wrapper_el_id, a_details_wrapper_el_id, a_show_details) {
	var l_details_wrapper_el, l_list_wrapper_el;


	l_list_wrapper_el = f_sapir_get_element_by_id (window.document, a_list_wrapper_el_id);
	if (!f_sapir_exists (l_list_wrapper_el )) {
		return;
	}

	l_details_wrapper_el = f_sapir_get_element_by_id (window.document, a_details_wrapper_el_id);
	//if (!f_sapir_exists (l_details_wrapper_el )) {
		l_dw_submit_form = f_sapir_form_get_by_name ("htmldw_submitForm");

		f_sapir_selflinkarg_set (l_dw_submit_form, "lang", g_sapir_scroller_url.lang);
		f_sapir_selflinkarg_set (l_dw_submit_form, "data_lang", g_sapir_scroller_url.data_lang);
		f_sapir_selflinkarg_set (l_dw_submit_form, "module", g_sapir_scroller_url.module);
		f_sapir_selflinkarg_set (l_dw_submit_form, "page", g_sapir_scroller_url.page_id);
		f_sapir_selflinkarg_set (l_dw_submit_form, "rsvr", g_sapir_scroller_url.rsvr);
		f_sapir_selflinkarg_set (l_dw_submit_form, "param", g_sapir_scroller_url.extra_param);

		/*
		l_show_details = f_sapir_param_get_key (g_sapir_scroller_url.extra_param2, "show_details");
		if (l_show_details == "true") {
			l_show_details = "false";
		} else {
			l_show_details = "true";
		}
		*/
		l_show_details = a_show_details;
		g_sapir_scroller_url.extra_param2 = f_sapir_param_set_key (g_sapir_scroller_url.extra_param2, "show_details", l_show_details, true);
		f_sapir_selflinkarg_set (l_dw_submit_form, "param2", g_sapir_scroller_url.extra_param2);

		f_sapir_selflinkarg_set (l_dw_submit_form, "site", g_sapir_scroller_url.site);
		f_sapir_selflinkarg_set (l_dw_submit_form, "htmldw_action", g_sapir_scroller_url.htmldw_action);
		f_sapir_selflinkarg_set (l_dw_submit_form, "htmldw_context", g_sapir_scroller_url.htmldw_context);
		l_dw_submit_form.submit ();
		return;
	//}

	if (f_sapir_class_find (l_details_wrapper_el, "sapir_hide")) {
		f_sapir_class_remove (l_details_wrapper_el, "sapir_hide");
		f_sapir_class_remove (l_list_wrapper_el, "wideList");

	} else {
		f_sapir_class_prepend (l_details_wrapper_el, "sapir_hide");
		f_sapir_class_prepend (l_list_wrapper_el, "wideList");
	} 

	return;

	/*
	l_info_iframe = f_sapir_get_frame (a_details_frame_id);
	if (!f_sapir_exists (l_info_iframe)) {
		return;
	}
	l_info_iframe_el = f_sapir_get_element_by_id (window.document, a_details_frame_id);
	*/
}

function f_sapir_profile_change (a_new_profile) {
	//debugger;
	l_newrl = f_sapir_url_set_arg (new String (f_sapir_window_location ()),"rsvr", a_new_profile);
	f_sapir_location_replace (l_newrl);
	//window.location.replace (l_newrl);
	return false;
} 

function f_sapir_scroller_add () {
	//f_sapir_scroller_add_row ("123456", "testing");
	//return;

	var l_url_parms, l_scroller_props, l_dialog_args, l_dialog_features, l_file_url, l_called_by_dview,
			l_dst_element, l_dview_wrapper_div, l_dst_dw_col_name, l_code, l_descr, l_caller_lif, l_htmldw_submitform, l_full_url, l_url_parms;

	if (f_sapir_is_empty (g_sapir_scroller_state)) {
		return;
	}
			
	f_sapir_please_wait_popup (true, null, "", null, true, "scroller_add");
			
	g_sapir_cat_from_scroller_props	= new sapir_cat_from_scroller_props ("new");
	l_url_parms = f_sapir_cat_from_scroller_set_parms (g_sapir_cat_from_scroller_props);

	l_full_url = g_sapir_cat_from_scroller_props.url_page + "?" + g_sapir_cat_from_scroller_props.url_parms;
	g_sapir_cat_from_scroller_props.original_url = l_full_url;

	//g_sapir_cat_from_scroller_debug = "1";

	if (g_sapir_cat_from_scroller_debug == "1") {
			//window.location = l_full_url;
			window.open (l_full_url);
	} else {
		/*
		if (g_sapir_browser_is_ie) {
			l_dialog_args = self;
	
			l_dialog_features = "dialogWidth:850px;"
								+ "dialogHeight:450px;"
								+ "resizable:yes"
								+ "help:no;"
								+ "status:no;";
			l_popup_open_ret = f_sapir_ie_modal (l_full_url, 
							 l_dialog_args, l_dialog_features);
			if (l_popup_open_ret == true) {
				if (f_sapir_is_empty (g_sapir_cat_from_scroller_props.returned_code)) {
					g_sapir_cat_from_scroller_props = null;
					return;
				}
			
				// refresh scroller list
				f_sapir_scroller_add_row (g_sapir_cat_from_scroller_props.returned_code, g_sapir_cat_from_scroller_props.returned_descr);
			}
			g_sapir_cat_from_scroller_props = null;			
		} else {
		*/
				l_popup_open_ret = f_sapir_popup (l_full_url, 
						"",
						"height=450"
						+ ",width=850"
						+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
						/*+ ",modal=yes"*/
						);
				return;
		/*}*/
	}

	//f_sapir_alert ("back from scroller add");
}

function f_sapir_scroller_update (a_item_id, ai_row_no) {
	//f_sapir_scroller_add_row ("123456", "testing");
	//return;

	var l_url_parms, l_scroller_props, l_dialog_args, l_dialog_features, l_file_url, l_called_by_dview, l_popup_open_ret,
			l_dst_element, l_dview_wrapper_div, l_dst_dw_col_name, l_code, l_descr, l_caller_lif, l_htmldw_submitform, l_full_url, l_url_parms;

	g_sapir_cat_from_scroller_props	= new sapir_cat_from_scroller_props ("update", a_item_id, ai_row_no);
	l_url_parms = f_sapir_cat_from_scroller_set_parms (g_sapir_cat_from_scroller_props);

	l_full_url = g_sapir_cat_from_scroller_props.url_page + "?" + g_sapir_cat_from_scroller_props.url_parms;
	g_sapir_cat_from_scroller_props.original_url = l_full_url;
	/*
	window.open (l_full_url, 
					"",
					"height=500"
					+ ",width=400"
					+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
					+ ",modal=yes"
					);
	return;
	*/
	/*
	l_htmldw_submitform = f_sapir_form_get_by_name ("htmldw_submitForm");
	l_caller_lif = f_sapir_dw_param_get_key ("htmldw", "lif");
		
	l_full_url = "cat_from_scroller.asp" 
								 + "?"
								 + "lang=" + f_sapir_selflinkarg (l_htmldw_submitform, "lang")
								 + "&module=cataloging"
								 + "&page=notebookcat"
								 + "&rsvr=" + f_sapir_selflinkarg (l_htmldw_submitform, "rsvr")
								 + "&param="
									 + "<caller>scroller</caller>" 
									 + "<caller_lif>" + l_caller_lif + "</caller_lif>"
									 + "<book_id></book_id>"
									 + "<rsvr_id>" + f_sapir_selflinkarg (l_htmldw_submitform, "rsvr")+ "</rsvr_id>"
									 + "<lang_id>" + f_sapir_selflinkarg (l_htmldw_submitform, "lang") + "</lang_id>"
									 + "<dlang>" + f_sapir_selflinkarg (l_htmldw_submitform, "dlang") + "</dlang>"
									 + "<formid>1</formid><tab_id>1</tab_id><tabpage_id>item_main</tabpage_id>"
									 + "<form_client_status>new</form_client_status>"
									 + "<type>" + g_sapir_scroller_state.type1_id + "</type>"
								 + "&param2="
								 + "&site_dtl=" + f_sapir_selflinkarg (l_htmldw_submitform, "site_dtl")
	
	//l_full_url = "test_cat_from_scroller.htm";
	//l_full_url = "test_modal_submit.htm";
	//f_sapir_alert ("v13 : " + l_full_url);
	*/
	
	//g_sapir_cat_from_scroller_debug = "1";
	//f_sapir_alert ("g_sapir_cat_from_scroller_debug = " + g_sapir_cat_from_scroller_debug);

	if (g_sapir_cat_from_scroller_debug == "1") {
			f_sapir_window_location () = l_full_url;
	} else {
		/*
		if (g_sapir_browser_is_ie) {
			// modal popup
			l_dialog_args = self;
	
			l_dialog_features = "dialogWidth:850px;"
								+ "dialogHeight:470px;"
								+ "resizable:yes"
								+ "help:no;"
								+ "status:no;";
			l_popup_open_ret = f_sapir_ie_modal (l_full_url, 
							 l_dialog_args, l_dialog_features);
			if (l_popup_open_ret == true) {
				if (f_sapir_is_empty (g_sapir_cat_from_scroller_props.returned_code)) {
					g_sapir_cat_from_scroller_props = null;
					return;
				}
			}
			// refresh scroller list

			f_sapir_scroller_update_row (g_sapir_cat_from_scroller_props.returned_code, g_sapir_cat_from_scroller_props.returned_descr);
			g_sapir_cat_from_scroller_props = null;
		} else {
		*/
			// non-modal popup
			l_popup_open_ret = f_sapir_popup (l_full_url /* + "&ts=" + f_sapir_datetime_get () */, 
					"scroller cataloging",
					"height=400" /* + g_sapir_measure_unit */
					+ ",width=600" /* + g_sapir_measure_unit */
					+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
					/*+ ",modal=yes"*/
					);
			if (l_popup_open_ret == true) {
				g_sapir_popup_ref.focus ();
			}			
		/*}*/		
	}

	//f_sapir_alert ("back from scroller add");
}

function f_sapir_notebook_set_datalang (a_lang_by) {
	var l_param, l_param_new, l_newrl;
	l_newrl = f_sapir_url_param_set_key (g_sapir_url,"dlang", a_lang_by); 
	f_sapir_location_replace (l_newrl);
	//window.location.replace (l_newrl);
}

function sapir_cat_from_scroller_props (a_mode, a_item_id, ai_row_no) {
	var l_htmldw_submitform, l_table_name_param, l_table_code_param, l_form_id, l_table_param, l_caller_lif;
	
	this.mode = a_mode;

	if (this.mode == "update") {
		this.item_id = a_item_id;
		this.row_no = ai_row_no;
		this.form_client_status = "";
	} else if (this.mode == "new") {
		this.item_id = "";
		this.row_no = -1;
		this.form_client_status = "new";
	} else if (this.mode == "delete") {
		this.item_id = a_item_id;
		this.row_no = ai_row_no;
		this.form_client_status = "delete";
	}

	l_table_name_param = "";
	l_table_code_param = "";
	if (f_sapir_is_empty (g_sapir_scroller_state.table_name)) 	{
		l_form_id = "1";		
	} else {
		l_form_id = "10";
		l_table_name_param = "<table_name>" + g_sapir_scroller_state.table_name + "</table_name>";
		if (a_mode == "update" || a_mode == "delete") {
			l_table_code_param = "<table_code>" + a_item_id + "</table_code>";
		}
	}

	// is it a table ?
	l_table_param = "";

	if (g_sapir_scroller_state.lif_type == "item") {
		l_table_param = "<table>Y</table>";
	} else if (g_sapir_scroller_state.lif_type == "item_link") {
		if (g_sapir_scroller_state.lif_link_tables_type == "1" /*|| g_sapir_scroller_state.lif_link_tables_type == "3"*/)  {
			l_table_param = "<table>Y</table>";
		}
	}

	l_htmldw_submitform = f_sapir_form_get_by_name ("htmldw" + "_submitForm");

	this.ext_param2 = f_sapir_selflinkarg (l_htmldw_submitform, "param2");
	
	l_caller_lif = f_sapir_param_get_key (f_sapir_selflinkarg (l_htmldw_submitform, "param2"), "Field");
	this.ext_param2 = f_sapir_param_remove_key (this.ext_param2, "Field");

	this.url_page = "cat_from_scroller.asp";
	this.module = "cataloging";
	this.page = "notebookcat";
	
	this.lang = f_sapir_selflinkarg (l_htmldw_submitform, "lang");
	this.rsvr = f_sapir_selflinkarg (l_htmldw_submitform, "rsvr");
	this.site = f_sapir_selflinkarg (l_htmldw_submitform, "site");

	this.ext_param = "<caller>scroller</caller>" 
						+ "<caller_lif>" + l_caller_lif + "</caller_lif>"
						+ "<caller_lif_descr>" + escape  (g_sapir_scroller_state.lif_descr) + "</caller_lif_descr>"
						+ "<auto_ref_lif>" + escape  (g_sapir_scroller_state.auto_ref_lif) + "</auto_ref_lif>"
						+ "<book_id>" + this.item_id + "</book_id>"
						+ "<rsvr_id>" + f_sapir_selflinkarg (l_htmldw_submitform, "rsvr")+ "</rsvr_id>"
						+ "<lang_id>" + f_sapir_selflinkarg (l_htmldw_submitform, "lang") + "</lang_id>"
						+ "<dlang>" + f_sapir_selflinkarg (l_htmldw_submitform, "dlang") + "</dlang>"
						+ "<formid>" + l_form_id + "</formid><tab_id>1</tab_id><tabpage_id>item_main</tabpage_id>"
						+ "<form_client_status>" + this.form_client_status + "</form_client_status>"
						+ "<type>" + g_sapir_scroller_state.type1_id + "</type>"
						+ l_table_name_param
						+ l_table_code_param
						+ l_table_param;

	this.ext_param = new String (this.ext_param).replace (/#/g, "!35;");
	this.ext_param2 = new String (this.ext_param2).replace (/#/g, "!35;");
	
	this.url_parms = "";

	this.returned_code = "";
	this.returned_descr = "";

	// clear <table_name> in param selflink argument
	if (f_sapir_is_empty (g_sapir_scroller_state.table_name)) 	{
		l_ext_param = g_sapir_scroller_url.extra_param// f_sapir_selflinkarg (l_htmldw_submitform, "param");
		l_ext_param = f_sapir_param_remove_key (l_ext_param, "table_name");
		//f_sapir_selflinkarg_set (l_htmldw_submitform, "param", l_ext_param) 
		//l_ext_param = f_sapir_selflinkarg (l_htmldw_submitform, "param");
		g_sapir_scroller_url.extra_param = l_ext_param;
	}
}

function f_sapir_cat_from_scroller_set_parms (a_cat_from_scroller_props) {
	var l_url_parms, l_param, l_param2,  _htmldw_submitform;

	l_htmldw_submitform = htmldw.submitForm;

	l_param = a_cat_from_scroller_props.ext_param;

	l_param2 = a_cat_from_scroller_props.ext_param2;
	//alert ("l_param2 = " + l_param2);

	l_url_parms = 	"param=" + l_param
					+ "&param2=" + l_param2
					+ "&lang=" + a_cat_from_scroller_props.lang 
					+ "&module=" + a_cat_from_scroller_props.module 
					+ "&page=" + a_cat_from_scroller_props.page
					+ "&rsvr=" + a_cat_from_scroller_props.rsvr
					+ "&site=" + a_cat_from_scroller_props.site
					;

	a_cat_from_scroller_props.url_parms = l_url_parms;
	return true;
}

function sapir_reader_reg_props () {
	this.returned_code = "";
	this.returned_descr = "";
}

function sapir_reader_update_props () {
	this.returned_descr = "";
}

function sapir_item_delete_props (a_book_id, a_item_descr) {
	this.book_id = a_book_id;
	this.item_decr = a_item_descr;

	this.ret = "";
	this.delete_page_base_args = "";
}

function sapir_basket_download_props () {
	this.ret = "";
}

function f_sapir_please_wait (a_show) {
	var l_show = false;
	if (typeof (a_show) == "undefined") {
		l_show = true;
	}
	f_sapir_please_wait_popup (l_show, null, "", null, true, "please_wait");
}

function f_sapir_please_wait_popup (a_show, a_el, a_msg, a_scrollbar_parent_el, a_horiz_center, a_caller) {
	//f_sapir_alert ("f_sapir_please_wait_popup : " + a_caller + ", " + a_show);
	var l_done_msg_div, l_pop_top, l_pop_left, l_please_wait_iframe, l_please_wait_iframe_el, l_please_wait_iframe_frame, l_please_wait_iframe_window,
			l_iframe_wrapper, l_wrapper_div, l_scrolltop, l_caller;

	if (typeof (a_caller) == "undefined") {
		l_caller = a_caller;
	}
	
	if (typeof (a_show) == "undefined") {
		a_show = true;
	}
	if (typeof (a_el) == "undefined") {
		a_el = null;
	}
	if (typeof (a_msg) == "undefined") {
		a_msg = "";
	}
	if (typeof (a_scrollbar_parent_el) == "undefined") {
		a_scrollbar_parent_el = null;
	}
	if (typeof (a_horiz_center) == "undefined") {
		a_horiz_center = false;
	}	
	
	/*
	if (g_sapir_wrapper_el_id == "") {
		return;
	}
	*/

	//l_iframe_wrapper = f_sapir_get_element_by_id (window.document, "please_wait_wrapper");
	
	l_please_wait_iframe = f_sapir_get_frame ("please_wait_iframe");
	l_please_wait_iframe_el = f_sapir_get_element_by_id (window.document, "please_wait_iframe");
	if (!f_sapir_exists (l_please_wait_iframe_el)) {
		//alert ("f_sapir_please_wait_popup : no iframe_el (" + l_caller + ", " + g_sapir_page_id + ")");
		return null;
	}
	l_please_wait_iframe_frame = f_sapir_get_iframe_frame (l_please_wait_iframe, "please_wait_iframe");
	if (!f_sapir_exists (l_please_wait_iframe_frame)) {
		//alert ("f_sapir_please_wait_popup : no iframe_frame (" + l_caller + ", " + g_sapir_page_id + ")");
		return null;
	}	
	l_please_wait_iframe_window = f_sapir_frame_window (l_please_wait_iframe);
	if (!f_sapir_exists (l_please_wait_iframe_window)) {
		//alert ("f_sapir_please_wait_popup : no iframe_window (" + l_caller + ", " + g_sapir_page_id + ")");
		return null;
	}	

	if (!a_show) {
		f_sapir_class_prepend (l_please_wait_iframe_el, "sapir_hide");
		/*
		l_please_wait_iframe_el.style.height = "1px";			
		l_please_wait_iframe_el.style.width = "1px";			
		l_please_wait_iframe_el.style.top = "1px";			
		l_please_wait_iframe_el.style.left = "1px";
		*/
		return;
	}

	f_sapir_class_prepend (l_please_wait_iframe_el, "sapir_hide");
	//l_please_wait_iframe_el.src = "please_wait.htm";
	if (g_sapir_page_id == "scroller" || g_sapir_page_id == "field_scroller" || g_sapir_page_id == "cat_scroller") {
		l_please_wait_iframe_el.style.height = "36px";
		l_please_wait_iframe_el.style.width = "328px";

		if (typeof (g_sapir_popup_opener.g_sapir_scroller_height) != "undefined") {		
			l_please_wait_iframe_el.style.top = f_sapir_measure ((g_sapir_popup_opener.g_sapir_scroller_height 
																	- f_sapir_get_numeric_measure (l_please_wait_iframe_el.style.height)) / 2,
																	1, g_sapir_popup_opener.g_sapir_scroller_height);
			l_please_wait_iframe_el.style.left = f_sapir_measure ((g_sapir_popup_opener.g_sapir_scroller_width 
																- f_sapir_get_numeric_measure (l_please_wait_iframe_el.style.width)) / 2,
																1, g_sapir_popup_opener.g_sapir_scroller_width);
		}
	} else {
		if (a_el) {
			if (f_sapir_exists (a_scrollbar_parent_el)) {
				l_scrolltop = new Number (a_scrollbar_parent_el.scrollTop);
			} else {
				l_scrolltop = 0;
			}

			//l_please_wait_iframe_el.style.height = "36px";
			//l_please_wait_iframe_el.style.width = "328px";
			l_please_wait_iframe_el.setAttribute ("height", "36px");
			l_please_wait_iframe_el.setAttribute ("width", "328px");
			l_please_wait_iframe_el.style.top = new String (f_sapir_element_get_offsetTop (a_el) - l_scrolltop) + g_sapir_measure_unit;	
			if (a_horiz_center == true) {
				l_please_wait_iframe_el.style.left = new String ((screen.availWidth - 328) / 2) + g_sapir_measure_unit;
			} else {
				l_please_wait_iframe_el.style.left = f_sapir_measure (f_sapir_element_get_offsetLeft (a_el), 
																		1, window.document.documentElement.clientWidth - f_sapir_get_numeric_measure (l_please_wait_iframe_el.getAttribute ("width")));
			}
		} else {					
			l_please_wait_iframe_el.style.height = "36px";
			l_please_wait_iframe_el.style.width = "328px";

			l_please_wait_iframe_el.style.top = f_sapir_measure ((window.document.documentElement.clientHeight 
																	- f_sapir_get_numeric_measure (l_please_wait_iframe_el.style.height)) / 2 
																	+ f_sapir_element_get_offsetTop (window.document.documentElement),
																	1, window.document.documentElement.clientHeight);
			
			l_please_wait_iframe_el.style.left = f_sapir_measure ((window.document.documentElement.clientWidth 
																	- f_sapir_get_numeric_measure (l_please_wait_iframe_el.style.width)) / 2,
																	1, window.document.documentElement.clientwidth);
		}
	}
	
	//debug
	//l_please_wait_iframe_window.f_set_caller (a_caller);
	
	f_sapir_class_remove (l_please_wait_iframe_el, "sapir_hide");

	//l_please_wait_iframe_el.focus ();
	//f_sapir_get_element_by_id (f_sapir_frame_document (l_please_wait_iframe), "please_wait_wrapper").focus ();

	//var child_temp = window.open ("", "", "width=1px,height=1px,"
	//															+ "left=" + f_sapir_get_numeric_measure (l_please_wait_iframe_el.style.left)
	//															+ ",top=" + f_sapir_get_numeric_measure (l_please_wait_iframe_el.style.top));
	//child_temp.close ();
	
	//f_sapir_class_remove (l_iframe_wrapper, "sapir_hide");
	//f_sapir_class_prepend (l_iframe_wrapper, "refreshing");
	//l_please_wait_iframe_el.focus ();
	
	/*
	l_done_msg_div = window.document.createElement ("div");
	l_done_msg_div.setAttribute ("className", "page_refresh");
	l_done_msg_div.innerHTML = "refreshing page, please wait...";
	//l_done_msg_div.childNodes [0].nodeValue = "page refresh, please wait...";
	//f_sapir_alert (l_done_msg_div.style.height + ", " + l_done_msg_div.style.width);
	l_done_msg_div.style.top = f_sapir_measure ((window.document.documentElement.clientHeight - f_sapir_get_numeric_measure ("25px")) / 2,
																	1, window.document.documentElement.clientHeight);
	l_done_msg_div.style.left = f_sapir_measure ((window.document.documentElement.clientWidth - f_sapir_get_numeric_measure ("300px")) / 2,
																	1, window.document.documentElement.clientwidth);

	f_sapir_get_element_by_id (window.document, g_sapir_wrapper_el_id).insertBefore (l_done_msg_div);
	*/
	
	// refresh image
	if (f_sapir_exists (l_please_wait_iframe_window)) {
		if (typeof (l_please_wait_iframe_window.f_image_activate) != "undefined") {
			l_please_wait_iframe_window.f_image_activate ();
		}
	}

	return l_please_wait_iframe_el;
}

function f_sapir_unload_before_handler (a_event) {
	//f_sapir_alert ("f_sapir_unload_before_handler : " + window.location.href);
	var unload_before_exception, l_cat_split_main_frame, l_before_unload_window;
	var b_confirm, l_dview_count, idx, l_rte_el_name, l_rte_window_el, b_chrome_cat_split;
	//try {
	//g_sapir_window_before_unload_done = true;
	//f_sapir_debugger ();
	//f_sapir_alert ("debug_alert : f_sapir_unload_before_handler : " + g_sapir_unload_confirm);

	g_sapir_unload_before = true;

	b_confirm = false;

	// cat_split page : special handling in Google Chrome,
	// since Chrome iframes do not fire onBeforeOnload.
	// so BeforeUnload in cat_split checks if the cat_form_main iFrame has changed
	
	if (g_sapir_browser_type == "chrome" && g_sapir_page_id == "cat_split") {
		b_chrome_cat_split = true;
	} else {
		b_chrome_cat_split = false;
	}

	if (b_chrome_cat_split) {
		l_cat_split_main_frame = f_sapir_get_frame ("main_frame");
		l_before_unload_window = f_sapir_frame_window (l_cat_split_main_frame);
	} else {
		l_before_unload_window = window;
	}

	if (l_before_unload_window.g_sapir_cat_ui_active) {
		if (l_before_unload_window.g_sapir_unload_confirm) {

			if (!l_before_unload_window.f_sapir_form_is_changed ()) {
				b_confirm = false;
			} else {
				b_confirm = true;
			}
		} else {
				l_before_unload_window.g_sapir_unload_confirm = true;
				b_confirm = false;
		}
	}
	
	if (f_sapir_exists (l_before_unload_window.g_sapir_popup_ref)) {
		l_before_unload_window.g_sapir_popup_ref.close ();
	}

	if (b_confirm) {
		return l_before_unload_window.g_sapir_dict.get_value ("gui_6247");
	}

	/*
	if (g_sapir_page_id == "scroller" || g_sapir_page_id == "field_scroller" || g_sapir_page_id == "cat_scroller") {
		if (!g_sapir_unload_popup_cancel ) 	{
				g_sapir_unload_popup = true;
		}
		g_sapir_unload_popup_cancel = false;
	}
	*/

	/*
	// cat from scroller : closing on X requires updating opener, as in CLOSE button
	if (g_sapir_cat_ui_active) {
		if (g_sapir_form.cat_mode == "scroller") {
			// f_sapir_form_cancel (); 
			// OR : f_sapir_cat_from_scroller_close ();
		}
	}
	*/
	
	if (l_before_unload_window.g_sapir_unload_popup) {
		l_before_unload_window.f_sapir_please_wait_popup (true, null, "", null, true, "unload_before_handler : " + g_sapir_page_id);
	}

	if (l_before_unload_window.g_sapir_cat_ui_active) {
		if (g_sapir_unload_called_by_app == false) {
			if (l_before_unload_window.g_sapir_unload_popup == false) {
				l_before_unload_window.f_sapir_please_wait_popup (true, null, "", null, true, "unload_before_handler");
			}
			l_before_unload_window.f_sapir_readonly_form (true, false, "all");
		}
	}
	//event.returnValue = "";
	
	if (l_before_unload_window.g_sapir_cat_ui_active) {
		if (g_sapir_unload_called_by_app == false) {
			return;
		} else {
			return "";
		}
	} else {
		return;
	}
	
	/*
	if (g_sapir_is_rte) {
		var l_dview_count, idx, l_rte_el_name, l_rte_el;
		l_dview_count = g_sapir_form_dviews.length;
		for (idx = 0; idx < l_dview_count; idx++) {
			if (g_sapir_form_dviews [idx].dview_function != "summary") {
				continue;
			}
			
			l_rte_el_name = g_sapir_form_dviews [idx].dview_id + "_rte";
			l_rte_window_el = window.document.frames [l_rte_el_name];
			//document.getElementById(rte).contentWindow.document
			l_rte_window_el.history.go (1);
		}
	}
	*/
	
	//event.returnValue = "";
	//if (!f_sapir_msgbox (null, g_sapir_form_changed_msg, "info", "f_sapir_brief_toggle", "confirm")) {
	//	return g_sapir_form_changed_short_msg;
    //}
		
	//} catch (unload_before_exception) {
	//	//debugger;
	//	f_sapir_exception ("sapirjsfile", "unload_before", unload_before_exception);
	//}
}

function f_sapir_unload_handler () {
	//if (g_sapir_page_id == "cat_media_upload") {
	//	debugger;
	//	//alert ("cat_media_upload unload");
	//}

	var unload_exception;
	try {
	var l_dview_count, idx, l_rte_el_name, l_rte_el;
	
	if (g_sapir_cat_ui_active) {
		if (g_sapir_is_rte) {
			// turn off design mode in all RTEs since GPFs in IE7 on history BACK button
			f_sapir_rte_set_design_mode ("off");
		}
	}
	
	if (g_sapir_is_popup && g_sapir_is_ie_modal == false) {
		if (g_sapir_popup_close_notify) {
			if (f_sapir_exists (g_sapir_popup_opener) && !g_sapir_popup_opener.closed) {
				g_sapir_popup_opener.f_sapir_popup_closed ();
			}
		}
	}

	/*	
	if (typeof (g_sapir_is_popup) != "undefined") {
		if (g_sapir_is_popup == true) {
			if (typeof (g_sapir_popup_opener) != "undefined") {
				var l_parent_wait_typoef  = typeof g_sapir_popup_opener.f_sapir_scroller_please_wait_close;
				if ((l_parent_wait_typoef == "object" || l_parent_wait_typoef == "function")) {
					g_sapir_popup_opener.f_sapir_scroller_please_wait_close ();
				}
			}
		}
	}
	*/
	
	if (f_sapir_exists (g_sapir_trace_win)) {
		g_sapir_trace_win.close ();
	}
	
	} catch (unload_exception) {
		//debugger;
		f_sapir_exception ("sapirjsfile", "unload", unload_exception);
	}
}

function f_sapir_split_set_media (a_url) {
	//return;
	//debugger;
	var	l_url, l_last_dot_pos, l_extension, l_url_frame, l_url_frame_el, l_url_frame_doc, l_url_frame_frame,
			l_media_object, l_media_embed, l_media_param, 
			l_media_fileName, l_media_animationatStart, l_media_transparentatStart, l_media_autoStart, l_media_showControls, l_media_Volume;

	l_extension = "";
	l_url = new String (a_url);

	l_last_dot_pos = l_url.lastIndexOf (".");
	if (l_last_dot_pos > 0) {
		l_extension = l_url.substring (l_last_dot_pos + 1).toLowerCase ();
	}

	if (l_url.indexOf ("http://") == 0 || l_url.indexOf ("https://") == 0 || l_url.indexOf ("www.") == 0 || l_url.indexOf ("/") == 0) {
		// url
		if (l_extension == "pdf") {
			f_pdf_iframe (l_url);
		} else {
			f_pdf_iframe (l_url);
			//f_split_media_url_iframe_anchor (l_url);
		}
		//f_split_media_url_iframe_anchor (l_url);
		//f_url_anchor (l_url);
		//f_url_iframe (l_url);
		return;
	}

	if (l_extension == "pdf") {
		//return;
		//f_sapir_get_element_by_id (window.document, "split_media_object").data = a_url + "#navpanes=0";
		//// pdf parms : #navpanes=0&scrollbar=0&toolbar=0
		////f_sapir_get_element_by_id (window.document, "split_media_object").src = a_url;
		//f_sapir_class_prepend (f_sapir_get_element_by_id (window.document, "split_media_img"), "sapir_invisible");
		//f_sapir_class_remove (f_sapir_get_element_by_id (window.document, "split_media_object"), "sapir_invisible");
		
		/*
		//a_url = "4693145_08032102_JM_19983_7021_73_24.pdf";
		//f_sapir_alert ("test url = " + a_url);

		l_media_object = document.createElement ("object");
		l_media_object.setAttribute ("type", "application/pdf");
		l_media_object.setAttribute ("name", "split_media_object");
		l_media_object.setAttribute ("id", "split_media_object");
		l_media_object.setAttribute ("width", "95%");
		l_media_object.setAttribute ("height", "95%");
		l_media_object.setAttribute ("data", a_url + "#navpanes=0");
		//l_media_object.setAttribute ("class", "");
		l_media_object.setAttribute ("style", "margin:3px 3px 3px 3px;left=2px;");
		document.getElementsByTagName ("body")[0].appendChild (l_media_object);
		*/

		//a_url = "4693145_08032102_JM_19983_7021_73_24.pdf";
		//f_sapir_alert ("test LOCAL pdf = " + a_url);

		f_pdf_iframe (a_url);

		//document.writeln ("<object name=\"split_media_object\" id=\"split_media_object\" width=\"95%\" height=\"95%\" data=\"" + a_url + "#navpanes=0" + "\"" 
		//				+ "src=\"\" type=\"application/pdf\" class=\"\" style=\"margin:3px 3px 3px 3px;left=2px; float;\"></object>");
		return;
	} 

	if (l_extension == "doc") {
		f_pdf_iframe (a_url);
		//f_split_media_url_iframe_anchor (l_url, l_extension);
		return;
	}

	if (l_extension == "tif" || l_extension == "tiff") {
		l_url = "media_to_thumbnail.asp?media_full_path=" + l_url + "&thumbnail_width=" + g_sapir_tif_split_size;
		f_split_media_url_iframe_anchor (l_url, l_extension);
		//f_sapir_get_element_by_id (window.document, "split_media_img").src = 
		//	"media_to_thumbnail.asp?"
		//	+ "media_full_path=" + a_url 
		//	+ "&thumbnail_width=600";
		//f_sapir_class_remove (f_sapir_get_element_by_id (window.document, "split_media_img"), "sapir_invisible");
		return;
	}
	
	if (l_extension == "mp3") {
		f_split_media_url_iframe_anchor (l_url, l_extension);
		//f_url_anchor (l_url);
		//f_url_iframe (l_url);

		/* windows media player
		if (navigator.appName == "Microsoft Internet Explorer") {
			l_media_object = document.createElement ("object");
			l_media_object.setAttribute ("name", "split_media_object");
			l_media_object.setAttribute ("id", "split_media_object");
			l_media_object.setAttribute ("type", "audio/mpeg");
			l_media_object.setAttribute ("data", l_url);
			//l_media_object.setAttribute ("classid", "CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95");
			//l_media_object.setAttribute ("codebase", "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701");

			//l_media_fileName = document.createElement ("param");
			//l_media_fileName.setAttribute ("name", "fileName");
			//l_media_fileName.setAttribute ("value", l_url);
			//l_media_object.appendChild (l_media_fileName);

			//l_media_animationatStart = document.createElement ("param");
			//l_media_animationatStart.setAttribute ("name", "animationatStart");
			//l_media_animationatStart.setAttribute ("value", "true");
			//l_media_object.appendChild (l_media_animationatStart);

			//l_media_transparentatStart = document.createElement ("param");
			//l_media_transparentatStart.setAttribute ("name", "transparentatStart");
			//l_media_transparentatStart.setAttribute ("value", "true");
			//l_media_object.appendChild (l_media_transparentatStart);

			//l_media_autoStart = document.createElement ("param");
			//l_media_autoStart.setAttribute ("name", "autoStart");
			//l_media_autoStart.setAttribute ("value", "true");
			//l_media_object.appendChild (l_media_autoStart);

			//l_media_showControls = document.createElement ("param");
			//l_media_showControls.setAttribute ("name", "showControls");
			//l_media_showControls.setAttribute ("value", "true");
			//l_media_object.appendChild (l_media_showControls);

			//l_media_Volume = document.createElement ("param");
			//l_media_Volume.setAttribute ("name", "Volume");
			//l_media_Volume.setAttribute ("value", "-300");
			//l_media_object.appendChild (l_media_Volume);

			document.getElementsByTagName ("body")[0].appendChild (l_media_object);
		} else {
			l_media_embed = document.createElement ("embed");
			l_media_embed.setAttribute ("type", "application/x-mplayer2");
			l_media_embed.setAttribute ("pluginspage", "http://www.microsoft.com/Windows/MediaPlayer/");
			l_media_embed.setAttribute ("src", l_url);
			l_media_embed.setAttribute ("name", "MediaPlayer1");
			l_media_embed.setAttribute ("width", "280");
			l_media_embed.setAttribute ("height", "46");
			l_media_embed.setAttribute ("autostart", "1");
			l_media_embed.setAttribute ("showcontrols", "1");
			l_media_embed.setAttribute ("volume", "-300");

			document.getElementsByTagName ("body")[0].appendChild (l_media_embed);
		}
		*/

		//f_split_media_url_iframe_anchor (l_url);
		//f_url_anchor (l_url);
		//f_url_iframe (l_url);
		return;
	}

	// standard image
	f_split_media_url_iframe_anchor (l_url, l_extension);
	//f_sapir_get_element_by_id (window.document, "split_media_img").src = a_url;
	//f_sapir_class_remove (f_sapir_get_element_by_id (window.document, "split_media_img"), "sapir_invisible");

	//window.document.all ["split_media_img"].src = a_url;
}

function f_sapir_split_media_close () {
	parent.f_sapir_split (true);
}

function f_sapir_split_media_sync_parent_pos () {
	var l_url_frame_el, l_url_frame_doc, l_url_frame_window, l_pdf_frame_el;
	l_url_frame_el = f_sapir_get_element_by_id (window.document, "url_frame");
	if (!f_sapir_exists (l_url_frame_el)) {
		return;
	}
	//if (window.document.documentElement.clientWidth - 10 > f_sapir_get_numeric_measure (l_url_frame_el.style.width)) {
		l_url_frame_el.style.width = f_sapir_measure (window.document.documentElement.clientWidth - 10, -1, -1);
	//}

	l_url_frame = f_sapir_get_frame ("url_frame");	
	l_url_frame_doc = f_sapir_frame_document (l_url_frame);
	l_url_frame_window = f_sapir_frame_window (l_url_frame);
	
	l_pdf_frame = l_url_frame_window.f_sapir_get_frame ("pdf_frame");
	l_pdf_frame_el = f_sapir_get_element_by_id (l_url_frame_doc, "pdf_frame");

	if (!f_sapir_exists (l_pdf_frame_el)) {
		return;
	}
	//if (window.document.documentElement.clientWidth - 10 > f_sapir_get_numeric_measure (l_url_frame_el.style.width)) {
		l_pdf_frame_el.style.width = f_sapir_measure (window.document.documentElement.clientWidth - 10, -1, -1);
	//}
}

function f_split_media_url_iframe_anchor (a_url, a_extension) {
	var l_frame_document, l_url_frame_doc, l_url_frame_el, l_iframe_anchor_el;

	if (f_sapir_is_empty (a_url)) {
		return;
	}
	
	if (!a_extension) {
		a_extension = "";
	}
	a_extension = a_extension.toLowerCase ();

	l_url_frame = f_sapir_get_frame ("url_frame");
	l_url_frame_doc = f_sapir_frame_document (l_url_frame);
	l_url_frame_el = f_sapir_get_element_by_id (window.document, "url_frame");

	//l_url_frame_frame = f_sapir_get_iframe_frame (l_url_frame);
	//l_url_frame_el.style.position = "relative";

	l_url_frame_el.style.height = f_sapir_measure (window.document.documentElement.clientHeight - 50, -1, -1);
	l_url_frame_el.style.width = f_sapir_measure (window.document.documentElement.clientWidth - 10, -1, -1);

	if (a_extension == "doc" || a_extension == "mp3" || a_extension == "flv") {
		l_iframe_anchor_el = f_sapir_get_element_by_id (l_url_frame_doc, "split_media_anchor");
		l_iframe_anchor_el.href = a_url;
		f_sapir_class_remove (l_iframe_anchor_el, "sapir_invisible");
		l_iframe_anchor_el.focus ();
		l_iframe_anchor_el.click ();

	} else if (a_extension == "gif" || a_extension == "jpg" || a_extension == "png" || a_extension == "tif") {
		//debugger;
		var l_image_width, l_image_height;
		l_iframe_anchor_el = f_sapir_get_element_by_id (l_url_frame_doc, "split_media_img");
		l_iframe_anchor_el.src = a_url;
		l_image_width = f_sapir_get_image_width (a_url);
		if (l_image_width > 0) {
			l_iframe_anchor_el.width = l_image_width;
		}
		l_image_height = f_sapir_get_image_height (a_url);
		if (l_image_height > 0) {
			l_iframe_anchor_el.height = l_image_height;
		}
		f_sapir_class_remove (l_iframe_anchor_el, "sapir_invisible");
	} else {
		f_sapir_location_replace (a_url, l_url_frame, true);
		//l_url_frame.location.replace (a_url);
	}

	f_split_media_url_frame_progress_bar_fix ();
}

function f_split_media_url_frame_progress_bar_fix (a_url) {
	var l_frame_document, l_url_frame_doc, l_url_frame_el;

	l_url_frame = f_sapir_get_frame ("url_frame");
	l_url_frame_doc = f_sapir_frame_document (l_url_frame);
	l_url_frame_el = f_sapir_get_element_by_id (window.document, "url_frame");

	//while (l_url_frame_el.readyState.toLowerCase () != "complete") {
	//}
	f_sapir_frame_window (l_url_frame).f_sapir_progress_bar_fix ();
}

function f_pdf_iframe (a_url) {
	var l_frame_document, l_url_frame_doc, l_url_frame_el /*, l_pdf_control_el*/, l_url_frame_window, l_pdf_frame_doc, l_pdf_frame_el;

	l_url_frame = f_sapir_get_frame ("url_frame");
	l_url_frame_doc = f_sapir_frame_document (l_url_frame);
	l_url_frame_el = f_sapir_get_element_by_id (window.document, "url_frame");
	l_url_frame_window = f_sapir_frame_window (l_url_frame);
	//l_url_frame_frame = f_sapir_get_iframe_frame (l_url_frame);
	//l_url_frame_el.style.position = "relative";

	l_url_frame_el.style.height = f_sapir_measure (window.document.documentElement.clientHeight - 10, -1, -1);
	l_url_frame_el.style.width = f_sapir_measure (window.document.documentElement.clientWidth - 10, -1, -1);

	l_pdf_frame = l_url_frame_window.f_sapir_get_frame ("pdf_frame");
	l_pdf_frame_el = f_sapir_get_element_by_id (l_url_frame_doc, "pdf_frame");
	
	l_pdf_frame_el.style.height = l_url_frame_el.style.height;
	l_pdf_frame_el.style.width = l_url_frame_el.style.width;

	f_sapir_location_replace (a_url, l_pdf_frame, true);
	//l_url_frame.location.replace (a_url);

	/*
	l_pdf_control_el = f_sapir_get_element_by_id (l_url_frame_doc, "split_media_object");
	l_pdf_control_el.data = a_url + "#navpanes=0";
	//f_sapir_class_remove (l_iframe_anchor_el, "sapir_invisible");
	//l_iframe_anchor_el.focus ();
	//l_iframe_anchor_el.click ();
	*/

	//f_pdf_frame_progress_bar_fix ();
}

function f_pdf_frame_progress_bar_fix (a_url) {
	var l_frame_document, l_url_frame_doc, l_url_frame_el, l_garbage_frame;

	l_url_frame = f_sapir_get_frame ("url_frame");
	l_url_frame_doc = f_sapir_frame_document (l_url_frame);
	l_url_frame_el = f_sapir_get_element_by_id (window.document, "url_frame");

	//while (l_url_frame_el.readyState.toLowerCase () != "complete") {
	//}

	//l_url_frame.f_sapir_progress_bar_fix ();
	l_garbage_frame = parent.f_sapir_get_frame ("garbage_frame");
	if (!f_sapir_exists (l_garbage_frame)) {
		return;
	}
	f_sapir_frame_window(l_garbage_frame).f_submit ();
}

function f_sapir_limitPane_expand_by_id (a_el, a_state) {
	var l_field_el;

	if (a_state == "limit") {
		l_field_el = f_sapir_get_element_by_id (window.document, "limitOptionsTab");
		f_sapir_class_prepend (l_field_el, "active");

		l_field_el = f_sapir_get_element_by_id (window.document, "databanksTab");
		f_sapir_class_remove (l_field_el, "active");

		l_field_el = f_sapir_get_element_by_id (window.document, "limitOptions");
		f_sapir_class_remove (l_field_el, "sapir_hide");

		l_field_el = f_sapir_get_element_by_id (window.document, "databanks");
		f_sapir_class_prepend (l_field_el, "sapir_hide");
	} 	else {
		l_field_el = f_sapir_get_element_by_id (window.document, "limitOptionsTab");
		f_sapir_class_remove (l_field_el, "active");

		l_field_el = f_sapir_get_element_by_id (window.document, "databanksTab");
		f_sapir_class_prepend (l_field_el, "active");

		l_field_el = f_sapir_get_element_by_id (window.document, "databanks");
		f_sapir_class_remove (l_field_el, "sapir_hide");

		l_field_el = f_sapir_get_element_by_id (window.document, "limitOptions");
		f_sapir_class_prepend (l_field_el, "sapir_hide"); 
	}
}

function f_sapir_basket_download (a_confirm_title, a_confirm_msg) {
	var l_dialog_ref, l_dw_submit_form, l_param, l_param2, l_lang, l_site, l_confirm_title, l_confirm_msg, l_dialog_args, l_dialog_features,
			l_popup_open_ret;

	g_sapir_basket_download_props = new sapir_basket_download_props ();

	l_confirm_title = escape (a_confirm_title);
	l_confirm_msg = escape (a_confirm_msg);

	l_dw_submit_form = f_sapir_form_get_by_name ("htmldw_submitForm");

	l_lang = new String (f_sapir_selflinkarg (l_dw_submit_form, "lang"));
	l_site = new String (f_sapir_selflinkarg (l_dw_submit_form, "site"));

	l_param = new String (f_sapir_selflinkarg (l_dw_submit_form, "param"));
	l_param2 = new String (f_sapir_selflinkarg (l_dw_submit_form, "param2"));
	
	l_page_url_args =	"?" 
											+ "lang=" + l_lang
											+  "&param=" + l_param
											+  "&param2=" + l_param2
											+  "&site=" + l_site
											+ "&confirm_title=" + l_confirm_title
											+ "&confirm_msg=" + l_confirm_msg;

	/*
	if (g_sapir_browser_is_ie) {
		l_dialog_args = self;
	
		l_dialog_features = "dialogWidth:400px;"
							+ "dialogHeight:125px;"
							+ "help:no;"
							+ "resizable:yes;"
							+ "status:no;";
		l_popup_open_ret = f_sapir_ie_modal ("basket_download_confirm.asp" + l_page_url_args, 
						 l_dialog_args, l_dialog_features);
	} else {
	*/
		l_popup_open_ret = f_sapir_popup (	"basket_download_confirm.asp" + l_page_url_args /*+ "?" + "ts=" + f_sapir_datetime_get ()*/, 
																		"",
																		"height=250" /* + g_sapir_measure_unit */
																		+ ",width=350" /* + g_sapir_measure_unit */
																		+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
																		/*+ ",modal=yes"*/
																		);
		if (l_popup_open_ret == true) {
			g_sapir_popup_ref.focus ();	
		}
	/*}*/
}

function f_sapir_basket_download_confirm_init (a_dialogArguments) {
	/*
	//f_sapir_log ("f_sapir_basket_download_confirm_init", "", 3);
	if (typeof (a_dialogArguments) != "undefined") {
		window.opener = a_dialogArguments;
	} else {
		//f_sapir_alert ("f_sapir_scroller_init : " + window.opener);
	}
	//window.opener.f_sapir_log ("f_sapir_basket_download_confirm_init", "", 3);
	*/
}

function f_sapir_basket_download_confirm_return (a_ret) {
	g_sapir_popup_opener.g_sapir_basket_download_props.ret = a_ret;
	g_sapir_popup_opener.f_sapir_basket_download_back_to_opener (self);
	self.close();
}

function f_sapir_basket_download_back_to_opener (a_dialog_ref) {
	var l_basket_download_rc, l_page_base_args, l_error_code_begin_pos, l_error_code_end_pos, l_error_code, l_error_msg_begin_pos, l_error_msg_end_pos, l_error_msg, l_final_msg;

	// basket_download canceled
	if (g_sapir_basket_download_props.ret == "$sapir_basket_download$cancel$/sapir_basket_download$" || f_sapir_is_empty (g_sapir_basket_download_props.ret)) {
		g_sapir_basket_download_props.ret = "";
		if (g_sapir_cat_ui_active) {
			g_sapir_unload_confirm = true;
		}
		g_sapir_basket_download_props = null;
		return;
	}

	l_basket_download_rc = f_sapir_basket_download_result (g_sapir_basket_download_props);

	// basket_download failed
	//if (l_basket_download_rc == false) {
		l_final_msg = f_sapir_basket_download_response_msg (g_sapir_basket_download_props);

		if (a_dialog_ref) {
			f_sapir_get_element_by_id (a_dialog_ref.document, "basket_download_response_msg").innerHTML = l_final_msg;
		} else {
			f_sapir_alert (l_final_msg);
		}

		if (g_sapir_cat_ui_active) {
			g_sapir_unload_confirm = true;
		}
		g_sapir_basket_download_props = null;
		return;
	//}

	// delete done
	if (a_dialog_ref) {
		a_dialog_ref.close ();
	}
	g_sapir_basket_download_props = null;
}

function f_sapir_basket_download_result (a_basket_download_props) {
	if (a_basket_download_props.ret.indexOf ("$sapir_basket_download$failed$/sapir_basket_download$") >= 0) {
		return false;
	}
	return true;
}

function f_sapir_basket_download_response_msg (a_basket_download_props) {
	l_error_code_begin_pos = a_basket_download_props.ret.indexOf ("$error_code$") + new String ("$error_code$").length;
	l_error_code_end_pos = a_basket_download_props.ret.indexOf ("$/error_code$") - 1;
	l_error_code = a_basket_download_props.ret.substring (l_error_code_begin_pos, l_error_code_end_pos + 1);
	
	l_error_msg_begin_pos = a_basket_download_props.ret.indexOf ("$error_text$") + new String ("$error_text$").length;
	l_error_msg_end_pos = a_basket_download_props.ret.indexOf ("$/error_text$") - 1;
	l_error_msg = a_basket_download_props.ret.substring (l_error_msg_begin_pos, l_error_msg_end_pos + 1);
	
	if (f_sapir_is_empty (l_error_msg)) {
		l_error_msg = "Basket download failed"
		if (!f_sapir_is_empty (l_error_code)) {
			l_error_msg += "\r\n" + "(error no.  " + l_error_code + ")";
		}
	}
	return l_error_msg;
}
	
function f_sapir_textarea_width (a_textarea_el) {
	// width : in IE (7?) it must be set as definite size
	
	var l_ta_width, l_client_width;

	if (!g_sapir_browser_is_ie) {
		return;
	}

	if (!f_sapir_is_empty (a_textarea_el.value)) {
		l_client_width = new Number (window.document.documentElement.clientWidth);		
		l_ta_width = "98.5%";
		a_textarea_el.style.width = new String (l_ta_width);
		//l_ta_width = l_client_width * 0.478;
		//a_textarea_el.style.width = new String (l_ta_width) + "px";
	}
}

function f_sapir_textarea_design_refresh () {
	var l_ta_count, l_ta_idx;
	
	if (!g_sapir_browser_is_ie) {
		return;
	}
	l_ta_count = g_sapir_textrea_list.length;

	for (l_ta_idx = 0; l_ta_idx < l_ta_count; l_ta_idx++) {
		f_sapir_textarea_width (g_sapir_textrea_list [l_ta_idx]);
	}
}

function f_sapir_scroller_width (a_modal) {
	var l_width;
	
	if (a_modal == true) {
		l_width = screen.availWidth - 300;
	} else {
		l_width = screen.availWidth - 300;
	}
	
	g_sapir_scroller_width = l_width;
	return g_sapir_scroller_width;
}

function f_sapir_scroller_height (a_modal) {
	var l_height;
	
	if (a_modal == true) {
		l_height = screen.availHeight - 160;
	} else {
		l_height = screen.availHeight - 220;
	}
	//if (typeof window.innerWidth != "undefined") {
	//	l_height = screen.availHeight - 220;
	//} else {
	//}
	
	g_sapir_scroller_height = l_height;
	return g_sapir_scroller_height;
}

function f_sapir_media_scroller_width (a_modal) {
	var l_width;
	
	if (a_modal == true) {
		l_width = screen.availWidth - 300;
	} else {
		l_width = screen.availWidth - 300;
	}
	
	if (l_width > 650) {
		l_width = 650;
	}
	
	g_sapir_media_scroller_width = l_width;
	return g_sapir_media_scroller_width;
}

function f_sapir_media_scroller_height (a_modal) {
	var l_height;
	
	if (a_modal == true) {
		l_height = screen.availHeight - 160;
	} else {
		l_height = screen.availHeight - 220;
	}
	//if (typeof window.innerWidth != "undefined") {
	//	l_height = screen.availHeight - 220;
	//} else {
	//}
	
	if (l_height > 550) {
		l_height = 550;
	}
	
	g_sapir_media_scroller_height = l_height;
	return g_sapir_media_scroller_height;
}

function f_sapir_login_dialog_ok () {
	//f_sapir_alert ("f_sapir_login_dialog_ok");
	
	if (g_sapir_is_ie_modal == false) {
		f_sapir_login_dialog_main ();
	} else {
		f_sapir_login_dialog_main (g_sapir_popup_opener);
	}
	f_sapir_login_return ("$sapir_login$ok$/sapir_login$");
}

function f_sapir_login_dialog_main (a_dialogArguments) {
	if (typeof (a_dialogArguments) == "undefined") {
		f_sapir_login_dialog_init ();
	} else {
		f_sapir_login_dialog_init (a_dialogArguments);
	}
}

function f_sapir_changes_backup (a_htmldw_name, a_new_value, a_dw_row, a_dw_col) {
	var l_changes_restore_el, l_changes_restore_value, l_new_value;
	l_changes_restore_el = f_sapir_get_element_by_id (window.document, "sapir_changes_" + a_htmldw_name);
	
	if (!l_changes_restore_el) {
		return;
	}
	
	l_new_value = new String (a_new_value);
	
	l_new_value = l_new_value.replace(/\"/g, "\\\"");
	l_new_value = l_new_value.replace(/\'/g, "\\\'");
	
	l_changes_restore_value = l_changes_restore_el.value;
	l_changes_restore_value = f_sapir_info_set_key (l_changes_restore_value, a_dw_row + "." + a_dw_col, l_new_value);
	l_changes_restore_el.value = l_changes_restore_value;
	//alert (window.location.href + "\r\n" + l_changes_restore_el.value);
	//document.title = l_changes_restore_el.value;
	return;
}

function f_sapir_changes_test (a_htmldw_name) {
	var l_changes_restore_el, l_changes_restore_value;
	l_changes_restore_el = f_sapir_get_element_by_id (window.document, "sapir_changes_" + a_htmldw_name);
	
	if (!l_changes_restore_el) {
		return;
	}
	
	alert (window.location.href + "\r\n" + l_changes_restore_el.value);
	//document.title = l_changes_restore_el.value;
	return;
}

function f_sapir_changes_restore (a_htmldw_name) {
	// 	after history paging : for search pages - restore page inputs,
	//	for new item : restore page inputs, for updating an item : refresh page

	var l_changes_restore_el, l_restore, l_changes, l_changes_string, l_key_value, l_key_value_string, l_key, l_key_string, l_value, l_dw_row, l_dw_col_name;
	//l_sapir_info_obj = new sapir_info_class ();

	l_restore = true;

	/*
	if (g_sapir_cat_ui_active) {
		if (f_sapir_dw_param_get_key ("sapir_form_dw", "form_client_status") != "new") {
			l_restore = false;
		}		
	}
	*/

	l_changes_restore_el = f_sapir_get_element_by_id (window.document, "sapir_changes_" + a_htmldw_name);
	//f_sapir_alert ("changes_restore el = " + l_changes_restore_el);
	if (!f_sapir_exists (l_changes_restore_el)) {
		return;
	}
	//f_sapir_alert ("changes_restore el value = " + l_changes_restore_el.value);
	if (f_sapir_is_empty (l_changes_restore_el.value)) {
		return;
	}
	
	if (!l_restore) {
		f_sapir_location_reload ();
		return;
	}
	
	l_changes = l_changes_restore_el.value;
	l_changes_string = new sapir_string_obj (l_changes);
	l_key_value = f_sapir_get_token (l_changes_string, g_sapir_info_delimiter);
	
	while (!f_sapir_is_empty (l_key_value) || l_changes_string.value.length > 0) {
		if (f_sapir_is_empty (l_key_value)) {
			l_key_value = f_sapir_get_token (l_changes_string, g_sapir_info_delimiter);
			continue;
		}
		l_key_value_string = new sapir_string_obj (l_key_value);
		
		l_key = f_sapir_get_token (l_key_value_string, "==");
		l_value = l_key_value_string.value;
		
		// key is row.col : strip them
		l_key_string = new sapir_string_obj (l_key);
		l_dw_row = f_sapir_get_token (l_key_string, ".");
		l_dw_col_name = l_key_string.value;
		
		//f_sapir_alert ("f_sapir_changes_restore : " + l_dw_row + "." + l_dw_col_name + " == " + l_value)
		
		f_dbg ("setitem_K");
		eval (a_htmldw_name + ".SetItem (l_dw_row,\"" + l_dw_col_name + "\",\"" + l_value + "\")");
		//var ggg = eval (a_htmldw_name + ".GetItem (l_dw_row,\"" + l_dw_col_name + "\")");
		//f_sapir_alert ("f_sapir_changes_restore : " + ggg);
		
		// continue to next key
		l_key_value = f_sapir_get_token (l_changes_string, g_sapir_info_delimiter);
	}
}

function f_sapir_delete_confirm_main (a_dialogArguments) {
	//f_sapir_alert ("f_sapir_delete_confirm_main");
	if (typeof (a_dialogArguments) == "undefined") {
		f_sapir_delete_confirm_init ();
	} else {
		f_sapir_delete_confirm_init (a_dialogArguments);
	}
}

function f_sapir_delete_confirm_cancel () {
	//f_sapir_alert ("f_sapir_delete_confirm_cancel");
	if (f_sapir_exists (g_sapir_popup_opener) && !g_sapir_popup_opener.closed) {
		g_sapir_popup_opener.g_sapir_item_delete_props.ret = "$sapir_delete$cancel$/sapir_delete$";
	}
	self.close ();
}

function f_sapir_delete_confirm_delete () {
	//f_sapir_alert ("f_sapir_delete_confirm_delete");
	var l_form, l_param_el, l_param_value, l_ok_button_el, l_cancel_button_el;

	l_ok_button_el= f_sapir_get_element_by_id (window.document, "b_ok");
	l_cancel_button_el= f_sapir_get_element_by_id (window.document, "b_cancel");

	l_ok_button_el.disabled = true;
	l_cancel_button_el.disabled = true;

	l_form = f_sapir_get_element_by_id (window.document, "form1");
	l_param_el = f_sapir_get_element_by_id (l_form, "param");
	l_param_value = l_param_el.value;
	l_param_value = f_sapir_param_set_key (l_param_value, "form_client_status", "delete"); 
	l_param_el.value = l_param_value;
	l_form.submit ();
}

function f_basket_download_cancel () {
	//window.opener.g_sapir_basket_download_props.ret = "$sapir_download$cancel$/sapir_download$";
	self.close ();
}
			
function f_basket_download_go (a_remove) {
	var l_form, l_param_el, l_param_value, l_yes_button_el, _l_no_button_el, l_cancel_button_el;

	l_yes_button_el= f_sapir_get_element_by_id (window.document, "b_yes");
	l_no_button_el= f_sapir_get_element_by_id (window.document, "b_no");
	l_cancel_button_el= f_sapir_get_element_by_id (window.document, "b_cancel");

	l_yes_button_el.disabled = true;
	l_no_button_el.disabled = true;
	l_cancel_button_el.disabled = true;
	
	l_form = f_sapir_form_get_by_name ("form1");
	//l_form = f_sapir_get_element_by_id (window.document, "form1");
	
	l_param_el = f_sapir_get_element_by_id (l_form, "param");
	l_param_value = l_param_el.value;

	if (a_remove == "remove") {
		l_param_value = f_sapir_param_set_key (l_param_value, "remove_item", "y");
	} else {
		l_param_value = f_sapir_param_set_key (l_param_value, "remove_item", "n");
	}

	l_param_el.value = l_param_value;

	l_form.submit ();
}

function f_sapir_basket_download_response_init (a_dialogArguments) {
	/*
	//f_sapir_log ("f_sapir_basket_download_response_init", "", 3);
	if (typeof (a_dialogArguments) != "undefined") {
		window.opener = a_dialogArguments;
	} else {

	}
	//window.opener.f_sapir_log ("f_sapir_basket_download_response_init", "", 3);
	*/
}

function f_sapir_rte_trace (a_event, a_msg) {
	// trace element should be in the page :
	// <div id="rte_trace" style="direction:ltr; float:left; height:100px; width:300px; overflow-y:scroll; background-color:cyan;"></div>
	var l_trace_el;
	
	l_trace_el = f_sapir_get_element_by_id (window.document, "rte_trace");
	if (!f_sapir_exists (l_trace_el)) {
		return;
	}
	
	if (g_sapir_trace_counter == 0) {
		l_trace_el.innerHTML = "";
	}
	
	g_sapir_trace_counter += 1;
	
	l_trace_el.innerHTML = l_trace_el.innerHTML + new String (g_sapir_trace_counter) + ". " + a_event + " : " + a_msg + "<br/>";	
}

function f_sapir_rte_toolbar_img_create (a_rte_el, a_tr_el, a_img_id, a_img_src, a_img_alt, a_rte_command, a_width, a_height, a_class, a_onclick) {
	var l_td, l_img
	l_td = document.createElement ("TD");
	l_img = document.createElement ("IMG");
	
	if (a_img_id != "") {
		l_img.setAttribute ("id", a_img_id);
	}
	
	l_img.setAttribute ("class", a_class);
	l_img.setAttribute ("src", a_img_src);
	l_img.setAttribute ("width", a_width);
	l_img.setAttribute ("height", a_height);
	l_img.setAttribute ("alt", a_img_alt);
	l_img.setAttribute ("title", a_img_alt);
	
	if (a_rte_command != "") {
		f_sapir_event_add (l_img, "click", new Function ("rteCommand(\'" + a_rte_el + "\', \'" + a_rte_command + "\', \'\')"));
		
		//l_img.setAttribute ("onClick", "rteCommand(\'" + a_rte_el + "\', \'" + a_rte_command + "\', \'\')");
		//f_sapir_alert (l_img.getAttribute ("onClick"));
	} else if (a_onclick != "") {
		f_sapir_event_add (l_img, "click", new Function (a_onclick));
	}
	
	l_td.appendChild (l_img);
	a_tr_el.appendChild (l_td);
}

function f_sapir_scroller_please_wait (a_el, a_scroller_top, a_scroller_left, a_scrollbar_parent_el) {
	f_sapir_please_wait_popup (true, a_el, "", a_scrollbar_parent_el, false, "scroller_please_wait");

	/*
	var l_popup_features, l_popup_ref, l_popup_width, l_popup_height, l_popup_left, l_popup_top;
	
	l_popup_width = 300;
	l_popup_height = 20;
	
	l_popup_top = (screen.availHeight - l_popup_height) / 2;
	l_popup_left = (screen.availWidth - l_popup_width) / 2;
	
	//l_popup_top = (a_scroller_top - l_popup_height) / 2;
	//l_popup_left = (a_scroller_left - l_popup_width) / 2;
	
	l_popup_features = "width=" + new String (l_popup_width)
							+ ",height=" + new String (l_popup_height)
							+ ",top=" + new String (l_popup_top)
							+ ",left=" + new String (l_popup_left)
							// + ",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'";
							+ ",toolbar=0"
							+ ",location=0"
							+ ",menubar=0";
							+ ",directories=0"
							+ ",statusbar=0"
							+ ",scrollbars=0"
							+ ",resizable=0";
							//		,modal=no"
	l_popup_ref = window.open ("scroller_please_wait.htm", "", l_popup_features);
	//l_popup_ref.document.body.style.margin = '0'; 
	//window.focus ();
	
	return l_popup_ref;
	*/
}

function f_sapir_scroller_please_wait_close () {
	f_sapir_please_wait_popup (false, null, "", null, true, "scroller_please_wait_close");
	//if (typeof (l_scroller_parent.g_sapir_scroller_please_wait_popup) == "object") {
}

function f_sapir_popup (a_url, a_title, a_features, a_exclusive) {
	//f_sapir_alert ("f_sapir_popup (" + a_url + ", " + a_title + ", " + a_features + ")");
	var popup_exception, l_exclusive;
	try {	
	var l_url, l_title, l_features;

	if (typeof (a_exclusive) == "undefined") {
		l_exclusive = true;
	} else {
		l_exclusive = a_exclusive;
	}
	
	if (l_exclusive == true) {
		//if (g_sapir_browser_is_ie == false) {	
			if (g_sapir_popup_ref != null) {
				if (g_sapir_popup_ref.closed == false) {
					//alert ("a popup is already opened - please close it first...");
					if (g_sapir_browser_is_ie == false) {
						g_sapir_popup_ref.focus ();
					}
					return false;
				}
				g_sapir_popup_ref = null;
			}
		//}
	}
	
	if (typeof (a_url) == "undefined") {
		l_url = "";
	} else {
		l_url = a_url;
	}
	if (typeof (a_title) == "undefined") {
		l_title = "";
	} else {
		l_title = a_title;
	}
	if (typeof (a_features) == "undefined") {
		l_features = "";
	} else {
		l_features = a_features;
	}
	g_sapir_popup_ref = window.open (l_url, "_blank", l_features, false);
	return true;
	
	} catch (popup_exception) {
		//debugger;
		f_sapir_exception ("sapirjsfile", "popup", popup_exception);
	}	
}

function f_sapir_ie_modal (a_url, a_args, a_features) {
	var ie_modal_exception;
	try {
	
	var l_url, l_args, l_features;

	/*
	if (g_sapir_popup_ref != null) {
		if (g_sapir_popup_ref.closed == false) {
			f_sapir_alert ("a popup is already opened - please close it first...");
			if (g_sapir_browser_is_ie == false) {
				g_sapir_popup_ref.focus ();
			}
			return false;
		}
		g_sapir_popup_ref = null;
	}
	*/
	
	if (typeof (a_url) == "undefined") {
		l_url = "";
	} else {
		l_url = a_url;
	}
	if (typeof (a_args) == "undefined") {
		l_args = "";
	} else {
		l_args = a_args;
	}
	if (typeof (a_features) == "undefined") {
		l_features = "";
	} else {
		l_features = a_features;
	}
	showModalDialog (l_url, l_args, l_features);
	return true;
	
	} catch (ie_modal_exception) {
		//debugger;
		f_sapir_exception ("sapirjsfile", "ie_modal", ie_modal_exception);
	}	
}

function f_sapir_popup_closed () {
	var popup_closed_exception;
	try {
	if (typeof (g_sapir_scroller_props) != "undefined") {
		g_sapir_scroller_props	= null;
	}
	if (typeof (g_sapir_cat_from_scroller_props) != "undefined") {
		g_sapir_cat_from_scroller_props	= null;
	}
	if (typeof (g_sapir_media_scroller_props) != "undefined") {
		g_sapir_media_scroller_props	= null;
	}
	if (typeof (g_sapir_media_upload_props) != "undefined") {
		g_sapir_media_upload_props	= null;
	}
	if (typeof (g_sapir_field_insert_props) != "undefined") {
		g_sapir_field_insert_props	= null;
	}
	if (typeof (g_sapir_field_trans_props) != "undefined") {
		g_sapir_field_trans_props	= null;
	}
	if (typeof (g_sapir_item_delete_props) != "undefined") {
		g_sapir_item_delete_props	= null;
	}
	} catch (popup_closed_exception) {
		//debugger;
		f_sapir_exception ("sapirjsfile", "popup_closed", popup_closed_exception);
	}
	g_sapir_popup_ref = null;
}

function f_sapir_input_keypress (aEvent) {
	var l_Event = aEvent ? aEvent : window.event;  
  var keycode = l_Event.keyCode;   
  var realkey = String.fromCharCode(l_Event.keyCode);
	
	// enter => new line (only at end of value is supported)
  if (keycode==13) {
		var l_val;
		l_val = f_sapir_event_element (l_Event).value;
		l_val += "<BR>";
		//l_val = f_sapir_slashes (l_val);
		f_sapir_event_element (l_Event).value = l_val;
		f_sapir_event_cancel (l_Event);		
  }
}

function f_sapir_page_title () {
	var l_title_is_set = false;
	/*
	if (g_sapir_cat_ui_active == false) {
		return;
	}
	// set title for cataloging a new item only. otherwise title is already set
	var l_set_title, l_page_title, l_scroller_field_descr;
	
	l_scroller_field_descr = "";
	l_set_title = false;
	
	if (g_sapir_form.cat_mode == "scroller") {
		l_scroller_field_descr = g_sapir_form.scroller_lif_descr + " : " ;
		l_set_title = true;
	}
	if (g_sapir_form.book_id == "") {
		l_page_title = g_sapir_dict.get_value ("gui_480");
		l_set_title = true;
	//} else {
	//	l_page_title = g_sapir_dict.get_value ("gui_6184") + " " + g_sapir_form.book_id;
	}
	*/
	
	l_set_title = true;
	if (l_set_title) {
		//l_page_title = l_scroller_field_descr + l_page_title;
		l_page_title = document.title;
		if (f_sapir_exists (parent)) {
				if (typeof (parent.g_sapir) != "undefined") {
					parent.document.title = l_page_title;
				}
		} else {
				document.title = l_page_title;
		}
	}
	/*
	if (g_sapir_cat_ui_active == true) {
		if (g_sapir_form.cat_mode == "scroller") {
			document.title += " (" + g_sapir_form.scroller_lif_descr + ")";
		}
	}
	*/
}
function f_sapir_register_from_login (a_url, a_event) {
	f_sapir_login_return ("$sapir_login$register$/sapir_login$", a_url);	
}

function f_sapir_split_page () {
	if (!f_sapir_exists (parent)) {
		return null;
	}
	if (parent.location.href == window.location.href) {
		return null;
	}
	if (typeof (parent.g_sapir) == "undefined") {
		return null;
	}
	if (!parent.f_sapir_is_implemented ("f_sapir_split_flag")) {
		return null;
	}
	return parent;
}

function f_sapir_feedback_popup () {
	var l_feedback_popup_title, l_feedback_popup_msg, l_feedback_popup_close, l_page_url_args, l_popup_top, l_popup_left, l_popup_width, l_popup_height;
	l_feedback_popup_title = escape (new String (g_sapir_feedback_popup_title));
	l_feedback_popup_msg = escape (new String (g_sapir_feedback_popup_msg));
	l_feedback_popup_close = escape (new String (g_sapir_feedback_popup_close));
	
	l_page_url_args = "?lang=" + g_sapir_lang + "&title=" + l_feedback_popup_title + "&msg=" + l_feedback_popup_msg + "&close=" + l_feedback_popup_close ;
	
	l_popup_width = 460;
	l_popup_height = 103;
	l_popup_top = (screen.availHeight - l_popup_height) / 2;
	l_popup_left = (screen.availWidth - l_popup_width) / 2;
	
	l_popup_open_ret = f_sapir_popup ("feedback_popup.asp" + l_page_url_args /*+ "?" + "ts=" + f_sapir_datetime_get ()*/, 
				"feedback_popup",
				"height=" + l_popup_height /* + g_sapir_measure_unit */
				+ ",width=" + l_popup_width /* + g_sapir_measure_unit */
				+ ",top=" + l_popup_top
				+ ",left=" + l_popup_left
				+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no"
				/*+ ",modal=yes"*/
				);
	if (l_popup_open_ret == true) {
		g_sapir_popup_ref.focus ();		
	}
}

function f_sapir_location_reload () {
	//debugger;
	f_sapir_please_wait_popup (true, null, "", null, true, "location_reload");
	//if (g_sapir_browser_type == "firefox") {
	//	window.document.reload ();
	//} else {
		window.location.reload ();
	//}	
}

function f_sapir_is_popup () {
	if (f_sapir_is_ie_modal ()) {
		return true;
	}
	if (window.parent) {
		if (window.parent.opener) {
			return true;
		}
	}
	return false;
}

function f_sapir_is_ie_modal () {
	if (g_sapir_browser_is_ie && typeof (dialogArguments) != "undefined") {
		return true;
	}
	return false;
}

function f_sapir_popup_opener () {
	if (f_sapir_is_ie_modal ()) {
		return window.dialogArguments;
	}
	if (typeof (window.parent.opener != "undefined")) {
		return window.parent.opener;
	}
	return window.opener;
}

function f_sapir_browser_type () {
	var l_navigator_appname, l_browser_type, l_msie_pos, l_msie_ver_pos, l_msie_subver_dot_pos;

	l_navigator_appname = new String (navigator.userAgent);
	l_navigator_appname = l_navigator_appname.toLowerCase ();

	g_sapir_browser_is_ie = false;
	l_msie_pos = l_navigator_appname.indexOf ("msie");
	if (l_msie_pos >= 0) 	{
		g_sapir_browser_type = "ie";
		g_sapir_browser_is_ie = true;

		// ie : get version
		l_msie_ver_pos = l_msie_pos + new String ("msie ").length;
		l_msie_subver_dot_pos = l_navigator_appname.indexOf (".", l_msie_ver_pos);
		g_sapir_ie_ver = new Number (l_navigator_appname.substring (l_msie_ver_pos, l_msie_subver_dot_pos));
	} else if (l_navigator_appname.indexOf ("firefox") >= 0)	{
		g_sapir_browser_type = "firefox";
	} else if (l_navigator_appname.indexOf ("chrome") >= 0) {
		g_sapir_browser_type = "chrome";
	} else {
		g_sapir_browser_type = "";
	}
	return g_sapir_browser_type;
}
f_sapir_browser_type ();

function f_sapir_cat_split_nob () {
	var l_nob;
	l_nob = new Number (f_sapir_param_get_key (g_cat_split_param, "nob"));
	return l_nob;
}
function f_sapir_cat_iframe_nob () {
	var l_nob;
	l_nob = new Number (f_sapir_param_get_key (g_cat_iframe_param, "nob"));
	return l_nob;
}
function f_sapir_cat_iframe_set_param (a_param) {
	if (!f_sapir_is_empty (g_cat_iframe_param)) {
		return;
	}
	g_cat_iframe_param = a_param;	
}
function f_sapir_cat_iframe_set_referer_url (a_referer_url) {
	if (!f_sapir_is_empty (g_cat_iframe_referer_url)) {
		return;
	}
	g_cat_iframe_referer_url = a_referer_url;
	//f_sapir_alert ("split.g_cat_iframe_referer_url = " + g_cat_iframe_referer_url);
}

function f_sapir_cat_split_close () {
	var l_xml_open_decode, l_xml_close_decode, l_open_regexp, l_close_regexp, l_referer_url, l_cnob;
	l_xml_open_decode = "~@";
	l_xml_close_decode = "@~";
	l_open_regexp = new RegExp (l_xml_open_decode, "gi");
	l_close_regexp = new RegExp (l_xml_close_decode, "gi");
	
	var l_referer_url = new String (g_cat_iframe_referer_url);
	l_referer_url = l_referer_url.replace (l_open_regexp, "<");
	l_referer_url = l_referer_url.replace (l_close_regexp, ">");

	l_cnob = new Number (f_sapir_cat_iframe_nob ()) /*- 1*/;
	
	l_referer_url = f_sapir_url_param_set_key (l_referer_url,"cnob", new String (l_cnob));
	//f_sapir_alert (l_referer_url);
	
	f_sapir_location_replace (l_referer_url);
}

function sideMenu(show_text, hide_text) {
  var sideMenu = $('.sideMenu');
  var menuColumn = $('.menuColumn');
  var sideNavContainer = $('#sideNavContainer');
	var l_menu_state = "";
	var l_stateman_args = "";
	
	if ($(sideMenu).hasClass("sideMenuShow")) {
  //if ($(sideNavContainer).is(":hidden")) {
		$(sideMenu).removeClass('sideMenuShow');
		$(sideMenu).text(hide_text);
		$(sideNavContainer).show();
		$(menuColumn).removeClass('menuColumnHide');
		l_menu_state = "show";
	} else {
		$(sideMenu).addClass('sideMenuShow');
		$(sideMenu).text(show_text);
		$(sideNavContainer).hide();
		$(menuColumn).addClass('menuColumnHide');
		l_menu_state = "hide";
	}
	if (f_sapir_exists (g_sapir_stateman_iframe_el)) {
		l_stateman_args = "key=sidemenu&value=" + l_menu_state;
		g_sapir_stateman_iframe_el.src = "stateman.asp?" + l_stateman_args;
		//g_sapir_stateman_iframe_el.location.replace ("stateman.asp?" + l_stateman_args);		
	}
}

function f_sapir_url_parse (a_url, a_map /*a_keys_ret, a_values_ret*/) {
	var query = a_url; 
	var pairs = query.split("&");

	for (var i=0;i<pairs.length;i++) { 
		var pos = pairs[i].indexOf('='); 
		if (pos >= 0) { 
			var argname = pairs[i].substring(0,pos); 
			var value = pairs[i].substring(pos+1); 
			
			a_map.keys [a_map.keys.length] = argname;
			a_map.values [a_map.values.length] = value;
			//a_keys_ret[a_keys_ret.length] = argname; 
			//a_values_ret[a_values_ret.length] = value; 
		} 
	} 
}

function f_sapir_trace_init () {
	f_sapir_alert ("f_sapir_trace_init");
	
	g_sapir_trace_win = window.open ("sapir_log.htm", 
		"",
		"height=500"
		+ ",width=200"
		+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
		);
}

function f_sapir_trace (a_event, a_msg) {
return;
	if (f_sapir_is_empty (g_sapir_trace_win)) {		
		return;
	}
	g_sapir_trace_win.f_trace (a_event, a_msg)
}

function f_sapir_trace_closed () {
	g_sapir_trace_win = null;
}

function f_sapir_trace_reset () {
	if (f_sapir_is_empty (g_sapir_trace_win)) {
		//f_sapir_alert ("popup closed");
		return;
	}
	g_sapir_trace_win.f_trace_ui_clear ();
}

function f_sapir_re_login () {
	g_sapir_re_login_timeout_id = window.setTimeout ("f_sapir_re_login_post ()", 500);
}
function f_sapir_re_login_post () {	
	if (g_sapir_re_login_timeout_id != null) {	
		//f_sapir_alert ("clearing");
		clearTimeout (g_sapir_re_login_timeout_id);
		g_sapir_re_login_timeout_id = null;
	}

	if (typeof (g_sapir_popup_login) != "undefined") {
		f_sapir_please_wait_popup (true, null, "", null, true, "f_sapir_re_login");
	}
	
	//f_sapir_alert ("f_sapir_re_login_post");
	
	/*
	if (!g_sapir_cat_ui_active) {
		f_sapir_alert ("f_sapir_re_login_post : error - not cataloging page");
		return;
	}
	*/
	
	var l_htmldw_submitform, l_site, l_lang, l_dlang, l_rsvr, l_module, l_page, l_param, l_param2, l_url;
	if (!g_sapir_cat_ui_active) {
		l_htmldw_submitform = f_sapir_form_get_by_name ("htmldw_submitForm");
	} else {
		l_htmldw_submitform = g_sapir_form.submit_form;
	}
	if (f_sapir_exists (l_htmldw_submitform)) {
		l_site = new String (f_sapir_selflinkarg (l_htmldw_submitform, "site"));
		l_lang = new String (f_sapir_selflinkarg (l_htmldw_submitform, "lang"));
		//l_dlang = new String (f_sapir_selflinkarg (l_htmldw_submitform, "dlang"));
		l_rsvr = new String (f_sapir_selflinkarg (l_htmldw_submitform, "rsvr"));
		//l_module = new String (f_sapir_selflinkarg (l_htmldw_submitform, "module"));
		//l_page = new String (f_sapir_selflinkarg (l_htmldw_submitform, "page"));	
		l_param = new String (f_sapir_selflinkarg (l_htmldw_submitform, "param"));
		//l_param2 = new String (f_sapir_selflinkarg (l_htmldw_submitform, "param2"));
	} else {
		l_lang = g_sapir_lang;
		l_rsvr = g_sapir_re_login.rsvr;
		l_param = g_sapir_re_login.param;
		l_site = g_sapir_re_login.site;
	}

	/*
	l_lang = g_sapir_lang;
	l_rsvr = g_sapir_re_login.rsvr;
	l_param = g_sapir_re_login.param;
	l_site = g_sapir_re_login.site;
	*/
	
	//f_sapir_alert ("re_login : " + l_lang + ", " + l_rsvr + ", " + l_site + "\r\n" + l_param);
	f_sapir_login ('login_check', l_lang, '','', l_rsvr, l_param, '', '', l_site);
	
	/*
	f_sapir_login ('login','HEB','security','login','2','<dispq> </dispq><uppernav>simple</uppernav><logged_in>y</logged_in><view></view><nob>0</nob><rsvr_ser@<@1@@2@@4@@all@@AR_LEV@@AR_STORGE@@AR_ADMIN</rsvr_ser><query_name>idea-yairl_5416_311015</query_name><start_entry>1</start_entry><dlang>HEB</dlang><rsort></rsort><quantity>15</quantity><num_of_items>0</num_of_items><query_index></query_index><reader_id>6</reader_id><thumb>0</thumb><sort></sort><smode>dts</smode><book_id>8</book_id><last_item>1</last_item><cnob>0</cnob><rsvr_ser>@@2</rsvr_ser>','','','devg_local');}
	*/
	
}

function f_sapir_re_login_post_notinuse () {
	if (g_sapir_re_login_timeout_id != null) {	
		//f_sapir_alert ("clearing");
		clearTimeout (g_sapir_re_login_timeout_id);
		g_sapir_re_login_timeout_id = null;
	}

	//f_sapir_alert ("f_sapir_re_login_post");
	
	/*
	if (!g_sapir_cat_ui_active) {
		f_sapir_alert ("f_sapir_re_login_post : error - not cataloging page");
		return;
	}
	*/
	
	var l_htmldw_submitform, l_site, l_lang, l_dlang, l_rsvr, l_module, l_page, l_param, l_param2, l_url;
	
	/*
	if (!g_sapir_cat_ui_active) {
		l_htmldw_submitform = f_sapir_form_get_by_name ("htmldw_submitForm");
	} else {
		l_htmldw_submitform = g_sapir_form.submit_form;
	}
	if (f_sapir_exists (l_htmldw_submitform)) {
		l_site = new String (f_sapir_selflinkarg (l_htmldw_submitform, "site"));
		l_lang = new String (f_sapir_selflinkarg (l_htmldw_submitform, "lang"));
		//l_dlang = new String (f_sapir_selflinkarg (l_htmldw_submitform, "dlang"));
		l_rsvr = new String (f_sapir_selflinkarg (l_htmldw_submitform, "rsvr"));
		//l_module = new String (f_sapir_selflinkarg (l_htmldw_submitform, "module"));
		//l_page = new String (f_sapir_selflinkarg (l_htmldw_submitform, "page"));	
		l_param = new String (f_sapir_selflinkarg (l_htmldw_submitform, "param"));
		//l_param2 = new String (f_sapir_selflinkarg (l_htmldw_submitform, "param2"));
	} else {
		l_lang = g_sapir_lang;
		l_rsvr = g_sapir_re_login.rsvr;
		l_param = g_sapir_re_login.param;
		l_site = g_sapir_re_login.site;
	}
	*/

	l_lang = g_sapir_lang;
	l_rsvr = g_sapir_re_login.rsvr;
	l_param = g_sapir_re_login.param;
	l_site = g_sapir_re_login.site;
	f_sapir_alert ("re_login : " + l_lang + ", " + l_rsvr + ", " + l_site + "\r\n" + l_param);
	f_sapir_login ('login', l_lang, '','', l_rsvr, l_param, '', '', l_site);
	
	/*
	f_sapir_login ('login','HEB','security','login','2','<dispq> </dispq><uppernav>simple</uppernav><logged_in>y</logged_in><view></view><nob>0</nob><rsvr_ser@<@1@@2@@4@@all@@AR_LEV@@AR_STORGE@@AR_ADMIN</rsvr_ser><query_name>idea-yairl_5416_311015</query_name><start_entry>1</start_entry><dlang>HEB</dlang><rsort></rsort><quantity>15</quantity><num_of_items>0</num_of_items><query_index></query_index><reader_id>6</reader_id><thumb>0</thumb><sort></sort><smode>dts</smode><book_id>8</book_id><last_item>1</last_item><cnob>0</cnob><rsvr_ser>@@2</rsvr_ser>','','','devg_local');}
	*/
	
}

function sapir_re_login (a_rsvr, a_param, a_site) {
	if (a_rsvr) {
		this.rsvr = a_rsvr;
	}
	if (a_param) {
		this.param = a_param;
	}
	if (a_site) {
		this.site = a_site;
	}
}

function f_sapir_struct_change (a_new_struct) {
	var l_newrl;
	l_newrl = f_sapir_url_param_set_key (g_sapir_url,"struct_id", a_new_struct); 
	f_sapir_location_replace (l_newrl);
	return false;
}

function f_sapir_actions_combo_get_height (a_el) {
	var l_anchors, l_anchor_count, l_height;
	l_height = 0;
	l_anchors = a_el.getElementsByTagName ("A");
	l_anchor_count = l_anchors.length;
	for (var i = 0; i < l_anchor_count; i++) {
		if (f_sapir_class_find (l_anchors [i], "sapir_invisible")) {
			//f_sapir_alert ("option " + i + " is hidden");
			continue;
		}
		l_height += 16;
		//f_sapir_alert ("option " + i + " is visible : " + l_height);
	}
	//l_height += 10;
	return l_height;
}

function f_sapir_reader_update (a_reader_id, a_module, a_page, a_lang, a_dlang, a_site, a_extra_param) {
	//g_sapir_reader_update_timeout_id = window.setTimeout ("f_sapir_reader_update_post ()", 500);
	var l_reader_update_url, l_args_delimiter, l_page_base_args, l_page_url_args, l_lang, l_site;
	var l_popup_open_ret = false;
	
	l_args_delimiter = "";
	l_page_base_args = "";
	l_page_url_args = "";

	l_lang = a_lang;
	if (!f_sapir_is_empty (l_lang)) {
		l_page_base_args = l_page_base_args + l_args_delimiter + "lang=" + l_lang;
		l_args_delimiter = "&";
	}

	l_site = a_site;
	if (!f_sapir_is_empty (l_site)) {
		l_site = l_site.replace(/&lt;/g, "<");
		l_site = l_site.replace(/&gt;/g, ">");
		l_page_base_args = l_page_base_args + l_args_delimiter + "site=" + l_site;
		l_args_delimiter = "&";
	}
	
	l_page_url_args = l_page_base_args;

	if (!f_sapir_is_empty (a_module)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "module=" + a_module 
		l_args_delimiter = "&";
	}
	
	if (!f_sapir_is_empty (a_page)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "page=" + a_page
		l_args_delimiter = "&";
	}
	
	if (!f_sapir_is_empty (a_extra_param)) {
		l_page_url_args = l_page_url_args + l_args_delimiter + "param=" + a_extra_param
		l_args_delimiter = "&";
	}
	
	if (!f_sapir_is_empty (l_page_url_args)) {
		l_page_url_args = "?" + l_page_url_args;
	}
	
	l_reader_update_url = "cat_form.asp" + l_page_url_args
	//alert (l_reader_update_url);	
	
	f_sapir_please_wait_popup (true, null, "", null, true, "f_sapir_reader_update");
	g_sapir_reader_update_props = null;
	g_sapir_reader_update_props	= new sapir_reader_update_props ();
	l_popup_open_ret = f_sapir_popup (l_reader_update_url, 
			"reader update",
			"height=550"
			+ ",width=750" 
		+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
	
		);
		if (l_popup_open_ret == true) {
			g_sapir_popup_ref.focus ();
		}
}

/*function f_sapir_reader_update_post () {	
	if (g_sapir_reader_update_timeout_id != null) {	
			clearTimeout (g_sapir_reader_update_timeout_id);
			g_sapir_reader_update_timeout_id = null;
	}

	var l_reader_update_url = "";
	var l_popup_open_ret = false;
	f_sapir_please_wait_popup (true, null, "", null, true, "f_sapir_reader_update");
	g_sapir_reader_update_props = null;
	g_sapir_reader_update_props	= new sapir_reader_update_props ();
	l_popup_open_ret = f_sapir_popup (l_reader_update_url, 
			"reader update",
			"height=550"
			+ ",width=750" 
		+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
	
		);
		if (l_popup_open_ret == true) {
			g_sapir_popup_ref.focus ();
		}
}
*/
function f_sapir_reader_reg () {
	// wait until login dialog itself is closed
	g_sapir_reader_reg_timeout_id = window.setTimeout ("f_sapir_reader_reg_post ()", 500);
}

function f_sapir_reader_reg_post () {	
	if (g_sapir_reader_reg_timeout_id != null) {	
			clearTimeout (g_sapir_reader_reg_timeout_id);
			g_sapir_reader_reg_timeout_id = null;
	}

	if (g_sapir_popup_ref != null) {
		g_sapir_reader_reg_timeout_id = window.setTimeout ("f_sapir_reader_reg_post ()", 500);
		return;
	}
	var l_popup_open_ret = false;
	f_sapir_please_wait_popup (true, null, "", null, true, "f_sapir_reader_reg");
	g_sapir_reader_reg_props = null;
	g_sapir_reader_reg_props	= new sapir_reader_reg_props ();
	l_popup_open_ret = f_sapir_popup (g_sapir_login_register_url, 
			"reader registration",
			"height=620" /* + g_sapir_measure_unit */
			+ ",width=850" /* + g_sapir_measure_unit */
			+ ",toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes"
			/*+ ",modal=yes"*/
		);
		if (l_popup_open_ret == true) {
			g_sapir_popup_ref.focus ();
		}
}

function f_sapir_reader_reg_ok () {
	if (f_sapir_exists (g_sapir_popup_opener) && !g_sapir_popup_opener.closed) {
		g_sapir_popup_opener.f_sapir_reader_reg_back_to_opener ();
	}
	self.close();
}

function f_sapir_reader_reg_back_to_opener () {
		f_sapir_please_wait_popup (false, null, "", null, true, "reader_reg_back_to_opener");
		f_sapir_please_wait_popup (true, null, "", null, true, "reader_reg_back_to_opener");
		if (new String (window.location).indexOf (".asp?")  <= 0) {
			if (typeof (g_sapir_url) != "undefined") {
				//window.location.reload (true);
				f_sapir_location_replace (g_sapir_url);
				return;
			} else {
				f_sapir_location_reload ();
				return;
			}
		} else {
			//if (typeof (g_sapir_url) != "undefined") {
			//	f_sapir_location_replace (g_sapir_url);
			//	return;
			//} else {
				f_sapir_location_reload ();
				return;
			//}
			//return;
		}
}

function f_sapir_logged_user_state () {	
	var l_popup_opener, l_last_opener;
	
	//f_sapir_alert ("f_sapir_logged_user_state : " + g_sapir_logged_user_state);
	//alert ("f_sapir_logged_user_state : " + g_sapir_is_popup + "\r\n" + window.location.href);
	
	if (f_sapir_exists (g_sapir_popup_ref)) {
		if (/*g_sapir_browser_is_ie || */g_sapir_popup_ref.closed == false) {
			return null;
		}
	}

	if (g_sapir_is_popup == false) {
		return g_sapir_logged_user_state;
	}
	
	// popup : get info from root opener. 
	//			: search scroller : is an iframe, so must go to its parent
	if (window.location.href.indexOf ("/scroller.asp") >= 0) {
		l_popup_opener = window.parent.opener;	
	} else {
		l_popup_opener = g_sapir_popup_opener;
	}
	while (f_sapir_exists (l_popup_opener)) {
		l_last_opener = l_popup_opener;
		
		if (l_popup_opener.location.href.indexOf ("/scroller.asp") >= 0) {
			l_popup_opener = l_popup_opener.parent.opener;	
		} else {
			l_popup_opener = l_popup_opener.g_sapir_popup_opener;
		}	
	}
	return l_last_opener.g_sapir_logged_user_state;
}

function f_sapir_logged_user_state_debug () {	
	alert ("f_sapir_logged_user_state_debug");
	var l_popup_opener, l_last_opener;
	
	//f_sapir_alert ("f_sapir_logged_user_state : " + g_sapir_logged_user_state);
	//alert ("f_sapir_logged_user_state : " + g_sapir_is_popup + "\r\n" + window.location.href);
	
	if (f_sapir_exists (g_sapir_popup_ref)) {
		alert ("f_sapir_logged_user_state_debug : 2");
		if (/*g_sapir_browser_is_ie || */g_sapir_popup_ref.closed == false) {
			alert ("f_sapir_logged_user_state_debug : 3");
			return null;
		}
	}

	if (g_sapir_is_popup == false) {
		alert ("f_sapir_logged_user_state_debug : 4");
		return g_sapir_logged_user_state;
	}
	
	// popup : get info from root opener. 
	//			: search scroller : is an iframe, so must go to its parent
	if (window.location.href.indexOf ("/scroller.asp") >= 0) {
		l_popup_opener = window.parent.opener;	
	} else {
		l_popup_opener = g_sapir_popup_opener;
	}
	alert ("f_sapir_logged_user_state_debug : 5 = " + l_popup_opener.location.href);
	while (f_sapir_exists (l_popup_opener)) {
		l_last_opener = l_popup_opener;
		
		if (l_popup_opener.location.href.indexOf ("/scroller.asp") >= 0) {
			l_popup_opener = l_popup_opener.parent.opener;
		} else {
			l_popup_opener = l_popup_opener.g_sapir_popup_opener;
		}	
	}
	alert ("f_sapir_logged_user_state_debug : 6 = " + l_last_opener.location.href);
	return l_last_opener.g_sapir_logged_user_state;
}

function sapir_logged_user_state (a_logged_user_validation_interval) {
	this.logged_user_validation_interval = a_logged_user_validation_interval;
	// convert from sec to msec
	this.logged_user_validation_interval = new Number (this.logged_user_validation_interval) * 1000;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from sapir_gen.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var g_sapir_measure_unit = "px";
var g_sapir_post_f5_frame_level_timeout_id = null;
var g_sapir_date_delimiter = "/";
var g_sapir_key_not_found = "$sapir_not_found$";
var g_sapir_info_delimiter = "*^";

function expandcontent(curobj, cid){
	if (ccollect.length>0){
		document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
		curobj.src=(document.getElementById(cid).style.display=="none")? expandsymbol : contractsymbol
	}
}

function getElementbyClass(rootobj, classname){
	var temparray=new Array()
	var inc=0
	var rootlength=rootobj.length
	for (i=0; i<rootlength; i++){
		if (rootobj[i].className==classname)
			temparray[inc++]=rootobj[i]
	}
	return temparray
}

//================================================================================================================================
// arrays indexOf
	//This prototype is provided by the Mozilla foundation and
	//is distributed under the MIT license.
	//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
	if (!Array.prototype.indexOf) {
		Array.prototype.indexOf = 
			function (elt /*, from*/)  {
			    var len = this.length;
				var from = Number(arguments[1]) || 0;
				from = (from < 0)
					? Math.ceil(from)         
					: Math.floor(from);
				if (from < 0) {
					from += len;
				}
				for (; from < len; from++) {
					if (from in this && this[from] === elt) {
						return from;
					}
				}
				return -1;
			};
	}

function f_sapir_class_append (a_el, a_new_class) {
	a_el.className += " " + a_new_class;
}

function f_sapir_class_find (a_el, a_class) {
	//f_sapir_alert ("find : " + a_el.className + " : " + a_class);
	var l_class_string, l_class_begin_pos, l_class_end_pos, l_class_delimiter_pos;

	if (!f_sapir_exists (a_el)) {
		f_sapir_alert ("bad !" + a_class);
	}

	l_class_string = new String (a_el.className);

	l_class_begin_pos = l_class_string.indexOf (a_class);
	if (l_class_begin_pos < 0) {
		return false;
	}
	
	l_class_delimiter_pos = l_class_string.indexOf (" ", l_class_begin_pos);
	if (l_class_delimiter_pos > l_class_begin_pos) {
		if ((l_class_delimiter_pos - l_class_begin_pos - 1) == (a_class.length - 1)) {
			return true;
		} else {
			return false;
		}
	}
	l_class_end_pos = l_class_begin_pos + a_class.length - 1;
	if (l_class_end_pos < 0 || l_class_end_pos != (l_class_string.length - 1)) {
		return false;
	}
	
	return true;
}

function f_sapir_class_override (a_el, a_new_class) {
	a_el.className = a_new_class;
	return 1;
}

function f_sapir_class_prepend (a_el, a_new_class) {
	//return;
	//f_sapir_log ("f_sapir_class_prepend", a_el.id + "," + a_el.name, 3);
	f_sapir_class_remove (a_el, a_new_class) 
	a_el.className = a_new_class + " " + a_el.className;
}

function f_sapir_class_prepend_list (a_el_list, a_new_class) {
	var l_list_length, lidx;
	l_list_length = a_el_list.length;
	for (lidx = 0; lidx < l_list_length; lidx++) {
		f_sapir_class_prepend (a_el_list [lidx], a_new_class);
	}
}

function f_sapir_class_remove (a_el, a_remove_class) {	
	var l_class_string, l_remove_class_begin_pos, l_remove_class_end_pos, l_class_attrib_end_pos;

	if (!f_sapir_class_find (a_el, a_remove_class)) {
		return;
	}

	l_class_string = new String (a_el.className);
	l_remove_class_begin_pos = l_class_string.indexOf (a_remove_class);
	l_remove_class_end_pos = l_class_string.indexOf (" ", l_remove_class_begin_pos);
	l_class_attrib_end_pos = l_class_string.length - 1; /*l_class_string.indexOf ("\"", l_remove_class_begin_pos); */
	if (l_remove_class_end_pos == -1) {
		l_remove_class_end_pos = l_class_attrib_end_pos;
	} else if (l_class_attrib_end_pos > -1) {
		l_remove_class_end_pos = Math.min (l_remove_class_end_pos, l_class_attrib_end_pos);
	}
	a_el.className = l_class_string.substring (0, l_remove_class_begin_pos)
					+ " " + l_class_string.substring (l_remove_class_end_pos + 1);
}

function f_sapir_class_remove_list (a_el_list, a_new_class) {
	var l_list_length, lidx;
	l_list_length = a_el_list.length;
	for (lidx = 0; lidx < l_list_length; lidx++) {
		f_sapir_class_remove (a_el_list [lidx], a_new_class);
	}
}

function f_sapir_class_replace (a_el, a_old_class, a_new_class) {
	var l_class_string, l_old_class_begin_pos, l_old_class_end_pos, l_class_delimiter_pos;
	
	if (!f_sapir_class_find (a_el, a_old_class)) {
		a_el.className += " " + a_new_class;
		return 1;
	}

	l_class_string = new String (a_el.className);
	l_old_class_begin_pos = l_class_string.indexOf (a_old_class);
	
	if (l_old_class_begin_pos < 0) {
		a_el.className += " " + a_new_class;
		return 1;
	} 

	l_class_delimiter_pos = l_class_string.indexOf (" ", l_old_class_begin_pos);
	if (l_class_delimiter_pos > l_old_class_begin_pos) {
		l_old_class_end_pos = l_class_delimiter_pos - 1;
	} else {
		l_old_class_end_pos = l_old_class_begin_pos + a_old_class.length - 1;
	}

	if (l_old_class_end_pos < 0) {
		return -1;
	}
	
	a_el.className =	 l_class_string.substring (0, l_old_class_begin_pos)
								+ a_new_class + " " + l_class_string.substring (l_old_class_end_pos + 1);
	return 1;
}

function f_sapir_datetime_get () {
	var now, hours, minutes, seconds, timeValue;
	now = new Date();
	hours = now.getHours();
	minutes = now.getMinutes();
	seconds = now.getSeconds();
	timeValue = now + " " + ((hours >12) ? hours -12 :hours);
	if (timeValue == "0") {
		timeValue = 12;
	}
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	timeValue += ((seconds < 10) ? ":0" : ":") + seconds
	//timeValue += (hours >= 12) ? " P.M." : " A.M."
	return timeValue;
}

function f_sapir_date_validate (a_date, a_complete, a_date_format, a_year_min, a_year_max) {
	return true;
	
	/*
	var l_date, l_pattern;
	l_date = new String (a_date);
	l_pattern = new RegExp ("/^\d{1,2}(\-|\/|\.)\d{1,2}\1(\d{2}|\d{4})$/");
	f_sapir_alert (l_date + " = " + l_pattern.test (l_date));
	*/

	var strDay, strMonth, strYear, l_date, l_complete;
	
	if (!f_sapir_is_empty (a_complete)) {
		l_complete = a_complete;
	} else {
		l_complete = false;
	}
	
	if (a_date == "") {
		return true;
	}
	
	l_date = a_date.replace (/_/g, "0");
	
	var daysInMonth = f_sapir_days_array (12);
	var pos1 = l_date.indexOf (g_sapir_date_delimiter);
	var pos2 = l_date.indexOf (g_sapir_date_delimiter, pos1 + 1);
	
	if (a_date_format == "dd/mm/yyyy") {
		strDay = l_date.substring (0, pos1);
		strMonth = l_date.substring (pos1 + 1, pos2);
	} else {
		// mm/dd/yyyy
		strMonth = l_date.substring (0, pos1);
		strDay = l_date.substring (pos1 + 1, pos2);
	}
	strYear = l_date.substring (pos2 + 1);
	
	strYr = strYear;
	if (strDay.charAt (0) =="0" && strDay.length > 1) {
		strDay = strDay.substring (1);
	}
	if (strMonth.charAt (0)=="0" && strMonth.length>1) {
		strMonth = strMonth.substring (1);
	}
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) {
			strYr = strYr.substring(1);
		}
	}
	month = parseInt (strMonth);
	day = parseInt (strDay);
	year = parseInt (strYr);
	
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy");
		f_sapir_log ("f_sapir_date_validate", "The date format should be : mm/dd/yyyy", 3);
		return false;
	}
	if (strMonth.length < 1 || (l_complete && month < 1) || month > 12) {
		//f_sapir_alert ("Please enter a valid month");
		f_sapir_log ("f_sapir_date_validate", "error : invalid month", 3);
		return false;
	}
	if (strDay.length < 1 || (l_complete && day < 1) || day > 31 
		|| (month == 2 && day > f_sapir_days_in_february (year)) || day > daysInMonth [month]) {
		//f_sapir_alert ("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || (l_complete && year == 0) || year < a_year_min || year > a_year_max) {
		//f_sapir_alert ("Please enter a valid 4 digit year between " + g_sapir_year_min + " and " + g_sapir_year_max);
		return false;
	}
	if (l_date.indexOf (g_sapir_date_delimiter, pos2+1) != -1 
		|| f_sapir_is_integer (f_sapir_strip_chars_in_bag (l_date, g_sapir_date_delimiter)) == false) {
		//f_sapir_alert ("Please enter a valid date");
		return false;
	}
	return true;
}
function f_sapir_decode_text (a_text) {
	var l_decoded_text;
	l_decoded_text = a_text;
	l_decoded_text = l_decoded_text.replace(/&#34;/g, "\"");
	l_decoded_text = l_decoded_text.replace(/&#39;/g, "\'");
	l_decoded_text = l_decoded_text.replace(/&#39;/g, "\'");
	l_decoded_text = l_decoded_text.replace(/&#47;/g, "\/");
	l_decoded_text = l_decoded_text.replace(/&#92;/g, "\\");
	l_decoded_text = l_decoded_text.replace(/&#60;/g, "<");
	l_decoded_text = l_decoded_text.replace(/&#62;/g, ">");
	l_decoded_text = l_decoded_text.replace(/&#38;/g, "&"); //  must be last !!!
	return l_decoded_text;
}

/*
function f_sapir_js_load (a_js_file) {
	var script, head, scriptTag, l_scrips_count;
	
	
	head = document.getElementsByTagName ("head").item (0);
	scriptTag = document.getElementById ("script_" + a_js_file);
	if (scriptTag) {
		//head.removeChild (scriptTag);
		return;
	}
	script = document.createElement ("script");
	//script.setAttribute ("defer", "defer");
	script.setAttribute ("src", a_js_file);
	script.setAttribute ("type", "javaScript");
	script.setAttribute ("id", "script_" + a_js_file);
	l_script_count = g_sapir_scripts.length;
	g_sapir_scripts [l_script_count] = new sapir_script (a_js_file, script);
	script.onreadystatechange = function (l_script_count) { 
		//if (script.readyState == 'complete') {
			g_sapir_scripts [l_script_count].readyState = script.readyState;
			if (g_sapir_scripts [l_script_count].readyState == 'complete') {
			}
	}
	
	//script.onload = function() { alert("file " + a_js_file + " loaded!") }; 
	head.appendChild (script);
}
*/
/*
function addCSSClass (elem, className) { 
	removeClassName (elem, className); 
	elem.className = (elem.className + " " + className).trim(); 
}
*/

function f_sapir_exists (a_object) {
	var l_typeof, l_ret;
	l_typeof = typeof (a_object);
	
	switch (l_typeof) {
		case "object":
			l_ret = true;
			break;

		case "undefined":
			l_ret = false;
			break;
			
		case "function":
			l_ret = true;
			break;
			
		default:
			l_ret = false;
	}
	
	if (l_ret) {
		if (a_object == null) {
			l_ret = false;
		}
	}
	
	return l_ret;
}

function f_sapir_el_get_document (a_el) {
	var bDocFound, oRequestor, oParent, bHasParent, oLocatedFrame;

	bDocFound = false;
	oRequestor = a_el;
	bHasParent = true;
	oLocatedFrame = null;

	while (bHasParent == true && oRequestor != null && bDocFound == false) {
		if (oRequestor.parent) {
			oParent = oRequestor.parent;
		} else {
			oParent = oRequestor.parentElement;
		}
		//f_sapir_alert ("oParent = " + oParent);
		if (f_sapir_exists (oParent)) {
			//f_sapir_alert (oParent.nodeType);
			if (oParent.nodeType) {
				if (oParent.nodeType == "9") {
					bDocFound = true;						
				}
			}
		} else {
			bHasParent = false;
		}
		oRequestor = oParent;
	}
	if (bDocFound == true) {
		return oRequestor;
	}
}

function f_sapir_event (a_event) {
	if (window.event) {
		return window.event;
	} else {
		return a_event;
	}
	return null;
}

function f_sapir_event_cancel (a_event) {
	a_event || (a_event = window.event);
	
	if (a_event == null) {
		return false;
	}	
	if (a_event.preventDefault) {
		a_event.preventDefault ();
	}	
	if (a_event.stopPropagation) {
		a_event.stopPropagation ();
	}	
	a_event.cancelBubble = true;
	a_event.returnValue = false;	
	
	return false;
}

function f_sapir_event_element (e) {
	/*
	var e=e || window.event;
	return e.target || e.srcElement;
	*/

	if (window.event) {
		return window.event.srcElement;
	}
	if (e.target) {
		// FireFox condition ?
		return e.target;
	}
	if (e.currentTarget) {
		return e.currentTarget;
	}
	return null;
}

function f_sapir_event_key_code (a_event) {
	if (window.event) {
		return window.event.keyCode;
	} else {
		return a_event.keyCode;
	}
	return null;
}

function f_sapir_event_parent_element (a_event) {
	if (window.event) {
		return window.event.srcElement.parentElement;
	} else {
		return a_event.target.parentNode;
	}
	return null;
}

function f_sapir_el_get_id (a_el) {
	var l_id, l_name;
	
	if (!f_sapir_exists (a_el)) {
		return "";
	}
	
	try {
		l_name = a_el.name;
	} catch (ex) {
	}

	try {
		l_id = a_el.id;
	} catch (ex) {
	}
	
	if (!f_sapir_is_empty (l_name)) {
		return l_name;
	}
	
	if (!f_sapir_is_empty (l_id)) {
		return l_id;
	}
	
	return "";
}

//String.prototype.trim = function() { 
//	return this.replace( /^\s+|\s+$/, "" ); 
//} 

function f_sapir_info_obj (a_sapir_info) {
	var l_sapir_info_string, l_sapir_info_obj, l_key_value, l_key_value_string, l_key, l_value;
	l_sapir_info_obj = new sapir_info_class ();

	l_sapir_info_string = new sapir_string_obj (a_sapir_info);
	l_key_value = f_sapir_get_token (l_sapir_info_string, g_sapir_info_delimiter);
	
	while (!f_sapir_is_empty (l_key_value) || l_sapir_info_string.value.length > 0) {
		if (f_sapir_is_empty (l_key_value)) {
			l_key_value = f_sapir_get_token (l_sapir_info_string, g_sapir_info_delimiter);
			continue;
		}
		l_key_value_string = new sapir_string_obj (l_key_value);
		l_key = f_sapir_get_token (l_key_value_string, "==");
		l_value = l_key_value_string.value;
		eval ("l_sapir_info_obj." + l_key + " = \"" + l_value + "\"");
		
		l_key_value = f_sapir_get_token (l_sapir_info_string, g_sapir_info_delimiter);
	}
	
	return l_sapir_info_obj;
}

function sapir_info_class () {
}

function f_sapir_info_get_key (a_sapir_info, a_key) {
	var l_sapir_info, l_key, l_key_pos, l_key_close_pos, l_value_pos, l_value;
	
	l_sapir_info = new String (a_sapir_info);
	l_key = g_sapir_info_delimiter + a_key + "==";
	l_key_pos = l_sapir_info.indexOf (l_key);
	if (l_key_pos < 0) {
		return g_sapir_key_not_found;
	}
	l_value_pos = l_key_pos + l_key.length;
	l_key_close_pos = l_sapir_info.indexOf (g_sapir_info_delimiter, l_value_pos);
	l_value = l_sapir_info.substring (l_value_pos, l_key_close_pos);
	return l_value;
}

function f_sapir_info_set_key (a_sapir_info, a_key, a_value) {
	var l_sapir_info, l_key, l_key_pos, l_key_close_pos, l_value_pos, l_value, l_current_value;
	
	l_sapir_info = new String (a_sapir_info);
	
	l_current_value = f_sapir_info_get_key (a_sapir_info, a_key);
	
	// append key
	if (l_current_value == g_sapir_key_not_found) {
		l_sapir_info = l_sapir_info + g_sapir_info_delimiter + a_key + "==" + a_value + g_sapir_info_delimiter;
		return l_sapir_info;
	}
	
	// replace key value	
	l_key = g_sapir_info_delimiter + a_key + "==";
	l_key_pos = l_sapir_info.indexOf (l_key);

	l_value_pos = l_key_pos + l_key.length;
	l_key_close_pos = l_sapir_info.indexOf (g_sapir_info_delimiter, l_value_pos);
	
	l_sapir_info = l_sapir_info.substring (0, l_value_pos) + a_value + l_sapir_info.substring (l_key_close_pos);
	
	return l_sapir_info;
}

function f_sapir_is_empty (a_string) {
var l_string;
	
	if (a_string == null) {
		return true;
	}
	if (a_string == undefined) {
		return true;
	}
	
	l_string = new String (a_string);
	if (l_string == "") {
		return true;
	}
	if (l_string == "null") {
		return true;
	}
	if (l_string == "undefined") {
		return true;
	}
	
	if (l_string == null || l_string == undefined || l_string == "") {
		return true;
	}
	return false;
}

function f_sapir_is_implemented (a_func_name) {
	var l_typeof = eval ('typeof ' + a_func_name);
	if (l_typeof == "function" || l_typeof == "object") {
		return true;
  }
	return false;    
}

function f_sapir_get_frame (a_frame_name, a_window) {
	var l_win;
	if (a_window) {
		l_win = a_window;
	} else {
		l_win = window;
	}

	if (l_win.document.frames) {
		return l_win.document.frames [a_frame_name];
	}
	if (l_win.document.getElementById) {
		return l_win.document.getElementById (a_frame_name);
	}
	if (l_win.document.all) {
		return l_win.document.all (a_frame_name);
	}
	return null;
}

function f_sapir_frame_window (a_frame) {
	if (!f_sapir_exists (a_frame)) {
		return null;
	}
	if (a_frame.contentWindow) {
		return a_frame.contentWindow;
	}
	return a_frame;
}

function f_sapir_frame_document (a_frame) {
	//f_sapir_alert ("f_sapir_frame_document : " + a_frame.location);
	if (typeof (a_frame) == "undefined") {
		//f_sapir_alert ("f_sapir_frame_document : 1");
		return null;
	}
	if (!f_sapir_exists (a_frame)) {
		//f_sapir_alert ("f_sapir_frame_document : 2");
		return null;
	}

	if (typeof (a_frame.document) != "undefined") {
		//f_sapir_alert ("f_sapir_frame_document : 3");
		if (f_sapir_exists (a_frame.document)) {
			return a_frame.document;
		}
		return null;
	}

	if (typeof (f_sapir_frame_window (a_frame).document) != "undefined") {
		//f_sapir_alert ("f_sapir_frame_document : 4");
		if (f_sapir_exists (f_sapir_frame_window (a_frame).document)) {
			return f_sapir_frame_window (a_frame).document;
		}
		return null;
	}
		
	if (f_sapir_exists (f_sapir_get_iframe_frame (a_frame))) {		
		return f_sapir_get_iframe_frame (a_frame);
	}
	
	if (typeof (a_frame.contentDocument) != "undefined") {
		//f_sapir_alert ("f_sapir_frame_document : 5");
		if (f_sapir_exists (a_frame.contentDocument)) {
			return a_frame.contentDocument;
		}
		return null;
	}
		
	if (typeof (a_frame.htmliframeelement) != "undefined") {
		//f_sapir_alert ("f_sapir_frame_document : 6");
		if (f_sapir_exists (a_frame.htmliframeelement)) {
			if (f_sapir_exists (a_frame.htmliframeelement.contentDocument)) {
				return a_frame.htmliframeelement.contentDocument;
			}
		}
		return null;
	}
		
	//f_sapir_alert ("f_sapir_frame_document : 7");
	return null;
}

function f_sapir_get_iframe_frame (a_iframe, a_iframe_name) {
	//f_sapir_alert ("f_sapir_get_iframe_frame : " + a_iframe_name);
	if (typeof (a_iframe) == "undefined") {
		//if (typeof (a_iframe_name) != "undefined") {
		//	f_sapir_alert ("f_sapir_get_iframe_frame : undefined (" + a_iframe_name + ")");
		//}
		return null;
	}
	if (!f_sapir_exists (a_iframe)) {
		//if (typeof (a_iframe_name) != "undefined") {
		//	f_sapir_alert ("f_sapir_get_iframe_frame : does not exist (" + a_iframe_name + ")");
		//}
		return null;
	}
	//f_sapir_alert ("77 : " + typeof (a_iframe.frameElement));
	if (typeof (a_iframe.frameElement) != "undefined") {
		if (f_sapir_exists (a_iframe.frameElement)) {
			//f_sapir_alert ("78 : " + a_iframe.frameElement);
			return a_iframe.frameElement;
		}
		return null;
	}
	
	//f_sapir_alert ("79 : " + typeof (f_sapir_frame_window (a_iframe).frameElement));
	if (typeof (f_sapir_frame_window (a_iframe).frameElement) != "undefined") {		
		if (f_sapir_exists (f_sapir_frame_window (a_iframe).frameElement)) {
			//f_sapir_alert ("80 : " + f_sapir_frame_window (a_iframe).frameElement);
			return f_sapir_frame_window (a_iframe).frameElement;
		}
		return null;
	}

	return null;
}

function f_sapir_get_element_by_id (a_parent_element, a_element_name) {
	var l_el;

	if (!f_sapir_exists (a_parent_element)) {
		//f_sapir_log ("f_sapir_get_element_by_id", "parent of " + a_element_name + " : null. sorry!", 3);
		return null;
	}
	if (a_parent_element.getElementById) {
		l_el = a_parent_element.getElementById (a_element_name);
	} else if (window.document.getElementById) {
		l_el = window.document.getElementById (a_element_name);
	} 
	if (f_sapir_exists (l_el)) {
		return l_el;
	}

	if (!document.all) {
		return null;
	}
	l_el = a_parent_element.all [a_element_name];
	if (f_sapir_exists (l_el)) {
		return l_el;
	}
	
	return null;
}

function f_sapir_get_element_id (a_el) {
	var l_el_id;

	if (a_el.getAttribute) {
		l_el_id = a_el.getAttribute ("id");
	} else {
		l_el_id = a_el.id;
	}
	if (!f_sapir_is_empty (l_el_id)) {
		return l_el_id;
	}
	if (a_el.getAttribute) {
		l_el_id = a_el.getAttribute ("name");
	} else {
		l_el_id = a_el.name;
	}
	if (f_sapir_is_empty (l_el_id)) {
		return "";
	}
	return l_el_id;
}

function removeClassName (elem, className) { 
	elem.className = elem.className.replace(className, "").trim();
} 
function rtclickcheck(keyp){
/*  if (document.layers && keyp.which != 1) {
    alert(mymessage);
    return false; }
  if (document.all && event.button != 1) {
    alert(mymessage);
    return false; }
*/
   return false;
}
function sapir_string_obj (a_value) {
	this.value = a_value;
}
function stripedTable() { 
	return;

	if (document.getElementById && document.getElementsByTagName) {  
		var allTables = document.getElementsByTagName('table'); 
		if (!allTables) { return; } 
		for (var i = 0; i < allTables.length; i++) { 
			if (allTables[i].className.match(/[\w\s ]*scrollTable[\w\s ]*/)) { 
				var trs = allTables[i].getElementsByTagName("tr"); 
				for (var j = 0; j < trs.length; j++) { 
					removeClassName(trs[j], 'alternateRow'); 
					addCSSClass(trs[j], 'normalRow'); 
				} 
				for (var k = 0; k < trs.length; k += 2) { 
					removeClassName(trs[k], 'normalRow'); 
					addCSSClass(trs[k], 'alternateRow'); 
				} 
			} 
		} 
	} 
}

function f_sapir_get_attribute (a_element, a_attrib_name) {	
	if (!f_sapir_exists (a_element)) {
		return null;
	}
	if (!f_sapir_exists (a_element.attributes)) {
		return null;
	}
	return a_element.getAttribute (a_attrib_name);
}

function f_sapir_set_attribute (a_element, a_attrib_name, a_attrib_value) {
	var l_selected_attrib;

	if (!f_sapir_exists (a_element)) {
		return;
	}
	if (!f_sapir_exists (a_element.attributes)) {
		return;
	}

	l_selected_attrib = a_element.getAttribute (a_attrib_name);
	if (l_selected_attrib == undefined || l_selected_attrib == null) {
		l_selected_attrib = document.createAttribute(a_attrib_name);
		a_element.setAttributeNode (l_selected_attrib);
	}
	a_element.setAttribute (a_attrib_name, a_attrib_value);
}

function f_sapir_ShowAttribs (oElem)
{

	var txtAttribs;
    txtAttribs = '';
	
    // Retrieve the collection of attributes for the specified object.
    var oAttribs = oElem.attributes;

    // Iterate through the collection.
    for (var i = 0; i < oAttribs.length; i++)
    {
        var oAttrib = oAttribs[i];

        // Print the name and value of the attribute. 
        // Additionally print whether or not the attribute was specified
        // in HTML or script.
        txtAttribs += oAttrib.nodeName + '=' + 
            oAttrib.nodeValue + ' (' + oAttrib.specified + ')<BR>'; 
    }
	return txtAttribs;
}

function f_sapir_focus_default_field (a_field_name) {
	//f_sapir_alert ("f_sapir_focus_default_field = " + a_field_name);
	var l_field_el;
	var browserName = navigator.appName;
	
	l_field_el = f_sapir_get_element_by_id (window.document, a_field_name);
	if (!f_sapir_exists (l_field_el)) {
		return;
	}
	//f_sapir_alert ("focusing");
	l_field_el.focus ();
	
	if (f_sapir_is_ie_modal ()) {
		self.focus ();
	}
	
	if (g_sapir_browser_is_ie) {
	//if (browserName == "Microsoft Internet Explorer") {
    	l_field_el.setActive ();
	}
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}



function viewSource() {
	var d;
	d = window.open ();
	d.document.open ('text/plain').write (document.documentElement.outerHTML);
}

function f_sapir_is_checkbox (a_el) {
	if (a_el.type == "checkbox") {
		return true;
	}
	return false;
}

function f_sapir_is_dropdown (a_el) {
	//.getAttribute ("type")
	if (a_el.multiple == undefined) {
		return false;
	}
	return true;
}

function f_sapir_is_integer (s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function f_sapir_is_textarea (a_el) {
	//f_sapir_alert ("f_sapir_is_dropdown : " + a_el.name + ", " + a_el.type + ", " + a_el.multiple)
	//.getAttribute ("type")
	if (a_el.rows == undefined) {
		return false;
	}
	return true;
}

function f_sapir_is_readonly (a_el) {
	if (f_sapir_is_checkbox (a_el)) {
		// checkbox
		return a_el.disabled;
	} 
	if (f_sapir_is_dropdown (a_el)) {
		// select
		return a_el.disabled;
	}
	if (f_sapir_is_textarea (a_el)) {
		// textarea
		if (typeof (a_el.disabled) != "undefined") {
			if (a_el.disabled == "disabled" || a_el.disabled == true) {
				return true;
			}
		}
		if (typeof (a_el.readOnly) != "undefined") {
			if (a_el.readOnly == "readonly" || a_el.readOnly == true) {
				return true;
			}
		}
		return false;
	}	
	if (typeof (a_el.disabled) != "undefined") {
		if (a_el.disabled == "disabled") {
			return true;
		}
	}	
	if (typeof (a_el.readOnly) != "undefined") {
		if (a_el.readOnly == "readonly") {
			return true;
		}
	}
	return false;	
}

function f_sapir_get_numeric_measure (a_measure) {
	var l_measure, l_unit_pos, l_ret;
	
	l_measure = new String (a_measure);
	l_unit_pos = l_measure.indexOf (g_sapir_measure_unit);
	if (l_unit_pos < 0) {
		l_ret = new Number (l_measure);
	} else {
		l_ret = new Number (l_measure.substring (0, l_measure.length - g_sapir_measure_unit.length));
	}
	return l_ret;
}

function f_sapir_measure (a_measure, a_min, a_max, a_no_units) {
	var l_measure , l_ret;

	if (typeof (a_no_units) == "undefined") {
		a_no_units = false;
	}
	
	l_measure = a_measure;
	
	if (a_min >= 0 && l_measure < a_min) {
		l_measure = a_min;
	} else if (a_max >= 0 && l_measure > a_max) {
		l_measure = a_max;
	}
	l_ret = new String (l_measure)
	
	if (a_no_units == false) {
		l_ret += g_sapir_measure_unit;
	}

	return l_ret;
}

function getMouseX (e, a_window) {
	var tempX;
	
    if (g_sapir_browser_is_ie) {
      tempX = e.clientX + a_window.document.body.scrollLeft;
    } else {
      tempX = e.pageX;
    }  
    
    if (tempX < 0){
		tempX = 0;
	}    
  
	return tempX;
}
  
function getMouseY (e, a_window) {
	var tempY;
    if (g_sapir_browser_is_ie) {
      tempY = event.clientY + a_window.document.body.scrollTop;
    } else {
      tempY = e.pageY;
    }  
    
    if (tempY < 0){tempY = 0;}     
    
    return tempY;
}

function f_sapir_mousedown (e) {
	var l_el_name;
	if (!(e)) {
		e = window.event;
	}
	f_sapir_mousedown_logic (e)

	f_sapir_event_cancel (e);
}

function f_sapir_mousedown_logic (e) {
	f_sapir_alert ("f_sapir_mousedown_logic : not in use ???");
	var l_el_name;

	l_el_name = f_sapir_el_get_id (f_sapir_event_element (e));

	if (f_sapir_is_implemented ("f_sapir_" + l_el_name + "_mousedown")) {
		eval ("f_sapir_" + l_el_name + "_mousedown (e)");
	}	
}

function f_sapir_mousemove_logic (e) {
	f_sapir_alert ("f_sapir_mousemove_logic : not in use ???");
	var l_el_name;

	l_el_name = f_sapir_el_get_id (f_sapir_event_element (e));

	if (f_sapir_is_implemented ("f_sapir_" + l_el_name + "_mousemove")) {
		eval ("f_sapir_" + l_el_name + "_mousemove (e)");
	}	
}

function f_sapir_mouseup_logic (e) {
	f_sapir_alert ("f_sapir_mouseup_logic : not in use ???");
	var l_el_name;

	l_el_name = f_sapir_el_get_id (f_sapir_event_element (e));

	if (f_sapir_is_implemented ("f_sapir_" + l_el_name + "_mouseup")) {
		eval ("f_sapir_" + l_el_name + "_mouseup (e)");
	}	
}

function f_hex_to_dec (a_hex) {
	return parseInt (a_hex, 16);
}

function f_string_to_array (a_src) {
	var l_src, l_array;
	l_src = new String (a_src);
	l_array = l_src.split ("");
	return l_array;
}

function f_decode_string(src) {
	var pos,end_pos;
	var asc, dst;
	
	dst = src;

	pos = dst.indexOf("!");
	while (pos >= 0) {
		end_pos = dst.indexOf(";",pos);
		asc = dst.substr(pos + 1,(end_pos - pos) - 1);
		var temp;
		temp = dst.substr(0,pos);
		temp += String. fromCharCode(parseInt(asc));
		temp += dst.substr(end_pos + 1);
		dst = temp;
	
		pos = dst.indexOf("!");
		//pos = dst.indexOf("!",pos + 1);
	}

	return dst;
}

/* Block F5 refresh in frames © John Davenport Scheuer
* As first seen in http://www.dynamicdrive.com/forums/
* Username: jscheuer1 - This credit must remain for legal use */

function nof5 (){
f_sapir_alert ("nof5");
	if(window.frames && window.frames[0]) {
		window.frames[0].focus ();
		for (var i_tem = 0; i_tem < window.frames.length; i_tem++) {
			if (document.all && document.body.filters) {
				window.frames[i_tem].document.onkeydown = new Function ("var e=window.frames[" + i_tem +"].event; if(e.keyCode==116){e.keyCode=0;return false;};");
			} else if (document.getElementById) {
				window.frames[i_tem].onkeypress = new Function ("e","if(e.keyCode==116){e.preventDefault();e.stopPropagation();}");
			}
		}
	}
}

//yair
function f5_frame_level (){
	//f_sapir_alert ("debug : f5_frame_level");
	window.document.onkeydown = f5_frame_level_impl;
}

function f5_frame_level_impl (a_event){
	var l_event;
	if (document.all) {	
		l_event = window.event;
	} else {
		l_event = a_event;
	}
	
	if (l_event.keyCode == 116) {
		if (document.all) {
			l_event.keyCode=0;
			g_sapir_post_f5_frame_level_timeout_id = window.setTimeout ("f5_frame_level_post ()", 150);	
			return false;
		} else if (document.getElementById) {
			l_event.preventDefault();
			l_event.stopPropagation();
			g_sapir_post_f5_frame_level_timeout_id = window.setTimeout ("f5_frame_level_post ()", 150);
			return;
		}
	}
	
	// not f5
	if (f_sapir_is_implemented ("keyDown")) {
		keyDown ();
	}
}

function f5_frame_level_post () {
	f_sapir_location_reload ()	
}

function f_sapir_get_token (a_sapir_string_obj, a_token) {
	var l_token_pos, l_next_token_pos, l_next_value;
	
	l_token_pos = a_sapir_string_obj.value.indexOf (a_token);

	if (l_token_pos < 0) {
		return null;
	}
	
	// get value
	l_next_value = a_sapir_string_obj.value.substring (0 , l_token_pos);
	
	// strip out value + its token
	a_sapir_string_obj.value = a_sapir_string_obj.value.substring (l_token_pos + a_token.length);
	
	return l_next_value;
}

function f_sapir_url_encode (a_url) {
	var l_url;
	l_url = new String (a_url);

	//l_url = l_url.replace(/\%/g, "%25");
	l_url = l_url.replace(/\"/g, "%22");
	l_url = l_url.replace(/\'/g, "%27");
	//l_url = l_url.replace(/\?/g, "%3F");

	l_url = l_url.replace(/\&lt;/g, "<");
	l_url = l_url.replace(/\&gt;/g, ">");
	//l_url = l_url.replace(/\&/g, "%26");

	if (l_url.indexOf (".pdf#") < 0) {
		l_url = l_url.replace(/\#/g, "%23");
	}

	// / =>	%2F
	// \ =>	%5C	

	return l_url;
}

function f_sapir_event_add (obj, evType, fn, capture) {
	//debugger;
	var l_capture;
	if (!f_sapir_exists (obj)) {
		f_sapir_alert ("event_add failed : object does not exist : " + evType + " = " + fn);
		return;
	}
	
	if (typeof (capture) != "undefined") {
		l_capture = capture;
	} else {
		l_capture = false;
	}
	
	if (obj.addEventListener) {
		try {
			eval ("obj.addEventListener (\"" + evType + "\"" + "," + fn + ", l_capture)");
			//obj.addEventListener (evType, fn, l_capture);
		} catch(ex) {
		//	debugger;
			var xxx = 1;
		}
		return true;
	}
	if (obj.attachEvent) {
		var r = eval ("obj.attachEvent (\"on" + evType + "\"" + "," + fn + ")");
		//var r = obj.attachEvent ("on" + evType, fn);
		return r;
	}
	return false;	
}

function f_sapir_event_remove (obj, evType, fn, capture) {
	try {
	var l_capture;
	
	//if (evType == "mousemove") {
	//	debugger;
	//}
	
	if (!f_sapir_exists (obj)) {
		f_sapir_alert ("event_add failed : object does not exist : " + evType + " = " + fn);
		return;
	}
	
	if (typeof (capture) != "undefined") {
		l_capture = capture;
	} else {
		l_capture = true;
	}
	if (obj.removeEventListener) {
		obj.removeEventListener(evType, fn, l_capture);
		return true;
	} else if (obj.detachEvent) {
		var r = obj.detachEvent ("on" + evType, fn);
		//var r = eval ("obj.detachEvent (\"on" + evType + "\"" + "," + fn + ")");
		return r;
	} else {
		alert("Handler could not be removed");
	}
	} catch (event_remove_exception) {
		//debugger;
		alert ("error : " + window.location.href);
		f_sapir_exception ("sapirjsfile", "event_remove : " + evType, event_remove_exception);
	}
}

function f_sapir_parent (a_el) {
	if (!f_sapir_exists (a_el)) {
		return false;
	}
	if (a_el.parentElement) {
		return a_el.parentElement;
	}
	if (a_el.parentNode) {
		return a_el.parentNode;
	}
	return null;
}

function f_sapir_form_get_by_name (a_form_name, a_window) {
	var l_forms, l_form_count, lidx, l_form_el;
	
	var l_win;
	if (a_window) {
		l_win = a_window;
	} else {
		l_win = window;
	}
	
	l_form_el = null;
	
	l_forms = l_win.document.getElementsByTagName ("form");
	l_form_count = l_forms.length;
	for (var lidx = 0; lidx < l_form_count; lidx++) {
		if (l_forms [lidx].getAttribute ("name") == a_form_name) {
			l_form_el = l_forms [lidx];
			break;
		}
	}
	
	return l_form_el
}

function f_sapir_element_set_value (a_el, a_value) {
	var l_el_type = "text";
	if (!f_sapir_is_empty (f_sapir_get_attribute (a_el, "src"))) {
		l_el_type = "img";
	}
	//f_sapir_log ("f_sapir_element_set_value", "type of " + a_el.name + " = " + l_el_type, 3);
	
	if (l_el_type == "text") {
		a_el.value = a_value;
	} else if (l_el_type == "img") {
		a_el.src = a_value;
	}
}

function f_sapir_element_get_offsetLeft (a_el) {
	var l_offset, l_el;
	l_offset = 0;
	l_el = a_el;
	
	if (l_el.offsetParent) {
		l_offset = l_el.offsetLeft;
		while (l_el = l_el.offsetParent) {
			l_offset += l_el.offsetLeft;
		}
	} else {
		l_offset = l_el.offsetLeft;
	}
	
	/*
	while (f_sapir_exists (l_el.parentElement)) {
		if (l_el.parentElement.style.position == "absolute") {
			break;
		}
		//f_sapir_alert (l_el.parentElement.id + " = " + l_el.parentElement.offsetLeft)
		l_offset += l_el.parentElement.offsetLeft;
		l_el = l_el.parentElement;
	}
	l_offset += a_el.offsetLeft;
	f_sapir_alert (a_el.id + " = " + a_el.offsetLeft)
	*/
	return l_offset;
}

function f_sapir_element_get_offsetTop (a_el) {
	var l_offset, l_el;
	l_offset = 0;
	l_el = a_el;
	
	if (l_el.offsetParent) {
		l_offset = l_el.offsetTop;
		while (l_el = l_el.offsetParent) {
			l_offset += l_el.offsetTop;
		}
	}else {
		l_offset = l_el.offsetTop;
	}
	
	/*
	while (f_sapir_exists (l_el.parentElement)) {
		if (l_el.parentElement.style.position == "absolute") {
			break;
		}
		//f_sapir_alert (l_el.parentElement.id + " = " + l_el.parentElement.offsetTop)
		l_offset += l_el.parentElement.offsetTop;
		l_el = l_el.parentElement;
	}
	l_offset += a_el.offsetTop;
	f_sapir_alert (a_el.id + " = " + a_el.offsetTop)
	*/
	return l_offset;
}

/*
window.document.getElementById ("dview_3_2_value_2").currentStyle ("width");
document.defaultView.getComputedStyle(window.document.getElementById ("dview_3_2_value_2"),null).getPropertyValue("width");
*/

function f_sapir_anchor_click (a_anchor_id) {
	var l_anchor_el;
	l_anchor_el = f_sapir_get_element_by_id (window.document, a_anchor_id);
	l_anchor_el.click ();
}

function f_sapir_unescape (a_value) {
	f_sapir_log ("f_sapir_unescape", a_value, 3);
	var l_string_value = new String (a_value);
	var pos, end_pos, entity_ref, l_ret;

	//l_string_value = f_sapir_slashes (l_string_value);
	
	// single quote
	l_string_value = l_string_value.replace (/!33;39;/g, "\'");
	// #
	l_string_value = l_string_value.replace (/!33;35;/g, "#");
	// !
	l_string_value = l_string_value.replace (/!33;33;/g, "!");

	pos = l_string_value.indexOf ("&");
	while (pos >= 0) {
		end_pos = l_string_value.indexOf (";", pos);
		if (end_pos < 0)  {
			break;
		}
		entity_ref = l_string_value.substring (pos, end_pos + 1);
		var temp;
		temp = l_string_value.substring (0, pos);

		if (entity_ref == "&apos;") {
			temp += "\'";
		} else if (entity_ref == "&quot;") {
			temp += "\"";
		} else if (entity_ref == "&lt;") {
			temp += "<";
		} else if (entity_ref == "&gt;") {
			temp += ">";
		} else if (entity_ref == "&amp;") {
			temp += "&";
		}
	
		temp += l_string_value.substring (end_pos + 1);
		l_string_value = temp;

		pos = l_string_value.indexOf ("&");
	}

	/*
	// single quote
	if (l_string_value.indexOf ("&apos;") >= 0) {
		l_string_value = l_string_value.replace(/&apos;/gi, "\'");
	}
	
	// "
	if (l_string_value.indexOf ("&quot;") >= 0) {
		l_string_value = l_string_value.replace(/&quot;/gi, "\"");
	}

	// <
	if (l_string_value.indexOf ("&lt;") >= 0) {
		l_string_value = l_string_value.replace(/&lt;</gi, "<");
	}
	
	// >
	if (l_string_value.indexOf ("&gt;") >= 0) {
		l_string_value = l_string_value.replace(/&gt;</gi, ">");
	}

	// &
	if (l_string_value.indexOf ("&amp;") >= 0) {
		l_string_value = l_string_value.replace (/&amp;/gi, "\&");
	}
	*/

	l_ret = l_string_value;
	return l_ret;
}

function f_sapir_date_validate (a_date, a_complete, a_date_format, a_year_min, a_year_max) {
	return true;
	
	/*
	var l_date, l_pattern;
	l_date = new String (a_date);
	l_pattern = new RegExp ("/^\d{1,2}(\-|\/|\.)\d{1,2}\1(\d{2}|\d{4})$/");
	f_sapir_alert (l_date + " = " + l_pattern.test (l_date));
	*/

	var strDay, strMonth, strYear, l_date, l_complete;
	
	if (!f_sapir_is_empty (a_complete)) {
		l_complete = a_complete;
	} else {
		l_complete = false;
	}
	
	if (a_date == "") {
		return true;
	}
	
	l_date = a_date.replace (/_/g, "0");
	
	var daysInMonth = f_sapir_days_array (12);
	var pos1 = l_date.indexOf (g_sapir_date_delimiter);
	var pos2 = l_date.indexOf (g_sapir_date_delimiter, pos1 + 1);
	
	if (a_date_format == "dd/mm/yyyy") {
		strDay = l_date.substring (0, pos1);
		strMonth = l_date.substring (pos1 + 1, pos2);
	} else {
		// mm/dd/yyyy
		strMonth = l_date.substring (0, pos1);
		strDay = l_date.substring (pos1 + 1, pos2);
	}
	strYear = l_date.substring (pos2 + 1);
	
	strYr = strYear;
	if (strDay.charAt (0) =="0" && strDay.length > 1) {
		strDay = strDay.substring (1);
	}
	if (strMonth.charAt (0)=="0" && strMonth.length>1) {
		strMonth = strMonth.substring (1);
	}
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) {
			strYr = strYr.substring(1);
		}
	}
	month = parseInt (strMonth);
	day = parseInt (strDay);
	year = parseInt (strYr);
	
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy");
		f_sapir_log ("f_sapir_date_validate", "The date format should be : mm/dd/yyyy", 3);
		return false;
	}
	if (strMonth.length < 1 || (l_complete && month < 1) || month > 12) {
		//f_sapir_alert ("Please enter a valid month");
		f_sapir_log ("f_sapir_date_validate", "error : invalid month", 3);
		return false;
	}
	if (strDay.length < 1 || (l_complete && day < 1) || day > 31 
		|| (month == 2 && day > f_sapir_days_in_february (year)) || day > daysInMonth [month]) {
		//f_sapir_alert ("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || (l_complete && year == 0) || year < a_year_min || year > a_year_max) {
		//f_sapir_alert ("Please enter a valid 4 digit year between " + g_sapir_year_min + " and " + g_sapir_year_max);
		return false;
	}
	if (l_date.indexOf (g_sapir_date_delimiter, pos2+1) != -1 
		|| f_sapir_is_integer (f_sapir_strip_chars_in_bag (l_date, g_sapir_date_delimiter)) == false) {
		//f_sapir_alert ("Please enter a valid date");
		return false;
	}
	return true;
}
function f_sapir_decode_text (a_text) {
	var l_decoded_text;
	l_decoded_text = a_text;
	l_decoded_text = l_decoded_text.replace(/&#34;/g, "\"");
	l_decoded_text = l_decoded_text.replace(/&#39;/g, "\'");
	l_decoded_text = l_decoded_text.replace(/&#39;/g, "\'");
	l_decoded_text = l_decoded_text.replace(/&#47;/g, "\/");
	l_decoded_text = l_decoded_text.replace(/&#92;/g, "\\");
	l_decoded_text = l_decoded_text.replace(/&#60;/g, "<");
	l_decoded_text = l_decoded_text.replace(/&#62;/g, ">");
	l_decoded_text = l_decoded_text.replace(/&#38;/g, "&"); //  must be last !!!
	return l_decoded_text;
}

function f_sapir_get_image_width (a_img_url) {
	var newImg = new Image();
	newImg.src = a_img_url;
	var width = newImg.width;
	return width;
}

function f_sapir_get_image_height (a_img_url) {
	var newImg = new Image();
	newImg.src = a_img_url;
	var height = newImg.height;
	return height;
}

function f_sapir_file_get_name (a_full_path) {
	//f_sapir_alert ("f_sapir_file_get_name : " + a_full_path);
	var l_last_slash_pos, l_file_name, l_full_path;
	l_full_path = new String (a_full_path);
	l_last_slash_pos = l_full_path.lastIndexOf ("\\");
	l_file_name = l_full_path.substring (l_last_slash_pos + 1);
	return l_file_name;
}

function f_sapir_window_location () {
	if (typeof (window.location) == "object") {
		return window.location.href;
	}
	return window.location;
}

function f_sapir_window_location_set (a_url) {
	f_sapir_location_replace (a_url, window, false);
	/*
	if typeof (window.location == "object") {
		return window.location.href;
	}
	return window.location;
	*/
}

function f_sapir_location_replace (a_url, a_window, a_is_iframe) {	
	//g_sapir_browser_type
	var l_final_url, l_window, l_is_iframe;
	
	if (g_sapir_location_replace_timeout_id != null) {
	   clearTimeout (g_sapir_location_replace_timeout_id);
	   g_sapir_location_replace_timeout_id = null;
 	}

	if (a_window) {
		l_window = a_window;
	} else {
		l_window = window;
	}
	
	if (a_is_iframe) {
		l_is_iframe = a_is_iframe;
	} else {
		l_is_iframe = false;
	}
	
	if (f_sapir_is_implemented ("f_sapir_rte_set_design_mode")) {
		f_sapir_rte_set_design_mode ("off");
	}
	// try_catch required since if user cancels in onBeforeUnload, there will be an "unspecified error"
	//f_sapir_alert (new String (a_url + "&ts=" + f_sapir_datetime_get ()).length);
	if (new String (a_url /* + "&ts=" + f_sapir_datetime_get () */).length > 2048) {
		alert ("location replace failed : url size exceeds limit");
		return false;
	}

	l_final_url = new String (a_url);
	if (l_final_url.indexOf ("?") >= 0) {
		/*
		if (l_final_url.indexOf ("&ts=") < 0) {
			l_final_url += "&";
			l_final_url += "ts=" + f_sapir_datetime_get ();
		}
		*/
	}
	//f_sapir_please_wait_popup (true, null, "", null);
	try {
		if (l_is_iframe == true) {
			if (g_sapir_browser_type != "ie") {
				if (g_sapir_browser_type == "firefox") {
					f_sapir_frame_document (l_window).location.replace (l_final_url);
					return true;			
				}
			}
		}		
		// location value : window.location (ie, ff), window.location.href (chrome, ff)
		l_window.location.replace (l_final_url);
	} catch(ex) {
		//f_sapir_alert (ex.number);
		//f_sapir_alert ("location replace failed");
		return false;
	}
	return true;
}

function jquery_toggle(el,scr,mode) {
                if ($(el).is(":hidden")) {
                  if (mode=='slide'){
					    $(el).slideDown("slow");
                     } else if(mode=='fade') {
                        $(el).fadeIn("slow");
                     } else {
                        $(el).show();
                     }
                     $(scr).attr("src","images/ltr/icons/bullet_minus_comments.gif");
                } else {
                     if (mode=='slide'){
							$(el).slideUp("slow");
		                } else if(mode=='fade') {
							$(el).fadeOut("slow");
                        } else {
							$(el).hide();
                        }
						$(scr).attr("src","images/ltr/icons/bullet_plus_comments.gif");
                }
}

function of_Select_Branch(el, url, expand) {
	var OriginPos = 146
	var Linepos = $(el).position();
	var RefPos = Linepos.top - 125 ;
	var iframe = $('.archiveItemDetailsIframe')
	var iframepos = $(iframe).position();
	var prev_branch = $('#cur_level_name').val();
	var l_tree_state = "";
	var l_stateman_args = "";

	if (expand == 1) {
		if (prev_branch.indexOf(el) == -1) {
			return;
		}
	}

	$('#cur_level_name').val(el)
	$(iframe).attr("src",url);
	$('span').removeClass('ArchiveTreeItemSelected');
	$(el).addClass('ArchiveTreeItemSelected') ;
	if (Linepos.top > 280) {
		$(iframe).css({ position: "absolute", top: RefPos, left: iframepos.left});
	} else{
		$(iframe).css({ position: "absolute", top: OriginPos, left: iframepos.left});
	}
	l_tree_state = f_sapir_url_encode (el);
	if (f_sapir_exists (g_sapir_stateman_iframe_el)) {
		l_stateman_args = "key=tree&value=" + l_tree_state;
		g_sapir_stateman_iframe_el.src = "stateman.asp?" + l_stateman_args;
	}
	return false;
}

// UI : tips
//////////////////////////

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12; //Customize x offset of tooltip
var offsetfromcursorY=10; //Customize y offset of tooltip

var offsetdivfrompointerX=10; //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ddrivetip(thetext, thewidth, thecolor){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
		tipobj.innerHTML=thetext;
		enabletip=true;
		return false;
	}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false;
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px";
nondefaultpos=true;
}
else if (curX<leftedge)
tipobj.style.left="5px";
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
nondefaultpos=true;
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
}
tipobj.style.visibility="visible";
if (nondefaultpos == false) {
} else {
}
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false;
tipobj.style.visibility="hidden";
tipobj.style.left="-1000px";
tipobj.style.backgroundColor='';
tipobj.style.width='';
}

}

/* end of Cool DHTML tooltip */


////////////////////// end of sapir_gen.js ///////////////////////////
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from scripts.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
//var g_sapir_images_preload_done = false;


function ShowHide(divId,spanId)
{
  isDisplayed = document.getElementById(divId).style.display
  if(isDisplayed=='block')
    {
      document.getElementById(divId).style.display='none';
	   document.getElementById(spanId).src='images/ltr/side_menu/bullet_subClosed.gif';
    }
  else
    {
		      document.getElementById(divId).style.display='block';
			  if (document.getElementById(spanId)){
			   document.getElementById(spanId).src='images/ltr/side_menu/bullet_subOpen.gif';}
    }
}

function HideAll()
{
 var i,ols,spans;
  ols=document.getElementsByTagName('ol');
  spans=document.getElementsByTagName('span');
 
 for (i = 0; i <= ols.length-1; i++)
 {   if(ols[i].style.display=='block')
     ols[i].style.display='none';
 }
 
 for (i = 0; i <= spans.length-1; i++)
 {   if(spans[i].style.display=='block')
     spans[i].style.display='none';
 }
 
}

function f_notebook_ext_onload () {
	// disable all anchors
	var l_anchors;
	l_anchors = window.document.getElementsByTagName ("a");
	for (var idx = 0; idx < l_anchors.length; idx++) {
		l_anchors [idx].removeAttribute ("href");
	}
}

function MM_preloadImages() { //v3.0
	/*
	if (g_sapir_images_preload_done == true) {
		return;
	}
	g_sapir_images_preload_done = true;
	*/
	var a;
	var d=document; 
	if(!d.images){
		return;
	}
	if (!d.MM_p) {
		d.MM_p=new Array();
	}
	var i,j;
	
	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_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_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];}
}

var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function loadmenu(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("nav_menu").style.display=''
document.getElementById("nav_menu").style.width=initialwidth=width+"px"
document.getElementById("nav_menu").style.height=initialheight=height+"px"
document.getElementById("nav_menu").style.left="10px"
document.getElementById("nav_menu").style.top=ns6? window.pageYOffset*1+80+"px" : iecompattest().scrollTop*1+80+"px"
document.getElementById("cframe").src=url
}
}

function closemenu(){
document.getElementById("nav_menu").style.display="none"
}



var ie = false;
var lastNote = '';
if (document.all) { ie = true; }
 
 function getObj(id) {
  if (ie) {
   return document.all[id];
  } else {
   return document.getElementById(id);
  }
 }
 
  function showNote (a_name, a_mode, a_row_el_id) {
	 var l_css_class = "", l_row_el, l_actions_height, l_actions_top_limit;

	if (a_name == lastNote) {
		hideNote (a_name);
		return false;
	}

	if (a_mode == '1')  {
		l_css_class = "notevisible";
	} else if (a_mode == "scroller") {
		l_css_class = "scr_notevisible";
	} else {
		l_css_class = "notevisible2";
	}

	if (lastNote != '') {
		hideNote(lastNote);
	}

	var title = getObj (a_name + '_title');
	var body = getObj (a_name + '_body');
	//title.className = 'notehidden';
	body.className = l_css_class;

	l_actions_height = f_sapir_actions_combo_get_height (body);
	l_actions_top_limit = new Number (window.document.documentElement.clientHeight) - new Number (l_actions_height) - 60;

	if (a_mode == "scroller") {
		body.style.top = f_sapir_measure (f_sapir_element_get_offsetTop (body), 1, l_actions_top_limit, false);
	}
	
	lastNote = a_name;

	// "scroller" mode -  backup mouseover & mouseout of current TR to avoid flickering
	if (a_mode == "scroller")  {
		l_row_el = f_sapir_get_element_by_id (window.document, a_row_el_id);
		f_sapir_event_add (l_row_el, "mouseover", "f_sapir_scroller_row_mouseover_cancel");

		if (!f_sapir_exists (g_sapir_scroller_state)) {
			g_sapir_scroller_state = new sapir_scroller_state ();
			g_sapir_scroller_state.row_el = l_row_el;
		}
	}
	return false;
}
 
 function hideNote (a_name, a_mode) {
	var title, body, l_row_el;
	
	title = getObj(a_name + "_title");
	body = getObj(a_name + "_body");
	//title.className = "note";
	body.className = "notehidden";
	lastNote = "";

	if (a_mode == "scroller")  {
		if (f_sapir_exists (g_sapir_scroller_state)) {
			if (f_sapir_exists (g_sapir_scroller_state.row_el )) {
				l_row_el = g_sapir_scroller_state.row_el;
				f_sapir_removeEvent (l_row_el, "mouseover", "f_sapir_scroller_row_mouseover_cancel");
			}
		}		
	}
	return false;
 }

function openWindow(URL,name, w, h, top, left) {
    popupWin = window.open(URL, name, 'width=' + w+ ',height=' + h+',scrollbars=no, resizable=yes, top=' + top+ ',left=' + left);
}		
////////////////////// end of scripts.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from scroller_utils.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// global variables
var mywindow;
var g_last_detailed_elem = "";
var g_last_edited_elem = "";
var g_scroller_whiteText, g_scroller_readOnlyOnEmptyReturn;
var g_sapir_scroller_type1_id = "";
var g_sapir_scroller_table_name = "";

//**********************************************************************************************************
//	scroller_utils.js
// 
// 	These JavaScript utility functions enable HTML code to open a sub windows (scrollers).
//	The scrollers can return values to the window that opened them
//	The utilities assist in the creation of the interface for opening the scrollers (flashlight icon button)
//
//**********************************************************************************************************

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	openScroller: use this function to open a scroller window
//
//	codeField: a form filed to which code information returened from the scroller is assigned (null if for no field)
//	textField: a form filed to which text information returened from the scroller is assigned (null if for no field)
//	url:			the url to be loaded in the scroller
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function f_exists (a_object) {
	if (typeof a_object == 'object' && a_object != null && a_object != undefined) {
		return true;
	} else {
		return false;
	}
}

function f_get_element_by_id (a_parent_element, a_element_name) {
	var l_el;

	if (a_parent_element.getElementById) {
		l_el = a_parent_element.getElementById (a_element_name);
	} 
	if (f_exists (l_el) == false) {
		l_el = a_parent_element.all [a_element_name];
	}
	return l_el;
}

function openScroller(codeField, textField, url) {
	openScroller6(codeField, textField, url, "", "", true, "");
	return false;
}

function openScroller6(codeField, textField, url, whiteText, readOnlyOnEmptyReturn, showDetails, url_prefix) {
	// biz 77577 : test
	//window.open ("empty.htm", "_blank", "", true);
	//textField.value = "brown";
	//setDwScrollerValues (textField, window, 0);
	//return;

	var codeFormNum = -1;
	var codeElementNum = -1;
	var textFormNum = -1;
	var textElementNum = -1;
	var l_info_form;
	var l_scroller_width, l_scroller_height, l_scroller_top, l_scroller_left, l_popup_open_ret;
	var l_wrapper_page, l_content_iframe, l_utility_iframe;
	var l_wrapper_page_syntax, l_content_iframe_syntax, l_utility_iframe_syntax;
	var content_url, utility_url;

	if (!f_sapir_exists (codeField)) {
		codeField = f_sapir_get_element_by_id (window.document, codeField);
	}

    if (codeField != null) {
		for (var i = 0; i < document.forms.length; i++) {
			if (document.forms[i] == codeField.form) {
				codeFormNum = i;
				break;
			}
		}
		if (codeFormNum >= 0) {
			for (var i = 0; i < codeField.form.elements.length; i++) {
				if (codeField.form.elements[i] == codeField) {
					codeElementNum = i;
					break;
				}
			}
		}
	}

	if (!f_sapir_exists (textField)) {
		textField = f_sapir_get_element_by_id (window.document, textField);
	}

	if (textField != null) {
		for (var i = 0; i < document.forms.length; i++) {
			if (document.forms[i] == textField.form) {
				textFormNum = i;
				break;
			}
		}

		if (textFormNum >= 0) {
			for (var i = 0; i < textField.form.elements.length; i++) {
				if (textField.form.elements[i] == textField) {
					textElementNum = i;
					break;
				}
			}
		}
	}

	if (!f_sapir_is_empty (whiteText)) {
		textField.setAttribute ("sapir_scroller_whiteText", whiteText);
	}
	if (!f_sapir_is_empty (readOnlyOnEmptyReturn)) {
		textField.setAttribute ("sapir_scroller_readOnlyOnEmptyReturn", readOnlyOnEmptyReturn);
	}
		
	//alert("Code (" + codeFormNum + "," + codeElementNum + ")")
	//alert("Text (" + textFormNum + "," + textElementNum + ")")

	// yair 9\10\06 : code field is optional
	if (/* codeFormNum < 0 && */ textFormNum < 0) {
		return;
	}
	
	content_url = new String (url);
	// encode "&" inside the content url, so they dont mess the url itself
	content_url = content_url.replace(/\&/g, "%26");
	//content_url = f_sapir_url_encode (content_url);

	utility_url = "scroller_utility_frame.asp?" 
								
	// yair 9\10\06 : code field is optional
	if (codeFormNum >= 0) {
		utility_url += "codeFormNum=" + codeFormNum
								+ "&codeElementNum=" + codeElementNum;
	}
	if (codeFormNum >= 0) {
		utility_url += "&";
	}
	utility_url += "textFormNum=" + textFormNum
							+ "&textElementNum=" +textElementNum;
	// encode "&" inside the content url, so they dont mess the url itself
	utility_url = utility_url.replace(/\&/g, "%26");
			
	/*
	l_wrapper_page_syntax = '<HTML><BODY>'
													+ '<IFRAME NAME="Utility" ID="Utility" width="0" height="0">'
													+ '<IFRAME NAME="Content" ID="Content" width="100%" height="100%" SRC="' + url + '">';
	l_utility_iframe_syntax = '<HTML><BODY><FORM ID="Info" NAME="Info"><INPUT TYPE="HIDDEN" NAME="textForm"><INPUT TYPE="HIDDEN" NAME="textElement"><INPUT TYPE="HIDDEN" NAME="codeForm"><INPUT TYPE="HIDDEN" NAME="codeElement"></FORM></BODY></HTML>';
													
	//l_wrapper_page_syntax, l_content_iframe_syntax, l_utility_iframe_syntax
	*/
	
	/* commented 19\1\10
	frameSetContent  = '<HTML><FRAMESET ROWS="0,100%" BORDER=0 FRAMBORDER=0><FRAME NAME="Utility">';
	frameSetContent += '<FRAME NAME="Content" SRC="' + url + '"></FRAMESET></HTML>';
	utilityFrameContent = '<HTML><BODY><FORM ID="Info" NAME="Info"><INPUT TYPE="HIDDEN" NAME="textForm"><INPUT TYPE="HIDDEN" NAME="textElement"><INPUT TYPE="HIDDEN" NAME="codeForm"><INPUT TYPE="HIDDEN" NAME="codeElement"></FORM></BODY></HTML>';
	*/

	f_sapir_scroller_width (false);
	f_sapir_scroller_height (false);
	
	l_scroller_top = (screen.availHeight - g_sapir_scroller_height) / 2;
	//l_scroller_top = document.getElementsByTagName ("body") [0].scrollTop;
	//l_scroller_top = window.document.documentElement.clientTop;

	l_scroller_left = (screen.availWidth - g_sapir_scroller_width) / 2;
	//l_scroller_left = document.getElementsByTagName ("body") [0].scrollLeft;
	//l_scroller_left = window.document.documentElement.clientLeft;

	g_sapir_scroller_please_wait_popup = f_sapir_scroller_please_wait (textField, l_scroller_top, l_scroller_left, null);
	
	//if (content_url.indexOf ("../../sapir_asp") >= 0) {
	//	ls_url_prefix = "../../sapir_asp/";
	//}
	l_popup_open_ret = f_sapir_popup (url_prefix + "scroller_wrapper.asp?"
																				/*+ "title=" + name*/
																				+ "content_url=" + content_url 
																				+ "&utility_url=" + utility_url
																				+ "&width=" + g_sapir_scroller_width
																				+ "&height=" + g_sapir_scroller_height,
																		"Scroller","WIDTH=" + g_sapir_scroller_width + ",HEIGHT=" + g_sapir_scroller_height 
																		+ ",Left=" + l_scroller_left +",Top=" + l_scroller_top + ",resizable=1");

	if (l_popup_open_ret == false) {
		f_sapir_scroller_please_wait_close ();
		return;
	}
	g_sapir_popup_ref.focus();
	
	/* commented 19\1\10
	g_sapir_popup_ref.document.write(frameSetContent);
	g_sapir_popup_ref.document.close();
	g_sapir_popup_ref.Utility.document.write(utilityFrameContent);
	g_sapir_popup_ref.Utility.document.close();

	//g_sapir_popup_ref.width = g_sapir_scroller_width;
	//g_sapir_popup_ref.height = g_sapir_scroller_height;
	
	l_info_form = f_sapir_get_element_by_id (g_sapir_popup_ref.Utility.document, "Info");

	// yair 9\10\06 : code field is optional
	if (codeFormNum >= 0) {		
		l_info_form.codeForm.value = codeFormNum;
		l_info_form.codeElement.value = codeElementNum ;
	}

	l_info_form.textForm.value = textFormNum;
	l_info_form.textElement.value = textElementNum ;
	g_sapir_popup_ref.document.title = name;
	g_sapir_popup_ref.focus();	
	*/

}

function openScroller_descr_cinabu (textField, url_prefix, url, whiteText, readOnlyOnEmptyReturn) {
	openScroller_descr5(textField, url, whiteText, readOnlyOnEmptyReturn, true, url_prefix);
	return false;
}

function openScroller_descr(textField, url, whiteText, readOnlyOnEmptyReturn) {
	openScroller_descr5(textField, url, whiteText, readOnlyOnEmptyReturn, true);
	return false;
}

function openScroller_descr5(textField, url, whiteText, readOnlyOnEmptyReturn, showDetails, url_prefix) {
	try {
	var codeField = null;

	openScroller6(codeField, textField, url, whiteText, readOnlyOnEmptyReturn, showDetails, url_prefix);
	return false;
	
	} catch (openScroller_descr5_exception) {
		f_sapir_exception ("scroller_utils", "scroller", openScroller_descr5_exception);
	}	
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	returnScroller: use this function to return values from a scroller to the calling window and close the scroller 
//
//	text: returened text string encoded in a !ascCode; syntex
//	code: returened code string
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function returnScroller (text, text_el_id, code, a_pb_dw, a_ui_lang) {
	var formNum;
	var elementNum;
	var field;
	var dataForm_name, dataForm_suffix, dataForm_suffix_pos, dw_name;
	var col_name, row_num, row_num_pos, item_val, l_or, l_text_el, l_text_ui_value;
	var l_utility_frame, l_utility_frame_window, l_info_form;

	var l_returned_descr_filled, l_operator;

	if (f_sapir_is_implemented ("f_sapir_scroller_return")) {
		f_sapir_scroller_return (code, text , text_el_id);
		return;
	}
	
	l_returned_descr_filled = false;
	l_operator = "";

	if (a_pb_dw == '') {
		a_pb_dw = "Y";
	}

	if (parent == null) {
		alert("There is no parent for the window. Return value is: " + text);
		return;
	}
	if (parent.opener.closed) {
		alert("The opener window is closed. Return value is: " + text);
		parent.close();
		return;
	}

// override text value : since cataloguer might modify descr via scroller. do not override if ui text is truncated : i.e. ends with "..."
	//if (g_sapir_browser_is_ie) {
		l_text_el = f_sapir_get_element_by_id (window.document, text_el_id);
		if (f_sapir_exists (l_text_el)) {
			// only text elements are valid : e.g. word marking inserts a non-text element inside the value, so it will not be handled
			//if (l_text_el.childNodes [0].nodeType == "3") {
			if (!f_sapir_exists (l_text_el.getElementsByTagName ("strong"))) {
				l_text_ui_value = l_text_el.childNodes [0].nodeValue;
				if (l_text_ui_value.indexOf ("...") != l_text_ui_value.length - 3) {
					text = l_text_ui_value;
				}
			}
		}
	//}

	//l_utility_frame = parent.f_get_utility_iframe ();
	l_utility_frame = f_sapir_get_frame ("Utility", parent);
	l_utility_frame_window = f_sapir_frame_window (l_utility_frame);
	l_info_form = l_utility_frame_window.f_sapir_form_get_by_name ("Info");

	/*	
	formNum = getCodeForm(l_utility_frame, l_utility_frame_window, l_info_form);
	if (formNum == "") {
		formNum = null;
	}

	elementNum = getCodeElement(l_utility_frame, l_utility_frame_window, l_info_form);
	if (elementNum == "") {
		elementNum = null;
	}

	if (formNum != null && elementNum != null ) {
		if (formNum >= 0 && elementNum >= 0) {
			field = parent.opener.document.forms[formNum].elements[elementNum];

			//field.fireEvent("onfocus");

			//// yair 11\11\04 : rem on focus & click
			//field.focus();
			//field.click();
			field.value = code;

			// yair 8\12\04
			if (a_pb_dw.toLowerCase () == "y")  	{
				setDwScrollerValues (field, parent.opener, formNum);
			}

			//// yair 11\11\04 : rem on focus & click
			//field.fireEvent("onblur");
			//field.blur();
		}
	}
	*/
	formNum = getTextForm(l_utility_frame, l_utility_frame_window, l_info_form);
	elementNum = getTextElement(l_utility_frame, l_utility_frame_window, l_info_form);

	if (formNum >= 0 && elementNum >= 0) {
		field = parent.opener.document.forms[formNum].elements[elementNum];
		
		var whiteText = field.getAttribute ('sapir_scroller_whiteText');
		var readOnlyOnEmptyReturn = field.getAttribute ('sapir_scroller_readOnlyOnEmptyReturn');
		//// yair 11\11\04 : rem on focus & click
		//field.focus();
		//field.click();

		
		if (!l_returned_descr_filled) {
			if (typeof (g_sapir_search_scroller_multiple_values) != "undefined") {
				if (g_sapir_search_scroller_multiple_values == true) {
					if (field.value == whiteText) {
						field.value = decodeParam(text)  ;
					} else if (!f_sapir_is_empty (field.value)) {
						//if (typeof (g_scroller_append_operator) == "undefined") {
							l_operator = g_sapir_search_scroller_multiple_operator;
						//} else {
						//	l_operator = g_scroller_append_operator;
						//}
						field.value = field.value + " " + l_operator + " " + decodeParam(text)  ;
					} else {
						field.value = decodeParam(text)  ;
					}
					l_returned_descr_filled = true;
				}
			}
		}

		if (!l_returned_descr_filled) {
			field.value = decodeParam(text);
		}
		/*
		if (!l_returned_descr_filled) {
			// ran
			if (getCodeElement(l_utility_frame, l_utility_frame_window, l_info_form) == "" )
				{
					if (field.value == whiteText) {
						field.value = decodeParam(text)  ;
					} else if (field.value > "") {
						if (a_ui_lang.toLowerCase () == "heb") {
							l_or = " או ";
						} else {
							l_or = " OR ";
						}
						field.value = field.value + l_or + decodeParam(text)  ;
					} else {
						field.value = decodeParam(text)  ;
					}
			} else {
				field.value = decodeParam(text)  ;
			}
		}
		*/
		if (field.value == "") {
			if (readOnlyOnEmptyReturn) {
				field.readOnly = true;
			}
		}

		// yair 8\12\04
		if (a_pb_dw.toLowerCase () == "y")  	{
			setDwScrollerValues (field, parent.opener, formNum);
		}

		//// yair 11\11\04 : rem on focus & click
		//field.fireEvent("onblur");
		//field.blur();

	}

	parent.close();
}

function getTextForm (a_utility_frame, a_utility_frame_window, a_info_form) {
	return a_info_form.textForm.value;
}
function getTextElement (a_utility_frame, a_utility_frame_window, a_info_form) {
	return a_info_form.textElement.value;
}
function getCodeForm(a_utility_frame, a_utility_frame_window, a_info_form) {
	return a_info_form.codeForm.value;
}
function getCodeElement (a_utility_frame, a_utility_frame_window, a_info_form) {
	return a_info_form.codeElement.value;
}
/*
function scrImgD(img) {
  document.images[img].src = 'images/lookup.bmp';
  return false
}
function scrImgU(img) {
  document.images[img].src = 'images/lookup.bmp';
  return false
}
*/
function setScrollerTitle (text) {
	//self.document.title = text;
  parent.document.title = text;	
}

function decodeParam(src) {
	var pos,end_pos;
	var asc, dst;
	dst = src;

	pos = dst.indexOf("!");
	while (pos >= 0) {
		end_pos = dst.indexOf(";",pos);
		asc = dst.substr(pos + 1,(end_pos - pos) - 1);
		var temp;
		temp = dst.substr(0,pos);
		temp += String. fromCharCode(parseInt(asc));
		temp += dst.substr(end_pos + 1);
		dst = temp;

		pos = dst.indexOf("!");
		//pos = dst.indexOf("!",pos + 1);
	}

	var l_decoded_text;
	l_decoded_text = dst;
	l_decoded_text = l_decoded_text.replace(/&#34;/g, "\"");
	l_decoded_text = l_decoded_text.replace(/&#39;/g, "\'");
	l_decoded_text = l_decoded_text.replace(/&#39;/g, "\'");
	l_decoded_text = l_decoded_text.replace(/&#47;/g, "\/");
	l_decoded_text = l_decoded_text.replace(/&#92;/g, "\\");
	l_decoded_text = l_decoded_text.replace(/&#60;/g, "<");
	l_decoded_text = l_decoded_text.replace(/&lt;/g, "<");
	l_decoded_text = l_decoded_text.replace(/&#62;/g, ">");
	l_decoded_text = l_decoded_text.replace(/&gt;/g, ">");
	l_decoded_text = l_decoded_text.replace(/&#38;/g, "&"); //  must be last !!!
	return l_decoded_text;
	
	//return dst;
}

function setDwScrollerValues (aScrollerField, aOpener, aOpenerFormNum) {
	// yair 8\12\04 : SetItem in addition to setting the HTML value of the field
	// so dw buffer will contain the new value from scroller

	var dataForm_name, dataForm_suffix, dataForm_suffix_pos, dw_name;
	var col_name, row_num, row_num_pos, item_val;

	dataForm_name = aOpener.document.forms[aOpenerFormNum].name;
	dataForm_suffix = new String ("_dataForm");
	dataForm_suffix_pos = new Number (dataForm_name.lastIndexOf (dataForm_suffix));
	dw_name = new String (dataForm_name.substring (0, dataForm_suffix_pos));

	col_name = new String (aScrollerField.name);
	row_num_pos = new Number (col_name.lastIndexOf ("_") + 1);
	row_num = new Number (col_name.substring (row_num_pos, col_name.length));
	col_name = col_name.substring (0, row_num_pos - 1);

	eval ("aOpener." + dw_name + ".SetItem (row_num + 1, col_name, aScrollerField.value)");
	
	//eval ("aOpener." + dw_name + ".SetRow (row_num + 1, \"returnScroller\")");
	//eval ("aOpener." + dw_name + ".SetColumn (row_num + 1, col_name)");
	
	//aOpener.focus ();
	//aScrollerField.focus ();
	//htmldw.currentControl = aScrollerField;
	//eval ("aOpener." + dw_name + ".AcceptText ()");
	
	/*
	alert ("setDwScrollerValues : " + aScrollerField.value);
	var l_changes_restore_el, l_changes_restore_value;
	l_changes_restore_el = f_sapir_get_element_by_id (aOpener.document, "sapir_changes_htmldw");
	alert ("a1 = " + l_changes_restore_el);
	if (!l_changes_restore_el) {		
		return;
	}
	alert ("a2 = " + l_changes_restore_el.value);
	*/
	
	aOpener.f_sapir_changes_backup ("htmldw", aScrollerField.value, row_num + 1, col_name);
	
	/*
	l_changes_restore_el = f_sapir_get_element_by_id (aOpener.document, "sapir_changes_htmldw");
	alert ("b1 = " + l_changes_restore_el);
	if (!l_changes_restore_el) {		
		return;
	}	
	alert ("b2 = " + l_changes_restore_el.value);
	*/
}

function f_sapir_scroller_details (a_elem_name, a_item_id, a_field, a_title, a_ui_lang, a_data_lang, a_images_folder, a_row_el_id) {
	var l_iframe, l_site, l_param, l_param2, l_htmldw_form, l_image, l_elem, l_row_el, l_old_row_el, l_url;
	
	// dim previously selected item
	/*
	if (g_last_detailed_elem != "")
	{
		l_elem = f_sapir_get_element_by_id (window.document, g_last_detailed_elem);
		l_image = l_elem.getElementsByTagName ("img") [0];
		if (f_sapir_exists (l_image)) {
			l_image.src = a_images_folder + "/dview/icon_info.gif";
		}
	}
	// highlight selected item
		
	l_elem = f_sapir_get_element_by_id (window.document, a_elem_name);
	l_image = l_elem.getElementsByTagName ("img") [0];
	if (f_sapir_exists (l_image)) {
			l_image.src = a_images_folder + "/dview/icon_info_o.gif";
	}
	*/
	g_last_detailed_elem = a_elem_name;
	
	// highlight selected row	
	if (g_sapir_scroller_state.selected_row_el_id  != a_row_el_id) {
			l_row_el = f_sapir_get_element_by_id (window.document, a_row_el_id);

			if (!f_sapir_is_empty (g_sapir_scroller_state.selected_row_el_id )) 	{
				l_old_row_el = f_sapir_get_element_by_id (window.document, g_sapir_scroller_state.selected_row_el_id);
				l_old_row_el.onmouseover = g_sapir_scroller_state.selected_row_mouseover;
				l_old_row_el.onmouseout = g_sapir_scroller_state.selected_row_mouseout;
				f_sapir_class_remove (l_old_row_el, "selected");
				f_sapir_class_remove (l_old_row_el, "blue");
			}

			g_sapir_scroller_state.selected_row_el_id = a_row_el_id;
			g_sapir_scroller_state.selected_row_mouseover = l_row_el.onmouseover;
			g_sapir_scroller_state.selected_row_mouseout = l_row_el.onmouseout;
			f_sapir_class_prepend (l_row_el, "selected");

			//if (window.captureEvents) {
			//	l_row_el.captureEvents (Event.mouseover);
			//	l_row_el.captureEvents (Event.mouseout);
			//} else {
				l_row_el.onmouseover = function () {return;};
				l_row_el.onmouseout = function () {return;};
			//}
	}

	l_htmldw_form =  f_sapir_form_get_by_name ("htmldw_submitForm");
	l_site = f_sapir_selflinkarg (l_htmldw_form, "site");
	l_param = f_sapir_selflinkarg (l_htmldw_form, "param");
	l_param2 = f_sapir_selflinkarg (l_htmldw_form, "param2");
	
	l_param += "<item_id>" + a_item_id + "</item_id>"
	l_param += "<item_title>" + a_title + "</item_title>"

	// encode
	l_param = new String (l_param).replace(/#/g, "%23");
	l_param = new String (l_param).replace(/&quot;/g, "%26quot;");
	l_param = new String (l_param).replace(/&apos;/g, "%26apos;");
	//l_param = new String (l_param).replace(/</g, "&lt;");
	//l_param = new String (l_param).replace(/>/g, "&gt;");
	l_param2 = new String (l_param2).replace(/#/g, "%23");
	l_param2 = new String (l_param2).replace(/&quot;/g, "%26quot;");
	l_param2 = new String (l_param2).replace(/&apos;/g, "%26apos;");
	l_param2 = new String (l_param2).replace(/</g, "&lt;");
	l_param2 = new String (l_param2).replace(/>/g, "&gt;");

	//g_sapir_unload_popup_cancel  = true;
	//debugger;
	l_iframe = f_sapir_get_frame ("scr_details");
	
	l_url = "scroller_details.asp?"
				+ "lang=" + a_ui_lang
				+ "&dlang=" + a_data_lang
				+ "&site=" + l_site
				+ "&param=" + l_param
				+ "&param2=" + l_param2
				+ "&module=search"
				+ "&page=scroller_details"

	f_sapir_location_replace (l_url, l_iframe, true);
	
	/*
	f_sapir_frame_document (l_iframe).location.replace ("scroller_details.asp?"
										+ "lang=" + a_ui_lang
										+ "&dlang=" + a_data_lang
										+ "&site_dtl=" + l_site_dtl
										+ "&param=" + l_param
										+ "&param2=" + l_param2
										+ "&module=search"
										+ "&page=scroller_details"
										);
	*/
}

function f_sapir_scroller_details_nop (a_elem_name, a_item_id, a_field, a_title, a_ui_lang, a_data_lang, a_images_folder, a_row_el_id) {
	var l_iframe, l_site, l_param, l_param2, l_htmldw_form, l_image, l_elem, l_row_el, l_old_row_el;
	
	// dim previously selected item
	if (g_last_detailed_elem != "")
	{
		l_elem = f_sapir_get_element_by_id (window.document, g_last_detailed_elem);
		l_image = l_elem.getElementsByTagName ("img") [0];
		if (f_sapir_exists (l_image)) {
			l_image.src = a_images_folder + "/dview/icon_info.gif";
		}
	}
	// highlight selected item
		
	l_elem = f_sapir_get_element_by_id (window.document, a_elem_name);
	l_image = l_elem.getElementsByTagName ("img") [0];
	if (f_sapir_exists (l_image)) {
			l_image.src = a_images_folder + "/dview/icon_info_o.gif";
	}
	g_last_detailed_elem = a_elem_name;
	
	// highlight selected row	
	if (g_sapir_scroller_state.selected_row_el_id  != a_row_el_id) {
			l_row_el = f_sapir_get_element_by_id (window.document, a_row_el_id);

			if (!f_sapir_is_empty (g_sapir_scroller_state.selected_row_el_id )) 	{
				l_old_row_el = f_sapir_get_element_by_id (window.document, g_sapir_scroller_state.selected_row_el_id);
				l_old_row_el.onmouseover = g_sapir_scroller_state.selected_row_mouseover;
				l_old_row_el.onmouseout = g_sapir_scroller_state.selected_row_mouseout;
				f_sapir_class_remove (l_old_row_el, "selected");
				f_sapir_class_remove (l_old_row_el, "blue");
			}

			g_sapir_scroller_state.selected_row_el_id = a_row_el_id;
			g_sapir_scroller_state.selected_row_mouseover = l_row_el.onmouseover;
			g_sapir_scroller_state.selected_row_mouseout = l_row_el.onmouseout;
			f_sapir_class_prepend (l_row_el, "selected");

			//if (window.captureEvents) {
			//	l_row_el.captureEvents (Event.mouseover);
			//	l_row_el.captureEvents (Event.mouseout);
			//} else {
				l_row_el.onmouseover = function () {return;};
				l_row_el.onmouseout = function () {return;};
			//}
	}
}

function f_sapir_scroller_edit (a_elem_name, a_item_id, a_field, a_ui_lang, a_data_lang, a_images_folder) {
	//f_sapir_alert ("f_sapir_scroller_zoom (" + a_item_id + ", " + a_field + ", " + a_ui_lang + ", " + a_data_lang + ")");
	var l_iframe, l_site, l_param, l_param2, l_htmldw_form, l_image, l_elem;
	
	// dim previously selected item
	if (g_last_edited_elem != "")
	{
		l_elem = f_sapir_get_element_by_id (window.document, g_last_edited_elem);
		l_image = l_elem.getElementsByTagName ("img") [0];
		l_image.src = a_images_folder + "/dview/icon_update.gif";
	}
	// highlight selected item
	l_elem = f_sapir_get_element_by_id (window.document, a_elem_name);
	l_image = l_elem.getElementsByTagName ("img") [0];
	l_image.src = a_images_folder + "/dview/icon_update_over.gif";
	g_last_edited_elem = a_elem_name;
		
	l_htmldw_form = f_sapir_get_element_by_id (window.document, "htmldw_submitForm");
	l_site = f_sapir_get_element_by_id (l_htmldw_form, "site").value;
	l_param = f_sapir_get_element_by_id (l_htmldw_form, "param").value;
	l_param2 = f_sapir_get_element_by_id (l_htmldw_form, "param2").value;
	
	l_param += "<item_id>" + a_item_id + "</item_id>"
	
	//TODO - edit the selected item
	alert("Edit is not available at this point...");

//	l_iframe = window.document.frames ["scr_details"];
//	l_iframe.document.location.replace ("scroller.asp?"
//										+ "lang=" + a_ui_lang
//										+ "&dlang=" + a_data_lang
//										+ "&site_dtl=" + l_site_dtl
//										+ "&param=" + l_param
//										+ "&param2=" + l_param2
//										+ "&module=search"
//										+ "&page=scroller_details"
//										);
}

function f_sapir_scroller_detail_lang_change_handler (a_el) {
	//debugger;
	try {
	var l_lang_el, l_details_iframe, l_new_lang, l_details_url, l_details_newrl;

	l_details_iframe = f_sapir_get_frame ("scr_details");
	if (!f_sapir_exists (l_details_iframe)) {
		return;
	}

	l_lang_el = a_el; //f_sapir_event_element (a_event);	
	l_new_lang = l_lang_el.options [l_lang_el.selectedIndex].value;

	if (g_sapir_browser_type != "ie") {
		l_details_url = f_sapir_frame_document (l_details_iframe).location.toString ();
	} else {
		l_details_url = l_details_iframe.location;
	}

	l_details_newrl = f_sapir_url_set_arg (new String (l_details_url), "dlang", l_new_lang);
	l_details_newrl  = f_sapir_url_param_set_key (l_details_newrl , "dlang", l_new_lang) ;

	f_sapir_location_replace (l_details_newrl, l_details_iframe, true);
	} catch (scroller_detail_lang_change_exception) {
		//debugger;
		f_sapir_exception ("scroller_utils", "scroller_detail_lang_change", scroller_detail_lang_change_exception);
	}
}

function f_sapir_scroller_row_mouseover_cancel (a_event) {
	if (!(a_event)) {
		a_event = window.event;
	}
	f_sapir_event_cancel (a_event);
}

function sapir_scroller_state () {
	this.table_name = "";
	this.selected_row_el_id = "";
	this.selected_row_mouseover = null;
	this.selected_row_mouseout= null;

	this.row_el = null;
	this.mouse_over = "";
	this.mouse_out = "";
}

function htmldw_OnSubmit () {
	/*
	if (g_sapir_page_id == "scroller" || g_sapir_page_id == "cat_scroller") {
		g_sapir_unload_popup = true;
	}
	*/
	return 0;
}

function f_sapir_scroller_criteria_submit_pre () {
	var l_search_value, l_all_search_values, l_fields_idx, l_field_id, l_field_dw_row;

	if (typeof (g_sapir_scroller_state) != "undefined") {
		if (g_sapir_scroller_state.search_is_mandatory == "0") {
			return 0;
		}
	}
	
	// verify at least one search field is filled up
	l_all_search_values = "";
	for (l_fields_idx = 0; l_fields_idx < 10; l_fields_idx++) {
		l_field_id = "get_var_" + new String (l_fields_idx);
		l_field_dw_row = l_fields_idx + 1;
		if (!f_sapir_exists (f_sapir_get_element_by_id (window.document, l_field_id))) {
			continue;
		}
		l_search_value = htmldw.GetItem (l_field_dw_row, "get_var");
		if (!f_sapir_is_empty (l_search_value)) {
			l_all_search_values += l_search_value;
		}
	}

	if (!f_sapir_is_empty (l_all_search_values)) {
		return 0;
	}

	if (typeof (g_sapir_scroller_state) == "undefined") {
		alert ("please enter a search value");
		return 1;
	}

	if (typeof (g_sapir_scroller_state.empty_search_msg) == "undefined") {
		alert ("please enter a search value");
		return 1;
	}
	
	if (f_sapir_is_empty (g_sapir_scroller_state.empty_search_msg)) {
		alert ("please enter a search value");
		return 1;
	}
	
	alert (g_sapir_scroller_state.empty_search_msg);
	return 1;
	
	// *** validate ALL criteria fields
}

////////////////////// end of scroller_utils.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from calendar_flat.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/*  Copyright Mihai Bazon, 2002-2005  |  www.bazon.net/mishoo
	/*  Copyright Mihai Bazon, 2002-2005  |  www.bazon.net/mishoo
 * -----------------------------------------------------------
 *
 * The DHTML Calendar, version 1.0 "It is happening again"
 *
 * Details and latest version at:
 * www.dynarch.com/projects/calendar
 *
 * This script is developed by Dynarch.com.  Visit us at www.dynarch.com.
 *
 * This script is distributed under the GNU Lesser General Public License.
 * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
 */

// $Id: calendar.js,v 1.51 2005/03/07 16:44:31 mishoo Exp $

/** The Calendar object constructor. */
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
	// member variables
	this.activeDiv = null;
	this.currentDateEl = null;
	this.getDateStatus = null;
	this.getDateToolTip = null;
	this.getDateText = null;
	this.timeout = null;
	this.onSelected = onSelected || null;
	this.onClose = onClose || null;
	this.dragging = false;
	this.hidden = false;
	this.minYear = 1970;
	this.maxYear = 2050;
	this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"];
	this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"];
	this.isPopup = true;
	this.weekNumbers = true;
	this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD; // 0 for Sunday, 1 for Monday, etc.
	this.showsOtherMonths = false;
	this.dateStr = dateStr;
	this.ar_days = null;
	this.showsTime = false;
	this.time24 = true;
	this.yearStep = 2;
	this.hiliteToday = true;
	this.multiple = null;
	// HTML elements
	this.table = null;
	this.element = null;
	this.tbody = null;
	this.firstdayname = null;
	// Combo boxes
	this.monthsCombo = null;
	this.yearsCombo = null;
	this.hilitedMonth = null;
	this.activeMonth = null;
	this.hilitedYear = null;
	this.activeYear = null;
	// Information
	this.dateClicked = false;
	
	var l_prev_sapir_year_input, l_prev_sapir_year_div;
	l_prev_sapir_year_input = f_sapir_get_element_by_id (window.document, "sapir_year_input");
	if (f_sapir_exists (l_prev_sapir_year_input)) {
		l_prev_sapir_year_div = f_sapir_parent (l_prev_sapir_year_input);
		l_prev_sapir_year_div.removeChild (l_prev_sapir_year_input);
	}
	
	this.sapir_year_div = null;
	this.sapir_year_label = null;
	this.sapir_year_input = null;
	
	// one-time initializations
	if (typeof Calendar._SDN == "undefined") {
		// table of short day names
		if (typeof Calendar._SDN_len == "undefined")
			Calendar._SDN_len = 3;
		var ar = new Array();
		for (var i = 8; i > 0;) {
			ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len);
		}
		Calendar._SDN = ar;
		// table of short month names
		if (typeof Calendar._SMN_len == "undefined")
			Calendar._SMN_len = 3;
		ar = new Array();
		for (var i = 12; i > 0;) {
			ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len);
		}
		Calendar._SMN = ar;
	}
	
	this.sapir_keydown_backup = document.onkeydown;
	document.onkeydown = null;
};

// ** constants

/// "static", needed for event handlers.
Calendar._C = null;

/// detect a special case of "web browser"
Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
		   !/opera/i.test(navigator.userAgent) );

Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) );

/// detect Opera browser
Calendar.is_opera = /opera/i.test(navigator.userAgent);

/// detect KHTML-based browsers
Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);

// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate
//        library, at some point.
var g_cal_debug = true;
Calendar.getAbsolutePos = function(el) {
	/*
	if (g_cal_debug == true) {
		g_cal_debug = false;
		f_sapir_alert ("getAbsolutePos : " + document.body.scrollTop + ", " +  document.body.offsetTop);
	}
	*/
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = this.getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
};

Calendar.isRelated = function (el, evt) {
	var l_evt_type = evt.type;
	var related = evt.relatedTarget;
	if (related == l_evt_type) {
		return false;
	}
	if (!related) {		
		if (l_evt_type == "mouseover") {
			related = evt.fromElement;
		} else if (l_evt_type == "mouseout") {
			related = evt.toElement;
		}
	}
	while (related) {
		if (related == el) {
			return true;
		}
		related = f_sapir_parent (related);
		//related = related.parentNode;
	}
	return false;
};

Calendar.removeClass = function(el, className) {
	if (!(el && el.className)) {
		return;
	}
	var cls = el.className.split(" ");
	var ar = new Array();
	for (var i = cls.length; i > 0;) {
		if (cls[--i] != className) {
			ar[ar.length] = cls[i];
		}
	}
	el.className = ar.join(" ");
};

Calendar.addClass = function(el, className) {
	Calendar.removeClass(el, className);
	el.className += " " + className;
};

// FIXME: the following 2 functions totally suck, are useless and should be replaced immediately.
Calendar.getElement = function(ev) {
	//debugger;
	//var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget;
	var f = f_sapir_event_element (ev);
	while (f.nodeType != 1 || /^div$/i.test(f.tagName))
		f = f_sapir_parent (f);
		//f = f.parentElement;
	return f;
};

Calendar.getTargetElement = function(ev) {
	//var f = Calendar.is_ie ? window.event.srcElement : ev.target;
	var f = window.event ? window.event.srcElement : ev.target;
	
	while (f.nodeType != 1)
		f = f_sapir_parent (f);
		//f = f.parentNode;
	return f;
};

Calendar.stopEvent = function(ev) {
	ev || (ev = window.event);
	if (Calendar.is_ie) {
		ev.cancelBubble = true;
		ev.returnValue = false;
	} else {
		ev.preventDefault();
		ev.stopPropagation();
	}
	return false;
};

Calendar.addEvent = function(el, evname, func) {
	f_sapir_event_add (el, evname, func);
	/*
	if (el.attachEvent) { // IE
		el.attachEvent("on" + evname, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	} else {
		el["on" + evname] = func;
	}
	*/
};

Calendar.removeEvent = function(el, evname, func) {
	//debugger;
	f_sapir_event_remove (el, evname, func);
	/*
	if (el.detachEvent) { // IE
		el.detachEvent("on" + evname, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(evname, func, true);
	} else {
		el["on" + evname] = null;
	}
	*/
};

Calendar.createElement = function(type, parent) {
	var el = null;
	if (document.createElementNS) {
		// use the XHTML namespace; IE won't normally get here unless
		// _they_ "fix" the DOM2 implementation.
		el = document.createElementNS("http://www.w3.org/1999/xhtml", type);
	} else {
		el = document.createElement(type);
	}
	if (typeof parent != "undefined") {
		parent.appendChild(el);
	}
	return el;
};

// END: UTILITY FUNCTIONS

// BEGIN: CALENDAR STATIC FUNCTIONS

/** Internal -- adds a set of events to make some element behave like a button. */
Calendar._add_evs = function(el) {
	with (Calendar) {
		addEvent(el, "mouseover", dayMouseOver);
		addEvent(el, "mousedown", dayMouseDown);
		addEvent(el, "mouseout", dayMouseOut);
		if (is_ie) {
			addEvent(el, "dblclick", dayMouseDblClick);
			el.setAttribute("unselectable", true);
		}
	}
};

Calendar.findMonth = function(el) {
	if (typeof el.month != "undefined") {
		return el;
	} else if (typeof el.parentNode.month != "undefined") {
		return f_sapir_parent (el);
		//return el.parentNode;
	}
	return null;
};

Calendar.findYear = function(el) {
	if (typeof el.year != "undefined") {
		return el;
	} else if (typeof el.parentNode.year != "undefined") {
		return f_sapir_parent (el);
		//return el.parentNode;
	}
	return null;
};

Calendar.showMonthsCombo = function () {
	return; // yair 22.3.09 : dont show combo since selects date, plus cut in the middle
	var cal = Calendar._C;
	if (!cal) {
		return false;
	}
	var cal = cal;
	var cd = cal.activeDiv;
	var mc = cal.monthsCombo;
	if (cal.hilitedMonth) {
		Calendar.removeClass(cal.hilitedMonth, "hilite");
	}
	if (cal.activeMonth) {
		Calendar.removeClass(cal.activeMonth, "active");
	}
	var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];
	Calendar.addClass(mon, "active");
	cal.activeMonth = mon;
	var s = mc.style;
	s.display = "block";
	if (cd.navtype < 0)
		s.left = cd.offsetLeft + "px";
	else {
		var mcw = mc.offsetWidth;
		if (typeof mcw == "undefined")
			// Konqueror brain-dead techniques
			mcw = 50;
		s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px";
	}
	s.top = (cd.offsetTop + cd.offsetHeight) + "px";
};

Calendar.showYearsCombo = function (fwd) {
	return; // yair 22.3.09 : dont show combo since selects date, plus cut in the middle
	var cal = Calendar._C;
	if (!cal) {
		return false;
	}
	var cal = cal;
	var cd = cal.activeDiv;
	var yc = cal.yearsCombo;
	if (cal.hilitedYear) {
		Calendar.removeClass(cal.hilitedYear, "hilite");
	}
	if (cal.activeYear) {
		Calendar.removeClass(cal.activeYear, "active");
	}
	cal.activeYear = null;
	var Y = cal.date.getFullYear() + (fwd ? 1 : -1);
	var yr = yc.firstChild;
	var show = false;
	for (var i = 12; i > 0; --i) {
		if (Y >= cal.minYear && Y <= cal.maxYear) {
			yr.innerHTML = Y;
			yr.year = Y;
			yr.style.display = "block";
			show = true;
		} else {
			yr.style.display = "none";
		}
		yr = yr.nextSibling;
		Y += fwd ? cal.yearStep : -cal.yearStep;
	}
	if (show) {
		var s = yc.style;
		s.display = "block";
		if (cd.navtype < 0)
			s.left = cd.offsetLeft + "px";
		else {
			var ycw = yc.offsetWidth;
			if (typeof ycw == "undefined")
				// Konqueror brain-dead techniques
				ycw = 50;
			s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px";
		}
		s.top = (cd.offsetTop + cd.offsetHeight) + "px";
	}
};

// event handlers

Calendar.tableMouseUp = function(ev) {
	//debugger;
	//f_cal_trace ("tableMouseUp");
	var cal = Calendar._C;
	if (!cal) {
		//f_cal_trace ("tableMouseUp : !cal");
		return false;
	}
	//f_cal_trace ("tableMouseUp : cal");
	if (cal.timeout) {
		clearTimeout(cal.timeout);
	}
	var el = cal.activeDiv;
	//f_cal_trace ("tableMouseUp : el == " + el);
	if (!el) {
		return false;
	}

	var target = Calendar.getTargetElement(ev);
	//f_cal_trace ("tableMouseUp : target == " + target);
	ev || (ev = window.event);
	Calendar.removeClass(el, "active");
	//f_cal_trace ("target == el ? " + (target == el));
	//f_cal_trace ("target parent == el ? " + (f_sapir_parent (target) == el));
	if (target == el || f_sapir_parent (target) == el) {
		//f_cal_trace ("tableMouseUp : cellClick");
		Calendar.cellClick(el, ev);
	}
	var mon = Calendar.findMonth(target);
	//f_cal_trace ("tableMouseUp : mon == " + mon);
	var date = null;

	if (mon) {
		date = new Date(cal.date);
		//f_cal_trace ("tableMouseUp : date == " + date);
		if (mon.month != date.getMonth()) {
			date.setMonth(mon.month);
			cal.setDate(date);
			cal.dateClicked = false;
			cal.callHandler();
		}
	} else {
		var year = Calendar.findYear(target);
		//f_cal_trace ("tableMouseUp : year == " + year);
		if (year) {
			date = new Date(cal.date);
			if (year.year != date.getFullYear()) {
				date.setFullYear(year.year);
				cal.setDate(date);
				cal.dateClicked = false;
				cal.callHandler();
			}
		}
	}

	with (Calendar) {
		removeEvent(document, "mouseup", tableMouseUp);
		removeEvent(document, "mouseover", tableMouseOver);
		removeEvent(document, "mousemove", tableMouseOver);
		cal._hideCombos();
		_C = null;
		return stopEvent(ev);
	}
};

Calendar.tableMouseOver = function (ev) {
	var cal = Calendar._C;
	if (!cal) {
		return;
	}
	var el = cal.activeDiv;
	var target = Calendar.getTargetElement(ev);
	if (target == el || f_sapir_parent (target) == el) {
		Calendar.addClass(el, "hilite active");
		Calendar.addClass(f_sapir_parent (el), "rowhilite");
	} else {
		if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2)))
			Calendar.removeClass(el, "active");
		Calendar.removeClass(el, "hilite");
		Calendar.removeClass(f_sapir_parent (el), "rowhilite");
	}
	ev || (ev = window.event);
	if (el.navtype == 50 && target != el) {
		var pos = Calendar.getAbsolutePos(el);
		var w = el.offsetWidth;
		var x = ev.clientX;
		var dx;
		var decrease = true;
		if (x > pos.x + w) {
			dx = x - pos.x - w;
			decrease = false;
		} else
			dx = pos.x - x;

		if (dx < 0) dx = 0;
		var range = el._range;
		var current = el._current;
		var count = Math.floor(dx / 10) % range.length;
		for (var i = range.length; --i >= 0;)
			if (range[i] == current)
				break;

		while (count-- > 0)
			if (decrease) {
				if (--i < 0)
					i = range.length - 1;
			} else if ( ++i >= range.length )
				i = 0;
		var newval = range[i];
		el.innerHTML = newval;

		cal.onUpdateTime();
	}
	var mon = Calendar.findMonth(target);
	if (mon) {
		if (mon.month != cal.date.getMonth()) {
			if (cal.hilitedMonth) {
				Calendar.removeClass(cal.hilitedMonth, "hilite");
			}
			Calendar.addClass(mon, "hilite");
			cal.hilitedMonth = mon;
		} else if (cal.hilitedMonth) {
			Calendar.removeClass(cal.hilitedMonth, "hilite");
		}
	} else {
		if (cal.hilitedMonth) {
			Calendar.removeClass(cal.hilitedMonth, "hilite");
		}
		var year = Calendar.findYear(target);
		if (year) {
			if (year.year != cal.date.getFullYear()) {
				if (cal.hilitedYear) {
					Calendar.removeClass(cal.hilitedYear, "hilite");
				}
				Calendar.addClass(year, "hilite");
				cal.hilitedYear = year;
			} else if (cal.hilitedYear) {
				Calendar.removeClass(cal.hilitedYear, "hilite");
			}
		} else if (cal.hilitedYear) {
			Calendar.removeClass(cal.hilitedYear, "hilite");
		}
	}
	return Calendar.stopEvent(ev);
};

Calendar.tableMouseDown = function (ev) {
	if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) {
		return Calendar.stopEvent(ev);
	}
};

Calendar.calDragIt = function (ev) {
	var cal = Calendar._C;
	if (!(cal && cal.dragging)) {
		return false;
	}
	var posX;
	var posY;
	if (Calendar.is_ie) {
		posY = window.event.clientY + document.body.scrollTop;
		posX = window.event.clientX + document.body.scrollLeft;
	} else {
		posX = ev.pageX;
		posY = ev.pageY;
	}
	cal.hideShowCovered();
	var st = cal.element.style;
	st.left = (posX - cal.xOffs) + "px";
	st.top = (posY - cal.yOffs) + "px";
	return Calendar.stopEvent(ev);
};

Calendar.calDragEnd = function (ev) {
	var cal = Calendar._C;
	if (!cal) {
		return false;
	}
	cal.dragging = false;
	with (Calendar) {
		removeEvent(document, "mousemove", calDragIt);
		removeEvent(document, "mouseup", calDragEnd);
		tableMouseUp(ev);
	}
	cal.hideShowCovered();
};

Calendar.dayMouseDown = function(ev) {
	//debugger;
	var el = Calendar.getElement(ev);
	if (el.disabled) {
		return false;
	}
	
	var cal = el.calendar;
	cal.activeDiv = el;
	Calendar._C = cal;
	if (el.navtype != 300) with (Calendar) {
		if (el.navtype == 50) {
			el._current = el.innerHTML;
			addEvent(document, "mousemove", tableMouseOver);
		} else
			addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver);
		addClass(el, "hilite active");
		addEvent(document, "mouseup", tableMouseUp);
	} else if (cal.isPopup) {
		cal._dragStart(ev);
	}
	if (el.navtype == -1 || el.navtype == 1) {
		if (cal.timeout) clearTimeout(cal.timeout);
		cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250);
	} else if (el.navtype == -2 || el.navtype == 2) {
		if (cal.timeout) clearTimeout(cal.timeout);
		cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250);
	} else {
		cal.timeout = null;
	}
	return Calendar.stopEvent(ev);
};

Calendar.dayMouseDblClick = function(ev) {
	//debugger;
	//f_cal_trace ("dayMouseDblClick");
	Calendar.cellClick(Calendar.getElement(ev), ev || window.event);
	if (Calendar.is_ie) {
		document.selection.empty();
	}
};

Calendar.dayMouseOver = function(ev) {
	var el = Calendar.getElement(ev);
	if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) {
		return false;
	}
	if (el.ttip) {
		if (el.ttip.substr(0, 1) == "_") {
			el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1);
		}
		el.calendar.tooltips.innerHTML = el.ttip;
	}
	if (el.navtype != 300) {
		Calendar.addClass(el, "hilite");
		if (el.caldate) {
			Calendar.addClass(f_sapir_parent (el), "rowhilite");
		}
	}
	return Calendar.stopEvent(ev);
};

Calendar.dayMouseOut = function(ev) {
	with (Calendar) {
		var el = getElement(ev);
		if (isRelated(el, ev) || _C || el.disabled)
			return false;
		removeClass(el, "hilite");
		if (el.caldate)
			removeClass(f_sapir_parent (el), "rowhilite");
		if (el.calendar)
			el.calendar.tooltips.innerHTML = _TT["SEL_DATE"];
		return stopEvent(ev);
	}
};

/**
 *  A generic "click" handler :) handles all types of buttons defined in this
 *  calendar.
 */
Calendar.cellClick = function(el, ev) {
	//debugger;
	var cal = el.calendar;
	var closing = false;
	var newdate = false;
	var date = null;

	if (typeof el.navtype == "undefined") {
		if (cal.currentDateEl) {
			Calendar.removeClass(cal.currentDateEl, "selected");
			Calendar.addClass(el, "selected");
			closing = (cal.currentDateEl == el);
			if (!closing) {
				cal.currentDateEl = el;
			}
		}
		cal.date.setDateOnly(el.caldate);
		date = cal.date;
		var other_month = !(cal.dateClicked = !el.otherMonth);
		if (!other_month && !cal.currentDateEl)
			cal._toggleMultipleDate(new Date(date));
		else
			newdate = !el.disabled;
		// a date was clicked
		if (other_month)
			cal._init(cal.firstDayOfWeek, date);
	} else {
		if (el.navtype == 200) {
			Calendar.removeClass(el, "hilite");
			cal.callCloseHandler();
			return;
		}
		date = new Date(cal.date);
		if (el.navtype == 0)
			date.setDateOnly(new Date()); // TODAY
		// unless "today" was clicked, we assume no date was clicked so
		// the selected handler will know not to close the calenar when
		// in single-click mode.
		// cal.dateClicked = (el.navtype == 0);
		cal.dateClicked = false;
		var year = date.getFullYear();
		var mon = date.getMonth();
		function setMonth(m) {
			var day = date.getDate();
			var max = date.getMonthDays(m);
			if (day > max) {
				date.setDate(max);
			}
			date.setMonth(m);
		};
		switch (el.navtype) {
		    case 400:
			Calendar.removeClass(el, "hilite");
			var text = Calendar._TT["ABOUT"];
			if (typeof text != "undefined") {
				text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : "";
			} else {
				// FIXME: this should be removed as soon as lang files get updated!
				text = "Help and about box text is not translated into this language.\n" +
					"If you know this language and you feel generous please update\n" +
					"the corresponding file in \"lang\" subdir to match calendar-en.js\n" +
					"and send it back to <mihai_bazon@yahoo.com> to get it into the distribution  ;-)\n\n" +
					"Thank you!\n" +
					"http://dynarch.com/mishoo/calendar.epl\n";
			}
			alert(text);
			return;
		    case -2:
			if (year > cal.minYear) {
				date.setFullYear(year - 1);
			}
			break;
		    case -1:
			if (mon > 0) {
				setMonth(mon - 1);
			} else if (year-- > cal.minYear) {
				date.setFullYear(year);
				setMonth(11);
			}
			break;
		    case 1:
			if (mon < 11) {
				setMonth(mon + 1);
			} else if (year < cal.maxYear) {
				date.setFullYear(year + 1);
				setMonth(0);
			}
			break;
		    case 2:
			if (year < cal.maxYear) {
				date.setFullYear(year + 1);
			}
			break;
		    case 100:
			cal.setFirstDayOfWeek(el.fdow);
			return;
		    case 50:
			var range = el._range;
			var current = el.innerHTML;
			for (var i = range.length; --i >= 0;)
				if (range[i] == current)
					break;
			if (ev && ev.shiftKey) {
				if (--i < 0)
					i = range.length - 1;
			} else if ( ++i >= range.length )
				i = 0;
			var newval = range[i];
			el.innerHTML = newval;
			cal.onUpdateTime();
			return;
		    case 0:
			// TODAY will bring us here
			if ((typeof cal.getDateStatus == "function") &&
			    cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) {
				return false;
			}
			break;
		}
		if (!date.equalsTo(cal.date)) {
			cal.setDate(date);
			//sapir, yair, 08\12\05 : newdate = true;
		} else if (el.navtype == 0)
			newdate = closing = true;
	}
	if (newdate) {
		ev && cal.callHandler();
	}
	if (closing) {
		Calendar.removeClass(el, "hilite");
		ev && cal.callCloseHandler();
	}
};

// END: CALENDAR STATIC FUNCTIONS

// BEGIN: CALENDAR OBJECT FUNCTIONS

/**
 *  This function creates the calendar inside the given parent.  If _par is
 *  null than it creates a popup calendar inside the BODY element.  If _par is
 *  an element, be it BODY, then it creates a non-popup calendar (still
 *  hidden).  Some properties need to be set before calling this function.
 */
Calendar.prototype.create = function (_par) {
	if (typeof (g_sapir_cat_ui_active) != "undefined") {
		if (g_sapir_cat_ui_active) {
			if (typeof (g_input_disabled) != "undefined") {
				if (g_input_disabled) {
					return;
				}
			}
		}
	}
	
	var parent = null;
	if (! _par) {
		// default parent is the document body, in which case we create
		// a popup calendar.
		parent = document.getElementsByTagName("body")[0];
		this.isPopup = true;
	} else {
		parent = _par;
		this.isPopup = false;
	}

	this.date = this.dateStr ? new Date(this.dateStr) : new Date();

	var table = Calendar.createElement("table");
	this.table = table;
	table.cellSpacing = 0;
	table.cellPadding = 0;
	table.calendar = this;
	Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown);

	var div = Calendar.createElement("div");
	this.element = div;
	div.className = "calendar";
	if (this.isPopup) {
		div.style.position = "absolute";
		div.style.display = "none";
	}

	var l_sapir_year_div, l_sapir_year_label, l_sapir_year_label_text, l_sapir_year_input, l_sapir_year_set;

	//f_sapir_alert (this.sapir_year_div + ", " + this.sapir_year_label + ", " + this.sapir_year_input);
	
	//f_sapir_alert ("ggg = " + f_sapir_get_element_by_id (window.document, "sapir_year_input"));
	
	l_sapir_year_div= Calendar.createElement ("div");
	l_sapir_year_div.calendar = this;
	l_sapir_year_div.className = "sapir_calendar_year_div";
	
	if (g_sapir_lang.toLowerCase () == "heb") {
		l_sapir_year_div.dir = "rtl";
	} else {
		l_sapir_year_div.dir = "ltr";
	}
	
	this.sapir_year_div = l_sapir_year_div;
	
	l_sapir_year_label = Calendar.createElement ("label");
	l_sapir_year_label.className = "sapir_calendar_year_label";
	this.sapir_year_label = l_sapir_year_label;
	
	l_sapir_year_label_text = window.document.createTextNode (Calendar._TT["SAPIR_YEAR_LABEL"]);
	l_sapir_year_label.appendChild  (l_sapir_year_label_text );
	l_sapir_year_div.appendChild(l_sapir_year_label);

	//if (Calendar.is_ie ) {
	//	l_sapir_year_input = Calendar.createElement ("<input type='text' name='sapir_year_input' id='sapir_year_input'  VALUE='1942' class='sapir_year_input'>");
	//} else {

		l_sapir_year_input = Calendar.createElement ("input");
		l_sapir_year_input.className = "sapir_calendar_year_input";
		
		this.sapir_year_input = l_sapir_year_input;
		l_sapir_year_input.setAttribute ("id", "sapir_year_input"); // *** unique ???
		l_sapir_year_input.setAttribute ("name", "sapir_year_input"); // *** unique ???
		l_sapir_year_input.type = "text";
		//l_sapir_year_input.setAttribute ("type", "text");
		l_sapir_year_input.setAttribute ("tabIndex", "1");
		//l_sapir_year_input.ttip = Calendar._TT["SAPIR_YEAR_INPUT"];
		l_sapir_year_input.calendar = this;
		
		f_sapir_event_add (l_sapir_year_input, "blur", "f_sapir_calendar_year_onblur");
	//}
	l_sapir_year_div.appendChild(l_sapir_year_input);

	/*
	l_sapir_year_set = Calendar.createElement ("input");
	l_sapir_year_set.className = "sapir_calendar_year_set";
	l_sapir_year_set.setAttribute ("id", "sapir_year_set"); // *** unique ???
	l_sapir_year_set.setAttribute ("name", "sapir_year_set"); // *** unique ???

	l_sapir_year_set.type = "button";
	l_sapir_year_set.value = Calendar._TT["SAPIR_GO_VALUE"];
	//l_sapir_year_set.setAttribute ("value", "=>");
	*/
	f_sapir_year_set = function (ev) {
		var el, l_year_el_id , l_year_el, l_date, cal;
		if (window.event) {
			ev = window.event;
		}
		el = Calendar.getElement (ev);
		//f_cal_trace ("f_sapir_year_set : " + el.name + " = " + el.value);
		f_sapir_year_set2 (el, "sapir_year_input");
	}
	
	/*
	//f_sapir_event_add (l_sapir_year_set, "click", f_sapir_year_set);

	l_sapir_year_div.appendChild(l_sapir_year_set);
	*/
	
	//div.appendChild(l_sapir_year_div);

	div.appendChild(table);

	var thead = Calendar.createElement("thead", table);
	var cell = null;
	var row = null;

	var cal = this;
	var hh = function (text, cs, navtype) {
		cell = Calendar.createElement("td", row);
		cell.colSpan = cs;
		cell.className = "button";
		if (navtype != 0 && Math.abs(navtype) <= 2)
			cell.className += " nav";
		Calendar._add_evs(cell);
		cell.calendar = cal;
		cell.navtype = navtype;
		cell.innerHTML = "<div unselectable='on'>" + text + "</div>";
		return cell;
	};

	row = Calendar.createElement("tr", thead);
	var title_length = 6;
	(this.isPopup) && --title_length;
	(this.weekNumbers) && ++title_length;

	hh("?", 1, 400).ttip = Calendar._TT["INFO"];
	this.title = hh("", title_length, 300);
	this.title.className = "title";
	if (this.isPopup) {
		this.title.ttip = Calendar._TT["DRAG_TO_MOVE"];
		this.title.style.cursor = "move";
		hh("&#x00d7;", 1, 200).ttip = Calendar._TT["CLOSE"];
	}

	var l_sapir_tr = Calendar.createElement("tr", thead);
	//l_sapir_tr.className = "daynames";
	//l_sapir_tr.appendChild (l_sapir_year_div);
	var l_sapir_cell = Calendar.createElement("td", l_sapir_tr);
	//l_sapir_cell.className = "name wn";
	l_sapir_cell.colSpan = 7;
	l_sapir_cell.appendChild (l_sapir_year_div);
	
	row = Calendar.createElement("tr", thead);
	row.className = "headrow";

	this._nav_py = hh("&#x00ab;", 1, -2);
	this._nav_py.ttip = Calendar._TT["PREV_YEAR"];

	this._nav_pm = hh("&#x2039;", 1, -1);
	this._nav_pm.ttip = Calendar._TT["PREV_MONTH"];

	this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0);
	this._nav_now.ttip = Calendar._TT["GO_TODAY"];

	this._nav_nm = hh("&#x203a;", 1, 1);
	this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"];

	this._nav_ny = hh("&#x00bb;", 1, 2);
	this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"];

	// day names
	row = Calendar.createElement("tr", thead);
	row.className = "daynames";
	if (this.weekNumbers) {
		cell = Calendar.createElement("td", row);
		cell.className = "name wn";
		cell.innerHTML = Calendar._TT["WK"];
	}
	for (var i = 7; i > 0; --i) {
		cell = Calendar.createElement("td", row);
		if (!i) {
			cell.navtype = 100;
			cell.calendar = this;
			Calendar._add_evs(cell);
		}
	}
	this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild;
	this._displayWeekdays();

	var tbody = Calendar.createElement("tbody", table);
	this.tbody = tbody;

	for (i = 6; i > 0; --i) {
		row = Calendar.createElement("tr", tbody);
		if (this.weekNumbers) {
			cell = Calendar.createElement("td", row);
		}
		for (var j = 7; j > 0; --j) {
			cell = Calendar.createElement("td", row);
			cell.calendar = this;
			Calendar._add_evs(cell);
		}
	}

	if (this.showsTime) {
		row = Calendar.createElement("tr", tbody);
		row.className = "time";

		cell = Calendar.createElement("td", row);
		cell.className = "time";
		cell.colSpan = 2;
		cell.innerHTML = Calendar._TT["TIME"] || "&nbsp;";

		cell = Calendar.createElement("td", row);
		cell.className = "time";
		cell.colSpan = this.weekNumbers ? 4 : 3;

		(function(){
			function makeTimePart(className, init, range_start, range_end) {
				var part = Calendar.createElement("span", cell);
				part.className = className;
				part.innerHTML = init;
				part.calendar = cal;
				part.ttip = Calendar._TT["TIME_PART"];
				part.navtype = 50;
				part._range = [];
				if (typeof range_start != "number")
					part._range = range_start;
				else {
					for (var i = range_start; i <= range_end; ++i) {
						var txt;
						if (i < 10 && range_end >= 10) txt = '0' + i;
						else txt = '' + i;
						part._range[part._range.length] = txt;
					}
				}
				Calendar._add_evs(part);
				return part;
			};
			var hrs = cal.date.getHours();
			var mins = cal.date.getMinutes();
			var t12 = !cal.time24;
			var pm = (hrs > 12);
			if (t12 && pm) hrs -= 12;
			var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23);
			var span = Calendar.createElement("span", cell);
			span.innerHTML = ":";
			span.className = "colon";
			var M = makeTimePart("minute", mins, 0, 59);
			var AP = null;
			cell = Calendar.createElement("td", row);
			cell.className = "time";
			cell.colSpan = 2;
			if (t12)
				AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);
			else
				cell.innerHTML = "&nbsp;";

			cal.onSetTime = function() {
				var pm, hrs = this.date.getHours(),
					mins = this.date.getMinutes();
				if (t12) {
					pm = (hrs >= 12);
					if (pm) hrs -= 12;
					if (hrs == 0) hrs = 12;
					AP.innerHTML = pm ? "pm" : "am";
				}
				H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs;
				M.innerHTML = (mins < 10) ? ("0" + mins) : mins;
			};

			cal.onUpdateTime = function() {
				var date = this.date;
				var h = parseInt(H.innerHTML, 10);
				if (t12) {
					if (/pm/i.test(AP.innerHTML) && h < 12)
						h += 12;
					else if (/am/i.test(AP.innerHTML) && h == 12)
						h = 0;
				}
				var d = date.getDate();
				var m = date.getMonth();
				var y = date.getFullYear();
				date.setHours(h);
				date.setMinutes(parseInt(M.innerHTML, 10));
				date.setFullYear(y);
				date.setMonth(m);
				date.setDate(d);
				this.dateClicked = false;
				this.callHandler();
			};
		})();
	} else {
		this.onSetTime = this.onUpdateTime = function() {};
	}

	var tfoot = Calendar.createElement("tfoot", table);

	row = Calendar.createElement("tr", tfoot);
	row.className = "footrow";

	cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300);
	cell.className = "ttip";
	if (this.isPopup) {
		cell.ttip = Calendar._TT["DRAG_TO_MOVE"];
		cell.style.cursor = "move";
	}
	this.tooltips = cell;

	div = Calendar.createElement("div", this.element);
	this.monthsCombo = div;
	div.className = "combo";
	for (i = 0; i < Calendar._MN.length; ++i) {
		var mn = Calendar.createElement("div");
		mn.className = Calendar.is_ie ? "label-IEfix" : "label";
		mn.month = i;
		mn.innerHTML = Calendar._SMN[i];
		div.appendChild(mn);
	}

	div = Calendar.createElement("div", this.element);
	this.yearsCombo = div;
	div.className = "combo";
	for (i = 12; i > 0; --i) {
		var yr = Calendar.createElement("div");
		yr.className = Calendar.is_ie ? "label-IEfix" : "label";
		div.appendChild(yr);
	}

	this._init(this.firstDayOfWeek, this.date);
	parent.appendChild(this.element);

	//l_sapir_year_input = f_sapir_get_element_by_id (window.document, "sapir_year_input") // *** unique per row ?
	//f_sapir_event_add (l_sapir_year_set, "click", f_sapir_year_set (l_sapir_year_input));
};

/** keyboard navigation, only for popup calendars */
Calendar._keyEvent = function(ev) {
	// sapir
	if (!ev) {
		ev = window.event;
	}
	var l_el;
	l_el = f_sapir_event_element (ev);
	
	//f_sapir_alert (f_sapir_get_attribute (f_sapir_event_element (ev), "name"));
	//f_sapir_alert (l_el.nodeName);
	if (f_sapir_exists (f_sapir_event_element (ev))) {
		if (f_sapir_get_attribute (f_sapir_event_element (ev), "name") == "sapir_year_input") {
			return f_sapir_year_input_key (ev);
		}
	}
	return;
	var cal = window._dynarch_popupCalendar;
	if (!cal || cal.multiple)
		return false;
	(Calendar.is_ie) && (ev = window.event);
	var act = (Calendar.is_ie || ev.type == "keypress"),
		K = ev.keyCode;
	if (ev.ctrlKey) {
		switch (K) {
		    case 37: // KEY left
			act && Calendar.cellClick(cal._nav_pm);
			break;
		    case 38: // KEY up
			act && Calendar.cellClick(cal._nav_py);
			break;
		    case 39: // KEY right
			act && Calendar.cellClick(cal._nav_nm);
			break;
		    case 40: // KEY down
			act && Calendar.cellClick(cal._nav_ny);
			break;
		    default:
			return false;
		}
	} else switch (K) {
	    case 32: // KEY space (now)
		Calendar.cellClick(cal._nav_now);
		break;
	    case 27: // KEY esc
		act && cal.callCloseHandler();
		break;
	    case 37: // KEY left
	    case 38: // KEY up
	    case 39: // KEY right
	    case 40: // KEY down
		if (act) {
			var prev, x, y, ne, el, step;
			prev = K == 37 || K == 38;
			step = (K == 37 || K == 39) ? 1 : 7;
			function setVars() {
				el = cal.currentDateEl;
				var p = el.pos;
				x = p & 15;
				y = p >> 4;
				ne = cal.ar_days[y][x];
			};setVars();
			function prevMonth() {
				var date = new Date(cal.date);
				date.setDate(date.getDate() - step);
				cal.setDate(date);
			};
			function nextMonth() {
				var date = new Date(cal.date);
				date.setDate(date.getDate() + step);
				cal.setDate(date);
			};
			while (1) {
				switch (K) {
				    case 37: // KEY left
					if (--x >= 0)
						ne = cal.ar_days[y][x];
					else {
						x = 6;
						K = 38;
						continue;
					}
					break;
				    case 38: // KEY up
					if (--y >= 0)
						ne = cal.ar_days[y][x];
					else {
						prevMonth();
						setVars();
					}
					break;
				    case 39: // KEY right
					if (++x < 7)
						ne = cal.ar_days[y][x];
					else {
						x = 0;
						K = 40;
						continue;
					}
					break;
				    case 40: // KEY down
					if (++y < cal.ar_days.length)
						ne = cal.ar_days[y][x];
					else {
						nextMonth();
						setVars();
					}
					break;
				}
				break;
			}
			//f_cal_trace ("ne = " + ne);
			if (ne) {
				if (!ne.disabled) {
					//f_cal_trace ("ne enabled");
					Calendar.cellClick(ne);
				}
				else if (prev)
					prevMonth();
				else
					nextMonth();
			}
		}
		break;
	    case 13: // KEY enter
		
		if (act) {
			//f_cal_trace ("cal enter - act");
			Calendar.cellClick(cal.currentDateEl, ev);
		} else {
			//f_cal_trace ("cal enter - no act");
		}
		break;
	    default:
		return false;
	}
	return Calendar.stopEvent(ev);
};

/**
 *  (RE)Initializes the calendar to the given date and firstDayOfWeek
 */
Calendar.prototype._init = function (firstDayOfWeek, date) {
	var today = new Date(),
		TY = today.getFullYear(),
		TM = today.getMonth(),
		TD = today.getDate();
	this.table.style.visibility = "hidden";
	var year = date.getFullYear();
	if (year < this.minYear) {
		year = this.minYear;
		date.setFullYear(year);
	} else if (year > this.maxYear) {
		year = this.maxYear;
		date.setFullYear(year);
	}
	this.firstDayOfWeek = firstDayOfWeek;
	this.date = new Date(date);
	var month = date.getMonth();
	var mday = date.getDate();
	var no_days = date.getMonthDays();

	// calendar voodoo for computing the first day that would actually be
	// displayed in the calendar, even if it's from the previous month.
	// WARNING: this is magic. ;-)
	date.setDate(1);
	var day1 = (date.getDay() - this.firstDayOfWeek) % 7;
	if (day1 < 0)
		day1 += 7;
	date.setDate(-day1);
	date.setDate(date.getDate() + 1);

	var row = this.tbody.firstChild;
	var MN = Calendar._SMN[month];
	var ar_days = this.ar_days = new Array();
	var weekend = Calendar._TT["WEEKEND"];
	var dates = this.multiple ? (this.datesCells = {}) : null;
	for (var i = 0; i < 6; ++i, row = row.nextSibling) {
		var cell = row.firstChild;
		if (this.weekNumbers) {
			cell.className = "day wn";
			cell.innerHTML = date.getWeekNumber();
			cell = cell.nextSibling;
		}
		row.className = "daysrow";
		var hasdays = false, iday, dpos = ar_days[i] = [];
		for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) {
			iday = date.getDate();
			var wday = date.getDay();
			cell.className = "day";
			cell.pos = i << 4 | j;
			dpos[j] = cell;
			var current_month = (date.getMonth() == month);
			if (!current_month) {
				if (this.showsOtherMonths) {
					cell.className += " othermonth";
					cell.otherMonth = true;
				} else {
					cell.className = "emptycell";
					cell.innerHTML = "&nbsp;";
					cell.disabled = true;
					continue;
				}
			} else {
				cell.otherMonth = false;
				hasdays = true;
			}
			cell.disabled = false;
			cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday;
			if (dates)
				dates[date.print("%Y%m%d")] = cell;
			if (this.getDateStatus) {
				var status = this.getDateStatus(date, year, month, iday);
				if (this.getDateToolTip) {
					var toolTip = this.getDateToolTip(date, year, month, iday);
					if (toolTip)
						cell.title = toolTip;
				}
				if (status === true) {
					cell.className += " disabled";
					cell.disabled = true;
				} else {
					if (/disabled/i.test(status))
						cell.disabled = true;
					cell.className += " " + status;
				}
			}
			if (!cell.disabled) {
				cell.caldate = new Date(date);
				cell.ttip = "_";
				if (!this.multiple && current_month
				    && iday == mday && this.hiliteToday) {
					cell.className += " selected";
					this.currentDateEl = cell;
				}
				if (date.getFullYear() == TY &&
				    date.getMonth() == TM &&
				    iday == TD) {
					cell.className += " today";
					cell.ttip += Calendar._TT["PART_TODAY"];
				}
				if (weekend.indexOf(wday.toString()) != -1)
					cell.className += cell.otherMonth ? " oweekend" : " weekend";
			}
		}
		if (!(hasdays || this.showsOtherMonths))
			row.className = "emptyrow";
	}
	this.title.innerHTML = Calendar._MN[month] + ", " + year;
	this.onSetTime();
	this.table.style.visibility = "visible";
	this._initMultipleDates();
	// PROFILE
	// this.tooltips.innerHTML = "Generated in " + ((new Date()) - today) + " ms";
};

Calendar.prototype._initMultipleDates = function() {
	if (this.multiple) {
		for (var i in this.multiple) {
			var cell = this.datesCells[i];
			var d = this.multiple[i];
			if (!d)
				continue;
			if (cell)
				cell.className += " selected";
		}
	}
};

Calendar.prototype._toggleMultipleDate = function(date) {
	if (this.multiple) {
		var ds = date.print("%Y%m%d");
		var cell = this.datesCells[ds];
		if (cell) {
			var d = this.multiple[ds];
			if (!d) {
				Calendar.addClass(cell, "selected");
				this.multiple[ds] = date;
			} else {
				Calendar.removeClass(cell, "selected");
				delete this.multiple[ds];
			}
		}
	}
};

Calendar.prototype.setDateToolTipHandler = function (unaryFunction) {
	this.getDateToolTip = unaryFunction;
};

/**
 *  Calls _init function above for going to a certain date (but only if the
 *  date is different than the currently selected one).
 */
Calendar.prototype.setDate = function (date) {
	if (!date.equalsTo(this.date)) {
		this._init(this.firstDayOfWeek, date);
	}
};

/**
 *  Refreshes the calendar.  Useful if the "disabledHandler" function is
 *  dynamic, meaning that the list of disabled date can change at runtime.
 *  Just * call this function if you think that the list of disabled dates
 *  should * change.
 */
Calendar.prototype.refresh = function () {
	if (typeof (g_sapir_cat_ui_active) != "undefined") {
		if (g_sapir_cat_ui_active) {
			if (typeof (g_input_disabled) != "undefined") {
				if (g_input_disabled) {
					return;
				}
			}
		}
	}
	this._init(this.firstDayOfWeek, this.date);
};

/** Modifies the "firstDayOfWeek" parameter (pass 0 for Synday, 1 for Monday, etc.). */
Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) {
	this._init(firstDayOfWeek, this.date);
	this._displayWeekdays();
};

/**
 *  Allows customization of what dates are enabled.  The "unaryFunction"
 *  parameter must be a function object that receives the date (as a JS Date
 *  object) and returns a boolean value.  If the returned value is true then
 *  the passed date will be marked as disabled.
 */
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
	this.getDateStatus = unaryFunction;
};

/** Customization of allowed year range for the calendar. */
Calendar.prototype.setRange = function (a, z) {
	this.minYear = a;
	this.maxYear = z;
};

/** Calls the first user handler (selectedHandler). */
Calendar.prototype.callHandler = function () {
	if (this.onSelected) {
		this.onSelected(this, this.date.print(this.dateFormat));
	}
};

/** Calls the second user handler (closeHandler). */
Calendar.prototype.callCloseHandler = function () {
	document.onkeydown = this.sapir_keydown_backup;
	if (this.onClose) {
		this.onClose(this);
	}
	this.hideShowCovered();
};

/** Removes the calendar object from the DOM tree and destroys it. */
Calendar.prototype.destroy = function () {
	var el = f_sapir_parent (this.element);
	el.removeChild(this.element);
	Calendar._C = null;
	window._dynarch_popupCalendar = null;
};

/**
 *  Moves the calendar element to a different section in the DOM tree (changes
 *  its parent).
 */
Calendar.prototype.reparent = function (new_parent) {
	var el = this.element;
	f_sapir_parent (el).removeChild(el);
	new_parent.appendChild(el);
};

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
Calendar._checkCalendar = function(ev) {
	// yair 15\7\10 : nop - since in ff + chrome causes mouseclicks to block focus (biz 76692)
	return false;
	
	var calendar = window._dynarch_popupCalendar;
	if (!calendar) {
		return false;
	}
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null && el != calendar.element; el = f_sapir_parent (el));
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		window._dynarch_popupCalendar.callCloseHandler();
		return Calendar.stopEvent(ev);
	}
};

/** Shows the calendar. */
Calendar.prototype.show = function () {
	if (typeof (g_sapir_cat_ui_active) != "undefined") {
		if (g_sapir_cat_ui_active) {
			if (typeof (g_input_disabled) != "undefined") {
				if (g_input_disabled) {
					return;
				}
			}
		}
	}

	var rows = this.table.getElementsByTagName("tr");
	for (var i = rows.length; i > 0;) {
		var row = rows[--i];
		Calendar.removeClass(row, "rowhilite");
		var cells = row.getElementsByTagName("td");
		for (var j = cells.length; j > 0;) {
			var cell = cells[--j];
			Calendar.removeClass(cell, "hilite");
			Calendar.removeClass(cell, "active");
		}
	}
	this.element.style.display = "block";
	this.hidden = false;
	if (this.isPopup) {
		window._dynarch_popupCalendar = this;
		Calendar.addEvent(document, "keydown", Calendar._keyEvent);
		Calendar.addEvent(document, "keypress", Calendar._keyEvent);
		Calendar.addEvent(document, "mousedown", Calendar._checkCalendar);
	}
	this.hideShowCovered();
};

/**
 *  Hides the calendar.  Also removes any "hilite" from the class of any TD
 *  element.
 */
Calendar.prototype.hide = function () {
	if (this.isPopup) {
		Calendar.removeEvent(document, "keydown", Calendar._keyEvent);
		Calendar.removeEvent(document, "keypress", Calendar._keyEvent);
		Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar);
	}
	this.element.style.display = "none";
	this.hidden = true;
	this.hideShowCovered();
};

/**
 *  Shows the calendar at a given absolute position (beware that, depending on
 *  the calendar element style -- position property -- this might be relative
 *  to the parent's containing rectangle).
 */
Calendar.prototype.showAt = function (x, y) {
	var s = this.element.style;
	s.left = x + "px";
	s.top = y + "px";
	this.show();
	f_sapir_get_element_by_id (window.document, "sapir_year_input").focus ();
};

/** Shows the calendar near a given element. */
Calendar.prototype.showAtElement = function (el, opts) {
	var self = this;
	var p = Calendar.getAbsolutePos(el);
	if (!opts || typeof opts != "string") {
		this.showAt(p.x, p.y + el.offsetHeight);
		return true;
	}
	function fixPosition(box) {
	/*
	if (g_cal_debug == true) {
		g_cal_debug = false;
		f_sapir_alert ("fixPosition 1 : " + document.body.scrollTop + ", " +  document.body.offsetTop);
		f_sapir_alert ("fixPosition 1 : " + document.documentElement.scrollTop + ", " +  document.documentElement.offsetTop);
	}
	*/
		if (box.x < 0)
			box.x = 0;
		if (box.y < 0)
			box.y = 0;
		var cp = document.createElement("div");
		var s = cp.style;
		s.position = "absolute";
		s.right = s.bottom = s.width = s.height = "0px";
		document.body.appendChild(cp);
		var br = Calendar.getAbsolutePos(cp);
		document.body.removeChild(cp);
		if (Calendar.is_ie) {
			//if (g_sapir_ie_ver < 8) {
			//	br.y += document.body.scrollTop;
			//	br.x += document.body.scrollLeft;
			//} else {
				br.y += new Number (document.documentElement.scrollTop);
				br.x += new Number (document.documentElement.scrollLeft);
			//}
		} else {
			br.y += window.scrollY;
			br.x += window.scrollX;
		}
		var tmp = box.x + box.width - br.x;
		if (tmp > 0) box.x -= tmp;
		tmp = box.y + box.height - br.y;
		if (tmp > 0) box.y -= tmp;
	};
	this.element.style.display = "block";
	Calendar.continuation_for_the_fucking_khtml_browser = function() {
		var w = self.element.offsetWidth;
		var h = self.element.offsetHeight;
		self.element.style.display = "none";
		var valign = opts.substr(0, 1);
		var halign = "l";
		if (opts.length > 1) {
			halign = opts.substr(1, 1);
		}
		// vertical alignment
		switch (valign) {
		    case "T": p.y -= h; break;
		    case "B": p.y += el.offsetHeight; break;
		    case "C": p.y += (el.offsetHeight - h) / 2; break;
		    case "t": p.y += el.offsetHeight - h; break;
		    case "b": break; // already there
		}
		// horizontal alignment
		switch (halign) {
		    case "L": p.x -= w; break;
		    case "R": p.x += el.offsetWidth; break;
		    case "C": p.x += (el.offsetWidth - w) / 2; break;
		    case "l": p.x += el.offsetWidth - w; break;
		    case "r": break; // already there
		}
		p.width = w;
		p.height = h + 40;
		self.monthsCombo.style.display = "none";
		fixPosition(p);
		self.showAt(p.x, p.y);
	};
	if (Calendar.is_khtml)
		setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
	else
		Calendar.continuation_for_the_fucking_khtml_browser();
};

/** Customizes the date format. */
Calendar.prototype.setDateFormat = function (str) {
	this.dateFormat = str;
};

/** Customizes the tooltip date format. */
Calendar.prototype.setTtDateFormat = function (str) {
	this.ttDateFormat = str;
};

/**
 *  Tries to identify the date represented in a string.  If successful it also
 *  calls this.setDate which moves the calendar to the given date.
 */
Calendar.prototype.parseDate = function(str, fmt) {
	if (!fmt)
		fmt = this.dateFormat;
	this.setDate(Date.parseDate(str, fmt));
};

Calendar.prototype.hideShowCovered = function () {
	if (!Calendar.is_ie && !Calendar.is_opera)
		return;
	function getVisib(obj){
		var value = obj.style.visibility;
		if (!value) {
			if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
				if (!Calendar.is_khtml)
					value = document.defaultView.
						getComputedStyle(obj, "").getPropertyValue("visibility");
				else
					value = '';
			} else if (obj.currentStyle) { // IE
				value = obj.currentStyle.visibility;
			} else
				value = '';
		}
		return value;
	};

	var tags = new Array("applet", "iframe", "select");
	var el = this.element;

	var p = Calendar.getAbsolutePos(el);
	var EX1 = p.x;
	var EX2 = el.offsetWidth + EX1;
	var EY1 = p.y;
	var EY2 = el.offsetHeight + EY1;

	for (var k = tags.length; k > 0; ) {
		var ar = document.getElementsByTagName(tags[--k]);
		var cc = null;

		for (var i = ar.length; i > 0;) {
			cc = ar[--i];

			p = Calendar.getAbsolutePos(cc);
			var CX1 = p.x;
			var CX2 = cc.offsetWidth + CX1;
			var CY1 = p.y;
			var CY2 = cc.offsetHeight + CY1;

			if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
				if (!cc.__msh_save_visibility) {
					cc.__msh_save_visibility = getVisib(cc);
				}
				cc.style.visibility = cc.__msh_save_visibility;
			} else {
				if (!cc.__msh_save_visibility) {
					cc.__msh_save_visibility = getVisib(cc);
				}
				cc.style.visibility = "hidden";
			}
		}
	}
};

/** Internal function; it displays the bar with the names of the weekday. */
Calendar.prototype._displayWeekdays = function () {
	var fdow = this.firstDayOfWeek;
	var cell = this.firstdayname;
	var weekend = Calendar._TT["WEEKEND"];
	for (var i = 0; i < 7; ++i) {
		cell.className = "day name";
		var realday = (i + fdow) % 7;
		if (i) {
			cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]);
			cell.navtype = 100;
			cell.calendar = this;
			cell.fdow = realday;
			Calendar._add_evs(cell);
		}
		if (weekend.indexOf(realday.toString()) != -1) {
			Calendar.addClass(cell, "weekend");
		}
		cell.innerHTML = Calendar._SDN[(i + fdow) % 7];
		cell = cell.nextSibling;
	}
};

/** Internal function.  Hides all combo boxes that might be displayed. */
Calendar.prototype._hideCombos = function () {
	this.monthsCombo.style.display = "none";
	this.yearsCombo.style.display = "none";
};

/** Internal function.  Starts dragging the element. */
Calendar.prototype._dragStart = function (ev) {
	if (this.dragging) {
		return;
	}
	this.dragging = true;
	var posX;
	var posY;
	if (Calendar.is_ie) {
		posY = window.event.clientY + document.body.scrollTop;
		posX = window.event.clientX + document.body.scrollLeft;
	} else {
		posY = ev.clientY + window.scrollY;
		posX = ev.clientX + window.scrollX;
	}
	var st = this.element.style;
	this.xOffs = posX - parseInt(st.left);
	this.yOffs = posY - parseInt(st.top);
	with (Calendar) {
		addEvent(document, "mousemove", calDragIt);
		addEvent(document, "mouseup", calDragEnd);
	}
};

// BEGIN: DATE OBJECT PATCHES

/** Adds the number of days array to the Date object. */
Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

/** Constants used for time computations */
Date.SECOND = 1000 /* milliseconds */;
Date.MINUTE = 60 * Date.SECOND;
Date.HOUR   = 60 * Date.MINUTE;
Date.DAY    = 24 * Date.HOUR;
Date.WEEK   =  7 * Date.DAY;

Date.parseDate = function(str, fmt) {
	var today = new Date();
	var y = 0;
	var m = -1;
	var d = 0;
	var a = str.split(/\W+/);
	var b = fmt.match(/%./g);
	var i = 0, j = 0;
	var hr = 0;
	var min = 0;
	for (i = 0; i < a.length; ++i) {
		if (!a[i])
			continue;
		switch (b[i]) {
		    case "%d":
		    case "%e":
			d = parseInt(a[i], 10);
			break;

		    case "%m":
			m = parseInt(a[i], 10) - 1;
			break;

		    case "%Y":
		    case "%y":
			y = parseInt(a[i], 10);
			(y < 100) && (y += (y > 29) ? 1900 : 2000);
			break;

		    case "%b":
		    case "%B":
			for (j = 0; j < 12; ++j) {
				if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
			}
			break;

		    case "%H":
		    case "%I":
		    case "%k":
		    case "%l":
			hr = parseInt(a[i], 10);
			break;

		    case "%P":
		    case "%p":
			if (/pm/i.test(a[i]) && hr < 12)
				hr += 12;
			else if (/am/i.test(a[i]) && hr >= 12)
				hr -= 12;
			break;

		    case "%M":
			min = parseInt(a[i], 10);
			break;
		}
	}
	if (isNaN(y)) y = today.getFullYear();
	if (isNaN(m)) m = today.getMonth();
	if (isNaN(d)) d = today.getDate();
	if (isNaN(hr)) hr = today.getHours();
	if (isNaN(min)) min = today.getMinutes();
	if (y != 0 && m != -1 && d != 0)
		return new Date(y, m, d, hr, min, 0);
	y = 0; m = -1; d = 0;
	for (i = 0; i < a.length; ++i) {
		if (a[i].search(/[a-zA-Z]+/) != -1) {
			var t = -1;
			for (j = 0; j < 12; ++j) {
				if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
			}
			if (t != -1) {
				if (m != -1) {
					d = m+1;
				}
				m = t;
			}
		} else if (parseInt(a[i], 10) <= 12 && m == -1) {
			m = a[i]-1;
		} else if (parseInt(a[i], 10) > 31 && y == 0) {
			y = parseInt(a[i], 10);
			(y < 100) && (y += (y > 29) ? 1900 : 2000);
		} else if (d == 0) {
			d = a[i];
		}
	}
	if (y == 0)
		y = today.getFullYear();
	if (m != -1 && d != 0)
		return new Date(y, m, d, hr, min, 0);
	return today;
};

/** Returns the number of days in the current month */
Date.prototype.getMonthDays = function(month) {
	var year = this.getFullYear();
	if (typeof month == "undefined") {
		month = this.getMonth();
	}
	if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
		return 29;
	} else {
		return Date._MD[month];
	}
};

/** Returns the number of day in the year. */
Date.prototype.getDayOfYear = function() {
	var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
	var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
	var time = now - then;
	return Math.floor(time / Date.DAY);
};

/** Returns the number of the week in year, as defined in ISO 8601. */
Date.prototype.getWeekNumber = function() {
	var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
	var DoW = d.getDay();
	d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
	var ms = d.valueOf(); // GMT
	d.setMonth(0);
	d.setDate(4); // Thu in Week 1
	return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
};

/** Checks date and time equality */
Date.prototype.equalsTo = function(date) {
	return ((this.getFullYear() == date.getFullYear()) &&
		(this.getMonth() == date.getMonth()) &&
		(this.getDate() == date.getDate()) &&
		(this.getHours() == date.getHours()) &&
		(this.getMinutes() == date.getMinutes()));
};

/** Set only the year, month, date parts (keep existing time) */
Date.prototype.setDateOnly = function(date) {
	var tmp = new Date(date);
	this.setDate(1);
	this.setFullYear(tmp.getFullYear());
	this.setMonth(tmp.getMonth());
	this.setDate(tmp.getDate());
};

/** Prints the date in a string according to the given format. */
Date.prototype.print = function (str) {
	var m = this.getMonth();
	var d = this.getDate();
	var y = this.getFullYear();
	var wn = this.getWeekNumber();
	var w = this.getDay();
	var s = {};
	var hr = this.getHours();
	var pm = (hr >= 12);
	var ir = (pm) ? (hr - 12) : hr;
	var dy = this.getDayOfYear();
	if (ir == 0)
		ir = 12;
	var min = this.getMinutes();
	var sec = this.getSeconds();
	s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
	s["%A"] = Calendar._DN[w]; // full weekday name
	s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
	s["%B"] = Calendar._MN[m]; // full month name
	// FIXME: %c : preferred date and time representation for the current locale
	s["%C"] = 1 + Math.floor(y / 100); // the century number
	s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
	s["%e"] = d; // the day of the month (range 1 to 31)
	// FIXME: %D : american date style: %m/%d/%y
	// FIXME: %E, %F, %G, %g, %h (man strftime)
	s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
	s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
	s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
	s["%k"] = hr;		// hour, range 0 to 23 (24h format)
	s["%l"] = ir;		// hour, range 1 to 12 (12h format)
	s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
	s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
	s["%n"] = "\n";		// a newline character
	s["%p"] = pm ? "PM" : "AM";
	s["%P"] = pm ? "pm" : "am";
	// FIXME: %r : the time in am/pm notation %I:%M:%S %p
	// FIXME: %R : the time in 24-hour notation %H:%M
	s["%s"] = Math.floor(this.getTime() / 1000);
	s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
	s["%t"] = "\t";		// a tab character
	// FIXME: %T : the time in 24-hour notation (%H:%M:%S)
	s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
	s["%u"] = w + 1;	// the day of the week (range 1 to 7, 1 = MON)
	s["%w"] = w;		// the day of the week (range 0 to 6, 0 = SUN)
	// FIXME: %x : preferred date representation for the current locale without the time
	// FIXME: %X : preferred time representation for the current locale without the date
	s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
	s["%Y"] = y;		// year with the century
	s["%%"] = "%";		// a literal '%' character

	var re = /%./g;
	if (!Calendar.is_ie5 && !Calendar.is_khtml)
		return str.replace(re, function (par) { return s[par] || par; });

	var a = str.match(re);
	for (var i = 0; i < a.length; i++) {
		var tmp = s[a[i]];
		if (tmp) {
			re = new RegExp(a[i], 'g');
			str = str.replace(re, tmp);
		}
	}

	return str;
};

Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y) {
	var d = new Date(this);
	d.__msh_oldSetFullYear(y);
	if (d.getMonth() != this.getMonth())
		this.setDate(28);
	this.__msh_oldSetFullYear(y);
};

// END: DATE OBJECT PATCHES


// global object that remembers the calendar
window._dynarch_popupCalendar = null;

function f_sapir_year_set2 (a_el, a_year_el_id) {
	//f_sapir_alert ("f_sapir_year_set2");
	var l_calendar, cal, l_year_el;

	l_year_el = f_sapir_get_element_by_id (window.document, a_year_el_id);
	//f_cal_trace ("f_sapir_year_set2 : " + a_el + ", " + a_year_el_id + ", value = " + l_year_el.value);
	if (f_sapir_is_empty (l_year_el.value)) {
		return;
	}
	//f_cal_trace ("f_sapir_year_set2 : " + l_year_el.value);
	l_calendar = l_year_el.calendar;
	cal = l_calendar; // l_calendar._C;
	l_date = new Date (cal.date);
	l_date.setFullYear(l_year_el.value);
	cal.setDate(l_date);
	l_year_el.value = "";
}

function f_sapir_calendar_year_onblur (a_event) {
	var l_event;
	if (a_event) {
		l_event = a_event;
	} else {
		l_event = window.event;
	}
	//f_cal_trace ("f_sapir_calendar_year_onblur : " + l_event);
	f_sapir_year_set (l_event);
}

function f_sapir_year_input_key (ev) {
	var cal, act, K;
	cal = window._dynarch_popupCalendar;
	(Calendar.is_ie) && (ev = window.event);
	
	//sapir
	act = true;
	//act = (Calendar.is_ie || new String (ev.type) == "keypress");
	
	K = ev.keyCode;
	if (ev.ctrlKey) {
		return true;
	} else switch (K) {
	    case 27: // KEY esc
			act && cal.callCloseHandler();
			return false;

	    case 13: // KEY enter
			//debugger;
			if (act) {
				//f_cal_trace ("year enter - act");
				f_sapir_calendar_year_onblur (ev);
			} else {
				//f_cal_trace ("year enter - no act");
			}
			f_sapir_event_cancel (ev);
			return false;
			break;
			
	    default:
			return true;
	}
	return true;
}

/////////////////////////// calendar-setup.js ////////////////////////////////////////////////////////////////////
/*  Copyright Mihai Bazon, 2002, 2003  |  http://dynarch.com/mishoo/
 * ---------------------------------------------------------------------------
 *
 * The DHTML Calendar
 *
 * Details and latest version at:
 * http://dynarch.com/mishoo/calendar.epl
 *
 * This script is distributed under the GNU Lesser General Public License.
 * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
 *
 * This file defines helper functions for setting up the calendar.  They are
 * intended to help non-programmers get a working calendar on their site
 * quickly.  This script should not be seen as part of the calendar.  It just
 * shows you what one can do with the calendar, while in the same time
 * providing a quick and simple method for setting it up.  If you need
 * exhaustive customization of the calendar creation process feel free to
 * modify this code to suit your needs (this is recommended and much better
 * than modifying calendar.js itself).
 */

// $Id: calendar-setup.js,v 1.25 2005/03/07 09:51:33 mishoo Exp $

/**
 *  This function "patches" an input field (or other element) to use a calendar
 *  widget for date selection.
 *
 *  The "params" is a single object that can have the following properties:
 *
 *    prop. name   | description
 *  -------------------------------------------------------------------------------------------------
 *   inputField    | the ID of an input field to store the date
 *   displayArea   | the ID of a DIV or other element to show the date
 *   button        | ID of a button or other element that will trigger the calendar
 *   eventName     | event that will trigger the calendar, without the "on" prefix (default: "click")
 *   ifFormat      | date format that will be stored in the input field
 *   daFormat      | the date format that will be used to display the date in displayArea
 *   singleClick   | (true/false) wether the calendar is in single click mode or not (default: true)
 *   firstDay      | numeric: 0 to 6.  "0" means display Sunday first, "1" means display Monday first, etc.
 *   align         | alignment (default: "Br"); if you don't know what's this see the calendar documentation
 *   range         | array with 2 elements.  Default: [1900, 2999] -- the range of years available
 *   weekNumbers   | (true/false) if it's true (default) the calendar will display week numbers
 *   flat          | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
 *   flatCallback  | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
 *   disableFunc   | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
 *   onSelect      | function that gets called when a date is selected.  You don't _have_ to supply this (the default is generally okay)
 *   onClose       | function that gets called when the calendar is closed.  [default]
 *   onUpdate      | function that gets called after the date is updated in the input field.  Receives a reference to the calendar.
 *   date          | the date that the calendar will be initially displayed to
 *   showsTime     | default: false; if true the calendar will include a time selector
 *   timeFormat    | the time format; can be "12" or "24", default is "12"
 *   electric      | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
 *   step          | configures the step of the years in drop-down boxes; default: 2
 *   position      | configures the calendar absolute position; default: null
 *   cache         | if "true" (but default: "false") it will reuse the same calendar object, where possible
 *   showOthers    | if "true" (but default: "false") it will show days from other months too
 *
 *  None of them is required, they all have default values.  However, if you
 *  pass none of "inputField", "displayArea" or "button" you'll get a warning
 *  saying "nothing to setup".
 */
Calendar.setup = function (params) {
	function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };

	/*
	if (g_sapir_cat_ui_active) {
		if (g_input_disabled) {
			return false;
		}
	}
	*/

	param_default("inputField",     null);
	param_default("displayArea",    null);
	param_default("button",         null);
	param_default("eventName",      "click");
	param_default("ifFormat",       "%Y/%m/%d");
	param_default("daFormat",       "%Y/%m/%d");
	param_default("singleClick",    true);
	param_default("disableFunc",    null);
	param_default("dateStatusFunc", params["disableFunc"]);	// takes precedence if both are defined
	param_default("dateText",       null);
	param_default("firstDay",       null);
	param_default("align",          "Br");
	param_default("range",          [1900, 2999]);
	param_default("weekNumbers",    false);
	param_default("flat",           null);
	param_default("flatCallback",   null);
	param_default("onSelect",       null);
	param_default("onClose",        null);
	param_default("onUpdate",       null);
	param_default("date",           null);
	param_default("showsTime",      false);
	param_default("timeFormat",     "24");
	param_default("electric",       true);
	param_default("step",           2);
	param_default("position",       null);
	param_default("cache",          false);
	param_default("showOthers",     false);
	param_default("multiple",       null);

	var tmp = ["inputField", "displayArea", "button"];
	for (var i in tmp) {
		if (typeof params[tmp[i]] == "string") {
			params[tmp[i]] = document.getElementById(params[tmp[i]]);
		}
	}
	if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) {
		alert("Calendar.setup:\n  Nothing to setup (no fields found).  Please check your code");
		return false;
	}

	function onSelect(cal) {
		var p = cal.params;
		var update = (cal.dateClicked || p.electric);
		if (update && p.inputField) {
			p.inputField.value = cal.date.print(p.ifFormat);
			if (typeof p.inputField.onchange == "function")
				p.inputField.onchange();
		}
		if (update && p.displayArea)
			p.displayArea.innerHTML = cal.date.print(p.daFormat);
		if (update && typeof p.onUpdate == "function")
			p.onUpdate(cal);
		if (update && p.flat) {
			if (typeof p.flatCallback == "function")
				p.flatCallback(cal);
		}
		if (update && p.singleClick && cal.dateClicked)
			cal.callCloseHandler();
	};

	if (params.flat != null) {
		if (typeof params.flat == "string")
			params.flat = document.getElementById(params.flat);
		if (!params.flat) {
			alert("Calendar.setup:\n  Flat specified but can't find parent.");
			return false;
		}
		var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect);
		cal.showsOtherMonths = params.showOthers;
		cal.showsTime = params.showsTime;
		cal.time24 = (params.timeFormat == "24");
		cal.params = params;
		cal.weekNumbers = params.weekNumbers;
		cal.setRange(params.range[0], params.range[1]);
		cal.setDateStatusHandler(params.dateStatusFunc);
		cal.getDateText = params.dateText;
		if (params.ifFormat) {
			cal.setDateFormat(params.ifFormat);
		}
		if (params.inputField && typeof params.inputField.value == "string") {
			cal.parseDate(params.inputField.value);
		}
		cal.create(params.flat);
		cal.show();
		return false;
	}

	var triggerEl = params.button || params.displayArea || params.inputField;
	triggerEl["on" + params.eventName] = function() {
		var dateEl = params.inputField || params.displayArea;
		var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
		var mustCreate = false;
		var cal = window.calendar;
		if (dateEl)
			params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);
		if (!(cal && params.cache)) {
			window.calendar = cal = new Calendar(params.firstDay,
							     params.date,
							     params.onSelect || onSelect,
							     params.onClose || function(cal) { cal.hide(); });
			cal.showsTime = params.showsTime;
			cal.time24 = (params.timeFormat == "24");
			cal.weekNumbers = params.weekNumbers;
			mustCreate = true;
		} else {
			if (params.date)
				cal.setDate(params.date);
			cal.hide();
		}
		if (params.multiple) {
			cal.multiple = {};
			for (var i = params.multiple.length; --i >= 0;) {
				var d = params.multiple[i];
				var ds = d.print("%Y%m%d");
				cal.multiple[ds] = d;
			}
		}
		cal.showsOtherMonths = params.showOthers;
		cal.yearStep = params.step;
		cal.setRange(params.range[0], params.range[1]);
		cal.params = params;
		cal.setDateStatusHandler(params.dateStatusFunc);
		cal.getDateText = params.dateText;
		cal.setDateFormat(dateFmt);
		if (mustCreate) {
			cal.create();
		}
		cal.refresh();
		if (typeof (g_sapir_cat_ui_active) != "undefined") {
			if (g_sapir_cat_ui_active) {
				if (typeof (g_input_disabled) != "undefined") {
					if (g_input_disabled) {
						return;
					}
				}
			}
		}
		if (!params.position) {
			cal.showAtElement(params.button || params.displayArea || params.inputField, params.align);
		} else {
			cal.showAt(params.position[0], params.position[1]);
		}
		return false;
	};

	return cal;
};
////////////////////// end of calendar_flat.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from EmbedHtml.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*/
\\\	This is the only file that should be imported by Sapir.
/// All dependant JavaScript files (base on the embedded content)
\\\ will be dynamically loaded.
///
\\\ The only "external" functions are f_idea_prepareEmbed and f_idea_embedAllHtmls.
/*/

/*/
\ \	Logic for dynamically loading external JS files
/*/

var g_idea_importedFiles = new Object;
var g_idea_embedsByType = new Object;

function f_idea_importBaseJs()  {
	/*
	if (  f_sapir_exists( g_idea_importedFiles['EmbedHtmlHelper.js'] )  )
		return;
		// insert the script element into the DOM
	
	var scriptElem		= document.createElement('script');  
	scriptElem.src		= 'EmbedHtmlHelper.js';  
	scriptElem.type		= 'text/javascript';  
	scriptElem.defer	= true;  
	document.getElementsByTagName('head').item(0).appendChild(scriptElem);
	*/
}
 
function f_idea_importAndRun(/*objects array*/ a_embedParamsArray) {
	var fileToImp = 'scripts/Embed' + a_embedParamsArray[0].i_type + '.js';	
	if (  ! f_sapir_exists( g_idea_importedFiles[fileToImp] )  ) {
			// insert the script element into the DOM
		var scriptElem		= document.createElement('script');
		scriptElem.src		= fileToImp;
		scriptElem.type		= 'text/javascript';
			// set callbacks to get notified when import JS is available
		scriptElem.onloadDone = false;
		scriptElem.onreadystatechange = function() {
			if ( (scriptElem.readyState == 'complete' || scriptElem.readyState == 'loaded')
				 && scriptElem.onloadDone == false ) {
				scriptElem.onloadDone = true;
				g_idea_importedFiles[fileToImp] = true;
				f_idea_embedAfterImport(a_embedParamsArray);
			}
		}
		
		
		
		scriptElem.onload = function() {
			scriptElem.onloadDone = true;
			g_idea_importedFiles[fileToImp] = true;
			f_idea_embedAfterImport(a_embedParamsArray);
		}
		document.getElementsByTagName('head').item(0).appendChild(scriptElem);
	} else {
		f_idea_embedAfterImport(a_embedParamsArray);
	}
}

/*/
\ \	The executer of the required embedding,
/ / callbacked only after the JS file needed
\ \ has been fully loaded.
/*/

function f_idea_embedAfterImport(/*objects array*/ a_embedParamsArray) {
	switch ( a_embedParamsArray[0].i_type ) {
		case 'youtube':
			f_idea_embedYouTube(a_embedParamsArray);
			break;
		case 'googlevideo':
			f_idea_embedGoogleVideo(a_embedParamsArray);
			break;
		case 'flickr':
			f_idea_embedFlickr(a_embedParamsArray);
			break;
		case 'googlemaps':
			f_idea_embedGoogleMaps(a_embedParamsArray);
			break;
		case 'googlemapsapi':
			f_idea_embedGoogleMapsApi(a_embedParamsArray);
			break;
		default:
			var trgElem = f_sapir_get_element_by_id( document, a_embedParamsArray[0].i_targetElemId );
			trgElem.innerHTML = '[Unsupported embedding type ' + a_embedParams.i_type + ']';
	}
}

function /*string*/ f_idea_fixEmbedType(/*string*/ a_sapirType) {
		// convert sapir EMBED_TY codes to internally used types
	switch ( a_sapirType.toLowerCase() ) {
	case 'g_video':
		return 'googlevideo';
	case 'g_maps':
		return 'googlemaps';
	case 'g_maps_api':
		return 'googlemapsapi';
	case 'flickr':
		return 'flickr';
	case 'youtube':
		return 'youtube';
	}
}

/*/
\ \	The only "external" functions for HTML embedding -
/ / call f_idea_prepareEmbed for each embedded item before the page is loaded;
\ \ call f_idea_embedAllHtmls on the onload event to render the embedded items.
/*/

function /*void*/ f_idea_prepareEmbed(/*string*/ a_embedType,
								 /*string*/ a_html,
								 /*string*/ a_targetElemId,
								 /*string*/ a_targetFrameId,
								 /*number*/ a_width,
								 /*number*/ a_height,
								 /*string*/ a_miscArgs) {
	a_embedType = f_idea_fixEmbedType(a_embedType);
	var miscArgs = f_sapir_info_obj(a_miscArgs);
	var embedParams = {
		i_type: a_embedType,
		i_html: a_html,
		i_targetElemId: a_targetElemId,
		i_targetFrameId: a_targetFrameId,
		i_width: a_width,
		i_height: a_height,
		i_miscArgs: miscArgs
	};
	if (  ! f_sapir_exists( g_idea_embedsByType[a_embedType] )  )
		g_idea_embedsByType[a_embedType] = [];
	g_idea_embedsByType[a_embedType].push(embedParams);
}

function /*void*/ f_idea_embedAllHtmls() {
	var embedTypes = ['youtube', 'googlevideo', 'flickr', 'googlemaps', 'googlemapsapi'], type;

	if (embedTypes.length > 0) {
		f_idea_importBaseJs();
	}
	for (var i = 0, typesNum = embedTypes.length; i < typesNum; ++i) {
		type = embedTypes[i];
		if (  f_sapir_exists( g_idea_embedsByType[type] )  ) {
			f_idea_importAndRun( g_idea_embedsByType[type] );
		}
	}
}

////////////////////// end of EmbedHtml.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from EmbedHtmlHelper.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*/
\\\		This is the base helper function. All implementions of embedded content
///		should inherit from it, and implement the missing member functions.
\\\		The file sould be loaded by EmbedHtml.js
/*/

/*/
\ \		Functionality shared between all implementations
/*/

function /*void*/ f_idea_embedHtmlHelper() {
    this.i_htmlTmpl      = '';
    this.i_html          = '';
    this.i_targetElemId  = '';
    this.i_targetFrameId = '';
    this.i_width         = '';
    this.i_height        = '';
    this.i_miscArgs      = new Object;
}

f_idea_embedHtmlHelper.prototype.f_setArgs = 
/*void*/ function (/*string*/ a_html,
                   /*string*/ a_targetElemId,
                   /*string*/ a_targetFrameId,
                   /*number*/ a_width,
                   /*number*/ a_height,
                   /*object*/ a_miscArgs) {
    this.i_html          = a_html;
    this.i_targetElemId  = a_targetElemId;
    this.i_targetFrameId = a_targetFrameId;
    this.i_width         = a_width;
    this.i_height        = a_height;
    this.i_miscArgs      = a_miscArgs;
}

f_idea_embedHtmlHelper.prototype.f_getHtmlDom = 
/*DOMElement*/ function (/*string*/ a_html) {
	var htmlDom = document.createElement("div");
    htmlDom.innerHTML = a_html;
	return htmlDom;
}

f_idea_embedHtmlHelper.prototype.f_embedSafeHtml = 
/*void*/ function (/*string*/ a_safeHtml, /*string*/ a_targetElemId, /*string*/ a_targetFrameId) {
    var trgElem;
	if (a_targetFrameId) {
		var trgFrame = f_sapir_get_frame(a_targetFrameId);
		trgElem = f_sapir_get_element_by_id( f_sapir_frame_document(trgFrame), a_targetElemId );
	} else {
		trgElem = f_sapir_get_element_by_id(document, a_targetElemId);
	}
	trgElem.innerHTML = a_safeHtml;
}
 
/*/
\ \		Functionality that can be overridden in derived functions
/*/

f_idea_embedHtmlHelper.prototype.f_go = 
/*void*/ function () {
    var htmlDom = this.f_getHtmlDom(this.i_html);
    var argsMap = new Object();
    this.f_extractArgs(htmlDom, argsMap);
    var safeHtml = this.f_createSafeHtml(argsMap, this.i_htmlTmpl);
    this.f_embedSafeHtml(safeHtml, this.i_targetElemId, this.i_targetFrameId);
}
 
/*/
\ \		Functionality that must be implemented in derived functions
/*/

f_idea_embedHtmlHelper.prototype.f_extractArgs = 
/*void*/ function (/*DOMElement*/ a_htmlDom, /*object*/ a_argsMap) {
}

f_idea_embedHtmlHelper.prototype.f_createSafeHtml = 
/*string*/ function (/*object*/ a_argsMap, /*string*/ a_htmlTmpl) {
}

////////////////////// end of EmbedHtmlHelper.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from LyteBox.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//***********************************************************************************************************************************/
//	LyteBox v3.22
//
//	 Author: Markus F. Hay
//  Website: http://www.dolem.com/lytebox
//	   Date: October 2, 2007
//	License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)
// Browsers: Tested successfully on WinXP with the following browsers (using no DOCTYPE and Strict/Transitional/Loose DOCTYPES):
//				* Firefox: 2.0.0.7, 1.5.0.12
//				* Internet Explorer: 7.0, 6.0 SP2, 5.5 SP2
//				* Opera: 9.23
//
// Releases: For up-to-date and complete release information, visit http://www.dolem.com/forum/showthread.php?tid=62
//				* v3.22 (10/02/07)
//				* v3.21 (09/30/07)
//				* v3.20 (07/12/07)
//				* v3.10 (05/28/07)
//				* v3.00 (05/15/07)
//				* v2.02 (11/13/06)
//
//   Credit: LyteBox was originally derived from the Lightbox class (v2.02) that was written by Lokesh Dhakar. For more
//			 information please visit http://huddletogether.com/projects/lightbox2/
//***********************************************************************************************************************************/
Array.prototype.removeDuplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } }
Array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } }
String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); }

function LyteBox() {
	/*** Start Global Configuration ***/
		this.theme				= 'grey';	// themes: grey (default), red, green, blue, gold
		this.hideFlash			= true;		// controls whether or not Flash objects should be hidden
		this.outerBorder		= true;		// controls whether to show the outer grey (or theme) border
		this.resizeSpeed		= 8;		// controls the speed of the image resizing (1=slowest and 10=fastest)
		this.maxOpacity			= 30;		// higher opacity = darker overlay, lower opacity = lighter overlay
		this.navType			= 1;		// 1 = "Prev/Next" buttons on top left and left (default), 2 = "<< prev | next >>" links next to image number
		this.autoResize			= true;		// controls whether or not images should be resized if larger than the browser window dimensions
		this.doAnimations		= true;		// controls whether or not "animate" Lytebox, i.e. resize transition between images, fade in/out effects, etc.
		
		this.borderSize			= 12;		// if you adjust the padding in the CSS, you will need to update this variable -- otherwise, leave this alone...
	/*** End Global Configuration ***/
	
	/*** Configure Slideshow Options ***/
		this.slideInterval		= 4000;		// Change value (milliseconds) to increase/decrease the time between "slides" (10000 = 10 seconds)
		this.showNavigation		= true;		// true to display Next/Prev buttons/text during slideshow, false to hide
		this.showClose			= true;		// true to display the Close button, false to hide
		this.showDetails		= true;		// true to display image details (caption, count), false to hide
		this.showPlayPause		= true;		// true to display pause/play buttons next to close button, false to hide
		this.autoEnd			= true;		// true to automatically close Lytebox after the last image is reached, false to keep open
		this.pauseOnNextClick	= false;	// true to pause the slideshow when the "Next" button is clicked
        this.pauseOnPrevClick 	= true;		// true to pause the slideshow when the "Prev" button is clicked
	/*** End Slideshow Configuration ***/
	
	if(this.resizeSpeed > 10) { this.resizeSpeed = 10; }
	if(this.resizeSpeed < 1) { resizeSpeed = 1; }
	this.resizeDuration = (11 - this.resizeSpeed) * 0.15;
	this.resizeWTimerArray		= new Array();
	this.resizeWTimerCount		= 0;
	this.resizeHTimerArray		= new Array();
	this.resizeHTimerCount		= 0;
	this.showContentTimerArray	= new Array();
	this.showContentTimerCount	= 0;
	this.overlayTimerArray		= new Array();
	this.overlayTimerCount		= 0;
	this.imageTimerArray		= new Array();
	this.imageTimerCount		= 0;
	this.timerIDArray			= new Array();
	this.timerIDCount			= 0;
	this.slideshowIDArray		= new Array();
	this.slideshowIDCount		= 0;
	this.imageArray	 = new Array();
	this.activeImage = null;
	this.slideArray	 = new Array();
	this.activeSlide = null;
	this.frameArray	 = new Array();
	this.activeFrame = null;
	this.checkFrame();
	this.isSlideshow = false;
	this.isLyteframe = false;
	/*@cc_on
		/*@if (@_jscript)
			this.ie = (document.all && !window.opera) ? true : false;
		/*@else @*/
			this.ie = false;
		/*@end
	@*/
	this.ie7 = (this.ie && window.XMLHttpRequest);	
	this.initialize();
}
LyteBox.prototype.initialize = function() {
	this.updateLyteboxItems();
	var objBody = this.doc.getElementsByTagName("body").item(0);	
	if (this.doc.getElementById('lbOverlay')) {
		objBody.removeChild(this.doc.getElementById("lbOverlay"));
		objBody.removeChild(this.doc.getElementById("lbMain"));
	}
	var objOverlay = this.doc.createElement("div");
		objOverlay.setAttribute('id','lbOverlay');
		objOverlay.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		if ((this.ie && !this.ie7) || (this.ie7 && this.doc.compatMode == 'BackCompat')) {
			objOverlay.style.position = 'absolute';
		}
		objOverlay.style.display = 'none';
		objBody.appendChild(objOverlay);
	var objLytebox = this.doc.createElement("div");
		objLytebox.setAttribute('id','lbMain');
		objLytebox.style.display = 'none';
		objBody.appendChild(objLytebox);
	var objOuterContainer = this.doc.createElement("div");
		objOuterContainer.setAttribute('id','lbOuterContainer');
		objOuterContainer.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objLytebox.appendChild(objOuterContainer);
	var objIframeContainer = this.doc.createElement("div");
		objIframeContainer.setAttribute('id','lbIframeContainer');
		objIframeContainer.style.display = 'none';
		objOuterContainer.appendChild(objIframeContainer);
	var objIframe = this.doc.createElement("iframe");
		objIframe.setAttribute('id','lbIframe');
		objIframe.setAttribute('name','lbIframe');
		objIframe.style.display = 'none';
		objIframeContainer.appendChild(objIframe);
	var objImageContainer = this.doc.createElement("div");
		objImageContainer.setAttribute('id','lbImageContainer');
		objOuterContainer.appendChild(objImageContainer);
	var objLyteboxImage = this.doc.createElement("img");
		objLyteboxImage.setAttribute('id','lbImage');
		objImageContainer.appendChild(objLyteboxImage);
	var objLoading = this.doc.createElement("div");
		objLoading.setAttribute('id','lbLoading');
		objOuterContainer.appendChild(objLoading);
	var objDetailsContainer = this.doc.createElement("div");
		objDetailsContainer.setAttribute('id','lbDetailsContainer');
		objDetailsContainer.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objLytebox.appendChild(objDetailsContainer);
	var objDetailsData =this.doc.createElement("div");
		objDetailsData.setAttribute('id','lbDetailsData');
		objDetailsData.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objDetailsContainer.appendChild(objDetailsData);
	var objDetails = this.doc.createElement("div");
		objDetails.setAttribute('id','lbDetails');
		objDetailsData.appendChild(objDetails);
	var objCaption = this.doc.createElement("span");
		objCaption.setAttribute('id','lbCaption');
		objDetails.appendChild(objCaption);
	var objHoverNav = this.doc.createElement("div");
		objHoverNav.setAttribute('id','lbHoverNav');
		objImageContainer.appendChild(objHoverNav);
	var objBottomNav = this.doc.createElement("div");
		objBottomNav.setAttribute('id','lbBottomNav');
		objDetailsData.appendChild(objBottomNav);
	var objPrev = this.doc.createElement("a");
		objPrev.setAttribute('id','lbPrev');
		objPrev.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objPrev.setAttribute('href','#');
		objHoverNav.appendChild(objPrev);
	var objNext = this.doc.createElement("a");
		objNext.setAttribute('id','lbNext');
		objNext.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objNext.setAttribute('href','#');
		objHoverNav.appendChild(objNext);
	var objNumberDisplay = this.doc.createElement("span");
		objNumberDisplay.setAttribute('id','lbNumberDisplay');
		objDetails.appendChild(objNumberDisplay);
	var objNavDisplay = this.doc.createElement("span");
		objNavDisplay.setAttribute('id','lbNavDisplay');
		objNavDisplay.style.display = 'none';
		objDetails.appendChild(objNavDisplay);
	var objClose = this.doc.createElement("a");
		objClose.setAttribute('id','lbClose');
		objClose.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objClose.setAttribute('href','#');
		objBottomNav.appendChild(objClose);
	var objPause = this.doc.createElement("a");
		objPause.setAttribute('id','lbPause');
		objPause.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objPause.setAttribute('href','#');
		objPause.style.display = 'none';
		objBottomNav.appendChild(objPause);
	var objPlay = this.doc.createElement("a");
		objPlay.setAttribute('id','lbPlay');
		objPlay.setAttribute((this.ie ? 'className' : 'class'), this.theme);
		objPlay.setAttribute('href','#');
		objPlay.style.display = 'none';
		objBottomNav.appendChild(objPlay);
};
LyteBox.prototype.updateLyteboxItems = function() {	
	var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		var relAttribute = String(anchor.getAttribute('rel'));
		if (anchor.getAttribute('href')) {
			if (relAttribute.toLowerCase().match('lytebox')) {
				anchor.onclick = function () { myLytebox.start(this, false, false); return false; }
			} else if (relAttribute.toLowerCase().match('lyteshow')) {
				anchor.onclick = function () { myLytebox.start(this, true, false); return false; }
			} else if (relAttribute.toLowerCase().match('lyteframe')) {
				anchor.onclick = function () { myLytebox.start(this, false, true); return false; }
			}
		}
	}
};
LyteBox.prototype.start = function(imageLink, doSlide, doFrame) {
	if (this.ie && !this.ie7) {	this.toggleSelects('hide');	}
	if (this.hideFlash) { this.toggleFlash('hide'); }
	this.isLyteframe = (doFrame ? true : false);
	var pageSize	= this.getPageSize();
	var objOverlay	= this.doc.getElementById('lbOverlay');
	var objBody		= this.doc.getElementsByTagName("body").item(0);
	objOverlay.style.height = pageSize[1] + "px";
	objOverlay.style.display = '';
	this.appear('lbOverlay', (this.doAnimations ? 0 : this.maxOpacity));
	var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
	if (this.isLyteframe) {
		this.frameArray = [];
		this.frameNum = 0;
		if ((imageLink.getAttribute('rel') == 'lyteframe')) {
			var rev = imageLink.getAttribute('rev');
			this.frameArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev)));
		} else {
			if (imageLink.getAttribute('rel').indexOf('lyteframe') != -1) {
				for (var i = 0; i < anchors.length; i++) {
					var anchor = anchors[i];
					if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {
						var rev = anchor.getAttribute('rev');
						this.frameArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev)));
					}
				}
				this.frameArray.removeDuplicates();
				while(this.frameArray[this.frameNum][0] != imageLink.getAttribute('href')) { this.frameNum++; }
			}
		}
	} else {
		this.imageArray = [];
		this.imageNum = 0;
		this.slideArray = [];
		this.slideNum = 0;
		if ((imageLink.getAttribute('rel') == 'lytebox')) {
			this.imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));
		} else {
			if (imageLink.getAttribute('rel').indexOf('lytebox') != -1) {
				for (var i = 0; i < anchors.length; i++) {
					var anchor = anchors[i];
					if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {
						this.imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
					}
				}
				this.imageArray.removeDuplicates();
				while(this.imageArray[this.imageNum][0] != imageLink.getAttribute('href')) { this.imageNum++; }
			}
			if (imageLink.getAttribute('rel').indexOf('lyteshow') != -1) {
				for (var i = 0; i < anchors.length; i++) {
					var anchor = anchors[i];
					if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) {
						this.slideArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
					}
				}
				this.slideArray.removeDuplicates();
				while(this.slideArray[this.slideNum][0] != imageLink.getAttribute('href')) { this.slideNum++; }
			}
		}
	}
	var object = this.doc.getElementById('lbMain');
		object.style.top = (this.getPageScroll() + (pageSize[3] / 15)) + "px";
		object.style.display = '';
	if (!this.outerBorder) {
		this.doc.getElementById('lbOuterContainer').style.border = 'none';
		this.doc.getElementById('lbDetailsContainer').style.border = 'none';
	} else {
		this.doc.getElementById('lbOuterContainer').style.borderBottom = '';
		this.doc.getElementById('lbOuterContainer').setAttribute((this.ie ? 'className' : 'class'), this.theme);
	}
	this.doc.getElementById('lbOverlay').onclick = function() { myLytebox.end(); return false; }
	this.doc.getElementById('lbMain').onclick = function(e) {
		var e = e;
		if (!e) {
			if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {
				e = window.parent.window.event;
			} else {
				e = window.event;
			}
		}
		var id = (e.target ? e.target.id : e.srcElement.id);
		if (id == 'lbMain') { myLytebox.end(); return false; }
	}
	this.doc.getElementById('lbClose').onclick = function() { myLytebox.end(); return false; }
	this.doc.getElementById('lbPause').onclick = function() { myLytebox.togglePlayPause("lbPause", "lbPlay"); return false; }
	this.doc.getElementById('lbPlay').onclick = function() { myLytebox.togglePlayPause("lbPlay", "lbPause"); return false; }	
	this.isSlideshow = doSlide;
	this.isPaused = (this.slideNum != 0 ? true : false);
	if (this.isSlideshow && this.showPlayPause && this.isPaused) {
		this.doc.getElementById('lbPlay').style.display = '';
		this.doc.getElementById('lbPause').style.display = 'none';
	}
	if (this.isLyteframe) {
		this.changeContent(this.frameNum);
	} else {
		if (this.isSlideshow) {
			this.changeContent(this.slideNum);
		} else {
			this.changeContent(this.imageNum);
		}
	}
};
LyteBox.prototype.changeContent = function(imageNum) {
	if (this.isSlideshow) {
		for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
	}
	this.activeImage = this.activeSlide = this.activeFrame = imageNum;
	if (!this.outerBorder) {
		this.doc.getElementById('lbOuterContainer').style.border = 'none';
		this.doc.getElementById('lbDetailsContainer').style.border = 'none';
	} else {
		this.doc.getElementById('lbOuterContainer').style.borderBottom = '';
		this.doc.getElementById('lbOuterContainer').setAttribute((this.ie ? 'className' : 'class'), this.theme);
	}
	this.doc.getElementById('lbLoading').style.display = '';
	this.doc.getElementById('lbImage').style.display = 'none';
	this.doc.getElementById('lbIframe').style.display = 'none';
	this.doc.getElementById('lbPrev').style.display = 'none';
	this.doc.getElementById('lbNext').style.display = 'none';
	this.doc.getElementById('lbIframeContainer').style.display = 'none';
	this.doc.getElementById('lbDetailsContainer').style.display = 'none';
	this.doc.getElementById('lbNumberDisplay').style.display = 'none';
	if (this.navType == 2 || this.isLyteframe) {
		object = this.doc.getElementById('lbNavDisplay');
		object.innerHTML = '&nbsp;&nbsp;&nbsp;<span id="lbPrev2_Off" style="display: none;" class="' + this.theme + '">&laquo; prev</span><a href="#" id="lbPrev2" class="' + this.theme + '" style="display: none;">&laquo; prev</a> <b id="lbSpacer" class="' + this.theme + '">||</b> <span id="lbNext2_Off" style="display: none;" class="' + this.theme + '">next &raquo;</span><a href="#" id="lbNext2" class="' + this.theme + '" style="display: none;">next &raquo;</a>';
		object.style.display = 'none';
	}
	if (this.isLyteframe) {
		var iframe = myLytebox.doc.getElementById('lbIframe');
		var styles = this.frameArray[this.activeFrame][2];
		var aStyles = styles.split(';');
		for (var i = 0; i < aStyles.length; i++) {
			if (aStyles[i].indexOf('width:') >= 0) {
				var w = aStyles[i].replace('width:', '');
				iframe.width = w.trim();
			} else if (aStyles[i].indexOf('height:') >= 0) {
				var h = aStyles[i].replace('height:', '');
				iframe.height = h.trim();
			} else if (aStyles[i].indexOf('scrolling:') >= 0) {
				var s = aStyles[i].replace('scrolling:', '');
				iframe.scrolling = s.trim();
			} else if (aStyles[i].indexOf('border:') >= 0) {
				// Not implemented yet, as there are cross-platform issues with setting the border (from a GUI standpoint)
				//var b = aStyles[i].replace('border:', '');
				//iframe.style.border = b.trim();
			}
		}
		this.resizeContainer(parseInt(iframe.width), parseInt(iframe.height));
	} else {
		imgPreloader = new Image();
		imgPreloader.onload = function() {
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (myLytebox.autoResize) {
				var pagesize = myLytebox.getPageSize();
				var x = pagesize[2] - 150;
				var y = pagesize[3] - 150;
				if (imageWidth > x) {
					imageHeight = Math.round(imageHeight * (x / imageWidth));
					imageWidth = x; 
					if (imageHeight > y) { 
						imageWidth = Math.round(imageWidth * (y / imageHeight));
						imageHeight = y; 
					}
				} else if (imageHeight > y) { 
					imageWidth = Math.round(imageWidth * (y / imageHeight));
					imageHeight = y; 
					if (imageWidth > x) {
						imageHeight = Math.round(imageHeight * (x / imageWidth));
						imageWidth = x;
					}
				}
			}
			var lbImage = myLytebox.doc.getElementById('lbImage')
			lbImage.src = (myLytebox.isSlideshow ? myLytebox.slideArray[myLytebox.activeSlide][0] : myLytebox.imageArray[myLytebox.activeImage][0]);
			lbImage.width = imageWidth;
			lbImage.height = imageHeight;
			myLytebox.resizeContainer(imageWidth, imageHeight);
			imgPreloader.onload = function() {};
		}
		imgPreloader.src = (this.isSlideshow ? this.slideArray[this.activeSlide][0] : this.imageArray[this.activeImage][0]);
	}
};
LyteBox.prototype.resizeContainer = function(imgWidth, imgHeight) {
	this.wCur = this.doc.getElementById('lbOuterContainer').offsetWidth;
	this.hCur = this.doc.getElementById('lbOuterContainer').offsetHeight;
	this.xScale = ((imgWidth  + (this.borderSize * 2)) / this.wCur) * 100;
	this.yScale = ((imgHeight  + (this.borderSize * 2)) / this.hCur) * 100;
	var wDiff = (this.wCur - this.borderSize * 2) - imgWidth;
	var hDiff = (this.hCur - this.borderSize * 2) - imgHeight;
	if (!(hDiff == 0)) {
		this.hDone = false;
		this.resizeH('lbOuterContainer', this.hCur, imgHeight + this.borderSize*2, this.getPixelRate(this.hCur, imgHeight));
	} else {
		this.hDone = true;
	}
	if (!(wDiff == 0)) {
		this.wDone = false;
		this.resizeW('lbOuterContainer', this.wCur, imgWidth + this.borderSize*2, this.getPixelRate(this.wCur, imgWidth));
	} else {
		this.wDone = true;
	}
	if ((hDiff == 0) && (wDiff == 0)) {
		if (this.ie){ this.pause(250); } else { this.pause(100); } 
	}
	this.doc.getElementById('lbPrev').style.height = imgHeight + "px";
	this.doc.getElementById('lbNext').style.height = imgHeight + "px";
	this.doc.getElementById('lbDetailsContainer').style.width = (imgWidth + (this.borderSize * 2) + (this.ie && this.doc.compatMode == "BackCompat" && this.outerBorder ? 2 : 0)) + "px";
	this.showContent();
};
LyteBox.prototype.showContent = function() {
	if (this.wDone && this.hDone) {
		for (var i = 0; i < this.showContentTimerCount; i++) { window.clearTimeout(this.showContentTimerArray[i]); }
		if (this.outerBorder) {
			this.doc.getElementById('lbOuterContainer').style.borderBottom = 'none';
		}
		this.doc.getElementById('lbLoading').style.display = 'none';
		if (this.isLyteframe) {
			this.doc.getElementById('lbIframe').style.display = '';
			this.appear('lbIframe', (this.doAnimations ? 0 : 100));
		} else {
			this.doc.getElementById('lbImage').style.display = '';
			this.appear('lbImage', (this.doAnimations ? 0 : 100));
			this.preloadNeighborImages();
		}
		if (this.isSlideshow) {
			if(this.activeSlide == (this.slideArray.length - 1)) {
				if (this.autoEnd) {
					this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("myLytebox.end('slideshow')", this.slideInterval);
				}
			} else {
				if (!this.isPaused) {
					this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("myLytebox.changeContent("+(this.activeSlide+1)+")", this.slideInterval);
				}
			}
			this.doc.getElementById('lbHoverNav').style.display = (this.showNavigation && this.navType == 1 ? '' : 'none');
			this.doc.getElementById('lbClose').style.display = (this.showClose ? '' : 'none');
			this.doc.getElementById('lbDetails').style.display = (this.showDetails ? '' : 'none');
			this.doc.getElementById('lbPause').style.display = (this.showPlayPause && !this.isPaused ? '' : 'none');
			this.doc.getElementById('lbPlay').style.display = (this.showPlayPause && !this.isPaused ? 'none' : '');
			this.doc.getElementById('lbNavDisplay').style.display = (this.showNavigation && this.navType == 2 ? '' : 'none');
		} else {
			this.doc.getElementById('lbHoverNav').style.display = (this.navType == 1 && !this.isLyteframe ? '' : 'none');
			if ((this.navType == 2 && !this.isLyteframe && this.imageArray.length > 1) || (this.frameArray.length > 1 && this.isLyteframe)) {
				this.doc.getElementById('lbNavDisplay').style.display = '';
			} else {
				this.doc.getElementById('lbNavDisplay').style.display = 'none';
			}
			this.doc.getElementById('lbClose').style.display = '';
			this.doc.getElementById('lbDetails').style.display = '';
			this.doc.getElementById('lbPause').style.display = 'none';
			this.doc.getElementById('lbPlay').style.display = 'none';
		}
		this.doc.getElementById('lbImageContainer').style.display = (this.isLyteframe ? 'none' : '');
		this.doc.getElementById('lbIframeContainer').style.display = (this.isLyteframe ? '' : 'none');
		try {
			this.doc.getElementById('lbIframe').src = this.frameArray[this.activeFrame][0];
		} catch(e) { }
	} else {
		this.showContentTimerArray[this.showContentTimerCount++] = setTimeout("myLytebox.showContent()", 200);
	}
};
LyteBox.prototype.updateDetails = function() {
	var object = this.doc.getElementById('lbCaption');
	var sTitle = (this.isSlideshow ? this.slideArray[this.activeSlide][1] : (this.isLyteframe ? this.frameArray[this.activeFrame][1] : this.imageArray[this.activeImage][1]));
	object.style.display = '';
	object.innerHTML = (sTitle == null ? '' : sTitle);
	this.updateNav();
	this.doc.getElementById('lbDetailsContainer').style.display = '';
	object = this.doc.getElementById('lbNumberDisplay');
	if (this.isSlideshow && this.slideArray.length > 1) {
		object.style.display = '';
		object.innerHTML = "Image " + eval(this.activeSlide + 1) + " of " + this.slideArray.length;
		this.doc.getElementById('lbNavDisplay').style.display = (this.navType == 2 && this.showNavigation ? '' : 'none');
	} else if (this.imageArray.length > 1 && !this.isLyteframe) {
		object.style.display = '';
		object.innerHTML = "Image " + eval(this.activeImage + 1) + " of " + this.imageArray.length;
		this.doc.getElementById('lbNavDisplay').style.display = (this.navType == 2 ? '' : 'none');
	} else if (this.frameArray.length > 1 && this.isLyteframe) {
		object.style.display = '';
		object.innerHTML = "Page " + eval(this.activeFrame + 1) + " of " + this.frameArray.length;
		this.doc.getElementById('lbNavDisplay').style.display = '';
	} else {
		this.doc.getElementById('lbNavDisplay').style.display = 'none';
	}
	this.appear('lbDetailsContainer', (this.doAnimations ? 0 : 100));
};
LyteBox.prototype.updateNav = function() {
	if (this.isSlideshow) {
		if (this.activeSlide != 0) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbPrev2') : this.doc.getElementById('lbPrev'));
				object.style.display = '';
				object.onclick = function() {
					if (myLytebox.pauseOnPrevClick) { myLytebox.togglePlayPause("lbPause", "lbPlay"); }
					myLytebox.changeContent(myLytebox.activeSlide - 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbPrev2_Off').style.display = ''; }
		}
		if (this.activeSlide != (this.slideArray.length - 1)) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbNext2') : this.doc.getElementById('lbNext'));
				object.style.display = '';
				object.onclick = function() {
					if (myLytebox.pauseOnNextClick) { myLytebox.togglePlayPause("lbPause", "lbPlay"); }
					myLytebox.changeContent(myLytebox.activeSlide + 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbNext2_Off').style.display = ''; }
		}
	} else if (this.isLyteframe) {
		if(this.activeFrame != 0) {
			var object = this.doc.getElementById('lbPrev2');
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeFrame - 1); return false;
				}
		} else {
			this.doc.getElementById('lbPrev2_Off').style.display = '';
		}
		if(this.activeFrame != (this.frameArray.length - 1)) {
			var object = this.doc.getElementById('lbNext2');
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeFrame + 1); return false;
				}
		} else {
			this.doc.getElementById('lbNext2_Off').style.display = '';
		}		
	} else {
		if(this.activeImage != 0) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbPrev2') : this.doc.getElementById('lbPrev'));
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeImage - 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbPrev2_Off').style.display = ''; }
		}
		if(this.activeImage != (this.imageArray.length - 1)) {
			var object = (this.navType == 2 ? this.doc.getElementById('lbNext2') : this.doc.getElementById('lbNext'));
				object.style.display = '';
				object.onclick = function() {
					myLytebox.changeContent(myLytebox.activeImage + 1); return false;
				}
		} else {
			if (this.navType == 2) { this.doc.getElementById('lbNext2_Off').style.display = ''; }
		}
	}
	this.enableKeyboardNav();
};
LyteBox.prototype.enableKeyboardNav = function() { document.onkeydown = this.keyboardAction; };
LyteBox.prototype.disableKeyboardNav = function() { document.onkeydown = ''; };
LyteBox.prototype.keyboardAction = function(e) {
	var keycode = key = escape = null;
	keycode	= (e == null) ? event.keyCode : e.which;
	key		= String.fromCharCode(keycode).toLowerCase();
	escape  = (e == null) ? 27 : e.DOM_VK_ESCAPE;
	if ((key == 'x') || (key == 'c') || (keycode == escape)) {
		myLytebox.end();
	} else if ((key == 'p') || (keycode == 37)) {
		if (myLytebox.isSlideshow) {
			if(myLytebox.activeSlide != 0) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeSlide - 1);
			}
		} else if (myLytebox.isLyteframe) {
			if(myLytebox.activeFrame != 0) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeFrame - 1);
			}
		} else {
			if(myLytebox.activeImage != 0) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeImage - 1);
			}
		}
	} else if ((key == 'n') || (keycode == 39)) {
		if (myLytebox.isSlideshow) {
			if(myLytebox.activeSlide != (myLytebox.slideArray.length - 1)) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeSlide + 1);
			}
		} else if (myLytebox.isLyteframe) {
			if(myLytebox.activeFrame != (myLytebox.frameArray.length - 1)) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeFrame + 1);
			}
		} else {
			if(myLytebox.activeImage != (myLytebox.imageArray.length - 1)) {
				myLytebox.disableKeyboardNav();
				myLytebox.changeContent(myLytebox.activeImage + 1);
			}
		}
	}
};
LyteBox.prototype.preloadNeighborImages = function() {
	if (this.isSlideshow) {
		if ((this.slideArray.length - 1) > this.activeSlide) {
			preloadNextImage = new Image();
			preloadNextImage.src = this.slideArray[this.activeSlide + 1][0];
		}
		if(this.activeSlide > 0) {
			preloadPrevImage = new Image();
			preloadPrevImage.src = this.slideArray[this.activeSlide - 1][0];
		}
	} else {
		if ((this.imageArray.length - 1) > this.activeImage) {
			preloadNextImage = new Image();
			preloadNextImage.src = this.imageArray[this.activeImage + 1][0];
		}
		if(this.activeImage > 0) {
			preloadPrevImage = new Image();
			preloadPrevImage.src = this.imageArray[this.activeImage - 1][0];
		}
	}
};
LyteBox.prototype.togglePlayPause = function(hideID, showID) {
	if (this.isSlideshow && hideID == "lbPause") {
		for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
	}
	this.doc.getElementById(hideID).style.display = 'none';
	this.doc.getElementById(showID).style.display = '';
	if (hideID == "lbPlay") {
		this.isPaused = false;
		if (this.activeSlide == (this.slideArray.length - 1)) {
			this.end();
		} else {
			this.changeContent(this.activeSlide + 1);
		}
	} else {
		this.isPaused = true;
	}
};
LyteBox.prototype.end = function(caller) {
	var closeClick = (caller == 'slideshow' ? false : true);
	if (this.isSlideshow && this.isPaused && !closeClick) { return; }
	this.disableKeyboardNav();
	this.doc.getElementById('lbMain').style.display = 'none';
	this.fade('lbOverlay', (this.doAnimations ? this.maxOpacity : 0));
	this.toggleSelects('visible');
	if (this.hideFlash) { this.toggleFlash('visible'); }
	if (this.isSlideshow) {
		for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
	}
	if (this.isLyteframe) {
		 this.initialize();
	}
};
LyteBox.prototype.checkFrame = function() {
	if (window.location.href != parent.location.href &&
			window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {
		this.isFrame = true;
		this.lytebox = "window.parent." + window.name + ".myLytebox";
		this.doc = parent.document;
	} else {
		this.isFrame = false;
		this.lytebox = "myLytebox";
		this.doc = document;
	}
};
LyteBox.prototype.getPixelRate = function(cur, img) {
	var diff = (img > cur) ? img - cur : cur - img;
	if (diff >= 0 && diff <= 100) { return 10; }
	if (diff > 100 && diff <= 200) { return 15; }
	if (diff > 200 && diff <= 300) { return 20; }
	if (diff > 300 && diff <= 400) { return 25; }
	if (diff > 400 && diff <= 500) { return 30; }
	if (diff > 500 && diff <= 600) { return 35; }
	if (diff > 600 && diff <= 700) { return 40; }
	if (diff > 700) { return 45; }
};
LyteBox.prototype.appear = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + (opacity + 10) + ")";
	if (opacity == 100 && (id == 'lbImage' || id == 'lbIframe')) {
		try { object.removeAttribute("filter"); } catch(e) {}	/* Fix added for IE Alpha Opacity Filter bug. */
		this.updateDetails();
	} else if (opacity >= this.maxOpacity && id == 'lbOverlay') {
		for (var i = 0; i < this.overlayTimerCount; i++) { window.clearTimeout(this.overlayTimerArray[i]); }
		return;
	} else if (opacity >= 100 && id == 'lbDetailsContainer') {
		try { object.removeAttribute("filter"); } catch(e) {}	/* Fix added for IE Alpha Opacity Filter bug. */
		for (var i = 0; i < this.imageTimerCount; i++) { window.clearTimeout(this.imageTimerArray[i]); }
		this.doc.getElementById('lbOverlay').style.height = this.getPageSize()[1] + "px";
	} else {
		if (id == 'lbOverlay') {
			this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("myLytebox.appear('" + id + "', " + (opacity+20) + ")", 1);
		} else {
			this.imageTimerArray[this.imageTimerCount++] = setTimeout("myLytebox.appear('" + id + "', " + (opacity+10) + ")", 1);
		}
	}
};
LyteBox.prototype.fade = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if (opacity <= 0) {
		try {
			object.display = 'none';
		} catch(err) { }
	} else if (id == 'lbOverlay') {
		this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("myLytebox.fade('" + id + "', " + (opacity-20) + ")", 1);
	} else {
		this.timerIDArray[this.timerIDCount++] = setTimeout("myLytebox.fade('" + id + "', " + (opacity-10) + ")", 1);
	}
};
LyteBox.prototype.resizeW = function(id, curW, maxW, pixelrate, speed) {
	if (!this.hDone) {
		this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("myLytebox.resizeW('" + id + "', " + curW + ", " + maxW + ", " + pixelrate + ")", 100);
		return;
	}
	var object = this.doc.getElementById(id);
	var timer = speed ? speed : (this.resizeDuration/2);
	var newW = (this.doAnimations ? curW : maxW);
	object.style.width = (newW) + "px";
	if (newW < maxW) {
		newW += (newW + pixelrate >= maxW) ? (maxW - newW) : pixelrate;
	} else if (newW > maxW) {
		newW -= (newW - pixelrate <= maxW) ? (newW - maxW) : pixelrate;
	}
	this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("myLytebox.resizeW('" + id + "', " + newW + ", " + maxW + ", " + pixelrate + ", " + (timer+0.02) + ")", timer+0.02);
	if (parseInt(object.style.width) == maxW) {
		this.wDone = true;
		for (var i = 0; i < this.resizeWTimerCount; i++) { window.clearTimeout(this.resizeWTimerArray[i]); }
	}
};
LyteBox.prototype.resizeH = function(id, curH, maxH, pixelrate, speed) {
	var timer = speed ? speed : (this.resizeDuration/2);
	var object = this.doc.getElementById(id);
	var newH = (this.doAnimations ? curH : maxH);
	object.style.height = (newH) + "px";
	if (newH < maxH) {
		newH += (newH + pixelrate >= maxH) ? (maxH - newH) : pixelrate;
	} else if (newH > maxH) {
		newH -= (newH - pixelrate <= maxH) ? (newH - maxH) : pixelrate;
	}
	this.resizeHTimerArray[this.resizeHTimerCount++] = setTimeout("myLytebox.resizeH('" + id + "', " + newH + ", " + maxH + ", " + pixelrate + ", " + (timer+.02) + ")", timer+.02);
	if (parseInt(object.style.height) == maxH) {
		this.hDone = true;
		for (var i = 0; i < this.resizeHTimerCount; i++) { window.clearTimeout(this.resizeHTimerArray[i]); }
	}
};
LyteBox.prototype.getPageScroll = function() {
	if (self.pageYOffset) {
		return this.isFrame ? parent.pageYOffset : self.pageYOffset;
	} else if (this.doc.documentElement && this.doc.documentElement.scrollTop){
		return this.doc.documentElement.scrollTop;
	} else if (document.body) {
		return this.doc.body.scrollTop;
	}
};
LyteBox.prototype.getPageSize = function() {	
	var xScroll, yScroll, windowWidth, windowHeight;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = this.doc.scrollWidth;
		yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
	} else if (this.doc.body.scrollHeight > this.doc.body.offsetHeight){
		xScroll = this.doc.body.scrollWidth;
		yScroll = this.doc.body.scrollHeight;
	} else {
		xScroll = this.doc.getElementsByTagName("html").item(0).offsetWidth;
		yScroll = this.doc.getElementsByTagName("html").item(0).offsetHeight;
		xScroll = (xScroll < this.doc.body.offsetWidth) ? this.doc.body.offsetWidth : xScroll;
		yScroll = (yScroll < this.doc.body.offsetHeight) ? this.doc.body.offsetHeight : yScroll;
	}
	if (self.innerHeight) {
		windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;
		windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = this.doc.documentElement.clientWidth;
		windowHeight = this.doc.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = this.doc.getElementsByTagName("html").item(0).clientWidth;
		windowHeight = this.doc.getElementsByTagName("html").item(0).clientHeight;
		windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;
		windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;
	}
	var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
	var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
	return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
};
LyteBox.prototype.toggleFlash = function(state) {
	var objects = this.doc.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) {
		objects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	var embeds = this.doc.getElementsByTagName("embed");
	for (var i = 0; i < embeds.length; i++) {
		embeds[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	if (this.isFrame) {
		for (var i = 0; i < parent.frames.length; i++) {
			try {
				objects = parent.frames[i].window.document.getElementsByTagName("object");
				for (var j = 0; j < objects.length; j++) {
					objects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';
				}
			} catch(e) { }
			try {
				embeds = parent.frames[i].window.document.getElementsByTagName("embed");
				for (var j = 0; j < embeds.length; j++) {
					embeds[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';
				}
			} catch(e) { }
		}
	}
};
LyteBox.prototype.toggleSelects = function(state) {
	var selects = this.doc.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i++ ) {
		selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	if (this.isFrame) {
		for (var i = 0; i < parent.frames.length; i++) {
			try {
				selects = parent.frames[i].window.document.getElementsByTagName("select");
				for (var j = 0; j < selects.length; j++) {
					selects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible';
				}
			} catch(e) { }
		}
	}
};
LyteBox.prototype.pause = function(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime) { return; }
	}
};
/* commented : moved to f_sapir_onload
if (window.addEventListener) {
	window.addEventListener("load",initLytebox,false);
} else if (window.attachEvent) {
	window.attachEvent("onload",initLytebox);
} else {
	window.onload = function() {initLytebox();}
}
*/
function initLytebox() { myLytebox = new LyteBox(); }

////////////////////// end of LyteBox.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from jquery.min.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*
 * jQuery JavaScript Library v1.3.2
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 * Revision: 6246
 */
(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
/*
 * Sizzle CSS Selector Engine - v0.9.3
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML='   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();

////////////////////// end of jQuery.min.js ///////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// taken from pb10_htmldw.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//**************************************************************************

//		Copyright  Sybase, Inc. 1998-1999

//						 All Rights reserved.

//

//	Sybase, Inc. ("Sybase") claims copyright in this

//	program and documentation as an unpublished work, versions of

//	which were first licensed on the date indicated in the foregoing

//	notice.  Claim of copyright does not imply waiver of Sybase's

//	other rights.

//

//	 This code is generated by the PowerBuilder HTML DataWindow generator.

//	 It is provided subject to the terms of the Sybase License Agreement

//	 for use as is, without alteration or modification.  

//	 Sybase shall have no obligation to provide support or error correction 

//	 services with respect to any altered or modified versions of this code.  

//

//       ***********************************************************

//       **     DO NOT MODIFY OR ALTER THIS CODE IN ANY WAY       **

//       ***********************************************************

//

//       ***************************************************************

//       ** IMPLEMENTATION DETAILS SUBJECT TO CHANGE WITHOUT NOTICE.  **

//       **            DO NOT RELY ON IMPLEMENTATION!!!!		      **

//       ***************************************************************

//

// Use the public interface only.

//**************************************************************************



// these arrays will be filled with internationalized strings based on the server

var DW_shortDayNames = new Array("Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat");

var DW_longDayNames = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

var DW_shortMonthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

var DW_longMonthNames = new Array("January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");



// this is dependent on the control panel setting on the server

// it indicates the order of days (this is mm/dd/yyyy)

var DW_PARSEDT_monseq = 0;

var DW_PARSEDT_dayseq = 1;

var DW_PARSEDT_yearseq = 2;



// DWItemStatus

var DW_ITEMSTATUS_NOCHANGE = 0;

var DW_ITEMSTATUS_MODIFIED = 1;

var DW_ITEMSTATUS_NEW = 2;

var DW_ITEMSTATUS_NEW_MODIFIED = 3;



// Added to determine if dates are being processed in client side JavaScript.

var bDateTimeProcessingEnabled = false;



var gMask = "";



// common utility functions



function escapeString( inString )

{

    var index;

    var outString = "";

    var tempChar;



    // force to string type or charAt will fail!

    if (typeof inString != "string")

    	inString = inString.toString();



    var strLength = inString.length;

    for ( index=0; index < strLength; index++ )

        {

        tempChar = inString.charAt( index );

        if (tempChar == "\"" || tempChar == "'") 

            outString += "~" + tempChar;

        else if (tempChar == "\r")

            outString += "~r";

        else if (tempChar == "\n")

            outString += "~n";

        else

            outString += tempChar;

        }

    return outString;

}



function convertToRGB( color )

{

	var hexValue = "000000" + eval( color ).toString(16);

	hexValue = hexValue.substr( hexValue.length - 6, 6 );

	hexValue = hexValue.substr( 4, 2 ) + hexValue.substr( 2, 2 ) + hexValue.substr( 0, 2 );

	return hexValue;

}



// default event returns to 0

function _evtDefault (value)

{

    if (value + "" == "undefined")

        return 0;

    return value;

}



// need to double up because of template expander!

function DW_parseIsSpace(theChar)

{

    return /^\s$/.test(theChar);

}



function DW_parseIsDigit(theChar)

{

    return /^\d$/.test(theChar);

}



function DW_parseIsAlpha(theChar)

{

    return /^\w$/.test(theChar) && ! /^\d$/.test(theChar);

}



// auto binding of events expect <controlName>_<eventName>

function HTDW_eventImplemented(sEventName)

{

    // check if we already have one scripted

    if (this[sEventName] == null)

        {

        // check for function with default name

        var testName = this.name + '_' + sEventName;

        if (eval ('typeof ' + testName) == 'function')

            this[sEventName] = eval(testName);

        }



    return this[sEventName] != null;

}



// utility functions

function allowInString (inString, refString)

{

    var index, tempChar;

    var strLength = inString.length;

    for (index=0; index < strLength; index++)

        {

        tempChar= inString.charAt (index);

        if (refString.indexOf (tempChar)==-1)  

            return false;

        }

    return true;

}



function DW_Trim(inString)

{

    var indexStart, indexEnd, tempChar, outString;

    var strLength = inString.length;

    // skip leading blanks

    for (indexStart=0; indexStart < strLength; indexStart++)

        {

        tempChar= inString.charAt (indexStart);

        if (tempChar != " ")

            break;

        }

    if (indexStart != strLength)

        {

        // skip trailing blanks

        for (indexEnd=strLength-1; indexEnd > 0; indexEnd--)

            {

            tempChar= inString.charAt (indexEnd);

            if (tempChar != " ")

                break;

            }

        // get all chars in between

        outString = inString.substring(indexStart, indexEnd+1);

        }

    else

        outString = "";

    return outString;

}



function DW_Round(num, decPlaces)

{

	var powTen = Math.pow(10.0,decPlaces);

	num *= powTen;

	if (num >= 0)

	    num = Math.floor(num + 0.5);

	else

	    num = Math.ceil(num - 0.5);



    return num / powTen;

}



function DW_IsNonNegativeNumber(inString, bNilIsNull)

{

	if (arguments.length < 2)

			bNilIsNull = false;

		if (inString == "")

			return bNilIsNull;

		else

		{

			var newString = DW_Trim(inString);		

			if (newString == "")								

				return false; 										

			else														

			{														

				var result = new DW_NumberClass();	

				if(DW_parseNumberStringAgainstMask(inString, result, false)) 	

				{													

					if (result >= 0) 							

						return true; 								

				}													

				

				return false; 									

			}														

		}

}



function DW_IsValidDisplayOrDataValue(inString, bNilIsNull)

{

    if (arguments.length < 2)

        bNilIsNull = false;

    if (inString == "")

        return bNilIsNull;

    else

        {

        var i;

        for(i = 0; i < this.displayValue.length; i++)

            {

            if (inString == this.displayValue[i])

                return true;		    

            if (inString == this.dataValue[i])

                return true;		    

            }

        return false;

        }

}



function DW_IsNumber(inString, bNilIsNull)

{

	if (arguments.length < 2)

			bNilIsNull = false;

		if (inString == "")

			return bNilIsNull;

		else

		{

			var newString = DW_Trim(inString);		

			if (newString == "")		

				return false;		

			else			

				return DW_parseNumberStringAgainstMask(inString, null, true); 

		}

}



// exprContext class

function HTDW_exprContextClass(dataWindow)

{

    this.dw = dataWindow;

    this.row = -1;

    this.currentText = "";

}



// Col0 class

function HTDW_Col0Class(rowId, dwItemStatus)

{

    this.colModified = new Array();

    this.rowId = rowId;

    this.itemStatus = dwItemStatus;

}



// Row class

function HTDW_RowClass(rowId)
{
	
    var col;

    // column 0 holds special data

    this[0] = new HTDW_Col0Class(rowId, arguments[1]);

    

    // get data values

    for (col = 1; col < arguments.length - 1; col++)

        {

        this[0].colModified[col] = false;

        this[col] = arguments[col + 1];

        }



    this.numCols = arguments.length - 1;

}



function HTDW_Row_generateChange (rowNum, rowObj)

{

    var col;

    var result;



    if (rowObj[0].itemStatus == DW_ITEMSTATUS_MODIFIED ||

        rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED)

        {

        result = "(ModifyRow " + rowNum + " " + rowObj[0].rowId + " (";

        for (col = 1; col < rowObj.numCols; col++)

            {

            if (rowObj[0].colModified[col])

                {

                if (rowObj[col] == null)

                    result += "(" + col + " 1)";

                else

                    result += "(" + col + " 0 '" + escapeString(rowObj[col]) + "')";

                }

            }

        result += "))";

        }

    else

        result = "";



    return result;

}



function HTDW_Row_dumpRow (rowNum, rowObj)

{

    var col;

    var result;



    result = "Row " + rowNum + "\n" + 

             "Modified:" + rowObj[0].itemStatus + "\n" +

             "RowId:" + rowObj[0].rowId + "\n" + 

             "NumCols:" + (rowObj.numCols - 1) + "\n";

             

    for (col = 1; col < rowObj.numCols; col++)

        {

        result += "   Col " + col + " modified:" + rowObj[0].colModified[col] + " '" + rowObj[col] + "'\n";

        }



    // f_sapir_alert (result);

    

    return result;

}



// set up class functions

HTDW_RowClass.generateChange = HTDW_Row_generateChange;

HTDW_RowClass.dumpRow = HTDW_Row_dumpRow;



function HTDW_ColumnGob(name, colNum, rowInDetail, region, bRequired, bNilIsNull, bFocusRect, formatFunc, getDisplayFormatFunc, getEditFormatFunc, column)

{

    this.name = name;

    this.colNum = colNum;

    this.rowInDetail = rowInDetail;

    this.region = region;

    this.bRequired = bRequired;

    this.bNilIsNull = bNilIsNull;

	//yair 6\7\10 : ignore PB focus rectangle
	this.bFocusRect = false;
	//this.bFocusRect = bFocusRect;

	this.bUseCodeTable = false;



    this.getDisplayFormat = getDisplayFormatFunc;

    this.getEditFormat = getEditFormatFunc;

    this.format = formatFunc;

    this.column = column;

}



function HTDW_ComputeGob(name, region, computeFunc, formatFunc, getDisplayFormatFunc)

{

    this.name = name;

    this.region = region;



    this.compute = computeFunc;

    this.getDisplayFormat = getDisplayFormatFunc;

    this.format = formatFunc;

}



// Depend classes common function

// DependCompute class

function HTDW_DependComputeUpdate(htmlDw, row, bSkipCurrent)

{

    var gob = this.gob;

    var control = htmlDw.findControl(htmlDw.name, gob.name, row, gob.region == 0);



    if (control != null && typeof gob.compute == "function")

        {

        // body

        if (gob.region == 0)

            row = row;

        // header

        else if (gob.region == 1)

            row = htmlDw.firstRow;

        // footer or summary

        else if (gob.region == 2 || gob.region == 3)

            row = htmlDw.lastRow;



        var exprCtx = htmlDw.exprCtx;

        exprCtx.row = row;

        exprCtx.currentText = "";



        var value = gob.compute(exprCtx);



        if (control.type == "hidden" || control.type == "password" || 

            control.type == "text" || control.type == "textarea")

            {

            var displayValue;

            if (gob.format != null && gob.getDisplayFormat != null)

                {

                var formatString;

                if (typeof gob.getDisplayFormat == "string")

                    formatString = gob.getDisplayFormat;

                else

                    formatString = gob.getDisplayFormat (exprCtx);

                displayValue = gob.format (formatString, value, control);

                }

            else if (value != null)

                displayValue = value.toString();

            else

                displayValue = "";

            control.value = displayValue;

            }

        }

}



function HTDW_DependCompute(gob)

{

    this.gob = gob;

    

    this.update = HTDW_DependComputeUpdate;

}



// DependColumn class

function HTDW_DependColumnUpdate(htmlDw, row, bSkipCurrent)

{
    var gob = this.gob;
	var control = htmlDw.findControl(htmlDw.name, gob.name, row, gob.region == 0);
    // don't mess with the current control if asked not to

    if (control != null && 

            ! (bSkipCurrent && control == htmlDw.currentControl))

        {

        // body

        if (gob.region == 0)

            row = row + gob.rowInDetail;

        // header

        else if (gob.region == 1)

            row = htmlDw.firstRow;

        // footer or summary

        else if (gob.region == 2 || gob.region == 3)

            row = htmlDw.lastRow;



        var value = htmlDw.rows[row][gob.colNum];



        if (control.type == "hidden" || control.type == "password" || 

            control.type == "text" || control.type == "textarea" ||

            control.type == "select-one")

            {
						f_dbg ("dcu");

            var displayValue;

            if (gob.format != null && gob.getDisplayFormat != null)

                {

                var exprCtx = htmlDw.exprCtx;

                exprCtx.row = row;

                exprCtx.currentText = "";

                if (typeof gob.getDisplayFormat == "string")

                    formatString = gob.getDisplayFormat;

                else

                    formatString = gob.getDisplayFormat (exprCtx);

                displayValue = gob.format (formatString, value, control);

                }

            else if (value != null)

                displayValue = value.toString();

            else

                displayValue = "";

            control.value = displayValue;

            }

        }

}



function HTDW_DependColumn(gob)

{

    this.gob = gob;



    this.update = HTDW_DependColumnUpdate;

}



// Column class

function HTDW_Column_addDepend(depend)

{

    if (this.dependents == null)

        this.dependents = new Array();



    this.dependents[this.dependents.length] = depend;

}

function HTDW_Column_updateDependents(htmlDw, row, bSkipCurrent)

{
	//if (g_sapir_cat_ui_active) {
	//f_sapir_log ("updateDependents", this.dependents, 3);
	//f_sapir_log ("updateDependents", this.dependents.length, 3);
	//}
    if (this.dependents != null)

        {

        for (var i=0; i < this.dependents.length; ++i)
            this.dependents[i].update (htmlDw, row, bSkipCurrent);

        }
}

function HTDW_ColumnClass(colId, name, convertFromStringFunc, typeValidationFunc, itemValidateFunc, validationMessageFunc, computeFunc, displayGobName)

{
	//f_sapir_alert ("HTDW_ColumnClass : " + name);

    this.colId = colId;

    this.name = name;

    this.dependents = null;

    

    this.convertFromString = convertFromStringFunc;

    this.validateByType = typeValidationFunc;

    this.validateItem = itemValidateFunc;

    this.validationError = validationMessageFunc;

    this.compute = computeFunc;

    this.displayGobName = displayGobName;

    

    // interface functions

    this.addDepend = HTDW_Column_addDepend;

    this.updateDependents = HTDW_Column_updateDependents;



    this.displayValue = new Array();

    this.dataValue = new Array()

}



// DataWindow class

function HTDW_findControl(a_htmldw_name, gobName, row, bInBody)

{

	// sapir : added htmldw name arg

    var control = null;

    var controlExists;

    var controlName;

    var controlObject;

	if (g_sapir_cat_ui_active) {
		controlName = a_htmldw_name + "_" + gobName;
	} else {
		controlName = gobName
	}
	
	//if (g_sapir_cat_ui_active) {
	//	f_sapir_log ("findControl", "controlName = " + controlName, 3);
	//}

	// sapir : control row = html row, not dw buffer row
	if (g_sapir_cat_ui_active) {
		var l_sapir_rows;
		l_sapir_rows = eval (a_htmldw_name + ".rows_info");
		if (f_sapir_exists (l_sapir_rows)) {
			var l_sapir_html_row;
			l_sapir_html_row = l_sapir_rows [ row - 1].html_row_no;
		}
	} else {
		l_sapir_html_row = row;
	}

    if (bInBody)
		controlName += "_" + l_sapir_html_row;
        // pb orig : controlName += "_" + row;

	//if (g_sapir_cat_ui_active) {
	//	f_sapir_log ("findControl", "final controlName = " + controlName, 3);
	//}

    if (this.dataForm + "" != "undefined")

        {
			if (g_sapir_cat_ui_active) {
				controlObject = f_sapir_get_element_by_id (window.document, controlName);
				//if (g_sapir_cat_ui_active) {
				//f_sapir_log ("findControl", "controlObject = " + controlObject.name, 3);
				//}
		        controlExists = typeof controlObject;
			} else {
				controlObject = f_sapir_get_element_by_id (window.document, controlName);
				controlExists = typeof controlObject;
		        //controlObject = 'this.dataForm.' + controlName;
		        //controlExists = eval('typeof ' + controlObject);
			}

        if (controlExists == "object")

            control = eval(controlObject);

    }

    else if (this.navLayerForms[0] + "" != "undefined") // try array of Netscape layered forms

        {

        var rowObj = this.rows[row];

        var index = 0;

        if (bInBody)

            index = row * (rowObj.numCols - 1); // skip over for search

        for( ; index < this.navLayerForms.length; index++)

             {

             if (this.navLayerForms[index].elements[0].name == controlName)

                 {

                 control = this.navLayerForms[index].elements[0];

                 break;

                 }

             }

        }

    else

        control = null;

	/*
	if (g_sapir_cat_ui_active) {
    	f_sapir_log ("findControl", "ret = " + control, 3);
		if (control != null) {
			f_sapir_log ("findControl", "ret name = " + control.name, 3);
		}
	}
	*/

    return control;

}



function HTDW_itemGainFocus(newRow,newCol,control,gob, a_event)

{	
	f_sapir_trace ("itemGainFocus", "(" + newRow + ", " + newCol + ", " + control.name + ")");
	/*
	if (typeof (g_sapir_scroller_state) != "undefined" || g_sapir_page_id == "getreader_dialog") {
		f_sapir_alert ("itemGainFocus (" + newRow + ", " + newCol + ", " + control + ", " + gob + ", " + a_event + ")");
	}
	*/
	
	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("itemGainFocus", this.name + " : " + newRow + ", " + newCol + ", control = " + control.name, 3);
	//if (window.event) {
	//	f_sapir_log ("ie : itemGainFocus", "event_element = " + a_event.srcElement.name, 3);
	//} else {
	//	f_sapir_log ("non ie : itemGainFocus", "event_element = " + a_event.target.name, 3);
	//}
	}*/

	//var l_sapir_div1 = f_sapir_get_element_by_id (window.document, "div1");
	//l_sapir_div1.innerHTML =  l_sapir_div1.innerHTML + "itemGainFocus : " + newRow + "," + newCol + "," + control.name + "," + gob + "<BR>";

    var bRowChanged = false;

	var bReadOnlyControl = false;

	var bNegativeTabIndexControl = false;

    

    // default arguments

    control.row = newRow;

    control.col = newCol;

    control.gob = gob;

    

    // if in the middle of trying to force focus back

    // to a control, ignore all other focus stuff

	if (this.forcingBackFocusTo != null)

	    {

	    // check if we have made it back yet

	    if (this.forcingBackFocusTo == control)

	    {

    		this.forcingBackFocusTo = null;
			
			//if (g_sapir_cat_ui_active) {
			//	f_sapir_log ("itemGainFocus", "forcingBackFocusTo : control => currentControl", 3);
			//}
			
    		this.currentControl = control;

	    }

    	// don't do any other focus related stuff

    	return;

    	}


    // bail if we think that the current control already has focus

    // (Could happen if a button is pressed)

    if (this.currentControl == control &&

		!(this.currentControl.type == "hidden" || this.currentControl.type == "password" ||

		this.currentControl.type == "text" || this.currentControl.type == "textarea"))

        return;

	// check control attri
	
	//if (g_sapir_cat_ui_active) {
	//	f_sapir_log ("itemGainFocus", "this.currentControl == control", 3);
	//}

	if (control.readOnly + "" != "undefined")

		{

		bReadOnlyControl = control.readOnly;

		}

	if (control.tabIndex + "" != "undefined")

		{
		if(control.tabIndex < 0 )

			bNegativeTabIndexControl = true;

		}



	if (bNegativeTabIndexControl)

		{
			//if (g_sapir_cat_ui_active) {
			//	f_sapir_log ("itemGainFocus", "bNegativeTabIndexControl", 3);
			//}
		control.blur(); //don't allow focus.

		return;

		}



    if (newRow != -1)

        {
			//if (g_sapir_cat_ui_active) {
			//f_sapir_log ("ItemGainFocus", "newrow = " + newRow + ", this.currRow = " + this.currRow, 3);
			//}
        if (newRow != this.currRow)

            {

            bRowChanged = true;
			//if (g_sapir_cat_ui_active) {
			//	f_sapir_log ("ItemGainFocus", "bRowChanged = true", 3);
			//}			

            // row focus changing event

            if (this.eventImplemented("RowFocusChanging"))

                {
                var result = _evtDefault(this.RowFocusChanging (this.currRow+1, newRow+1, a_event));

                // if 1 returned, don't allow focus to change (leave focus in last control to have gained focus

                if (result == 1)

                    {
						//if (g_sapir_cat_ui_active) {
						//	f_sapir_log ("ItemGainFocus", "calling restoreFocus", 3);
						//}			
                    this.restoreFocus();

                    // bail out early

                    return;

                    }

                }

			

            }
        this.currRow = newRow;

        }

    if (newCol != -1)

        this.currCol = newCol;



    this.currentControl = control;

	//if (g_sapir_cat_ui_active) {
	//	f_sapir_log ("ItemGainFocus", "this.currentControl = " + this.currentControl.name, 3);
	//}			

    // update the displayed value to be in editible form

    if (newRow != -1 && newCol != -1 && 

	    (this.currentControl.type == "hidden" || this.currentControl.type == "password" ||

		 this.currentControl.type == "text" ||this.currentControl.type == "textarea"))

        {
        var value = this.rows[newRow][newCol];

        if (gob.format != null)

            {
				
			//if (g_sapir_cat_ui_active) {
			//	f_sapir_log ("ItemGainFocus", "handling gob.format", 3);
			//}		

            var displayValue;



            if (gob.getEditFormat != null)

                {

                var formatString;

                if (typeof gob.getEditFormat == "string")

                    formatString = gob.getEditFormat;

                else

                    {

                    var exprCtx = this.exprCtx;

                    exprCtx.row = control.row;

                    exprCtx.currentText = "";

                    formatString = gob.getEditFormat (exprCtx);

                    }

					displayValue = gob.format (formatString, value, this.currentControl);

                }

            else if (value != null) {
                displayValue = value.toString();
			}
            else

                displayValue = "";

			//restore_changes_alt 
			//this.rows[newRow][newCol] = this.currentControl.value;
       this.currentControl.value = displayValue;
			
				//if (g_sapir_cat_ui_active) {
				//	f_sapir_log ("ItemGainFocus", "after setting displayValue", 3);
				//}		
            }

        else if ( value != null )

            {

            // Do not compare against Date/Time if no date fields have been defined

            if (!bDateTimeProcessingEnabled ||

               (value.toString != DW_DatetimeToString &&

                value.toString != DW_DateToString &&

                value.toString != DW_TimeToString))

				//restore_changes_alt 
				//this.rows[newRow][newCol] = this.currentControl.value;
         this.currentControl.value = value.toString( );

            }

		//restore_changes_alt
        else

            this.currentControl.value = "";

        }

    

    // can only programatically change border on IE4

    if ((g_sapir_cat_ui_active || control.gob.bFocusRect) && HTDW_DataWindowClass_sapir.isIE4) {
		if (g_sapir_cat_ui_active) {
			//if (f_sapir_dview_get (this.name).display_only == "false") {
	        //	this.currentControlBorder = control.style.borderStyle;
		     //   control.style.borderStyle = "dotted";
			//}
		} else {
        	this.currentControlBorder = control.style.borderStyle;
	        control.style.borderStyle = "dotted";
		}
	}

        

	

    // row focus changed event

    if (bRowChanged && this.eventImplemented("RowFocusChanged"))

        this.RowFocusChanged (newRow+1, a_event)

        

    // item focus changed event

    if (newCol != -1 && this.eventImplemented("ItemFocusChanged"))

        this.ItemFocusChanged (newRow+1, this.cols[newCol].name, a_event)

	

}

function HTDW_itemLoseFocus(control, a_event)

{
	f_dbg ("lose");
	f_sapir_trace ("itemLoseFocus", "(" + control.name + ")");
	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("itemLoseFocus", control.name, 3);
	}*/
	
	var bReadOnlyControl = false;

	var bNegativeTabIndexControl = false;



	// check control attri

	if (control.readOnly + "" != "undefined")

		{

		bReadOnlyControl = control.readOnly;

		}

	if (control.tabIndex + "" != "undefined")

		{

		if( control.tabIndex < 0 )

			bNegativeTabIndexControl = true;

		}



	if (bNegativeTabIndexControl)

		{

		return 2;

		}



    // restore border

    // can only programatically change border on IE4
	/*
    if ((g_sapir_cat_ui_active || (control.gob.bFocusRect && HTDW_DataWindowClass_sapir.isIE4)) && this.currentControl == control) {
		if (g_sapir_cat_ui_active) {
			//if (f_sapir_dview_get (this.name).display_only == "false") {
		    //    control.style.borderStyle = this.currentControlBorder;
			//}
		} else {
	        control.style.borderStyle = this.currentControlBorder;
		}
	}
	*/

    // don't do validation if in the middle of forcing focus

    // due to validation error (endless loop could happen)

    if (this.forcingBackFocusTo != null)

        return 2;



    if (this.currentControl != control)

        {

		// yair : commented error msg
        //alert("Focus problem! Control losing focus is not current control!");
		//alert("Focus problem! Control losing focus is not current control!");

        // fake it out

        this.currentControl = control;

        }



	var gob = control.gob;

	// yair : verify gob is valid - e.g. on page refresh it is not
	if (f_sapir_is_empty (gob)) {
		return 2;
	}
	
	if (gob.getEditFormat != null)

	{

		if (typeof gob.getEditFormat == "string")

		gMask = gob.getEditFormat;

		else

		{

			var exprCtx = this.exprCtx;

			exprCtx.row = control.row;

			exprCtx.currentText = "";

			gMask = gob.getEditFormat (exprCtx);

		}

		

		// code table's edit format is a dummy "CodeTable" format for info.

		if (gob.bUseCodeTable)

			gMask = "";

	}


	//if (g_sapir_cat_ui_active) {
	//f_sapir_log ("itemLoseFocus : " + control.name + ".bChanged = " + control.bChanged + ", type = " + control.type, 3);
	//}

    if (!control.bChanged)  // check if Change misfired (losing focus beyond frame?)

        {

        var newValue;

        var row = control.row;

        var col = control.col;

        var rowObj = this.rows[row];

        var colObj = this.cols[col];



        if (control.type == "select-one") {
					f_dbg ("lose_3");
			if (control.selectedIndex >= 0) {
	            newValue = control.options[control.selectedIndex].value;
			} else {
				newValue = null;
			}
		} else {

            newValue = control.value;
		}


        if (newValue == "")

            {

            if (control.gob.bNilIsNull)

				{

				if (rowObj[col] != null /* yair : added condition on empty string */ && rowObj[col] != "")  {
					control.bChanged = true;
				}

				}

			else if (rowObj[col] != null && rowObj[col] != "") { // for inserts
				control.bChanged = true;
			}

            }

        else if (colObj.convertFromString != null)

            {

            var convertedValue;

		    if (colObj.convertFromString == parseInt)

			{

				var reg = /,/g;

				var noComma = newValue.replace(reg, "");

				convertedValue = colObj.convertFromString (noComma, 10);

			}

			else

				convertedValue = colObj.convertFromString (newValue);



            if (rowObj[col] != convertedValue)

                control.bChanged = true;

            }

        else

            {

            if (rowObj[col] != newValue)

                control.bChanged = true;

            }

        }



	//if (control.type != "select-one") { /* condition : yair */
		f_sapir_trace ("itemLoseFocus", "calling accepttext");
			f_dbg ("lose_2");
	    var result = this.AcceptText();
	//}



	gMask = "";



    if (result == 1)

        {

        // reformat the data

        var gob = control.gob;

        var value = this.rows[control.row][gob.colNum];

		

        if (control.type == "hidden" || control.type == "password" || 

            control.type == "text" || control.type == "textarea")

            {

            if (gob.format != null)

                {

                var displayValue;



                if (gob.getDisplayFormat != null)

                    {

                    var formatString;

                    if (typeof gob.getDisplayFormat == "string")

                        formatString = gob.getDisplayFormat;

                    else

                        {

                        var exprCtx = this.exprCtx;

                        exprCtx.row = control.row;

                        exprCtx.currentText = "";

                        formatString = gob.getDisplayFormat (exprCtx);

                        }

                    displayValue = gob.format (formatString, value, this.currentControl);

                    }

                else if (value != null)

                    displayValue = value.toString();

                else

                    displayValue = "";

                this.currentControl.value = displayValue;

                }

            else if ( value != null )

                {

                // Do not compare against Date/Time if no date fields have been defined

                if (!bDateTimeProcessingEnabled ||

                    (value.toString != DW_DatetimeToString &&

                     value.toString != DW_DateToString &&

                     value.toString != DW_TimeToString))

                     this.currentControl.value = value.toString( );

                }

            else

                this.currentControl.value = "";

            }

        }

	if (g_sapir_cat_ui_active) {        
		var l_item_html_el;
		l_item_html_el = control;
		f_sapir_class_remove (l_item_html_el, "sapir_item_focus");
		/*f_sapir_log ("itemLoseFocus", this.name 
					 + ", item_html_el = " + l_item_html_el.name + ", class = " + l_item_html_el.className, 3);*/
		
		//f_sapir_log ("itemlosefocus", "onkeydown = " + l_item_html_el.onkeydown, 3);
		l_item_html_el.onkeydown=null;
		//f_sapir_log ("itemlosefocus", "clean onkeydown = " + l_item_html_el.onkeydown, 3);
	}
	
	return result;

}



function HTDW_selectControlContent(control)

{

	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("selectControlContent", control.name, 3);
	}*/

	var bNegativeTabIndexControl = false;

	if(control != null)

		{

		if (control.tabIndex + "" != "undefined")

			{

			if( control.tabIndex < 0 )

				bNegativeTabIndexControl = true;

			}



		if(!bNegativeTabIndexControl)

			{

			control.select();

			}

		}

}



function HTDW_getChanges()

{
	var changes = "";

    var index, rowObj;

    for (index=0; index < this.rows.length; ++index)

        {

        rowObj = this.rows[index];

        if (rowObj != null)

            {

            HTDW_RowClass.dumpRow (index, rowObj);

            changes += HTDW_RowClass.generateChange (index, rowObj);

            }

        }

    return changes;

}



function HTDW_itemError(row, col, exprCtx, bIsRequired)

{
	if (g_sapir_cat_ui_active) {
		f_sapir_log ("itemError", row + ", " + col, 3);
		return 2;
	}

    var colObj = this.cols[col];

    var result = 0;



	

    // item error event

    if (this.eventImplemented("ItemError"))

        result = _evtDefault(this.ItemError (row+1, colObj.name, exprCtx.currentText))

	



    // map unknown results to 0

    if (result != 1 && result != 2 && result != 3)

        result = 0;

        

    if (result == 0)

        {

        var sMessage;

        if (colObj.validationError != null)

            sMessage = colObj.validationError (exprCtx);

        else if (bIsRequired)

            sMessage = "Value required for item '" + colObj.name + "'.";

        else

            sMessage = "Item '" + exprCtx.currentText + "' does not pass validation test.";



        f_sapir_alert (sMessage);

        }



    return result;

}



function HTDW_restoreFocus()

{
	if (g_sapir_cat_ui_active) {
		f_sapir_log ("restoreFocus", "begin", 3);
	}
    if (this.currentControl != null)

        {
		if (g_sapir_cat_ui_active) {
			f_sapir_log ("restoreFocus", "before currentcontrol focus : " + this.currentControl.name, 3);
		}
        this.currentControl.focus();
		if (g_sapir_cat_ui_active) {
			f_sapir_log ("restoreFocus", "after currentcontrol focus", 3);
		}
        }
	if (g_sapir_cat_ui_active) {
		f_sapir_log ("restoreFocus", "end", 3);
	}
}







function HTDW_setCheckboxValue(control, chkValue, unchkValue)

{

    if (control.checked)

        control.value = chkValue;

    else

        control.value = unchkValue;

}



function HTDW_acceptText(a_onchange)

{
	f_dbg ("accept");
	//f_sapir_trace ("acceptText", "currentControl = " + this.currentControl.name);

	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("acceptText", "", 3);
	}*/
	
    // nothing to do if no current control

    if (this.currentControl == null)

        return 1;

	if (g_sapir_cat_ui_active) {
		if (this.currentControl.type == "select-one" && f_sapir_is_empty (a_onchange)) {
			f_dbg ("acc:nop");
			//f_sapir_log ("accepttext", "ddlb, called by onchange : nop", 3);
			return 1;
		}
	}
	
    var control = this.currentControl;

    var row = control.row;
	
	//if (g_sapir_cat_ui_active) {
	//	f_sapir_log ("accepttext", "row = " + row + ", new value = " + control.value, 3);
	//}
	
    var col = control.col;

	//yair
    var bRequired = false;
    //var bRequired = control.gob.bRequired;

    var colObj = this.cols[col];

    var bIsValid = true;

    var exprCtx = this.exprCtx;

    var validAction = 2;  // default to accept

    var newValue;

		if (control.type == "select-one") {
			if (control.selectedIndex >= 0) {
				newValue = control.options[control.selectedIndex].value;
			} else {
				newValue = null;
			}
		} else if (g_sapir_cat_ui_active && this.currentControl.type == "checkbox") {
			// checkbox : checked = "Y", unchecked = "N"
			if (this.currentControl.checked) {
				newValue = "Y";
			} else {
				newValue = "N";
			}
			control.value = newValue;
		} else {
			newValue = control.value;
		}

    exprCtx.row = row;

    exprCtx.currentText = newValue;

    // check if value required
    if (bRequired && ! control.bChanged) {
        if (this.rows[row][col] == null) {
            validAction = this.itemError (row, col, exprCtx, true);
				}
		} else if (bRequired && control.gob.bNilIsNull && newValue == "") {
        validAction = this.itemError (row, col, exprCtx, true);
		}

    if (control.bChanged) {
		if (!g_sapir_cat_ui_active) {
			if (bIsValid && colObj.validateByType != null) {
				bIsValid = colObj.validateByType(newValue, control.gob.bNilIsNull);
			}
	
			if (bIsValid && colObj.validateItem != null) {
				bIsValid = colObj.validateItem (exprCtx);
			}
		}
		
        // item changed event

		//f_sapir_alert (colObj.name);

        if (bIsValid && this.eventImplemented("ItemChanged")) {
            validAction = _evtDefault(this.ItemChanged (row+1, colObj.name, newValue));

			if (g_sapir_cat_ui_active) {
				f_dbg ("accept:override");
				newValue = f_sapir_dw_item_changed_override_value (this.name, row+1, colObj.name, newValue);
			}

            // map unknown results to 0

            if (validAction != 1 && validAction != 2) {
                validAction = 0;
			}

            // map itemChanged action codes to itemError action codes

            if (validAction == 0) // accept value

                validAction = 2;

            else

                {

                bIsValid = false;

                if (validAction == 1) // reject value, no focus change

                    validAction = 1;

                else // reject value, allow focus change

                    validAction = 3;

                }

            }
		



        if (! bIsValid) {
					if (g_sapir_cat_ui_active) {
						f_dbg ("acc-1");
						return -1;
					}
					//validAction = 0;
           validAction = this.itemError (row, col, exprCtx, false);
		}
		
		if (!g_sapir_cat_ui_active) {
			validAction = 2;
		}

        if (validAction == 2)

            {
						f_sapir_changes_backup (this.name, newValue, row+1, colObj.name);
            var rowObj = this.rows[row];

            if (control.gob.bNilIsNull && newValue == "")

                {

                if (rowObj[col] != null)

                    { 

                    rowObj[col] = null;

                    if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                        rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

                        this.modifiedCount++;

                    rowObj[0].colModified[col] = true;		    

                    if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

                    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

                    }

                }

            else if (colObj.convertFromString != null)

                {

				var convertedValue;

				if (colObj.convertFromString == parseInt)

					convertedValue = colObj.convertFromString (newValue, 10);

				else

					convertedValue = colObj.convertFromString (newValue);



                if (rowObj[col] != convertedValue)

                    {

                    rowObj[col] = convertedValue;

                    if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                        rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

                        this.modifiedCount++;	    

                    rowObj[0].colModified[col] = true;		    

                    if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

                    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

                    }

                }

            else

                {

                if (rowObj[col] != newValue)

                    {

                    rowObj[col] = newValue;

                    if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                        rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

                        this.modifiedCount++;	    

                    rowObj[0].colModified[col] = true;		    

                    if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

                    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

                    }

                }

			// yair
			var l_changed;
			if (g_sapir_cat_ui_active) {
				l_changed = control.bChanged;
			}

            control.bChanged = false;

            // skip current control

            colObj.updateDependents(this, row, true);

            }

        }



    // force focus back if an error (focus change will happen after we return!)

    if (validAction < 2)

        {
				f_dbg ("acc<2");
        this.forcingBackFocusTo = control;

        control.focus();

        }



    var result = (validAction < 2) ? -1 : 1;

	// yair
	if (result == 1 && g_sapir_cat_ui_active) {
		// free=>list : sync list
		if (l_changed
			&&	!f_sapir_is_empty (f_sapir_dview_get (this.name).list_dview_id)
				&& f_sapir_exists (f_sapir_dview_get (f_sapir_dview_get (this.name).list_dview_id))) {
			//l_list_dview = f_sapir_dview_get (f_sapir_dview_get (this.name).list_dview_id);
			f_sapir_free_list_sync (this.name);
		}
	}	

    return result;

    // this return will only be used if we are not an input form

    return 1;

}





// if false returned, don't allow focus to change or action to happen (leave focus in last control to have gained focus

function HTDW_itemClicked(row, col, objName, a_event)

{
	if (g_sapir_cat_ui_active) {
		return true;
	}
	//f_sapir_alert ("itemClicked : " + row + "," + col + "," + objName);

	var l_el_id, l_el, l_editable_field;

	if (g_sapir_cat_ui_active) {
		l_el_id = this.name + "_" + objName + "_" + row;
		l_el = 	f_sapir_get_element_by_id (window.document, l_el_id);
		if (f_sapir_exists (l_el)) {
			if (f_sapir_is_readonly (l_el)) {
				l_editable_field = false;
			} else {
				l_editable_field = true;
			}	
		} else {
			l_editable_field = false;
		}
	}

	if (g_sapir_cat_ui_active && !l_editable_field) {
		return true;
	}

    var evtResult = 0;

    // CR228156 - click on DDDW column fires a validation error in IE5.x - Partha

    if (this.currentControl != null)

    {

	if ( this.currentControl.type == "select-one" ) {

	    if ( HTDW_DataWindowClass_sapir.isIE4 

		&& this.currentControl.gob.bRequired == true 

		&& this.currentControl.value == "" )

            	return false ;

	    else {
				f_dbg ("itemClicked_1");
		if (this.AcceptText() != 1)

			return false;
}


	}

    	else if (this.currentControl.type == "checkbox" 

		|| this.currentControl.type == "radio" 

		|| this.currentControl.type == "select-multiple" )

	{
					f_dbg ("itemClicked_2");

        	if (this.AcceptText() != 1)

			return false;

	}

    }

	// yair - 17\9\06 - moved "this. this.clickedCol" setting so it will be available to app htmldw_clicked (...)
    this.clickedCol = col;

    if (this.eventImplemented("Clicked"))

        evtResult = _evtDefault(this.Clicked (row+1, objName));



    // prevent clicked event from bubbling up in IE4 or higher

    if (HTDW_DataWindowClass_sapir.isIE4) {
		// sapir : event may be null - if action sent from another dw
		if (typeof window.event == "object" && window.event != null)
			window.event.cancelBubble = true;
	}


    this.clickedRow = row;

	// yair - 17\9\06 - moved "this. this.clickedCol" setting so it will be available to app htmldw_clicked (...)
    //this.clickedCol = col;

    

    return evtResult != 1;

}



function HTDW_performAction(action)

{
	/* test cat_from_scroller
	if (this.name == "sapir_form_dw") {
		f_sapir_alert ("submit only : " + this.submitForm.action);
		this.submitForm.submit();
		return;
	} else {
		return;
	}
	*/
	if (g_sapir_cat_ui_active) {
		f_sapir_log ("performAction", this.name, 3);
	}
	var b_idea_submit, rc;
	
	this.action = action;

 	//if (this.b4GLWeb) {
	//	// cause the surrounding page to be submitted
	//	psPage.Submit();
	//	return;
	//} 
	// deal with it like in 7.0
	rc = 0;
	// OnSubmit can prevent the page from being submitted by returning 1

	if (this.eventImplemented("OnSubmit")) {
		rc = _evtDefault(this.OnSubmit ());
	}

	if (rc != 0) {
		return;
	}
	if (!g_sapir_cat_ui_active) {
		this.actionField.value = this.action;
		this.contextField.value = this.GetFullContext();
		//f_sapir_alert ("sapir_changes : HTDW_performAction : " + this.contextField.value);
		this.submitForm.submit();
		return;
	}
	
	//.toLowerCase () == "update" && f_sapir_action_get_level () == "dview"		
	
	if (this.name == "sapir_form_dw"
		|| (action.toLowerCase () == "update" && f_sapir_action_dview_get (this.name).send_context)) {
		//|| f_sapir_action_get_send_all_dviews ()
		//|| f_sapir_dview_get (this.name).data_changed 
		//|| f_sapir_dw_param_get_key ("sapir_form_dw", "form_client_status") == "new") {
		this.actionField.value = this.action;
		//f_sapir_log ("HTDW_performAction", "before GetFullContext", 0);
		this.contextField.value = this.GetFullContext();
		//f_sapir_log ("HTDW_performAction", "after GetFullContext", 3);
	}

	// explicit call to onSubmit event-handler, if defined, 
	// since it does not fire when form is submitted via javascript.
	b_idea_submit = false;
	if (f_sapir_action_get_level () == "form") {
		if (eval ("typeof (this.submitForm.onsubmit)") == "function") {
			//f_sapir_log ("HTDW_performAction", "before this.submitForm.onsubmit", 3);
			b_idea_submit = this.submitForm.onsubmit ();
			//f_sapir_log ("HTDW_performAction", "after this.submitForm.onsubmit", 3);
		} else {
			//f_sapir_log ("HTDW_performAction", "b_idea_submit = true", 3);
			b_idea_submit = true; 
		}
	} else {
		f_sapir_action_init (this.name, action, "", "", "dview");
		f_sapir_dview_set_action (this.name, action);
	}
	
	//f_sapir_alert ("sapir_changes : HTDW_performAction : " + this.contextField.value);
	
	//f_sapir_log ("HTDW_performAction", "final idea_submit = " + b_idea_submit, 3);
	if (b_idea_submit) {
		//f_sapir_log ("HTDW_performAction", "b_idea_submit => NOP", 3);
		//f_sapir_log ("HTDW_performAction", "b_idea_submit => calling this.submitForm.submit()", 3);
		try {
			// try_catch required since if user cancels in onBeforeUnload, submit() generates an "unspecified error"
			this.submitForm.submit();
			this.submitForm.target = "_self";
		} catch(ex) {
		}
		//f_sapir_log ("HTDW_performAction", "b_idea_submit => after this.submitForm.submit()", 3);
	}

	/*
	// yair 23\06\06 - added call to idea_form post_submit : relevent in AJAX
	f_sapir_alert ("post submit ?");
	if (eval ("typeof (f_idea_form_dw_submit_post)") == "function") {
		f_idea_form_dw_submit_post ();
	}
	*/
	f_sapir_log ("HTDW_performAction", "end", 3);
}



function HTDW_GetFullContext()

{
	if (g_sapir_cat_ui_active) {
		if (f_sapir_is_implemented ("f_sapir_dw_GetFullContext_pre")) {			
			f_sapir_dw_GetFullContext_pre (this.name);
		}
	}

	var     result = this.context;

    result += "(";

    result += this.getChanges();

    if (this.currRow != -1)

        result += "(row " + this.currRow + ")";

    if (this.sortString != null)

        result += "(sortString '" + escapeString (this.sortString) + "')";

    result += ")";

	return result ;

}



function HTDW_buttonPress(action, row, buttonName)

{
f_dbg ("butt");
	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("buttonPress", this.name, 3);
	}*/

	var evtResult;

    // false from clicked will cancel processing

    if (!this.itemClicked(row, -1, buttonName))

        return;



    // button clicking event

    if (this.eventImplemented("ButtonClicking"))

        {
		// yair 5\3\08 : add action to buttonClicking as optional parameter
        evtResult = _evtDefault(this.ButtonClicking (row+1, buttonName, action));
		//evtResult = _evtDefault(this.ButtonClicking (row+1, buttonName ));

        // non-zero return will cancel processing

        if (evtResult != 0)

            return;

        }



    // make sure all changes have been recorded

    if (action != "" && this.AcceptText() != 1)

        // cancel processing if AcceptText fails

        return;



    // update start event 
    if (action == "Update" && this.eventImplemented("UpdateStart"))

        {

        evtResult = _evtDefault(this.UpdateStart ());

        // a return of 1 will cancel action

        if (evtResult == 1)

            return;

        }



    if (action == "Print")

	    {

        window.print();

        return;

        }

    // an action of "" is a user defined button which doesn't cause a page reload

    if (action != "") {
		/*if (g_sapir_cat_ui_active) {
			f_sapir_log ("buttonPress", this.name + " : calling performAction" , 3);
		}*/
		this.performAction(action);
	} else {

        // button clicked event

        if (this.eventImplemented("ButtonClicked"))

            this.ButtonClicked (row+1, buttonName)

	}
	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("buttonPress", this.name + " : end", 3);
	}*/
}



function HTDW_getColNum(col)

{

    if (typeof col == "string")

        {

        for (var i=1; i< this.cols.length; ++i)

            {

            var colObj = this.cols[i];

            if (colObj.name == col)

                return i;

            }

        }

    else

        return col;



    // if we get here, then we couldn't find it

    return -1;

}



function HTDW_DeletedCount()

{

	return this.deletedCount;

}



function HTDW_DeleteRow(row)

{

	if(this.AcceptText() == 1)

		{

		if (row > 0)

    		this.currRow = row-1;

		this.performAction ("DeleteRow");

		return 1;

		}

	else

		return -1;

}



function HTDW_GetClickedColumn()

{

	return this.clickedCol;

}



function HTDW_GetClickedRow()

{

	return this.clickedRow + 1;

}



function HTDW_GetColumn()

{

	return this.currCol;

}



function HTDW_GetNextModified(startRow)

{

    var nextModified = 0;

    var index, rowObj;

 

    if (startRow == null)

        return null;



    for (index=startRow-1; index < this.rows.length; ++index)

        {

        rowObj = this.rows[index];

        if (rowObj != null)

            {

            if (rowObj[0].itemStatus == DW_ITEMSTATUS_MODIFIED ||

                rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED)

                {

                nextModified = index+1;

                break;

                }

            }

        }

    return nextModified;

}



function HTDW_GetRow()

{

	return this.currRow + 1;

}



function HTDW_GetItem(row, col)

{

	var result;

	var colNum = this.getColNum(col);

    var rowObj = this.rows[row-1];



	if (colNum == -1 ||

	        (rowObj + "" == "undefined") || 

			rowObj[colNum] + "" == "undefined")

		result = -1;

	else

		result = rowObj[colNum];



	return result;

}



function HTDW_GetItemStatus(row, col)

{

    if (row == null || col == null)

        return null;



    var dwItemStatus = DW_ITEMSTATUS_NOCHANGE;

    var colNum = this.getColNum(col);

    var rowObj = this.rows[row-1];



    if (colNum == -1 ||

            (rowObj + "" == "undefined") || 

            (colNum > 0 && rowObj[colNum] + "" == "undefined"))

        dwItemStatus = -1;

    else if (colNum == 0)

            dwItemStatus = rowObj[0].itemStatus;

    else

        {

        if (rowObj[0].colModified[colNum])

            dwItemStatus = DW_ITEMSTATUS_MODIFIED;

        }



	return dwItemStatus;

}



function HTDW_InsertRow(row)

{

	if(this.AcceptText() == 1)

		{

		this.currRow = row-1;

		this.performAction ("InsertRow");

		return 1;

		}

	else

		return -1;

}



function HTDW_ModifiedCount()

{

    return this.modifiedCount;

}



function HTDW_Retrieve()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("Retrieve");

		return 1;

		}

	else

		return -1;

}



function HTDW_RowCount()

{

	return this.rowCount;

}



function HTDW_ScrollFirstPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PageFirst");

		return 1;

		}

	else

		return -1;

}



function HTDW_ScrollLastPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PageLast");

		return 1;

		}

	else

		return -1;

}



function HTDW_ScrollNextPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PageNext");

		return 1;

		}

	else

		return -1;

}



function HTDW_ScrollPriorPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PagePrior");

		return 1;

		}

	else

		return -1;

}



function HTDW_SetItem(row,col,value, a_set_type)

{
	f_dbg ("setitem");
	//f_sapir_alert ("setitem : " + row + ", " + col + ", " + value);
	//f_sapir_log ("SetItem", this.name + ", " + row + ", " + col + ", " + value, 3);
	var result;
	var colNum = this.getColNum(col);
    var rowObj = this.rows[row-1];
	var l_sapir_info, l_col_function, l_lookup_type, l_dview, l_checked;

	if (colNum == -1 ||

	        (rowObj + "" == "undefined") || 

			rowObj[colNum] + "" == "undefined") {

		result = -1;

	} else

		{

        if (rowObj[colNum] != value)

			{

			rowObj[colNum] = value;

            if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

				this.modifiedCount++;	    

			rowObj[0].colModified[colNum] = true;

            if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

            else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

			}



		// update them all

		this.cols[colNum].updateDependents(this, row-1, false);

		result = 1;

		}

	//if (g_sapir_cat_ui_active) {
	//	f_sapir_debugger ();
	//}
	
	// cat_ui : mark item as changed
	if (g_sapir_cat_ui_active && result == 1) {
		if (a_set_type != "ajax_sync" && f_sapir_dview_get (this.name).dview_function != "summary") {
			f_sapir_dview_get (this.name).data_changed_set (true);
		}
	}
	
	// cat_ui : if user combo => sync selected value (if not in sync already)
	if (g_sapir_cat_ui_active && result == 1) {
		f_dbg ("setitem:sync");
		f_sapir_personal_combo_sync_selected_value (this, row, col, value);
	}
	
	// cat_ui : if checkbox => set its CHECKED property
	if (g_sapir_cat_ui_active) {
		l_dview = f_sapir_dview_get (this.name);
		l_col_function = f_sapir_col_get_function (this.name, col);
		if (l_col_function == "value") {
			l_sapir_info = f_sapir_info_get_value (this.name, row, col);
		} else if (l_col_function == "code"){
			l_sapir_info = f_sapir_info_get_value (this.name, row, f_sapir_col_name_get_full_prefix (col) + "value");
		} else if (l_dview.dview_function == "summary" && l_col_function == "datalang") {
			l_sapir_info = f_sapir_info_get_value (this.name, row, f_sapir_col_name_get_full_prefix (col) + "value");
		}

		l_lookup_type = f_sapir_info_get_key (l_sapir_info, "lookup_type");

		// checkbox : checked = Y, unchecked = N
		if (l_lookup_type == "cbx" ) {
			//l_checked = f_sapir_get_attribute (l_el, "checked");
			//if (l_checked) {
			//} else {
			//}
		}
	}

	return result;

}



function HTDW_SetColumn(col)

{
	//if (g_sapir_cat_ui_active) {
	//	f_sapir_log ("SetColumn", this.name + " : " + col, 3);
	//}
    var result = -1;

	var colNum = this.getColNum(col);



    if (colNum != -1)

        {

        var colObj = this.cols[colNum];

        if (typeof colObj != "undefined" && colObj.displayGobName != null)

            {

            var control = this.findControl(this.name, colObj.displayGobName, this.currRow, true);

            // if we can't find a control, then we can't set the column

            if (control != null)

                {

                // force focus onto the found control

                // the onFocus event will change the currency variables

                control.focus();

                result = 1;

                }

            }

        }

	return result;

}



function HTDW_SetRow(row, a_caller_name)

{
	/*if (g_sapir_cat_ui_active) {
		f_sapir_log ("SetRow", this.name + " : " + row + ", " + a_caller_name, 3);
	}*/

    var result = -1;

    row -= 1;

	var colNum = this.currCol;



    if (colNum != -1)

        {
        var colObj = this.cols[colNum];
		//if (g_sapir_cat_ui_active) {
		//f_sapir_log ("SetRow", this.name + " : typeof colObj = " + typeof colObj, 3);
		//f_sapir_log ("SetRow", this.name + " : colObj.displayGobName = " + colObj.displayGobName, 3);
		//}
        if (typeof colObj != "undefined" && colObj.displayGobName != null)

            {
            var control = this.findControl(this.name, colObj.displayGobName, row, true);
			/*if (g_sapir_cat_ui_active) {
			f_sapir_log ("SetRow", this.name + " : " + row + " : back from findControl = " + control.name, 3);
			}*/
            // if we can't find a control, then we can't set the row
			if (!g_sapir_cat_ui_active 
				|| (f_sapir_is_empty (a_caller_name) || a_caller_name.toLowerCase () != "item_focus_changed")) {
				if (control != null)
	
					{
						// force focus onto the found control, 					
						// the onFocus event will change the currency variables
						// yair : verify that this is an HTML element
						if (f_sapir_exists (control.attributes)) {
	
							try {
								//control.click(); // yair
								control.focus();
								result = 1;
							} catch (err) {
								f_sapir_alert ("exception caught in focus on : " + control.name 
									   + " in " + this.name 
									   + ", parent = " + control.parentElement.name
									   + ", row = " + row + " : " + err.description);
							}
						}
					}
	
				}
			}
        }

	return result;

}



function HTDW_SetSort(sortString)

{

	this.sortString = sortString;

	return 1;

}



function HTDW_Sort()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("Sort");

		return 1;

		}

	else

		return -1;

}



function HTDW_Update()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("Update");

		return 1;

		}

	else

		return -1;

}



function DW_EditKeyPressed(nCase)

{

	if(nCase == 1)

	{

		event.srcElement.value += String.fromCharCode(event.keyCode).toUpperCase();

		event.returnValue = false;

	}

	else if (nCase == 2)

	{

		event.srcElement.value += String.fromCharCode(event.keyCode).toLowerCase();

		event.returnValue = false;

	}

}

function HTDW_DataWindowClass_sapir(name) {
	this.rowInfos = new Array(); // pb11.5
	var l_submit_form, l_action_field, l_context_field;
	l_submit_form = f_sapir_form_get_by_name (name + "_submitForm");
	l_action_field  = f_sapir_selflinkarg_ref (l_submit_form, name + "_action");
	l_context_field  = f_sapir_selflinkarg_ref (l_submit_form, name + "_context");
	
	//return new HTDW_DataWindowClass(name, l_submit_form,l_action_field, l_context_field);
	
    // if used in 4GL web, these will not be defined!

    /*
	if (arguments.length == 1)

        {

        submitForm = null;

        actionField = null;

        contextField = null;

        }
	*/
       
    this.name = name;

    this.submitForm = l_submit_form;

    this.actionField = l_action_field;

    this.contextField = l_context_field;

    this.sortString = null;

    this.action = "";

    

    // private functions

    this.buttonPress = HTDW_buttonPress;

	this.performAction = HTDW_performAction;

    this.eventImplemented = HTDW_eventImplemented;

    this.itemClicked = HTDW_itemClicked;



    // public function

    this.GetFullContext = HTDW_GetFullContext;

    

    this.currRow = -1;

    this.currCol = -1;

    this.forcingBackFocusTo = null;

    this.currentControl = null;

    this.bSingleRow = false;

    

    this.gobs = new Object();

    this.rows = new Array();

    this.cols = new Array();

    this.navLayerForms = new Array();

    this.exprCtx = new HTDW_exprContextClass(this);



    // private functions

    this.getChanges = HTDW_getChanges;

    this.itemLoseFocus = HTDW_itemLoseFocus;

    this.selectControlContent = HTDW_selectControlContent;

    this.itemError = HTDW_itemError;

    this.itemGainFocus = HTDW_itemGainFocus;

    this.restoreFocus = HTDW_restoreFocus;

    this.findControl = HTDW_findControl;

    this.setCheckboxValue = HTDW_setCheckboxValue;



    // public functions

    this.AcceptText = HTDW_acceptText;

    // private functions

    this.getColNum = HTDW_getColNum;

    

    // public functions

    this.AcceptText = HTDW_acceptText;

	this.DeletedCount = HTDW_DeletedCount;

	this.DeleteRow = HTDW_DeleteRow;

	this.GetClickedColumn = HTDW_GetClickedColumn;

	this.GetClickedRow = HTDW_GetClickedRow;

	this.GetColumn = HTDW_GetColumn;

	this.GetNextModified = HTDW_GetNextModified;

	this.GetRow = HTDW_GetRow;

	this.GetItem = HTDW_GetItem;

	this.GetItemStatus = HTDW_GetItemStatus;

	this.InsertRow = HTDW_InsertRow;

	this.ModifiedCount = HTDW_ModifiedCount;

	this.Retrieve = HTDW_Retrieve;

	this.RowCount = HTDW_RowCount;

	this.ScrollFirstPage = HTDW_ScrollFirstPage;

	this.ScrollLastPage = HTDW_ScrollLastPage;

	this.ScrollNextPage = HTDW_ScrollNextPage;

	this.ScrollPriorPage = HTDW_ScrollPriorPage;

	this.SetItem = HTDW_SetItem;

	this.SetColumn = HTDW_SetColumn;

	this.SetRow = HTDW_SetRow;

	this.SetSort = HTDW_SetSort;

	this.Sort = HTDW_Sort;

	this.Update = HTDW_Update;
}

function HTDW_DataWindowClass(name, submitForm, actionField, contextField)

{
    // if used in 4GL web, these will not be defined!

    if (arguments.length == 1)

        {

        submitForm = null;

        actionField = null;

        contextField = null;

        }

        

    this.name = name;

    this.submitForm = submitForm;

    this.actionField = actionField;

    this.contextField = contextField;

    this.sortString = null;

    this.action = "";

    

    // private functions

    this.buttonPress = HTDW_buttonPress;

	this.performAction = HTDW_performAction;



    this.eventImplemented = HTDW_eventImplemented;

    this.itemClicked = HTDW_itemClicked;



    // public function

    this.GetFullContext = HTDW_GetFullContext;

    

    this.currRow = -1;

    this.currCol = -1;

    this.forcingBackFocusTo = null;

    this.currentControl = null;

    this.bSingleRow = false;

    

    this.gobs = new Object();

    this.rows = new Array();

    this.cols = new Array();

    this.navLayerForms = new Array();

    this.exprCtx = new HTDW_exprContextClass(this);



    // private functions

    this.getChanges = HTDW_getChanges;

    this.itemLoseFocus = HTDW_itemLoseFocus;

    this.selectControlContent = HTDW_selectControlContent;

    this.itemError = HTDW_itemError;

    this.itemGainFocus = HTDW_itemGainFocus;

    this.restoreFocus = HTDW_restoreFocus;

    this.findControl = HTDW_findControl;

    this.setCheckboxValue = HTDW_setCheckboxValue;



    // public functions

    this.AcceptText = HTDW_acceptText;


    // private functions

    this.getColNum = HTDW_getColNum;

    

    // public functions

    this.AcceptText = HTDW_acceptText;

	this.DeletedCount = HTDW_DeletedCount;

	this.DeleteRow = HTDW_DeleteRow;

	this.GetClickedColumn = HTDW_GetClickedColumn;

	this.GetClickedRow = HTDW_GetClickedRow;

	this.GetColumn = HTDW_GetColumn;

	this.GetNextModified = HTDW_GetNextModified;

	this.GetRow = HTDW_GetRow;

	this.GetItem = HTDW_GetItem;

	this.GetItemStatus = HTDW_GetItemStatus;

	this.InsertRow = HTDW_InsertRow;

	this.ModifiedCount = HTDW_ModifiedCount;

	this.Retrieve = HTDW_Retrieve;

	this.RowCount = HTDW_RowCount;

	this.ScrollFirstPage = HTDW_ScrollFirstPage;

	this.ScrollLastPage = HTDW_ScrollLastPage

	this.ScrollNextPage = HTDW_ScrollNextPage

	this.ScrollPriorPage = HTDW_ScrollPriorPage

	this.SetItem = HTDW_SetItem

	this.SetColumn = HTDW_SetColumn

	this.SetRow = HTDW_SetRow

	this.SetSort = HTDW_SetSort

	this.Sort = HTDW_Sort;

	this.Update = HTDW_Update

}



// determine the client browser

// this should be used only where ABSOLUTELY necessary

// Generic JavaScript should be used where ever possible

HTDW_DataWindowClass_sapir.isNav4 = false;

HTDW_DataWindowClass_sapir.isIE4 = false;

if (parseInt(navigator.appVersion) >= 4)

    {

    HTDW_DataWindowClass_sapir.isNav4 = (navigator.appName == "Netscape");

    HTDW_DataWindowClass_sapir.isIE4 = (navigator.appName.indexOf("Microsoft") != -1);

    }



function DW_ShowCodeTableDisplayValue(formatString, value)

{

    if (value == null)

        return "";

    var result = value.toString();

    var i;

    for (i = 0; i < this.column.displayValue.length; i++)

        if (value.toString() == this.column.dataValue[i])

            {

            result = this.column.displayValue[i];

            i = this.column.displayValue.length; 

            }

    

   return result;

}



// between is inclusive

function DW_Between(val, test1, test2)

{

    if (val == null || test1 == null || test2 == null)

        return false;

        

    if (test1 <= val && val <= test2)

        return true;

    else

        return false;

}



function DW_BetweenByFunc(val, test1, test2, func)

{

    return func(test1, val) >= 0 && func(val, test2) <= 0;

}



function DW_In(testValue)

{

    var bResult = false;



    for (var i=1; i < arguments.length; i++)

        {

        if (arguments[i] == testValue)

            {

            bResult = true;

            break;

            }

        }

    return bResult;

}



function DW_InByFunc(testValue, func)

{

    var bResult = false;



    for (var i=2; i < arguments.length; i++)

        {

        if (func(arguments[i],testValue) == 0)

            {

            bResult = true;

            break;

            }

        }

    return bResult;

}



//

// Date management code

//



// Added to determine if dates are being processed in client side JavaScript.

bDateTimeProcessingEnabled = true;



var DW_dayTable = new Array();

DW_dayTable[0] = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

DW_dayTable[1] = new Array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);



var DW_cumDayTable = new Array();

DW_cumDayTable[0] = new Array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365);

DW_cumDayTable[1] = new Array(0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366);



function DW_daysInCentury(year)

{

    return ((((year) / 100) % 4 ? 24 : 25) + 36500);

}



function DW_isLeap(year)

{

    return ((year%4 == 0 && year%100 != 0) || year%400 == 0);

}



function DW_dayOfYear(year, month, day)

{

	var i, aleap;



	aleap = DW_isLeap(year) ? 1 : 0;

	for (i = 1; i < month; i++)

		day += DW_dayTable[aleap][i];

	return day;                   // Offset from 0

}



function DW_dayOfCentury(year, month, day)

{

	var days, leaps;

	var years_in_century;



	/* Get number of years in the century. */

	y
