
function popUp(url, width, height) {
        window.open(url, '', 'width='+width+',height='+height);
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function bookmark() {
        var url;
        var title;
        url = window.location.href;
        title = document.title;
        if (document.all) {
                window.external.AddFavorite(url, title);
                } else {
                alert('Pressione Ctrl-D para adicionar aos favoritos.');
        }
}

function hpShowDiv(id)
{
    document.getElementById('hp1').style.display ='none';
    document.getElementById('hp2').style.display ='none';
    document.getElementById('hp3').style.display ='none';
    document.getElementById('hp'+id).style.display ='block';
}


document.getElementsById = function (tagName) {
	var unFiltered = document.getElementsByTagName('*');
	var filtered = [];
	for (i = 0; i < unFiltered.length; i++) if (unFiltered[i].getAttribute('id') == tagName) filtered.push(unFiltered[i]);
	return filtered;
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    cat = unescape(document.cookie.substring(c_start,c_end));
	cate = 'Category' + cat;
	
	if (document.getElementById(cate)) { 
			toogleCategory(cat);
		}
    } 
  }
}

function toogleCategory (id)
{
	setCookie('cat',id,1);
    toogleHelper (id);
    
    if (document.toogleCategoryID && document.toogleCategoryID != id)
        toogleHelper (document.toogleCategoryID, true);
    
    document.toogleCategoryID = id;    
}

function toogleHelper (id, close)
{
    var value = document.getElementById ('Category' + id).style.display;
    if (value == 'block' || close == true)
        value = 'none';
    else
        value = 'block';
        
    ids = document.getElementsById ('Category' + id);
    for (i = 0; i < ids.length; i++)    
        ids[i].style.display = value;

}