

function fireDomEvent(srcElement,invokedMethod){

if (srcElement.fireEvent) {
     srcElement.fireEvent(invokedMethod);
} else {
   var e = document.createEvent('HTMLEvents');
   //remove prefix "on" in invokdeMethod
  // alert(invokedMethod.substring(2,invokedMethod.length));
   e.initEvent(invokedMethod.substring(2,invokedMethod.length), false, false);
   srcElement.dispatchEvent(e);
}


}



function Debug_info(title,msg){
   if(document.getElementById("SYS_DEBUG_PANEL")) document.getElementById("SYS_DEBUG_PANEL").innerHTML=document.getElementById("SYS_DEBUG_PANEL").innerHTML+new Date()+">"+title+":"+msg+"<br>";

}





function getInputValue(obj){
  var res=null;
  
  //if it is single option
  if(!obj.length) {
      if   (obj.checked){   
        res=obj.value; 	 
      }   

  }else {
	  for   (i=0;i<obj.length;i++){   
		  if   (obj[i].checked){   
			  res=obj[i].value;  
			 
			  break;
		  }   
	  }
  }
 return res;   
}

function setInputValue(radioObj,newValue){
if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
  
}


function submitOffline(edpApplet,form,uiPrefix,dataSourceStr){
         var json= getFormJson(document.detailForm)
         var obj=edpApplet.execute(jsonToString(json));   
         createUIControl(edpApplet,obj,dataSourceStr,uiPrefix);
}




//create UI Control via applet regarding div prefixed with "SYS_"
function createUIControl(edpApplet,obj,dataMapString,predixPath){
        
     var divArray=document.getElementsByTagName('div')

     for(var i=0;i<divArray.length;i++){
		 var divObj=divArray[i];
		 if( divObj.id &&   divObj.id.indexOf("SYS_")==0) {
             var controlId= divObj.id.substring(4);
			 var str=edpApplet.createUIControl(obj,dataMapString,predixPath+controlId);
             document.getElementById(divObj.id ).innerHTML=str;

         }


	 }

}








function jsonToString(o){
    var r = [];
    if(typeof o =="string") return "\""+o.replace(/([\'\"\\])/g,"\\$1").replace(/(\n)/g,"\\n").replace(/(\r)/g,"\\r").replace(/(\t)/g,"\\t")+"\"";
    if(typeof o == "object"){
        if(!o.sort){
            for(var i in o)
                r.push(i+":"+jsonToString(o[i]));
            if(!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)){
                r.push("toString:"+o.toString.toString());
            }
            r="{"+r.join()+"}"
        }else{
            for(var i =0;i<o.length;i++)
                r.push(jsonToString(o[i]))
            r="["+r.join()+"]"
        }
        return r;
    }
    return o.toString();
}


function mergeObject  (ob1,ob) {
	var o = ob1;
	var i = 0;
	for (var z in ob) 	{		
		if (ob.hasOwnProperty(z)) {o[z] = ob[z];}
	}
	return o;
}



function urlToJson(url){
  var json=eval("({})");
  var iconPos=url.indexOf("?");
  var actionEventStr=url;

  if(iconPos>0){
     var paramString=url.substring(iconPos+1);
     var params=paramString.split("&");
	 for(var i=0;i<params.length;i++){
       var peer=params[i].split("=");
       json[peer[0]]=peer[1];
	 }
    
    actionEventStr=url.substring(0,iconPos)

  }
  
  //handle actionEvent
  if(actionEventStr.indexOf("controlservlet")<0){
      var duPos= actionEventStr.indexOf(".du");
	  if(duPos>=0) {
         var action=actionEventStr.substring(0,duPos).split("$");
		 //handle if action if  action$event
		 json["action"]=action[0];
		 if(action.length==2){
		    json["event"]=action[1];
		 }



	  }
     
  }






  return json;


}




//dynamic form create

function createNewForm(id){
    
	if(document.getElementById(id)!=null) return document.getElementById(id);
	
	var submitForm = document.createElement("FORM");

	

    document.body.appendChild(submitForm);
    submitForm.method = "POST";
	submitForm.id=id;
	submitForm.name=id;
    return submitForm;

}



//disble input control depends on the status of other control
//////////////////////////////Begin
function enableDependon(){
   var inputs= document.getElementsByTagName("input");
   for (i=0;i<inputs.length; i++) {
      if(inputs[i].dependon!=null  && inputs[i].dependon!=""   ){			
			ids=inputs[i].dependon.split();			 
			for(j=0;j<ids.length; j++){	
			  reverseFlag=ids[j].startWith("!");
			  if(reverseFlag)   ids[j]=ids[j].substring(1);	
              if(!reverseFlag)   inputs[i].disabled= document.getElementById(ids[j]).disabled;
              else inputs[i].disabled= !document.getElementById(ids[j]).disabled;

			}           

	  }    
   }
 inputs= document.getElementsByTagName("a");
   for (i=0;i<inputs.length; i++) {
        if(inputs[i].dependon!=null  && inputs[i].dependon!=""   ){			
			ids=inputs[i].dependon.split();			 
			for(j=0;j<ids.length; j++){	
               reverseFlag=ids[j].startWith("!");
			   if(reverseFlag) ids[j]=ids[j].substring(1);
              // alert(ids[j]+document.getElementById(ids[j]));

			    if(!reverseFlag) disableLink( inputs[i],  document.getElementById(ids[j]).disabled);   
                else 
                disableLink( inputs[i], ! document.getElementById(ids[j]).disabled);   
			   
			   /**alert(ids[j]+reverseFlag);
               if ( document.getElementById(ids[j]).tagName=="A" ) {
                   if(!reverseFlag) disableEnableLink( inputs[i],  document.getElementById(ids[j]).disabled);   
				   //inputs[i].style.display=   document.getElementById(ids[j]).style.display;
				   else {                   
				       if( document.getElementById(ids[j]).style.display==""  || document.getElementById(ids[j]).style.display==null ) {
					     inputs[i].style.display="none";
					   }else {
                          inputs[i].style.display="";
					   }

				   }

			   }else {              
			     if(document.getElementById(ids[j]).disabled)
                   inputs[i].style.display="none";
                 else
                  inputs[i].style.display="";
			  }
			 
			**/
        } 
	  }    
   }

}

function disableLink(objLink,xHow){
    objLink.disabled = xHow;
//link with onclick
    

    if(objLink.onclick && xHow){  
        objLink.onclick = new Function("return false;" + objLink.onclick.toString().getFuncBody());
    }
    //link without onclick
    else if(xHow){  
     objLink.onclick = function(){return false;}
    }
    //remove return false with link without onclick
    else if(!xHow &&  objLink.onclick &&  objLink.onclick.toString().indexOf("function(){return false;}") != -1){            
      objLink.onclick = null;
    }
    //remove return false link with onclick
    else if(!xHow &&  objLink.onclick && objLink.onclick.toString().indexOf("return false;") != -1){  
      strClick = objLink.onclick.toString().getFuncBody().replace("return false;","")
      objLink.onclick = new Function(strClick);
    }
}

String.prototype.getFuncBody = function(){ 
  var str=this.toString(); 
  str=str.replace(/[^{]+{/,"");
  str=str.substring(0,str.length-1);   
  str = str.replace(/\n/gi,"");
  if(!str.match(/\(.*\)/gi))str += ")";

  return str; 
} 

////////////////////////////End



// show progress when ajax progress
function showProgress(){

    if(document.getElementById("progressDiv")!=null){
          document.getElementById("progressDiv").style.display="block";
         return ;

	}

	var obody = document.getElementsByTagName("body")[0];
	var frag = document.createDocumentFragment();
	var obol = document.createElement("div");
    obol.setAttribute("id", "progressDiv");
	obol.style.position = "absolute";
	obol.style.top = 0;	
	obol.style.zIndex = 998;
	obol.style.width = "100%";
	obol.innerHTML="<img src='images/waitpic.gif'>";
	frag.appendChild(obol);
	obody.insertBefore(frag, obody.firstChild);


}

function closeProgress(){  
    if(document.getElementById("progressDiv")!=null){
        document.getElementById("progressDiv").style.display="none";
	}


}

//toggleLayer
function showLayer(divId,flag) { //v3.0
   var a=document.getElementById(divId);
   
    if(a.style.display=="" ||  a.style.display=="block") {    
        a.style.display="none";
    }else{		
        a.style.display="block";      
	}	
}

//change element的class
function setClass(eleName,clsName) {
	document.getElementById(eleName).className = clsName;
}


 function setAttributeValue(aFormObject,aAttributeName,aValue){
 
    var len=document.psnlist.all.length;
    for(var i=0;i<len;i++){
      var objItem=aFormObject.item(i);
   
     if ( objItem!=null && objItem.getAttribute(aAttributeName)!=null ) {
	   objItem.value =aValue;             
	  }
     
    }

 }




//add HiddenDiv
function addHiddenClick(){
 
   for(i=0;i<20;i++){
   
    var aObj=document.getElementById("hiddendiv"+i);
   
    if(aObj!=null &&  aObj.style.display=="none"){  
     aObj.style.display="";
     document.getElementById("hiddeninput"+i).value=0;
     return;
    }
  }


}

function delHiddenClick(aIndex){



  document.getElementById("hiddendiv"+aIndex).style.display="none";
  document.getElementById("hiddeninput"+aIndex).value=1;



}


// to handle Item

function handleItem(aFormName,aAction,aItem){
   var aForm=document.forms.item(aFormName);
 
   aForm.checkitem.value=aItem;
   if(aAction=="EDIT" ){
    aForm.event.value="modify";
    }
   if(aAction=="PRINT" ){
    aForm.event.value="print";
    }

  if(aAction=="DEL"){
        var msg = "Do you really to delete the record?";
		if (confirm(msg) == false)
		    return;
		aForm.event.value="delete"
   
  }
  aForm.submit();



}

function appendHTML (el,HTMLString) {
if (!el) return;
if (window.ActiveXObject) { //For IE
el.innerHTML = "<img style='display:none'/>" + HTMLString.replace(/<script([^>]*)>/ig, '<script$1 defer>');
el.removeChild(el.firstChild)
} else { //For Mozilla,Opare
var nSibling = el.nextSibling;
var pNode = el.parentNode;
pNode.removeChild(el);
el.innerHTML = HTMLString;
pNode.insertBefore(el,nSibling)
}
}


function checkForm(aObj){
 
 for(var i=0;i<len;i++){

 var objItem=aObj.all.item(i);
  if (checkField(objItem)){
    alert("Please insert valid data!"); 
    return false;
  }



}
  return true;


}



function  getFloat(str,decimalLength)  
	 
{  
     
		   
		   if(decimalLength){
		     str  =  Math.round  (str*Math.pow(10,decimalLength))/Math.pow(10,decimalLength);  
           }else {
		      str  = 1* str;
		   }
		   return  str;  
}  

function addHiddenInput(formobj, name, value){
  /** var  inputObj=document.createElement("INPUT");
   inputObj.name=name;
   inputObj.type = "hidden"
   inputObj.value=value;
**/
    if (formobj[name]) {
        formobj[name].value = value;
    } else {
        var input = document.createElement("input");
        input.setAttribute("name", name);
        input.setAttribute("type", "hidden");
        input.setAttribute("value", value);
        formobj.appendChild(input);
        formobj[name] = input;
    }
   
 }

function removeHiddenInput(formobj, name){
                             
        var input = formobj.elements [name];       
		formobj.removeChild(input);	   
 }



 function bindInput(field,field2,field3,field4,field5,field6,field7,field8){ 
	var  checkBoxObj=document.getElementsByName(field);
    var  checkBoxObj2=document.getElementsByName(field2);
	var  checkBoxObj3=document.getElementsByName(field3);
	var  checkBoxObj4=document.getElementsByName(field4);
    var  checkBoxObj5=document.getElementsByName(field5);
	var  checkBoxObj6=document.getElementsByName(field6);
	var  checkBoxObj7=document.getElementsByName(field7);
	var  checkBoxObj8=document.getElementsByName(field8);
	
	var nCount=getCheckBoxCount(checkBoxObj ) ;
	if (nCount == 0){
		alert(MSG_SELECT_RECORD);
		return;
	}    


	var returnValue="",returnValue2="",returnValue3="",returnValue4="" ,returnValue5="", returnValue6="",returnValue7="",returnValue8="";    
	if (checkBoxObj.length != null && checkBoxObj.length > 0)
	{
		for (var i = 0; i < checkBoxObj.length; i ++)
			if (checkBoxObj[i].checked) {
			   returnValue=returnValue+checkBoxObj[i].value+",";
			
			   if(field2)   returnValue2=returnValue2+checkBoxObj2[i].value+","; 
			   if(field3)   returnValue3=returnValue3+checkBoxObj3[i].value+",";
			   if(field4)   returnValue4=returnValue4+checkBoxObj4[i].value+",";
			   if(field5)   returnValue5=returnValue5+checkBoxObj5[i].value+",";
			   if(field6)   returnValue6=returnValue6+checkBoxObj6[i].value+",";
			   if(field7)   returnValue7=returnValue7+checkBoxObj7[i].value+",";
			   if(field8)   returnValue8=returnValue8+checkBoxObj8[i].value+",";
		    }	
	}
	else
	{
		if (checkBoxObj.checked) {
			   returnValue=returnValue+checkBoxObj[i].value+",";
			   if(field2)   returnValue2=returnValue2+checkBoxObj2[i].value+",";
			   if(field3)   returnValue3=returnValue3+checkBoxObj3[i].value+",";
			   if(field4)   returnValue4=returnValue4+checkBoxObj4[i].value+",";
			   if(field5)   returnValue5=returnValue5+checkBoxObj5[i].value+",";
			   if(field6)   returnValue6=returnValue6+checkBoxObj6[i].value+",";
			   if(field7)   returnValue7=returnValue7+checkBoxObj7[i].value+",";
			   if(field8)   returnValue8=returnValue8+checkBoxObj8[i].value+",";
		};
			
	}
	if(returnValue.indexOf(",")==returnValue.length-1)returnValue=returnValue.substring(0,returnValue.length-1);    
    if(field2)   if(returnValue2.indexOf(",")==returnValue2.length-1)returnValue2=returnValue2.substring(0,returnValue2.length-1);    
    if(field3)   if(returnValue3.indexOf(",")==returnValue3.length-1)returnValue3=returnValue3.substring(0,returnValue3.length-1);    
    if(field4)   if(returnValue4.indexOf(",")==returnValue4.length-1)returnValue4=returnValue4.substring(0,returnValue4.length-1);  
	if(field5)   if(returnValue5.indexOf(",")==returnValue5.length-1)returnValue5=returnValue5.substring(0,returnValue5.length-1);    
    if(field6)   if(returnValue6.indexOf(",")==returnValue6.length-1)returnValue6=returnValue6.substring(0,returnValue6.length-1);    
    if(field7)   if(returnValue7.indexOf(",")==returnValue7.length-1)returnValue7=returnValue7.substring(0,returnValue7.length-1);   
	if(field8)   if(returnValue8.indexOf(",")==returnValue8.length-1)returnValue8=returnValue8.substring(0,returnValue8.length-1);   
	
   


    if(window.opener ){
  	   eval("window.opener."+onBindInput()+"(returnValue, returnValue2,returnValue3,returnValue4,returnValue5,returnValue6,returnValue7,returnValue8)");
  	   window.close();
    }else if(window.parent){
  	   eval("window.parent."+onBindInput()+"(returnValue, returnValue2,returnValue3,returnValue4,returnValue5,returnValue6,returnValue7,returnValue8)");
       window.parent.closeDivWindow();
	} 
    
	


 
 }

 function bindInputClear(){ 
     if(window.opener ){
  	   eval("window.opener."+onBindInput()+"('', '')");
  	
    }else if(window.parent){
  	   eval("window.parent."+onBindInput()+"('', '')");
    } 

 }


function getURLBase(){ 
  
	  if(appName=='/') {
	    protocalPrefix= document.location.toString().indexOf("://" );
        trimedUrl= document.location.toString().substring(protocalPrefix+3).indexOf(appName);		

        return   document.location.toString().substring(0,protocalPrefix +3+ trimedUrl );

      }else {
         var appNameIndex= document.location.toString().indexOf(appName );    
         return  document.location.toString().substring(0,appNameIndex  ) ;
      }
}









//openWindow 
function openWindow(this_url,w_width,w_height,w_name) {
     
       if (w_height>=screen.height-100) w_height=screen.height-100;
       if (w_width>=screen.width-100) w_width=screen.width-100;


    	var w_top = (screen.height - w_height)/2 - 30;
		var w_left = (screen.width - w_width)/2;	
		
        

		w_param = "top=#t#,left=#l#,width=#w#,height=#h#,channelmode = no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no";
		w_param = w_param.replace("#h#",w_height);
		w_param = w_param.replace("#w#",w_width);
		w_param = w_param.replace("#t#",w_top);
		w_param = w_param.replace("#l#",w_left);
        var childWindow=null;
         //added by Alan on 2009 07 for  unicode characters





        this_url=encodeURI(this_url);
	    if (w_name)
			childWindow = window.open(this_url,w_name,w_param);
		else
			childWindow = window.open(this_url,'',w_param);

         
 
        childWindow=null;

	
		
}


function closeWindow(url) {


  
  
   if(window.opener) {
         if(window.opener.refresh){
		    window.opener.refresh();
		 }
	
	  window.close();
     

   }else{   

      if(url)  document.location=url;
	  

    
       if(parent.closeDivWindow){       
		   if(parent.refresh){
		   parent.refresh();
		} 
        
		 parent.closeDivWindow(); 
	     
	   }



   }
  
 


}

 
 

function getCheckBoxCount(checkBoxObj){
	
	if (checkBoxObj == null)
	{
		return 0;
	}
	var nCount = 0;
	if (checkBoxObj.length != null && checkBoxObj.length > 0)
	{
		for (var i = 0; i < checkBoxObj.length; i ++)
			if (checkBoxObj[i].checked)
				nCount ++;
	}
	else
	{
		if (checkBoxObj.checked)
			nCount = 1;
	}

	return nCount;



}


function getCheckBoxIndex(checkBoxObj){
	
	if (checkBoxObj == null)
	{
		return 0;
	}
	var index = 0;
	if (checkBoxObj.length != null && checkBoxObj.length > 0)
	{
		for (var i = 0; i < checkBoxObj.length; i ++)
			if (checkBoxObj[i].checked){
				index=++i;
	}        }  
	else
	{
		if (checkBoxObj.checked)
			index = 1;
	}

	return index;



}


function getCheckedCount(objName)
{
	var aryChecked = document.getElementsByName;
	if (aryChecked == null)
	{
		return;
	}
	var nCount = 0;
	if (aryChecked.length != null && aryChecked.length > 0)
	{
		for (var i = 0; i < aryChecked.length; i ++)
			if (aryChecked[i].checked)
				nCount ++;
	}
	else
	{
		if (aryChecked.checked)
			nCount = 1;
	}
	return nCount;
}




function checkAll(checkListName, controlCheck)
{
    var aryChecked = document.getElementsByName(checkListName);
    if (aryChecked != null)
    {
        if (aryChecked.length != null && aryChecked.length > 0)
        {
            for (var i = 0; i < aryChecked.length; i ++)
            {
				if (aryChecked[i].disabled == false)
				{
				    aryChecked[i].checked = controlCheck.checked;
				}
            }
        }
        else
        {
			if (aryChecked.disabled == false)
			    aryChecked.checked  = controlCheck.checked;
        }
    }
}

function checkClear(aryChecked)
{
   

    if (aryChecked != null)
    {
        if (aryChecked.length != null && aryChecked.length > 0)
        {
            for (var i = 0; i < aryChecked.length; i ++)
            {
				
				    aryChecked[i].checked = false;;
				
            }
        }
        else
        {
			   aryChecked.checked  = false;
        }
    }
}


function checkItem(checkListName, controlCheck)
{

	
	var aryChecked = document.getElementsByName(checkListName);
	if (aryChecked != null)
	{
		if (aryChecked.length != null && aryChecked.length > 0)
		{
			var nCount = 0;
			for (var i = 0; i < aryChecked.length; i ++)
			{
				if (aryChecked[i].checked)
				    nCount ++;
			}
			if (nCount == aryChecked.length)
			    controlCheck.checked = true;
			else
			    controlCheck.checked = false;
		}
		else
		{
			controlCheck.checked = aryChecked.checked;
		}
	}
}











	function checkSingle( needChangeName,headObj) {		
    	var checkObj = document.getElementsByName(headObj.name);
		if (checkObj) {
            var count=checkObj.length;
            var checkedCount=0;
			for (var i = 0; i < checkObj.length; i++) {
			   if(	checkObj[i].checked ) checkedCount++;
			}

		  if(checkedCount==count)
			    document.getElementsByName(needChangeName)[0].checked=true;
		  else 
			    document.getElementsByName(needChangeName)[0].checked=false;
	    
			
			
			}

          


	}


	
	function trim(str) { 
		if (str.length > 0) {
			while ((str.substring(0,1) == " ") && (str.length > 0)) { 
				str = str.substring(1,str.length); 
			} 
			
			while (str.substring(str.length-1,str.length) == " ") { 
				str = str.substring(0,str.length-1); 
			}
		}
		return str;
	}
	
	function typeofFunction(targetObj, functionName) {

		if (document.all) {
			var funcObj = eval("targetObj." + functionName);
			if (funcObj) {
				var funStr = funcObj.toString();
				return (funStr && funStr.length >= 8 && funStr.substring(0, 8) == "function");
			} else {
				return false;
			}
		} else {
			return eval("typeof targetObj."+functionName) == "function";
		}

	}
	
	function buildForm(url, target, name) {
		var urls = url.split("?");
		if (urls[1])
			var params = urls[1].split("&");
			
		var formObj = document.createElement("FORM");
		formObj.action = urls[0];
		formObj.target = target;
		formObj.method = "POST";
		
		if (name)
			formObj.name = name;
			
		if (params) {
			for (var i = 0; i < params.length; i ++) {
				var inputObj = document.createElement("INPUT");
				inputObj.type = "hidden"
				inputObj.name = params[i].split("=")[0];
				inputObj.value = params[i].split("=")[1];
				
				formObj.appendChild(inputObj);								
			}		
		}
		
		document.body.appendChild(formObj);
		formObj.submit();
		document.body.removeChild(formObj);	
	}

	function startWith(oStr, sStr) {
		var s = oStr.substring(0, sStr.length);
		return s.toLowerCase() == sStr.toLowerCase();
	}
	





  function getBoundingClientLeft(obj) {
		var left = 2;
		if (obj.clientLeft)
			left = obj.clientLeft;
		while (obj) {			
			left += obj.offsetLeft;
			obj = obj.offsetParent;
		}
		return left;
	}

	function getBoundingClientTop(obj) {
		var top = 2;
		if (obj.clientTop)
			top = obj.clientTop;
		while (obj) {
			top += obj.offsetTop;
			obj = obj.offsetParent;
		}
		return top;
	}

	function getBoundingClientRight(obj) {
		return obj.offsetWidth + getBoundingClientLeft(obj);
	}
	
	function getBoundingClientBottom(obj) {
		return obj.offsetHeight + getBoundingClientTop(obj);
	}
	





/**	
	The follow stringbuffer toString method  will cause JQuery running in abnormal ,so change toString to toFullString
**/

	function StringBuffer(bufferSize) {
		if (bufferSize)
			this.bufferSize = bufferSize;
		else
			this.bufferSize = 500;
		this.bf = new Array(this.bufferSize);
		this.top = 0;
		this.value = "";

		this.append = append;
		this.toString = toFullString;
		this.concatBuffer = concatBuffer;

	}

	function append(str) {		
		this.bf[this.top++] = str;
		
		if (this.top == this.bufferSize) {
			this.concatBuffer(this.top);
			this.top = 0;
		}

		return this;
	}

	function toFullString() {
		this.concatBuffer(this.top);
		return this.value;
	}

	function concatBuffer(endIndex) {
		for (var i = this.bufferSize-1;i >= endIndex ;i-- ) {
			this.bf[i] = "";
		}
		this.value = this.value.concat(this.bf.join(""));		
	}		














function enterToTab(){
        if(event.srcElement.type != 'button' && event.srcElement.type != 'textarea' && event.keyCode == 13){
                event.keyCode = 9;
        }
}

////show layer
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d)  //v4.0
{
  var p,i,x;
  if(!d)
    d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document;
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all)
    x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++)
    x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
    x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById)
    x=document.getElementById(n);
  return x;
}

/**Start of HashMap implementation   * used like java.lang.HashMap   */


/**
* @fileoverview Contains <tt>HashMap</tt> class. A HashMap cannot contain duplicate keys;
* each key can map to at most one value.
*
* <p>
* This is part of Troika.ASP Framework - web development MVC framework for ASP 3.0.
* Please visit {@link http://www.troika-asp.com www.troika-asp.com} for more details.
* </p>
*
* @author Pavel Chuchev pav@troika-asp.com
* @version $Revision: 1.4 $
*/
/**
* Constructs an empty <tt>HashMap</tt> object.
*
* @class This is <tt>HashMap</tt> class - implementation of an object that maps keys to values.
*
* @constructor
* @return A new <tt>HashMap</tt> object
* @type HashMap
*/
function HashMap() {

    this.init();
}

/**
* Initializes an empty <tt>HashMap</tt>.
*
* @return <tt>HashMap</tt> object instance itself
* @type HashMap
*/
HashMap.prototype.init = function () {

    this.values = {

    };
    this.isValidating = false;
    return this;
};

/**
* Removes all of the key/value pairs this map.
*/
HashMap.prototype.clear = function () {

    this.values = {

    };
};

/**
* Returns <tt>true</tt> if this map contains the specified key.
*
* @param {Object} key The key whose presence in this map is to be tested.
* @return <tt>true</tt> If this map contains the specified key.
* @type boolean
*/
HashMap.prototype.containsKey = function (key) {

    return typeof (this.values[key]) != "undefined";
};

/**
* Returns <tt>true</tt> if this map contains the specified value.
*
* @param {Object} value The value whose presence in this map is to be tested.
* @return <tt>true</tt> If this map contains the specified value.
* @type boolean
*/
HashMap.prototype.containsValue = function (value) {

    for (var key in this.values) {

        var val = this.values[key];
        if (val == value) {

            return true;
        }
    }

    return false;
};

/**
* Returns value for the key.
*
* @param {Object} key The key whose value in this map is to be returned.
* @return The value if found or <tt>undefined</tt> if not found and isValidating flag is not set.
* @throws Error If the key is not found.
* @type Object
*/
HashMap.prototype.get = function (key) {

    if (this.containsKey(key)) {

        return this.values[key];
    }
    else {

        if (this.isValidating) {

            throw new Error("Field '" + key + "' not found");
        }
        return undefined;
    }
};

/**
* Tests if this map has no elements.
*
* @return  <tt>true</tt> If this map has no elements;
*          <tt>false</tt> otherwise.
* @type boolean
*/
HashMap.prototype.isEmpty = function () {

    return !this.size();
};

/**
* Returns an array of the keys contained in this map.
*
* @return A an array of the keys contained in this map.
* @type Array
*/
HashMap.prototype.keySet = function () {

    var result = [];
    for (var key in this.values) {

        var value = this.values[key];
        if (typeof (value) != "object" && typeof (value) != "function") {

            result.push(key);
        }
    }

    return result;
};

/**
* Associates the specified value with the specified key in this map.
* If the map previously contained a mapping for this key, the old value is
* replaced by the specified value.
*
* @param {Object} key The key with which the specified value is to be associated.
* @param {Object} value The value to be associated with the specified key.
* @return The previous value associated with specified key, or <tt>undefined</tt>
*          if there was no mapping for key.
* @type Object
*/
HashMap.prototype.put = function (key, value) {

    var previous = this.containsKey(key) ? this.get(key) : undefined;

    this.values[key] = value;
    return previous;
};

/**
* Copies all of the mappings from the specified map to this map.
*
* @param {Object} values Mappings to be stored in this map.
*/
HashMap.prototype.putAll = function (values) {

    if (typeof (values) == "object") {

        for (var key in values) {

            var value = values[key];
            this.values[key] = value;
        }
    }
};

/**
* Removes the mapping for this key from this map if it is present.
*
* @param {Object} key The key whose mapping is to be removed from the map.
* @return The previous value associated with specified key, or <tt>undefined</tt>
*          if there was no mapping for key.
* @type Object
*/
HashMap.prototype.remove = function (key) {

    var value = this.containsKey(key) ? this.get(key) : undefined;

    if (value) {

        delete this.values[key];
    }

    return value;
};

/**
* Returns the number of key-value mappings in this map.
*
* @return The number of key-value mappings in this map.
* @type int
*/

HashMap.prototype.size = function () {

    var count = 0;
    for (key in this.values) {

        count++;
    }
    return count - 1;
};

/**
* Populates this map with key/value pairs from the specified collection.
* Where the value is <tt>ArrayList</tt> containing one or more values per key.
* It adapts one ASP collection object to HashMap object. 
*/
HashMap.prototype.populate = function (collection) {

    var vars =  new Enumerator(collection);
    for (vars.moveFirst(); !vars.atEnd(); vars.moveNext()) {

        var key = vars.item();
        if (!this.containsKey(key)) {

            var arrayList =  new ArrayList();

            var values = collection(key);
            try {

                var en =  new Enumerator(values);
                for (en.moveFirst(); !en.atEnd(); en.moveNext()) {

                    arrayList.add(en.item());
                }
            }
            catch (e) {

                arrayList.add(values);
            }

            this.values[key] = arrayList;
        }
    }
};



/** End  of HashMap implementation  **/

