	// ==========================================================================
	// ||||||||||||||||||||||||| 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+$/,"");
    }

	
	//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";
	}

	//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";
	}

    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 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{
								                    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)
    {
        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
					,'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)
    {
        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
    					,'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 show_parcel_info(agent_id, collector_id, parcel_id, info_type, is_collector)
    {
        if(info_type == 0)
        {
            request_type = 'retrieve_parcel_status';
        }else if(info_type == 1)
        {
            request_type = 'retrieve_parcel_info';
        }
       	AjaxRequest.post(
       	        {
					'url':'/ajax/property_file_requests.php'
					,'request_type':request_type
					,'agent_id':agent_id
					,'collector_id':collector_id
					,'parcel_id':parcel_id
					,'is_collector':is_collector
					,'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 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;
    }


// ===========================================================================
// 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;
	}
}
//============================================================================================
