var is_modal_opened = 0;

function modal(id) {
	$('.flashadv').hide();
	if(is_modal_opened==1) {
		modalClose();
	}
	is_modal_opened = 1;
	if($('div#'+id).size()==1) {
   		$('div#modal_content').append($('div#'+id));
	}
   	$('div#'+id).show();
   	modal_id = id;
  	var width    = $('#main_container').width();
  	var height   = $(document).height();
  	var b_height = $(window).height();
  	var m_height = $('div#modal').height();
  	scroll_var   = $(window).scrollTop();		

    var top_var = scroll_var + 20; //+ ((b_height/2)-(m_height/2));
    $('div#submodal').css('width',width+'px');
    $('div#submodal').css('height',height+'px');
  	$('div#submodal').show();
	$('div#modal').css({"top":top_var+'px'});
   	$('div#modalC').show();
   	$('div#modal').show();
    $('div#submodal').css('width',width+'px');
    $('div#submodal').css('height',height+'px');
	if(typeof(eval('window.'+modal_id+'_start'))=='function') {
		eval(id + '_start' + '()');
	}
	
}

function modalClose() {
   	$('div#modalC').hide();
   	$('div#modal').hide();
   	$('div#submodal').hide();
   	$('div#'+modal_id).hide();
	if(typeof(eval('window.'+modal_id+'_end'))=='function') {
		eval(modal_id + '_end' + '()');
	}
   	modal_id = '';
	$('.flashadv').show();
	is_modal_opened = 0;
}

function SelectAll(id) {
	document.getElementById(id).focus();
	document.getElementById(id).select();
}

function loading_start() {}
function loading_end() {}
