/**
 * Project:     
 * File:        
 * @author:     Michael D. Wailes   mwailes@holonyx.com
 * Version:     
 * Description: 
 *
 */


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/* This is function is used to call a request from the server via AJAX...Probably wont use this
* anymore in favor of the Prototype request*/
function loadPageContent(thisSource){
  var url = "modules/";
  url = url + thisSource +".php";
  url = url + "?dummy=" + new Date().getTime();
  request.open("GET", url, true);
  request.onreadystatechange = updatePage;
  request.send(null);
 
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/




/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/* This function updates the page contents with the return of loadPageContent() function.
* Probably wont use this anymore in favor of the Protoype request*/
function updatePage(){
  if (request.readyState == 4){
    var pageContent = request.responseText;
    document.getElementById('contentArea').innerHTML = pageContent;
    }
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function updateContentAjax(what, where, id, extra){
				new Ajax.Updater(where, what, { method: 'get', parameters: {userID: id, ex: extra}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function updateContentPostAjax(what, where, id, extra){
				new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, ex: extra}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function getPasswordAjax(what, where){
				new Ajax.Updater(where, what, { method: 'post', parameters: {usernameFGT: $F('usernameFGT'), email: $F('email')}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function checkPasswordAnswerAjax(what, where, id){
				new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, answer: $F('answer')}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/



/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function getEventAjax(what, where, id){
				new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, event_date: $F('event_date')}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/



/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function updateNavAjax(what, where, startnumber, extra){
				new Ajax.Updater(where, what, { method: 'post', parameters: {startnumber: startnumber, ex: extra}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function updateNav2Ajax(what, where, userID, startnumber, alpha, menu ){
				new Ajax.Updater(where, what, { method: 'post', parameters: {userID: userID, startnumber: startnumber, alpha: alpha, menu: menu}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function createEventAjax(what, userID){
				new Ajax.Request(what, { method: 'post', parameters: {userID: userID, 
                                                                                                                                 event_title: $F('event_title'),
                                                                                                                                event_descript: $F('event_descript'), 
                                                                                                                                event_date: $F('event_date'), 
                                                                                                                                contact:$F('contact')
                                                                                                                                                                                                 }, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/




/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function completeEventAjax(what, userID, contactID, eventID){
				new Ajax.Request(what, { method: 'post', parameters: {userID: userID, contactID: contactID, eventID: eventID}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function writeNoteAjax(what, userID, contactID){
				new Ajax.Request(what, { method: 'post', parameters: {userID: userID, contactID: contactID, content:  $F('new_note')}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/



/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function editNoteAjax(what, userID, contactID, noteID, ex){
        var note = 'editThisNote' + ex;
				new Ajax.Request(what, { method: 'post', parameters: {userID: userID, contactID: contactID, noteID: noteID, content: $F(note)}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/



/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function deleteNoteAjax(what, userID, contactID, noteID){
				new Ajax.Request(what, { method: 'post', parameters: {userID: userID, contactID: contactID, noteID: noteID}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/




/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called and the "where" param is where the update takes place. 
* This function also evaluates any inline scripts contained in the callback*/
function updatePropertyAjax(what, where, id, contact, property){
				new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, contactID: contact, propID: property}, evalScripts: true })
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/





/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateMenuContentAjax(what, where, who, id){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'get', parameters: {caller: who, userID: id}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/



/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateReportMenuAjax(what, where, who, id){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {caller: who, userID: id, selection: $F('report')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateReportMenu2Ajax(what, where, id, extra){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, ex: extra, selection: $F('param1')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateReportMenu3Ajax(what, where, id, extra){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, ex: extra, selection2: $F('param1')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateReportMinRateAjax(what, where, id, extra){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, ex: extra, product: $F('product')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateReportMaxRateAjax(what, where, id){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, minRate: $F('min_rate')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function getMaxRateMenu2Ajax(what, where, id, extra){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, ex: extra, selection: $F('param1')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/




/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles live searchs. 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "id" param is either the user who is making the call or the user
* upon the request it (for the admin side). A new parameter is introduced but not passed
* to the function: "alpha", which simply pulls the value of the input text box and passes it
* to the php script that is called in the "what" parameter
*/
function liveSearchAjax(what, where, id, startnumber, menu){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'get', parameters: {alpha: $F('name_search'), userID: id, startnumber: startnumber, menu: menu}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/



/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function updates the sys_user database when the admin edits a user.
*/
function editUserAjax(what){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Request(what, { method: 'post', 
                                                                                parameters: {get_user_id: $F('get_user_id'),
                                                                                                       user_fname: $F('user_fname'),
                                                                                                       user_mname: $F('user_mname'),
                                                                                                       user_lname: $F('user_lname'),
                                                                                                       user_address: $F('user_address'),
                                                                                                       user_city: $F('user_city'),
                                                                                                       user_state: $F('user_state'),
                                                                                                       user_zip: $F('user_zip'),
                                                                                                       user_phone: $F('user_phone'),
                                                                                                       user_mobile: $F('user_mobile'),
                                                                                                       user_fax: $F('user_fax'),
                                                                                                       user_email: $F('user_email'),
                                                                                                       user_active: $F('active'),
                                                                                                       user_level: $F('user_level'),
                                                                                                       company_name: $F('company_name'),
                                                                                                       company_address: $F('company_address'),
                                                                                                       company_city: $F('company_city'),
                                                                                                       company_state: $F('company_state'),
                                                                                                       company_zip: $F('company_zip'),
                                                                                                       user_password: $F('user_password'),
                                                                                                       password_question: $F('password_question'),
                                                                                                       password_answer: $F('password_answer'),
                                                                                                       remind_email: $F('remind_email'),
                                                                                                       remind_password: $F('remind_password')                                                                                       }	
		})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
* This function handles updating a list menu based on a user selection.
* This function will treat any container like a form element...don't need innerHTML 
* The "what" param is the file to be called, the "where" param is where the update 
* takes place, the "who" param is where the call was made from 
*/
function updateSourceMenu1Ajax(what, where, id){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {userID: id, category: $F('category')}
			})
}

function updateSourceMenu2Ajax(what, where, who, id){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {caller: who, userID: id, source1: $F('sourceMenu')}
			})
}

function updateSourceMenu3Ajax(what, where, who, id){
                        // "Caller" is the variable that is sent to the .php script and "who" is its value
			new Ajax.Updater(where, what, { method: 'post', parameters: {caller: who, userID: id, referral: $F('referralMenu')}
			})
}
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/
/*
These functions are used to delete a contact
*/
/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/

function deleteContact(what, where, userID, contactID, startNumber){
                var agree = confirm("WARNING: Are you sure you want to delete this contact? THIS ACTION CANNOT BE UNDONE. Click OK to delete the contact, click CANCEL to return to your contacts without making any changes.");
                if (agree)
                        deleteContactAjax(what, where, userID, contactID, startNumber)
                else
                        return false;
}

function deleteContactAjax(what, where, userID, contactID, startNumber){
        new Ajax.Request(what, { method: 'post', parameters: {userID: userID, contactID: contactID, startNumber: startNumber}, evalScripts: true });
        updateDeleteAjax('modules/contacts/sqlToretrieve.php', 'MaincontentArea', userID, startNumber);
}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

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

function updateDeleteAjax(what, where, userID, startNumber){
        new Ajax.Request(what, { method: 'post', parameters: {userID: userID, startnumber: startNumber}, evalScripts: true });
}


/*--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--*/


function setTrialDaysAjax(what){
				new Ajax.Request(what, { method: 'post', parameters: {trialDays: $F('trial_days') }, evalScripts: true })
}
 

