var imServer = getParameter("imserver");
var lvid = getParameter("lvid");
var sign = getParameter("sign");
var teamId = getParameter("teamid");
imServer = getImServer(imServer);
$(document).ready(function() {
	$('.radio i').click(function() {
		$(this).parent().addClass('radio_on').removeClass('radio_off');
		$(this).parent().siblings('.radio').removeClass('radio_on').addClass('radio_off');
		$(this).siblings('input[type=radio]').attr("checked", "checked");
		$(this).parent().siblings('.radio').find('input[type=radio]').removeAttr("checked");
	});
	$("#alertnewlyClose").click(function() {
		$("#alertpopupSureBut").click();
	});
	$("#alertpopupSureBut").click(function() {
		$(".PopupQueding").hide();
		$(".announPopup").hide();
	});
	lvAlertInit("annWarp");
});
$(document).on('keydown', function(e) {
	if (e.keyCode == 13) {
		tiJiao();
	}
})
function frameFocus() { 
	$("#groupname").focus(); 
}
function tiJiao() {
	if ($("#xieyi").is(':checked') == false) { 
		var paramStr = "{title:'创建云组',cat:0,content:'请阅读并同意图驴云组服务协议！'}";
		var params = "{command:9006,params:" + paramStr + "}";
		sendCommand(params);
		return;
	}
	var verify = jQuery("input[name='types']:checked").val();
	var gname = $.trim(jQuery("#groupname").val()) 
	if (gname.match(/^\s+$/g)){
		var paramStr = "{title:'创建云组',cat:0,content:'请填写组名！'}";
		var params = "{command:9006,params:" + paramStr + "}";
		sendCommand(params);
		return;
	}
	if (gname == null || gname == '' || gname.length == 0) {
		var paramStr = "{title:'创建云组',cat:0,content:'请填写组名！'}";
		var params = "{command:9006,params:" + paramStr + "}";
		sendCommand(params);
		return;
	}
	var params = {
		'lvid': lvid,
		'sign': sign,
		'name': gname,
		'verify': verify,
		'supergroupid':teamId
	};
	$.getJSON(requestUrlMap['creatGroup']['url'], params, function(data) {
		if (!data || data['errorid'] != 0) { 
			var paramStr = "{title:'创建云组',cat:2,content:'提交失败！'}";
			var params = "{command:9006,params:" + paramStr + "}";
			sendCommand(params);
			return;
		}
		sendCommand("{command:9001, params:{lvid:" + lvid + "}}");
	})
}

function cancel(){
	sendCommand("{command:9001, params:{lvid:" + lvid + "}}");
}
function clickurl(url){  
	var params = "{command:9010, params:{url: " + url + "}}";
	sendCommand(params);
}
