function addBot(){
	
	whost_JID = $('#whost_JID').val();
	widg_Name = $('#widg_Name').val();
	widg_URL = $('#widg_URL').val();
	widg_Desc = $('#widg_Desc').val();
	widg_Help = $('#widg_Help').val();
	widg_Privacy = $('#widg_Privacy').val();
	
	$('p.error').remove();
	errors = false;
	
	if(widg_Name == '')
	{
		$("#widg_Name").after('<p class="error">Bot Name is required</p>');
		errors = true;
	}
	
	if(whost_JID == '' || whost_JID.length < 4 || val.indexOf(' ') != -1)
	{
		$("#whost_JID").before('<p class="error">A valid screen name of 4 or more letters or numbers with no spaces is required</p>');
		errors = true;
	}
	
	if(errors)
	{
		scroll(0,0);
		$('#errorBox').show();
		returnVal =  false;
	}else
	{
		returnVal = true;
	}
	
return returnVal;
}

function postJIDUpdateKeypress(box, e) {
	var val = box.value;
	
	if(val.length > 3)
		updateJIDText(val);
	else
		if(val.length > 0)
		{
			$("#JIDCheck").html('Not available');
			$("#JIDCheck").css('color','red');
		}
}

function updateJIDText(val) {
	
	if (val.indexOf(' ') != -1) {
		$("#JIDCheck").html('Spaces are not allowed');
	    $("#JIDCheck").css('color','red');
	} else
	{
	
		url = "/account/ajax/checkjid?jid=" + val;
		$.getJSON(url,
        function(data){
          if(data.available == 0){
          	$("#JIDCheck").html('Not available');
		    $("#JIDCheck").css('color','red');
          }else{
          	$("#JIDCheck").html('Available');
		    $("#JIDCheck").css('color','green');
          }
        });
	}
}