// LOAD UP GLOBAL VARIABLES
var siteRoot = 'http://www.crossdevelopment.net/';

//-------------------------------------------------------------------------------------------------------->
// CHECK CONTACT US FORM
//-------------------------------------------------------------------------------------------------------->
function check_contact_us(){

	var name = eGet('name').value;
	var subject = eGet('subject').value;
	var email = eGet('email').value;
	var message = eGet('message').value;
	var err = new Array();

	if(name.length < 2) err.push('- Name must be at least 2 letters\n');
	if(subject.length < 2) err.push('- Subject must be at least 2 letters\n');
	if(email.length == 0) err.push('- You must enter an email address\n');
	if(message.length < 3) err.push('- Your message must be at least 3 characters\n');

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false && email.length > 0) err.push('- Please enter a valid email address!\n');

	if(err.length > 0){
		var error = ''
		for(i = 0; i < err.length; i++){error += err[i];}
		alert(error);
		return false;
	}else{
		return true;
	}

}

//-------------------------------------------------------------------------------------------------------->
// SCROLL THE MEDIA FORWARDS
//-------------------------------------------------------------------------------------------------------->
function checkLogin(){

	if(eGet('user_name').value == '' || eGet('password').value == ''){
		alert('You must enter a username and password!');
		return false;
	}else{
		return true;
	}

}

//-------------------------------------------------------------------------------------------------------->
// EDIT LOAD
//-------------------------------------------------------------------------------------------------------->
function editLoad(page,id,type,width){

	//--> COLLECT CURRENT VALUE
	var val = eGet(id).innerHTML.replace(/<br>/gi,'\r');

	//--> CHANGE EDIT TEXT
	eGet('edit_box').innerHTML = '<span class="box_error edit_button point" onclick="editSave(\''+page+'\',\''+id+'\',\''+type+'\',\''+width+'\');">click here to save</span>';

	//--> CHANGE TO INPUT BOX OR TEXTAREA
	if(type == 'input'){
		eGet('val_box').innerHTML = '<input type="text" id="'+id+'" style="width:'+width+'px;" value="'+val+'" />';
	}else if(type == 'textarea'){
		eGet('val_box').innerHTML = '<textarea id="'+id+'" style="width:'+width+'px;height:400px;">'+val+'</textarea>';
	}

}

//-------------------------------------------------------------------------------------------------------->
// EDIT SAVE
//-------------------------------------------------------------------------------------------------------->
function editSave(page,id,type,width){

	//--> COLLECT CURRENT VALUE
	var val = nl2br(eGet(id).value);

	//--> CHANGE EDIT TEXT
	eGet('edit_box').innerHTML = '<span class="box_info edit_button point" onclick="editLoad(\''+page+'\',\''+id+'\',\''+type+'\',\''+width+'\');">click here to edit</span>';

	//--> CHANGE TO INPUT BOX OR TEXTAREA
	if(type == 'input'){
	}else if(type == 'textarea'){
		eGet('val_box').innerHTML = '<span id="'+id+'">'+val+'</span>';
	}

	//--> PASS TO CLASS TO PERFORM THE ACTUAL INSERTION
	eGet('result_box').innerHTML = '';
	showDiv('result_box');
	var ajax_url = siteRoot + '?nadt=&c=admin&m=edit_save&id='+page+'&val='+val;
	eGet('result_box').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-medium.gif" /> Saving...';
	var helloAjax = new ajaxObject('result_box', ajax_url);
	helloAjax.update('&nadth=');

}

var desc_edits = new Array();
desc_edits[0] = new Array();
desc_edits[0][0] = 'none';
desc_edits[0][1] = 'nothing';

//-------------------------------------------------------------------------------------------------------->
// EDIT LOAD (PICTURE DESCRIPTION)
//-------------------------------------------------------------------------------------------------------->
function editLoad_desc(page,id,type,width){

	//--> COLLECT CURRENT VALUE
	var val = eGet(id).innerHTML.replace(/<br>/gi,'\r');

	//--> CHANGE EDIT TEXT
	eGet('edit_box').innerHTML = '<span class="box_error edit_button point" onclick="editSave_desc(\''+page+'\',\''+id+'\',\''+type+'\',\''+width+'\');">click here to save</span>';

	//--> CHANGE TO INPUT BOX OR TEXTAREA
	if(type == 'input'){
		eGet('val_box').innerHTML = '<input type="text" id="'+id+'" style="width:'+width+'px;margin:0px;" value="'+val+'" />';
	}else if(type == 'textarea'){
		eGet('val_box').innerHTML = '<textarea id="'+id+'" style="width:'+width+'px;height:400px;">'+val+'</textarea>';
	}

}

//-------------------------------------------------------------------------------------------------------->
// EDIT SAVE (PICTURE DESCRIPTION)
//-------------------------------------------------------------------------------------------------------->
function editSave_desc(page,id,type,width){

	//--> COLLECT CURRENT VALUE
	var val = nl2br(eGet(id).value);

	//--> CHANGE EDIT TEXT
	eGet('edit_box').innerHTML = '<span class="box_info edit_button point" onclick="editLoad_desc(\''+page+'\',\''+id+'\',\''+type+'\',\''+width+'\');">click here to edit</span>';

	//--> CHANGE BACK TO TEXT
	eGet('val_box').innerHTML = '<div id="'+id+'">'+val+'</div>';

	//--> UPDATE THE DESC_EDITS ARRAY
	var found = 'no'
	for(var d = 0; d < desc_edits.length; d++){
		if(desc_edits[d][0] == id) found = 'yes';
		item = d;
	}
	if(found == 'yes'){
		desc_edits[d][1] = val;
	}else{
		var item = desc_edits.length;
		desc_edits[item] = new Array();
		desc_edits[item][0] = page;
		desc_edits[item][1] = val;
	}

	//--> PASS TO CLASS TO PERFORM THE ACTUAL INSERTION
	eGet('result_box').innerHTML = '';
	showDiv('result_box');
	var ajax_url = siteRoot + '?nadt=&c=admin&m=edit_save_desc&id='+page+'&val='+val;
	eGet('result_box').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-medium.gif" /> Saving...';
	var helloAjax = new ajaxObject('result_box', ajax_url);
	helloAjax.update('&nadth=');


}

//-------------------------------------------------------------------------------------------------------->
// FLYER DELETE
//-------------------------------------------------------------------------------------------------------->
function flyer_delete(id){

	//--> DELETE THE FLYER IF THAT IS THEIR WISH
	if(confirm('Are you sure you want to delete this flyer?')){

		//--> PASS TO CLASS TO PERFORM THE ACTUAL INSERTION
		var ajax_url = siteRoot + '?nadt=&c=admin&m=flyer_delete&id='+id;
		eGet('flyer_'+id).innerHTML = 'deleting...';
		var helloAjax = new ajaxObject('flyer_'+id, ajax_url);
		helloAjax.update('&nadth=');

	}

}

//-------------------------------------------------------------------------------------------------------->
// LOAD PHOTO
//-------------------------------------------------------------------------------------------------------->
function loadPhoto(id,desc,li){

	//--> IF THIS ID HAS BEEN EDITED PREVIOUSLY, USE THE MOST RECENT EDIT TEXT
	for(var d = 0; d < desc_edits.length; d++){
		//--> FIND OUT IF THIS ID MATCHES
		if(desc_edits[d][0] == id){
			//--> IT DOES, CHECK THE LENGTH OF THE VALUE. IF IT EXISTS USE THIS AS THE DESC VAR
			if(desc_edits[d][1].length > 0) desc = desc_edits[d][1];
		}
	}

	//--> UPDATE PICTURE
	eGet('picture').innerHTML = '<img src="'+siteRoot+'images/photos/mid_'+id+'.jpg" />';

	//--> BUILD DESCRIPTION WITH EDIT ABILITY IF LOGGED IN
	var use = '<div class="floatL">';
	if(li == 1) use += '<div id="edit_box"><span class="box_info edit_button point" onclick="editLoad_desc(\''+id+'\',\'desc_text\',\'input\',\'380\');">click here to edit</span></div>';
	use += '</div><div id="val_box" class="floatL" style="margin-left: 15px;"><div id="desc_text">'+desc+'</div></div><div class="clear"></div>';

	//--> UPDATE DESCRIPTION
	eGet('desc').innerHTML = use;
}


//-------------------------------------------------------------------------------------------------------->
// PICTURE MARQUIS
//-------------------------------------------------------------------------------------------------------->
var phrases = [];
var last1 = 0;
var last2 = 0;
var last3 = 0;
var last4 = 0;
var last5 = 0;
phrases[1] = new Array('3000', '<img src="'+siteRoot+'images/marquis/man_woman_bags.jpg" />');
phrases[2] = new Array('3000', '<img src="'+siteRoot+'images/marquis/hand_shake.jpg" />');
phrases[3] = new Array('3000', '<img src="'+siteRoot+'images/marquis/kohls.gif" />');
phrases[4] = new Array('3000', '<img src="'+siteRoot+'images/marquis/worker_holding_food.jpg" />');
phrases[5] = new Array('3000', '<img src="'+siteRoot+'images/marquis/steel_frame_construction.jpg" />');
phrases[6] = new Array('3000', '<img src="'+siteRoot+'images/marquis/MCD.jpg" />');
phrases[7] = new Array('3000', '<img src="'+siteRoot+'images/marquis/drive_thru.jpg" />');
phrases[8] = new Array('3000', '<img src="'+siteRoot+'images/marquis/24HourFitness.jpg" />');
phrases[9] = new Array('3000', '<img src="'+siteRoot+'images/marquis/hand_pile.jpg" />');
phrases[10] = new Array('3000', '<img src="'+siteRoot+'images/marquis/woman_sitting_bags.jpg" />');
phrases[11] = new Array('3000', '<img src="'+siteRoot+'images/marquis/grand_opening.jpg" />');

//--> POP THE OLD MARQUIS IMAGE
function marquis(num){

	//--> PUFF THE FRAME
	new Effect.Fade('marquis');

	//--> PULL UP THE NEXT FRAME AFTER A WAIT
	setTimeout('new marquis_next('+num+')', 1500);

}

//--> LOAD THE NEW MARQUIS IMAGE
function marquis_next(num){

	//--> FIGURE OUT WHICH TO SHOW AND SET LAST 3 IMAGES SO THEY AREN'T SHOWN AGAIN
	if(num == 0){
		//--> FIRST PAGE LOAD, SHOW FIRST FRAME
		num = 1;
		last1 = 1;
	}else{
		//--> ON ANY SUBSEQUENT LOADS ROTATE BETWEEN THE REST, MAKING SURE IT HASN'T BEEN USED LAST 3 TIMES
		num = Math.ceil((phrases.length-1)*Math.random());
			while(num == last1 || num == last2 || num == last3 || num == last4 || num == last5){
				num = Math.ceil((phrases.length-1)*Math.random());
			}
		last5 = last4;
		last4 = last3;
		last3 = last2;
		last2 = last1;
		last1 = num;
	}

	//--> FIRST IMAGE SHOULD BE MAN AND WOMAN HOLDING BAGS, THEN ROTATE
	var pic = (num == 1) ? phrases[1][1] : phrases[num][1];

	//--> CLEAR OUT MARQUIS
	eGet('marquis').innerHTML = pic;
	new Effect.Appear('marquis');

	setTimeout('new marquis('+num+')', phrases[num][0]);

}


//-------------------------------------------------------------------------------------------------------->
// SCROLL THE MEDIA BACKWARDS
//-------------------------------------------------------------------------------------------------------->
var worker = 'open';
function moveToPrevious(numPics, picsPer, moveAmt){
	if(eGet('curPic').innerHTML > 1){
		if(worker == 'open'){worker = 'working';
			new Effect.Move('imageBoxInside', { x: moveAmt, y: 0, transition: Effect.Transitions.sinoidal });
			eGet('curPic').innerHTML = parseInt(eGet('curPic').innerHTML) - picsPer;
			setTimeout('worker = \'open\'',1000);
		}
	}
}  

//-------------------------------------------------------------------------------------------------------->
// SCROLL THE MEDIA FORWARDS
//-------------------------------------------------------------------------------------------------------->
function moveToNext(numPics, picsPer, moveAmt){
	if(parseInt(eGet('curPic').innerHTML) + picsPer <= numPics){
		if(worker == 'open'){worker = 'working';
			new Effect.Move('imageBoxInside', { x: -moveAmt, y: 0, transition: Effect.Transitions.sinoidal });
			eGet('curPic').innerHTML = parseInt(eGet('curPic').innerHTML) + picsPer;
			setTimeout('worker = \'open\'',1000);
		}
	}
}

//-------------------------------------------------------------------------------------------------------->
// EDIT PROPERTY
//-------------------------------------------------------------------------------------------------------->
function propertyEdit_load(id)
{

	//--> PASS TO CLASS
	var ajax_url = siteRoot + '?nadt=&c=site&m=property_edit_load&id='+id;
	eGet('content_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Loading...';
	var helloAjax = new ajaxObject('content_'+id, ajax_url);
	helloAjax.update('&nadth=');

}

//-------------------------------------------------------------------------------------------------------->
// CANCEL PROPERTY UPDATE
//-------------------------------------------------------------------------------------------------------->
function propertyEdit_cancel(id)
{

	//--> PASS TO CLASS
	var ajax_url = siteRoot + '?nadt=&c=site&m=site&page=properties&cancel=yes&id='+id;
	eGet('content_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Loading...';
	var helloAjax = new ajaxObject('content_'+id, ajax_url);
	helloAjax.update('&nadth=');

}

//-------------------------------------------------------------------------------------------------------->
// DELETE PROPERTY
//-------------------------------------------------------------------------------------------------------->
function propertyDelete(id)
{

	//--> CONFIRM
	if(confirm('Are you sure you want to delete this property?\n\nALL details including every photo will be deleted')){

		//--> PASS TO CLASS TO FINISH DELETION
		var ajax_url = siteRoot + '?nadt=&c=site&m=property_delete&id='+id;
		eGet('inner_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Deleting...';
		var helloAjax = new ajaxObject('inner_'+id, ajax_url);
		helloAjax.update('&nadth=');

	}

}

//-------------------------------------------------------------------------------------------------------->
// UPDATE PROPERTY
//-------------------------------------------------------------------------------------------------------->
function propertyEdit_update(id)
{

	//--> COLLECT VALUES
	var title = eGet('title_'+id).value;
	var description = nl2br(eGet('description_'+id).value, true);
	var address1 = eGet('address1_'+id).value;
	var address2 = eGet('address2_'+id).value;
	var city = eGet('city_'+id).value;
	var state = eGet('state_'+id).value;
	var zip = eGet('zip_'+id).value;
	var team_id = eGet('team_id_'+id).options[eGet('team_id_'+id).selectedIndex].value;

	//--> VALIDATE TITLE AND DESCRIPTION EXIST
	if(title.length == 0 && description.length == 0){
		alert('You must enter a title and description');
		return false;
	}

	//--> PASS TO CLASS
	var ajax_url = siteRoot + '?nadt=&c=site&m=site&page=properties&update=yes&id='+id+'&title='+title+'&description='+description+'&address1='+address1+'&address2='+address2+'&city='+city+'&state='+state+'&zip='+zip+'&team_id='+team_id;
	eGet('content_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Updating...';
	var helloAjax = new ajaxObject('content_'+id, ajax_url);
	helloAjax.update('&nadth=');

}

//-------------------------------------------------------------------------------------------------------->
// SHOW ALWAYS (PHOTO)
//-------------------------------------------------------------------------------------------------------->
function show_always(id){

	//--> SEE IF IT'S CHECKED
	var option = (eGet('show_always_'+id).checked == true) ? 'yes' : 'no';

	//--> RESET SHOW ALWAYS RESULT DIV
	eGet('show_always_'+id+'_result').innerHTML = '';
	showDiv('show_always_'+id+'_result');

	//--> PASS TO CLASS
	var ajax_url = siteRoot + '?nadt=&c=admin&m=show_always&id='+id+'&show='+option;
	eGet('show_always_'+id+'_result').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-small.gif" /> Updating...';
	var helloAjax = new ajaxObject('show_always_'+id+'_result', ajax_url);
	helloAjax.update('&nadth=');

}

//-------------------------------------------------------------------------------------------------------->
// SLOGANS
//-------------------------------------------------------------------------------------------------------->
var slogans = [];
slogans[1] = new Array('4500', 'Commercial Real Estate Solutions');
slogans[2] = new Array('4500', 'A Foundation Built on Trust');
slogans[3] = new Array('4500', 'The Wise Choice in Real Estate Development');
slogans[4] = new Array('4500', 'Real Estate Knowledge You Can Trust');
slogans[5] = new Array('4500', 'A Fresh Approach to Real Estate');
slogans[6] = new Array('4500', 'Adding Value One Relationship at a Time');

//--> POP THE OLD SLOGAN
function slogan(num){

	//--> PUFF THE FRAME
	new Effect.DropOut('slogan');

	//--> PULL UP THE NEXT FRAME AFTER A WAIT
	setTimeout('new slogan_next('+num+')', 1500);

}

//--> LOAD THE NEW SLOGAN
function slogan_next(num){

	var num = (num + 1 >= slogans.length) ? 1 : num + 1;

	//--> CLEAR OUT slogan
	eGet('slogan').innerHTML = slogans[num][1];
	new Effect.BlindDown('slogan');

	setTimeout('new slogan('+num+')', slogans[num][0]);

}

//-------------------------------------------------------------------------------------------------------->
// EDIT TEAM
//-------------------------------------------------------------------------------------------------------->
function teamEdit_load(id)
{

	//--> PASS TO CLASS
	var ajax_url = siteRoot + '?nadt=&c=site&m=team_edit_load&id='+id;
	eGet('content_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Loading...';
	var helloAjax = new ajaxObject('content_'+id, ajax_url);
	helloAjax.update('&nadth=');

}

//-------------------------------------------------------------------------------------------------------->
// CANCEL TEAM UPDATE
//-------------------------------------------------------------------------------------------------------->
function teamEdit_cancel(id)
{

	//--> PASS TO CLASS
	var ajax_url = siteRoot + '?nadt=&c=site&m=site&page=our_team&cancel=yes&id='+id;
	eGet('content_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Loading...';
	var helloAjax = new ajaxObject('content_'+id, ajax_url);
	helloAjax.update('&nadth=');

}

//-------------------------------------------------------------------------------------------------------->
// DELETE TEAM MEMBER
//-------------------------------------------------------------------------------------------------------->
function teamDelete(id)
{

	//--> CONFIRM
	if(confirm('Are you sure you want to delete this employee?\n\nALL details including their bio and picture will be deleted')){

		//--> PASS TO CLASS TO FINISH DELETION
		var ajax_url = siteRoot + '?nadt=&c=site&m=team_delete&id='+id;
		eGet('inner_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Deleting...';
		var helloAjax = new ajaxObject('inner_'+id, ajax_url);
		helloAjax.update('&nadth=');

	}

}

//-------------------------------------------------------------------------------------------------------->
// UPDATE TEAM
//-------------------------------------------------------------------------------------------------------->
function teamEdit_update(id)
{

	//--> COLLECT VALUES
	var first_name = escape(eGet('first_name_'+id).value);
	var last_name = escape(eGet('last_name_'+id).value);
	var bio = escape(nl2br(eGet('bio_'+id).value, true));
	var title = escape(eGet('title_'+id).value);
	var loc = escape(eGet('location_'+id).value);
	var email = escape(eGet('email_'+id).value);
	var phone = escape(eGet('phone_'+id).value);
	var fax = escape(eGet('fax_'+id).value);
	var cell = escape(eGet('cell_'+id).value);
	var ext = escape(eGet('ext_'+id).value);
	var sort = (eGet('sort_'+id).value == 99999 || eGet('sort_'+id).value == 'N/A') ? 99999 : eGet('sort_'+id).value;

	//--> VALIDATE TITLE AND DESCRIPTION EXIST
	if(first_name.length == 0 || last_name.length == 0){
		alert('You must enter a first and last name');
		return false;
	}

	//--> PASS TO CLASS
	var ajax_url = siteRoot + 'nadt=&c=site&m=site&page=our_team&update=yes&id='+id+'&sort='+sort+'&first_name='+first_name+'&last_name='+last_name+'&title='+title+'&location='+loc+'&email='+email+'&phone='+phone+'&ext='+ext+'&fax='+fax+'&cell='+cell+'&bio='+bio;
	eGet('content_'+id).innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+siteRoot+'design/ajax-loader-large.gif" /> Updating...';
	var helloAjax = new ajaxObject_post('content_'+id, siteRoot);
	helloAjax.update('content_'+id, ajax_url, 'POST');

}

//-------------------------------------------------------------------------------------------------------->
// UPLOAD EMPLOYEE PICTURE SHOW UPLOAD WINDOW
//-------------------------------------------------------------------------------------------------------->
function upload_employee_picture_show(id){
	window.open(siteRoot + '?c=site&m=upload_employee_picture_show&id='+id,'Upload Photo','width=500,height=500,toolbar=no,location=no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

//-------------------------------------------------------------------------------------------------------->
// USE THIS INSTEAD OF HAVING TO TYPE OUT DOCUMENT.GETELEMENTBYID EVERYTIME
//-------------------------------------------------------------------------------------------------------->
function eGet(element){return document.getElementById(element);}

//-------------------------------------------------------------------------------------------------------->
// PRIMARY AJAX ENGINE
//-------------------------------------------------------------------------------------------------------->
function ajaxObject(layer, url) {	                                 // This is the object constructor
   var that=this;                                                    // A workaround for some javascript idiosyncrocies
   var updating = false;                                             // Set to true if this object is already working on a request
   this.callback = function() {}                                     // A post-processing call -- a stub you overwrite.

   this.update = function(passData) {                                // Initiates the server call.
      if (updating==true) { return false; }                          // Abort if we're already processing a call.
      updating=true;                                                 // Set the updating flag.
      var AJAX = null;                                               // Initialize the AJAX variable.
      if (window.XMLHttpRequest) {                                   // Are we working with mozilla?
         AJAX=new XMLHttpRequest();                                  //  Yes -- this is mozilla.
      } else {                                                       // Not Mozilla, must be IE
         AJAX=new ActiveXObject("Microsoft.XMLHTTP");                //  Wheee, ActiveX, how do we format c: again?
      }                                                              // End setup Ajax.
      if (AJAX==null) {                                              // If we couldn't initialize Ajax...
         alert("Your browser doesn't support AJAX.");                // Sorry msg.                                              
         return false                                                // Return false (WARNING - SAME AS ALREADY PROCESSING!)
      } else {
         AJAX.onreadystatechange = function() {                      // When the browser has the request info..
            if (AJAX.readyState==4 || AJAX.readyState=="complete") { //   see if the complete flag is set.
               LayerID.innerHTML=AJAX.responseText;                  //   It is, so put the new data in the object's layer
               delete AJAX;                                          //   delete the AJAX object since it's done.
               updating=false;                                       //   Set the updating flag to false so we can do a new request
               that.callback();                                      //   Call the post-processing function.
            }                                                        // End Ajax readystate check.
         }                                                           // End create post-process fucntion block.
         var timestamp = new Date();                                 // Get a new date (this will make the url unique)
         var uri=urlCall+passData+'&timestamp='+(timestamp*1);   // Append date to url (so the browser doesn't cache the call)
         AJAX.open("GET", uri, true);                                // Open the url this object was set-up with.
         AJAX.send(null);                                            // Send the request.
         return true;                                                // Everything went a-ok.
      }                                                              // End Ajax setup aok if/else block                 
   }
      
   // This area set up on constructor calls.
   var LayerID = eGet(layer);                     // Remember the layer associated with this object.
   var urlCall = url;                                                // Remember the url associated with this object.
}                                                                    // End AjaxObject


function ajaxObject_post(layer, url, callbackFunction) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(layer, passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4 || that.AJAX.readyState=="complete") {             
          LayerID.innerHTML=that.AJAX.responseText;                  //   It is, so put the new data in the object's layer
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  LayerID = eGet(layer);                     // Remember the layer associated with this object.
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}
//-------------------------------------------------------------------------------------------------------->
// PAUSE THE SCRIPT
//-------------------------------------------------------------------------------------------------------->
function pause(millis)
{
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < millis);
}

//-------------------------------------------------------------------------------------------------------->
// SHOW A DIV ELEMENT (OPENS IT ESSENTIALLY)
//-------------------------------------------------------------------------------------------------------->
function showDiv(element){
	//--> USE DISPLAY NONE TO HIDE THE DIV
	try{eGet(element).style.display = 'block';}catch(e){}
}

//-------------------------------------------------------------------------------------------------------->
// HIDE A DIV ELEMENT (CLOSES IT ESSENTIALLY)
//-------------------------------------------------------------------------------------------------------->
function hideDiv(element,delay){
	//--> USE DISPLAY NONE TO HIDE THE DIV
	if(delay > 0){
		setTimeout('try{eGet(\''+element+'\').style.display = \'none\';}catch (e) {}',delay);
	}else{
		try{eGet(element).style.display = 'none';}catch (e) {}
	}
}

//-------------------------------------------------------------------------------------------------------->
// NL2BR
//-------------------------------------------------------------------------------------------------------->
function nl2br (str, is_xhtml) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Philip Peterson
    // +   improved by: Onno Marsman
    // +   improved by: Atli Þór
    // +   bugfixed by: Onno Marsman
    // *     example 1: nl2br('Kevin\nvan\nZonneveld');
    // *     returns 1: 'Kevin<br />\nvan<br />\nZonneveld'
    // *     example 2: nl2br("\nOne\nTwo\n\nThree\n", false);
    // *     returns 2: '<br>\nOne<br>\nTwo<br>\n<br>\nThree<br>\n'
    // *     example 3: nl2br("\nOne\nTwo\n\nThree\n", true);
    // *     returns 3: '<br />\nOne<br />\nTwo<br />\n<br />\nThree<br />\n'
 
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
 
    return (str).replace(/\n/gi, breakTag);
}