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
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
function myXMLHttpRequest() {
  var xmlhttplocal;
  try {
    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
    xmlhttplocal=false;
  }
 }

if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
 try {
  var xmlhttplocal = new XMLHttpRequest();
 } catch (e) {
  var xmlhttplocal=false;
  alert('couldn\'t create xmlhttp object');
 }
}
return(xmlhttplocal);
}

function enablebutton(button, button2, target) {
	var string = target.value; 
	button2.disabled = false;
	if (string.length > 3) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
	//var target2 = document.getElementById('commentcaptcha');
}

function checkit(form) {
  var name = escape(form.username.value);
  url = '/ajax/checkusername/?username='+name;
  checkitxmlhttp = new myXMLHttpRequest();
  checkitxmlhttp.open("GET",url,true);
  checkitxmlhttp.onreadystatechange=function() {
    if (checkitxmlhttp.readyState==4) {
      responsestring = checkitxmlhttp.responseText;
      if (responsestring == 'taken'|| responsestring == 'not acceptable - user names must have 4-15 characters, and only alphanumeric characters.') {
		document.getElementById('checkitvalue').innerHTML = '<strong style="background: url(/images/deny.png) 0 1px no-repeat; padding-left: 16px; font-size: 12px; color: #cc0000;">Sorry, the username "'+name+'" is '+responsestring+'.</strong>';
		form.submit.disabled = 'disabled';
      } else {
		document.getElementById('checkitvalue').innerHTML = '<strong style="background: url(/images/confirm.png) 0 1px no-repeat; padding-left: 16px; font-size: 12px; color: #347637;">Good choice! The username "'+name+'" is '+responsestring+'.</strong>';
		form.submit.disabled = '';
      }
    }
  }
  //  xmlhttp.setRequestHeader('Accept','message/x-formresult');
  checkitxmlhttp.send(null);
  return false;  
}

function hitit(user, photo, code) {
	alert('hit');
}

function blab_reply_form(blab_id) {
	//alert('<form style="padding:10px;" method="post" action="/blabbers/add">type your reply here<br/><textarea style="width:95%" name="blabber[body]" cols="50" rows="2"></textarea><input type="submit" value="Reply To Topic"/><input onClick="cancel_reply_form('+ blab_id +');" type="button" value="Cancel"></form>');
	document.getElementById('blab_'+blab_id).innerHTML = '<form class="reply_form" method="post" action="/blabbers/add"><input type="hidden" name="blabber[parent_id]" value="'+ blab_id +'" />type your reply here<br/><textarea style="width:95%" name="blabber[body]" cols="50" rows="2"></textarea><input type="submit" value="Reply To Topic"/><input onClick="cancel_reply_form('+ blab_id +');" type="button" value="Cancel"></form>';
}

function cancel_reply_form(blab_id) {
	document.getElementById('blab_'+blab_id).innerHTML = '';
}


