
imgList = new Array();
imgType = new Array();
imgLoad = new Image();

imgList[0] = "garache-2";
imgType[0] = "square";
imgList[1] = "villon-2";
imgType[1] = "square";
imgList[2] = "rembrandt-2";
imgType[2] = "square";
imgList[3] = "masson-2";
imgType[3] = "square";
imgList[4] = "woodward-4";
imgType[4] = "square";
imgList[5] = "corneille-2";
imgType[5] = "square";
imgList[6] = "chahine";
imgType[6] = "square";
imgList[7] = "dali-6";
imgType[7] = "square";
imgList[8] = "picasso-5";
imgType[8] = "square";
imgList[9] = "marini";
imgType[9] = "square";
imgList[10] = "matisse-2";
imgType[10] = "square";
imgList[11] = "picasso-4";
imgType[11] = "square";
imgList[12] = "miro-6";
imgType[12] = "square";
imgList[13] = "chimot-2";
imgType[13] = "square";
imgList[14] = "woodward-5";
imgType[14] = "square";
imgList[15] = "renoir";
imgType[15] = "square";
imgList[16] = "moore-3";
imgType[16] = "square";
imgList[17] = "chagall-4";
imgType[17] = "square";
imgList[18] = "tobiasse-2";
imgType[18] = "square";
imgList[19] = "artigas";
imgType[19] = "thin";
imgList[20] = "dali-3";
imgType[20] = "thin";
imgList[21] = "vanvelde";
imgType[21] = "thin";
imgList[22] = "braque";
imgType[22] = "thin";
imgList[23] = "chagall";
imgType[23] = "thin";
imgList[24] = "corneille";
imgType[24] = "thin";
imgList[25] = "bolliger";
imgType[25] = "thin";
imgList[26] = "garache";
imgType[26] = "thin";
imgList[27] = "leilapissarro";
imgType[27] = "thin";
imgList[28] = "cathelin";
imgType[28] = "thin";
imgList[29] = "chagall-2";
imgType[29] = "thin";
imgList[30] = "dali-4";
imgType[30] = "thin";
imgList[31] = "chimot";
imgType[31] = "thin";
imgList[32] = "chahine";
imgType[32] = "thin";
imgList[33] = "marini";
imgType[33] = "thin";
imgList[34] = "matisse";
imgType[34] = "thin";
imgList[35] = "picasso";
imgType[35] = "thin";
imgList[36] = "masson";
imgType[36] = "thin";
imgList[37] = "rembrandt";
imgType[37] = "thin";
imgList[38] = "woodward";
imgType[38] = "thin";
imgList[39] = "tobiasse";
imgType[39] = "thin";
imgList[40] = "renoir";
imgType[40] = "thin";
imgList[41] = "miro";
imgType[41] = "thin";
imgList[42] = "cocteau";
imgType[42] = "thin";
imgList[43] = "dali";
imgType[43] = "thin";
imgList[44] = "calder";
imgType[44] = "thin";
imgList[45] = "dali-2";
imgType[45] = "thin";
imgList[46] = "miro-2";
imgType[46] = "thin";
imgList[47] = "dix";
imgType[47] = "thin";
imgList[48] = "miro-4";
imgType[48] = "wide";
imgList[49] = "miro-5";
imgType[49] = "wide";
imgList[50] = "calder-2";
imgType[50] = "wide";
imgList[51] = "moore-2";
imgType[51] = "wide";
imgList[52] = "woodward-3";
imgType[52] = "wide";
imgList[53] = "villon";
imgType[53] = "wide";
imgList[54] = "moore";
imgType[54] = "wide";
imgList[55] = "corneille";
imgType[55] = "wide";
imgList[56] = "picasso-2";
imgType[56] = "wide";
imgList[57] = "chagall-3";
imgType[57] = "wide";
imgList[58] = "cathelin-2";
imgType[58] = "wide";
imgList[59] = "leger";
imgType[59] = "wide";
imgList[60] = "matisse";
imgType[60] = "wide";
imgList[61] = "woodward-2";
imgType[61] = "wide";
imgList[62] = "picasso-3";
imgType[62] = "wide";
imgList[63] = "rembrandt";
imgType[63] = "wide";
imgList[64] = "tobiasse";
imgType[64] = "wide";
imgList[65] = "dali-5";
imgType[65] = "wide";
imgList[66] = "miro-3";
imgType[66] = "wide";
imgList[67] = "moore-4";
imgType[67] = "tall";
imgList[68] = "rouault-2";
imgType[68] = "tall";
imgList[69] = "villon-3";
imgType[69] = "tall";
imgList[70] = "rouault";
imgType[70] = "tall";
imgList[71] = "miro-7";
imgType[71] = "tall";
imgList[72] = "chimot-3";
imgType[72] = "tall";
imgList[73] = "chahine-3";
imgType[73] = "tall";
imgList[74] = "chagall-5";
imgType[74] = "tall";
imgList[75] = "ubac";
imgType[75] = "tall";
imgList[76] = "dali-7";
imgType[76] = "tall";
imgList[77] = "cathelin-4";
imgType[77] = "tall";
imgList[78] = "miro-8";
imgType[78] = "tall";
imgList[79] = "woodward-6";
imgType[79] = "tall";
imgList[80] = "tobiasse-3";
imgType[80] = "tall";
imgList[81] = "garache-3";
imgType[81] = "tall";
imgList[82] = "cathelin-3";
imgType[82] = "tall";
imgList[83] = "corneille-3";
imgType[83] = "tall";

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func;
		}
	}
}

function setHeightById (eId, height) {
	try {
		
		element = document.getElementById(eId);
		element.style.height = height + 'px';
	}
	catch (err) {
		
	}
}

function matchColumns () {
	try{
		leftnode = document.getElementById(arguments[0]);
		var lefttotal = 0;
		
		for(x in leftnode.childNodes) {
			if( typeof leftnode.childNodes[x].offsetHeight != "undefined" && typeof leftnode.childNodes[x].offsetHeight != '') {
				lefttotal = lefttotal + leftnode.childNodes[x].offsetHeight;
			}
		}
		
		rightnode = document.getElementById(arguments[1]);
		var righttotal = 0;
		
		for(x in rightnode.childNodes) {
			if( typeof rightnode.childNodes[x].offsetHeight != "undefined" && typeof rightnode.childNodes[x].offsetHeight != '') {
				righttotal = righttotal + rightnode.childNodes[x].offsetHeight;
			}
		}
	}
	catch(err){}
	if( typeof arguments[3] != "undefined") {
		var offset = arguments[3];
	} else {
		var offset = 0;
	}
	
	try{
		if (lefttotal > righttotal)
			document.getElementById(arguments[2]).style.height = (lefttotal - 218 - offset) + 'px';
	}
	catch(err){}
	return lefttotal + " " + righttotal + " " + (lefttotal - 218 - offset);
}

function matchContent () {
	try {
		left = document.getElementById('left').offsetHeight;
		right = document.getElementById('right').offsetHeight;
		content = document.getElementById('content').offsetHeight;
		if (left > content || right > content) {
			if (left > right) {
				document.getElementById('content').style.height = (left-3) + "px";
			} else {
				document.getElementById('content').style.height = (right-3) + "px";
			}
		}
		return "Content: " + document.getElementById('content').style.height + "Left: " + left + "Right: " + right;
	}
	catch(err){}
}

function clearSpacers() {
	try {
		if (document.getElementById('presslinks').offsetHeight) {
				//alert('testing-ignore this');
				document.getElementById('content').style.height = (document.getElementById('content').offsetHeight - 8) + "px";
		}
	}
	catch(err){}
}

function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)", "i") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i < arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}

function changeImage (imgId, type) {
	try {
	img = document.getElementById('img' + imgId);
	link = document.getElementById('linkimg' + imgId);
	randomnum = Math.floor(Math.random() * imgList.length);
	matchImg = getElementsByAttribute(document, 'img', 'alt', imgList[randomnum]);
	if (matchImg.length || imgType[randomnum] != type) {
		changeImage (imgId, type);
	} else {
		img.src = "images/framed/" + type + "/" + imgList[randomnum] + ".jpg";
		link.href = "images/framed/" + type + "/" + imgList[randomnum] + ".jpg";
		img.alt = imgList[randomnum];
	}
	}
	catch(err){
	}
}

function startTimers() {
	var int1 = setInterval("changeImage('1','wide');", 5000);
	var int2 = setInterval("changeImage('2','thin');", 7000);
	var int3 = setInterval("changeImage('3','square');", 5000);
	var int4 = setInterval("changeImage('4','square');", 7000);
	var int5 = setInterval("changeImage('5','thin');", 5000);
	var int6 = setInterval("changeImage('6','wide');", 7000);
	var int7 = setInterval("changeImage('7','tall');", 5000);
	var int8 = setInterval("changeImage('8','square');", 7000);
	var int9 = setInterval("changeImage('9','tall');", 5000);
}

addLoadEvent (function () {
	//startTimers();
	matchColumns('leftcol','rightcol','content');
	matchColumns('left','right','right',72);
	matchContent();
	clearSpacers();
});
