
		// remote scripting library
		// (c) copyright 2005 modernmethod, inc
		var sajax_debug_mode = false;
		var sajax_request_type = "POST";
		var sajax_target_id = "";
		var sajax_failure_redirect = "";

		function sajax_debug(text) {
			if (sajax_debug_mode)
				alert(text);
		}

 		function sajax_init_object() {
 			sajax_debug("sajax_init_object() called..")

 			var A;

 			var msxmlhttp = new Array(
//				'Msxml2.XMLHTTP.5.0',
				'Msxml2.XMLHTTP.4.0',
				'Msxml2.XMLHTTP.3.0',
				'Msxml2.XMLHTTP',
				'Microsoft.XMLHTTP');
			for (var i = 0; i < msxmlhttp.length; i++) {
				try {
					A = new ActiveXObject(msxmlhttp[i]);
				} catch (e) {
					A = null;
				}
			}

			if(!A && typeof XMLHttpRequest != "undefined")
				A = new XMLHttpRequest();
			if (!A)
				sajax_debug("Could not create connection object.");
			return A;
		}

		var sajax_requests = new Array();

		function sajax_cancel() {
			for (var i = 0; i < sajax_requests.length; i++)
				sajax_requests[i].abort();
		}

		function sajax_do_call(func_name, args) {
			var i, x, n;
			var uri;
			var post_data;
			var target_id;

			sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id);
			target_id = sajax_target_id;
			if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "")
				sajax_request_type = "GET";

			uri = "http://mlm.linky.hu/linkertekeles";
			if (sajax_request_type == "GET") {

				if (uri.indexOf("?") == -1)
					uri += "?rs=" + escape(func_name);
				else
					uri += "&rs=" + escape(func_name);
				uri += "&rst=" + escape(sajax_target_id);
				uri += "&rsrnd=" + new Date().getTime();

				for (i = 0; i < args.length-1; i++)
					uri += "&rsargs[]=" + escape(args[i]);

				post_data = null;
			}
			else if (sajax_request_type == "POST") {
				post_data = "rs=" + escape(func_name);
				post_data += "&rst=" + escape(sajax_target_id);
				post_data += "&rsrnd=" + new Date().getTime();

				for (i = 0; i < args.length-1; i++) {
					post_data = post_data + "&rsargs[]=" + escape(args[i]);
				}

			}
			else {
				alert("Illegal request type: " + sajax_request_type);
			}

			x = sajax_init_object();
			if (x == null) {
				if (sajax_failure_redirect != "") {
					location.href = sajax_failure_redirect;
					return false;
				} else {
					sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent);
					return false;
				}
			} else {
				x.open(sajax_request_type, uri, true);
				// window.open(uri);

				sajax_requests[sajax_requests.length] = x;

				if (sajax_request_type == "POST") {
					x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
					x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
				}

				x.onreadystatechange = function() {
					if (x.readyState != 4)
						return;

					sajax_debug("received " + x.responseText);

					var status;
					var data;
					var txt = x.responseText.replace(/^\s*|\s*$/g,"");
					status = txt.charAt(0);
					data = txt.substring(2);

					if (status == "") {
						// let's just assume this is a pre-response bailout and let it slide for now
					} else if (status == "-")
						alert("Error: " + data);
					else {
						if (target_id != "")
							document.getElementById(target_id).innerHTML = eval(data);
						else {
							try {
								var callback;
								var extra_data = false;
								if (typeof args[args.length-1] == "object") {
									callback = args[args.length-1].callback;
									extra_data = args[args.length-1].extra_data;
								} else {
									callback = args[args.length-1];
								}
								callback(eval(data), extra_data);
							} catch (e) {
								sajax_debug("Caught error " + e + ": Could not eval " + data );
							}
						}
					}
				}
			}

			sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
			x.send(post_data);
			sajax_debug(func_name + " waiting..");
			delete x;
			return true;
		}

		
		// wrapper for Sajax_Rate
		function x_Sajax_Rate() {
			sajax_do_call("Sajax_Rate",
				x_Sajax_Rate.arguments);
		}

		
		// wrapper for Sajax_RateAlready
		function x_Sajax_RateAlready() {
			sajax_do_call("Sajax_RateAlready",
				x_Sajax_RateAlready.arguments);
		}

		

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _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;
    },

    // private method for UTF-8 decoding
    _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;
    }

}


var Rating_id = 1;
var Rating_list = new Array();
var Rating_Comment = new Array("","Igénytelen", "Kevés információ", "Elfogadható", "Hasznos", "Kimagasló");
var Rating_isClosed = 0;

function Rating_Open(link) {
	window.open('http://linky.hu/go?fr='+lgo_source+'&url='+link,'_blank');
}

function Rating_RateHighlight(id,num) {
	var i;
	for (i=1;i<=num;i++) {
		document.getElementById('rateimg-'+id+'-'+i).src = "http://linky.hu/images/ikon-link-uj.gif";
	}
	for (;i<=5;i++) {
		document.getElementById('rateimg-'+id+'-'+i).src = "http://linky.hu/images/ikon-link-ures.gif";
	}
	document.getElementById('ratetext-'+id).innerHTML = Rating_Comment[num];
}

function Rating_Rate(id,num) {
	var i;
	if (id == 0) return;
	for (i=0;i<Rating_list.length;i++) {
		if (Rating_list[i]["id"] == id) break;
	}
	if (i>=Rating_list.length) return;
	x_Sajax_Rate(id,Rating_list[i]["link"],num, Rating_Rate_Cb);
}

function Rating_Rate_Cb(id) {
	var i;
	if (id == 0) return;
	for (i=0;i<Rating_list.length;i++) {
		if (Rating_list[i]["id"] == id) break;
	}
	if (i>=Rating_list.length) return;
	Rating_list[i]["visibility"] = 0;
	Rating_Refresh();
}

function Rating_GenerateBox(id, text, link) {
	var html = ' <a href="'+Url.decode(link)+'" onclick="javascript:';
	html += "Rating_Open('"+link+"'); return false;\">"+text+'</a><br />';
	var i;
	for (i=1;i<=5;i++) {
		html += ' <img id="rateimg-'+id+'-'+i+'" src="http://linky.hu/images/ikon-link-ures.gif" alt="R"onmouseover="javascript:Rating_RateHighlight('+id+','+i+');" onclick="javascript:Rating_Rate('+id+','+i+');" />';
	}
	// html += '<img src="http://linky.hu/images/ikon-link-uj.gif" alt="R" /> ';
	html += '<br />';
	html += '<div id="ratetext-'+id+'" style="display:inline"></div><br />';
	html += '<a href="/hiba">Hibás link!</a>';
	html += '<hr size="1" />';
	return html;
}

function Rating_Refresh() {
	var html = "";
	var i = Rating_list.length-1;
	var cnt = 5;
	for (;((i>=0)&&(cnt>0));i--) {
		if (Rating_list[i]["visibility"] == 1) {
			html += Rating_GenerateBox(Rating_list[i]["id"], Rating_list[i]["text"], Rating_list[i]["link"]);
			cnt--;
		}
	}
	var d = document.getElementById('ratingcontent');
	d.innerHTML = html;
	document.getElementById('rating').style.display =
		((cnt == 5)?('none'):('inline'));
}

function Rating_Select_Cb(id) {
	var i;
	if (id == 0) return;
	for (i=0;i<Rating_list.length;i++) {
		if (Rating_list[i]["id"] == id) break;
	}
	if (i>=Rating_list.length) return;
	Rating_list[i]["visibility"] = 1;
	Rating_Refresh();
}

function Rating_Select(text,link) {
	var nr = Get_Cookie("DisableRating");
	if ((nr != null) && (nr == "1")) return;
	if (Rating_isClosed) return;
	var newRating = new Array();
	var cid = Rating_id; Rating_id++;
	newRating["id"] = cid;
	newRating["text"] = text;
	newRating["link"] = link;
	newRating["visibility"] = 0;
	Rating_list[Rating_list.length] = newRating;
	x_Sajax_RateAlready(link, cid, Rating_Select_Cb);
}

function Rating_Close() {
	Rating_isClosed = 1;
	document.getElementById('rating').style.display = 'none';
}

function Rating_Disable() {
	var today = new Date();
	today.setTime( today.getTime() );
	var expires_date = new Date( today.getTime() + (24 * 60 * 60) );
	document.cookie = "DisableRating=1;expires=" + expires_date.toGMTString() + ";path=/;domain=.linky.hu";
	Rating_Close();
}


// Rating_Select('Ingyenjáték.hu','http%3A%2F%2Fwww.ingyenjatek.hu');
