function SayThanks(id,s,e)
{
	$.ajax({
				type: "POST",
				url: '/util.php',
				data: 'module=1&code=clean&act=say_thanks&secure='+s+'&torrent_id='+id,
				dataType: "json",
				success: function(obj)
				{
					if(!obj.error)
					{
						if(obj.result == 'ok')
						{
							$(e).fadeOut();
						}
					}
					else
					{
						switch(obj.error)
						{
							case 'repeat':
								alert('Вы уже благодарили за этот торрент.');
							break;
							case 'required_error':
								alert('Ошибка. Не все обязательные поля присутствуют.');
							break;
							case 'system_error':
								alert('Ошибка. Отсутствует, либо неверен ключ.');
							break;
						}

					}
				}
			});

	return;
}

function ShowRules()
{
	window.open('/rules.php?code=empty','rules','width=500,height=400');
}

function ShowHappyUsers(id,s,e)
{
	$.ajax({
				type: "POST",
				url: '/util.php',
				data: 'module=1&code=clean&act=show_happy_users&secure='+s+'&torrent_id='+id,
				dataType: "json",
				success: function(obj)
				{
					if(!obj.error)
					{
						if(obj.result == 'ok')
						{
							$(e).fadeOut();
							obj = obj.data;
							for(var key in obj)
							{
								$('#happy_users_list').append('<a href="/userdetails.php?id='+obj[key].userid+'" title="'+obj[key].classtitle+'">'+obj[key].username+'</a>, ');
							}
						}
					}
					else
					{
						switch(obj.error)
						{
							case 'required_error':
								alert('Ошибка. Не все обязательные поля присутствуют.');
							break;
							case 'system_error':
								alert('Ошибка. Отсутствует, либо неверен ключ.');
							break;
						}

					}
				}
			});
	return;
}

function in_array(needle, haystack, argStrict) 
{
// http://kevin.vanzonneveld.net
// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	var found = false, key, strict = !!argStrict;
	for (key in haystack) 
	{
		if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) 
		{
			found = true;
			break;
		}
	}
	return found;
}
/*
function ImgLoaded(el)
{
	alert('ddd');
	if($(el).width() > 400)
	{
		$(el).css({width:'400px'})
	}
	$(el).show();
}
*/
function getDelPerm()
{
	return window.confirm("Подтвердите удаление...");
}

var Url = { 
 
	// публичная функция для кодирования URL 
	encode : function (string) { 
		return escape(this._utf8_encode(string)); 
	}, 
 
	// публичная функция для декодирования URL 
	decode : function (string) { 
		return this._utf8_decode(unescape(string)); 
	}, 
 
	// приватная функция для кодирования URL 
	_utf8_encode : function (string) { 
		string = string.replace(/\r\n/g,"\n"); 
		var utftext = ""; 
 
		for (var n = 0; n < string.length; n++) { 
 
			var c = string.charCodeAt(n); 
 
			if (c < 128) { 
				utftext += String.fromCharCode(c); 
			} 
			else if((c > 127) && (c < 2048)) { 
				utftext += String.fromCharCode((c >> 6) | 192); 
				utftext += String.fromCharCode((c & 63) | 128); 
			} 
			else { 
				utftext += String.fromCharCode((c >> 12) | 224); 
				utftext += String.fromCharCode(((c >> 6) & 63) | 128); 
				utftext += String.fromCharCode((c & 63) | 128); 
			} 
 
		} 
 
		return utftext; 
	}, 
 
	// приватная функция для декодирования URL 
	_utf8_decode : function (utftext) { 
		var string = ""; 
		var i = 0; 
		var c = c1 = c2 = 0; 
 
		while ( i < utftext.length ) { 
 
			c = utftext.charCodeAt(i); 
 
			if (c < 128) { 
				string += String.fromCharCode(c); 
				i++; 
			} 
			else if((c > 191) && (c < 224)) { 
				c2 = utftext.charCodeAt(i+1); 
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 
				i += 2; 
			} 
			else { 
				c2 = utftext.charCodeAt(i+1); 
				c3 = utftext.charCodeAt(i+2); 
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 
				i += 3; 
			} 
 
		} 
 
		return string; 
	} 
 
}
