// JavaScript Document

var loading = "<div class=\"loading\">&nbsp;</div>";





function show_albums(user_id) {
	
	//alert('showing abums');
}


function add_new_album() {
	
	var new_album = $('new_album').value;
	var new_time = get_time();
	var url = base_url + '/system/application/ajax/photo_system.php';
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'add_new_album', user_id: user_id, profile_id: profile_id, new_album: new_album, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		show_photo_albums();
	}	
}


function set_profile_photo(album_id, file_id) {
	
	var new_time = get_time();
	var url = base_url + '/system/application/ajax/photo_system.php';
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'set_profile_photo', user_id: user_id, profile_id: profile_id, album_id: album_id, file_id: file_id, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		$('profile_panel').innerHTML = req.responseText;
		get_profile_icon(200)
	}	
}

function get_profile_icon(photo_width) {
	
	var new_time = get_time();
	var url = base_url + '/system/application/ajax/photo_system.php';
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'get_profile_icon', user_id: user_id, profile_id: profile_id, photo_width: photo_width, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_photo').innerHTML = req.responseText;
		
	}	
}



function delete_user_photo(album_id, photo_id) {
	
	var new_time = get_time();
	var url = base_url + '/system/application/ajax/photo_system.php';
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'delete_photo', user_id: user_id, profile_id: profile_id, album_id: album_id, photo_id: photo_id, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		$('profile_panel').innerHTML = req.responseText;
	}	
}



function show_photo_albums() {
	
	var new_time = get_time();
	var url = base_url + '/system/application/ajax/photo_system.php';
	$('profile_panel').innerHTML = loading;
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'show_photo_albums', profile_id: profile_id, user_id: user_id, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_panel').innerHTML = req.responseText;
	}
}



function show_photo_album(album_id) {
	
	var new_time = get_time();
	$('profile_panel').innerHTML = loading;
	var url = base_url + '/system/application/ajax/photo_system.php';
	$('profile_panel').innerHTML = loading;
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'show_photo_album', profile_id: profile_id, user_id: user_id, album_id: album_id, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_panel').innerHTML = req.responseText;
	}
}

function set_album_cover(album_id, photo_id) {
	
	var new_time = get_time();
	var url = base_url + '/system/application/ajax/photo_system.php';
	
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'set_album_cover', user_id: user_id, profile_id: profile_id, album_id: album_id, photo_id: photo_id, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_panel').innerHTML = req.responseText;
	}
}

function edit_photo_caption(photo_id, album_id, caption_id) {
	
	var new_time = get_time();
	var new_caption = $(caption_id).value;
	
	var url = base_url + '/system/application/ajax/photo_system.php';
	
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'edit_photo_caption', user_id: user_id, profile_id: profile_id, photo_id: photo_id, album_id: album_id, new_caption: new_caption, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_panel').innerHTML = req.responseText;
	}
}

function move_photo(photo_id, album_id, move_id) {
	
	var new_time = get_time();
	var move_to = $(move_id).value;
	$('profile_panel').innerHTML = loading;
	var url = base_url + '/system/application/ajax/photo_system.php';
	
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'move_photo', user_id: user_id, profile_id: profile_id, photo_id: photo_id, album_id: album_id, move_to: move_to, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_panel').innerHTML = req.responseText;
	}
}

function change_album_name(album_id) {
	
	var new_time = get_time();
	var new_album_name = $('new_album_title_text_' + album_id).value;
	var url = base_url + '/system/application/ajax/photo_system.php';
	
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'change_album_name', user_id: user_id, profile_id: profile_id, album_id: album_id, new_album_name: new_album_name, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		
		$('profile_panel').innerHTML = req.responseText;
	}
}

function delete_photo_album(album_id, move_delete) {
	
	var new_time = get_time();
	//alert(move_delete);
	var photo_option = $(move_delete).value;
		
	var url = base_url + '/system/application/ajax/photo_system.php';
	
	new Ajax.Request(url, {
		method: 'get',
		parameters: {do_this: 'delete_photo_album', user_id: user_id, profile_id: profile_id, album_id: album_id, photo_option: photo_option, time: new_time },
		onComplete: showResponse 

	});
	
	function showResponse(req){
		//alert(req.responseText);
		$('profile_panel').innerHTML = req.responseText;
	}
}
