function loadSpecificFormHtmlDetails(info, currentPropertyID, currentTransactionID)
{
	new Ajax.Request("data/getDetails.php",
	{
			onSuccess : function(response)
			{
				if(currentProcessState == 'add')
				{
					disableMenu(currentProcessState);
					$('savedData').innerHTML = '';
				}
				$('divDetailsDetails').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
				
				
				if(currentPaymentID == 1)
				{
					$('divDetailsBuyer').style.fontWeight 	= '';
					eval("TabArray."+"buyer"+" = false;");
					$('SellerName').innerHTML = "Lessor";
				}
				else
				{
					eval("TabArray."+"buyer"+" = true;");
					$('SellerName').innerHTML = "Seller";
				}
				
				if(currentProcessState == 'add')
				{
					displayTeams();
				}
			},
			onFailure : function(request) {
				alert("error loading Details form ...");
			},
			onComplete : function(request) 
			{
				$('Loading').style.display = 'none';
			},
			parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID
	});
}

function loadSpecificFormHtmlListing(info, currentPropertyID, currentPropertyTypeSent, currentTitleDeedSent, currentTransactionID, currentPaymentID, deleteFeaturesVar)
{
	var yesno = false;
	var safe  = false;
	Potential = 'Yes';
//	if(currentPropertyTypeSent != currentPropertyType || currentTitleDeedSent != currentTitleDeed)
//	{
//		var yesno = confirm('Are you sure you want to Change your listings type? (This will remove all features!)');
//	}
//	else if(currentPropertyTypeSent == currentPropertyType && currentTitleDeedSent == currentTitleDeed)
//	{
		safe = true;
//	}
//	
//	if(deleteFeaturesVar == 'deleteFeatures' && yesno==true)
//	{
//		new Ajax.Request("data/delfeatures.php",
//		{
//				onSuccess : function(response) 
//				{
//					
//				},
//				onFailure : function(request) {
//					alert("error deleting features ...");
//				},
//				onComplete : function(request) 
//				{
//					$('Loading').style.display = 'none';
//				},
//				parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyTypeSent + "&TitleDeed=" + currentTitleDeedSent + "&TransactionID=" + currentTransactionID + "&PaymentID=" + currentPaymentID + "&currentProcessState=" + currentProcessState
//		});
//	}
	
	if(yesno==true || safe==true)
	{
	new Ajax.Request("data/getListing.php",
	{
			onSuccess : function(response) 
			{
				//alert(currentPaymentID);
//				if(currentProcessState == 'add')
//				{
					$('divDetailsListing').style.fontWeight = 'bold';
					disableMenu(currentProcessState);
//				}
				$('divDetailsListing').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
				$('savechangeslisting').disabled = true;
				LoadInitialSuburbOptions(currentPropertyID);
				
			},
			onFailure : function(request) {
				alert("error loading Listings form ...");
			},
			onComplete : function(request) 
			{
				$('Loading').style.display = 'none';
				
			},
			parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyTypeSent + "&TitleDeed=" + currentTitleDeedSent + "&TransactionID=" + currentTransactionID + "&PaymentID=" + currentPaymentID + "&currentProcessState=" + currentProcessState
	});
	}
}

function loadSpecificFormHtmlFeatures(info, currentPropertyID, currentPropertyType, currentTransactionID, Extra)
{
//	if(Extra == 'addsection' && currentProcessState == 'add')
//	{
//		new Ajax.Request("data/TestAgentExits.php",
//		{
//				onSuccess : function(response) 
//				{
//					if(response.responseText == 'true')
//					{
//						new Ajax.Request("data/getfeaturesform.php",
//						{
//								onSuccess : function(response) 
//								{
//									if(currentProcessState == 'add')
//									{
//										$('divDetailsFeatures').style.fontWeight = 'bold';
//										disableMenu(currentProcessState);
//									}
//									$('divDetailsFeatures').style.backgroundColor  = '#8AA7E1';
//									$('divDetailsContent').innerHTML = response.responseText;
//								},
//								onFailure : function(request) {
//									alert("error loading Features form ...");
//								},
//								onComplete : function(request) 
//								{
//									$('Loading').style.display = 'none';
//								},
//								parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyType + "&TransactionID=" + currentTransactionID + "&currentProcessState=" + currentProcessState
//						});
//					}
//					else
//					{
//						alert('Please Add a Agent....');
//					}
//				},
//				onFailure : function(request) {
//					alert("error loading Features form ...");
//				},
//				onComplete : function(request) 
//				{
//					
//				},
//				parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyType + "&TransactionID=" + currentTransactionID
//		});
//		
//	}
//	else
//	{
		new Ajax.Request("data/getfeaturesform.php",
		{
				onSuccess : function(response) 
				{
					if(currentProcessState == 'add')
					{
						$('divDetailsFeatures').style.fontWeight = 'bold';
						disableMenu(currentProcessState);
					}
					$('divDetailsFeatures').style.backgroundColor  = '#8AA7E1';
					$('divDetailsContent').innerHTML = response.responseText;
					
					
					

				},
				onFailure : function(request) {
					alert("error loading Features form ...");
				},
				onComplete : function(request) 
				{
					$('Loading').style.display = 'none';														
				},
				parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyType + "&TransactionID=" + currentTransactionID + "&currentProcessState=" + currentProcessState
		});
//	}
}

function updatefeatures(ProptypeID, PropertyID, CurrentFeatures, TransactionID, Description, pvtnotes, hightlights)
{	
	pvtnote	   	   = encodeURIComponent(pvtnotes); 
	hightlight	   = encodeURIComponent(hightlights);
	
	var params = Form.serialize($("featuresForms"));
	new Ajax.Request("data/updatefeaturesforms.php",
	{
			onSuccess : function(response) 
			{
//				var test = new MaJiG_BOX(response.responseText);
				var ErrorDivs = document.getElementsByClassName("errorDiv");
				$H(ErrorDivs).each(function(Div)
				{
					Div.value.style.display = "none";
					Div.value.innerHTML ="";
				});
				var dataset = $H();
				dataset = eval("(" + response.responseText + ")");
				if(dataset.errors)
				{
					formFieldsErrorDisplay(dataset.errors);
				}
				
				//$('Description_ErrorDiv').innerHTML = "";
				$('PropNotes_ErrorDiv').innerHTML = "";
                                if(response.responseText == "false")
				{
					$('Description_ErrorDiv').innerHTML = "<font color='red'>This field requires a value</font>";
					$('PropNotes_ErrorDiv').innerHTML = "&nbsp";
					$('savedData').innerHTML = "<font color='red'><b>An Error was found updating values.....</b></font>";
				}
				else if(dataset.errors)
				{
					$('savedData').innerHTML = dataset.msg;
				}
				else
				{
					$('savedData').innerHTML = "<font color='green'><b>Successfully Saved..</b></font>";
					if(currentProcessState == 'add')
					{
						loadAgent('agent', currentPropertyID, currentPropertyType, currentTransactionID);
//						imagesUploaderForm('images', currentPropertyID, currentPropertyType, currentTransactionID);
						$('savedData').innerHTML = '';
					}
				}
				
				if(currentProcessState != 'add')
				{
					//_prop24Update();
					_propertyFeedsUpdate();
				}
			},
			onFailure : function(request) {
				alert("error loading Features form ...");
			},
			onComplete : function(request) 
			{
				
			},
			parameters:params + "&Proptype=" + ProptypeID + "&PropertyID=" + PropertyID + "&TransactionID=" + currentTransactionID + "&pvtnotes=" + pvtnote + "&highlights=" + hightlight + "&Mode=" + currentProcessState
	});
	//"&HiddenFeatureArray=" + sortPropListFeatures(CurrentFeatures) +
}

function imagesUploaderForm(info, currentPropertyID, currentPropertyType, currentTransactionID)
{
	$('savedData').innerHTML = "";
	new Ajax.Request("data/imagesuploader.php",
	{
			onSuccess : function(response) 
			{
//				if(currentProcessState == 'add')
//				{
					$('divDetailsImages').style.fontWeight = 'bold';
					disableMenu(currentProcessState);
//				}
				$('divDetailsImages').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
			},
			onFailure : function(request) {
				alert("error loading Images form ...");
			},
			onComplete : function(request)
			{
				$('Loading').style.display = 'none';
			},
			parameters : "propid=" + currentPropertyID + "&TransactionID=" + currentTransactionID + "&currentProcessState=" + currentProcessState + "&currentPropertyType=" + currentPropertyType
	});	
}


function loadSellerForm(info, currentPropertyID, currentPropertyType, currentTransactionID)
{
	new Ajax.Request("data/getSellerBuyer.php",
	{
			onSuccess : function(response) 
			{
				if(currentProcessState == 'add')
				{
					$('divDetailsSeller').style.fontWeight = 'bold';
					disableMenu(currentProcessState);
				}
				$('divDetailsSeller').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
			},
			onFailure : function(request) {
				alert("error loading Seller form ...");
			},
			onComplete : function(request) 
			{
				
			},
			parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyType + "&Request=Seller"  + "&TransactionID=" + currentTransactionID + "&currentProcessState=" + currentProcessState
	});
}

function loadBuyerForm(info, currentPropertyID, currentPropertyType, currentTransactionID)
{
	new Ajax.Request("data/getSellerBuyer.php",
	{
			onSuccess : function(response) 
			{
				if(currentProcessState == 'add')
				{
					disableMenu(currentProcessState);
				}
				$('divDetailsBuyer').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
			},
			onFailure : function(request) {
				alert("error loading Seller form ...");
			},
			onComplete : function(request) 
			{
				
			},
			parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyType + "&Request=Buyer"  + "&TransactionID=" + currentTransactionID
	});
}

function loadAgent(info, currentPropertyID, currentPropertyType, currentTransactionID)
{
	new Ajax.Request("data/getAgent.php",
	{
			onSuccess : function(response) 
			{
				if(currentProcessState == 'add')
				{
					$('divDetailsAgent').style.fontWeight = 'bold';
					disableMenu(currentProcessState);
					$('savedData').innerHTML = '';
				}
				$('divDetailsAgent').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
				UpdateAgentOrLoad('LOAD', currentPropertyID, currentTransactionID);
			},
			onFailure : function(request) {
				alert("error loading Agents form ...");
			},
			onComplete : function(request) 
			{
				$('Loading').style.display = 'none';
			},
			parameters : "PropertyID=" + currentPropertyID + "&Proptype=" + currentPropertyType + "&TransactionID=" + currentTransactionID+ "&currentPropertyType=" + currentPropertyType + "&currentProcessState=" + currentProcessState
	});
}

function loadStatus()
{
	new Ajax.Request("data/getStatus.php",
	{
			onSuccess : function(response) 
			{
				if(currentProcessState == 'add')
				{
					$('divDetailsStatus').style.fontWeight = 'bold';
					disableMenu(currentProcessState);
					$('savedData').innerHTML = '';
				}
				$('divDetailsStatus').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
				StatusChange();
//				UpdateAgentOrLoad('LOAD', currentPropertyID, currentTransactionID);
			},
			onFailure : function(request) {
				alert("error loading Agents form ...");
			},
			onComplete : function(request) 
			{
				$('Loading').style.display = 'none';
			},
			parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID+ "&currentPropertyType=" + currentPropertyType + "&currentProcessState=" + currentProcessState
	});
}

function confirmStatusChange (edit)
{
	if ($('PropertyStatusID').value==7)
	{
		if (confirm("WARNING: This property will permanently be removed from the system.\r\n\r\nAre you sure you want to delete this property?"))
		{
			StatusChange(edit);
			loadSearchForm(); // reload the form as we don't want to be able to edit the deleted listing
		}
	}	
	else StatusChange(edit);
}


function StatusChange(edit)
{	
	var FileName = "";
	var FileDistination = "";
	switch($('PropertyStatusID').value)
	{
		case '1' : //active
				 FileName = 'active';
				 FileDistination = "data/StatusChange.php";
				 break;
//		case '2' : //Pending
//				 FileName = 'Pending';
//				 FileDistination = "data/StatusChange.php";
//				 break;
		case '4' : //withdrawn
				 FileName = 'withdrawn';
				 FileDistination = "data/propform_withdrawn.php";
				 break;
		case '2' : //Offer
				 FileName = 'Offer';
				 FileDistination = "data/StatusChange.php";
				 break;
		case '3' : //Sold
				 FileName = 'Sold';
				 FileDistination = "data/propform_sold.php";
				 break;
		case '6' : //Transferred
				 FileName = 'Transferred';
				 FileDistination = "data/StatusChange.php";
				 break;
		case '7' : // Delete
				 FileName = 'Delete';
			 	 FileDistination = "data/StatusChange.php";
				 break;	 
	}

	new Ajax.Request(FileDistination,
	{
			onSuccess : function(response) 
			{
				$('StatusDiv').innerHTML = response.responseText;
			},
			onFailure : function(request) 
			{
				alert("error loading AgentsUpdateSection form ...");
			},
			onComplete : function(request) 
			{
				
			},
			parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID + "&status=" + FileName + "&edit=" + edit
	});	
}

function updatesold(formID) 
{
	var params = Form.serialize($(formID));
	$('errorMsg').innerHTML = '';
    new Ajax.Request("data/updateSold.php",
    {
		      onSuccess : function(response) 
		      {
		      	//var test = new MaJiG_BOX(response.responseText);
		      	var ErrorDivs = document.getElementsByClassName("errorDiv");
				$H(ErrorDivs).each(function(Div)
				{
					Div.value.innerHTML ="";
				});

		      	var dataset = $H();
				dataset = eval("(" + response.responseText + ")");
		      	if(dataset.errors)
				{
					formFieldsErrorDisplay(dataset.errors);
					$('errorMsg').innerHTML = dataset.msg;
				}
				else
				{
					$('errorMsg').innerHTML = dataset.msg;
				}
		      },
		      onFailure : function(request) 
		      {
			         alert("error loading form ...");
		      },
		      onComplete : function(request) 
		      {
		      	if(currentProcessState != 'add')
				{
					_propertyFeedsUpdate();
				}
		      },
		      parameters:params
	 });
}

function UpdateStatusChange()
{	
	$('savechangesStatus').disabled = true;
	new Ajax.Request("data/UpdateStatusChange.php",
	{
			onSuccess : function(response) 
			{
//				alert(response.responseText);
				StatusChange('');
			},
			onFailure : function(request) 
			{
				alert("error loading AgentsUpdateSection form ...");
			},
			onComplete : function(request) 
			{
				if(currentProcessState != 'add')
				{
					_propertyFeedsUpdate();
				}
			},
			parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID + "&group1=" + $('group1').value + "&group2=" + $('group2').value + "&group3=" + $('group3').value + "&group4=" + $('group4').value
	});	
}

function UpdateAgentOrLoad(type, currentPropertyID, currentTransactionID, UserID, agent)
{
	new Ajax.Request("data/updateAgents.php",
	{
			onSuccess : function(response) 
			{
				$('AgentDiv').innerHTML = response.responseText;
			},
			onFailure : function(request) {
				alert("error loading AgentsUpdateSection form ...");
			},
			onComplete : function(request) 
			{
				if(currentProcessState != 'add')
				{
					//_prop24Update();
					_propertyFeedsUpdate();
				}	
			},
		
			parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID + "&type=" + type + "&UserID=" + UserID + "&agent=" + agent + "&mode=" + currentProcessState + "&currentPaymentID=" + currentPaymentID
	});
}

function M_var_dump(obj)
{
	_console("<ul>");
	$H(obj).each(function(item)
	{
		switch(item.value == '[Object]' || item.value == "[object Object]")
		{
				case true:
					_console("<li><b>"+item.key+"</b></li>");
					M_var_dump(item.value)
				break;
				default:
					_console("<li><b>"+item.key+" : </b>"+item.value+"</li>");
				break;
		}		
	});
	_console("</ul>");
}

function formFieldsErrorDisplay(object)
{
	$H(object).each(function(item)
	{
		$(item.key + "_ErrorDiv").innerHTML = "<font color='red'>" + item.value + "</font>";	
		$(item.key + "_ErrorDiv").style.display = "block";
	});
}

function updateFormValues(commentdivID, formID, section)
{
	var postToPage = '';
	switch(section)
	{
		case 'seller' 	: postToPage = 'data/updateSellerBuyer.php';break;
		case 'listings' : postToPage = 'data/updateListing.php';break;
	}
	
	if(postToPage != '')
	{	
		$('savechangeslisting').disabled = true;
		var params = Form.serialize($(formID));
		
		new Ajax.Request(postToPage,
		{
				onSuccess : function(response) 
				{
//					alert(response.responseText);
					var ErrorDivs = document.getElementsByClassName("errorDiv");
					$H(ErrorDivs).each(function(Div)
					{
						Div.value.style.display = "none";
						Div.value.innerHTML ="";
					});
					var dataset = $H();
					dataset = eval("(" + response.responseText + ")");
					if(dataset.errors)
					{
						formFieldsErrorDisplay(dataset.errors);
					}
					else if(section == 'listings' && dataset.update)
					{
						currentPropertyID	 	=	dataset.update.PropertyID;
						currentTransactionID 	=	dataset.update.TransactionID;
						currentPropertyType  	= 	dataset.update.PropTypeID;
					    currentTitleDeed    	= 	dataset.update.TitleDeedID;
					    currentPaymentID     	= 	dataset.update.PaymentID;
					    currentWebRef           =   dataset.update.WebRef;
					    
					    if(currentPaymentID == 1)
						{
							$('divDetailsBuyer').style.fontWeight 	= '';
							eval("TabArray."+"buyer"+" = false;");
							$('SellerName').innerHTML = "Lessor";
						}
						else
						{
							if(currentProcessState != 'add')
							{
								$('divDetailsBuyer').style.fontWeight 	= 'bold';
							}
							$('SellerName').innerHTML = "Seller";
						}
					    
					    if(currentProcessState == 'add')
					    {
					    	_getInspectionTimes();
//					    	imagesUploaderForm('images', currentPropertyID, currentPropertyType, currentTransactionID);
//					    	loadAgent('agent', currentPropertyID, currentPropertyType, currentTransactionID);
					    	$('savedData').innerHTML = '';
					    	$('divDetailsContent').innerHTML = '';
					    }
					}
					else if(section == 'seller' && currentProcessState == 'add')
					{
						$('divDetailsBuyer').style.fontWeight = 'bold';
						$('divDetailsPrinting').style.fontWeight = 'bold';
						$('divDetailsDetails').style.fontWeight = 'bold';
						disableMenu(currentProcessState);
						loadSpecificFormHtmlDetails('details', currentPropertyID, currentTransactionID);
						$('savedData').innerHTML = '';
					}
					
					if(currentProcessState != 'add' && !dataset.errors)
					{
						SearchOptions.Properties[" " + currentPropertyID].MandatePrice  = dataset.NBFIELDS.MandatePrice;
						SearchOptions.Properties[" " + currentPropertyID].Address 	 	= dataset.NBFIELDS.Address;
						SearchOptions.Properties[" " + currentPropertyID].TitleDeedID  	= dataset.NBFIELDS.TitleDeedID;
						SearchOptions.Properties[" " + currentPropertyID].TypeName      = dataset.NBFIELDS.TypeName;
						SearchOptions.Properties[" " + currentPropertyID].PropTypeID    = dataset.NBFIELDS.PropTypeID;
						SearchOptions.Properties[" " + currentPropertyID].SuburbID	    = dataset.NBFIELDS.SuburbID;
						SearchOptions.Properties[" " + currentPropertyID].RegionID	    = dataset.NBFIELDS.RegionID;
						SearchOptions.Properties[" " + currentPropertyID].PaymentID	    = dataset.NBFIELDS.PaymentID;
						SearchOptions.Properties[" " + currentPropertyID].WebRef	 	= dataset.NBFIELDS.webref;
						if(SearchTimer!=0)
						{
							clearTimeout(SearchTimer);
						}
						if(currentSearchState == 'quicksearch')
						{
							SearchTimer = setTimeout('quickSave()', 1500);
						}
						else
						{
							SearchTimer = setTimeout('define_Results()', 1500);
						}
//						_prop24Update();
						_propertyFeedsUpdate();
					}
					else
					{
						currentWebRef = 0;
					}
					
					if(currentProcessState != 'add')
					{
						$(""+commentdivID+"").innerHTML = dataset.msg;
					}
					$('savechangeslisting').disabled = false;

				},
				onFailure : function(request) 
				{
					alert("error loading form ...");
				},
				onComplete : function(request) 
				{
					
				},
				parameters:params
		});
	}
}

function printingListing(currentPropertyID, currentTransactionID)
{
	new Ajax.Request("data/getPrinting.php",
	{
			onSuccess : function(response) 
			{
				if(currentProcessState == 'add')
			    {
					disableMenu(currentProcessState);
			    }
				$('divDetailsPrinting').style.backgroundColor  = '#8AA7E1';
				$('divDetailsContent').innerHTML = response.responseText;
			},
			onFailure : function(request) {
				alert("error loading printing form ...");
			},
			onComplete : function(request) 
			{
				$('Loading').style.display = 'none';
			},parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID
	});
}

function getPrint(currentPropertyID, currentTransactionID)
{
	window.open("data/propDetailPrint.php?PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID,"Printing", "height=700,width=650,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no");
}

function getPrintlisting(currentPropertyID, currentTransactionID)
{
	window.open("data/printlisting.php?PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID,"Printing", "height=620,width=960,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no");
//	alert("PropertyID :" + currentPropertyID + "TransactionID :" + currentTransactionID);
//	new Ajax.Request("data/printlisting.php",
//	{
//			onSuccess : function(response) 
//			{
//				$('divDetailsContent').innerHTML = response.responseText;
//			},
//			onFailure : function(request) {
//				alert("error loading printing form ...");
//			},
//			onComplete : function(request) 
//			{
//			
//			},parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID
//	});
}

function getPrintlistingA4(currentPropertyID, currentTransactionID)
{
	window.open("data/printlistingA4.php?PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID,"Printing", "height=900,width=600,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no");
}

function getProvinceSuburbs(ProvinceID)
{
	//alert(ProvinceID);
}

function setTabTrue(tableName)
{
	if(tableName == 'listing' && currentProcessState == 'add')
	{
		currentPaymentID 	= $('PaymentID').options[$('PaymentID').selectedIndex].value;
		currentTitleDeed 	= $('TitleDeedID').options[$('TitleDeedID').selectedIndex].value;
		currentPropertyType = $('PropTypeID').options[$('PropTypeID').selectedIndex].value;
	}
	eval("TabArray."+tableName+" = true;");
}

function manageSelectedSectionDetails(type, process, clickedOnDiv) 
{
    
	switch (process) 
    {
        case 'add'  : $('savedData').innerHTML = '';        			  
        			  switch (type) 
		              {
		                 case 'structure': if (TabArray.structure) { loadPropertyStructureForm('divDetailsContent');} break;
		                 case 'listing'  : if (TabArray.listing)   {loadSpecificFormHtmlListing('listings', currentPropertyID, currentPropertyType, currentTitleDeed, currentTransactionID, currentPaymentID);}	 
		                                   break;
		                 case 'Inspection': if (TabArray.inspection) {_getInspectionTimes();}	 
		                                   break;
		                 case 'features' : if (TabArray.features)  {loadSpecificFormHtmlFeatures('features', currentPropertyID, currentPropertyType, currentTransactionID);}	 
		                 				   break;
			             case 'images'   : if (TabArray.images)	{imagesUploaderForm('images', currentPropertyID, currentPropertyType, currentTransactionID);}break;
		                 case 'seller'   : if (TabArray.seller)	{loadManageClientSection('','Seller');}break;
		                 case 'buyer'    : if (TabArray.buyer) {loadManageClientSection('','Buyer');}break;
		                 case 'printing' : if (TabArray.printing) {printingListing(currentPropertyID, currentTransactionID);}break;
		                 case 'agent'    : if (TabArray.agent)	{ loadAgent('agent', currentPropertyID, currentPropertyType, currentTransactionID);}break;
		                 case 'status'   : if (TabArray.printing)	{ loadStatus();}break;
		                 case 'feeds'    : if (TabArray.printing)	{ _getFeeds();}break;
		                 default         : if (TabArray.printing)	{loadSpecificFormHtmlDetails('details', currentPropertyID, currentTransactionID);}break;
		             }
			         break;
        case 'edit' :
        			 $('Loading').style.display = 'block';
		             $('savedData').innerHTML = '';
		             disableMenu(currentProcessState);
		             switch (type) 
		             {
		                 case 'structure': if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || AssociateViewAll == 1 || rights == 'O'|| rights == 'Y'){loadPropertyStructureForm('divDetailsContent');}break;
		                 case 'listing'  : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || AssociateViewAll == 1 || rights == 'O'|| rights == 'Y'){loadSpecificFormHtmlListing('listings', currentPropertyID, currentPropertyType, currentTitleDeed, currentTransactionID, currentPaymentID);} break;
		                 case 'Inspection': if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || AssociateViewAll == 1 || rights == 'O'|| rights == 'Y'){_getInspectionTimes();} break;
		                 case 'features' : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || AssociateViewAll == 1 || rights == 'O'|| rights == 'Y'){loadSpecificFormHtmlFeatures('features', currentPropertyID, currentPropertyType, currentTransactionID);} break;
			             case 'images'   : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || rights == 'O'|| rights == 'Y'){imagesUploaderForm('images', currentPropertyID, currentPropertyType, currentTransactionID);}break;
		                 case 'seller'   : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || rights == 'O'|| rights == 'Y'){loadManageClientSection('','Seller');}else if(AssociateViewAll == 1){displayresultEmailsView('Seller');};break;
		                 case 'buyer'    : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || rights == 'O'|| rights == 'Y'){loadManageClientSection('','Buyer');}else if(AssociateViewAll == 1){displayresultEmailsView('Buyer');};break;
		                 case 'printing' : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || AssociateViewGroup == 1 || AssociateViewAll == 1 || rights == 'O'|| rights == 'Y'){printingListing(currentPropertyID, currentTransactionID);}break;
		                 case 'agent'    : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || rights == 'O'|| rights == 'Y'){loadAgent('agent', currentPropertyID, currentPropertyType, currentTransactionID);}break;
		                 case 'status'   : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || rights == 'O'|| rights == 'Y'){loadStatus();}break;
		                 case 'feeds'    : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || rights == 'O'|| rights == 'Y'){ _getFeeds();}break;
		                 case 'stats'    : if(rights == 'Y' && officeID == currentOfficeID || sessionassociates == currentAssociatesID && rights == 'E' || teamID == currentTeamID && teamYN == 'Y' && rights == 'E' || AssociateViewAll == 1 || rights == 'O'|| rights == 'Y'){getStats();}break;
		                 default         : loadSpecificFormHtmlDetails('details', currentPropertyID, currentTransactionID);break;
		             }
			         break;     
     }
}

function SellerDesChange(value)
{
	if(value == 1)
	{
		$('seller_extradetails').style.display = 'none';
	}
	else
	{
		$('seller_extradetails').style.display = 'block';
	}
}

function switchContent(value)
{
	//alert(value);
	var ConDisplay = 'none'
	var SecDisplay = 'none'
	var OtherDisplay = 'none'

	if (value == 'Remax')//Remax must display
	{
		ConDisplay = 'none'
		SecDisplay = 'block'
		OtherDisplay = 'none'
	}
	else if (value == 'Other')//Competitors must display
	{
		//alert("IN HERE" + value);
		ConDisplay = 'block'
		SecDisplay = 'none'
		OtherDisplay = 'none'
	}
    else if (value == 'OtherDesc')//Competitors must display
	{
		ConDisplay = 'none'
		SecDisplay = 'none'
		OtherDisplay = 'block'
	}
	
	$('Remax').style.display = SecDisplay
	$('Other').style.display = ConDisplay
	$('OtherDescText').style.display = OtherDisplay
}

function UpdateCheckStatus()
{
	//this is for complete and showonweb	
	new Ajax.Request("data/Update_CheckStatus.php",
	{
			onSuccess : function(response) 
			{
				
			},
			onFailure : function(request) 
			{
				alert("error loading AgentsUpdateSection form ...");
			},
			onComplete : function(request) 
			{
				if(currentProcessState != 'add')
				{
					_propertyFeedsUpdate();
				}
			},
			parameters : "PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID
	});	
}

function _saveTours(visualtours, floorplans)
{
//	alert(visualtours + " " + floorplans);
	visualtours = encodeURIComponent(visualtours);
	floorplans	   = encodeURIComponent(floorplans);
	new Ajax.Request("data/updateTours.php",
	{
			onSuccess : function(response) 
			{
				$('tours').innerHTML = response.responseText;
			},
			onFailure : function(request) 
			{
				alert("error saving Tours form ...");
			},
			onComplete : function(request) 
			{
				if(currentProcessState != 'add')
				{
					_propertyFeedsUpdate();
				}
			},
			parameters : "visual=" + visualtours + "&floor=" + floorplans + "&PropertyID=" + currentPropertyID + "&TransactionID=" + currentTransactionID
	});	
}

function _propertyFeedsUpdate()
{
	//currentTransactionID
	new Ajax.Request("data/updateFeedsGlobal.php",
	{
			onSuccess : function(response) 
			{
				//alert(response.responseText);
			},
			onFailure : function(request) 
			{
				alert("Error saving feeds ...");
			},
			onComplete : function(request) 
			{
				
			},
			parameters : "TransactionID=" + currentTransactionID + "&PropertyID=" + currentPropertyID
	});	
}
