var w = 302; //width of each image
var speed = 20; // equals pixels per 1000th of a second -> lower value = faster
var offset = 0; // initial offset in px on the left

var ii = 0;
var k = 0;
var poss = new Array();
var imgs;

function init(){
	imgs = document.getElementById('scroller').getElementsByTagName('img');

	for (ii=0;ii<imgs.length;ii++){
		imgs[ii].setAttribute("class","dimg");
		imgs[ii].className = "dimg"
		imgs[ii].style.left = (ii*w+offset) + 'px';
		poss[ii] = ii*w + offset;
	}
	scroller();
}
function scroller(){
	for (var jj=0;jj<imgs.length;jj++){
		imgs[jj].style.left = poss[jj]+'px';
		poss[jj]--;
		if (poss[jj] == -w){
			poss[jj] = w*(imgs.length-1);
		}
	}
	//alert('yep');
	setTimeout('scroller()',speed);
}
function builddata(){
	var dom = document.getElementById('domain');
	var tld = document.getElementById('tld');
	var code = document.getElementById('code');
	var q = '';
	if (dom.value.length < 2){
		document.getElementById('result').innerHTML = 'The domain name has to be 2 or more characters.';
		dom.focus();
	} else if (code.value == '') {
		document.getElementById('result').innerHTML = 'Please enter the code as shown in the image.';
		code.focus();
	} else {
		q = 'domain='+dom.value+'&tld='+tld.value+'&code='+code.value;
		loadresponse(q);
	}
}

function loadresponse(dt){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		var xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
		var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			var restxt = xmlhttp.responseText;
			if (restxt == 'Incorrect security code entered'){
				document.getElementById('ci').src = 'securimage/securimage_show.php?' + Math.random();
			}
			document.getElementById('result').innerHTML= restxt;
			document.getElementById('ci').src = 'securimage/securimage_show.php?' + Math.random();
		} else {
			document.getElementById('result').innerHTML='<img src="images/checking.gif" />';
		}
	}
	xmlhttp.open("GET",'whois.php?'+dt,true);
	xmlhttp.send();
}
