/*

Code from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array to make sure
that the browser has all the array functions we want.

*/

if (!Array.prototype.map)
{
  Array.prototype.map = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var res = new Array(len);
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        res[i] = fun.call(thisp, this[i], i, this);
    }

    return res;
  };
}

if (!Array.prototype.forEach)
{
  Array.prototype.forEach = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        fun.call(thisp, this[i], i, this);
    }
  };
}

/*

End code.

*/




function doMatch(label)
{
	function addDiv(elem)
	{
		function findDiv(elem)
		{
			return elem.nodeName == 'DIV' || elem.nodeName == 'div'  ? elem : findDiv(elem.parentNode);
		}
		elem.mydiv = findDiv(elem);
	}

	var els = [];
	var x;
	var i = 0;
	while ((x = document.getElementById(label + ++i)) != null)
	{
		els[i - 1] = x;
	}

	els.forEach(addDiv);
	
	var minheight = Math.min.apply(null, els.map(function(x) { return x.mydiv.offsetHeight; }));

	function shrink(el, newlength)
	{
		var curHeight = el.mydiv.offsetHeight;
		var curHTML = el.innerHTML;
		el.innerHTML = curHTML.substr(0, newlength);
		if (Math.abs(curHeight - minheight) < Math.abs(el.mydiv.offsetHeight - minheight))
		{
			el.innerHTML = curHTML;
			return false;
		}
		return true;
	}

	els.forEach(function(el)
	{
		var shrank = false;
		while (el.mydiv.offsetHeight > minheight && el.innerHTML.length > 0)
		{
			shrank = true;
			if (!shrink(el, el.innerHTML.length - 1)) break;
		}
		if (shrank)
		{
			var lastspace = el.innerHTML.lastIndexOf(' ');
			shrink(el, lastspace);
		}
	});
}

function match(label)
{
	if (window.doload)
		var old = window.doload;
	else
		var old = function () { };
	window.doload = function () { /*old(); doMatch(label);*/ }; /* lukasz.strozek(josh.haas): i disabled this */
}

function goOver(imgname){
     imgname.src = "/images/theissuer/votebox_full.jpg"
}

function goOut(imgname){
     imgname.src = "/images/theissuer/votebox_empty.jpg"
}
function showReview(me){
    me = document.getElementById(me);
    		if (me.style.display=="none"){
    			me.style.display="block";
    			}
    		else {
    				me.style.display="none";
    				
    			}
    		}
