﻿var http = createRequestObject();
var field = '';
		   var loadingText = "<center><b>Đang tải dữ liệu ...</b>";
function createRequestObject() {
	var xmlhttp;
	try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e) {
    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	catch(f) { xmlhttp=null; }
  }
  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
	xmlhttp=new XMLHttpRequest();
  }
	return  xmlhttp;
}

function handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			response = http.responseText;
			field.innerHTML = response;
			field.scrollIntoView();
			if(!response) window.location.href = url;
		}
  	}
	catch(e){}
	finally{}
}
function alexa() {
	try {
		url = document.getElementById("url").value;
		bg = document.getElementById("bg").value;
		field = document.getElementById("alexa_field");
		field.innerHTML = loadingText;
		http.open('POST','get.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponse;
		http.send('url='+url+'&bg='+bg);
	}
	catch(e){}
	finally{}
	return false;
}
function bgselect(url,style)
{
sel.img.src='image.php?url='+url+'&style='+style;
sel.embed.value='<img src="http://anhtrang.org/alexa/image.php?url='+url+'&style='+style+'" alt="'+url+'" border=0>';
}
function copy(text2copy) {
  if (window.clipboardData) {
	window.clipboardData.setData("Text",text2copy);
  }
  alert("Đã copy xong\nBạn chỉ việc Ctrl+V để dán!");
}
function applyType(obj, value)
{
					var arrType = document.getElementsByName('searchType');
					for (var i = 0; i < arrType.length; i++) {
						arrType[i].className = '';
					}
					obj.className = 'curnav';
					//$('t').value = value;
					document.getElementById('t').value = value;
}
function init(id) {
    dabba = id;
	n = document.getElementById(id);
	n.focus();
	n.select();
	return true;
}
