function EstateWeb_Objects_PropertyCartManager(){
	this.MessageBox = __EstateWeb_Objects_PropertyCartManager_MessageBox; //method that opens the message box
	this.Save = __EstateWeb_Objects_PropertyCartManager_Save; //method to save property
	this.SaveMultiple = __EstateWeb_Objects_PropertyCartManager_SaveMultiple; //method to save many properties at onces
	this.Delete = __EstateWeb_Objects_PropertyCartManager_Delete; //method to remove from saved properties
	this.DeleteAll = __EstateWeb_Objects_PropertyCartManager_DeleteAll; //method to remove all saved properties
	this.OutputContainer; //container used to output the messagebox in (default is body)
	this.GenerateOutputContainer = __EstateWeb_Objects_PropertyCartmanager_GenerateOutputContainer;
	this.EmailProperties = __EstateWeb_Objects_PropertyCartmanager_EmailProperties;
	this.RefreshInlineView = __EstateWeb_Objects_PropertyCartManager_RefreshInlineView;
	this.PropertyType = 0;
}

function __EstateWeb_Objects_PropertyCartmanager_GenerateOutputContainer(){
	document.write("<div id=\"propertycart-outputcontainer\"><\/div>");
	this.OutputContainer = "propertycart-outputcontainer";
}

function __EstateWeb_Objects_PropertyCartManager_MessageBox(title,message,returnFunction){
	var sMessageFormat = "<div id=\"PropertyCartMessage\" class=\"propertycart-message-container\" style=\"display:block\">";
	sMessageFormat += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
	sMessageFormat += "<tr>";
	sMessageFormat += "<td class=\"propertycart-message-title propertycart-border-left propertycart-border-top propertycart-border-right\">&nbsp;"+title+"</td>";
	sMessageFormat += "<td class=\"propertycart-shadow-right\" rowspan=\"2\">&nbsp;</td>";
	sMessageFormat += "</tr>";
	sMessageFormat += "<tr>";
	sMessageFormat += "<td height=\"70\" class=\"propertycart-message-text propertycart-border-left propertycart-border-right propertycart-border-bottom propDetails\" valign=\"middle\">"+message+"</td>";
	sMessageFormat += "</tr>";
	sMessageFormat += "<tr>";
	sMessageFormat += "<td colspan=\"2\" class=\"propertycart-shadow-bottom\"></td>";
	sMessageFormat += "</table>";
	sMessageFormat += "</div>";
	
	//check that the output container doesn't contain the HTML above
	var oOutputContainer;
	if ( this.OutputContainer ){
		oOutputContainer = HttpManager.Document.GetObject(this.OutputContainer);
	}else{
		oOutputContainer = document.getElementsByTagName("body")[0];
	}
	var oChildContainer = document.createElement("div");
	oChildContainer.id = "estateweb-objects-propertycartmanager-messagebox-childcontainer";
	oChildContainer.style.position = "absolute";
	
	if ( HttpManager.Document.GetObject("estateweb-objects-propertycartmanager-messagebox-childcontainer") ){
		if ( oOutputContainer.childNodes ){
			oOutputContainer.removeChild( HttpManager.Document.GetObject("estateweb-objects-propertycartmanager-messagebox-childcontainer") );
		}
	}
	oChildContainer.innerHTML = sMessageFormat;
	oOutputContainer.appendChild ( oChildContainer );	

	setTimeout(function() { HttpManager.Document.GetObject("PropertyCartMessage").style.display = "none"; if ( returnFunction ) { eval(returnFunction+"()")}  }, 2500);
}

function __EstateWeb_Objects_PropertyCartManager_Save(ID,returnFunction,type){
	var response = PropertyCartManager.Save(ID, ( type ? type : this.PropertyType ));
	var message;
	switch ( response.value ){
		case 0:
			message = "Property Saved";
		break;
		case 2:
			message = "This property is already saved!";
		break;
		default:
			message = "An Unknown error occured";
		break;
	}
	this.MessageBox("Saved Properties", message, returnFunction);
}

function __EstateWeb_Objects_PropertyCartManager_SaveMultiple(IDs,returnFunction,type){
	var response = PropertyCartManager.SaveMultiple(IDs, ( type ? type : this.PropertyType ));
	var message;
	switch ( response.value ){
		case 0:
			message = "Properties Saved";
			break;
		default:
			message = "An Unknown error occured";
			break;
	}
	this.MessageBox("Saved Properties", message, returnFunction);
}

function __EstateWeb_Objects_PropertyCartManager_Delete(ID,returnFunction,type){
	var response = PropertyCartManager.Delete(ID, ( type ? type : this.PropertyType) );
	var message;
	switch ( response.value ){
		case 0:
			message = "Property Deleted";
		break;
		default:
			message = "An Unknown Error Occured";
		break;
	}
	if ( returnFunction ) { eval(returnFunction+"('"+response.value.toString()+"')"); } else { this.MessageBox("Saved Properties", message); }
}

function __EstateWeb_Objects_PropertyCartManager_DeleteAll(returnFunction,type){
	var response = PropertyCartManager.DeleteAll(( type? type : this.PropertyType ));
	if ( returnFunction ){ eval(returnFunction+"()") }
}

function __EstateWeb_Objects_PropertyCartManager_RefreshInlineView(){
	if ( HttpManager.Document.GetObject("frmPropertyCartInline") ){
		HttpManager.Document.GetObject("frmPropertyCartInline").location.reload();
	}
}

function __EstateWeb_Objects_PropertyCartmanager_EmailProperties(senderName,receipientEmail,returnFunction,type){
	var response = PropertyCartManager.EmailProperties(senderName,receipientEmail, ( type ? type : this.PropertyType ));
	var message;
	switch ( response.value ){
		case 0:
			message = "Your properties were successfully sent to "+receipientEmail;
		break;
		default:
			message = "There was an error attempting to send to "+receipientEmail;
		break;
	}
	if ( returnFunction ) { eval(returnFunction+"('"+response.value.toString()+"')"); } else { this.MessageBox("Saved Properties", message); }
}