
function enterSubmit(ev){
	ev = ev || window.event;
  	 if(ev.keyCode == 13){
  	 	var tmp = this;
		while((tmp!=null)&&(tmp.tagName!="FORM")){
			tmp=tmp.parentElement;
		}
		alert(tmp);
		if((tmp!=null)&&(tmp.tagName=="FORM")){
			tmp.submit();
		}
 	}
}




function batch_do(entityName, action ,id,fid) {
	if(id == undefined){
		id = "ids";
	}
    if (!atleaseOneCheck(id)) {
        alert("请选择一个！");
        return;
    }
        
    if (confirm("\u786e\u5b9a\u8981" + entityName + "?")) {
    	var form = document.forms.ec;
    	if(fid != undefined){
    		form = $(fid);
    	}        
        form.action = action;
        form.submit();
    }
}

function batch_dox(entityName, action,fid) {        
    if (confirm("\u786e\u5b9a\u8981" + entityName + "?")) {
    	var form = $(fid);  
        form.action = action;
        form.submit();
    }
}

function atleaseOneCheck(ids) {
    var items = document.getElementsByName(ids);
    if (items.length > 0) {
        for (var i = 0; i < items.length; i++) {
            if (items[i].checked == true) {
                return true;
            }
        }
    } else {
        if (items.checked == true) {
            return true;
        }
    }
    return false;
}

function openIframe(url){
      var f=document.getElementById("iframeID");
	  f.src=url;
}
function setIframeHeight(){
	 var frame = parent.$("iframeID");
	 frame.height = document.body.scrollHeight+10;
}

function openPage(id,entityName,action){
		if(id == undefined){
			id = "ids";
		}
    	if (!atleaseOneCheck(id)) {
        	 alert("请选择一列.");
       		 return ;
   		}
   		if (confirm("\u786e\u5b9a\u8981" + entityName + "?")) {
   		     var form = document.forms.ec;
              form.action = action;
              form.target="_self";
             form.submit();
    	}
}

function selectByValue(id,value){
	var obj = document.getElementById(id);
	for(var i=0;i<obj.options.length;i++){
		if(obj.options[i].value == value){
			obj.options[i].selected = true;
			break;
		}else{
			obj.options[i].selected = false;
		}
	}
}
function checkByValue(name,value){
	var items = document.getElementsByName(name);
    if (items.length > 0) {
        for (var i = 0; i < items.length; i++) {
            if (items[i].value == value) {
                items[i].checked = true;
            }
        }
    } else {
        if(items.value == value){
        	items.checked = true
        }
    }
    return false;
}


function batch_delete(entityName, action ,id) {
    if (confirm("\u786e\u5b9a\u8981" + entityName + "?")) {
      
        if (!atleaseOneCheck(id)) {
            alert("\u8bf7\u81f3\u5c11\u9009\u62e9\u4e00" + entityName + "\uff01");
            return;
        }
        var form = document.forms.ec;
        var url = action + '?';
        if(typeof(form.ids.length) =='undefined'){
        	url += id + '=' + form.ids.value + '&';
        }else{
	        for(var i = 0; i< form.ids.length; i++){
				if (form.ids[i].checked == true){
					url += id + '=' + form.ids[i].value + '&';
				}
	        }
        }
        url += "id=" + document.forms.temp.tempId.value;
        var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		xmlhttp.Open("GET", url, false);
  		xmlhttp.Send();
  		location.reload();
    }
}

function removeSelectOption(selectId)
{
  var theSel   = document.getElementById(selectId);
  var selIndex = theSel.selectedIndex;
  if (selIndex != -1) {
    for(i=theSel.length-1; i>=0; i--)
    {
      if(theSel.options[i].selected)
      {
        theSel.options[i] = null;
      }
    }
    if (theSel.length > 0) {
      theSel.selectedIndex = selIndex == 0 ? 0 : selIndex - 1;
    }
  }
}

function getInputValue(tr,inputName){
	var inputs=tr.getElementsByTagName("input");
	for(var i=0;i<inputs.length;i++){
		if((inputs[i].name==inputName)){
			return inputs[i].value;
		}
	}
}

function selectOption2Url(selectId,param){
	if(param == undefined){
		param = selectId;
	}
	var select  = document.getElementById(selectId);
	var options = select.options;
	var url     = "";
	for(var i=0;i<options.length;i++){
		url += selectId+"="+options[i].value+"&";
	}
	if(url.length > 0){
		url = url.substring(0,url.length-1);
	}
	return url;
}

function selectOption2Str(selectId,split){
	if(split == undefined){
		split = ",";
	}
	var select  = document.getElementById(selectId);
	var options = select.options;
	var url     = "";
	for(var i=0;i<options.length;i++){
		url += options[i].value+split;
	}
	if(url.length > 0){
		url = url.substring(0,url.length-1);
	}
	return url;
}

function to_do(action ,id) {
	if(id == undefined){
		id = "ids";
	}
    if (!atleaseOneCheck(id)) {
        alert("请选择一个");
        return;
    }
    var form = document.forms.ec;
    form.action = action;
    form.submit();
}

function selectAllOption(selectId){
	var select  = document.getElementById(selectId);
	for(var i = 0;i< select.options.length; i++){  
  		select.options[i].selected = true;  
  	}
}

String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); }
String.prototype.lengths= function(){ return this.replace(/[\u4E00-\u9FA5]/g,"xx").length;}

String.prototype.isNotEmail = function(){
	return !/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(this);
} 
function win(href,isNew){
	if(isNew){
		window.open(href);
	}else{
		location.href = href;	
	}
}

function setTab11(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab11_'+m+i).className='uncurb4';
			$('tabc11_'+m+i).className='undis tab3cnt';
		}catch(e){}
	}
	$('tabc11_'+m+n).className='dis tab3cnt';
	$('tab11_'+m+n).className='curb4';
}

function setTab(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab_'+m+i).className='tabs';
			$('tabc_'+m+i).className='undis tabattention1';
		}catch(e){}
	}
	$('tabc_'+m+n).className='dis tabattention1';
	$('tab_'+m+n).className='curtabs';
}
function setTab2(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab2_'+m+i).className='tabs';
			$('tabc2_'+m+i).className='undis tabattention';
		}catch(e){}
	}
	$('tabc2_'+m+n).className='dis tabattention';
	$('tab2_'+m+n).className='curtabs';
}
function setTab12(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab12_'+m+i).className='uncurb2';
			$('tabc12_'+m+i).className='undis';
		}catch(e){}
	}
	$('tabc12_'+m+n).className='dis psnstock';
	$('tab12_'+m+n).className='curb2';
}
function setTab15(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab15_'+m+i).className='uncurb2';
			$('tabc15_'+m+i).className='undis acntdetail';
		}catch(e){}
	}
	$('tabc15_'+m+n).className='dis acntdetail';
	$('tab15_'+m+n).className='curb2';
}
function setTab14(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab14_'+m+i).className='uncurb2';
			$('tabc14_'+m+i).className='undis psnstock';
		}catch(e){}
	}
	$('tabc14_'+m+n).className='dis psnstock';
	$('tab14_'+m+n).className='curb2';
}
function setTab13(m,n,counter){
	for(var i=1;i<=counter;i++){
		try{
			$('tab13_'+m+i).className='uncurb4';
			$('tabc13_'+m+i).className='undis tab3cnt';
		}catch(e){}
	}
	$('tabc13_'+m+n).className='dis tab3cnt';
	$('tab13_'+m+n).className='curb4';
}
function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
}
/*firefox*/
function __firefox() {
	HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
	window.constructor.prototype.__defineGetter__("event", __window_event);
	Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style() {
	return this.style;
}
function __window_event() {
	return __window_event_constructor();
}
function __event_srcElement() {
	return this.target;
}
function __window_event_constructor() {
	if (document.all) {
		return window.event;
	}
	var _caller = __window_event_constructor.caller;
	while (_caller != null) {
		var _argument = _caller.arguments[0];
		if (_argument) {
			var _temp = _argument.constructor;
			if (_temp.toString().indexOf("Event") != -1) {
				return _argument;
			}
		}
		_caller = _caller.caller;
	}
	return null;
}
if (window.addEventListener) {__firefox();}
/*end firefox*/

/*弹窗居中*/
function showdialog(url,width,height){
	  var iTop = (window.screen.availHeight-30-height)/2;
	  var iLeft = (window.screen.availWidth-10-width)/2;
	  window.open(url,'','modal=yes,width='+width+',height='+height+',resizable=yes,scrollbars=yes,statusbar=no,top='+iTop +',left='+iLeft+'');
}
/*数据中心*/

//未实现功能提示
function clew (accountId){
	document.location.href="/account/account.action?accountId="+accountId;
}

//图片切换
function switchP(obj,sum){
	for(var i=1;i<=sum;i++){
		var obj1=document.getElementById("li"+i);
		obj1.className="uncurb2";
	}
	for(var i=1;i<=sum;i++){
		var obj2=document.getElementById("li"+i+"tu");
		obj2.className="undis";
	}
	var id=obj.id;
	obj.className="curb2";
	document.getElementById(id+"tu").className="dis"
}    
/*end*/
/*全球市场*/
function getP(id,sum,pId){
	for(var i=1;i<=sum;i++){
		document.getElementById("t"+i).className="undis";
	}
	document.getElementById(id).className="dis";
	changeP(pId,4,'.gif');
}

//参数为图片ID，图片数量，图片后缀
function changeP(pId,num,hz){
	for(var i=1;i<=num;i++){
		document.getElementById("id"+i).src="../images/id"+i+2+hz;
	}
	document.getElementById(pId).src="../images/"+pId+1+hz;
}
/*end*/