function gettype(filename) {
	var items = {"mp3": "audio/mpeg",  "avi": "video/x-msvideo",  "mpeg": "video/mpeg", "mpg": "video/mpeg", "mov": "video/quicktime", "wmv": "video/x-ms-wmv", "mp4": "video/mp4"};
	//
	var filenamearray = filename.split('.')
	var fl = filenamearray.length
	var lastone = fl - 1;	
	var thisext = filenamearray[lastone]
	//
	var mimetype = null
	//
	for (var ext in items) {
		if (ext == thisext) {
			var mimetype = items[ext]
			break
		}
	}
	return mimetype
}
function switchback(mimetype) {
	//stop the quicktime -- keeps playing because of a safari bug...
	if (($.browser.safari) && (mimetype == 'video/quicktime')) {
		document.thismedia.Stop();
	} 
	$('#videos').empty().fadeOut('slow')
}
//set relpath, which will point from where this javascript is called
var relpath = '../assets/';
function popitup(type, url, w, h) {
	if (type == 'image') {
		var fpath = relpath+'files_orig/'
		var width = w < 660 ? w + 40 : 700;
		var height = h < 460 ? h + 40 : 500;
		var imagepath = fpath+url
		var theurl = "return/popup.php?type=image&w="+width+"&="+height+"&url="+imagepath
		//pop it up
		window.open(theurl, "ai", "menubar=0, width="+width+", height="+height+", scrollbars=1, status=0, titlebar=0, toolbar=0, resizable=1")
	} else {
		var mimetype = gettype(url)
		//
		var fpath = relpath+'files_media/'
		var width = w ? w + 20 : 600;
		h += 15; //add 15 to the height to account for the controls
		var height = h ? h + 20 : 400;
		var mediapath = fpath+url
		var theurl = "return/loadmedia.php?mimetype="+mimetype+"&mediapath="+mediapath+"&w="+width+"&h="+height
	//	$('#flashcontent').fadeOut('fast');
		$('#videos').fadeIn('slow', function() {
			$(this).load(theurl)
		})
	}
}