var isIE = document.all && navigator.userAgent.indexOf('Opera')==-1;

loader = function ()
{
    
	var items = getElementsByAttribute("class", "gallery_image");
        
	var tmp = null;
	/*
	for(var i=0; i<items.length; i++)
	{
		if(items[i].parentNode.className.indexOf("variable_height")!=-1)
		{
			items[i].style.height = (items[i].parentNode.offsetHeight-2) + "px";
		}
				
		for (var j=0; j<3; j++)
		{ 
		    var varheight = items[0].offsetHeight ; 
		    tmp = document.createElement('div');
			tmp.className = "gallery_image";
			tmp.style.height = (varheight-2) + "px";
			tmp.style.position = "absolute";
			tmp.style.zIndex = (j*10 + 10) + "";
			tmp.style.margin = ((6-(2*j))- varheight) + "px 0 0 " + ((6-(2*j))) + "px";
			items[i].parentNode.appendChild(tmp);
		}
	}

	var items = getElementsByAttribute("class", "image_image");

	for(var i=0; i<items.length; i++)
	{
		if(items[i].parentNode.className.indexOf("variable_height")!=-1)
		{
			items[i].style.height = (items[i].parentNode.offsetHeight-2) + "px";
		}
	}
        
	var tmp = null;
	for(var i=0; i<items.length; i++)
	{
		//items[i].style.height = items[i].parentNode.offsetHeight + "px";
	}
    */
    
	items = getElementsByAttribute("class", "gray_box");
	tmp = "";
	for(var i=0; i<items.length; i++)
	{
		tmp = items[i].innerHTML;

		items[i].innerHTML = "<span></span>";

		items[i].innerHTML = "<table cellpadding='0' cellspacing='0' class='max_width'>" +
					"<tbody>" +
					"<tr>" +
						"<td class='gray_box_topleft'></td>" +
						"<td></td>" +
						"<td class='gray_box_topright'></td>" +
					"</tr>" +
					"<tr>" +
						"<td><div class='gray_box_divider'></div></td>" +
						"<td class='gray_box_center'>" + tmp + "</td>" +
						"<td><div class='gray_box_divider'></div></td>" +
					"</tr>" +
					"<tr>" +
						"<td class='gray_box_bottomleft'></td>" +
						"<td></td>" +
						"<td class='gray_box_bottomright'></td>" +
					"</tr>" +
					"</tbody>" +
					"</table>";
	}

	items = getElementsByAttribute("class", "red_box");
	tmp = "";
	for(var i=0; i<items.length; i++)
	{
		tmp = items[i].innerHTML;

		items[i].innerHTML = "<span></span>";

		items[i].innerHTML = "<table cellpadding='0' cellspacing='0' class='max_width'>" +
					"<tbody>" +
					"<tr>" +
						"<td class='red_box_topleft'></td>" +
						"<td></td>" +
						"<td class='red_box_topright'></td>" +
					"</tr>" +
					"<tr>" +
						"<td></td>" +
						"<td class='red_box_center'>" + tmp + "</td>" +
						"<td></td>" +
					"</tr>" +
					"<tr>" +
						"<td class='red_box_bottomleft'></td>" +
						"<td></td>" +
						"<td class='red_box_bottomright'></td>" +
					"</tr>" +
					"</tbody>" +
					"</table>";
	}

	// Gallery management pages (had to put it here otherwise IE nulls out the mouse events)
	// Assign mouseovers
	var private_button = document.getElementById('private');
	var public_button = document.getElementById('public');
	var locked_button = document.getElementById('locked');

	if(private_button)
	{
		private_button.onmouseover = function () { mouseover_func(this.id); };
		private_button.onmouseout = mouseout_func;
		private_button.onclick = function () { click_func(this.id); };
	}
	if(public_button)
	{
		public_button.onmouseover = function () { mouseover_func(this.id); };
		public_button.onmouseout = mouseout_func;
		public_button.onclick = function () { click_func(this.id); };
	}
	if(locked_button)
	{
		locked_button.onmouseover = function () { mouseover_func(this.id); };
		locked_button.onmouseout = mouseout_func;
		locked_button.onclick = function () { click_func(this.id); };
	}

  /*
	var radio_box = document.getElementById('galleryM_radio_buttons');

	if(radio_box)
	{
		var items = radio_box.getElementsByTagName('input');
		for(var i=0; i<items.length; i++)
		{
			if(items[i].getAttribute('type')=='radio')
			{
			    var strvalue = this.value ; 
			    strvalue = strvalue.toLowerCase();
			    strvalue = strvalue.substring(2,strvalue.length)
			 	items[i].onmouseover = function () { mouseover_func(strvalue); };
				items[i].onmouseout = mouseout_func;
			}
		}
	}
	*/	
};

addLoadListener(loader);

function openWindow(url,x,y)
{
	window.open(url, '', 'scrollbars,resizable,width='+x+',height='+y);
	return false;
}