/*
	validate by length
*/
function JB_isFilled(item,len) {
	var str=(item.value)?item.value:item; 
   	return (str.length >= len);
}


/*
	display an error alert
*/
function JB_doErr(elem,text) {
   	//when any error is found, pop up an alert dialogue
   	if (errfound) return;
   	window.alert('\n'+text+'\n');
   	if((elem.type == 'text' || elem.type == 'password' || elem.type == 'file' || elem.tagName == 'TEXTAREA' || elem.tagName == 'SELECT') && (elem.disabled == false)){
   		elem.focus();
   	}
   	errfound=true;
}


/*
function	:	JB_doTranlate
parameters	:	locale (required)(zh_TW | zh_CN)
descriptin	:	swap encodings between big5 and GB2312
*/
function JB_doTranlate(locale){
	if(!(locale=='zh_TW' || locale=='zh_CN')) return;
	var theURL=document.URL;
	var newURL='';
	var thePathname=window.location.pathname;
	var theSearch=window.location.search;
	var theHash=window.location.hash;

	theURL=(theHash ==-1 || theHash == '')?theURL:theURL.substring(0,theURL.indexOf(theHash));

	var theLocaleIdx=theSearch.indexOf('_locale');
	if(theSearch==-1 || theSearch==''){
		newURL=theURL+'?_locale='+locale;
	}
	else if(theLocaleIdx==-1){
		newURL=theURL+'&_locale='+locale;
	}
	else{
		newURL=thePathname+theSearch.substring(0,theLocaleIdx)+'_locale='+locale;
	}

	newURL=newURL+theHash;

	window.location.replace(newURL);
}


function JB_getURLParams(myParam) {
	var searchedStr = window.location.search;
	var params = new Array();
	var myValue = null;
	
	var pairs = searchedStr.split('&');
	for (var i = 0; i < pairs.length; i++) {
		nameVal = pairs[i].split('=');
		params[nameVal[0]] = nameVal[1];
		if(nameVal[0] == myParam){
			myValue = nameVal[1];
			break;
		}
  	}
  	
	return myValue;
}


function jbFcmControl(objID,v) {
	var obj = MM_findObj(objID);
	if (obj == null) return;
	if (obj.style)  obj = obj.style;
    obj.visibility = v; 
}


var timer = null;


function jbFcmOpen(objID) {
	if(timer != null) {
		
		clearTimeout(timer);
		timer = null;
	}
	jbFcmControl(objID,'visible');
}


function jbFcmClose(objID) {
	var action = 'jbFcmControl(\'' + objID + '\',\'hidden\') ';
	timer= setTimeout(action,600);
}

startList = function() 
{	
    if (document.all&&document.getElementById) 
    {

	navRoot = document.getElementById("H_Main_ul");
	sideRoot = document.getElementById("sideul");	
	
	
		if(sideRoot!=null)
	{
	
		 for (i=0; i<sideRoot.childNodes.length; i++) 
            {
				node = sideRoot.childNodes[i];
				
					if (node.nodeName=="LI") 
						{   node.onmouseover=function() {  this.className+=" over";	    }
							node.onmouseout=function() 	{  this.className=this.className.replace(" over", ""); }
							node.onfocusin=function() 	{  this.className+=" over";}
							node.onfocusout=function() 	{  this.className=this.className.replace(" over", "");  }			
							
							
						}
	    	}
		
		}


	if(navRoot!=null)
	{
		
		
	    for (i=0; i<navRoot.childNodes.length; i++) 
            {
				node = navRoot.childNodes[i];
					
					if (node.nodeName=="LI") 
						{   node.onmouseover=function() {  this.className+=" over";	    }
							node.onmouseout=function() 	{  this.className=this.className.replace(" over", ""); }
							node.onfocusin=function() 	{  this.className+=" over";}
							node.onfocusout=function() 	{  this.className=this.className.replace(" over", "");  }			
						}
	    	}
	}//end
	
   }
   
}

function Remov_code(getcode,inscode,words)
{	
	var get=document.getElementById(getcode).value.replace(/(<\/?[^>\/]*)\/?>/gi,"");
			get=get.replace(/◎|●|★/ig,"");
			get=get.replace(/<img.|a.+>/ig,"");
			get=get.replace(/<iframe.+>/ig,"");			
			get=get.replace(/^(&nbsp;|[\s])+|(&nbsp;|[\s])+$/gi,"" );
		if (words!=null || words >0)
		{
		document.getElementById(inscode).innerHTML=get.substring(0,words);
		}
		else 
		{
			document.getElementById(inscode).innerHTML=get		
		}
}

window.onload=startList;
