/*###################################################################################################
#mydbol.js version 2_r2_10_2010
#author: Kevin john O'Brien
#inception date:1/02/2006
#NOTICE OF COYPWRITE: this work is copywriten and may not used or  disrtibution without express writen permission of the author;
#site build:build_www.mydbol.com_3_24_2008
###################################################################################################*/
/*this version was modified(1/10/2010)
/*#################################################################################################*/
/* the following code get the mouse position in all browsers and creats global varibles */
/*#################################################################################################*/
// if form values have been changed warn the user before closing;
var $FileVersion='mydbol.js version 2 r9_22_2011';
var $formHasChanged=0;
window.onbeforeunload = function () {		    
 if($formHasChanged == 1){
   return "You have not saved your document yet.  If you continue, your work will not be saved."
 }
}
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
var xScroll=0;
var yScroll=0;
// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {

  if (IE) { // grab the x-y pos.s if browser is IE
	  //xScroll=document.getElementById('mainWorkSpace').scrollLeft;
	  //yScroll=document.getElementById('mainWorkSpace').scrollTop;
	  xScroll=0
	  yScroll=0;
	  
	  tempX = event.clientX + xScroll;
	  tempY = (event.clientY) + yScroll;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY

  return true

}
/*##############################################################################
this function is called with the following
Arguments
httpaction,url,params to send,the question id,destination to print outupt,val;
################################################################################*/
function ajaxFunction(httpaction,url,params,dest,val,showstatus,windowreference){
var myurl=url;
var windowvector;
if(dest == 'CreateDiv'){
var destination=creatediv();
//alert(destination+' bbb is the destination');
}else{

var destination=dest;
//alert(destination+' aaa is the destination');
}
        if(windowreference == undefined || windowreference == ''){
        windowvector='window';
	}else{
        windowvector=windowreference;
        }


var mycond=val;

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    
    xmlHttp.onreadystatechange=function(){
if(showstatus != 0){
        if(showstatus == undefined){
                if(dest == 'mainWorkSpace'){
                var downLoaderContent='<center><p style="width:200px;height:100px;color:gray;font: 8px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader2.gif"><br /><b>DownLoading</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;color:gray;font: 6px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader2.gif"><br /><b>Loading</b><br /><br />&nbsp;</p>';
                }else if(dest == 'control'){
                var downLoaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader7.gif"><br /><b>DownLoading</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;color:gray;font: 11px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader7.gif"><br /><b>Loading</b><br /><br />&nbsp;</p>';
                }else if(dest == 'formspace' || dest == 'searchDiv'){
                var downLoaderContent='<center><p style="width:200px;height:100px;color:gray;font: 9px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader8.gif"><br /><b>DownLoading</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;color:gray;font: 9px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader8.gif"><br /><b>Loading</b><br /><br />&nbsp;</p>';
                }else{
                var downLoaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader2.gif"><br /><b>DownLoading</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img src="/images/ajax-loader2.gif"><br /><b>Loading</b><br /><br />&nbsp;</p>';
                }
        }else if(showstatus == 'tiny'){
                var downLoaderContent='<center><p style="width:300px;height:100px;font: 6px verdana, arial, sans-serif;"><br /><br /><img style="width:10px;height:10px;"  src="/images/ajax-loader2.gif"><br /><b>DownLoading question</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:300px;height:100px;font: 6px verdana, arial, sans-serif;"><br /><br /><img style="width:10px;height:10px;"  src="/images/ajax-loader2.gif"><br /><b>Loading question</b><br /><br />&nbsp;</p>';
        }else if(showstatus == 'small'){
                var downLoaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:20px;height:20px;" src="/images/ajax-loader2.gif"><br /><b>DownLoading question</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:20px;height:20px;" src="/images/ajax-loader2.gif"><br /><b>Loading question</b><br /><br />&nbsp;</p>';
        }else if(showstatus == 'medium'){
                var downLoaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:30px;height:30px;" src="/images/ajax-loader2.gif"><br /><b>DownLoading question</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:30px;height:30px;" src="/images/ajax-loader2.gif"><br /><b>Loading question</b><br /><br />&nbsp;</p>';
        }else if(showstatus == 'mediumblack'){
                var downLoaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:30px;height:30px;" src="/images/ajax-loader7.gif"><br /><b>DownLoading question</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:30px;height:30px;" src="/images/ajax-loader2.gif"><br /><b>Loading question</b><br /><br />&nbsp;</p>';
        }else if(showstatus == 'large'){
                var downLoaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:40px;height:42px;" src="/images/ajax-loader2.gif"><br /><b>DownLoading question</b><br /><br />&nbsp;</p>';
                var loaderContent='<center><p style="width:200px;height:100px;font: 8px verdana, arial, sans-serif;"><br /><br /><img style="width:40px;height:42px;" src="/images/ajax-loader2.gif"><br /><b>Loading question</b><br /><br />&nbsp;</p>';
        }else {

        }
                       if(xmlHttp.readyState==1){
                                if(windowvector == 'window'){document.getElementById(destination).innerHTML=downLoaderContent};
                                if(windowvector == 'opener'){window.opener.document.getElementById(destination).innerHTML=downLoaderContent};
                                if(windowvector == 'parent'){window.parent.document.getElementById(destination).innerHTML=downLoaderContent};
                        }
                        if(xmlHttp.readyState==3){
                                if(windowvector == 'window'){document.getElementById(destination).innerHTML=loaderContent};
                                if(windowvector == 'opener'){window.opener.document.getElementById(destination).innerHTML=loaderContent};
                                if(windowvector == 'parent'){window.parent.document.getElementById(destination).innerHTML=loaderContent};
                        }
}
      if(xmlHttp.readyState==4){
                if(windowvector == 'window'){document.getElementById(destination).innerHTML=xmlHttp.responseText};
                if(windowvector == 'opener'){window.opener.document.getElementById(destination).innerHTML=xmlHttp.responseText};
                if(windowvector == 'parent'){window.parent.document.getElementById(destination).innerHTML=xmlHttp.responseText};
      }
}

    if(httpaction == 'POST'){
    xmlHttp.open(httpaction,myurl,true);
    xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
    xmlHttp.send(params);
    }else{
    var myrand=parseInt(Math.random()*99999999);
    xmlHttp.open(httpaction,myurl+val+'&reqver='+myrand,true);
    //alert(myurl+' '+myrand);
    xmlHttp.send(null);
    }
}
/*############################################################################
this function converts web forms to a url encoded post.
this function is called with the following
Arguments
the form id, destination to print outupt;
###############################################################################*/

function formToAjax(Id,dest){
var formId=Id;
var url='';
var params=''
    for (var i=0, j=document.getElementById(formId).elements.length; i<j; i++) {
        var myType = document.getElementById(formId).elements[i].type;
        var delim='';
        var k=i+1;
     if(k < j){delim = '&'};

        if (myType == 'checkbox' || myType == 'radio') {                        // if the input type is a check box or a radio
            if(document.getElementById(formId).elements[i].checked == true){    // if the element is ed get the value.
              var name1=document.getElementById(formId).elements[i].name;
              name1=name1.replace(/;/g,"semicolonswap");
              name1=name1.replace(/&/g,"ampersandswap");
              name1=name1.replace(/#/g,"hashswap");
              params= params+encodeURI(name1)+'=';
              var value1=document.getElementById(formId).elements[i].value;
              value1=value1.replace(/;/g,"semicolonswap");
              value1=value1.replace(/&/g,"ampersandswap");
              value1=value1.replace(/#/g,"hashswap");
              params= params+encodeURI(value1)+delim;
          }
        }else if(myType == 'select-multiple'){
		//need to loop though values and construct a pipe deliminated value that can be passed

		for(var fo=0;fo< document.getElementById(formId).elements[i].options.length;fo++){
			if(document.getElementById(formId).elements[i].options[fo].selected){
		var name1=document.getElementById(formId).elements[i].name;
              name1=name1.replace(/;/g,"semicolonswap");
              name1=name1.replace(/&/g,"ampersandswap");
              name1=name1.replace(/#/g,"hashswap");
	      params= params+encodeURI(name1)+'=';
	      var value1=document.getElementById(formId).elements[i].options[fo].value;
              value1=value1.replace(/;/g,"semicolonswap");
              value1=value1.replace(/&/g,"ampersandswap");
              value1=value1.replace(/#/g,"hashswap");
				params= params+encodeURI(value1)+delim;
			}
		}
	}else{
             var name1=document.getElementById(formId).elements[i].name;
              name1=name1.replace(/;/g,"semicolonswap");
              name1=name1.replace(/&/g,"ampersandswap");
              name1=name1.replace(/#/g,"hashswap");
	      params= params+encodeURI(name1)+'=';
              var value1=document.getElementById(formId).elements[i].value
              value1=value1.replace(/;/g,"semicolonswap");
              value1=value1.replace(/&/g,"ampersandswap");
              value1=value1.replace(/#/g,"hashswap");
	      params= params+encodeURI(value1)+delim;
        }

    }
//alert(document.getElementById(formId).action+'?'+params);
      ajaxFunction('POST',document.getElementById(formId).action,params,dest,'');
}
/*############################################################################*/
function hideObject(objName){
   document.getElementById('control').innerHTML='';
   var theMenu1 = document.getElementById('controlall');
   theMenu1.style.visibility = 'hidden';
   var theMenu = document.getElementById(objName);
   theMenu.style.visibility = 'hidden';
show();
}
/*############################################################################*/
function showObject(objName){
hide()
   var theMenu1 = document.getElementById('controlall');
   theMenu1.style.visibility = 'visible';
   var theMenu = document.getElementById(objName);
   theMenu.style.visibility = 'visible';
}
/*############################################################################
this function is called with the id of the oject if the objects diplay is det to
none it will set it to hidden. and visa vera.
#################################################################################*/
function hideObject2(objName){
   var theMenu = document.getElementById(objName);
var display=theMenu.style.display;
if(display == 'none'){
   theMenu.style.display = 'block';
}else{
   theMenu.style.display = 'none';
}
}
/*############################################################################
this function is called with the id of the oject if the objects diplay is det to
none it will set it to hidden. and visa vera.
#################################################################################*/
function togglevisability(objName,force){
var vis=document.getElementById(objName).style.visibility;
var disp=document.getElementById(objName).style.display;
	if(force == 'on'){
		alert('vis is='+vis+' name='+objName);
			if(vis == 'hidden' ||vis == 'visible'){				
				document.getElementById(objName).style.visibility = 'visible';
			}else if(disp  == 'none' || disp == 'block'){
				document.getElementById(objName).style.display = 'block';
			}
	}else if(force == 'off'){
		alert('vis is='+vis+' name='+objName);
			if(vis == 'hidden' ||vis == 'visible'){				
				document.getElementById(objName).style.visibility = 'hidden';
			}else if(disp == 'none' || disp == 'block'){
				document.getElementById(objName).style.display = 'none';
			}		
	}else{
		alert('made it to the else'+objName);		
			if(vis == 'hidden'){				
				document.getElementById(objName).style.visibility = 'visible';
			}else if(vis == 'visible'){
				document.getElementById(objName).style.visibility = 'hidden';
			}else if(disp == 'none'){
				document.getElementById(objName).style.display = 'block';
			}else if(disp == 'block'){
				document.getElementById(objName).style.display = 'none';
			}
	}
}

/*#################################################################################*/
/*eg. setObjectDisplay(this.id,'on/off','zindex','mouse/a number/empty','mouse/a number/empty','xoffset/empty','yoffset/empty')*/
/*if called with only nodeId this will toggle vid/diplay */
function setObjectDisplay(objName,force,userzindex,xPosition,yPosition,xoffsetIn,yoffsetIn){
var vis=document.getElementById(objName).style.visibility;
var disp=document.getElementById(objName).style.display;
var xPos=xPosition;
var yPos=yPosition;

var xoffset;
var yoffset;
if(xoffsetIn == undefined || xoffsetIn ==''){ xoffset='0'}else{xoffset=xoffsetIn};
if(yoffsetIn == undefined || yoffsetIn ==''){ yoffset='0'}else{yoffset=yoffsetIn};
			//alert('y='+tempY+'  yoffset='+yoffset+'xs'+xScroll+'ys'+yScroll);
	if(containsText(yPos)){
			//alert('y1='+tempY+' yPos='+yPos+'.  yoffset='+yoffset+' obj='+objName);
		if(yPos == 'mouse'){
			//alert('mouseY='+tempY+'  yoffset='+yoffset+' obj='+objName);
			var correctedYPos=(eval(tempY))+(eval(yoffset));			
			correctedYPos=correctedYPos+'px';
			document.getElementById(objName).style.top=correctedYPos;

		}else{
			var startY=document.getElementById(objName).style.top;
			//alert('startY='+startY+'obj='+objName);
			//alert('userY='+yPos+'obj='+objName);
			document.getElementById(objName).style.top=yPos+'px';
			var changedy=document.getElementById(objName).style.top;
			//alert('changedY='+changedy+'obj='+objName);
		}
	}
	if(containsText(xPos)){
		if(xPos == 'mouse'){
			var correctedXPos=(eval(tempX))+(eval(xoffset));
			correctedXPos=correctedXPos+'px';
			//alert('mouseX='+tempX+'  xoffset='+xoffset+' cxpos='+correctedXPos+' obj='+objName);
			document.getElementById(objName).style.left=correctedXPos;
		}else{
			//alert('userX='+xPos+'obj='+objName);
			document.getElementById(objName).style.left=xPos+'px';
		}
	}
	
	if(containsText(userzindex)){document.getElementById(objName).style.zIndex = userzindex;};
		if(force == 'on'){
				if(vis == 'hidden' || vis == 'visible'){
					document.getElementById(objName).style.visibility = 'visible';
				}else if(disp == 'none' || disp == 'block'){
					document.getElementById(objName).style.display = 'block';
				}
		}else if(force == 'off'){
				if(vis == 'hidden' || vis == 'visible'){
					document.getElementById(objName).style.visibility = 'hidden';
				}else if(disp == 'none' || disp == 'block'){
					document.getElementById(objName).style.display = 'none';
				}
		}else{
				if(vis == 'hidden'){
					document.getElementById(objName).style.visibility = 'visible';
				}else if(vis == 'visible'){
					document.getElementById(objName).style.visibility = 'hidden';
				}else if(disp == 'none'){
					document.getElementById(objName).style.display = 'block';
				}else if(disp == 'block'){
					document.getElementById(objName).style.display = 'none';
				}
		}
	
}

/*############################################################################*/
function hide(formId) {
   for (var f=0,fl=document.forms.length; f<fl; f++) {
       for (var i=0, j=document.forms[f].elements.length; i<j; i++) {
       var myType = document.forms[f].elements[i].type;
         if (myType == '-one' || myType == '-multiple') {
          document.forms[f].elements[i].style.visibility = 'hidden';
         }
       }
   }
}
/*############################################################################*/
function show() {
for (var f=0,fl=document.forms.length; f<fl; f++) {
    for (var i=0, j=document.forms[f].elements.length; i<j; i++) {
       var myType = document.forms[f].elements[i].type;
        if (myType == '-one' || myType == '-multiple') {
        document.forms[f].elements[i].style.visibility = 'visible';
                }
    }
}
}
/*############################################################################*/
function newWindow(url,h,w,name){
var imageeditresponce;
imageeditresponce = confirm('Do you wish to edit this Image');
if(imageeditresponce == 1){
open(url,name,"width="+w+",height="+h+"scrollbars=no,resizable=0");
}else{
}
}
/*############################################################################*/
function newWindowOpener(url,h,w,name,toolbar){
var imageeditresponce;
open(url,name,"width="+w+",height="+h+" scrollbars=yes,"+toolbar+",resizable=1");
}
/*############################################################################*/
   function notes(table,rd,aid,rid,win,pos){
     var id=aid;
     var tablename=table;
     var rootdocument=rd;
     var recordid=rid  ;
     var windowname=win ;
     var position=pos ;
     childWindow=open("/cgi-bin/addproduct.pl?aid="+id+"&tn="+tablename+"&rd="+rootdocument+"&rid="+recordid+"&wn="+windowname+"&position="+position,windowname,"width=600,height=640 scrollbars=yes,resizable=1");
     childWindow.opener = self
   }
/*############################################################################*/
   function orders(table,rd,aid,rid,win,pos){
     var id=aid;
     var tablename=table;
     var rootdocument=rd;
     var recordid=rid  ;
     var windowname=win ;
     var position=pos ;
     childWindow=open("/cgi-bin/orders.pl?aid="+id+"&tn="+tablename+"&rd="+rootdocument+"&rid="+recordid+"&wn="+windowname+"&position="+position,windowname,"width=600,height=640 scrollbars=yes,resizable=1");
     childWindow.opener = self
   }
/*############################################################################*/
   function delete_record(){
     var action=document.forms[1].elements[0].value;
     var id=document.forms[1].elements[1].value;
     var tablename=document.forms[1].elements[3].value;
     var rootdoc=document.forms[1].elements[4].value;
     var recordid=document.forms[1].elements[2].value;
     var windowname=document.forms[1].elements[5].value;
     var recordname=tablename +' '+recordid;
     var result=prompt('This action will remove this  record and all relavent data form the database. Type \'delete record\' to comfirm this action. ','')
            if(result == 'delete record'){
            ajaxFunction('GET',"addproduct.pl?aid=id&a="+action+"&tn="+tablename+"&rd="+rootdoc+"&rid="+recordid,'','addProductContent','','','');
            ajaxFunction('GET',"formstoproduct.pl?aid="+id+"&rd="+rootdoc+"&rid="+recordid,'','mainWorkSpace','','','opener');
            }

   }

/*############################################################################*/
function DisableRadios(){
        var at=document.getElementById('at').value;
        if( at == 4){
        document.getElementById('radioin').style.display = 'none';
        document.getElementById('listcap1').style.display = 'block';
        document.getElementById('listin1').style.display = 'block';
        }
        else if( at == 1){
        document.getElementById('radioin').style.display = 'block';
        document.getElementById('listcap1').style.display = 'none';
        document.getElementById('listin1').style.display = 'none';
        }
        else if( at == 2 || at == 3 || at == 5 || at == 6){
        document.getElementById('radioin').style.display = 'none';
        document.getElementById('listcap1').style.display = 'none';
        document.getElementById('listin1').style.display = 'none';
        }
}
/*############################################################################*/
function comppass(){
if(document.logi.newpassword.value == document.logi.newpassword2.value)
{
document.logi.submit()
}
else
{
alert("passwords do not match");
}
}

/*############################################################################*/
function checkform(v){
submitOK="t"
invalidchars=v
     for(cx=0 ; cx< invalidchars.length ; cx++){
	x=invalidchars.charAt(cx) 
	len=document.myform.length
	lent=len-2
       for (i = 0; i <= lent; i++){
	result=document.myform.elements[i].value.indexOf(x)
        if(result!=-1){
        alert("found a ' "+x+" ' in field "+(i+1))
        submitOK="False"
	}
	
       }
     }

if(submitOK == "False")
{
}
else
{
document.myform.submit()
}


}
/*############################################################################*/
     function delete_question(formName){
     var $currentForm=formName;
     var result=prompt('This action will remove this question and all stored data form the database. type \'delete question\' to comfirm this action. ','')
     if(result == 'delete question'){
     formToAjax('deleteQuestion','control');ajaxFunction('GET',"/cgi-bin/table.pl?a=3.9&tn="+$currentForm+"",'','formspace','');
    document.forms[1].submit();
     }
}
/*############################################################################*/
     function delete_child(rd){

     var result=prompt('This action will remove this form and all relavent data form the database. Type \'delete child\' to comfirm this action. ','')
     if(result == 'delete child'){
    formToAjax('deleteChildForm','control');
    alert(rd);
    ajaxFunction('GET',"/cgi-bin/table.pl?&rd="+rd+"",'','mainWorkSpace','');
    //document.forms[0].submit();
     }

   }
/*############################################################################*/
        function delete_root(mode,formId,dest){
     var Mymode= mode;
     if(Mymode == 'system'){                                                  // i added the cancel mode so that i could delete a table without a prompt.
    //document.forms[1].submit();
    formToAjax(formId,dest);  
    }else{
     var result=prompt('This action will remove this Parent form and all child forms from the database. Type \'delete parent\' to comfirm this action. ','')
     if(result == 'delete parent'){
    formToAjax(formId,dest);
     }
   }
   }
/*############################################################################*/
	function delete_item(formid){
	var result=prompt('This action will remove this list item and item relavent data form the database. Type \'delete item\' to comfirm this action. ','');
		if(result == 'delete item'){
			setObjectDisplay('controlContainer','off');
			setObjectDisplay('clickBlocker','off');
			setObjectDisplay('clickBlocker1','off');
	
			formToAjax(formid,'listSpace');
		}
	
	}
/*############################################################################*/
var status1;
var status2;

function clear_radio_buttons(radidid) {
var radid=radidid;

if(status1 == true){
document.forms[0].elements[radid][0].checked = false; 
}
if(status2 == true){
document.forms[0].elements[radid][1].checked = false;
}

}
/*############################################################################*/
function clear_radio_buttons2(radidid) {
var radid=radidid;
status1=document.forms[0].elements[radid][0].checked;
status2=document.forms[0].elements[radid][1].checked;

}
/*############################################################################*/
function runsearch(){
var rid=document.getElementById('checkByRid').value;
var rd=document.getElementById('rdNAME').value;
var rid2=eval(rid);
if(rid2 >= 1){
//open('formstoproduct.pl?aid='+rid2+'&rd='+rd+'&position=-7','main');
ajaxFunction('GET','formstoproduct.pl?aid='+rid2+'&rd='+rd+'&position=-7','','mainWorkSpace','');
var rid=document.getElementById('checkByRid').value='';
exit;
}
//document.getElementById('searcher').submit();
formToAjax('searcher','mainWorkSpace');
}
/*############################################################################*/
function resetsearch(){
document.searcher.reset();
}
/*############################################################################*/
function clearform(){
parent.search.searcher.submit();
}
/*############################################################################*/
function hasChanged(){
	try{
		$formHasChanged=1;	
	}catch(e){
		return false;
	}
}
/*############################################################################*/
function resetHasChanged(){
	try{
		$formHasChanged=0;	
	}catch(e){
		return false;
	}
}
/*############################################################################*/
function checkForChanges(){	
	if($formHasChanged == 1){
		if (confirm("Are you sure you want to close Me?")){ 
		window.close();
		return true;
		}else {
		
		      return false; 
		}
	}
			
}
/*############################################################################*/
   function printpage(table,win){
     var tablename=table
     var windowname=win
     open("/cgi-bin/print_form.pl?&tn="+tablename+"&a="+3+"&wn="+windowname,windowname,"width=650 scrollbars=yes,resizable=1")
   }




(document.getElementById ? DOMcapable = true : DOMcapable = false);
/*############################################################################*/
function hide(menuName)
{
 if (DOMcapable){
	try{	
	   var theMenu = document.getElementById(menuName+"choices");
	   theMenu.style.visibility = 'hidden';
	}catch(err){};
    }
}
/*############################################################################*/
function show(menuName)
{
 if (DOMcapable)
   {
var theMenu = document.getElementById(menuName+"choices");
var visibility=theMenu.style.visibility;
   if(visibility == 'visible')
   {
   theMenu.style.visibility = 'hidden';
   }
   if(visibility == 'hidden'){
   theMenu.style.visibility = 'visible';
   }
   }

}

/*############################################################################*/
function addcriteria(){
var y =  document.getElementById('mainform');
document.getElementById('c1').value='yes';
document.getElementById('switchedform').value='no';
        document.mainform.a1[0].checked=false; // this keeps the report from being run in the main window when the add criteria button is hit
        document.mainform.a1[1].checked=false;
formToAjax('mainform','mainWorkSpace');
}
/*############################################################################*/
function report_target(){
                if (document.mainform.a1[1].checked == false){document.mainform.a1[0].checked = true};

        var y =  document.getElementById("mainform");
                if (document.mainform.a1[0].checked){
			//alert('rand1='+document.getElementById("mainform").randomizer.value);
                        var myrand=parseInt(Math.random()*99999999);
			document.getElementById("mainform").randomizer.value=myrand;
			//alert('rand2='+document.getElementById("mainform").randomizer.value);
                        document.getElementById("mainform").target=myrand;
                }else{
                        document.getElementById("mainform").target='main';
                }
         
	y.submit();
        document.mainform.a1[0].checked=false;
        document.mainform.a1[1].checked=false;
	
        document.getElementById("mainform").target='main';
}

/*############################################################################*/
function submitformname(){
try{
document.mainform.a1[0].checked=false;
document.mainform.a1[1].checked=false;
}catch(e){
}
document.getElementById('switchedform').value='yes';
formToAjax('mainform','mainWorkSpace');
}
/*############################################################################*/
function savereport(){
try{
document.mainform.a1[0].checked=false;
document.mainform.a1[1].checked=false;
}catch(e){
}
document.getElementById('dosave').value='yes';
document.getElementById('save_name').value = document.getElementById('saveas').value;
if(document.getElementById('privateoption').checked == true){
document.getElementById("private").value = document.getElementById("privateoption").value;
}
formToAjax('mainform','mainWorkSpace');
}
/*############################################################################*/
function loadreport(){
try{
document.mainform.a1[0].checked=false;
document.mainform.a1[1].checked=false;
}catch(e){
}
document.getElementById('doload').value='yes';
document.getElementById('save_name').value = document.getElementById('loadselect').value;
formToAjax('mainform','mainWorkSpace');
}
/*############################################################################*/
function deletereport(){
try{
document.mainform.a1[0].checked=false;
document.mainform.a1[1].checked=false;
}catch(e){
}
document.getElementById('dodelete').value='yes';
document.getElementById('save_name').value = document.getElementById('loadselect').value;
var deletconfirm = confirm('Do you wish to Delete this Report');
if(deletconfirm == 1){
formToAjax('mainform','mainWorkSpace');
}else{
}
}
/*############################################################################*/
function printnotes(table,rd,aid,rid,win,pos){
     var id=aid
     var tablename=table
     var rootdocument=rd
     var recordid=rid
     var windowname=win
     var position=pos
     open("/cgi-bin/addproduct_printable.pl?aid="+id+"&tn="+tablename+"&rd="+rootdocument+"&rid="+recordid+"&wn="+windowname+"&position="+position,windowname,"width=600,height=640 scrollbars=yes,resizable=0")
   }
/*############################################################################*/
function check_for_visibles(){
	var theMenu1 = document.getElementById('control');
	if(theMenu1.style.visibility == 'visible'){
	hide();
	//alert("running job");
	     for (var i=0, j=document.getElementById('editForm').elements.length; i<j; i++) {
	       var myType = document.getElementById('editForm').elements[i].type;
		 if (myType == '-one' || myType == '-multiple') {
		  document.getElementById('editForm').elements[i].style.visibility = 'visible';
		 }
	       }
	}
}
/*############################################################################*/
function turnoncontrols(objName){
   var theMenu = document.getElementById('editrow_'+objName);
   theMenu.filters[0].opacity= '100';
}
/*############################################################################*/
function turnoffcontrols(objName){
   var theMenu = document.getElementById('editrow_'+objName);
   theMenu.filters[0].opacity= '0';
}
/*############################################################################*/
function showstuff(IDS){
var elid=IDS;
if(elid.style.display=="none"){
elid.style.display="block";
}else{
elid.style.display="none";
}
}


/*############################################################################*/
function showstuff2(IDS){
var elid=IDS;
//var re=document.getElementById(elid).style.display
//alert(elid+' '+re);
if(document.getElementById(elid).style.display=="none"){
document.getElementById(elid).style.display="block";
}else{
document.getElementById(elid).style.display="none";
}
}

/*#############################################################################*/
function showonhover(IDS){
var elid=IDS;
elid.style.display="block";
hide();
}
/*#############################################################################*/
function hideonhoverout(IDS){
var elid=IDS;
elid.style.display="none";
show();
}
/*############################################################################*/
function makeFloatingDialog(objName){
hide();
   var theMenu = document.getElementById(objName);
   theMenu.style.visibility = 'visible';
var y = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
var x = window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
document.getElementById(objName).style.top=y-10;
document.getElementById(objName).style.left=x-10;

}
/*############################################################################*/
function hideFloatingDialog(objName){
hide();
   var theMenu = document.getElementById(objName);
   theMenu.style.visibility = 'hidden';
}
/*############################################################################*/
function sortReport(FieldName,direction,position){	
// this function added the ability to drill down into data from chart.
var reportUrl=document.getElementById('reloadUrl').value
//alert(reportUrl);
reportUrl=reportUrl+'&sortBy='+FieldName+direction                      //direction of sort and fielname
reportUrl=reportUrl+'&startPosition='+position                          //position in the report;
  location.href=reportUrl;
}
/*############################################################################*/
function getConstituents(FieldName,fieldValue){
  var reportUrl=document.getElementById('reloadUrl').value
  //alert(reportUrl);
  //criteria::a::9999='+FieldName+'&criteria::b::9999=ie&criteria::c::9999=+fieldValue
  var myrand=parseInt(Math.random()*9999);
  myrand=myrand+200;
blankRE=/criteria/;
if(blankRE.test(reportUrl)){
    reportUrl=reportUrl+'&criteria::d::'+myrand+'=and'+'&criteria::a::'+myrand+'='+FieldName+'&criteria::b::'+myrand+'=ie&criteria::c::'+myrand+'='+fieldValue;
  
  }else{
      reportUrl=reportUrl+'&criteria::a::'+myrand+'='+FieldName+'&criteria::b::'+myrand+'=ie&criteria::c::'+myrand+'='+fieldValue;
  
};

location.href=reportUrl;
}
/*############################################################################*/
function breakDownColumn(FieldName,outputMode){
var reportUrl=document.getElementById('reloadUrl').value
//alert(reportUrl);
reportUrl=reportUrl+'&breakDown='+FieldName+outputMode
//location.href=reportUrl;
var target=FieldName;
ajaxFunction('GET',reportUrl,'',target);

}
/*############################################################################*/
function changeInputBox(updateTargetId){
var updateTargetSpan='span_criteria_c_'+updateTargetId;
//alert(updateTargetSpan);
var updateTargetSpan2='criteria::b::'+updateTargetId;

var temp=document.getElementById(updateTargetSpan2).value;
//alert(temp);
if(temp == 'db'){
var calContent="<br /><input type=\"hidden\" id =\"criteria::c::"+updateTargetId+"\" name=\"criteria::c::"+updateTargetId+"\" value=\"\"><i>from </i></span><input type=\"text\" id =\"criteria::c::"+updateTargetId+":date1\" name=\"criteria::c::"+updateTargetId+":date1\" value=\"\" size=\"19\" class=\"outlined\">&nbsp;<a href=\"javascript:NewCal('criteria::c::"+updateTargetId+":date1','mmddyyyy',true,12,'pulldown',true);\"><img src=\"/images/datepicker3.gif\" style=\"height:17px;border:0px solid;\"></a>&nbsp;<span style=\"color:gray\"><i>to </i></span><input type=\"text\" id =\"criteria::c::"+updateTargetId+":date2\" name=\"criteria::c::"+updateTargetId+":date2\" value=\"\" size=\"19\" class=\"outlined\">&nbsp;<a href=\"javascript:NewCal('criteria::c::"+updateTargetId+":date2','mmddyyyy',true,12,'pulldown',true)\"><img src=\"/images/datepicker3.gif\" style=\"height:17px;border:0px solid;\"></a>";
//alert(calContent);
}else if(temp == 'dwl'){ /* dwl stands for date within the last*/
var calContent="<i>within</i></span><select id =\"criteria::c::"+updateTargetId+"\" name=\"criteria::c::"+updateTargetId+"\" value=\"\">";
calContent+="<option value=\":date1:24hr:date2:0\">24 hours</option>";	
calContent+="<option value=\":date1:2dy:date2:0\">2 days</option>";	
calContent+="<option value=\":date1:3dy:date2:0\">3 days</option>";	
calContent+="<option value=\":date1:4dy:date2:0\">4 days</option>";	
calContent+="<option value=\":date1:5dy:date2:0\">5 days</option>";	
calContent+="<option value=\":date1:6dy:date2:0\">6 days</option>";	
calContent+="<option value=\":date1:1wk:date2:0\">1 week</option>";	
calContent+="<option value=\":date1:2wk:date2:0\">2 weeks</option>";	
calContent+="<option value=\":date1:3wk:date2:0\">3 weeks</option>";	
calContent+="<option value=\":date1:4wk:date2:0\">1 month</option>";	
}else{
var calContent="</span><input type=\"text\" id =\"criteria::c::"+updateTargetId+"\" name=\"criteria::c::"+updateTargetId+"\" value=\"\" >";
}

document.getElementById(updateTargetSpan).innerHTML=calContent;
}
/*###########################################################################*/
function creatediv(id, html, width, height, left, top) {
	var newdiv = document.createElement('div');
	var i=0;
	try{
	var collDivs = document.getElementsByTagName("div");
		i = collDivs.length;
	}catch(err){
	}
	if(i < 1 ){
		var divid='div'+1;
	}else{
		i--;
		var LastDivId = collDivs[i].id;
		LastDivId=LastDivId.replace(/div/g, '');
		eval(LastDivId);
		LastDivId++;
		var divid='div'+(LastDivId);
	}
	   newdiv.setAttribute('id', divid);
	   if (width) {
	       newdiv.style.width = 300;
	   }
	   if (height) {
	       newdiv.style.height = 300;
	   }
	   if ((left || top) || (left && top)) {
	       newdiv.style.position = "absolute";
	
	       if (left) {
		   newdiv.style.left = left;
	       }
	
	       if (top) {
		   newdiv.style.top = top;
	       }
	   }
	   document.body.appendChild(newdiv);
	 var newbr = document.createElement('br');
	   document.body.appendChild(newbr);
	
	return divid;
}
/*############################################################################*/
function showsaving(destination){
 document.getElementById(destination).innerHTML='saving <img src="/images/ajax-loader5.gif">';
}
/*#############################################################################*/

var firstClick=0;
var secondClick=0;
var keyisdown=0;
/*#############################################################################*/
function keyStatus(status){ /*major issue here in IE. the fact the tis function is running on every key stroke is delaying the the keystokes by many seconds
 this must be fixed before deployment  i will try to use events instead*/
 //alert('running key stat');
	if(status == 0){
 for(y=1;y <= 168;y++){
	 document.getElementById(y).style.color="#000000";
          }
	}
keyisdown=status;
return
}
/*#############################################################################*/
function hour(hr,question_id){
	var currentstatus=document.getElementById(hr).style.backgroundColor
	if(keyisdown == 0){     //if a button is not depressed this block will be executed on the click of the mouse.
	//alert(currentstatus);
		if(currentstatus == "#e6ecff" || currentstatus == "rgb(230, 236, 255)"){
			document.getElementById(hr).style.backgroundColor="#31ff00";
			avalNumber+=hr;
	
	
		}else if(currentstatus == "#31ff00" || currentstatus == "rgb(49, 255, 0)")
			document.getElementById(hr).style.backgroundColor="#e6ecff";
	//                avalNumber=avalNumber-hr;
	
	firstClick=hr;
	secondClick=0;
	keyisdown=0;
	//alert(avalNumber);
	
	}else{
		if(firstClick < 1){
			firstClick=hr;
	}else if(firstClick >= 1){
		secondClick=hr;
		//alert(firstClick+" "+secondClick);
		if(firstClick > secondClick){startId = secondClick; endId = firstClick;};
		if(firstClick < secondClick){startId = firstClick ; endId = secondClick;};
		var topspace=startId-((Math.floor(startId/24))*24);
		var bottomspace=(endId-((Math.floor(endId/24))*24))-24;
		//alert(startId+" "+endId);
		firstclickcurrentstatus=document.getElementById(firstClick).style.backgroundColor;
		if(firstclickcurrentstatus == "#31ff00" || firstclickcurrentstatus == "rgb(49, 255, 0)"){
			document.getElementById(firstClick).style.backgroundColor="#e6ecff";
		}else{
			document.getElementById(firstClick).style.backgroundColor="#31ff00";
		}
		for(x=startId;x <= endId;x++){
			var mytopspace=x-((Math.floor(x/24))*24);
			var mybottomspace=(x-((Math.floor(x/24))*24))-24;
			if(mybottomspace > bottomspace){
			}else if(mytopspace < topspace ){
			}else{
				document.getElementById(x).style.backgroundColor="#31ff00";
				document.getElementById(x).style.color="#000000";
			}
			//document.getElementById(x).style.backgroundColor="#31ff00";
			//document.getElementById(x).style.color="#000000";
			//alert(x);
			firstClick=0;
			secondClick=0;
			keyisdown=0;
		}
	}
}
//#---------------------------calculate the availnumber------------------------------------#
                
				var avalNumber='';
                var valueset='';
                for(y=1;y <= 168;y++){
                var boxstatus=document.getElementById(y).style.backgroundColor;
                if(boxstatus == "#31ff00" || boxstatus == "rgb(49, 255, 0)"){
                   avalNumber+='1';
                   valueset='y';
                }else{
                   avalNumber+='0';
                }
                }

if(valueset == 'y'){
hasChanged();
document.getElementById(question_id).value=avalNumber;
}else{
document.getElementById(question_id).value='';
}
//var holder=document.getElementById(question_id).value
//alert(question_id+"  "+holder);
}
/*#############################################################################*/
// this function shows the users what is going to happen.
function hourpreview(hr){

if(keyisdown == 1){

	
        if(firstClick >= 1){
                secondClick=hr;
                //alert(firstClick+" "+secondClick+" "+topspace+" "+bottomspace);
                if(firstClick > hr){startId = hr; endId = firstClick;};
                if(firstClick < hr){startId = firstClick ; endId = hr;};
		var topspace=startId-((Math.floor(startId/24))*24);
		var bottomspace=(endId-((Math.floor(endId/24))*24))-24;
                for(y=1;y <= 168;y++){
			document.getElementById(y).style.color="#000000";
                }
                for(x=startId;x <= endId;x++){
			var mytopspace=x-((Math.floor(x/24))*24);
			var mybottomspace=(x-((Math.floor(x/24))*24))-24;
			var currentstatus=document.getElementById(x).style.backgroundColor
			if(currentstatus == "#e6ecff" || currentstatus == "rgb(230, 236, 255)"){
				if(mybottomspace > bottomspace){
				}else if(mytopspace < topspace ){
				}else{
				document.getElementById(x).style.color="#31ff00";
				}
				//document.getElementById(x).style.color="#31ff00";
			}else if(currentstatus == "#31ff00" || currentstatus == "rgb(49, 255, 0)"){
				//document.getElementById(x).style.color="#ffffff";
				if(mybottomspace > bottomspace){
				}else if(mytopspace < topspace ){
				}else{
				document.getElementById(x).style.color="#ffffff";
				}
			}
                }
        }
}
}
/*############################################################################*/
function addremindernote(id,remindretime){
if(remindretime == 'none'){return};
var noteconfirm = confirm('Would you like to add a reminder note?');

if(noteconfirm == 1){
     var remindernote=prompt('Enter Reminder Notes:','');
     document.getElementById(id).value=remindernote;
return
}else{
     return;
}
}
/*############################################################################*/
function initTarget(formname,uploadTarget) {
//alert('running '+formname+' '+uploadTarget);
  document.getElementById(formname).target = uploadTarget;
document.getElementById(formname).submit();
}
/*############################################################################*/
function containsText(string){
blankRE=/^[\s]+$/;
if(string == "" || blankRE.test(string) || string==undefined){return false;}else{return true;};
}

/*############################################################################*/
function doesNotcontainsText(string){
blankRE=/^[\s]+$/;
if(string == "" || blankRE.test(string) || string==undefined){return true;}else{return false;};
}

/*##############################################################################*/
function containsDrop(string){
blankRE=/rop/;
if(blankRE.test(string)){return true;}else{return false;};
}
/*############################################################################*/

function validatedrop(grabText,zoneText){
try{
var $gradSplit=grabText.split("-");
var $zoneSplit=zoneText.split("-");
if($gradSplit[2] == $zoneSplit[2]){return true;}else{return false;};
}catch(e){
return false;
}
}

/*############################################################################*/

var $grabId;
var $heldId;
var $dropZone;
var $dropId;
var $currentNode;
var $currentAction;
var $grabedcontent;
var delayID=0;
var delayID=0;
var $functioncall;
var $validDrop;

function dropIt(snodeId,saction,callhandle){
// the objects handed to the finction should have ids formated in the following way
// nameUniqueToThePage-dropgrouping
// nameUniqueToThePage-dropgrouping-drop
// The drop grouping field will allow me to control if one object can be drop on another object
// eg. you can drop a question on a group
//document.getElementById('log').innerHTML='1<br>g='+$grabId+'<br>h='+$heldId+'<br>dz='+$dropZone+'<br>dz2='+$dropZone2+'<br>did='+$dropId+'<br>grabbed content='+$grabedcontent+document.getElementById('log').innerHTML;
$currentNode=snodeId;
$currentAction=saction;
$functioncall=callhandle;
        if($currentAction == 'highlighton'){
                $mousedover=$currentNode;
                $mousedover=$mousedover.replace(/-drop/g,"");
                document.getElementById($mousedover).style.backgroundColor='#efefef';

        return;
        }

        if($currentAction == 'highlightoff'){
                $mousedover=$currentNode;
                $mousedover=$mousedover.replace(/-drop/g,"");
                document.getElementById($mousedover).style.backgroundColor='#ffffff';
        return;
        }

	if($currentAction == 'grab'){
	        $grabId=undefined;
		$heldId=$heldId;
		$dropZone=$grabId;
		$dropId=undefined;
                $grabId=$currentNode;
                var $grabedcontent;
                $grabedcontent=document.getElementById($grabId).innerHTML
                document.getElementById('carrybox').innerHTML=$grabedcontent;
                return;
        }

	if($grabId == undefined){return};
	if($currentAction == 'isInHand'){
                $heldId=$currentNode;
                showContentBox('carrybox','10','10');
                togglevisability('carrybox','on');
                document.getElementById($dropZone).style.height='40px';

                return;
        }
        if($currentAction == 'clearDropZone'){
                $dropZone=$dropZone.replace(/-drop/g,"");
                $dropZone=$dropZone+'-drop';
                document.getElementById($dropZone).style.backgroundColor='#ffffff';
                document.getElementById($dropZone).innerHTML='';
                document.getElementById($dropZone).style.height='5px';
                document.getElementById($dropZone).innerHTML='';
                togglevisability('carrybox','on');
                return;
        }

	if($currentAction == 'loadDropZone'){

                $validDrop=validatedrop($grabId,$currentNode);
                //alert($validDrop+' '+$grabId+' '+$currentNode);
        	if($validDrop == true){
                        try{
                                $dropZone=$currentNode;
                                $dropZone=$dropZone.replace(/-drop/g,"");
                                document.getElementById($dropZone).style.backgroundColor='#ffffff';
                                $dropZone=$dropZone+'-drop';
                                document.getElementById($dropZone).style.backgroundColor='#efefef';
                                $heightset=document.getElementById('carrybox').style.height;
                                document.getElementById($dropZone).style.height=$heightset;
                                $grabedcontent=document.getElementById($grabId).innerHTML;
                                document.getElementById($dropZone).innerHTML=$grabedcontent;
                                togglevisability('carrybox','off');

                        }catch(err){
                                $dropZone=$currentNode;

                        }
                        return;
                }
        }

	if($currentAction == 'release'){
	        $dropId=$currentNode
                var $validDrop=validatedrop($grabId,$currentNode);
                //alert($validDrop);
                if($validDrop == false){
                        try{
                        document.getElementById($dropZone).innerHTML='';
                        }catch(err){
                        }

//                        alert('in first if');
		}else if($grabId == $dropId){
//                        alert('you clicked this is ');

                        try{
                        document.getElementById($dropZone).innerHTML='';
                        }catch(err){
                        }

                }else{
                        document.getElementById($dropZone).style.backgroundColor='#ffffff';
                        if($functioncall == 'listItem'){ajaxFunction('GET',"/cgi-bin/table.pl?a=4.4&tn=lists_systemcreated&grabedobject="+$grabId+"&dropzone="+$dropId,'','listSpace','','0');};
                        if($functioncall == 'formQuestion'){ajaxFunction('GET',"/cgi-bin/table.pl?a=3.31&grabedobject="+$grabId+"&dropzone="+$dropId,'','formspace','','0');};
                        if($functioncall == 'formGroup'){ajaxFunction('GET',"/cgi-bin/table.pl?a=3.32&grabedobject="+$grabId+"&dropzone="+$dropId,'','formspace','','0');};
                }

//                alert('dropzone='+$dropZone);
                togglevisability('carrybox','off');
                $grabId=undefined;
                $heldId=undefined;
                $dropZone=undefined;
                $dropId=undefined;
                $currentNode=undefined;
                $currentAction=undefined;
                $grabedcontent=undefined;
                $validDrop=undefined;
                return;

	}else{
                return;
	}
}



// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
        if (IE) {                                       // grab the x-y pos.s if browser is IE
                tempX = event.clientX + document.body.scrollLeft
                tempY = event.clientY + document.body.scrollTop
        } else {  // grab the x-y pos.s if browser is NS
                tempX = e.pageX
                tempY = e.pageY
        }
                                                                // catch possible negative values in NS4
        if (tempX < 0){tempX = 0}                               // show the position values in the form named Show
        if (tempY < 0){tempY = 0}             // in the text fields named MouseX and MouseY
        showContentBox('carrybox','100','5');

        return true
}
//###########################  postion and unhide content box #########################################
function showContentBox(objName,xoffset,yoffset){
        clearTimeout(delayID);
        if(xoffset < 1){var xoffset=10};
        if(yoffset < 1){var yoffset=10};
        var theMenu = document.getElementById(objName);
	try{
        document.getElementById(objName).style.top=tempY-yoffset;
        document.getElementById(objName).style.left=tempX-xoffset;
	}catch(err){	
	}
}
//########################### turn off/on display/visability#########################################
function togglevisability(objName,force){
   var theObject = document.getElementById(objName);
        if(force == 'on'){
                try{
                                displayStatus=theObject.style.visibility='visible';
                }catch(err){
                                displayStatus=theObject.style.display='block';
                }
        }else if(force == 'off'){
                try{
                                displayStatus=theObject.style.visibility='hidden';
                }catch(err){
                                displayStatus=theObject.style.display='none';
                }
        }else{

                try{
                        var displayStatus=theObject.style.visibility;
                        if(displayStatus == 'hidden'){
                                displayStatus=theObject.style.visibility='visible';
                        }else{
                                displayStatus=theObject.style.visibility='hidden';
                        }
                }catch(err){
                        var displayStatus=theObject.style.display;
                        if(displayStatus == 'none'){
                                displayStatus=theObject.style.display='block';
                        }else{
                                displayStatus=theObject.style.display='none';
                        }

                }
        }
}
/*###########################################################################*/
function autoScroller(){
        if($heldId){
        var $divHieght=document.getElementById('mainWorkSpace').clientHeight;
        var $topScrollSpace=165;
        var $bottomScrollSpace=($divHieght+145)-20;
                if(tempY > $bottomScrollSpace){
                        try{
                             //                   alert('scroll down'+ tempY + 'dh=' +$divHieght);
                                //document.getElementById('mainWorkSpace').scrollTop=800;
                                scrollDivDown('mainWorkSpace')
                        }catch(err){
                        }
                }else if(tempY < $topScrollSpace){
                                try{
                           //                     alert('scroll up' + tempY + 'dh=' + $divHieght);
                                scrollDivUp('mainWorkSpace');
                                //document.getElementById('mainWorkSpace').scrollTop=0;
                                }catch(err){
                                }
                }else{
                       try{
                        clearTimeout(timerDown);
                        clearTimeout(timerUp);
                }catch(err){};
                }

        }else{
                try{
                        clearTimeout(timerDown);
                        clearTimeout(timerUp);
                }catch(err){};
                
        }
}
/*###########################################################################*/
<!--
function toTop(id){
document.getElementById(id).scrollTop=0
}

defaultStep=1
step=defaultStep
function scrollDivDown(id){
document.getElementById(id).scrollTop+=step
timerDown=setTimeout("scrollDivDown('"+id+"')",20)
}

function scrollDivUp(id){
document.getElementById(id).scrollTop-=step
timerUp=setTimeout("scrollDivUp('"+id+"')",20)
}

function toBottom(id){
document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}

function toPoint(id){
document.getElementById(id).scrollTop=100
}
// -->
/*###########################################################################*/
function resizeElementHeight(element) {
var $offset;
var $elemnetName=element;
        if ($elemnetName == 'addProductContent'){
                $offset='35';
        }else{
                $offset='145';
        }
        
        var windowHeight=0;
        if (typeof window.innerWidth != 'undefined'){
                windowHeight = window.innerHeight;
        }else if (typeof document.documentElement != 'undefined'
                && typeof document.documentElement.clientWidth != 'undefined'
                && document.documentElement.clientWidth != 0){
                windowHeight = document.documentElement.clientHeight;
        }else{
                windowHeight = document.getElementsByTagName('body')[0].clientHeight;
        }
                //alert('h='+windowHeight);
                newheight=windowHeight-$offset+'px' ;
//                alert('new h='+newheight);
                document.getElementById(element).style.height=newheight;
return;
}
/*#######################################################################*/
function makeListOfFieldsRequired(){
    for(i=0;i < arguments.length;i++){
        var $theYPos=0;
        var $currentcontent;
        var $currentID=document.getElementById(arguments[i]);
        $currentcontent=$currentID.value;
        i++;
        var $currentRequiredFieldMessage=arguments[i];
        blankRE=/^[\s]+$/;
        if($currentcontent == "" || blankRE.test($currentcontent) || $currentcontent==undefined){
            alert($currentRequiredFieldMessage);
            $currentID.focus();
            exit;
            }
    }
}

/*#######################################################################*/
function addFieldsAsMoney(){
    // feed field nams into function to be addded to be added  the last argumentis the the field to deposit te answer.
    // called as follows
    //addFieldsAsMoney('public.5','public.2','.0','0','totalfield')"
    // the last three fields are the ,'taxmultipler', 'the fieldname to print the tax amount', 'the field to totalamount') 
    var argToAdd=arguments.length;
    argLength=arguments.length;
    argToAdd=argToAdd-3;
    var taxMultiplerIndex=argLength-3;
    var printTaxToIndex=argLength-2;
    var printTotalToIndex=argLength-1;
    var totalAll=0;
    var currentvalue;
    for(i=0;i < argToAdd;i++){
      //  alert(arguments[i]);
        var currentvaluestring=document.getElementById(arguments[i]).value;
        currentvaluestring1=currentvaluestring.match(/(\d*\.\d*)$/g);
        currentvalue=Number(currentvaluestring1);
        if(isNaN(currentvalue)){currentvalue=0};		
        totalAll=totalAll+currentvalue;
        //alert(totalAll+' '+currentvalue);
    }
    // alert(totalAll);
    // alert('total='+totalAll+' tax='+arguments[taxMultiplerIndex]);
    var taxTotal=totalAll*arguments[taxMultiplerIndex];
    if(taxTotal != 0 ){
    var taxTotalformated=formatCurrency(taxTotal);
    document.getElementById(arguments[printTaxToIndex]).value=taxTotalformated;
    totalAll=totalAll+taxTotal;
    }else{
    totalAll=totalAll;    
    }
    
    var finaltotal=formatCurrency(totalAll);
    // alert(finaltotal+' '+arguments[argToAdd]);
    document.getElementById(arguments[printTotalToIndex]).value=finaltotal;
}
function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + '$' + num + '.' + cents);
}
/*###################################EOF ####################################*/
function alertVersion(){
alert($FileVersion);
}
/*###################################EOF ####################################*/

