//
// Copyright (c) 2007 Drew Wilson (http://www.drewwilson.com/)
//

function fireAccordion(theclass,theid) {
	var items = document.getElementsByClassName(theclass);
	for(i=0; i < items.length; i++) {
		var item = items[i];
		var ele = $(theid);
		if (item != ele){
		Effect.BlindUp(item,{duration:.4});
		}
	}
	Effect.BlindDown(theid,{duration:.4});
}

function fireClassStick(theclass,theid,newclass) {
	var items = document.getElementsByClassName(theclass);
	for(i=0; i < items.length; i++) {
		var item = items[i];
		var ele = $(theid);
		if (item != ele){
			var single = $(item);
			single.className = theclass;
		}
	}
	var ele = $(theid);
	ele.className = theclass+' '+newclass;
}

				function showImage(dir,img,rel,theid,thearray) {
						var placeholder = $('placeholder-'+theid);
						var arrayval = parseInt(arrayval);
						if (!$('imgLoading'+theid)){
							var imgLoading = document.createElement("div");
							imgLoading.setAttribute('id','imgLoading'+theid);
							imgLoading.innerHTML='<img src=\'http://muse.drewwilson.com/firebolt/images/spinner.gif\' alt=\'Loading Muse\' style=\'margin-top:165px;\' />';
							placeholder.appendChild(imgLoading);
						}					
						if ($('imageholder-'+theid)) {
							Element.remove('imageholder-'+theid);
						}	
						var d1 = document.createElement('img');
						d1.setAttribute('id','imageholder-'+theid);
						d1.setAttribute('rel',rel);
						d1.style.display='none';
						d1.src = dir+img;

						d1.onload=function(){
							Element.remove('imgLoading'+theid);
							placeholder.appendChild(d1);
							Effect.Appear('imageholder-'+theid);
						}
						if (rel == 0) {
							$('prevLink').style.visibility='hidden';
						} else {
							$('prevLink').style.visibility='visible';
						}
						if (rel == (thearray.length - 1)) {
							if (rel == 0) {
								$('nextLink').style.visibility='visible';
							} else {
								$('nextLink').style.visibility='hidden';
							}
						} else {
							$('nextLink').style.visibility='visible';
						}
						return false;						
			}


				function nextImage(dir,theid,thearray) {
						var theImage = $('imageholder-'+theid);
						var relAttribute = theImage.getAttribute('rel');
						relAttribute = relAttribute++;
						showImage(dir,thearray[relAttribute+1],relAttribute+1,theid,thearray);
						return false;
			}
			
				function prevImage(dir,theid,thearray) {
						var theImage = $('imageholder-'+theid);
						var relAttribute = theImage.getAttribute('rel');
						relAttribute = relAttribute--;
						showImage(dir,thearray[relAttribute-1],relAttribute-1,theid,thearray);
						return false;
			}

