		function closeMe(){
			window.close();
		}
	
    function submitOnEnter(event, formname) {
		//Take care of IE's strange event handler
		if (!event) event = window.event;
		if (event && event.keyCode == 13) {
			submitForm(formname);
		}else{
			return true;
		}
    }

    function gotoTab(formname,tabname){
      setComponentValue(formname,"selectedTab",tabname);
      submitForm(formname);
    }
	
		function isAppletForm(formname){
			return (document.applets[formname]!=null);
		}
		
		function isDropDown(comp){
			if(comp.options!=null){
				return true;
			}else{
        return false;
			}
		}

		// gets either the PageWithTabsForm if this is a tabbed box,
		// or the named form
		function getForm(formname){
			// first try for tabbed page form
			theform=document.forms['PageWithTabsForm'];
     // alert ("getting form, " + theform + " formname  " + formname);
			if(theform==null){
        
				theform=document.forms[formname];
        
      //  alert("form null, getting new form " + theform + " new form name "+ theform.name );
			}
			return theform;
		}


		function setAddListValues(formname,compname,values,hiddenname,skipapplet)
		{
			if (isAppletForm(formname))
			{
				return;
			}
			theform=getForm(formname);
			thecomponent=theform[compname];
			thehidden=theform[hiddenname];
			if (thehidden==null||thehidden.value=="off")
			{
				return;
			}
			
			if (thecomponent==null)
			{
				//alert("Error: component "+compname+ " not found");
				return;
			}
			var selarr=thecomponent.options;
			for (x=selarr.length-1;x>=0;x--)
			{
				selarr[x]=null;
			}
			if (values=="null" || values=="")
			{
				return;
			}
			valstr=new String(values);
			valarr=valstr.split(",");
			for(x=valarr.length-1;x>=0;x--){
					newOp=new Option();
					newOp.text=valarr[x];
					selarr[x]=newOp;
			}
		}
		// sets the named component on the named form to the given value
		// returns true if assignment succeeds, false otherwise.
		// assignment will fail if component is a dropdown and the given value
		// is not in the list
    // if skipapplet is true, don't try to set component on applet form
    // (used if called from applet)
    function setComponentValue(formname,compname,value,skipapplet){
        if(value==null || value=="null" || value=="undefined") value="";
        if(compname=="newcolumn") return;
        valstr=new String(value);
        valarr=valstr.split("+");
        value="";
        for(x=0;x<valarr.length;x++){
            if(x!=0) value+=" ";
            value+=valarr[x];
        }
        value=unescape(value);
        theform=getForm(formname);
        thecomponent=theform[compname];
        if(thecomponent==null){
            //alert(" SetComponentValue() Error: "+compname+" not found");
            return;
        }
        if(isDropDown(thecomponent) ){
            // so try to find the right option
            foundone=false;
            for(x=thecomponent.options.length-1;x>=0;x--){
					if(!foundone && thecomponent.options[x].value==value){
                    thecomponent.options[x].selected=true;
                    foundone=true;
                }
                else{
                    thecomponent.options[x].selected=false;
                }
            }
            if(!foundone && thecomponent.options.length>0){
                thecomponent.options[0].selected=true;
            }
            thecomponent=null;
            return foundone;
        }	
        if(thecomponent.length==null)
        {
            thecomponent.value=value;
				
            if(!skipapplet && isAppletForm(formname)){
                setAppletComponentValue(formname,compname,value);
            }
			
            if(value=="on"){
                    thecomponent.checked=true;
                    //if(compname='dealer') alert(compname+'-on');
            }
            if(value=="off"){
                    thecomponent.checked=false;
                    //if(compname='dealer') alert(compname+'-off');
                    // wierd, but otherwise it won't get submitted if we turn it on
                    //thecomponent.value="on";
            }
        }
        else{
            // must be a radio button
            for(x=0;x<thecomponent.length;x++){
                if(thecomponent[x].value==value){
                    thecomponent[x].checked=true;
                }
                else{
                    thecomponent[x].checked=false;
                }
            }
        }
        return true;
    }
    
    
    // Used for components with multiple select
    // takes an array of values
    function setComponentValues(formname,compname,values,skipapplet){
        
        if(compname=="newcolumn") return;
        theform=getForm(formname);
        thecomponent=theform[compname];
        if(thecomponent==null){
            //alert(" SetComponentValue() Error: "+compname+" not found");
            return;
        }
                
        if(values==null) values = new Array("");

        //initialise options list so that all options are false
        for(x=thecomponent.options.length-1 ;x>=0; x--){
            thecomponent.options[x].selected=false;
        }
        
        // Loop through each value that has been passed in
        for(i=0; i < values.length; i++){
            if(values[i]==null || values[i]=="null" || values[i]=="undefined") values[i]="";
        
            valstr=new String(values[i]);
            valarr=valstr.split("+");
            values[i]="";
            for(x=0;x<valarr.length;x++){
                if(x!=0) values[i] += " ";
                values[i] += valarr[x];
            }
        
            values[i] = unescape(values[i]);
            
            if(isDropDown(thecomponent) ){
                // so try to find the right option
                foundone=false;
                for(x=thecomponent.options.length-1 ;x>=0; x--){

                    if(!foundone && thecomponent.options[x].value==values[i]){              
                        thecomponent.options[x].selected=true;
                        foundone=true;
                    }
                }
                if(!foundone && thecomponent.options.length>0){
                    thecomponent.options[0].selected=true;
                }
                //thecomponent=null;
                //return foundone;
            }
            // For components other than option boxes
            else if(thecomponent.length==null){
                thecomponent.value=values[i];                    
                if(!skipapplet && isAppletForm(formname)){
                    setAppletComponentValue(formname,compname,values[i]);
                }
                            
                if(values[i]=="on"){
                        thecomponent.checked=true;
                }
                if(values[i]=="off"){
                        thecomponent.checked=false;
                        // wierd, but otherwise it won't get submitted if we turn it on
                        //thecomponent.value="on";
                }
            }
            // must be a radio button
            else{
                for(x=0;x<thecomponent.length;x++){
                    if(thecomponent[x].value==values[i]){
                        thecomponent[x].checked=true;
                    }
                    else{
                        thecomponent[x].checked=false;
                    }
                }
            }
        }
        return true;
    }
		
    // returns the value of a component
    function getComponentValue(formname,compname){
        theform=getForm(formname);
        var thecomponent=theform[compname];        

        if(thecomponent==null){
            //alert("getComponentValue() Error: "+compname+" not found");
            return "";
        }
        if(isDropDown(thecomponent)){
            index=thecomponent.selectedIndex;
            if (index==-1) {
                    return "";
            }
            thevalue=thecomponent.options[thecomponent.selectedIndex].value;
            thecomponent=null;
            return thevalue;
        }
	if(thecomponent.length==null)
	{
            thevalue=thecomponent.value;
        }
        else{
            // radio button
            for(x=0;x<thecomponent.length;x++){
                if(thecomponent[x].checked) {
                    thevalue = thecomponent[x].value;
                    break;
                }
            }
        }
        thecomponent=null;        
        return thevalue;
    }

    function getCheckBoxValue(formname,compname){	
	theform=getForm(formname);
        var thecomponent=theform[compname];
        if(thecomponent==null)
            return "";
        else return thecomponent.checked;
    }

    // returns the selected values of a multiple select dropdown component
    function getDropDownValues(formname,compname){	
	theform=getForm(formname);
        var thecomponent=theform[compname];
        
        selected = new Array();
        		
        if(thecomponent==null){
            //alert("getComponentValue() Error: "+compname+" not found");
            return selected;
        }
        if(isDropDown(thecomponent)){
            for (var i = 0; i < thecomponent.options.length; i++){ 
                if (thecomponent.options[i].selected) selected.push(thecomponent.options[i].value);
            }
        }
        thecomponent=null;
        return selected;
    }
    
    
		// sets the valid values on an applet dropdown
		function setAppletComponentValidValues(formname,compname,values){
			theapplet=document.applets[formname];
			theapplet.clearComponentValidValues(compname);
			for(x=0;x<values.length;x++){
				theapplet.addComponentValidValue(compname,values[x]);
			}
			
		}
		
		function setAppletComponentValue(formname,compname,value){
			theapplet=document.applets[formname];
			if(!theapplet || !compname ){
				return;
			}
			theapplet.setComponentValue(compname,value);
		}

		//sets the valid values for a component
		//only works for drop-down types
		function setComponentValidValues(formname,compname,values){
			if(isAppletForm(formname)){
				setAppletComponentValidValues(formname,compname,values);
				return true;
			}
			theform=getForm(formname);
			thecomponent=theform[compname];
      if(thecomponent==null){
        //alert("setComponentValidValues() Error: "+compname+" not found");
        return false;
      }
      if(!isDropDown(thecomponent)){
				// not a drop down
				return false;
			}	
			for(x=0;x<values.length;x++){
				thecomponent.options[x]=new Option();
				thecomponent.options[x].value=values[x];
				thecomponent.options[x].text=values[x];
			}
			if(thecomponent.options.length>values.length){
				for(x=values.length;x<thecomponent.options.length;x++){
					thecomponent.options[x]=null;
				}
			}
			// select the first in the list
			thecomponent.options[0].selected=true;
			return true;
		}
		
		function submitForm(formname){
    //alert('is.js'+formname);
			theform=getForm(formname);
      if(theform==null) {
				//alert("No form named "+formname+" to submit!");
				return;
			}
			doSubmitChecks(formname);	
//      alert(' me am started, fromname ' + theform.name);
      theform.submit();
//      alert(' me am finished');
		}
    
    function setAndSubmit(formname, componentname, componentvalue) 
    {
      setComponentValue(formname, componentname, componentvalue);
			submitForm(formname);
		}
    
		function doSubmitChecks(formname){
      funcname="doSubmitChecks_"+formname+"()";
			eval(funcname);
		}

		function doCheckboxes(formname)
		{
			theform=getForm(formname);
			//sort out checkboxes
			for(x=0;x<theform.elements.length;x++){
				// if it is checked, the value should be on
				
				if(theform.elements[x].checked && theform.elements[x].value=="off"){
					theform.elements[x].value="on";
				}  
			}
		}
		function addToList(formName,listName)
		{
			theform=document.forms[formName];
			if (theform==null)
			{
				return;
			}
			thefromlist=theform[listName];
			if (thefromlist==null)
			{
				return;
			}
			theselectlist=theform[listName+"selected"];
			if (theselectlist==null)
			{
				return;
			}
			selarr = theselectlist.options;
			fromarr = thefromlist.options;
			outer : for (j=0; j<fromarr.length; j++) {
				fromOp = fromarr[j];
				if (fromOp.selected==true && fromOp.value!="No items available") {
					newop = new Option();
					newop.text=fromOp.text;
					for (i=0; i<selarr.length; i++) {
						if (selarr[i].text==newop.text) {
							continue outer;
						}
					}
					if (selarr.length==1) {
						if (selarr[0].text=="Select your items") {
							selarr[0]=newop;
						}
						else selarr[selarr.length]=newop;
					}
					else {
						selarr[selarr.length]=newop;
					}
				}
			}
		}
		
		function removeFromList(formName,listName)
		{
			theform=document.forms[formName];
			if (theform==null)
			{
				return;
			}
			thefromlist=theform[listName];
			if (thefromlist==null)
			{
				return;
			}
			theselectlist=theform[listName+"selected"];
			if (theselectlist==null)
			{
				return;
			}
			selarr = theselectlist.options;
			for (i=selarr.length-1;i>=0;i--)
			{
				if (selarr[i].selected) {
					selarr[i]=null;
				}
			}
		}
		
                function setListValues(formname,listname,value,hiddename)
		{
			var theForm=document.forms[formname];
			var theList="";
			if (theForm==null)
			{
				return;
			}
			var theList=theForm.elements[listname];
			if (theList==null)
			{
				return;
			}
			var thehidden=theForm.elements[hiddename];
			if (thehidden==null)
			{
				return;
			}
			thehidden.value="";
			selarr=theList.options;
			for (i=selarr.length-1;i>=0;i--)
			{
				if(thehidden.value!="")
				{
					thehidden.value=","+thehidden.value;
				}
				thehidden.value=selarr[i].text+thehidden.value
				selarr[i].selected=value;
			}
		}
    
    function showTipFor(object) {
      if (document.layers && document.layers[object] != null) {
        document.layers[object].left = window.event.x + 5 + document.body.scrollLeft;
        document.layers[object].top = window.event.y + 5 + document.body.scrollTop;
        document.layers[object].visibility = 'visible';
      }
      else if (document.all) {
        document.all[object].style.left = window.event.x + 5 + document.body.scrollLeft;
        document.all[object].style.top = window.event.y + 5 + document.body.scrollTop;
        document.all[object].style.visibility = 'visible';
      }
    }

    function hideTipFor(object) {
      if (document.layers && document.layers[object] != null) {
        document.layers[object].visibility = 'hidden';
      }
      else if (document.all) {
        document.all[object].style.visibility = 'hidden';
      }
    }
    
    function setComponentFocus(name){
        var c=document.getElementsByName(name);
        if(c!=null){
            try{
                c[0].focus();
            }
            catch(e){}
        }

    }
/*    
    function addMultiSelectOption( formName, listName, optionName ){
	theform=document.forms[formName];
        if (theform==null)
        {
                return;
        }
        theselectlist=theform[listName];
        if (theselectlist==null)
        {
                return;
        }
        selarr = theselectlist.options;
        if(selarr==null){
            return;
        }
        newop = new Option();
        newop.text=optionName;
        newop.selected=true;
        for (i=0; i<selarr.length; i++) {
                if (selarr[i].text==newop.text) {
                        return;
                }
        }
        if (selarr.length==1) {
            if (selarr[0].text=="Select your items") {
                    selarr[0]=newop;
            }
            else selarr[selarr.length]=newop;
        }
        else {
                selarr[selarr.length]=newop;
        }
       
    }
*/
