//全选中所有勾选项
function selectAllItem(item_name) {
	var items = document.getElementsByName(item_name);
	for(var i = 0; i < items.length; i++) {
		items[i].checked = event.srcElement.checked;
	}
}



//取出被选上的选项
function selected(item_name){    
    var selectedItem = new Array();
    var items = document.getElementsByName(item_name);
    var index = 0;
    for(var i = 0; i < items.length; i++) {
		if(items[i].checked) {
			selectedItem[index]=items[i];			
			index++;
		}
	}
	return selectedItem;
 }
 
function GetE( elementId )
{
	return document.getElementById( elementId )  ;
}

function ShowE( element, isVisible )
{
	if ( typeof( element ) == 'string' )
		element = GetE( element ) ;
	element.style.display = isVisible ? '' : 'none' ;
}

// 获取编辑器中HTML内容
function getEditorHTMLContents(EditorName) { 
    var oEditor = FCKeditorAPI.GetInstance(EditorName); 
    return(oEditor.GetXHTML(true)); 
}

// 获取编辑器中文字内容
function getEditorTextContents(EditorName) { 
    var oEditor = FCKeditorAPI.GetInstance(EditorName); 
    return(oEditor.EditorDocument.body.innerText); 
}

// 设置编辑器中内容
function SetEditorContents(EditorName, ContentStr) { 
    var oEditor = FCKeditorAPI.GetInstance(EditorName) ; 
    oEditor.SetHTML(ContentStr) ; 
}

//判断是否有选中
function checkSeleted(filedName){
	var i;
	var items = document.getElementsByName(filedName);    
    for(i = 0; i < items.length; i++) {
		if(items[i].checked) {			
			break;
		}
	}
	
	if(i>=items.length){ 
		return false;
	} else {		
		return true;
	}
}

//获取元素
function G(id){
    return document.getElementById(id);
}

//生成元素
function GC(t){
   return document.createElement(t);
}

//去头尾空白
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, '');
}

//去左边空白
String.prototype.ltrim = function() { 
	return this.replace(/(^\s*)/g, ""); 
}

//去右边空白
String.prototype.rtrim = function() {
	return this.replace(/(\s*$)/g, ""); 
} 

//判断是否ie浏览器
function isIE(){
      return (document.all && window.ActiveXObject && !window.opera) ? true : false;
} 

//验证邮箱地址是否正确，cEmail为邮箱地址。
function checkEmail(cEmail){
	/*if(cEmail.match(/[\w-]+@{1}[\w-]+\.{1}\w{2,4}(\.{0,1}\w{2}){0,1}/ig)!=cEmail){
  		return false
 	}else{
  		return true
  	}*/
  	if(!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(cEmail)){
  		return false;
  	}else{
  		return true;
  	}
  	
}

//验证手机号是否正确,mobile为手机号
function checkPhone(mobile){
	if((!/^13\d{9}$/g.test(mobile))
	     && (!/^15\d{9}$/g.test(mobile))
		 //&& (!/^159\d{8}$/g.test(mobile)) 
		 //&& (!/^158\d{8}$/g.test(mobile))
		 //&& (!/^188\d{8}$/g.test(mobile))
		 //&& (!/^189\d{8}$/g.test(mobile))
		 && (!/^18\d{9}$/g.test(mobile))){
		return false;
	}else{
		return true
	}
}

//获取被选择的值
function getCheckedValue(id){
   var result = "";
　　var items = document.getElementsByName(id);
　　for(i=0;i<items.length;i++)
　　{
    　	if(items[i].checked) result=items[i].value;
　　}
	return result;
}
