		$j = jQuery.noConflict();
		
		Array.prototype.exists = function(o) {
			for(var i = 0; i < this.length; i++)
			   if(this[i] === o)
			     return true;
			return false;
		}
		
		var detailsPage = {
			userObject:null,
			pageTitle : "Property Detail Page v.1",
			pageVersion : "1.0",
			propertyID : 0,
			partnerID : 0,
			partnerName : "",
			partnerCommisssion : 0,
			partnerLinkType : "",
			propertyCountry: "",
			EnquiryID : 0,
			modalPopUpControlID : "btnMakeEnquiry",
			modalPopUpContent: "",
			applicationPath : "http://www.themovechannel.com/",
			isNewClient:true,
			enquiryFormInit:function(){
				$j('#facebox a#btnSubmitEnquiry').removeClass('hide');
				$j('#facebox input#btnSubmitEnquiry').hide();
				
				
				$j('#facebox .userDetails').show();
				$j('#facebox #commentsRow').show();
				$j('#facebox #finalSubmitRow').hide();
				
				// -- set all fields as read-only;
				$j('#facebox #embedEnquiryForm > input[type="text"]').attr('readOnly',true);
				$j("#facebox #embedEnquiryForm > input[type='text']").addClass('readonly');
				
				$j('#facebox #btnCancelEnquiry').click(function(){
					$j.facebox.close();
				});
				
				$j('#facebox #btnConfrimDetails').click(function(){
					$j('#facebox .userDetails').show();
					$j('#facebox #commentsRow').hide();
					$j('#facebox #finalSubmitRow').show();
				});
				
				$j('#facebox #btnShowDetails').click(function(){
					$j('#facebox .userDetails').hide();
					$j('#facebox #commentsRow').show();
					$j('#facebox #finalSubmitRow').hide();
				});
				
				$j('#facebox #btnSubmitEnquiry').click(function(){
					// -- now validate email address and everthing, if they are all fine, submit the form now
					//alert('submit the form now');
					
						
							
							if ($j('#facebox #efChkBarclays')[0]!=undefined)
							{
								if ($j('#facebox #efChkBarclays').is(":checked"))
									detailsPage.submitEnquiryFormBarclays();
							}
						
					if($j('#facebox textarea[name="comments"]').attr('value')>""){	
						//$j('#facebox #embedEnquiryForm').submit();
						// get the form
						$j('#facebox #embedEnquiryForm').attr('target','');
						
						var f = $j('#facebox #embedEnquiryForm');
						var action = f.attr('action');
						var serializedForm = f.serialize();
						var errMessage = '';
						
						$j.post(
							action,
							serializedForm,
							function(data){
								//alert(data.returnValue);
								if (data.returnValue){
									detailsPage.EnquiryID=data.enquiryID;
									var msg = $j('#enquirySent').html();
									//msg += '<iframe id="googleConversion" src =detailsPage.applicationPath + "getScript/?d=&Enquiry_Successfully_Submitted=true" width="0" height="1" border="0" style="position:absolute;top:0;right:0;"></iframe>';
									detailsPage.onSuccessfulSubmission();
									detailsPage.ShowPopUpContent(msg);
									setTimeout(function(){$j.facebox.close();},3500);
								}else{
									detailsPage.ShowPopUpContent($j('#enquirySent').html());
									$j('#facebox .content .text').text('There was an error while submitting your enquiry, Please contact support for help.');
									if(data.error_description!=''){
										$j('#facebox .content .text').after('<p class="TextRed">Error Details: ' + data.error_description +'</p>');
									}
								}										
							},
							"json"
						);
					}
					
					return false;
				});
			},
			loadRenquiryForm:function(){
				$j.ajax({
					url:document.location.href,
					type:"POST",
					async:false,
					data:{"EnquiryFormOnly":"yes","client_email":'"'+$j('#contact_email').val()+'"'},
					complete:function(data){
						var email = $j('#contact_email').val();
						detailsPage.ShowPopUpContent(data.responseText);
						$j('#facebox #enquiryFormWrapper').show();
						$j('#facebox > input[name="contact_email"]').attr('value',email);
						detailsPage.enquiryFormInit();
						$j.facebox.reveal();
					}
				});
			},
			loadMortgageForm:function(){
				var res;
				$j.ajax({
					url:detailsPage.applicationPath + "en/pages/tmc.com.PropertyDetails.MortgageForm.html",
					type:"GET",
					async:false,
					data:{},
					complete:function(data){
						res=data.responseText;
					}
				});
				return res;
			},
			submitEnquiryFormBarclays:function(){
				var f = $j('#facebox #embedEnquiryForm');
				var action = detailsPage.applicationPath + "money/barclays/barclays_enquiry.asp" ; //document.location.href; //f.attr('action');
				var serializedForm = f.serialize();
				$j.post(
					action,
					serializedForm,
					function(data){
						
						
					},
					"json"
				);
			},
			submitRegisterFormNewsletters:function(){
				var f = $j('#facebox #frmRegister');
				var action = detailsPage.applicationPath + "my/subscriptions/" ; //document.location.href; //f.attr('action');
				var serializedForm = f.serialize();
				$j.post(
					action,
					serializedForm,
					function(data){
						//alert(data.returnValue);
						$j('#facebox #registerFormMessagePanel .msg').html('Newsletters subscribed<br/>Submitting enquiry....please wait');
					},
					"json"
				);
			},
			submitRegisterFormBarclays:function(){
				var f = $j('#facebox #frmRegister');
				var action = detailsPage.applicationPath + "money/barclays/barclays_enquiry.asp" ; //document.location.href; //f.attr('action');
				var serializedForm = f.serialize();
				$j.post(
					action,
					serializedForm,
					function(data){
						
						
					},
					"json"
				);
			},
			onSuccessfulSubmission:function(){
				try{
					if (detailsPage.isNewClient)
						pageTracker._setVar("New User");
					else
						pageTracker._setVar("Existing User");
					pageTracker._trackPageview(detailsPage.applicationPath + 'Property/Details/SendEnquiry');
					if ($j('#facebox #popUpNewsletters .list p input[@type=checkbox]:checked').size()>0)
					{
						pageTracker._trackPageview(detailsPage.applicationPath + 'Property/Details/NewsSubscription');
					}
					/* 
					// set Transaction variables
					 pageTracker._addTrans(
				      "Leads", // order ID - required
				      detailsPage.PropertyCountry, // Subdomain name
				      detailsPage.partnerCommission, // PPL Price or RR Price - required - if zero leave blank
				      "", // tax - leave blank
				      "", // shipping - leave blank
				      "", // city - leave blank
				      "", // state or province - leave blank
				      "USA" // IP Nationality  
					  );
					  
					  pageTracker._addItem(
					      "Leads", // order ID - necessary to associate item with transaction
					      detailsPage.propertyID, // SKU becomes Property ID - required - if zero leave blank
					      "152,000 EUR 2 Bed Apartments ", // Property price Beds apartments
					      "Andalusia", // Location 1
					      "10", // PPL Price or RR Pricuired
					   );
					*/
					
				}catch(err){
					alert(err);
				}
			},
			submitRegisterForm:function(){
				
				$j('#facebox #registerFormMessagePanel .msg').html('Submitting enquiry... please wait');
				
				var f = $j('#facebox #frmRegister');
				var action = detailsPage.applicationPath + "property_enquiry/" ; //document.location.href; //f.attr('action');
				var serializedForm = f.serialize();
				$j.post(
					action,
					serializedForm,
					function(data){
						//alert(data.returnValue);
						if (data.returnValue){
							detailsPage.EnquiryID=data.enquiryID;
							var msg = $j('#enquirySent').html();
							// if mortgage clicked then show mortgage details after Thank You
							var showMortgageForm=false;
							if ($j('#chkMortgage')[0]!=undefined)
							{
								if ($j('#chkMortgage')[0].checked)
								{
									msg=msg + detailsPage.loadMortgageForm();
									showMortgageForm=true;
									detailsPage.userObject.user.title=$j('#contact_title').val();
									detailsPage.userObject.user.firstname=$j('#contact_name').val();
									detailsPage.userObject.user.lastname=$j('#contact_surname').val();
									detailsPage.userObject.user.email=$j('#contact_email').val();
									detailsPage.userObject.user.homephone=$j('#best_phone').val();
						
								}
							}
							detailsPage.onSuccessfulSubmission();
							detailsPage.ShowPopUpContent(msg);
							if (!showMortgageForm)
							{
								setTimeout(function(){$j.facebox.close();},3500);
							}
							else
							{
								$j("#m_title").val(detailsPage.userObject.user.title);
								$j("#m_firstname").val(detailsPage.userObject.user.firstname);
								$j("#m_surname").val(detailsPage.userObject.user.lastname);
								$j("#m_email").val(detailsPage.userObject.user.email);
								$j("#m_adr1").val(detailsPage.userObject.user.address1);
								$j("#m_town").val(detailsPage.userObject.user.address4);
								$j("#m_postcode").val(detailsPage.userObject.user.postcode);
								$j("#m_homephone").val(detailsPage.userObject.user.homephone);
								
							}
						}else{
							detailsPage.ShowPopUpContent($j('#enquirySent').html());
							$j('#facebox .content .text').text('There was an error while submitting your enquiry, Please contact support for help.');
						}										
					},
					"json"
				);
			},
			isAlreadyRegister:function(email){
				return $j.ajax({
						url:detailsPage.applicationPath + 'en/services/Ajax.Users.asp?isUserExist=' + $j('#contact_email').val(),
						method:'GET',
						async:false,
						beforesend:function(){
							$j.facebox.loading();
						},
						complete:function(data){
							var result = $j.evalJSON(data.responseText);
							//alert(result.returnValue);
							return result.returnValue;
						}
					});
			},
			registerFormAutoFill:function(){
				$j.ajax({
					url:detailsPage.applicationPath + 'en/services/Ajax.Users.asp?GetUserObject='+$j('#contact_email').val(),
					method:'GET',
					async:true,
					complete:function(data){
						userObject = $j.evalJSON(data.responseText);
						detailsPage.userObject= $j.evalJSON(data.responseText);
						$j('#contact_title').attr('value',userObject.user.title);
						$j('#contact_name').attr('value',userObject.user.firstname);
						$j('#contact_surname').attr('value',userObject.user.lastname);
						
						if(userObject.user.country=='UK'){
							$j('#contact_country').attr('value','England');
						}else{
							if (userObject.user.country!=null){
								$j('#contact_country').attr('value',userObject.user.country);
							}
						}
						switch (userObject.user.country.toLowerCase())
						{
							case "england":
							case "scotland":
							case "wales":
							case "northern ireland":
								$j("#otherServices")[0].style.display="";
								ctry=$j("#enquiry_PropertyCountry").val().toLowerCase();
								if (ctry=="england" || ctry=="scotland" || ctry=="wales")
								{
								$j("#mortgage").show();
								}
								break;
							default:
								$j("#otherServices")[0].style.display="none";
								break;
						}
						if(userObject.user.daytimephone!=""&&userObject.user.daytimephone!=null)
							$j('#best_phone').attr('value',userObject.user.daytimephone);
						else if(userObject.user.homephone!=""&&userObject.user.homephone!=null)
							$j('#best_phone').attr('value',userObject.user.homephone);
						else if(userObject.user.mobilephone!=""&&userObject.user.mobilephone!=null)
							$j('#best_phone').attr('value',userObject.user.mobilephone);
						detailsPage.registerFormGetNewsletters();
						
						//detailsPage.registerFormGetBarclays();
						// now update onChangeCountry
						try{
							onChangeCountry($j('#contact_country')[0]);
						}catch(err){
							// err handler here
						}
					}
				});
			},
			registerFormValidateAndFillup:function(){
				// -- do the check now
				if(!detailsPage.isNewClient){
					$j.ajax({
						url:detailsPage.applicationPath + "en/services/Ajax.Users.asp",
						data:{"pwd":$j('#facebox #contact_pwd').val(),"ValidateUserLogin":$j('#facebox #contact_email').val()},
						method:"POST",
						complete:function(data){
							var result = $j.evalJSON(data.responseText);
							if(result.returnValue){
								//-- now load the form with user details
								detailsPage.registerFormAutoFill();
								$j('#facebox #registerFormMessagePanel .msg').html('');
							}else{
								//-- now tell the user that password is wrong
								alert('Password does not match!\nPlease enter correct password or click \'Mail me my password\'');
							}
						}
					});
				}
			},
			registerFormValidate:function(){
				// -- do the check now
				if(!detailsPage.isNewClient){
					$j.ajax({
						url:detailsPage.applicationPath + "en/services/Ajax.Users.asp",
						data:{"pwd":$j('#facebox #contact_pwd').val(),"ValidateUserLogin":$j('#facebox #contact_email').val()},
						method:"POST",
						complete:function(data){
							var result = $j.evalJSON(data.responseText);
							if(result.returnValue){
								//-- now load the form with user details
								//detailsPage.registerFormAutoFill();
							}else{
								//-- now tell the user that password is wrong
								alert('Password does not match!\nPlease enter correct password or click \'Mail me my password\'');
							}
						}
					});
				}
			},
			registerFormGetNewsletters:function(){
				$j('#facebox #popUpNewsletters').show();
				//-- now grab newsletters from ajaxed call
				$j.post(
					detailsPage.applicationPath + "my/subscriptions",
					{"GetPossibleNewsletterByPropertyID":detailsPage.propertyID,"client_email":$j('#facebox #contact_email').val()},
					function(data){
						var template = '<p><input type="checkbox" id="newsletter_@newsletter_id@" data="@newsletter_id@" name="newsletter_@newsletter_id@" class="JajoMore7 newsSubscribeChk" value="yes" checked="checked"/>@newsletter_name@</p>';
						var dummy;
						var dummyList = "";
						var nID;
						var nName;
						//alert(data.newsletters);
						$j('#facebox #popUpNewsletters .list p').remove();
						$j(data.newsletters).each(function(index){
							if(data.newsletters[index]!=undefined){
								if(data.newsletters[index].id!=undefined){
									nID = data.newsletters[index].id;
									nName = data.newsletters[index].description;
									if($j('#facebox #newsletter_'+nID)!=undefined){
										$j('#facebox #newsletter_'+nID).fadeOut("slow",function(){
											$j('#facebox #newsletter_'+nID).parent().remove();
										});
									}
									dummy = template.replace("@newsletter_id@",nID);
									dummy = dummy.replace("@newsletter_id@",nID);
									dummy = dummy.replace("@newsletter_id@",nID);
									dummy = dummy.replace("@newsletter_name@",nName);
									dummyList += dummy;
								}
							}
						});
						$j('#facebox #popUpNewsletters .list').append(dummyList);
						//alert($j('#facebox #popUpNewsletters .list p').size());
						if($j('#facebox #popUpNewsletters .list p').size()==0){
							$j('#facebox #popUpNewsletters').hide();
						}
					},
					"json"
				);
			},
			registerFormGetBarclays:function(){
				$j.post(
					detailsPage.applicationPath + "money/barclays/barclays_enquiry.asp",
					{"checkBarclays":"Yes","client_email":$j('#facebox #contact_email').val()},
					function(data){
						if (data.returnValue)
						{
							$j("#barclays")[0].style.display="none";
							$j("#otherServices")[0].style.display="none";
							
						}
					},
					"json"
				);
			},
			registerFormInit:function(){
				
				// -- grab newsletters if there is any
				$j('p > input.newsSubscribeChk').each(function(index){
					//alert($j(this).parent().html());
					$j('#facebox #popUpNewsletters .list').append('<p>'+$j(this).parent().html()+'</p>');
				});
				
				$j('#facebox #enquiry_PartnerID').val(detailsPage.partnerID);
				$j('#facebox #enquiry_PropertyID').val(detailsPage.propertyID);
				$j('#facebox #enquiry_PropertyCountry').val(detailsPage.propertyCountry);
				
				$j('#facebox #btnCancelEnquiry').click(function(){
					$j.facebox.close();
					return false;
				});
				
				$j('#facebox #btnResendPassword').click(function(){
					//alert('here');
					$j.post(
						detailsPage.applicationPath + "services/register/",
						{"action":"forgot","ajaxed":"yes","email":$j('#facebox #contact_email').val()},
						function(data){
							if(data.returnValue){
								//-- successful, then says that an email is already sent.
								$j('#facebox #registerFormMessagePanel .msg').html('We have sent you an email containing your password details.');
							}else{
								//-- failed, then says there was an error
								$j('#facebox #registerFormMessagePanel .msg').html('There was an error whilst we trying to sent your details, plesae contact us.');
							}
							//alert(data);
						},
						"json"
					);
					return false;
				});
				
				$j('#contact_email').unbind('change');
				
				$j('#facebox #btnSubmitEnquiry').click(function(){
					// -- do the form validation first
					var validFields = validateTMCForm(document.frmRegister);
					if(!validFields)return false;
					// -- do the authentication here and load logged-in enquiry form after successful authentication.
					//alert('here');
					if($j('#facebox #contact_pwd').val() == ""){
						alert('Please type in your password.');
					}else{
						// -- do the check now
						$j.ajax({
							url:detailsPage.applicationPath + "en/services/Ajax.Users.asp",
							data:{"pwd":$j('#facebox #contact_pwd').val(),"ValidateUserLogin":$j('#facebox #contact_email').val()},
							method:"POST",
							complete:function(data){
								var result = $j.evalJSON(data.responseText);
								if(result.returnValue){
									//user.isLoggedIn = true;
									//user.name = data.name;
									// -- now load enquiry form 
									//detailsPage.loadRenquiryForm();
									//alert(result.client_id);
									$j('#facebox #enquiry_ClientID').attr('value',result.client_id);
									// -- and add the comment and submit the form
									// now submit the form]
									// now subscribe newsletters
									detailsPage.submitRegisterFormNewsletters();
									
												
													
													if ($j('#chkBarclays')[0]!=undefined)
													{
														if ($j('#chkBarclays')[0].checked)
															detailsPage.submitRegisterFormBarclays();
													}
												
									detailsPage.submitRegisterForm();
								}else{
									//-- user got wrong password or havent register yet.
									//-- check if email is already registered?
									var isUserExist = detailsPage.isAlreadyRegister($j('#facebox #contact_email').val());
									var exist = $j.evalJSON(isUserExist.responseText).returnValue;
									//alert(exist);
									if (exist){
										// -- let user know that the password is wrong.!!!!
										alert('User name and password does not match. Click \'Email me my password\' link to retrieve your password.');
									}else{
										// -- now register user
										var f = $j('#facebox #frmRegister');
										var action = detailsPage.applicationPath + 'services/register/'; //f.attr('action');
										var serializedForm = f.serialize();
										$j.post(
											action,
											serializedForm,
											function(data){
												//alert(data.returnValue);
												if (data.returnValue!=0){
													$j('#facebox #registerFormMessagePanel .msg').html('User Account created.');
												}else{
													$j('#facebox #registerFormMessagePanel .msg').html('Error creating user account, please contact us.');
												}										
												$j('#facebox #enquiry_ClientID').attr('value',data.returnValue);
												// -- and add the comment and submit the form
												// now submit the form]
												// now subscribe newsletters
												detailsPage.submitRegisterFormNewsletters();
												
																									
													if ($j('#chkBarclays')[0]!=undefined)
													{
														if ($j('#chkBarclays')[0].checked)
															detailsPage.submitRegisterFormBarclays();
													}
												
												detailsPage.submitRegisterForm();
											},
											"json"
										);
									}	
								}
							}
						});
					}
					return false;
				});
				
				$j('#contact_pwd').change(function(){
					//alert('here');
					detailsPage.registerFormValidateAndFillup();
				});
				
				$j('#contact_name').change(function(){
					//alert('here');
					detailsPage.registerFormValidate();
				});
				
				$j('#contact_surname').change(function(){
					//alert('here');
					detailsPage.registerFormValidate();
				});
				
				$j('#contact_country').change(function(){
					switch ($j('#contact_country')[0].options[$j('#contact_country')[0].selectedIndex].value.toLowerCase())
						{
							case "england":
							case "scotland":
							case "wales":
							case "northern ireland":
								if ($j("#barclays")[0].style.display=="")
									$j("#otherServices")[0].style.display="";
								break;
							default:
								$j("#otherServices")[0].style.display="none";
								break;
						}
				});
				
				$j('#chkBarclays').change(function(){
					if ($j('#chkBarclays')[0].checked)
						$j('#otherServicesExtra')[0].style.display="";
					else
						$j('#otherServicesExtra')[0].style.display="none";
				});
				
				$j('#contact_email').change(function(){
					
						$j("#otherServices")[0].style.display="";
						
					
					$j.ajax({
						url:detailsPage.applicationPath + 'en/services/Ajax.Users.asp?isUserExist=' + $j('#contact_email').val(),
						method:'GET',
						async:false,
						beforesend:function(){
							$j.facebox.loading();
						},
						complete:function(data){
							var result = $j.evalJSON(data.responseText);
							if(result.returnValue){
								//-- now show one password field and ask user to log in
								detailsPage.isNewClient = false;
								$j('#facebox #registerFormMessagePanel .msg').html('If you do not remember your password, click "Email me my password" to re-send the password.');
								$j('#facebox .resendPasswordRow').show();
								$j('#facebox .passwordConfirmRow').hide();
								$j('#facebox #contact_pwd2').removeClass('rfv');
								$j('#facebox #contact_pwd2').removeClass('rfv');
								$j('#facebox .passwordRow').show();
								//$j('#facebox #btnEnquiryFormLogin').show();
								
								
								//-- now replace the register form with enquiry form
								/*$j.ajax({
									url:document.location.href,
									type:"POST",
									async:false,
									data:{"EnquiryFormOnly":"yes","client_email":'"'+$j('#contact_email').val()+'"'},
									complete:function(data){
										var email = $j('#contact_email').val();
										detailsPage.ShowPopUpContent(data.responseText);
										$j('#facebox #enquiryFormWrapper').show();
										$j('#facebox > input[name="contact_email"]').attr('value',email);
										detailsPage.enquiryFormInit();
										$j.facebox.reveal();
									}
								});*/
								
								/*
								//-- now hide password fields and filled the text boxes with user's details
								$j('p[class=passwordRow]').hide();
								$j('p.resendPasswordRow').show();
								// -- now get user object and fill up the text boxes
								$j.ajax({
									url:detailsPage.applicationPath + 'en/services/Ajax.Users.asp?GetUserObject='+$j('#contact_email').val(),
									method:'GET',
									async:true,
									complete:function(data){
										var userObject = $j.evalJSON(data.responseText);
										$j('#contact_title').attr('value',userObject.user.title);
										$j('#contact_name').attr('value',userObject.user.firstname);
										$j('#contact_surname').attr('value',userObject.user.lastname);
										if(userObject.user.country=='UK'){
											$j('#contact_country').attr('value','England');
										}else{
											$j('#contact_country').attr('value',userObject.user.country);
										}
										if(userObject.user.daytimephone!="")
											$j('#best_phone').attr('value',userObject.user.daytimephone);
										else if(userObject.user.homephone!="")
											$j('#best_phone').attr('value',userObject.user.homephone);
										else if(userObject.user.mobilephone!="")
											$j('#best_phone').attr('value',userObject.user.mobilephone);
										
										// now update onChangeCountry
										onChangeCountry($j('#contact_country')[0]);
									}
								});*/
							}else{
								//-- if user is not exist then, dont do anything
								//-- the rest of the form
								detailsPage.isNewClient = true;
								$j('#facebox #registerFormMessagePanel .msg').html('Please confirm you password.');
								$j('#facebox .resendPasswordRow').hide();
								$j('#facebox .passwordConfirmRow').show();
								$j('#facebox #contact_pwd2').addClass('rfv');
								$j('#facebox #contact_pwd2').addClass('rfv');
							}
						}
					});
					
					return true;
				});
				
				switch (detailsPage.propertyCountry.toLowerCase())
				{
					case "france":
					case "spain":
					case "italy":
					case "portugal":
					case "south africa":
					case "uae":
					case "dubai":
						$j('#barclays')[0].style.display="";
						break;
				}
			},
			BindControls:function(){
				$j(detailsPage.modalPopUpControlID).click(function(){
					//alert('clicked');
					//-- check if user is logged in 
					if (!user.isLoggedIn){
						//detailsPage.modalPopUpContent = $j('#NoLoggedInEnquiryForm').html();
						$j('#facebox #registerFormMessagePanel .msg').html('Please type in your email address first.');
						var formContent = '';
						//alert($j('#formPlaceHolder').html().length);
						//if($j('#formPlaceHolder').html().length < 2){
							$j.ajax({
								type:"GET",
								async:true,
								processData:false,
								url:detailsPage.applicationPath + 'en/pages/tmc.com.PropertyDetails.RegisterForm.html',
								data:"",
								complete:function(data){
									//alert(data.responseText);
									//formContent = data.responseText;
									//$j('#formPlaceHolder').html(formContent);
									//detailsPage.ShowPopUpContent($j('#formPlaceHolder').html());
									detailsPage.ShowPopUpContent(data.responseText);
									detailsPage.registerFormInit();
								}
							});
						//}else{
						//	detailsPage.ShowPopUpContent($j('#formPlaceHolder').html());
						//}
					}else{
						// --- auto-filled enquiry form -- 
						/*$j.ajax({
							url:document.location.href,
							type:"POST",
							async:true,
							data:{"EnquiryFormOnly":"yes"},
							complete:function(data){
								detailsPage.ShowPopUpContent(data.responseText);
							}
						});*/
						
						//-- get static enquiry form
						/*$j.ajax({
							type:"GET",
							async:true,
							processData:false,
							url:detailsPage.applicationPath + 'en/pages/tmc.com.PropertyDetails.EnquiryForm.html',
							data:"",
							complete:function(data){
								//alert(data.responseText);
								detailsPage.ShowPopUpContent(data.responseText);
								//detailsPage.registerFormInit();
							}
						});*/
						
						var EnquiryForm = $j('#enquiryFormWrapper').clone();
						$j(EnquiryForm).show();
						detailsPage.ShowPopUpContent(EnquiryForm);
						//$j('#facebox .userDetails').hide();
						detailsPage.enquiryFormInit();
					}
					return false;
				});
			},
			ShowPopUpContent:function(content){
				$j.facebox(content);
			},
			ShowPopUp:function(){
				//alert(detailsPage.modalPopUpContent);
				$j.facebox(detailsPage.modalPopUpContent);
			}
		}

		
		function mortgageEnquiryClick()
				{
					pageTracker._trackPageview('/Mortgage/Enquiry_Submit');
					if (validateTMCForm(document.frmMortgage))
					{
						sendMWUForm(document.frmMortgage);
					}
				}
		function sendMWUForm(f)
	{
		var sURL="http://peter.estateangels.co.uk/tools/tpmortgage.php";
		var sData="postcode=" + $j("#m_postcode").val() + "&callrequestid=40&mortgageremortgage=" + $j("#m_mortgageremortgage").val();
		var sendData={url:sURL,data:sData};
		$j.get("/tmc.system/tmc.ajax.crossdomain2.asp",sendData,function(d){
				if (d.indexOf("Error")>0)
					alert(d);
				else
				{
					var sData="";
					sData=sData + "leadid=" + d.substr(0,d.indexOf("|"));
					sData=sData + "&callrequestid=40";
					// lead adviser received
					$j(".mwu").each(function()
						{
							sData=sData + "&" + this.id.replace("m_","") + "=" + $j(this).val();
						});
					//sData=sData + "&comments=test please ignore";
				
					var sendData2={url:sURL,data:sData};
					$j.get("/tmc.system/tmc.ajax.crossdomain2.asp",sendData2,function(d2){
						if (d2=="OK")
						{
							$j.facebox.close()
						}
						else
							alert(d2);
					});
				}
			});
	}

