var CTV_indicator;
var CTV_win;
var CTV_path;
var CTV_alt;

function setCTV()
{
	var e = getElementsBySelector("#thumbs")[0];
	if(e)
	{
		//alert("Found gallery");
	}
		else
	{
		return;
	}

	var areas = getElementsBySelector("#thumbs a");
	for(var i=0; i<areas.length; i++){

		//EventUtils.addEventListener(areas[i],'mouseover',showCTVindicator);
		//EventUtils.addEventListener(areas[i],'mouseout',hideCTVindicator);
		EventUtils.addEventListener(areas[i],'click', doCTV);
		areas[i].imagePath = areas[i].href;
		areas[i].href = "javascript: void(0);";
		areas[i].target = "";
		
	}
}
/*
function showCTVindicator(){
	window.status = "Click to enlarge";
	if(CTV_indicator)
		CTV_indicator.style.visibility = "visible";
		
	return true;
}

function hideCTVindicator(){
	window.status = "";
	if(CTV_indicator)
		CTV_indicator.style.visibility = "hidden";
}*/

function doCTV(evt){
	var path;
	var alt;
	var img;
	if(evt.target)
	{
		el = evt.target;
	}
	else
	{
		el = evt.srcElement;
	}

	while(el.tagName != "A"){
		el = el.parentNode;
	}
	
	img = el.getElementsByTagName("img")[0];
	path = el.imagePath;
	alt = img.alt;
	
	CTV_win = window.open("image_viewer.htm",'CTV','status=yes,scrollbars=no,resizable=no,width=400,height=400');
	CTV_path = path;
	CTV_alt = alt;
	CTV_win.window.focus();
	
	return false;
}

EventUtils.addEventListener(window,'load',setCTV);
