var req;
function saveCustomizeFriends()
{
	this.Update = function( friendsList , row)
	{
		var loc = encodeURIComponent(window.location.href);
		//alert( page )
		req = new Ajax.Request('saveAlbumsCustomizeFriends.php',
		{
			method:'post',
			parameters:'friends_list='+friendsList + '&row='+row,
			onSuccess: function(Response)
			{
				document.getElementById('added_friends_div').innerHTML = Response.responseText;
				document.getElementById('username').value = '';
				document.getElementById('btn_go').disabled = false;
			},
			onLoading:function()
			{
			},
			onFailure:function()
			{
				alert('fail');
			}
		});
		
		this.hideBox1 = function () {
			hideBox();
		}
	}
}

function deleteCustomizeFriends()
{
	this.Update = function(customRecordID,row)
	{
		var loc = encodeURIComponent(window.location.href);
		req = new Ajax.Request('saveAlbumsCustomizeFriends.php',
		{
			method:'post',
			parameters:'custom_record_id='+customRecordID+'&row='+row,
			onSuccess: function(Response)
			{
				document.getElementById('added_friends_div').innerHTML = Response.responseText;
			},
			onLoading:function()
			{
			},
			onFailure:function()
			{
				alert('fail');
			}
		});
		
		this.hideBox1 = function () {
			hideBox();
		}
	}
}

function deleteSessionFriends()
{
	this.Update = function(friendid,row)
	{
		var loc = encodeURIComponent(window.location.href);
		req = new Ajax.Request('saveAlbumsCustomizeFriends.php',
		{
			method:'post',
			parameters:'custom_record_id=' + friendid + '&row=' + row + '&session=1',
			onSuccess: function(Response)
			{
				document.getElementById('added_friends_div').innerHTML = Response.responseText;
			},
			onLoading:function()
			{
			},
			onFailure:function()
			{
				alert('fail');
			}
		});
		
		this.hideBox1 = function () {
			hideBox();
		}
	}
}

function albumPopUp()
{
	this.Update = function( row )
	{
		var loc = encodeURIComponent(window.location.href);
		req = new Ajax.Request('addAlbumPopUp.php',
		{
			method:'post',
			parameters:'row='+row+'&LocationHeader='+loc,
			onSuccess: function(Response)
			{
				hideSelectBoxes();
				$('page_overlay_box').style.width = '600px';
				$('page_overlay_box').style.height = '500px';
				$('page_overlay_box').update(Response.responseText);
				center('page_overlay_box',500,500);
				$('image_overlay').hide();
				$('page_overlay_box').show();
			},
			onLoading:function()
			{
				showBox();
			},
			onFailure:function()
			{
				alert('fail');
				hideBox();
			}
		});
		
		this.hideBox1 = function () {
			hideBox();
		}
	}
	
	this.CheckFields = function()
	{
		return false;
	}
}

function addAlbum()
{
	this.Update = function(Title, Description, CategoryId, privacyValue, userComments, photorating, Owner, submitalbum, Friends)
	{
		var loc = encodeURIComponent(window.location.href);
		req = new Ajax.Request('addAlbumPopUp.php',
		{
			method:'post',
			parameters:'submitalbum='+submitalbum+'&Title='+Title+'&Description='+Description+'&CategoryId='+CategoryId+'&privacyValue='+privacyValue+'&userComments='+userComments+'&photorating='+photorating+'&Owner='+Owner+'&Friends='+Friends,
			onSuccess: function(Response)
			{
				document.getElementById('AlbumList').innerHTML = Response.responseText;	
				privacyVisibility();
				$('page_overlay_box').style.width = '0%';
				$('page_overlay_box').style.height = '0%';
				$('page_overlay_box').update('');
				$('page_overlay_box').hide();
				hideBox();
			},
			onLoading:function()
			{
				showBox();
			},
			onFailure:function()
			{
				alert('fail');
				hideBox();
			}
		});
		
		this.hideBox1 = function () {
			hideBox();
		}
	}
	
	this.CheckFields = function()
	{
		return false;
	}
}

function Cancel(req)
{
	req.transport.abort();	
	$('page_overlay_box').style.width = '0%';
	$('page_overlay_box').style.height = '0%';
	$('page_overlay_box').update('');
	$('page_overlay_box').hide();	
	hideBox();
	showSelectBoxes();
}

var saveFriends = new saveCustomizeFriends();
var deleteFriend = new deleteCustomizeFriends();
var deleteSessionFriend = new deleteSessionFriends();
var albumPopupWin = new albumPopUp();
var submitPhotoAlbum = new addAlbum();