// JavaScript Document

function preload(images,gal) {
for(var i=0; i<images.length; i++)
	{
		var preloads = new Array();
		preloads[i] = new Image;
		preloads[i].src = gal+images[i];
	}
}
function fadeIn() {
	crossfade(document.getElementById('toppic'), 'images/index1.jpg', '2.5', 'Spitting Image');
	preload(preload);
}

function change_content(cid) {
	if(ixf.newimg.parentNode) ixf.newimg.parentNode.removeChild(ixf.newimg);
	var container = document.getElementById('innerImage');
	var title = document.getElementById('pageTitle');
	var newContent = document.getElementById(cid).innerHTML;
	var newTitle = document.getElementById(cid+"_title").innerHTML;
	var poloroid = document.getElementById('poloroid');
	poloroid.style.background = "url(../images/poloroid_blank.gif) no-repeat";
	container.innerHTML = newContent;
	title.style.background = "#FFFFFF";
	title.innerHTML = newTitle;
}

function show_gallery(gal) {
	preload(galleries[gal],gal);
	var container = document.getElementById('innerImage');
	var thumbs = document.getElementById('pageTitle');
	var firstPic = "gallery/"+gal+"/"+galleries[gal][0];
	
	var poloroid = document.getElementById('poloroid');
	var string = '';
	poloroid.style.background = "url(../images/poloroid_blank.gif) no-repeat";
	container.innerHTML = '<img id="toppic" src="images/poloroid_hold.gif" width="402" height="402" alt="Spitting Image" />';
	
	for (i=0;i<8;i++) {
		if (i>galleries[gal].length) break;
		string += '<a href="Javascript:changePic(\''+gal+'\','+i+')"><img id="thumb'+i+'" src="gallery/'+gal+'/tn/'+galleries[gal][i]+'" onMouseOver="fadeThumb(\'thumb'+i+'\',50);" onMouseOut="fadeThumb(\'thumb'+i+'\',99);" width="28" height="28" alt="'+gal+'" border="0" style="padding:1px;" /></a>';
		if ((i+1)%4 == 0) string += "<br />";	
	}
	thumbs.style.width = "121px";
	thumbs.style.marginLeft = "70px";
	thumbs.style.marginTop = "190px";
	thumbs.style.background = "#e28151";
	thumbs.innerHTML = string;
	setOpacity('thumb0',50);
	crossfade(document.getElementById('toppic'), firstPic, '1.5', 'Spitting Image');
}
function changePic(gal,i) {
	var newPic = "gallery/"+gal+"/"+galleries[gal][i];
	for (j=0;j<8;j++) 
	{
		if(j!=i) setOpacity('thumb'+j+'', 99);
		else setOpacity('thumb'+j+'', 50);
		
	}
	crossfade(document.getElementById('toppic'), newPic, '1.5', 'Spitting Image');
}
function loadFlash () {
	
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="102" height="101" title="Music Player">');
        document.write('<param name="movie" value="flash/player.swf" />');
        document.write('<param name="quality" value="high" />');
		document.write('<PARAM NAME=FlashVars VALUE="song=music/song.mp3">');
        document.write('<embed src="flash/player.swf" FlashVars="song=music/song.mp3" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="102" height="101"></embed>');
    	document.write('</object>');

}
