/* CHANGE SECTION */
function changeSection(mediaType, sectionName, page) {
	var url = "/actions/change_media_list.php";
	var params = "type=" + mediaType + "&section=" + sectionName + "&page=" + page;
	var aj = new Ajax.Request(
					url,
					{
						method: 'post',
						parameters: params,
						onSuccess: function(response) { $('media_scroll_content').innerHTML = response.responseText; $$('.section_active').each(function(elem){ elem.removeClassName('section_active')}); $('section_'+sectionName).addClassName('section_active'); }
					});
					
	return false;
}
function updateMediaList(response) {
	var showThis = response.responseText;
	$('media_scroll_content').innerHTML = showThis;
	
}

/* CHANGE SLIDESHOW */
function changeSlideshow(slideshowID) {
	var url = "/actions/change_media_slideshow.php";
	var params = "slideshowID=" + slideshowID;
	var aj = new Ajax.Request(
					url,
					{
						method: 'post',
						parameters: params,
						onSuccess: updateSlideshowContent
					});
	return false;
}
function updateSlideshowContent(response) {
	var splitted = response.responseText.split("<|>");
	$('media_view_scroller').innerHTML = splitted[1];
	$('media_view_slideshow').innerHTML = splitted[0];
}


/* CHANGE VIDEO */
function changeVideo(vidID) {
	var url = "/actions/change_media_video.php";
	var params = "videoID=" + vidID;
	var aj = new Ajax.Request(
					url,
					{
						method: 'post',
						parameters: params,
						onSuccess: updateVidContent
					});
	return false;
}
function updateVidContent(response) {
	var splitted = response.responseText.split("<|>");
	$('media_view_scroller').innerHTML = splitted[1];
	$('media_view_video').innerHTML = splitted[0];
}


/* CHANGE AUDIO */
function changeAudio(audioID) {
	var url = "/actions/change_media_audio.php";
	var params = "audioID=" + audioID;
	var aj = new Ajax.Request(
					url,
					{
						method: 'post',
						parameters: params,
						onSuccess: updateAudioContent
					});
	return false;
}
function updateAudioContent(response) {
	var splitted = response.responseText.split("<|>");
	$('media_view_scroller').innerHTML = splitted[0];
	$('media_view').innerHTML = '<embed style="z-index: 0;" wmode="transparent" src="/mp3player/mp3player.swf" width="340" height="20" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=/media/audio/' +  splitted[1] + '&height=20&width=340&frontcolor=0xd3d7e3&backcolor=0x002954&lightcolor=0xCC0000&screencolor=0x002954&autostart=true" />';
}


/* CHANGE PHOTO GALLERY */
function changePhotoGallery(galleryID) {
	var url = "/actions/change_photo_gallery.php";
	var params = "galleryID=" + galleryID;
	var aj = new Ajax.Request(
					url,
					{
						method: 'post',
						parameters: params,
						onSuccess: updatePhotoGallery
					});
	return false;
}
function updatePhotoGallery(response) {
	var splitted = response.responseText.split("<|>");
	slider2.setValue(0);
	$('media_title_top').innerHTML = splitted[0];
	$('media_view').innerHTML = '<table cellpadding="0" cellspacing="0"><tr><td valign="middle" align="center" width="350" height="260"><img src="/media/photos/gallery/' + splitted[1] + '" border="0" id="thephoto" /></td></tr></table>';
	$('photo_caption').innerHTML = splitted[2];
	$('media_view_scroller').innerHTML = splitted[5];
}

/* CHANGE PHOTO */
function changePhoto(photoID,galleryID) {
	var url = "/actions/change_photo.php";
	var params = "photoID=" + photoID + "&galleryID=" + galleryID;
	var aj = new Ajax.Request(
					url,
					{
						method:'post',
						parameters: params,
						onSuccess: updatePhoto
					});
	return false;
}
function updatePhoto(response) {
	var splitted = response.responseText.split("<|>");
	$('media_view').innerHTML = '<table cellpadding="0" cellspacing="0"><tr><td valign="middle" align="center" width="350" height="260"><img src="/media/photos/gallery/' + splitted[0] + '" border="0" id="thephoto" /></td></tr></table>';
	$('photo_caption').innerHTML = splitted[1];
}

function bigSlideshow($theurl) {
	
	$('slideshow_frame').innerHTML = '';
	myLightWindow.activateWindow({
		href: 'http://www.thefranklinonline.com/pop_slideshow.php?slideshow=' + theurl + ''
	});
}
