var content_service = new ContentService();

function show_popup_content(id, width, height){
	
	show_popup('<img src="/images/public/waiting.gif" />', '', width, height);
	
	content_service.get_content.call(id);
	content_service.get_content.result = function(result) {

		if(result){
			show_popup(result.content_title, result.content_body, width, height);
		}
	}
}

function show_popup_rendered_content(id, width, height){
	
	show_popup('<img src="/images/public/waiting.gif" />', '', width, height);
	
	content_service.get_rendered_content.call(id);
	content_service.get_rendered_content.result = function(result) {

		if(result){
			show_rendered_popup(result,width, height);
		}
	}
}

function show_popup(title, html, width, height) {
	
	var popup = $('popup');
	
	popup.hide();
	
	var popup_content = $('popup-content');
	
	popup_content.update(html);
	
	var popup_header = $('popup-header');
		
	popup_header.update(title);
	
	position_popup(width, height);
}

function show_rendered_popup(content, width, height){

	var popup = $('popup');
	var popup_content = $('popup-content');
	var popup_header = $('popup-header');	

	popup.hide();
	popup_header.update('');
	popup_content.update(content);

	position_popup(width, height);
}

function position_popup(width, height){
	
	var popup = new getObj('popup');
	
	var window_width = getWindowWidth();
	var window_height = getWindowHeight();
	var scroll_top = getScrollTop();
	
	
	popup.style.position = 'absolute';
	popup.style.left = ((window_width - width)/2) + 'px';
	popup.style.top = (scroll_top + (window_height - height)/2) + 'px';
	popup.style.width = width + 'px';
	popup.style.height = height + 'px';
	
	
	if(IE6){
		popup.style.background = '#cccccc';
		popup.style.border = '1px solid #333333';
		popup.style.padding = '5px';
	}

	popup.obj.className = 'visible';
	popup.style.display = 'block';

}

function hide_popup(){
	
	var popup = $('popup');
		
	popup.hide();
}
