/*******************************************************************************
* pucv ajax library
*******************************************************************************/
function pucv_AjaxObjectCreator(browser,url,method,synchronisation,parameterList,callBackFunction,htmlElement,waitingMessage){
this.browser=browser;
this.url = url;
this.method = method;
this.synchronisation=synchronisation;
this.parameterList = parameterList;
this.callBackFunction = callBackFunction;
this.readyState=4;
this.status=200;
this.ajaxResponse;
this.htmlElement=htmlElement;
this.actionComplete=false;
document.getElementById(this.htmlElement).innerHTML = waitingMessage+'..';

switch(this.browser)
{
case 'IE':
ajaxObject = new window.ActiveXObject('Microsoft.XMLHTTP');
break;

case 'notIE':
ajaxObject = new XMLHttpRequest();
break;

default:
//ajaxObject = new window.ActiveXObject('Microsoft.XMLHTTP');
}
}

pucv_AjaxObjectCreator.prototype.runAjax=function(){
ajaxObject.onreadystatechange=this.callBackController;
ajaxObject.open(this.method,this.url,this.synchronisation);
if(this.method=='POST')
{ 
	ajaxObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxObject.setRequestHeader("Content-length", this.parameterList.length);
	ajaxObject.setRequestHeader("Connection", "close");

}
ajaxObject.send(this.parameterList);
}

pucv_AjaxObjectCreator.prototype.callBackController=function(){
if(ajaxObject.readyState == ajax.readyState)
  {
    if(ajaxObject.status == ajax.status)
		  {
				ajax.ajaxResponse = ajaxObject.responseText;
				eval(ajax.callBackFunction);
			}
  }
}

/*******************************************************************************
* Email functions - show inbox
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.showBox = function(){
document.getElementById(ajax.htmlElement).innerHTML = ajax.ajaxResponse;
//this.actionComplete=true;
}

/*******************************************************************************
* Email functions - delete email
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.deleteMessage = function(){
inbox();
}

/*******************************************************************************
* Email functions - send email
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.sendMessage = function(){
inbox();
}

/*******************************************************************************
* Email functions - show search results
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.displaySearchResults = function(){
document.getElementById(ajax.htmlElement).innerHTML = ajax.ajaxResponse;
}

/*******************************************************************************
* Shortlist functions - show search results
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.shortlist = function(){
}

/*******************************************************************************
* Shortlist functions - show search results
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.addShortlist = function(){

}

/*******************************************************************************
* Shortlist functions - show search results
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.removeShortlist = function(){

}

/*******************************************************************************
* Testing functions
*******************************************************************************/
pucv_AjaxObjectCreator.prototype.test = function(){
alert('test');
}

/* ********************************************************************************
*
* Method: updateSerachWords
* Description: records users key words to help search
*
* ********************************************************************************/
pucv_AjaxObjectCreator.prototype.updateSearch = function(){
document.getElementById('sug').innerHTML=ajax.ajaxResponse;
 }
/* ************************** End *************************************************/

