function getFormValues(fobj) 
{
	str = new Array;
	j = 0;
	for(i=0;i<fobj.elements.length;i++)
	{
		if(fobj.elements[i].type=="text" && fobj.elements[i].value!=""){
			str[j]=fobj.elements[i].value;
			j++;
		}
	}

	if(j>=2 && j<=10){
		return str;
	}else{
		return false;
	}
}

var http_request = false;
var window_open = false;

function makeRequest(value) {
	document.getElementById('submit_id').innerHTML = '<img id="progress" src="images/ajax-loader-black.gif" />';
	if(window_open==true) {
		Effect.toggle('sub_search','slide');
		window_open=false;
	}
//	if(document.getElementById('ajax').innerHTML!="") {
//		Effect.toggle('sub_search','slide');
//	}

	http_request = false;
	form_value = null;

	form_value = getFormValues(value);

	if(!form_value){
		document.getElementById('submit_id').innerHTML = '<input value="Animate" name="btnG" id="btnG" type="button" class="button" onclick="makeRequest(this.form);return false;" />';
		document.getElementById('ajax').innerHTML=""
		alert('Choose at least two Userbars');
		return false;
	}

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', 'anima.php', true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", form_value.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send('ub='+form_value);
}

function alertContents() {
	if (http_request.readyState == 4) {
		document.getElementById('submit_id').innerHTML = '<input value="Animate" name="btnG" id="btnG" type="button" class="button" onclick="makeRequest(this.form);return false;" />';
		if (http_request.status == 200) {
			if(http_request.responseText=="nobar"){
				document.getElementById('ajax').innerHTML = 'No userbar found';
			} else {
				document.getElementById('ajax').innerHTML = http_request.responseText;
			}
			Effect.toggle('sub_search','slide');
			window_open=true;
		} else {
			alert('There was a problem with the request.');
		}
	}
}

function crea_help_rit() 
{
	document.getElementById('ajax').innerHTML="What <strong>Userbar Animator</strong> is? Most  forums don't allow more then X Userbars per user in their own signature. With Userbars Animator you can put more then one Userbar in 350x19 pixel! (standard size) Actually it's supported a creation with  10 Userbar or less.<br /><br />";
	Effect.toggle('sub_search','slide');
}

function help() {
	if(window_open==true){
		Effect.toggle('sub_search','slide');
		window_open=false;
		setTimeout('crea_help_rit()',2000);
		window_open=true;
	}else{
		window_open=true;
		document.getElementById('ajax').innerHTML="What <strong>Userbar Animator</strong> is? Most  forums don't allow more then X Userbars per user in their own signature. With Userbars Animator you can put more then one Userbar in 350x19 pixel! (standard size) Actually it's supported a creation with  10 Userbar or less.<br />The Userbar in the last input field is our userbar. Support us and put it in your Animated Userbars.<br /><br /><div align=\"center\">Report bugs with the Contact form</div><br /><br />";
		Effect.toggle('sub_search','slide');
	}
}
