function signup(url, f, place_box, place_ok, place_error, place_form, place2, place3) {
	var xmlhttp

	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	if (!xmlhttp && document.createElement) {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	@end @*/
	if (!xmlhttp && document.createElement) {
	 xmlhttp = new XMLHttpRequest(); 
	}

	data = 0;
	url += '&username=' + escape(f.login.value);
	url += '&password=' + escape(f.password.value);
	url += '&password2=' + escape(f.password2.value);
	url += '&first_name=' + escape(f.first_name.value);
	url += '&last_name=' + escape(f.last_name.value);
	url += '&email=' + escape(f.email.value);
	url += '&email2=' + escape(f.email2.value);
	url += '&country=' + escape(f.country.value);
	url += '&code=' + escape(f.code.value);
	url += '&site_news=' + escape(f.site_news.checked);
	url += '&new_releases=' + escape(f.new_releases.checked);
	url += '&format_letter=' + escape(f.format_letter.value);

	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			data = xmlhttp.responseText.split('|');
			//alert('data=' + data);
			if (data[0] == 'error') {
				enable_submit(f);
				show(place_ok, 'none');
				show(place_error, 'block');
				el = document.getElementById(place_error);
				el.innerHTML = data[1];
				show(place_box, 'block');
				el = document.getElementById('imgcode');
				el.src = 'imgs/random.gif?' + Math.random();
			} else {
				/*disable_submit(f);
				delhtml(place2);
				delhtml(place3);
				show(place_form, 'none');
				show(place_error, 'none');
				show(place_ok, 'block');*/
				document.location.href='/add_funds.html';
			}
		}
	}
	xmlhttp.send(null)
}

function delhtml(n) {
	el = document.getElementById(n);
	if (el != null)	{
		el.CSSText = 'display:none';
		el.innerHTML = '';
	} else {
		alert('element '+n+' not found');
	}
}

function checkfield(f, url, field, place_ok, place_error) {
	var xmlhttp

	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	if (!xmlhttp && document.createElement) {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	@end @*/
	if (!xmlhttp && document.createElement) {
	 xmlhttp = new XMLHttpRequest(); 
	}

	data = 0;
	show(place_ok, 'none');
	show(place_error, 'none');
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			data = xmlhttp.responseText;
			//alert('data=' + data);
			if (data == 'error') {
				show(place_ok, 'none');
				show(place_error, 'block');
				el = document.getElementById(field);
				if (el != null) { el.focus(); }
				disable_submit(f);
			} else {
				show(place_ok, 'block');
				show(place_error, 'none');
				enable_submit(f);
			}
		}
	}
	xmlhttp.send(null)
}

function check(f, field, place_ok, place_error, checktype) {
	show(place_ok, 'none');
	show(place_error, 'none');
	el = document.getElementById(field);
	if (el == null) {
		el = f[field];
	}

	if (checktype == null) {
		checktype = 1;
	}

	if (el == null)	{
		//alert('field=' + field + ' not found, test=' + f[field].value);
	} else {
		if (el.value != '')	{
			checkfield(f, '/signup.html?check=' + checktype + '&' + field + '=' + escape(el.value), field, place_ok, place_error);
		}
	}
}

function show(place, val) { 
	el = document.getElementById(place);
	if (el != null)	{
		el.style.cssText = 'display:' + val;
	}
	return false;
}
function disable_submit(f) {
	if (f.signup != null) {
		f.signup.disabled = true;
	}
}
function enable_submit(f) {
	if (f.signup != null) {
		f.signup.disabled = false; 
	}
}

function check_email(f, checktype) {
	if (f == null) {
		f = document.formRegistration;
	}
	show('email_invalid', 'none');
	if (!validateEmailv2(f.email.value)) {
		show('email_invalid', 'block');
		f.email.focus();
	} else {
		check(f, 'email', 'email_ok', 'email_error', checktype);
	}
}

function save_userinfo(url, f, place_box, place_ok, place_error, place_form, place_button) {
	var xmlhttp

	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	if (!xmlhttp && document.createElement) {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	@end @*/
	if (!xmlhttp && document.createElement) {
	 xmlhttp = new XMLHttpRequest(); 
	}

	data = 0;

	show(place_button, 'none');
	show(place_box, 'none');
	show(place_form, 'block');
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			data = xmlhttp.responseText.split('|');
			//alert('data=' + data);
			if (data[0] == 'error') {
				enable_submit(f);
				show(place_ok, 'none');
				show(place_error, 'block');
				el = document.getElementById(place_error);
				el.innerHTML = data[1];
			} else {
				disable_submit(f);
				show(place_error, 'none');
				show(place_ok, 'block');
			}
			show(place_form, 'none');
			show(place_box, 'block');
		}
	}
	xmlhttp.send(null)
}

function call_proz(url, f, place_ok, place_info, place_error, place_form, place_btn, place_bar) {
	var xmlhttp

	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	if (!xmlhttp && document.createElement) {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	@end @*/
	if (!xmlhttp && document.createElement) {
	 xmlhttp = new XMLHttpRequest(); 
	}

	//show(place_info, 'none');
	show(place_ok, 'none');
	show(place_error, 'none');
	el = document.getElementById(place_btn);
	if (el != null) { el.disabled = true; }
	show(place_btn, 'none');

	data = 0;
	url += '&first_name=' + escape(f.first_name.value);
	url += '&last_name=' + escape(f.last_name.value);
	url += '&phone=' + escape(f.phone.value);
	url += '&sum=' + escape(f.sum.value);
//	url += '&company=' + escape(f.company.value);
	url += '&country=' + escape(f.country.value);
	url += '&city=' + escape(f.city.value);
	url += '&zip=' + escape(f.zip.value);
	url += '&address=' + escape(f.address.value);
	url += '&state=' + escape(f.state.value);
	url += '&number=' + escape(f.number.value);
	url += '&cvv=' + escape(f.cvv.value);
	url += '&month=' + escape(f.month.value);
	url += '&year=' + escape(f.year.value);
	url += '&issuer=' + escape(f.issuer.value);
	url += '&utime=' + escape(f.utime.value);

	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			data = xmlhttp.responseText.split('|');
			//alert('data0=' + data[0] + ' data1=' + data[1] + ' data2=' + data[2]);
			if (data[0] == 'error') {
				//show(place_info, 'none');
				show(place_ok, 'none');
				show(place_error, 'block');
				update_html(place_error, data[1]);
			} else {
				delhtml('td_sum');
				delhtml('td_state');
				delhtml('td_country');
				delhtml('td_date');
				show(place_form, 'none');
				show(place_error, 'none');
				show(place_ok, 'block');
				//show(place_info, 'block');
				//update_html(place_info, data[2]);
				if (data[1]) {
					//alert('new balance = '+data[1]);
					document.formLogout.balance.value=data[1];
					update_html('current_balance', '$'+data[1]);
				}
				//document.location.href='/add_funds.html';
			}
			show(place_btn, 'block');
			el = document.getElementById(place_btn);
			if (el != null) { el.disabled = false; }
			show(place_bar, 'none');
		}
		return false;
	}
	xmlhttp.send(null)

	return false;
}

function update_html(n, v) {
	el = document.getElementById(n);
	if (el != null) {
		el.innerHTML = v;
	} else {
		alert('element '+n+' not found');
	}
}

