function parseJSON(jsonString) {
	return (new Function('return ' + jsonString))();
}

function getSexString(sex) {
	if (sex == cSexNone) {
		return csSexNone;
	} else if (sex == cSexMale) {
		return csSexMale;
	} else if (sex == cSexFemale) {
		return csSexFemale;
	}
	return "";
}

function getSexValue(sexString) {
	if (sexString === csSexNone) {
		return cSexNone;
	} else if (sexString === csSexMale) {
		return cSexMale;
	} else if (sexString === csSexFemale) {
		return cSexFemale;
	}
	return cSexNone;
}

function formatOtherInfo(str) {
	var ret = str.replace(/</g, '&lt;');
	ret = ret.replace(/>/g, '&gt;');
	ret = ret.replace(/\r/g, '<br>');
	ret = ret.replace(/\s/g, '&nbsp;');
	return ret;
}

function unsetInputTextDefault(obj) {
	obj.removeClass('defaultInput');
	obj.removeAttr('defaultValue');
}

function setInputTextDefault(obj, text) {
	obj.addClass('defaultInput');
	obj.attr('defaultValue', text);
	obj.val(text);
}

function getDefaultInputVal(obj) {
	if (obj.hasClass('defaultInput')) {
		if (obj.attr('defaultValue') === obj.val()) {
			return '';
		}
	}
	return obj.val();
}

function resetScrollbarPos(){
	var scrollbar = getFoxWBScrollbar('scrollbar');
	if (scrollbar){
		scrollbar.scrollVert(0);
	}
}

function scrollPanel(obj, toolbar){
	var height = obj.height();
	var top = obj.offset().top;
	var bottom = top + height + 5;
	var toolBarTop = toolbar.offset().top;
	var scrollbar = getFoxWBScrollbar('scrollbar');
	if (scrollbar){
		var scrollTop = scrollbar.vertScrollTop();
		if (top < 0){
			var moveTo = scrollTop + top;
			scrollbar.scrollVert(moveTo);
		} else if (bottom > toolBarTop){
			var scrollPos = bottom - toolBarTop;
			var moveTo = scrollTop + scrollPos;
			scrollbar.scrollVert(moveTo);
		}
	}
}

function scrollGroupEditPanel(obj){
	var toolbar = $('#group_panel_edit .toolbar');
	scrollPanel(obj, toolbar);
}

function scrollEditPanel(obj){
	var toolbar = $('#edit_panel .toolbar');
	scrollPanel(obj, toolbar);
}

var g_resizeTimer = 0;
function AdjustFrameSize() {
	//update body_main height
	var clientHeightFix = -5;
	var borderHeightFix = -20;
	var clientHeight = document.documentElement.clientHeight;
	$('#body_main').css('height', (clientHeight + clientHeightFix)+'px');
	$('#frame_border').css('min-height', (clientHeight + borderHeightFix)+'px');
	updateScrollbar();
	/*
	$('#body_main').height(clientHeight + clientHeightFix);
	$('#frame_border').css('min-height', (clientHeight + borderHeightFix)+'px');
	updateScrollbar();
	var preHeight = clientHeight;
	var handler = function() {
		var clientHeight = document.documentElement.clientHeight;
		if (clientHeight != preHeight){
			preHeight = clientHeight;
			$('#body_main').height(clientHeight + clientHeightFix);
			$('#frame_border').css('min-height', (clientHeight + borderHeightFix)+'px');
			updateScrollbar();
			g_resizeTimer = setTimeout(handler, 100);
		}else{
			g_resizeTimer = 0;
		}
	}
	if (!g_resizeTimer){
		g_resizeTimer = setTimeout(handler, 100);
	}*/
}

// 获取显示姓名的各种组合
function getNameList(firstName, lastName, nickName) {
	var list = [];
	if(firstName !== '' && lastName !== '') {
		list[list.length] = lastName + firstName;
		list[list.length] = lastName + " " + firstName;
		list[list.length] = lastName + "," + firstName;
		list[list.length] = firstName + " " + lastName;
	} else if(firstName !== '' && lastName === '') {
		list[list.length] = firstName;
	} else if(firstName === '' && lastName !== '') {
		list[list.length] = lastName;
	}
	if (nickName !== '') list[list.length] = nickName;
	
	return list;
}

function getNameListIndex(list, item) {
	for(var i=0; i<list.length; i++) {
		if(list[i] === item)
			return i;
	}
	return 0;
}