function Toggle(a)
{
	$(a).toggle();
}

function News(a)
{
	$(a).toggle();
	ChangePicture(a);
}

function ChangePicture(a)
{
	id = 'pic' + a;
	var value = $(a);
	var img = $(id);

	if (value.getStyle('display') == 'none')
	{
		img.src = 'themes/images/plus.gif';
	}
	else
	{
		img.src = 'themes/images/minus.gif';
	}
}

var checkflag = false;
function SelectAll(form, input)
{
	if (checkflag == false)
	{
		$(form).getInputs('checkbox', input).each(function(value)
		{
			value.checked = true;
		});
		checkflag = true;
		return 'Kijelölés törlése';
	}
	else
	{
		$(form).getInputs('checkbox', input).each(function(value)
		{
			value.checked = false;
		});
		checkflag = false;
		return 'Mindet kijelöl';
	}
}

function ShowCover(id, image)
{
	var item = $('cover' + id);

	item.show();
	item.innerHTML = '<img src="' + image + '" alt="" width="200px" />';
}

function HideCover(id)
{
	$('cover' + id).hide();
}

function StickyShowCover(id, image)
{
	var item = $('sticky-cover' + id);

	item.show();
	item.innerHTML = '<img src="' + image + '" alt="" width="200px" />';
}

function StickyHideCover(id)
{
	$('sticky-cover' + id).hide();
}

function DisplayPoll()
{
	new Ajax.Request('poll.php?action=display',
	{
		method:'post',
		parameters: {},
		onSuccess: function(transport){
			var response = transport.responseText;
			$('poll_container').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('poll_container').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function ProcessPoll()
{
	inputs = $('pollform').getInputs('radio');
	selected = false;
	
	for (var i = 0; i < inputs.length; ++i)
	{
		if(inputs[i].checked)
		{
			selected = true;
			break;
		}
	}
	
	if (selected == true)
	{
		new Ajax.Request('poll.php?action=process',
		{
			method:'post',
			parameters: $('pollform').serialize(true),
			onSuccess: function(transport){
				DisplayPoll();
			},
			onFailure: function(){ 
				alert('There was an error with the connection.');
				$('poll_container').innerHTML = 'There is not data which can be displayed.';
			}
		});
	}
	else 
	{
		alert('Válassz ki egy opciót!');
	}
}

function PreView()
{
	var data = $('preview-textarea').value;

	new Ajax.Request('../preview.php',
	{
		method:'post',
		parameters: { data: data },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('preview').innerHTML = response;
			document.location.href = '#preview';
		},
		onFailure: function(){ 
			alert('There was an error with the connection.');
			$('preview').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function ActiveTab(number)
{
	list = $A($('tabbed-menu-ul').childElements('li'));

	for (var i = 0; i < list.length; i++)
	{
		if (i == number)
			list[i].className = 'isactive';
		else
			list[i].className = '';
	}
}

var pixel = 0;
var timer;

function ProgressBar()
{
	$('progress').setStyle({backgroundPosition: pixel + 'px'});
	pixel = pixel + 2;
	timer = setTimeout('ProgressBar()', 25);
}


function LoadProgress()
{
	var item = $('loading');

	item.setStyle({
		width: 740 + 'px',
		marginTop: 0 + 'px',
		display: 'block',
		verticalAlign: 'middle'
	});

	item.innerHTML = '<div id="progress"></div>';

	$('progress').setStyle({marginTop: 3 + 'px'});
	ProgressBar();
}

function CommentPager(perpage, page, id)
{
	new Ajax.Request('torrent_details.php?action=displaycomments',
	{
		method:'post',
		parameters: { perpage: perpage, page: page, id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('commenttable').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('commenttable').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function WriteComment(id)
{
	new Ajax.Request('torrent_details.php?action=writecomment',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('write-commment').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('write-commment').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function AddComment()
{
	field = $('preview-textarea');

	if (field.value == '')
	{
		alert('Üres a szövegmező!');
		field.focus();
	}
	else
	{
		new Ajax.Request('torrent_details.php?action=addcomment',
		{
			method:'post',
			parameters: $('commentform').serialize(true),
			onSuccess: function(transport){
				var response = transport.responseText;
				if (response == 'NoTorrent')
				{
					alert('Nincs torrent ilyen ID-vel!');
				}
				else if (response == 'DisabledPost')
				{
					alert('Le vannak tiltva a hozzászólások ehhez a torrenthez!');
				}
				else if (response == 'CantPost')
				{
					alert('Le van tiltva a hozzászólási jogod!');
				}
				else if (response == 'InvalidId')
				{
					alert('Érvénytelen torrent ID!');
				}
				else
				{
					CommentPager(20, 0, response)
					document.location.href="";
				}
			},
			onFailure: function(){
				alert('There was an error with the connection.');
				$('write-commment').innerHTML = 'There is not data which can be displayed.';
			}
		});
	}
}

function Preferences(section)
{
	LoadProgress();
	$('user-panel').setOpacity(0.5);
	//$('user-panel').setStyle({background: '#000'});

	new Ajax.Request('profile_settings.php?action=' + section,
    {
		method:'post',
		parameters: {},
		onSuccess: function(transport){
			var response = transport.responseText;
			$('user-panel').innerHTML = response;
			$('loading').innerHTML = '';
			$('loading').hide();
			$('user-panel').setOpacity(1);
			//$('user-panel').setStyle({background: 'none'});
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('user-panel').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Logout()
{
    document.location.href='../logout.php';
}

function UpdateProfile(section)
{
	LoadProgress();
	$('user-panel').setOpacity(0.5);
	//$('user-panel').setStyle({background: '#000'});

	new Ajax.Request('updateprofile.php?action=' + section,
    {
		method:'post',
        parameters: $('userform').serialize(true),
        onSuccess: function(transport){
			var response = transport.responseText;
			$('loading').innerHTML = '';
			$('loading').hide();
			$('user-panel').setOpacity(1);
			$('user-panel').setStyle({background: 'none'});
			$('notifications').show();

			if (response == 'PasswordUpdated')
			{
				$('notifications').innerHTML = 'A jelszavad frissítése sikeresen megtörtént! A rendszer automatikusan kiléptet!';
                Logout();
            }
			else if (response == 'InvalidPass')
			{
				$('notifications').innerHTML = 'Érvénytelen jelszó.';
			}
            else if (response == 'InvalidEmail')
            {
                $('notifications').innerHTML = 'Érvénytelen e-mail cím.';
            }
            else if (response == 'UsedEmail')
            {
                $('notifications').innerHTML = 'Az e-mail címet már használják.';
            }
			else if (response == 'EmailUpdated')
			{
				$('notifications').innerHTML = 'Megerősítő e-mail az új címedre elküldve! Kizárólag a megerősítés után frissül az e-mail címed!';
			}
            else if (response == 'PasswordTooLong')
            {
                $('notifications').innerHTML = 'A jelszó túl hosszú maximum 40 karakter.';
            }
            else if (response == 'PasswordDidntMatch')
            {
                $('notifications').innerHTML = 'A jelszó nem egyezik. Próbáld újra.';
            }
			else
			{
				$('notifications').innerHTML = response;
			}
			document.location.href='#tabbed-menu-ul';
		},
		onFailure: function(transport) {
			var response = transport.responseText;
			$('loading').innerHTML = '';
			$('loading').hide();
			$('user-panel').setOpacity(1);
			//$('user-panel').setStyle({background: 'none'});
			$('notifications').show();
			$('notifications').innerHTML = 'A profil nem lett frissítve!';
		}
	});

	return false;
}

function UserInfo(id)
{
	new Ajax.Request('profile.php?action=userinfo',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('userinfo').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('userinfo').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SeederList(id)
{
	new Ajax.Request('profile.php?action=seeder',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('seederlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('seederlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function LeecherList(id)
{
	new Ajax.Request('profile.php?action=leecher',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('leecherlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('leecherlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function UploadedList(id)
{
	new Ajax.Request('profile.php?action=uploaded',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('uploadedlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('uploadedlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SnatchedList(id)
{
	new Ajax.Request('profile.php?action=snatched',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('snatchedlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('snatchedlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function IncompletedList(id)
{
	new Ajax.Request('profile.php?action=incompleted',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('incompletedlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('incompletedlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function PeerList(id)
{
	new Ajax.Request('torrent_details.php?action=peerlist',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('peerlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('peerlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function FileList(id)
{
	new Ajax.Request('torrent_details.php?action=filelist',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('filelist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('filelist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SameTorrent(id)
{
	new Ajax.Request('torrent_details.php?action=sametorrent',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('sametorrentlist').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('sametorrentlist').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SearchUser()
{
    user = $('user').value;
    LoadProgress();

    if(user.length > 3)
    {
	    new Ajax.Request('profile.php?action=search',
	    {
		    method:'post',
		    parameters: { user: user },
		    onSuccess: function(transport){
			    var response = transport.responseText;
                $('loading').innerHTML = '';
                $('loading').hide();
			    $('response').innerHTML = response;
		    },
		    onFailure: function(){
			    alert('There was an error with the connection.');
			    $('response').innerHTML = 'There is not data which can be displayed.';
		    }
	    });
    }
}

function SearchUserClean()
{
    var user = $('user').value = '';
}

function UsersForbidden(section)
{
	LoadProgress();
	$('user-panel').setOpacity(0.5);
	//$('user-panel').setStyle({background: '#000'});

	new Ajax.Request('users_forbidden.php?action=' + section,
    {
		method:'post',
		parameters: {},
		onSuccess: function(transport){
			var response = transport.responseText;
			$('user-panel').innerHTML = response;
			$('loading').innerHTML = '';
			$('loading').hide();
			$('user-panel').setOpacity(1);
			//$('user-panel').setStyle({background: 'none'});
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('user-panel').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Uploaders(section)
{
	LoadProgress();
	$('user-panel').setOpacity(0.5);
	//$('user-panel').setStyle({background: '#000'});

	new Ajax.Request('uploaders.php?action=' + section,
    {
		method:'post',
		parameters: {},
		onSuccess: function(transport){
			var response = transport.responseText;
			$('user-panel').innerHTML = response;
			$('loading').innerHTML = '';
			$('loading').hide();
			$('user-panel').setOpacity(1);
			//$('user-panel').setStyle({background: 'none'});
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('user-panel').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Shoutbox()
{
	new Ajax.Request('shoutbox.php?action=display',
	{
		method:'post',
		parameters: { },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('shoutbox').innerHTML = response;
            setTimeout('Shoutbox()', 30000);
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('shoutbox').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function OnlineUsers()
{
	new Ajax.Request('shoutbox.php?action=online_users',
	{
		method:'post',
		parameters: { },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('online_users').innerHTML = response;
            setTimeout('online_users()', 10000);
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('online_users').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function AddMessage()
{
	new Ajax.Request('shoutbox.php?action=addmessage',
	{
		method:'post',
		parameters: $('shoutboxform').serialize(true),
		onSuccess: function(transport){
			var response = transport.responseText;
            document.forms["shoutboxform"].text.value = ''
			Shoutbox();
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('shoutbox').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function DeleteMessage(id)
{
    if (confirm("Biztosan Törölni akarod?"))
    {
	    new Ajax.Request('shoutbox.php?action=deletemessage',
	    {
		    method:'post',
		    parameters: { id: id },
		    onSuccess: function(transport){
			    var response = transport.responseText;
			    Shoutbox();
		    },
		    onFailure: function(){
			    alert('There was an error with the connection.');
			    $('shoutbox').innerHTML = 'There is not data which can be displayed.';
		    }
	    });
    }
}

function StaffShoutbox()
{
	new Ajax.Request('staff_shoutbox.php?action=display',
	{
		method:'post',
		parameters: { },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('shoutbox').innerHTML = response;
            setTimeout('StaffShoutbox()', 30000);
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('shoutbox').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function StaffAddMessage()
{
	new Ajax.Request('staff_shoutbox.php?action=addmessage',
	{
		method:'post',
		parameters: $('shoutboxform').serialize(true),
		onSuccess: function(transport){
			var response = transport.responseText;
            document.forms["shoutboxform"].text.value = ''
			StaffShoutbox();
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('shoutbox').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function StaffDeleteMessage(id)
{
    if (confirm("Biztosan Törölni akarod?"))
    {
	    new Ajax.Request('staff_shoutbox.php?action=deletemessage',
	    {
		    method:'post',
		    parameters: { id: id },
		    onSuccess: function(transport){
			    var response = transport.responseText;
			    StaffShoutbox();
		    },
		    onFailure: function(){
			    alert('There was an error with the connection.');
			    $('shoutbox').innerHTML = 'There is not data which can be displayed.';
		    }
	    });
    }
}

function TorrentsMenu(section)
{
	new Ajax.Request('torrents-menu.php?action=' + section,
	{
		method:'post',
		parameters: { },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browsemenu-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browsemenu-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Torrents(update)
{
	new Ajax.Request('browse.php?action=torrents',
	{
		method:'post',
		parameters: { update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function TorrentsPager(page,order,sort,update)
{
	new Ajax.Request('browse.php?action=torrents',
	{
		method:'post',
		parameters: { page: page, order: order, sort: sort, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Category(category,update)
{
	new Ajax.Request('browse.php?action=category',
	{
		method:'post',
		parameters: { category: category, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function CategoryPager(category,page,order,sort,update)
{
	new Ajax.Request('browse.php?action=category',
	{
		method:'post',
		parameters: { category: category, page: page, order: order, sort: sort, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Genre(genre,type,update)
{
	new Ajax.Request('browse.php?action=genre',
	{
		method:'post',
		parameters: { genre: genre, type: type, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function GenrePager(genre,type,page,order,sort,update)
{
	new Ajax.Request('browse.php?action=genre',
	{
		method:'post',
		parameters: { genre: genre, type: type, page: page, order: order, sort: sort, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Group(category,update)
{
	new Ajax.Request('browse.php?action=group',
	{
		method:'post',
		parameters: { category: category, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function GroupPager(category,page,order,sort,update)
{
	new Ajax.Request('browse.php?action=group',
	{
		method:'post',
		parameters: { category: category, page: page, order: order, sort: sort, update: update },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SearchTorrent()
{
	new Ajax.Request('browse.php?action=search',
	{
		method:'post',
		parameters: $('searchform').serialize(true),
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SearchTorrentClear()
{
    $('text').value = '';
}

function SearchTorrentPager(page,order,sort)
{
    var text = $('text').value;
    var state = $('state').value;
    var favor = $('favor').value;
    var type = $('type').value;
    var category = $('category').value;

	new Ajax.Request('browse.php?action=search',
	{
		method:'post',
		parameters: { page: page, order: order, sort: sort, text: text, state: state, favor: favor, type: type, category: category },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function FastSearch(search)
{
    if(search.length > 2)
    {
	    new Ajax.Request('browse.php?action=fastsearch',
	    {
		    method:'post',
		    parameters: { search: search },
		    onSuccess: function(transport){
			    var response = transport.responseText;
			    $('suggestions').innerHTML = response;
                $('suggestions').show();
		    },
		    onFailure: function(){
			    alert('There was an error with the connection.');
			    $('suggestions').innerHTML = 'There is not data which can be displayed.';
		    }
	    });
    }
}

function FastSearchRequest(search)
{
    if(search.length > 2)
    {
	    new Ajax.Request('requests_browse.php?action=fastsearch',
	    {
		    method:'post',
		    parameters: { search: search },
		    onSuccess: function(transport){
			    var response = transport.responseText;
			    $('suggestions').innerHTML = response;
                $('suggestions').show();
		    },
		    onFailure: function(){
			    alert('There was an error with the connection.');
			    $('suggestions').innerHTML = 'There is not data which can be displayed.';
		    }
	    });
    }
}

function Fill(text) {
	$('text').value = text;
	setTimeout("$('suggestions').hide();", 200);
}

function AddGenre(add)
{
    var added = document.getElementById('genre').value.toLowerCase();
    var matchRe = new RegExp(add.toLowerCase());

    if (matchRe.test(added))
        return false;

    document.getElementById('genre').value = document.getElementById('genre').value.replace(/,[\ ]*$/, '');
    document.getElementById('genre').value += (added ? ',' : '') + add;

    return true;
}

function AddGenreType(add)
{
    $('type').value = add;
}

function SearchGenre()
{

	new Ajax.Request('browse.php?action=searchgenre',
	{
		method:'post',
		parameters: $('genreform').serialize(true),
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SearchGenreClear()
{
    $('genre').value = '';
    $('type').value = '';
}

function SearchGenrePager(page,order,sort)
{
    var genre = $('genre').value;
    var type = $('type').value;

	new Ajax.Request('browse.php?action=searchgenre',
	{
		method:'post',
		parameters: { page: page, order: order, sort: sort, genre: genre, type: type },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function ViewNFO(id)
{
	elem = 'details-nfo' + id;
	var item = $(elem);
	
	if (item.getStyle('display') == 'none' && item.innerHTML == '')
	{
		new Ajax.Request('torrent_details.php?action=nfo',
		{
			method:'post',
			parameters: { id: id },
			onSuccess: function(transport){
				var response = transport.responseText;
				item.innerHTML = response;
				item.show();
			},
			onFailure: function(){ 
				alert('There was an error with the connection.');
				item.innerHTML = 'There is not data which can be displayed.';
				item.show();
			}
		});
	}
	else if (item.getStyle('display') == 'none' && item.innerHTML != '')
		item.show();
	else
		item.hide();
}

function BookmarkPager(page)
{
	new Ajax.Request('torrents-menu.php?action=bookmark',
	{
		method:'post',
		parameters: { page: page },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('browsemenu-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browsemenu-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function AddBookmark(id)
{
	new Ajax.Request('bookmark.php?action=add',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
            if (response == 'Invalid')
            {
                alert('Érvénytelen ID.');
            }
            else if (response == 'Already')
            {
                alert('Már szerepel a könyvjelzőid között!');
            }
            else
            {
                alert('Hozzáadva a könyvjelzőidhez.');
            }
		},
		onFailure: function(){
			alert('There was an error with the connection.');
		}
	});
}

function AddThanks(id)
{
	new Ajax.Request('torrent_details.php?action=addthanks',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			if (response == 'Invalid')
            {
                alert('Érvénytelen ID.');
            }
            else if (response == 'Already')
            {
                alert('Ez a Te feltöltésed.');
            }
            else
            {
                alert('Sikeresen megköszönve.');
				DisplayThanks(id);
            }
		},
		onFailure: function(){
			alert('There was an error with the connection.');
		}
	});
}

function DisplayThanks(id)
{
	new Ajax.Request('torrent_details.php?action=displaythanks',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('thanks').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
		}
	});
}

function DeleteBookmark(id)
{
	new Ajax.Request('bookmark.php?action=delete',
	{
		method:'post',
		parameters: { id: id },
		onSuccess: function(transport){
			var response = transport.responseText;
            if (response == 'Invalid')
            {
                alert('Érvénytelen ID.');
            }
            else
            {
                alert('Törölve a könyvjelzőid közül.');
                TorrentsMenu('bookmark');
            }
		},
		onFailure: function(){
			alert('There was an error with the connection.');
		}
	});
}

function RequestsMenu(section)
{
	new Ajax.Request('requests-menu.php?action=' + section,
	{
		method:'post',
		parameters: { },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browsemenu-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browsemenu-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function SelfPager(page)
{
	new Ajax.Request('requests-menu.php?action=self',
	{
		method:'post',
		parameters: { page: page },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browsemenu-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browsemenu-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function VotedPager(page)
{
	new Ajax.Request('requests-menu.php?action=voted',
	{
		method:'post',
		parameters: { page: page },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browsemenu-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browsemenu-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function Requests()
{
	new Ajax.Request('requests_browse.php?action=requests',
	{
		method:'post',
		parameters: { },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestsPager(page,order,sort)
{
	new Ajax.Request('requests_browse.php?action=requests',
	{
		method:'post',
		parameters: { page: page, order: order, sort: sort },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestsCategory(category)
{
	new Ajax.Request('requests_browse.php?action=category',
	{
		method:'post',
		parameters: { category: category },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestsCategoryPager(category,page,order,sort)
{
	new Ajax.Request('requests_browse.php?action=category',
	{
		method:'post',
		parameters: { category: category, page: page, order: order, sort: sort },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestsSearch()
{
	new Ajax.Request('requests_browse.php?action=search',
	{
		method:'post',
		parameters: $('searchform').serialize(true),
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestsSearchClear()
{
    $('text').value = '';
}

function RequestsSearchPager(page,order,sort)
{
    var text = $('text').value;
    var category = $('category').value;

	new Ajax.Request('requests_browse.php?action=search',
	{
		method:'post',
		parameters: { page: page, order: order, sort: sort, text: text, category: category },
		onSuccess: function(transport){
			var response = transport.responseText;
			$('requests-browse-response').innerHTML = response;
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('requests-browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestVote()
{

	new Ajax.Request('requests_browse.php?action=vote',
	{
		method:'post',
		parameters: $('voteform').serialize(true),
		onSuccess: function(transport){
			var response = transport.responseText;
            if (response == 'InvalidId')
            {
                alert('Érvénytelen kérés ID.');
            }
            else if (response == 'FewPoint')
            {
                alert('Kevés pontot adtál meg.');
            }
            else if (response == 'LittlePoint')
            {
                alert('Nincs elegendő pontod.');
            }
            else
            {
                alert('Sikeresen szavaztál a kérésre.');
            }
		},
		onFailure: function(){
			alert('There was an error with the connection.');
			$('browse-response').innerHTML = 'There is not data which can be displayed.';
		}
	});
}

function RequestDelete(id)
{
    if (confirm("Biztosan Törölni akarod?"))
    {
        new Ajax.Request('requests_browse.php?action=delete',
        {
            method:'post',
            parameters: { id: id },
            onSuccess: function(transport){
                var response = transport.responseText;
                if (response == 'InvalidId')
                {
                    alert('Érvénytelen kérés ID.');
                }
                else
                {
                    alert('Sikeresen törölve a kérés.');
                    document.location.href="../requests.php";
                }
            },
            onFailure: function(){
                alert('There was an error with the connection.');
            }
        });
    }
}

function ForumSearchOptions()
{
	var item = $('forum-search-options');
	
	if (item.getStyle('display') == 'none' && item.innerHTML == '')
	{
		new Ajax.Request('./search.php?action=options',
		{
			method:'post',
			parameters: { },
			onSuccess: function(transport){
				var response = transport.responseText;
				$('forum-search-options').innerHTML = response;
				$('forum-search-options').show();
			},
			onFailure: function(){ 
				alert('There was an error with the connection.');
				$('forum-search-options').innerHTML = 'There is not data which can be displayed.';
				$('forum-search-options').show();
			}
		});
	}
	else if (item.getStyle('display') == 'none' && item.innerHTML != '')
		item.show();
	else
		item.hide();
}

