function outDown(id,lang){
  image = new Image();
  image.src= 'http://www.papeldeparede.etc.br/config/out.php?id=' + id;
}

function relTag() {
	if (document.getElementsByTagName) {
		var anchors = document.getElementsByTagName( "a" );
		for (var loop = 0; loop < anchors.length; loop++) 
		{
			var anchor = anchors[loop];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
			{
				anchor.target = "_blank";
			}
		}
	}
}	

window.onload = function() {
	relTag();
}

function searchSubmit(obj){
	
	//if (obj.q.value.length<4) ....
	obj.q.value = obj.q.value.replace('?', '');
	window.location = '/'+encodeURIComponent(obj.q.value);
	return false;
}

menu_status = new Array();

function showHide(theid){
    if (document.getElementById) {
          var switch_id = document.getElementById(theid);
		  var switch_mais = document.getElementById('mais' + theid);
        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
		   switch_mais.innerHTML = '[-]';
           menu_status[theid] = 'show';
           //set_cookie(theid,'show');
		   //alert(theid+' show');
        }else{
           switch_id.className = 'hide';
		   switch_mais.innerHTML = '[+]';
           menu_status[theid] = 'hide';
           //set_cookie(theid,'hide');
		  // alert(theid+' hide');
        }
    }
}

function showHideAll(){
      var menuState = get_cookie('mymenu1');
      menu_status['mymenu1']=menuState;
      showHide('mymenu1');

      menuState = get_cookie ('mymenu2');
      menu_status['mymenu2']=menuState;
      showHide('mymenu2');
}

function get_cookie ( cookie_name ){
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );


  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ){
	
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );

  if ( secure )
        cookie_string += "; secure";

  document.cookie = cookie_string;
}
