
var loading_skin_obj=null;
var loading_skin_timer=null;
//loading_skin_create();

function loading_skin_show(msec_time,bgcolor,text,img,opacity)
{
	loading_skin_create();
	if(text){}
	else text='Loading ...';
	
	if(img){}
	if(img==' ')img='';
	else img='loading/loading.gif';
	
	
	if(bgcolor){}
	else bgcolor='transparent';
	
	if(loading_skin_obj==null)
	{
		loading_skin_hide();
		loading_skin_timer=setTimeout("loading_skin_show("+msec_time+",'"+bgcolor+"','"+text+"','"+img+"')",10);
		return;
	}
	
	if(msec_time){}
	else if((msec_time=='') || NaN(msec_time) || (msec_time<10)) msec_time=10;
	
	try{yellow_bar_close();}catch(e){}
	loading_skin_hide();
	
	if((typeof opacity!='undefined') && (opacity!='') && !isNaN(opacity) )opacity=opacity*1;
	else opacity=70;
	
	
	if(bgcolor!='transparent')
		loading_skin_change_opac(opacity);
	loading_skin_adjust_size();
	loading_skin_obj.style.background=bgcolor;
	document.getElementById('text_'+loading_skin_obj.id).innerHTML=text;
	var img_obj=document.getElementById('img_'+loading_skin_obj.id);
	if(img!='')
	{
		img_obj.src=img;
		img_obj.style.visibility='visible';
	}
	else
		img_obj.style.visibility='hidden';
	loading_skin_obj.style.display='block';
	
	var focus_obj=document.getElementById('focus_'+loading_skin_obj.id);
	focus_obj.style.display='block';
	focus_obj.value='';
	//focus_obj.focus();
	focus_obj.style.display='none';
	loading_skin_timer=setTimeout('loading_skin_hide()',msec_time);
	return loading_skin_obj.style.zIndex;
}
function loading_skin_hide()
{
	if(loading_skin_timer!=null)
	{
		try{clearTimeout(loading_skin_timer);}catch(e){}
		loading_skin_timer=null;
	}
	if(loading_skin_obj!=null)
	{
		loading_skin_obj.style.display='none';
	}
}

function loading_skin_hold_action()
{
	loading_skin_obj.style.display=(loading_skin_obj.style.display=='none')?'block':'none';
}


function loading_skin_create()
{
	if(loading_skin_obj!=null) return;
	try
	{
		var obj= document.createElement('DIV');
		obj.id='loadingskin_m'+Math.round(Math.random()*1000)+'agic';
		obj.style.position='absolute';
		obj.style.display='none';
		obj.style.zIndex=Math.round(10000+Math.random()*10000);
		obj.style.top='0px';
		obj.style.left='0px';
		obj.style.width='1px';
		obj.style.height='1px';
		obj.style.fontWeight='bold';
		obj.style.border='0px black solid';
		obj.style.background='transparent';
		
		obj.innerHTML='<table border="0" width="100%" height="100%"><tr><td align="center" valign="middle"><img id="img_'+obj.id+'" src="loading/loading.gif" /><br /><h1 id="text_'+obj.id+'">Loading ...</h1><input id="focus_'+obj.id+'" type=text style="border:0px solid black;width:10px;height:10px"></td></tr></table>';
		document.body.appendChild(obj); 
		loading_skin_obj=obj;
	}catch(e){setTimeout("loading_skin_create()",10);}
}

function loading_skin_adjust_size() 
{
	
	if(loading_skin_obj==null) return;
  	try
	{
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) 
		{
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
		var cw=document.body.offsetWidth;
		var ch=document.body.offsetHeight;
		myWidth=(myWidth>cw)?myWidth:cw;
		myHeight=(myHeight>ch)?myHeight:ch;
		
		if(loading_skin_obj!=null)
		{
			loading_skin_obj.style.width=myWidth+'px';
			loading_skin_obj.style.height=myHeight+'px';
		}
	}catch(e){}
	setTimeout("loading_skin_adjust_size()",10);
}

function loading_skin_change_opac(opacity) 
{
	if(loading_skin_obj==null) return;
	try{
		var object = loading_skin_obj.style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")"; 
	}catch(e){}
} 


