function uiOSD(css){
	this.id = 'OSD_'+Math.floor(Math.random()*10000);
	this.bid = this.id+'background';
	$('body').append('<div class="uiOSD" id="'+this.id+'"></div>');
	$('body').append('<div class="uiOSDBackground" id="'+this.bid+'"></div>');
	this.window = $('#'+this.id);
	this.background = $('#'+this.bid);
	this.window.hide();
	this.background.hide();
	if(css){
		this.set_background_style(css);	
	}
	this.set_background_style = function(css){
		this.background.css(css);	
	}
	this.set_position = function(top,left){
		this.window.css({top:top,left:left});	
		this.background.css({top:top,left:left});
	}
	this.add = function(text){
		this.window.html(this.window.html()+text);
		this.background.width(this.window.width());
		this.background.height(this.window.height());
	}
	this.hide = function(){
		this.window.hide();
		this.background.hide();	
	}
	this.hide_all = function(){
		$('.uiOSD,.uiOSDBackground').hide();
	}
	this.show = function(text,timeout){
		$('.uiOSD,.uiOSDBackground').fadeOut(100);
		$('.uiOSDBackground').css('z-index','1000000000');
		$('.uiOSD').css('z-index','1000000001');
		this.window.html(text);
		if(any_ie()){
			this.window.show()
			this.background.show();
		}else{
			this.window.fadeIn(500);
			this.background.fadeIn(500);
		}
		this.background.width(this.window.width());
		this.background.height(this.window.height());
		osd_self = this;
		clearTimeout(this.timeTimeout);
		if(timeout)
			this.timeTimeout = setTimeout(function(){
				if(any_ie()){
					osd_self.background.hide();
					osd_self.window.hide();
				}else{
					osd_self.background.fadeOut(500);
					osd_self.window.fadeOut(500)
				}
			},timeout)
			
		if(ie_lesser()){
			offset_t = ($(document).scrollTop()+10);
			this.window.css({top:offset_t});
			this.background.css({top:offset_t});
		}
		return this;
	}
	return this;
}

function OverLight(){
	this.id = 'OverLight_'+Math.floor(Math.random()*10000);
	this.pid = 'OverLight_Panel'+Math.floor(Math.random()*10000);
	$('body').append('<div class="uiOverLight" id="'+this.id+'"><img class="OverLightLoader" src="/img/ui/loader-2.gif" />&nbsp;</div>');
	$('body').append('<div class="uiOverLightPanel" style="width:auto;" id="'+this.pid+'">&nbsp;</div>');

	this.window = $('#'+this.id);
	this.window.width($(document).width());
	if(ie_lesser()){
		this.window.height($(document).height());
		$('#OverLightLoader').css('top',$(document).scrollTop()*2)
		$('#OverLightLoader').css('left',$(document).scrollLeft()*2)
	}
	this.window.hide();
	this.panel = $('#'+this.pid);
	this.panel.hide();
	this.show = function(text){
		$('embed').hide();
		
		//$('object').hide();
		if(any_ie())
			this.window.show();
		else
			this.window.fadeIn(500);
		if(text){
			this.panel.html(text);
			var offset_l = this.panel.width()-(this.panel.width()*2);
			var offset_t = this.panel.height()-(this.panel.height()*2);
			this.panel.css({marginLeft:(offset_l/2)+'px',marginTop:(offset_t/2)+'px'});
			this.panel.fadeIn(500);
		}
		
		return this
	}
	this.obscure = function(){
		this.panel.css('margin-top','-12000px');	
	}
	this.set_width = function(width){
		this.panel.width(width);
		this.center();
	}
	this.set_text = function(text,title){
		if(!title)
			title = '';
		this.panel.html('<div class="panel-top" ><p>'+title+'</p><p class="close-btn"><a href="javascript:void(0);" class="panel-close"><img src="/img/ui/x.png" width="18" height="18" style="border:0" /></a></p></div><div class="panel-text">'+text+'</div>');
		panel_self = this;
		this.panel.find('.panel-close').unbind('click').click(function(){
			panel_self.hide();
		});
		this.panel.show();
		var offset_l = this.panel.width()-(this.panel.width()*2);
		var offset_t = (this.panel.height()-(this.panel.height()*2));
		if(ie_lesser())
			offset_t += ($(document).scrollTop()*2);
		this.panel.hide();
		this.panel.css({marginLeft:(offset_l/2)+'px',marginTop:(offset_t/2)+'px'});
		loadTransImgs();
		this.panel.fadeIn(500);
		
	}
	this.center = function(){
		var offset_l = this.panel.width()-(this.panel.width()*2);
		var offset_t = (this.panel.height()-(this.panel.height()*2));
		if(ie_lesser())
			offset_t += ($(document).scrollTop()*2);
		this.panel.hide();
		this.panel.css({marginLeft:(offset_l/2)+'px',marginTop:(offset_t/2)+'px'});	
		this.panel.show();
	}
	this.add_text = function(text){
		this.panel.html(this.panel.html()+text)	;
		var offset_l = this.panel.width()-(this.panel.width()*2);
		var offset_t = this.panel.height()-(this.panel.height()*2);
		this.panel.css({marginLeft:(offset_l/2)+'px',marginTop:(offset_t/2)+'px'});
	}
	this.hide = function(){
		if(any_ie())
			this.window.hide();
		else
			this.window.fadeOut(500);
				
		this.panel.fadeOut(500,function(){
			$('embed').show();
			//$('object').show();	
		});
		
		return this
	}
}



function ie_lesser(){
	if ( $.browser.msie && $.browser.version  <= 6)
 			return true
 	else
 			return false
}
function any_ie(){
	if ( $.browser.msie )
 			return true
 	else
 			return false
}
