// JavaScript Document
	function ajax_onFailure( ro )
	{
		alert('Error: Could not connect to database');
		updateing=false;
	}
	
	function set_formwindow(a){
		//RecalcMagicWindow();
		/*
		$('formwindow').style.height = a + 'px';
		var topVal = -(a/2);
		// alert(topVal);
		$('overlay_pane').style.marginTop = topVal + 'px';
		*/
	}
	
	function showForm(originalRequest){
		// alert(originalRequest.responseText);
		// OpenMagicWindow(originalRequest.responseText);
		OpenMagicWindow(originalRequest.responseText,undefined,true);
	}
	
	function showThankyou(originalRequest){
		// alert(originalRequest.responseText);
		// OpenMagicWindow(originalRequest.responseText);
		RecalcMagicWindow();//set_formwindow(200);	
		$('formwindow').innerHTML = originalRequest.responseText;
	}
	
	function get_form(a,b,c){
		var pdata = "FormType="+a+"&MLS="+b+"&UserID="+c;
		// alert(pdata);
		var myAjax = new Ajax.Request( 'ajax/contactus.php',
		{ method: 'post', parameters: pdata, onFailure: ajax_onFailure, onSuccess: showForm } );
	}
	
	function get_sendform(a,b,c){
		var pdata = "FormType="+a+"&MLS="+b+"&AgentID="+c;
		// alert(pdata);
		var myAjax = new Ajax.Request( 'ajax/sendtofriend.php',
		{ method: 'post', parameters: pdata, onFailure: ajax_onFailure, onSuccess: showForm } );
	}	
	
	function submit_form(a){
		if(a){
			if ( !IsMagicWindowOpen() )
			{
				OpenMagicWindow('<div id="formwindow"><table width="500" cellspacing="0" cellpadding="0"><tr><td style="background-color: #FFFFFF;border: 1px solid #cccccc"><div id="SendingBox"><table cellspacing="10" class="fill" align="center"><tr><td><img src="images/aj_load.gif"/></td><td>Please wait a moment while we process your submission.</td></tr></table></div></td></tr></table></div>', submit_form.curry( a ) ,true);
				return;
			}
			var pdata = a;
		} else {
			var pdata = $('contactus').serialize();
		}
		
		try
		{
			var h = $('contactus').getHeight();
			$( 'contactus' ).hide();
			$( 'SendingBox' ).style.height = h+'px';
			$( 'SendingBox' ).style.display = 'block';
			try {
				$( 'SendingBox' ).down('.fill').style.height = h+'px';
			} catch( err ) { }
		}
		catch( err ) {}
		
		var myAjax = new Ajax.Request( 'ajax/contactus.php',
		{ method: 'post', parameters: pdata, evalScripts: true, onSuccess: function( ro ) {
			RecalcMagicWindow();
			$('formwindow').innerHTML = ro.responseText;
			( '' + ro.responseText ).evalScripts();
		}, onFailure: ajax_onFailure  } );
	}
	
	function submit_friend_form(){
		var pdata = $('sendtofriend').serialize();
		// alert(pdata);
		var myAjax = new Ajax.Updater( 'formwindow','ajax/sendtofriend.php',
		{ method: 'post', parameters: pdata, evalScripts: true, onFailure: ajax_onFailure  } );
	}

