function $(id)
{
	return document.getElementById(id); 
}

function debug(v, narrative) 
{
	if(narrative == true)
		$('debug').innerHTML = $('debug').innerHTML + v + "<br/>";
	else 
		$('debug').innerHTML = v;
}

function toggle(id)
{
	var obj = $(id);
	
	if(obj.style.display != "none")
		obj.style.display = "none";
	else
		obj.style.display = "block";

	return false;
}

function toggle2(id, url)
{
	var obj = $(id);
	
	if(obj.style.display != "none")
		obj.style.display = "none";
	else
	{
		obj.style.display = "block";
		$('widget_preview').src=url;
	}
	return false;
}

function set_opacity(id, value)
{
	var obj = $(id);
	if(value > -1)
	{	
		obj.style.opacity = value/100;
		obj.style.filter = 'alpha(opacity=' + value + ')';
	}
}

var progress_run_id;

function start_progress()
{
	$('pet_image').style.visibility = "visible";
	progress_run_id = setInterval(progress, 30);
}

var prg_width = 200;
var op = 100;
var w = 0;
var smi = 0.03;
var smsize = 100;

function progress()
{
	var node = $('progress_bar');
	var comment = $('progress_bar_comment');
	
	if(w > 100) smi = 0.1;
	if(w > 180) smi = 4.3;
	smsize = smsize - smi;
	
	set_opacity('smoke', parseInt(smsize)); 

	if(w > 0) comment.innerHTML = comments[0];
	if(w > 50) comment.innerHTML = comments[1];
	if(w > 100) comment.innerHTML = comments[2];
	if(w > 150) comment.innerHTML = comments[3];
				  
	if (w > prg_width-1)
	{
		$('progress_bar_container').style.display = "none";
		$('smoke').style.display = "none";
		clearInterval(progress_run_id);
		return;
	}

  	w++;
	node.style.width = w + 'px';
}

function create_bookmark() {
	if (window.sidebar) {
		window.sidebar.addPanel(b_title, b_url,"");
	} else if( window.external ) {
		window.external.AddFavorite(b_url, b_title); }
	else if(window.opera && window.print) { 
		return true; }
 }

