// ==UserScript==
// @name          Gmail Full Width
// @author        Raffles
// @namespace     http://raffles.awardspace.com/
// @description   Applies to conversations view only. The advertising box on the right is removed and conversations occupy the full width available.
// @injectframes  1
// @include       http*://mail.google.com/*
// ==/UserScript==


//A porting script from http://userscripts.org/scripts/show/9409
//Original Author: http://userscripts.org/people/18414

function getElementsByClass(cname)
{
	var res = [];
	var elms = document.getElementsByTagName('div');
	for(var i=0; i<elms.length; i++){
		if(elms[i].className == cname) res.push(elms[i]);
	}
	return res;
}

var rh = document.getElementById('rh');
if (rh) rh.style.display = 'none';
var fic = document.getElementById('fic');
if(fic){
	if (fic.style.width != '99%') fic.style.width = '99%';
	fic.style.margin = '5px;';
}

var tt = document.getElementById('tt');
if (tt && tt.style.width != '99%') tt.style.width = '99%';
window.setTimeout(m, 50);
//var mhc = document.evaluate('//div[@class="mhc"]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
var mhc = getElementsByClass('mhc');
  for (var i = 0; i < mhc.length; i++) {
    mhc[i].attachEvent('onmousedown', function() {
      window.setTimeout(uom, 1000);
    });
  }

function m() {
  var l = document.getElementById('ap');
  if (!l) return;
  var ap = l.cloneNode(true);
  tt.style.position = 'relative';
  tt.appendChild(ap);
  ap.style.cssFloat = 'right';
  ap.style.position = 'absolute';
  ap.style.top = '0';
  ap.style.right = '0';
  for (var i = 0; i < ap.childNodes.length; i++) {
    ap.childNodes[i].style.styleFloat = 'left';
    ap.childNodes[i].style.marginRight = '10px';
  }
  uom();
}

function uom() {
  //var om = document.evaluate('//div[@class="om"]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  var om = getElementsByClass('om');
  for (var i = 0; i < om.lLength; i++) {
    om[i].style.marginLeft = '-88px';
    PRO_log(om[i].id);
  }
}

