function execFilter(gid,url,ffKey,flKey) {

	var u = url;
	var ffArr = new Array();
	var flArr = new Array();
	var frm = document.forms[0];
	for(var i = 0; i < 9; i++) {
		ffKeyC = ffKey.substring(1) + i.toString();
		flKeyC = flKey.substring(1) + i.toString();
		els = getFormElementsByNameEnd(ffKey+ i.toString(),gid,true)
		if (els.length>0) {
		    ffArr[ffArr.length] = els[0];
		}
		els = getFormElementsByNameEnd(flKey+ i.toString(),gid,true)
		if (els.length>0) {
		    flArr[flArr.length] = els[0];
		}
	}
	
	for(var i = 0; i < ffArr.length; i++) {
		ffKeyC = ffKey + i.toString();
		flKeyC = flKey + i.toString();
		if (ffArr[i].value != '') {
			u = u +  '&' + gid + ffKeyC + '=' + ffArr[i].value.replace("&","%26");
			//u = u +  '&' + gid + ffKeyC + '=' + ffArr[i].value;
			if (flArr[i].options && flArr[i].options[flArr[i].selectedIndex]){
				u = u +  '&' + gid + flKeyC + '=' + flArr[i].options[flArr[i].selectedIndex].value;
			} else {
			    if (flArr[i]!=null && flArr[i]!='undefined'){
				    u = u +  '&' + gid + flKeyC + '=' + flArr[i].value;
				}
			}
		}
	}
	u=encodeURI(u).replace("%2526","%26");
	document.location.href = u;
}

// folowing function are for faster execution of getFormElementsByNameEnd
var __resultStore=null;
function addToResultStore(result, param1,param2,param3){
    if (__resultStore==null){
        __resultStore=[];
    }    
 	isSet=false;
 	for(var i = 0; i < __resultStore.length; i++) {
 	    if (__resultStore[i][1]==param1 && __resultStore[i][2]==param2 && __resultStore[i][3]==param3){
 	        isSet=true;
 	        __resultStore[i]=[result,param1,param2,param3]
 	        break;
 	    } 
 	}
    if (isSet==false){
        __resultStore[__resultStore.length]=[result,param1,param2,param3]
    }
    return result;
}
function checkResultStore(param1,param2,param3){
    if (__resultStore==null){
        return null;
    }else{
 	    for(var i = 0; i < __resultStore.length; i++) {
 	        if (__resultStore[i][1]==param1 && __resultStore[i][2]==param2 && __resultStore[i][3]==param3){
 	            return __resultStore[i][0]
 	        } 
 	    }
    }
    return null
}
function getFormElementsByNameEnd(elementName, substring, returnFirstResultOnly){// return array
	var result = checkResultStore(elementName, substring, returnFirstResultOnly)
	if (null!=result){
	    return result;
	}
	var frm = document.forms[0];
	if (elementName.length>1){
		elName = elementName.substr(1)
	}else{
		elName = elementName
	}
    var els = new Array();
    for(var j = 0; j < frm.length; j++){
        nm = frm[j].name
		if (nm == elementName){
		   els[els.length] = frm[j];
		} else {
			if (nm.length > elName.length) {
				nmEnd = nm.substr(nm.length - elName.length,nm.length)
				if (substring != null){
					 if (nm.indexOf(substring)>-1){
						if (nmEnd == elName){
							els[els.length] = frm[j];
							if (returnFirstResultOnly==true){
							    return addToResultStore(els,elementName, substring, returnFirstResultOnly);
							} 
						}
					}
				}else{
					if (nmEnd == elName){
						els[els.length] = frm[j];
						if (returnFirstResultOnly==true){
						    return addToResultStore(els,elementName, substring, returnFirstResultOnly);
						} 
					}
				}
			}
		}
    }
    return addToResultStore(els,elementName, substring, returnFirstResultOnly);
}

/*
function getCheckFromElement(nameEndWith){
	els = getFormElementsByNameEnd(nameEndWith)
	if (els.length>0) {
        for(var j = 0; j < els.length; j++){
            if (els[j].checked==true){
                return els[j].value;
            }
        }
	}
}

function execExport_(url,efKey,etKey,cExpFormat){
	var u = url;
	var efValue ;
	var etValue ;
	var frm = document.forms[0];
    efValue=getCheckFromElement(efKey)
    etValue=getCheckFromElement(etKey)

    var formatValue ='';
    if (efValue!='undefined' && efValue!=''){
        formatValue= efValue;
    }
    
    if (etValue=='newwindow' || etValue=='undefined' || etValue==null){
    	u = u +  '&'  + efKey + '=' + formatValue;;
    	var windowExport = window.open(u);
	    windowExport.focus();
    }else{
        etValue=etValue.replace('='+cExpFormat,'='+formatValue)
        eval(etValue)
    }
}
*/
function execExport(url,cExpFormat,efrmKey,remotejs){
	var u = url;
    var fldIdx;
    
    var fld = getFormElementByNameEnd(efrmKey);
    var formatValue ='';
    if (fld!='undefined' && fld!=null){
        mm=indooExportMode[fld.selectedIndex];
        formatValue=fld.options[fld.selectedIndex].value
    }
  
  
    if (mm==0 || mm==2 || mm==3 || mm=='undefined' || mm==null){
    	u = u +  '&'  + efrmKey + '=' + formatValue;;
    	var windowExport = window.open(u);
	    windowExport.focus();
    }else{
        remotejs=remotejs.replace('='+cExpFormat,'='+formatValue)
        eval(remotejs)
    }
}
function setVisible(el,isVisible){
    var visibility;
    if (isVisible==true){
        visibility='visible';
    }else{
        visibility='hide';
    }
    if(document.getElementById){//modern browsers
        obj = el.style;
    }
    else if(document.all){//IE 4
        obj = el.style;
    }
    else if(document.layers){//NS 4
        obj = el;
        if(isVisible){
            visibility='show';
        } else if(isVisible==false){
            visibility='hide'
        }
    }
    alert(obj.visibility)
    obj.visibility=visibility;
}


function copy_clip(copyText) {
     var isOk = false;
     if (window.clipboardData) { // IE send-to-clipboard method.
          window.clipboardData.setData('Text', copyText);
          isOk = true;
     } else if (window.netscape) {
          // You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true);
          netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
          
          // Store support string in an object.
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          if (!str) return false;
          str.data=copyText;
          
          // Make transferable.
          var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
          if (!trans) return false;
          
          // Specify what datatypes we want to obtain, which is text in this case.
          trans.addDataFlavor("text/unicode");
          trans.setTransferData("text/unicode",str,copyText.length*2);
          
          var clipid=Components.interfaces.nsIClipboard;
          var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
          if (clip) {
              isOk = true;
              clip.setData(trans,null,clipid.kGlobalClipboard);
          }
     }
        if (isOk==false) {
            var flashcopier = 'flashcopier';
            if(!document.getElementById(flashcopier)) {
              var divholder = document.createElement('div');
              divholder.id = flashcopier;
              document.body.appendChild(divholder);
            }
            document.getElementById(flashcopier).innerHTML = '';
            var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(copyText)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
            document.getElementById(flashcopier).innerHTML = divinfo;      
      }
     
}

function getaction(index){
	return act.split("_")[index]
}
function checkTab(elementID) {
	if (document.getElementById){
		if (document.getElementById(elementID)){
			element=document.getElementById(elementID);
			if ((9==event.keyCode) && (event.ctrlKey)) {
				element.selection = document.selection.createRange(); 
				element.selection.text=String.fromCharCode(9);
				setTimeout('element.focus()',0);
			}
		}
	}
}

function ddlCommand(ddlId,commandIndex, commandSubIndex){
	ddl=getFormElementByNameEnd(ddlId);
	if (ddl!=null){
		var funcs1 = ddl.options[ddl.selectedIndex].value.split(";")
		if (funcs1.length>commandIndex){
			var funcs2 = funcs1[commandIndex].split(":")
			if (funcs2.length>commandSubIndex){
				if (funcs2[commandSubIndex].length>0){
					eval(unescape(funcs2[commandSubIndex]));
				}
			}
		}
		//alert(unescape(ddl.options[ddl.selectedIndex].value) +'\n'+commandIndex+'\n'+commandSubIndex)
	}
}

    function getFormElementByNameEnd(elementName){
		var frm = document.forms[0];
		for(var j = 0; j < frm.length; j++){
			nm = frm[j].name;
			if (nm == elementName){
			   return frm[j];
			}
			if (nm.length > elementName.length) {
				nmEnd = nm.substr(nm.length - elementName.length,nm.length)
				if (nmEnd == elementName){
				   return frm[j];
				}
			}
		}
		return null;
	}

//-->
function fltClmnChng(s,sel,cellId){
    arr=eval(s);
    alt=0;
    for(var i = 0; i < arr.length; i++) {
        if(arr[i]==sel.options[sel.selectedIndex].value){alt=1}
    };
    el=getFormElementByNameEnd(cellId);
	if (document.getElementById){
		if (document.getElementById(cellId)){
			el=document.getElementById(cellId);
		}
	}

   
    if(el!=null && el!='undefined'){
		el=el.parentNode;
		for (var u = 0; u < el.childNodes.length; u++) {
			if (alt==0){
				setElementVisibility(el.childNodes[u],false)
			}else{
				setElementVisibility(el.childNodes[u],true)
			}
		}
    }
}
function setElementVisibility(el, showIt){
 			if (el!=null && el!='undefined' && el!=''){
				if (el.style!=null && el.style!='undefined' && el.style!='' && el.type!='hidden' ){
                    if( el.style ) {
                        if (showIt==true) {
                            el.style.display = "inline";
                        }else{
                             el.style.display = "none";
                        }
                    }
				}
			}
   
}

