
	var item_window;
	
	function display_modal(page, title, width, height) {
	
		if( document.getElementById('content') ) {  document.getElementById('content').style.display = 'none'; 	}
		
		if( document.getElementById('flashanim') ) { document.getElementById('flashanim').style.display = 'none'; }
		
		if( document.getElementById('flashcontent') ) { document.getElementById('flashcontent').style.display = 'none'; }
		
	
		item_window = dhtmlmodal.open('me_add_item_win', 'inline', '', title, 'width=' + width + 'px,height=' + height + 'px');
		
		// If the user selects one modal link, closes, then selects another one, it wont resize properly unless the following line is used
		item_window.setSize(width, height);
		
		item_window.moveTo('middle', 'middle');
		item_window.isResize(false);
		item_window.isScrolling(false);

		change_color('white');
			
		new Ajax.Request(page, {method: 'post', postBody: '', onSuccess: function (t) { item_window.load('inline', t.responseText); } });
	}
	
	function post_data() {
	
		if( document.getElementById('agree').checked == true ) {
		
			strData = "?";
			
			strData += "first_name=" + document.getElementById('first_name').value;
			strData += "&last_name=" + document.getElementById('last_name').value;
			strData += "&email=" + document.getElementById('email').value;
			strData += "&phone=" + document.getElementById('phone_number').value;
			
			
			
			new Ajax.Request('/join_conversation.php' + strData, 
				{
					method: 'post', 
					postBody: '', 
					
					onSuccess: function (t) { 
									if ( t.responseText == "1" ) {
										alert("Thank you for joining..");
										dhtmlmodal.close(item_window);
										
										if( document.getElementById('content') ) { document.getElementById('content').style.display = 'block'; }
										
										if( document.getElementById('flashanim') ) { document.getElementById('flashanim').style.display = 'block'; }
										
										if( document.getElementById('flashcontent') ) { document.getElementById('flashcontent').style.display = 'block'; }
									}else { 
										alert("All fields must be completed.");
									}
								} 
				}
			);
			
		} else {
			 
			 alert( "You must agree to the Terms and Conditions before you can join" );
		}
		
	}
	
	function change_color(color) {
		element = document.getElementById('drag-contentarea');
		element.style.background = color; 
	}
