var refreshList=new Array();
function addRefreshElement(item){
  refreshList[refreshList.length]= item;
}

function refreshElements(){
 for(var i=0; i<refreshList.length; i++){
   hide(refreshList[i]);   show(refreshList[i]);
 }
}

function clearProcesses(){
  try{ if(Scroll_List) stopScroll();
  }catch(e){}
}
function returnProcesses(){
  try{ if(Scroll_List) restartScroll();
  }catch(e){}
}

function embed_control(location,file,w,h){
  document.getElementById(location).innerHTML='<EMBED SRC="'+file+'" width='+w+' height='+h+'>';
}

function fillName(fl_name, file_name_field){
  var pos=0;
  var name=fl_name;
  pos=fl_name.lastIndexOf('/');
  if(pos == -1){
    pos=fl_name.lastIndexOf('\\');
  }
  if(pos == -1){
    pos=fl_name.lastIndexOf(':');
  }  
  if((pos != -1)){
    name=fl_name.substring(pos+1, fl_name.length);
  }  
  file_name_field.value=name;
  file_name_field.value=file_name_field.value.replace(/[^a-zA-Z0-9_\.]/g,"_");
}
function auto_fill(file_name_field,file_field){
  if(file_name_field.value.length>3) fillName(file_name_field.value,file_name_field);
  else fillName(file_field.value,file_name_field);
}

function ExpandNC(ID){ hide(ID+"_show"); show(ID+"_hide");hide(ID+"_instr");show(ID);}
function Expand(ID){
  hide(ID+"_show"); show(ID+"_hide");hide(ID+"_instr");show(ID);  
  SetCookie(ID,'on');
}
function ContractNC(ID){ hide(ID+"_hide"); show(ID+"_show");hide(ID);show(ID+"_instr"); }
function Contract(ID){
  hide(ID+"_hide"); show(ID+"_show");hide(ID);show(ID+"_instr");
  SetCookie(ID,'off');
}
function CheckMenu(ID){
  if(GetCookie(ID)=='on')Expand(ID);
  else SetCookie(ID,'off');
}

function hide(ID1){
  obj1=document.getElementById(ID1);
  if(obj1!=null){    obj1.style.display='none';}

}
function show(ID1){
  obj2=document.getElementById(ID1);
  if(obj2!=null){ obj2.style.visibility=''; obj2.style.position='';obj2.style.display=''; }
}


var TabObjects = new Array();
function TabObject(group,name){
  this.group=group;
  this.name=name;
  return this;
}

function TabCreate(group,name){
  var found=0;
  for(var i=0; i<TabObjects.length; i++){
    if(TabObjects[i].group==group) found=1;
  }
  TabObjects[TabObjects.length] = new TabObject(group,name);
  if(!found) ExpandNC(name);
  else ContractNC(name);
} 

function TabClick(group,name){
  for(var i=0; i<TabObjects.length; i++){
    if(TabObjects[i].group==group) ContractNC(TabObjects[i].name);
  }
  ExpandNC(name);
}




function scroll_to(id){
  pos=document.getElementById(id);
  var total_x=0;
  var total_y=0;
  while (pos!=null){
   total_x+=pos.offsetLeft;
   total_y+=pos.offsetTop;
   pos=pos.offsetParent;
  }
  window.scroll(0,total_y); 
}

var expire_today = new Date();
var expire_year = new Date(expire_today.getTime()+365*24*60*60*1000);

function getCookieVal(offset){
  var endstr=document.cookie.indexOf(";", offset);
  if(endstr==-1){endstr=document.cookie.length;}
  return unescape(document.cookie.substring(offset,endstr));
}

function GetCookie(name){
  var arg=name+"=";
  var alen=arg.length;
  var clen=document.cookie.length;
  var i=0;
  var j;
  while(i<clen){
    j=i+alen;
    if(document.cookie.substring(i,j)==arg){
      return getCookieVal(j);
    }
    i=document.cookie.indexOf(" ",i)+1;
    if(i==0)break;
  }
  return null;
}

function DeleteCookie(name,path,domain){
  if(GetCookie(name)){
    document.cookie=name+"="+
      ((path)?"; path="+path : "")+
      ((domain)?"; domain="+domain:"")+
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";      
  }
}

function SetCookie(name,value,expires,path,domain,secure){
  document.cookie=name+"="+escape(value)+"; expires="+
    ((expires)?expires.toGMTString():expire_year.toGMTString())+
    ((path)?"; path="+path : "")+
    ((domain)?"; domain="+domain:"")+
    ((secure)?"; secure":"");   
}


var required_fields =new Array();
var file_upload_fields=new Array();
function required_field_object(group,field,message,required_length,string_match,isSelectField,isRadioButton){
  this.group=group;
  this.field=field;
  this.alert_message=message;
  this.required_length=required_length;
  this.string_match=string_match;
  this.isSelectField=isSelectField;
  this.isRadioButton=isRadioButton;
  return this;
}
function file_upload_field_object(group,name_field, file_field){
  this.group=group;
  this.file_field=file_field;
  this.name_field=name_field;
  return this;
}
function add_required_field(group,field, message, required_length, string_match){
  required_fields[required_fields.length] = new required_field_object(group,field, message, required_length, string_match,0);
}
function add_required_select_field(group,field, message){
  required_fields[required_fields.length] = new required_field_object(group,field, message,0,'',1);
}
function add_required_radiobutton_field(group,field, message){
  required_fields[required_fields.length] = new required_field_object(group,field, message,0,'',false,true);
}
function add_file_upload_field(group,file_name_field,file_field){
  file_upload_fields[file_upload_fields.length]=new file_upload_field_object(group,file_name_field,file_field);
}

function check_required_fields(group){
  first_field=-1;
  for(var i=0; i<required_fields.length; i++){
    if(required_fields[i].group==group){
      if(required_fields[i].isRadioButton){
        if(required_fields[i].field[0]){
          for(var j=0; j<required_fields[i].field.length; j++){
            required_fields[i].field[j].className="normal-input";
          }
        }else{
           required_fields[i].field.className="normal-input";
        }
      }else{
        required_fields[i].field.className="normal-input";
      }
      if(required_fields[i].isSelectField){
        if(required_fields[i].field.selectedIndex==0){
          required_fields[i].field.className="required-input";
          if(first_field<0)first_field=i;
        }
      }else if(required_fields[i].isRadioButton){
        var found=false;
        if(required_fields[i].field[0]){
          for(var j=0; j<required_fields[i].field.length; j++){
            if(required_fields[i].field[j].checked){ found=true; break;}
          }
        }else{
          if(required_fields[i].field.checked){ found=true;}
        }
        if(!found){
          if(required_fields[i].field[0]){
            for(var j=0; j<required_fields[i].field.length; j++){
              required_fields[i].field[j].className="required-input";
            }
          }else{
             required_fields[i].field.className="required-input";
          }
          if(first_field<0)first_field=i;
        }
      }else{
        if( required_fields[i].field.value.length<required_fields[i].required_length
         || (required_fields[i].string_match!=""&&
              required_fields[i].field.value.indexOf(required_fields[i].string_match)<0) ){
           required_fields[i].field.className="required-input";
           if(first_field<0)first_field=i;
        }
      }
    }
  }
  if(first_field>=0){
    alert(required_fields[first_field].alert_message);
    if(required_fields[first_field].isRadioButton){ 
      if(required_fields[first_field].field[0]) required_fields[first_field].field[0].focus();
      else required_fields[first_field].field.focus();
    }else{
      required_fields[first_field].field.focus();
    }
    return false;
  }else   return true;
}


function check_file_upload_fields(group){
  var upload=false;
  for(var i=0; i<file_upload_fields.length; i++){
    if(file_upload_fields[i].group==group&&file_upload_fields[i].file_field.value!=''){       
       auto_fill(file_upload_fields[i].name_field, file_upload_fields[i].file_field);    
       if(file_upload_fields[i].name_field.value.length>3) upload=true;
    }
  }
  return upload;
}

function clear_field_group(group){
  for(var i=required_fields.length-1; i>=0; i--){
    if(required_fields[i].group==group)  required_fields.splice(i,1);
  }
  for(var i=file_upload_fields.length-1; i>=0; i--){
    if(file_upload_fields[i].group==group) file_upload_fields.splice(i,1);
  }  
}


  /*
    returns whether a character is numeric or not
  */
function is_numeric(character){
  var digits="0123456789";
  if (digits.indexOf(character)!=-1) return true;
  else return false;
}
function is_alpha(character){
  var chars="abcdefghijklmnopqrstuvwxyz";
  if(chars.indexOf(character.toLowerCase())!=-1) return true;
  else return false;
}
  /*
    remove everything except digits
  */
function strip_letters(mixed_text){
  var char_only="";
  for (var i=0;i<mixed_text.length;i++){
    if (is_numeric(mixed_text.charAt(i)))  char_only+=mixed_text.charAt(i);
  }
  return char_only;
}
  
  /*
    this is necessary because focus() is broken in NS 7.x from any of the event handlers.  
    it simply puts together a line of the focus and select calls for the given form element, 
    and then calls a setTimeout of 1/10th of a second.
  */
function focus_and_select(box){
    var full_field_path="document."+box.form.name+"."+box.name+".";
    setTimeout(full_field_path+"focus();"+full_field_path+"select();",100);
}
  
  /*
    force text value into (555) 555-5555 format
  */
function phone_filter(input_box, first,second, third, ext_char,x1,x2,x3 ){
  if(!x1)x1=3;
  if(!x2)x2=3;
  if(!x3)x3=4;
  var prefix="";   var area_code="";   var first_three="";   var last_four="";  var extension="";    
  var phone_text=input_box.value.toLowerCase();
  var ext_pos=phone_text.indexOf("x");  // grab extension 
  if(phone_text=="") return;
  if(ext_pos>=0){
    extension=strip_letters(phone_text.substr(ext_pos+1,phone_text.length));    
    phone_text=phone_text.substr(0,ext_pos);
  }
  phone_text=strip_letters(phone_text);
  if (phone_text.length==x2+x3||phone_text.length>=x1+x2+x3){
    input_box.value="";
    last_four=phone_text.substr(phone_text.length-x3,x3);  //next, grab the last 4 digits       
    first_three=phone_text.substr(phone_text.length-x3-x2,x2); //then, grab the first 3 digits

    //try for an area code
    if (phone_text.length>=x1+x2+x3){
      area_code=phone_text.substr(phone_text.length-(x1+x2+x3),x1);

      //last, look for anything at the beginning (country code, etc)
      if(phone_text.length>x1+x2+x3){
        prefix=phone_text.substr(0,phone_text.length-(x1+x2+x3));
        input_box.value+=prefix+" ";
      }
      input_box.value+=first+area_code+second;
    }
    input_box.value+=first_three+third+last_four;
    if (extension!="") input_box.value+=ext_char+extension;

  }else{
    alert("Please enter a "+(x2+x3)+" or "+(x1+x2+x3)+" digit phone number.");
    focus_and_select(input_box);
  }
} 

function phoneInt_filter(input_box, first,second, third,fourth, ext_char,x1,x2,x3,x4 ){
  if(!x1)x1=2;
  if(!x2)x2=2;
  if(!x3)x3=4;
  if(!x4)x4=4;
  var prefix="";  var nat_code=""; var area_code="";   var first_three="";   var last_four="";  var extension="";    
  var phone_text=input_box.value.toLowerCase();
  var ext_pos=phone_text.indexOf("x");  // grab extension 
  if(phone_text=="") return;
  if(ext_pos>=0){
    extension=strip_letters(phone_text.substr(ext_pos+1,phone_text.length));    
    phone_text=phone_text.substr(0,ext_pos);
  }
  phone_text=strip_letters(phone_text);
  if (phone_text.length>=x1+x2+x3+x4){
    input_box.value="";
    last_four=phone_text.substr(phone_text.length-x4,x4);  //next, grab the last 4 digits       
    first_three=phone_text.substr(phone_text.length-x4-x3,x3); //then, grab the first 3 digits
    area_code=phone_text.substr(phone_text.length-(x2+x3+x4),x2);
    nat_code=phone_text.substr(phone_text.length-(x1+x2+x3+x4),x1);

      //last, look for anything at the beginning (country code, etc)
      if(phone_text.length>x1+x2+x3+x4){
        prefix=phone_text.substr(0,phone_text.length-(x1+x2+x3+x4));
        input_box.value+=prefix+" ";
      }
    input_box.value+=first+nat_code+second+area_code+third+first_three+fourth+last_four;
    if (extension!="") input_box.value+=ext_char+extension;

  }else{
    alert("Please enter a "+(x1+x2+x3+x4)+" digit international phone number.");
    focus_and_select(input_box);
  }
} 
  
  
  /*
    force text value into 55555 or 55555-5555 format
  */
function zip_filter(input_box){       
  var zip_text=strip_letters(input_box.value);
  if (!(zip_text.length==5||zip_text.length==9)&&zip_text.length>0){      
    alert("Please enter a 5 or 9 digit zip code.");                  
    focus_and_select(input_box);
  }else{  
    if(zip_text.length==9) input_box.value=zip_text.substr(0,5)+"-"+zip_text.substr(5,4)   
    else input_box.value=zip_text
  }
}  
function zip_canada_filter(input_box){
  ucase_filter(input_box);
  if(input_box.value.length==6){
    if(is_alpha(input_box.value.charAt(0))&&is_alpha(input_box.value.charAt(2))&&is_alpha(input_box.value.charAt(4))&&is_numeric(input_box.value.charAt(1))&&is_numeric(input_box.value.charAt(3))&&is_numeric(input_box.value.charAt(5))) return true;
  }else if(input_box.value.length==7){
    if(is_alpha(input_box.value.charAt(0))&&is_alpha(input_box.value.charAt(2))&&is_alpha(input_box.value.charAt(5))&&is_numeric(input_box.value.charAt(1))&&is_numeric(input_box.value.charAt(4))&&is_numeric(input_box.value.charAt(6))&&input_box.value.charAt(3)==' ') return true;
  }
  alert("Please enter a valid zip code.");
  focus_and_select(input_box);    
}
  /*
    Numeric
  */
function numeric_filter(input_box){     
  input_box.value=strip_letters(input_box.value);
}

function numeric_filter_length(input_box,x1,x2,x3){     
  if(!x1) x1=-1;
  if(!x2) x2=-1;
  if(!x3) x3=-1;
  var number=new String(parseInt(strip_letters(input_box.value)));
  if(number.length==x1||number.length==x2||number.length==x3) input_box.value=number;
  else{
    if(x1>0)
      if(x2>0)
        if(x3>0) alert("Please enter "+x1+", "+x2+", or "+x3+" digits.")
        else alert("Please enter "+x1+" or "+x2+" digits.")
      else alert("Please enter "+x1+" digits.")
  }
}
  
         
  /*  
    make every character upper case
  */
function ucase_filter(input_box){
  input_box.value=input_box.value.toUpperCase();    
}
  
  /*
    make every character lower case
  */
function lcase_filter(input_box){
  input_box.value=input_box.value.toLowerCase();
}
  
  /*
    capitalize the first character of each word
  */
function capitalized_filter(input_box){
  var input_text="";
  var last_char_is_space=1;
  for (var i=0;i<input_box.value.length;i++){
    if(last_char_is_space) input_text+=input_box.value.charAt(i).toUpperCase();
    else input_text+=input_box.value.charAt(i).toLowerCase(); 
    if(input_box.value.charAt(i)==' ')last_char_is_space=1;
    else last_char_is_space=0;
  }
  input_box.value=input_text;
}

function date_conv(st){
  var invalid=false;
  var date_array = st.split("/");
  var month_st=date_array[0];
  var day_st=date_array[1];
  var year_st = date_array[2];
  if(year_st==null||month_st==null||day_st==null){
    alert("Date must be in the form mm/dd/yyyy");	return "";
  }
  if(month_st.length>2){invalid=true;}
  if(day_st.length>2){invalid=true;}
  if(year_st.length>4){
    invalid=true;
  }
  if(year_st.length==2){
    if(year_st<50){	  year_st=year_st*1+2000;	}else{	  year_st=year_st*1+1900;	}
  }
  if((year_st>2200)||(year_st<1900)){
    invalid=true;
  }    
  var month_st=date_array[0];
  if((month_st>12)||(month_st<1)){
    invalid=true;
  }
  var day_st=date_array[1];
  if((day_st>31)||(day_st<1)){
    invalid=true;
  }
  if(invalid){
    alert("Date must be in the form mm/dd/yyyy");	return "";
  }else{
    year_st=month_st+"/"+day_st+"/"+year_st;
    return year_st;
  }
}



function setMouseOver(input,prefix){
    input.className=prefix+"-button";
    input.onmouseover=function(){this.className=prefix+'-button-alt';};
    input.onfocus=function(){this.className=prefix+'-button-alt';}; 
    input.onblur=function(){this.className=prefix+'-button';};
    input.onmouseout=function(){this.className=prefix+'-button';};
}

function createButton(input,prefix,sm,bgstyle){
    var type="cartbutton"
    if(sm) type="cartbutton-small";
    if(bgstyle)type=type+"-"+bgstyle;
    var txt=input.innerHTML; 
    input.innerHTML="";
    var div1=ce('div');
    div1.className="button-start";
    var div2=ce('div');
    div2.innerHTML=txt;
    if(navigator.userAgent.toLowerCase().indexOf("msie 6")>=0) div2.style["color"]="black";
    div1.appendChild(div2);
    input.appendChild(div1);    
    div3=ce('div');
    div3.className="button-end";
    input.appendChild(div3);
    input.className=prefix+"-button "+type;
    input.onmouseover=function(){this.className=prefix+'-button-alt '+type;};
    input.onfocus=function(){this.className=prefix+'-button-alt '+type;}; 
    input.onblur=function(){this.className=prefix+'-button '+type;};
    input.onmouseout=function(){this.className=prefix+'-button '+type;};
    var width=parseInt(input.offsetWidth);
    if(width<=20)width=parseInt(input.style["width"]);
    if(width>20) div2.style["width"]=(width-20)+"px";

}

function createDialogButton(input,color){
    var prefix="dialog-"+color;
    var txt=input.innerHTML; 
    input.innerHTML="";
    var div1=ce('div');
    div1.className="button-start";
    var div2=ce('div');
    div2.innerHTML=txt;
    if(navigator.userAgent.toLowerCase().indexOf("msie 6")>=0) div2.style["color"]="black";    
    div1.appendChild(div2);
    input.appendChild(div1);    
    div3=ce('div');
    div3.className="button-end";
    input.appendChild(div3);
    input.className=prefix+"-button";
    input.onmouseover=function(){this.className=prefix+'-button-alt';};
    input.onfocus=function(){this.className=prefix+'-button-alt';}; 
    input.onblur=function(){this.className=prefix+'-button';};
    input.onmouseout=function(){this.className=prefix+'-button';};
    var width=parseInt(input.offsetWidth);
    if(width<=20)width=parseInt(input.style["width"]);
    if(width>20) div2.style["width"]=(width-20)+"px";

}


/*
function getPictureFrame(div,img_dir){
  var table, tbody, tr, td;
  table=document.createElement('table'); table.style["borderCollapse"]="collapse"; table.style["padding"]="0px"; table.style["margin"]="0px";
  tbody=document.createElement('tbody');
    tr=document.createElement('tr');
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="26px"; td.style["height"]="28px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_03.jpg)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["height"]="28px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_04.jpg)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; td.style["height"]="28px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_05.jpg)";
    tr.appendChild(td);
  tbody.appendChild(tr);
    tr=document.createElement('tr');
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="26px"; 
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_08.jpg)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["backgroundColor"]="white"; td.style["lineHeight"]="0px"; td.style["margin"]="0px";
      td.appendChild(div);
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_07.jpg)";
    tr.appendChild(td);
  tbody.appendChild(tr);
    tr=document.createElement('tr'); 
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="26px"; td.style["height"]="23px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_10.jpg)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["height"]="23px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_11.jpg)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; td.style["height"]="23px";
        td.style["backgroundImage"]="url("+img_dir+"/FormsFac_12.jpg)";
    tr.appendChild(td);
  tbody.appendChild(tr);
  table.appendChild(tbody);
  return table;
}
function createPanel(content,title,helpContext){
  var table, tbody,tr,td, input;
  table=ce('table'); table.className="tan-table"; table.style["width"]="100%"; table.style["borderCollapse"]="collapse";  table.style["marginBottom"]="15px";
   tbody=ce('tbody');
    tr=ce('tr');
     td=ce('td'); td.className="tan-header"; td.innerHTML=title; tr.appendChild(td);     
     td=ce('td'); td.className="tan-header"; td.style["textAlign"]="right";
       if(helpContext&&helpContext!=""){
         input=ce('input'); input.type="button"; input.value="Help"; input.style["fontSize"]="11px"; 
         setMouseOver(input,'black'); input.onclick=function(){help_popup(helpContext);};
         td.appendChild(input);
       } 
    tr.appendChild(td); tbody.appendChild(tr); tr=ce('tr');
     td=ce('td'); td.colSpan=2; td.className="tan-cell";  td.appendChild(content);  tr.appendChild(td);     
   tbody.appendChild(tr);
  table.appendChild(tbody);
  return table;
}       
*/

function getPictureFrame(div,img_dir){
  var table, tbody, tr, td;
  table=document.createElement('table'); table.style["borderCollapse"]="collapse"; table.style["padding"]="0px"; table.style["margin"]="0px";
  tbody=document.createElement('tbody');
    tr=document.createElement('tr');
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; td.style["height"]="25px";
        td.style["backgroundImage"]="url(images/frame_tl.png)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["height"]="25px";
        td.style["backgroundImage"]="url(images/frame_t.png)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; td.style["height"]="25px";
        td.style["backgroundImage"]="url(images/frame_tr.png)";
    tr.appendChild(td);
  tbody.appendChild(tr);
    tr=document.createElement('tr');
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; 
        td.style["backgroundImage"]="url(images/frame_l.png)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["backgroundColor"]="white"; td.style["lineHeight"]="0px"; td.style["margin"]="0px";
      td.appendChild(div);
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px";
        td.style["backgroundImage"]="url(images/frame_r.png)";
    tr.appendChild(td);
  tbody.appendChild(tr);
    tr=document.createElement('tr'); 
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; td.style["height"]="25px";
        td.style["backgroundImage"]="url(images/frame_bl.png)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["height"]="25px";
        td.style["backgroundImage"]="url(images/frame_b.png)";
    tr.appendChild(td);
      td=document.createElement('td'); td.style["fontSize"]="1px"; td.style["lineHeight"]="0px"; td.style["margin"]="0px"; td.style["padding"]="0px";
        td.style["width"]="25px"; td.style["height"]="25px";
        td.style["backgroundImage"]="url(images/frame_br.png)";
    tr.appendChild(td);
  tbody.appendChild(tr);
  table.appendChild(tbody);
  return table;
}

function createPanel(content,title,helpContext){
  var table, tbody,tr,td, input, div;
  table=ce('table'); table.className="tan-header rounded-box";
     table.style["padding"]="0px";  table.style["border"]="0px"; 
     table.style["borderCollapse"]="collapse";  table.style["marginBottom"]="15px";
   tbody=ce('tbody');
    tr=ce('tr'); tr.className="headerrow";
     td=ce('td'); td.className="main"; 
       if(helpContext&&helpContext!=""){
         div=ce('div'); div.style["cssFloat"]="right"; div.style["styleFloat"]="right";
         input=ce('input'); input.type="button"; input.value="Help"; input.style["fontSize"]="11px"; 
         setMouseOver(input,'black'); input.onclick=function(){help_popup(helpContext);};
         div.appendChild(input);
         td.appendChild(div);
       } 
      div=ce('div'); div.style["fontWeight"]="bold"; div.style["paddingTop"]="4px";
      div.innerHTML=title;
     td.appendChild(div); tr.appendChild(td);     
     td=ce('td'); td.className="end"; td.innerHTML="";  tr.appendChild(td);
    tbody.appendChild(tr); 
    tr=ce('tr'); tr.className="contentrow";
     td=ce('td'); td.className="main";  td.appendChild(content);  tr.appendChild(td);     
     td=ce('td'); td.className="end"; td.innerHTML=""; tr.appendChild(td);
   tbody.appendChild(tr);
    tr=ce('tr'); tr.className="footerrow";
     td=ce('td'); td.className="main";  td.innerHTML="";  tr.appendChild(td);     
     td=ce('td'); td.className="end"; td.innerHTML=""; tr.appendChild(td);
   tbody.appendChild(tr);
  table.appendChild(tbody);
  return table;
}       




function help_popup(context){
  url = "popup.iml?mdl=knowledgebase/opc_help.mdl&show_instructions=1&Popup_Title=Online%20Help:%20"+escape(context)+"&CONTEXT="+escape(context);
  helpWindow=window.open(url,"Email","height=450,width=450,resizable=1,scrollbars=1,status=no,toolbar=no,location=no,menubar=no");
    helpWindow.focus(); 
}


Number.prototype.minPrecision=function(places){
  var x=new Number(this.toFixed(places));
  if(x.valueOf()==this.valueOf())return this.toFixed(places);
  else return this;
}

var DEFINED_MENU_JS=false;
var jqueryProcessList=new Array();
$(function(){
   // add button mouse overs:
  if(!DEFINED_MENU_JS){
    $.fn.processContent=function(){
	  for(var i=0; i<jqueryProcessList.length; i++){
	    this.find(jqueryProcessList[i]).trigger('process');
      }
	}
    $("[button]").live('process', function(){ createButton(this,$(this).attr('button'),$(this).attr('small'),$(this).attr('bgstyle')); })
          .each(function(){ createButton(this,$(this).attr('button'),$(this).attr('small'),$(this).attr('bgstyle')); });
    jqueryProcessList[jqueryProcessList.length]="[button]";
    
    DEFINED_MENU_JS=true;
  }

  // hover notes
  $('[hoverNote]').live("mouseout",function(){
	          $('[hoverTarget='+$(this).attr('hoverNote')+']').attr('startOpen',0);
                    })
      .live("mouseover",function(){
	         if($('[hoverTarget='+$(this).attr('hoverNote')+']').attr('startOpen',1).length>0){
			   window.setTimeout(function() { $('[hoverTarget][startOpen=1]').fadeIn()}, 1000);
			 }
          });
  
  
  
});

