function gallery() {
	container = document.getElementById('jsprojects');
	imagecontainer = document.getElementById('images');
	
	imageso = imagecontainer.getElementsByTagName('img');
	
	for(i=0; i<imageso.length;i++) {
		YAHOO.util.Event.addListener(imageso[i],'mouseover',gallerySwap);
		YAHOO.util.Event.addListener(imageso[i],'mouseout',gallerySwap);
	}
}

function gallerySwap() {
	theid = this.id.substring(3);
	
	swapcontainer = document.getElementById('swap');
	thestatus = swapcontainer.innerHTML.substring(0,4);
	
	if(thestatus.toLowerCase() == '<img') {
		swapcontainer.innerHTML = '<h1>Ram Cast</h1>';
		textcontainer.innerHTML = '<br />';
	} else {
		textcontainer = document.getElementById('caption');
		swapcontainer.innerHTML = '<img src="'+this.src+'" width="300" />';
		textcontainer.innerHTML = textobj['id'+theid];
	}
}

function map() {
	thelist = document.getElementById('maplist');
	maplinks = thelist.getElementsByTagName('a');
	for(i=0; i<maplinks.length;i++) {
		YAHOO.util.Event.addListener(maplinks[i],'mouseover',mapCaption);
		YAHOO.util.Event.addListener(maplinks[i],'mouseout',mapCaptionReturn);
	}
	
}

function mapCaption() {
	captionbar = document.getElementById('mapcaption');
	captionbar.innerHTML = this.title;
	
	if(this.className.indexOf('resource') == -1) {
		captionbar.className = 'projectbar';
	}else{
		captionbar.className = 'resourcebar';
	}
}

function mapCaptionReturn() {
	captionbar = document.getElementById('mapcaption');
	captionbar.innerHTML = 'View &gt;&gt;&gt; Rollover Caption Giving Location';
	captionbar.className = 'defaultbar';
}

function initpopups() {
	alinks = document.getElementsByTagName('a');
	for(i=0; i<alinks.length;i++) {
		var mysite = location.hostname;
		if(alinks[i].href.indexOf(mysite) == -1) {
			YAHOO.util.Event.addListener(alinks[i],'click',popup);
		}
	}
}

function popup(e) {
	newwin = window.open(this.href);
	newwin.focus();
	YAHOO.util.Event.preventDefault(e);
}

YAHOO.util.Event.onAvailable('jsprojects', gallery);
YAHOO.util.Event.onAvailable('mapcontainer', map);
YAHOO.util.Event.onDOMReady(initpopups);
