var preloadedImages = new Array();
function preload() {
	var args = preload.arguments;
		
	for(var i = 0; i < args.length; i++) {
		var image = new Image();
		image.src = args[i];
		preloadedImages.push(image);		
	}
}

function hoverHome(who, hover) {
	var glowBackEl;
	var textGlowEl;
	
	if(who == 'painting') {
		glowBackEl = document.getElementById('paintingGlow');
		textGlowEl = document.getElementById('paintingText');
	} else if(who == 'ceramic') {
		glowBackEl = document.getElementById('ceramicGlow');
		textGlowEl = document.getElementById('ceramicText');
	} else {
		glowBackEl = document.getElementById('mixed_mediaGlow');
		textGlowEl = document.getElementById('mixed_mediaText');
	}
	
	var usesFilter = textGlowEl.getAttribute('usesFilter');
	
	if(hover) {
		glowBackEl.className = 'squareGlow';
		if(usesFilter == 'yes') {
			textGlowEl.filters(0).src = 'images/home/'+who+'s_text_on.png';
		} else {
			textGlowEl.src = 'images/home/'+who+'s_text_on.png';
		}
	} else {
		glowBackEl.className = '';
		if(usesFilter == 'yes') {
			textGlowEl.filters(0).src = 'images/home/'+who+'s_text.png';
		} else {
			textGlowEl.src = 'images/home/'+who+'s_text.png';
		}
	}
}

function outputPNG(imgSource, hoverSource, width, height, title, imgID, mapName) {	
	var isIE = (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf('Opera') == -1);
	var output = '';
	if(isIE) {
		// filter for MSIE 6.x and 5.5
		var ie6xFilter = /^.*MSIE [6]\.[0-9].*$/;
		var ie55Filter = /^.*MSIE [5].*$/;
		if (ie6xFilter.test(navigator.userAgent) || ie55Filter.test(navigator.userAgent)) {
			if (hoverSource) {
				output += '<img '+(mapName ? 'usemap="#'+mapName+'" ' : '')+(imgID ? 'id="'+imgID+'" ' : '')+'src="images/pixel.gif" border="0" usesFilter="yes" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+imgSource+');" onmouseover="this.filters(0).src=\''+hoverSource+'\';" onmouseout="this.filters(0).src=\''+imgSource+'\';" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+title+'">';
			}
			else {
				output += '<img '+(mapName ? 'usemap="#'+mapName+'" ' : '')+(imgID ? 'id="'+imgID+'" ' : '')+'src="images/pixel.gif" border="0" usesFilter="yes" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+imgSource+');" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+title+'">';
			}
		}
		else {
			if (hoverSource) {
				output += '<img '+(mapName ? 'usemap="#'+mapName+'" ' : '')+(imgID ? 'id="'+imgID+'" ' : '')+'src="'+imgSource+'" border="0" onmouseover="this.src=\''+hoverSource+'\';" onmouseout="this.src=\''+imgSource+'\';" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+title+'">';	 
			}
			else {
				output += '<img '+(mapName ? 'usemap="#'+mapName+'" ' : '')+(imgID ? 'id="'+imgID+'" ' : '')+'src="'+imgSource+'" border="0" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+title+'">';	 
			}
		}
	}
	else {
		if (hoverSource) {
			output += '<img '+(mapName ? 'usemap="#'+mapName+'" ' : '')+(imgID ? 'id="'+imgID+'" ' : '')+'src="'+imgSource+'" border="0" onmouseover="this.src=\''+hoverSource+'\';" onmouseout="this.src=\''+imgSource+'\';" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+title+'">';	 
		}
		else {
			output += '<img '+(mapName ? 'usemap="#'+mapName+'" ' : '')+(imgID ? 'id="'+imgID+'" ' : '')+'src="'+imgSource+'" border="0" width="'+width+'" height="'+height+'" alt="'+title+'" title="'+title+'">';	 
		}
	}
	
	return output;
}

function fixPNG(who) {
	var isIE = (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf('Opera') == -1);
	if(isIE) {
		// filter for MSIE 6.x and 5.5
		var ie6xFilter = /^.*MSIE [6]\.[0-9].*$/;
		var ie55Filter = /^.*MSIE [5].*$/;
		
		if(ie6xFilter.test(navigator.userAgent) || ie55Filter.test(navigator.userAgent)) {
			who.onload = function(){}
			who.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+who.src+')';
			who.src = 'images/pixel.gif';
		}
	}
}

function hover(who, baseClass, what) {
	var current;
	
	eval('current = who.className.match(/(Sel)?'+baseClass+'(Hover)?/);');
	current = current[0];
	
	if(what && current && current.search(/Hover$/) == -1) {
		eval('who.className = who.className.replace(/'+current+'/, "'+current+'Hover");');
	} else if(!what && current && current.search(/Hover$/) != -1) {
		eval('who.className = who.className.replace(/'+current+'/, "'+current.replace(/Hover$/, '')+'");');
	}
}

function getArtDetail(which, current, addContainers) {
	if(document.detailAnimation) {
		return;
	}
	
	sendRequest('what=getArtDetail', 'artId='+which+'&current='+current+(addContainers ? '&addContainers=yes' : ''), 'processGetArtDetail('+addContainers+');');
}

function processGetArtDetail(addContainers) {
	if(addContainers) {
		// populate the detail slip contents
		var detailSlipContent = document.getElementById('detailSlip');
		if (detailSlipContent) {
			detailSlipContent.innerHTML = httpReq.responseText;
		}
		
		showSlip('detail');
	} else {
		var oneDiv = document.getElementById('detail1');
		var twoDiv = document.getElementById('detail2');
		var fromDiv;
		var toDiv;
		
		if(oneDiv.style.zIndex == 3) {
			fromDiv = oneDiv;
			toDiv = twoDiv;
		} else {
			fromDiv = twoDiv;
			toDiv = oneDiv;
		}
		
		toDiv.innerHTML = httpReq.responseText;
		
		document.detailAnimation = new Fx.Styles(fromDiv.id, {duration: 500, transition: Fx.Transitions.quadOut, onComplete: function() {detailSwitchFinish(fromDiv, toDiv);} } );

		document.detailAnimation.start({
			'opacity': [1, 0]
		});
	}
}

function detailSwitchFinish(fromDiv, toDiv) {	
	fromDiv.style.zIndex = 2;
	toDiv.style.zIndex = 3;
	fromDiv.setStyle('opacity', 1);
	fromDiv.innerHTML = '';
	document.detailAnimation = null;
}

function getMediumDetail(which) {
	sendRequest('what=getMediumDetail', 'medium='+which, 'processGetMediumDetail();');
}

function processGetMediumDetail(addContainers) {
	// populate the detail slip contents
	var mediumSlipContent = document.getElementById('mediumSlip');
	if (mediumSlipContent) {
		mediumSlipContent.innerHTML = httpReq.responseText;
	}
	
	showSlip('medium');
}
