function show_progress(){
  if ((obj1 = document.getElementById('ProgressPanelFG')) && (obj2 = document.getElementById('ProgressPanelBG'))){          
    obj1.style.display = 'block';
    obj2.style.display = 'block'; 
    
    pb_visible = true;     
    
    window_resize();        
  }
}

function window_resize(){
  if (!pb_visible) return;
  
  if ((obj1 = document.getElementById('ProgressPanelFG')) && (obj2 = document.getElementById('ProgressPanelBG'))){
    /*var objs = document.getElementsByTagName('object');
    for(a = 0; a < objs.length; a++ ){
      objs[a].style.visibility = 'hidden';
    }*/
    
    //obj2.style.display = 'block';
    obj2.style.width = Math.max(document.documentElement.clientWidth, document.body.clientWidth) + 'px';
    obj2.style.height = Math.max(document.documentElement.clientHeight, document.body.clientHeight) + 'px';         
    
    //obj1.style.display = 'block';
    obj1.style.width = obj2.style.width
    obj1.style.height = obj2.style.height;                                  
  }
}

function createCookie(name,value,miliseconds) {
	if (miliseconds) {
		var date = new Date();
		date.setTime(date.getTime() + miliseconds);
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

// usefull when using jquery in edit mode
function get_system_message( text )
{
  sm_starts = text.indexOf('<'+'ul id="system_messages">');
  text = text.substring(sm_starts);
  sm_ends = text.indexOf('</ul>');

  if ( (sm_starts > -1) && (sm_ends > -1) ) {
    text = text.substring(0, sm_ends + 5);
    sm = $(text).html();
  }
  else sm = '';

  if ( sm != '' ) {
    // there is no system_mesages node, so create it
    if ( $('#system_messages').length == 0 ) $('body').prepend('<'+'ul id="system_messages">' + sm + '</ul>');
    // just change content of system_messages node
    else $('#system_messages').html(sm);
  }
  else {
    // remove system_messages node, because we don't need it anymore
    if ( $('#system_messages').length != 0 ) $('#system_messages').remove();
  }
}

function create_object( object, value, width, height )
{
  if ( value.indexOf('.swf') > -1 ) {
    obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" class="img" width="'+width+'" height="'+height+'" align="middle">' +
            '<param name="movie" value="'+value+'"/>' +
            '<!--[if !IE]>-->' +
            '<object type="application/x-shockwave-flash" data="{LOGO}" width="'+width+'" height="'+height+'">' +
                '<param name="movie" value="'+value+'"/>' +
            '<!--<![endif]-->' +
                '<a href="http://www.adobe.com/go/getflash">' +
                    '<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>' +
                '</a>' +
            '<!--[if !IE]>-->' +
            '</object>' +
            '<!--<![endif]-->' +
          '</object>';
    return $(object).replaceWith(obj);
  }
  else return $(object).replaceWith('<img src="/image.php?url=' + value +'&amp;width='+width+'&amp;height='+height+'" width="'+width+'" height="'+height+'" class="img"/>');
}
