function DefineLrgImg(src) {
		
	Img = new Image();
			
	var BaseImgName = new String(src);
			
	var l = BaseImgName.length;
	var s = BaseImgName.lastIndexOf("/");
	var e = BaseImgName.lastIndexOf(".");
	var full = BaseImgName.lastIndexOf("-"); //wordpress adds "-350x450"or whatever the dimensions are after the original filename before the "."
			
	//alert(l + " -- " + s + " -- " + e);
	//alert(s);		
	if(full<s){
		full=e;
	}		
	var path = BaseImgName.substring(0,(s+1));
	var file = BaseImgName.substring((s+1),full);
	var ext = BaseImgName.substring(e,l);
			
	//alert(path + " -- " + file + " -- " + ext);
			
	Img.src = path + file + ext;
				
}

function LoadJPG(src) {
	var ran = Math.round(100*Math.random())
	Img_ = new Image();
	Img_.src = src + "?" + ran;
	Img_.onload = ProcessJPG;
}
	
function ProcessJPG() {

	var media = document.getElementById("media-holder");
	
	media.style.width = Img_.width + "px";
	media.style.height = Img_.height + "px";
	//alert("Image width: " + Img_.width + " - Image height: " + Img_.height);
	
	var spacerImg = "";
	if(Img_.height < 350)
	{
		var offset = parseInt((350 - Img_.height)/2);
		var spacerImg = "<img src=\"/wp-content/themes/trigger/images_interface/p.gif\" width=\"1\" height=\"" + offset + " alt=\"\" />";
	}
	
	//media.style.display = "block";
	
	//document.getElementById("right-block").style.visibility = "visible";
	
	var img_str = new String(Img_.src);
	
	if(img_str.indexOf(".jpg") != -1 && img_str.indexOf("interactive") == -1) {
		//if we find .jpg and don't find interactive then run large image code
		
		media.innerHTML = spacerImg + "<img src=\"" + Img_.src + "\" alt=\"\" width=\"" + Img_.width + "\" height=\"" + Img_.height + "\" border=\"0\" class=\"lightbox\" title=\"click to enlarge\" />";
	
		media.onclick = LoadJPG_lrg;
			
		DefineLrgImg(Img_.src);
	}
	else {
	
		media.innerHTML = spacerImg + "<img src=\"" + Img_.src + "\" alt=\"\" width=\"" + Img_.width + "\" height=\"" + Img_.height + "\" border=\"0\" class=\"lightbox\" title=\"\" />";
		
		media.onclick = DoNothing;
	}
	
	setTimeout("HideLoading()",500);
}
			
function LoadJPG_lrg() {
			
	//alert("Image width: " + Img.width + " - Image height: " + Img.height);
	
	document.getElementById("image-display").style.width = (Img.width + 20) + "px";
	document.getElementById("image-display").style.height = Img.height + "px";
			
	document.getElementById("shadow-part1").style.width = Img.width + "px";
			
	document.getElementById("image-large").innerHTML = '<img src="' + Img.src + '" alt="" width="' + Img.width + '" height="' + Img.height + '" title=\"click to close\" border="0" />';		
			
	document.getElementById("media-large").style.display = "block";
}
		
function LoadFlash(src,type) {
	
	var media = document.getElementById("media-holder");
	
	media.style.width = "580px";
	media.style.height = "350px";
	
	if(type == "mp3") {
		var so = new SWFObject("/wp-content/themes/trigger/flash/mp3Player.swf", "trigger", "580", "350", "6", "#ffffff");
	}
	else if(type == "swf") {
		var so = new SWFObject("/wp-content/themes/trigger/flash/swfPlayer.swf", "trigger", "580", "350", "7", "#ffffff");
	}
	else {
		//var so = new SWFObject("/wp-content/themes/trigger/flash/mediaPlayer.swf", "trigger", "580", "350", "8", "#ffffff");	
		var so = new SWFObject("/wp-content/themes/trigger/flash/player.swf","trigger","580", "350", "9", "#ffffff");
		so.addVariable('file',src);
		so.addVariable('fullscreen',false);
		so.addVariable('image',src + '.jpg');
	}
			
	so.addVariable('src',src);
	so.addVariable('autostart',false);		
	so.addParam("allowScriptAccess","always");
	so.addParam("menu", "false");
	so.addParam("wmode", "transparent");
	so.write("media-holder");
	
	//media.style.display = "block";
	
	setTimeout("HideLoading()",500);
	
	media.onclick = DoNothing;
	
	//alert("the height is: " + so.getAttribute("height"));
}

function DoNothing() {
	//do nothing
}

function HideLoading() {
	document.getElementById("media-loading").style.display = "none";
}
		
function SetDisplay(obj,state) {
	obj.style.display = state;
}