/*************************************
* Floating Boxes                     *
**************************************
*                                    *
* Author: Tim Jans                   *
*                                    *
**************************************/

function floatingBox() {

	this.container = null;
	
	this.build = function(id) {
	
		$('.floatingSpecialBox').remove();
		
				
		this.container = $('<div class="floatingSpecialBox" id="' + id + '"></div>');
		fbox_inner = $('<div class="innerFloatingSpecialBox"></div>');
		fbox_header = $('<div class="boxHeader"></div>');
		fbox_content = $('<div class="boxContent"><div class="clear"></div></div>');
		fbox_footer = $('<div class="boxFooter"></div>');
		
		
		$('#content').append(this.container);
		this.container.append(fbox_inner);
		fbox_inner.append(fbox_header, fbox_content, fbox_footer);
	};

	this.setTitle = function(headerTxt) {
		fbox_header.html(headerTxt);
	};
	
	this.setContentTxt = function(contentTxt) {
		fbox_text = $('<div class="boxContentTxt">' + contentTxt + '</div>');
		fbox_content.prepend(fbox_text);
	};

	this.setContentImg = function(imgSrc) {
		fbox_img = $('<div class="boxContentImg"><img src="' + imgSrc + '" alt="" /></div>');
		fbox_content.prepend(fbox_img);
		w = (fbox_img.width() + 22) + 'px';
		fbox_text.css({marginLeft: w});
	};

	this.setButtons = function(buttons) {
        fbox_footer.html('');
		for (var i = 0; i < buttons.length; ++i) {
			fbox_footer.append('<input name="" onclick="' + buttons[i]['callback'] + '" value="' + buttons[i]['label'] + '" class="FormButton" onmouseover="this.className=\'FormButtonOver\';" onmouseout="this.className=\'FormButton\';" onfocus="this.className=\'FormButtonOver\';" onblur="this.className=\'FormButton\';" type="button">');
		}
	};
	
	this.addTextareaToggle = function(id, label, note) {
		
		
		var fbox_form = $('<div style="margin-top:10px" id = "' + id + '"></div>');
		
		fbox_form.append('<a href="javascript:void(0);" class="show_link smallDGrey" onclick="Box.box_toggle_message(\'' + id + '\');">' + label + '</a>');
		fbox_form.append('<span class="hide_link" style="display:none">' + label + ' <a href="javascript:void(0);" class="hide_link smallDGrey" onclick="Box.box_toggle_message(\'' + id + '\');">abbrechen</a></span>');
		
		fbox_form.append('<form style="display:none" class="styledForm">' + ((typeof(note) != 'undefined') ? '<span class="smallDGrey">' + note + '</span><br />' : '') + '<textarea id="message_' + id + '" name="message_' + id + '" class="txtInput" style="width: 315px;" rows="5"></textarea></form>');
		fbox_text.append(fbox_form);
	
	};
	
	this.box_toggle_message = function(id) {
		
		$("#" + id + " > form").toggle(); 
		$("#" + id + " a.show_link").toggle();
		$("#" + id + " span.hide_link").toggle();
		$("#message_" + id).val('');
		
		
	};
	
	this.destroy = function(id) {
		//$('#' + id ).remove();
		$(this.container).remove();
	};

	this.show = function() {
		this.container.bgiframe();
		this.container.show();
		
	};

}