var W = 0;					            //placeholder for document width
var H = 0;					            //placeholder for document height
var	d = document;

var ie = (getElm && d.all);


if (window.innerWidth) {
	W = window.innerWidth;
	H = window.innerHeight;
	
} else if (d.documentElement.offsetWidth) {
	W = d.documentElement.offsetWidth;
	H = d.documentElement.offsetHeight;
	
} else if (d.body) {
	W = d.body.offsetWidth;
	H = d.body.offsetHeight;
}

function grabDetailArticle(id) {
	var postString = '';
	var targDiv = 'targDiv' + id;
	new ajax('?id=' + id + '&ajax=1', {postBody: postString, update: targDiv, onComplete: itsOver});
}

function itsOver(request) {
	//d.getElementById("output2").innerHTML = request.responseText;
}

function addEvent( obj, type, fn ) {
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function initializer() {
if(d.getElementById) {
	var links = d.links;
	for (i=0;i<links.length;i++) {
		if (links[i].className == "dTrgr") {
			var detailTrigger = links[i];			
			detailTrigger.onclick = function() {
				return false;
			};			

			var minDiv = detailTrigger.parentNode.parentNode.parentNode;
			minDiv.onclick = function() {
				var id = this.id.substring(6);
				if (this.className == "minDiv") { // unopened
					grabDetailArticle(id); 
					this.className = "minDiv openedDiv";
					getElm('targDiv' + id).className = "targDiv openedDiv";
				} else {
					this.className = "minDiv";
					getElm('targDiv' + id).innerHTML = '';
					getElm('targDiv' + id).className = "targDiv visited";
				}
			}
			
			minDiv.onmouseover = function() {
				if(ie) {
					var summary = this.childNodes[0];
					var thumb = this.childNodes[1];
				} else {
					var summary = this.childNodes[1];
					var thumb = this.childNodes[3];
				}
				if (summary.className == "summary") {
					summary.className = "summary hidden";
					thumb.className = "thumb";
					thumb.style.backgroundImage = "url(/studio2/images/74t.jpg)";
				} else {
					thumb.className = "thumb hidden";
					summary.className = "summary";
				}
			}
			minDiv.onmouseout = function() {
				if(ie) {
					var summary = this.childNodes[0];
					var thumb = this.childNodes[1];
				} else {
					var summary = this.childNodes[1];
					var thumb = this.childNodes[3];
				}
				if (summary.className == "summary hidden") {
					summary.className = "summary";
					thumb.className = "thumb hidden";
				} else {
					thumb.className = "thumb";
					summary.className = "summary hidden";
				}
			}
		}
	}
}
}

function getElm (elm) {

	var e = d.getElementById(elm);
	if (e) {
		return e;
	} else {
		return null;
	}
}

addEvent(window, 'load',initializer);