	// ==========================================================================
	// ||||||||||||||||||||||||| GLOBAL VARIABLES |||||||||||||||||||||||||||||||
	// ==========================================================================
	// prepare all of the page's rollover graphics
	if(document.images){
		var icon_field_error_off = new Image(); icon_field_error_off.src = '/images/icons/icon_field_error_off.gif';
		var icon_field_error_on = new Image(); icon_field_error_on.src = '/images/icons/icon_field_error_on.gif';
		var icon_field_error_none = new Image(); icon_field_error_none.src = '/images/other/other_clear_spacer.gif';
	}
	
	// ==========================================================================
	// ||||||||||||||||||||||||| FUNCTIONS |||||||||||||||||||||||||||||||
	// ==========================================================================

	// this function takes the standardized base field name of a form section and
	// changes the color of the label, and turns on the error icon with
	// associated link and error message (via tooltip and javascript alert)
	/*
	function set_field_error(_field_name,_error_msg){
		// get references to the form label, and it's error icon image
		var form_label = document.getElementById(_field_name+'_label');
		var form_err_img = document.getElementById(_field_name+'_err_img');
		if(form_label && form_err_img){
			form_label.style.color = '#ff0000';
			form_err_img.src = icon_field_error_off.src;
			form_err_img.alt = _error_msg.replace('\r','&#13;');
			form_err_img.title = _error_msg.replace('\r','&#13;');
			form_err_img.style.cursor = 'hand';
			form_err_img.onmouseover = function(){ this.src = icon_field_error_on.src; };
			form_err_img.onmouseout = function(){ this.src = icon_field_error_off.src; };
			form_err_img.onclick = function(){ alert(_error_msg); };
			// we need to give the browser a split second to recognize the image's source has changed, and then we hide/show it to ensure it gets rendered
			var hide_obj_code = 'document.getElementById("'+_field_name+'_err_img").style.display = "none";';
			var show_obj_code = 'document.getElementById("'+_field_name+'_err_img").style.display = "";';
			setTimeout(hide_obj_code+' '+show_obj_code,10);
		}
	}

	// this function takes the an array of all the error names/text and calls the set_field_error on each one of them
	function load_all_errors(_error_names,_error_texts){
		// get references to the form label, and it's error icon image
		for(i = 0; i < _error_names.length; i++)
		{
			set_field_error(_error_names[i], _error_texts[i]);
		}
	}
	*/

	// this function is used with the menu systems. This helps with the IE Bug
	// keep for reference
	/*
	function IEHoverPseudo() {
		var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
		
		for (var i=0; i<navItems.length; i++) {
			if(navItems[i].className == "menuparent") {
				navItems[i].onmouseover=function() { this.className += " over"; }
				navItems[i].onmouseout=function() { this.className = "menuparent"; }
			}
		}
	}
	*/

    String.prototype.trim = function() {
    	return this.replace(/^\s+|\s+$/g,"");
    }
    String.prototype.ltrim = function() {
    	return this.replace(/^\s+/,"");
    }
    String.prototype.rtrim = function() {
    	return this.replace(/\s+$/,"");
    }

    function isArray(obj) {
       if (obj.constructor.toString().indexOf("Array") == -1 && obj.toString().indexOf("[object Object]") == -1)
          return false;
       else
          return true;
    }
	
	//Check if this is Internet explorer
	function browser_is_ie()
	{
	   if(navigator.appName == "Microsoft Internet Explorer")
	   {
	       return true;
	   }else{
	       return false;
	   }
	}
	
	function browser_version()
	{
        return parseFloat(navigator.appVersion);
	}
	
	if(browser_is_ie() && browser_version() < 8)
	{
	   var classText = "className";
	}else{
	   var classText = "class";
	}
	
	function change_texbox_val(field_name, display_type, display_text, is_password)
	{
        if(field_name)
        {
    		if(display_type == 1)
    		{
    			if(field_name.value == "")
    			{
                    if(is_password){ field_name.type = "text"; }
                    field_name.value = display_text;
                    field_name.style.color = "gray";
    			}
    		}else if(display_type == 0){
    			if(field_name.value == display_text && field_name.style.color == "gray")
    			{
                    if(is_password){ field_name.type = "password"; }
                    field_name.value = "";
                    field_name.style.color = "black";
    			}
    		}
		}
	}

	//This function allows any components display setting to be changed depending on what you want
	//id_name - the ID of the div/span/etc.
	//display_type - whether you want to show/hid
	//				0 = hide
	//				1 = show
	//				2 = toggle
	function change_display_value(id_name, display_type)
	{
		if(display_type == 2)
		{
			if(document.getElementById(id_name).style.display == "block")
			{
				display_type = 0;
			}else{
				display_type = 1;
			}
		}
	
		if(display_type == 1)
		{
			display_text = "block";
		}else if(display_type == 0){
			display_text = "none";
		}
		
		document.getElementById(id_name).style.display = display_text;
	}

	function display_help_text(field_name, toggle_type)
	{
		field_name = field_name.name;
		if(toggle_type == 1)
		{
			document.getElementById(field_name + "_info").innerHTML = help_text[field_name];
			document.getElementById(field_name + "_info").setAttribute(classText, "feedback_help");
			
			if(document.getElementById(field_name + "_label"))
			{
				document.getElementById(field_name + "_label").style.color = "black";
			}
		}else{
			document.getElementById(field_name + "_info").setAttribute(classText, "feedback_hidden");
		}
	}

	function display_error_text(errors_arr)
	{
        for(var field_name in errors_arr) {
            if(field_name == "error_all")
            {
                message_box_display("error", '', errors_arr[field_name]);
            }else{
    			document.getElementById(field_name + "_info").innerHTML = errors_arr[field_name];
    			document.getElementById(field_name + "_info").setAttribute(classText, "feedback_error");
    			
    			if(document.getElementById(field_name + "_label"))
    			{
    				document.getElementById(field_name + "_label").style.color = "black";
    			}
            }
        }
	}
	
	total_z_index = 0;
	function message_box_display(message_box_type, message_title, message_content)
	{
        posY = getScreenCenterY();
        posX = getScreenCenterX();

	   var message_box = document.getElementById(message_box_type + "_box");
	   var message_box_title = document.getElementById(message_box_type + "_box_title");
	   var message_box_content = document.getElementById(message_box_type + "_box_content");
	   
	   if(message_title != "")
	   {
	       message_box_title.innerHTML = message_title;
	   }else if(message_box_type == "error"){
	       message_box_title.innerHTML = "Error";
	   }
	   
	   if(message_content != "")
	   {
	       message_box_content.innerHTML = message_content;
	   }
	   
	   if(message_box_type == "error")
	   {
	       message_box_content.innerHTML += '<br /><br /><table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="#" class="error_button" onclick="message_box_hide(\'error\'); return false;">&nbsp;OK&nbsp;</a></td></tr></table>';
	   }
	   
	   message_box.style.visibility = "hidden";
	   message_box.style.display = "block";
	   
	   message_box.style.left = (posX - (message_box.offsetWidth / 2)) + "px";
	   message_box.style.top = (posY - (message_box.offsetHeight / 2)) + "px";
	   
	   message_box.style.visibility = "visible";
	   
	   message_box.style.zIndex = parseInt(total_z_index) + 1;
	   total_z_index++;
	}
	
	function message_box_hide(message_box_type)
	{
	   var message_box = document.getElementById(message_box_type + "_box");
	   
	   total_z_index--;
	   
	   message_box.style.display = "none";
	}
	
	var message_text = "";
	var print_message_box = "";
	function print_message(message_text_tmp)
	{
        message_text = message_text_tmp;
        print_message_box = window.open("/template_blanks/print_message_template.php", "print_message_box", "width=800,height=600");
        $(print_message_box.document).ready(function(){print_message_box.focus(); print_message_out();});
    }
    
    function print_message_out()
    {
        if(print_message_box.document.getElementById("print_message_text"))
        {
            print_message_box.document.getElementById("print_message_text").innerHTML = message_text;
            print_message_box.print();
        }else{
            setTimeout("print_message_out();", 100);
        }
    }

    function format_money(amount) {
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;

    }

    function compile_checked_list(form_checkboxes)
    {
        var compile_check_arr = new Array();
        var list_count = 0;
        
        if(form_checkboxes.length)
        {
            for(i = 0; i < form_checkboxes.length; i++)
            {
                if(form_checkboxes[i].checked)
                {
                    compile_check_arr[list_count] = form_checkboxes[i].value;
                    list_count++;
                }
            }
        }else{
            if(form_checkboxes.checked)
            {
                compile_check_arr[0] = form_checkboxes.value;
            }
        }
        
        return compile_check_arr;
    }

    //action_page = the page where the ajax script is for the function you want to retrieve
    //action_type = the name of the request/funciton/ajax
    //parameters = list of all the parameters to send to ajax
    //function_parameters = list of all the parameters you want to pass to the function
    function produce_action(action_page, action_type, parameters, function_parameters)
    {
        if(!isArray(parameters)){ parameters = new Object; }
            
        var function_parameter_arr = ['submit_form', 'load_tinymce','confirm_title', 'confirm_text', 'refresh_page', 'return_function'];
        for (i = 0; i < function_parameter_arr.length; i++)
        {
            eval('var ' + function_parameter_arr[i] + ' = "";');
        }
        if(function_parameters)
        {
            var list_count = 0;
            var new_function_parameters = Array();
            for (var i in function_parameters)
            {
                eval('var ' + i + ' = "' + function_parameters[i] + '";');
                if(i == "confirm_title" || i == "confirm_text"){ function_parameters[i] = ""; }
                new_function_parameters[list_count] = "'" + i + "':'" + function_parameters[i]+ "'";
                list_count++;
            }
        }
        if(submit_form != "")
        {
            var request_parameters = AjaxRequest.serializeForm(document.getElementById(submit_form));
            if(request_parameters != "")
            {
                request_parameters = request_parameters.split("&");
                for(i=0; i<request_parameters.length;i++)
                {
                    parameters[request_parameters[i].split("=")[0]] = request_parameters[i].split("=")[1];
                }
            }
        }
        if(parameters)
        {
            var list_count = 0;
            var new_parameters = Array();
            for (var i in parameters)
            {
                new_parameters[list_count] = "'" + i + "':'" + parameters[i]+ "'";
                list_count++;
            }
        }
        
        //document.switch_account_form.admin_action_type[0].selected = true;
        if(confirm_text != "")
        {
            message_box_display('message', confirm_title, confirm_text + '<br /><br /><table border="0" cellspacing="0" cellpadding="0"><tr><td height="30" align="center" valign="top"><a href="#" class="save" onclick="produce_action(\'' + action_page + '\', \'' + action_type + '\', {' + new_parameters + '}, {' + new_function_parameters + '}); message_box_hide(\'message\'); return false;">&nbsp;Yes&nbsp;</a></td><td width="4"></td><td align="center" valign="top"><a href="#" class="error_button" onclick="message_box_hide(\'message\'); return false;">&nbsp;No&nbsp;</a></td></tr></table>');
            return false;
        }
        
       	AjaxRequest.post(
       	        {
    				'url':'/ajax/' + action_page
    				,'parameters':parameters
    				,'request_type':action_type
    				,'onSuccess':function(req)
    										{
    							                if(req.responseText.substring(0,6) == "error:")
    							                {
    							                    message_box_display("error", '', req.responseText.substring(6));
    							                    setTimeout("message_box_hide('error')", 3000);
    							                }else if(req.responseText.substring(0,13) == "errors_array:")
    							                {
    							                    eval(req.responseText.substring(13));
    							                    display_error_text(error_text);
    
    							                    for(i=0; i<disabled_action_buttons.length; i++)
    							                    {
    							                        document.getElementById(disabled_action_buttons[i] + "_on").style.display = "block";
    							                        document.getElementById(disabled_action_buttons[i] + "_off").style.display = "none";
    							                    }
    							                }else{
    							                    if(req.responseText != "")
    							                    {
    							                        response_parse = req.responseText.split(";|;|;|;|");
    							                        if(return_function != "")
    							                        {
    							                            eval(return_function.replace("[aa:return_text]", "response_parse[0]"));
    							                        }else{
    							                            message_box_display("message", response_parse[0], response_parse[1]);
    							                        }
    							                    }
                                                    if(refresh_page == "1")
                                                    {
    							                        document.location = document.location.href;
                                                    }
                                                    if(load_tinymce != "")
                                                    {
                                                        tinyMCE.idCounter = 0;
                                                        tinyMCE.execCommand('mceAddControl', true, load_tinymce);
                                                    }
    											}
    										}
    			}
    		);
    }


    var uploads_in_progress = false;
    var uploads_in_queue = 0;
    var uploads_count = 0;
    var uploads_queue = new Array();
    function uploads_add_queue(upload_field)
    {
        var error_text = new Array();
        var errors = false;
        
        uploads_count++;
        
        file_name = upload_field.value;
        if(file_name.lastIndexOf("\\")){ file_name = file_name.substring(file_name.lastIndexOf("\\") + 1) }

        
        if(errors == true)
        {
            display_error_text(error_text);
        }else{
            var new_div = document.createElement('div');
            new_div.innerHTML = '<span id="uploads_text_' + uploads_count + '"><span style="color: red; font-weight: bold;">Uploading:</span> ' + file_name + ' (<a href="#" class="link" onclick="uploads_cancel(' + uploads_count + '); return false;">cancel upload</a>)</span>';
            document.getElementById("uploads_section_list").appendChild(new_div);
            
            uploads_queue.push(uploads_count);
            
            var uploads_submit_form = document.createElement("form");
            uploads_submit_form.name = "uploads_submit_form_" + uploads_count;
            uploads_submit_form.id = "uploads_submit_form_" + uploads_count;
            uploads_submit_form.method = "post";
            uploads_submit_form.action = "/ajax/function_requests.php";
            uploads_submit_form.target = "uploads_target";
            if(browser_is_ie()){ enc_type = uploads_submit_form.getAttributeNode("enctype"); enc_type.value = "multipart/form-data"; }else{ uploads_submit_form.enctype = "multipart/form-data"; }
            document.body.appendChild(uploads_submit_form);
            uploads_submit_form.style.display = "none";
            
            
            var request_type_input = document.createElement('input');
            request_type_input.type = "hidden";
            request_type_input.name = "request_type";
            request_type_input.value = "uploads_process_file";
            uploads_submit_form.appendChild(request_type_input);

            var uploads_clone = upload_field.cloneNode(true);
            if(!browser_is_ie()){ uploads_clone.value = ""; }
            document.getElementById("uploads_section").appendChild(uploads_clone);
            uploads_submit_form.appendChild(upload_field);

            if(uploads_in_progress == false){ uploads_process_queue(0); }
        }
    }
    
    function uploads_process_queue(next_file)
    {
        if(uploads_queue.length > 0 && (uploads_in_progress == false || next_file == 1))
        {
            uploads_in_progress = true;
            uploads_in_queue = uploads_queue.shift();

            document.getElementById("uploads_submit_form_" + uploads_in_queue).submit();
        }
    }
    
    function uploads_process_completed(file_name, file_location, attachment_id)
    {
        document.getElementById("uploads_text_" + uploads_in_queue).innerHTML = '<input type="checkbox" name="message_attachments_' + attachment_id + '" value="' + attachment_id + '" checked="checked">&nbsp;<a href="' + file_location + '" target="_blank" class="link">' + file_name + '</a>';
        if(uploads_queue.length > 0){ uploads_process_queue(1); return false; }
        uploads_in_progress = false;
    }
    
    function uploads_cancel(upload_id)
    {
        document.getElementById("uploads_text_" + upload_id).style.display = "none";
        if(upload_id == uploads_in_queue)
        {
            if(browser_is_ie()){ uploads_target.document.execCommand('Stop'); }else{ uploads_target.stop(); }
            setTimeout("uploads_process_queue(1);", 1000);
        }else{
            for(i=0; i<uploads_queue.length; i++)
            {
                if(uploads_queue[i] == upload_id)
                {
                    uploads_queue.splice(i, 1);
                    break;
                }
            }
        }
    }

    function profile_retrieve_info(account_id)
    {
       	AjaxRequest.post(
       	        {
					'url':'/ajax/profile_requests.php'
					,'request_type':'retrieve_info'
					,'account_id':account_id
					,'include_ok_button':'1'
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    message_box_display("message", 'Profile Info', req.responseText);
												}
											}
				}
			);
    }

    function registration_submit_info()
    {
       	AjaxRequest.submit(
       	        document.registration_form
       	        ,{
       	            'url':'/ajax/registration_requests.php'
					,'request_type':'registration_submit_info'
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else if(req.responseText.substring(0,13) == "errors_array:")
								                {
								                    eval(req.responseText.substring(13));
								                    display_error_text(error_text);
								                }else if(req.responseText.substring(0,16) == "existing_domain:")
								                {
								                    message_box_display("message", 'Existing Organization', req.responseText.substring(16));
								                }else if(req.responseText.substring(0,21) == "confirmation_message:")
								                {
								                    message_box_display("message", 'Confirmation', req.responseText.substring(21));
								                }else{
								                    setup_split = req.responseText.split(":");
								                    window.location = ("/registration_completion.php?email_address=" + setup_split[1] + "&setup_id=" + setup_split[0]);
                                                }
											}
				}
			);
    }

    function registration_update_existing_account(account_decision)
    {
        if(account_decision == 1)
        {
            if(!document.existing_account_form.existing_account_id.length)
            {
                document.registration_form.existing_account_id.value = document.existing_account_form.existing_account_id.value;
            }else{
                for (i=0;i<document.existing_account_form.existing_account_id.length;i++)
                {
                      if (document.existing_account_form.existing_account_id[i].checked)
                      {
                             document.registration_form.existing_account_id.value = document.existing_account_form.existing_account_id[i].value;
                      }
                }
            }
        }else{
            document.registration_form.existing_account_id.value = "0";
        }
        
        message_box_hide('message')
        registration_submit_info();
    }

    function network_add_request_confirm(account_id, user_id, network_account_id)
    {
       	AjaxRequest.post(
       	        {
					'url':'/ajax/network_requests.php'
					,'request_type':'add_request_confirm'
					,'account_id':account_id
					,'user_id':user_id
					,'network_account_id':network_account_id
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    response_parse = req.responseText.split(";|;|;|;|");
								                    message_box_display("message", response_parse[0], response_parse[1]);
												}
											}
				}
			); 
    }

    function network_add_request(account_id, user_id, network_account_id, lender_code, allow_taxservice)
    {
       	AjaxRequest.post(
       	        {
					'url':'/ajax/network_requests.php'
					,'request_type':'add_request'
					,'account_id':account_id
					,'user_id':user_id
					,'network_account_id':network_account_id
					,'lender_code':lender_code
					,'allow_taxservice':allow_taxservice
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    response_parse = req.responseText.split(";|;|;|;|");
								                    message_box_display("message", response_parse[0], response_parse[1]);
								                    if(document.getElementById("network_request_action_holder_" + network_account_id)){
								                        document.getElementById("network_request_action_holder_" + network_account_id).innerHTML = '<span class="network_action_pending">Network Request Pending</span>';
								                    }
								                    setTimeout("message_box_hide('message')", 3000);
												}
											}
				}
			); 
    }

    function network_delete_request_confirm(account_id, user_id, network_account_id, my_network_id)
    {
       	AjaxRequest.post(
       	        {
					'url':'/ajax/network_requests.php'
					,'request_type':'delete_request_confirm'
					,'account_id':account_id
					,'user_id':user_id
					,'network_account_id':network_account_id
					,'my_network_id':my_network_id
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    response_parse = req.responseText.split(";|;|;|;|");
								                    message_box_display("message", response_parse[0], response_parse[1]);
												}
											}
				}
			); 
    }

    function network_delete_request(account_id, user_id, network_account_id, my_network_id)
    {
       	AjaxRequest.post(
       	        {
					'url':'/ajax/network_requests.php'
					,'request_type':'delete_request'
					,'account_id':account_id
					,'user_id':user_id
					,'network_account_id':network_account_id
					,'my_network_id':my_network_id
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    response_parse = req.responseText.split(";|;|;|;|");
								                    message_box_display("message", response_parse[0], response_parse[1]);
								                    if(document.getElementById("network_request_action_holder_" + network_account_id))
								                    {
								                        document.getElementById("network_request_action_holder_" + network_account_id).innerHTML = '<a href="#" class="network_action_add" onclick="network_add_request_confirm(\'' + account_id + '\', \'' + user_id + '\', \'' + network_account_id + '\');">Add To Network</a>';
								                    }
								                    setTimeout("message_box_hide('message')", 3000);
												}
											}
				}
			);
    }

    function inbox_send_message(account_id, user_id, redirect)
    {
       	AjaxRequest.submit(
				document.send_message
				,{
					'url':'/ajax/inbox_requests.php'
					,'request_type':'send_message'
					,'account_id':account_id
					,'user_id':user_id
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else if(req.responseText.substring(0,13) == "errors_array:")
								                {
								                    eval(req.responseText.substring(13));
								                    display_error_text(error_text);
								                }else{
								                    if(redirect == 1)
								                    {
								                        js_redirect('/inbox_view.php?view_id=' + req.responseText);
								                    }else{
								                        message_box_display("message", 'Message sent', 'Your message has been sent.<br /><br /><table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="#" class="save" onclick="message_box_hide(\'message\');">&nbsp;OK&nbsp;</a></td></tr></table>');
								                        setTimeout("message_box_hide('message')", 3000);
								                    }
												}
											}
				}
			);
    }

    function inbox_send_template(account_id, user_id, redirect, message_to, message_subject, message_text)
    {
       	AjaxRequest.post(
				{
					'url':'/ajax/inbox_requests.php'
					,'request_type':'send_template'
					,'account_id':account_id
					,'user_id':user_id
					,'redirect':redirect
					,'message_to':message_to
					,'message_subject':message_subject
					,'message_text':message_text
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    message_box_display("message", 'Send a message', req.responseText);
												}
											}
				}
			);
    }
    
    function profile_picture_upload(account_id)
    {
       	AjaxRequest.post(
       	        {
					'url':'/ajax/profile_requests.php'
					,'request_type':'picture_upload'
					,'account_id':account_id
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    response_parse = req.responseText.split(";|;|;|;|");
								                    message_box_display("message", response_parse[0], response_parse[1]);
												}
											}
				}
			);
    }

    function picture_process_iframe()
    {
        var error_text = new Array();
        var errors = false;
        
        file_name = document.upload_picture_file.picture_file.value;
        
        if(file_name.length == 0){ error_text["picture_file"] = "Please select a file to upload"; errors = true; }
        if(file_name.length > 0)
        {
            var ext_dot = file_name.lastIndexOf(".");
            var file_ext = "";
            if( ext_dot != -1 )
            {
                file_ext = file_name.substr(ext_dot + 1,file_name.length);
                file_ext = file_ext.toLowerCase();
            }
            
            if(file_ext != "jpg" && file_ext != "png")
            {
                error_text["picture_file"] = "JPG or PNG files only"; errors = true;
            }
        }
        if(errors == true)
        {
            display_error_text(error_text);
        }else{
            document.upload_picture_file.submit();
            document.getElementById("picture_upload_box").innerHTML = 'Please wait while your file is being uploaded<br /><br /><img src="/images/ajax_loader.gif" border="0" />';
        }
    }

    var g_parcel_status = "";
    var g_parcel_search = "";

    //info_type =   0 - Just info
    function property_file_retrieve(agent_id, collector_id, parcel_status, parcel_search, is_collector, lender_code, parcel_last_modified)
    {
        g_parcel_status = parcel_status;
        g_parcel_search = parcel_search;
        
        document.getElementById("property_file_box").innerHTML = '<p>Please wait while your file is being loaded<br /><br /><img src="/images/ajax_loader.gif" border="0" /></p>';
        
       	AjaxRequest.post(
       	        {
					'url':'/ajax/property_file_requests.php'
					,'request_type':'retrieve_file'
					,'agent_id':agent_id
					,'collector_id':collector_id
					,'parcel_status':parcel_status
					,'parcel_search':parcel_search
					,'is_collector':is_collector
					,'lender_code':lender_code
					,'parcel_last_modified':parcel_last_modified
					,'onSuccess':function(req)
											{
								                if(req.responseText.substring(0,6) == "error:")
								                {
								                    message_box_display("error", '', req.responseText.substring(6));
								                    setTimeout("message_box_hide('error')", 3000);
								                }else{
								                    document.getElementById("property_file_box").innerHTML = req.responseText;
												}
											}
				}
			);
    }
    
    function property_group_toggle(agent_id, collector_id, parcel_grp, parcel_status, parcel_search, is_collector, lender_code, parcel_last_modified)
    {
        if(document.getElementById("parcel_grp_" + parcel_grp).innerHTML == "")
        {
           	AjaxRequest.post(
           	        {
    					'url':'/ajax/property_file_requests.php'
    					,'request_type':'retrieve_file_parcels'
    					,'agent_id':agent_id
    					,'collector_id':collector_id
    					,'parcel_grp':parcel_grp
    					,'parcel_status':parcel_status
    					,'parcel_search':parcel_search
    					,'is_collector':is_collector
                        ,'lender_code':lender_code
                        ,'parcel_last_modified':parcel_last_modified
    					,'onLoading':function() { document.getElementById("parcel_grp_" + parcel_grp).innerHTML = 'Please wait while the parcels are being loaded<br /><br /><img src="/images/ajax_loader.gif" border="0" />'; }
    					,'onSuccess':function(req)
    											{
    								                if(req.responseText.substring(0,6) == "error:")
    								                {
    								                    message_box_display("error", '', req.responseText.substring(6));
    								                    setTimeout("message_box_hide('error')", 3000);
    								                }else{
    								                    document.getElementById("parcel_grp_" + parcel_grp).innerHTML = req.responseText;
    												}
    											}
    				}
    			);
        }
        if(document.getElementById("parcel_grp_" + parcel_grp).style.display == "none")
        {
            document.getElementById("parcel_grp_" + parcel_grp).style.display = "block";
            document.getElementById("img_grp_" + parcel_grp).src = "/images/minus.jpg";
        }else{
            document.getElementById("parcel_grp_" + parcel_grp).style.display = "none";
            document.getElementById("img_grp_" + parcel_grp).src = "/images/plus.jpg";
        }
    }
	
	function confirm_box(confirmText)
	{
		confirmation = confirm(confirmText);
		
		return confirmation;
	}
	
	function trim(str)
	{
		return str.replace(/^\s*|\s*$/g,"");
	}  
  
    function getScreenCenterY() {  
        var y = 0;  
      
        y = getScrollOffset()+(getInnerHeight()/2);  
      
        return(y);  
    }  
      
    function getScreenCenterX() {  
        return(document.body.clientWidth/2);  
    }  
      
    function getInnerHeight() {  
        var y;  
        if (self.innerHeight) // all except Explorer  
        {  
            y = self.innerHeight;  
        } else if (document.documentElement &&  
            document.documentElement.clientHeight)  
            // Explorer 6 Strict Mode  
        {  
            y = document.documentElement.clientHeight;  
        } else if (document.body) // other Explorers  
        {  
            y = document.body.clientHeight;  
        }  
        return(y);  
    }  
      
    function getScrollOffset() {  
        var y;  
        if (self.pageYOffset) // all except Explorer  
        {  
            y = self.pageYOffset;  
        } else if (document.documentElement &&  
                document.documentElement.scrollTop)  
            // Explorer 6 Strict  
        {  
            y = document.documentElement.scrollTop;  
        } else if (document.body) // all other Explorers  
        {  
            y = document.body.scrollTop;  
        }  
        return(y);  
    }
    
    function js_redirect(url)
    {
        window.location = url;
    }
    
    //Grid Functions
    //Grid HTML Sort
    function mygrid_html_sort(a,b,order){ 
        a = a.replace(/(<([^>]+)>)/ig,"");
        b = b.replace(/(<([^>]+)>)/ig,"");
        return (a.toLowerCase()>b.toLowerCase()?1:-1)*(order=="asc"?1:-1);
    }


// ===========================================================================
// take a DOM object and determine its absolute top/left/width/height
// geometry relative to the browser window (body).
function get_abs_geometry(_dObj){
    var jCoords = -1; // assume failure
    var nDeltaX, nDeltaY;
    var t;

    // make sure we're not dealing with null, undefined, or empty string
    if(_dObj != null && _dObj != void(0) && _dObj != ''){
        // if the object has a tagname, then we're most likely working with a DOM object
        if(_dObj.tagName){
            jCoords = new Object();
            jCoords.x = jCoords.y = jCoords.w = jCoords.h = 0;

            // get the DOM object's width and height
            jCoords.w += (_dObj.offsetWidth) ? _dObj.offsetWidth : 0;
            jCoords.h += (_dObj.offsetHeight) ? _dObj.offsetHeight : 0;

            // always count the x,y geometry of the object passed in
            nDeltaX = nDeltaY = 0;
            nDeltaX = (_dObj.offsetLeft) ? _dObj.offsetLeft : 0;
            nDeltaY = (_dObj.offsetTop) ? _dObj.offsetTop: 0;

            // update our coordinates
            jCoords.x += nDeltaX;
            jCoords.y += nDeltaY;

            // look at this DOM object's parent for the next calculation
            _dObj = (_dObj.offsetParent) ? _dObj.offsetParent : _dObj.parentNode;

            // calculate it's position relative to top left corner of browser body
            while(1){
                // if our current object is the body or has no parent, we are done calculating
                if(!_dObj.parentNode || _dObj.tagName.toUpperCase() == 'BODY'){ break; }

                nDeltaX = nDeltaY = 0;
                // ignore poisonous tag geometry.
                // TR's geometry is already taken into account by the TD geometry
                // B, I, U, FONT, CENTER tags geometry should be ignored

                t = _dObj.tagName.toUpperCase();
                if(t!='TR' && t!='TBODY' && t!='B' && t!='I' && t!='U' && t!='FONT' && t!='CENTER' && t!='A'){
                    // continue summing/calculating our rendered position
                    nDeltaX = (_dObj.offsetLeft) ? _dObj.offsetLeft : 0;
                    nDeltaY = (_dObj.offsetTop) ? _dObj.offsetTop: 0;
                }

                jCoords.x += nDeltaX;
                jCoords.y += nDeltaY;

                // look at this DOM object's parent for the next calculation
            	_dObj = (_dObj.offsetParent) ? _dObj.offsetParent : _dObj.parentNode;
            }
        }
    }
    // return our coordinate object (-1 on failure)
    return jCoords;
}
//============================================================================================
//|||||||||||||||||||||||||||||||||| STANDARDIZE ARRAYS ||||||||||||||||||||||||||||||||||||||
//============================================================================================
if(!Array.prototype.pop){
	Array.prototype.pop = function(){
		var last_val = this[this.length-1];
		this.length = Math.max(this.length-1,0);
		return last_val;
	}
}
//--------------------------------------------------------------------------------------------
if(Array.prototype.push && ([0].push(true)==true)){ Array.prototype.push = null; }
if(!Array.prototype.push){
	Array.prototype.push = function(){
		for(var i = 0; i < arguments.length; i++){
			this[this.length] = arguments[i];
		}
		return this.length;
	}
}
//============================================================================================
