var Dlgs = {
	
	Tip : {
		SendFile : '/library/tip_send.php',
		BlogType : 'Regular',
		
		InitRegular : function() {
			Dlgs.Tip.BlogType = 'Regular';
			Dlgs.Tip.Display();
		},		
		
		InitTwitter : function() {
			Dlgs.Tip.BlogType = 'Twitter';
			Dlgs.Tip.Display();			
		},
		
		Display : function() {
			// Build the code for the Tip-Dialog and display it
			var TipDlgHTML = '<div id="dlg_tip" class="dlg">';
					TipDlgHTML+= '	<div class="box">';
									
					// Check which type of blog we're dealing with
					if( Dlgs.Tip.BlogType == 'Twitter' ) {
						TipDlgHTML+= '		<h2>Tipsa om Twitteradress</h2>';
						TipDlgHTML+= '		<fieldset class="box_content">';				
						TipDlgHTML+= '			<label>http://twitter.com/</label>';
					} else {
						TipDlgHTML+= '		<h2>Tipsa om bloggadress</h2>';
						TipDlgHTML+= '		<fieldset class="box_content">';					
						TipDlgHTML+= '			<label>http://</label>';					
					}
					TipDlgHTML+= '			<input type="text" class="txt_input" id="txt_input_address" />';
					TipDlgHTML+= '		</fieldset>';
					TipDlgHTML+= '		<span class="btn" id="btn_send"><span>Skicka</span></span>';
					TipDlgHTML+= '		<span class="btn" id="btn_cancel"><span>Avbryt</span></span>';
					TipDlgHTML+= '	</div>';
					TipDlgHTML+= '</div>';
			$('#people_popup').append( TipDlgHTML );
			$('#dlg_tip').hide();
			$('#dlg_tip #btn_send').click( Dlgs.Tip.Send );
			$('#dlg_tip #btn_cancel').click( Dlgs.Tip.Remove );
			$('#dlg_tip').fadeIn(250);
			
		},
		
		Send : function() {
			var address = $('#people_popup #txt_input_address').val();
			if( address != '' ) {
				$.ajax({
					type: 'GET',
					url: Dlgs.Tip.SendFile,
					dataType: 'text',
					data:	{
						id: Global.PersonID,
						name : Global.PersonName,
						type : Dlgs.Tip.BlogType,
						address : address
					},			
					success:
						function( data ) {
							if( data == 'ok' ) {
								$('#people_popup #dlg_tip label').remove();
								$('#people_popup #dlg_tip input').remove();								
								$('#people_popup #dlg_tip .btn').remove();
								
								var TipDlgThanksHTML = '<p>Tack för ditt tips. Vi ska lägga till det så snart som möjligt.</p>';
										TipDlgThanksHTML+= '<span class="btn btn_center" id="btn_ok"><span>OK</span></span>';
								$('#people_popup #dlg_tip .box fieldset').append( TipDlgThanksHTML );
								
								$('#dlg_tip #btn_ok').click( Dlgs.Tip.Remove );		
							} else {
								alert('Ett fel uppstod.');
							}
						}
				})
			}
				
		},
		
		Remove : function() {
			$('#dlg_tip').fadeOut(250, function() {
				$('#dlg_tip').remove();
			});		
		}
	}
}
