function HttpRequest() {
	var http_request = false;
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	return http_request;
}

var R = HttpRequest();

function change() {
	if (R.readyState != 4 && R.readyState != 200) return;
	var D = document.getElementById("d");
	D.innerHTML = R.responseText;
}

function profile(u,p,i) {
	var D = document.getElementById("d");
	D.innerHTML = "<a href='blacksea?u=" + u + "'><img src='files/user/" + i + "' border='0' width='50' height='50'></a><p>" + p;
}

function combo() {
	if (R.readyState != 4 && R.readyState != 0) return;
	var q = document.f.q.value;
	var D = document.getElementById("d");
	D.innerHTML = "";
	if (q != "") {
    R.onreadystatechange = change;
    R.open("GET", "combo.php?m=make&q="+encodeURIComponent(q), true);
    R.send(null);
  }
}

function add_finn() {
	if (R.readyState != 4 && R.readyState != 200) return;
	var D = document.getElementById("d");
	D.innerHTML += R.responseText;
  D.scrollTop = D.scrollHeight;
}

function finn() {
	if (R.readyState != 4 && R.readyState != 0) return;
	var q = document.f.q.value;
	var u = document.f.u.value;
	if (q != "") {
    R.onreadystatechange = add_finn;
    R.open("GET", "finn?m=q&q="+encodeURIComponent(q)+"&u="+encodeURIComponent(u), true);
    R.send(null);
  }
	document.f.q.value = '';
  return false;
}

function clearform() {
	document.f.q.value = '';
	var D = document.getElementById("d");
	D.innerHTML= "";
	return false;
}

function show(divid, focus) {
  var s = document.getElementById(divid).style;
  if (s.display == "none") {
    s.display = "";
    s.visibility = "visible";
    if (focus) focus.focus();
  }
  else {
    s.display = "none";
    s.visibility = "hidden";
  }
}

function change_tr(idname, over, overcolor, outcolor) {
  if (!overcolor) overcolor = "#eeeeee";
  if (!outcolor) outcolor = "#ffffff";
  if (over == 1) idname.style.background=overcolor;
  else idname.style.background=outcolor;
}

function gourl(url) {
  document.location.href=url;
}

function resizeImage(num, size)
{
	var oImg = eval("document.getElementById('userimg" + num + "')");
  var IMAGE_WIDTH = size;

  if (oImg.naturalWidth != oImg.width) {
		oImg.width = oImg.naturalWidth;
		oImg.height = oImg.naturalHeight;
  } else if (oImg.width > IMAGE_WIDTH) {
		var width = oImg.width;
		var height = oImg.height;
		var ratio = IMAGE_WIDTH/width;
		oImg.width = IMAGE_WIDTH;
		oImg.height = height*ratio;
	}
}

function fitImage(num, size)
{
	var oImg = eval("document.getElementById('userimg" + num + "')");
  var IMAGE_WIDTH = size;

  if (oImg.width > IMAGE_WIDTH) {
		var width = oImg.width;
		var height = oImg.height;
		var ratio = IMAGE_WIDTH/width;
		oImg.width = IMAGE_WIDTH;
		oImg.height = height*ratio;
	}
}

function suxx(vote)
{
  document.f.vote.value = vote;
  document.f.submit();
}

function qtqt()
{
  document.f.qt.value = 1;
  document.f.submit();
}


