// ##############################################################################// #### LOCALIZATION (Singleton)// ##############################################################################var trans= new Array();trans['want_save']='Opravdu chcete dokument ulo\u017Eit?';trans['want_close']='Opravdu chcete dokument zav\u0159\u00EDt bez ulo\u017Een\u00ED?';trans['document_saved']='Dokument byl ulo\u017Een ...';trans['want_delete']='Chcete dokument opravdu vymazat?';var Localization={       translate: function(word){      if (trans[word]){         return trans[word]      } else {         return word+' -> NOT TRANSLATED!!!';      }   } //--}var $T = Localization.translate;// ##############################################################################// #### HELPERS (Singleton)// ##############################################################################var Helpers={   dialogue: function(url,width,height){      //theURL=contacts_path()+"/select_contact?openform&cid="+unid;	 mywin = window.open(url, "", "left=200,top=200,width="+width+",height="+height+",status=no,scrollbars=no,toolbar=no,menubar=no,dependent=yes,alwaysRaised=yes,titlebar=no,z-lock=yes");      mywin.focus();   }} // END OF HELPER Singleton// ##############################################################################// #### ENVIRONMENT// ##############################################################################var Environment={   // do exists openned document that needs to be save?   exists_document: function (){      return true;      if  (Environment.body_form() && Environment.body_form().f) {         return true;      } else{          return false      }    },      body_frame: function(){   	if (parent && parent.body){         return(parent.body) //body frame global variable       } else {         return(parent)      }   }, //--      body_form: function(name){        	return(Environment.body_frame().document.forms[name])   },      // full dbpath, or path to database    get_module_dbname: function(name){      var names=new Array();      names['projects']='projects.nsf';      names['contacts']='cust.nsf';      names['activities']='act.nsf';      names['web']='web.nsf';      names['param']='param.nsf';      return names[name];   }, //--      dbpath: function(name){      if (!name){         return location.href.substr(0, location.href.indexOf(".nsf") + 4);      } else {         return Environment.dbdir()+"/"+Environment.get_module_dbname(name);      }   }, //--       // database directory   dbdir: function(){      return Environment.dbpath().substr(0, Environment.dbpath().lastIndexOf("/") );   },   // return current window   win: function(){      if (parent.window) {         return parent.window;      } else {         return window;      }     } // --   // end of Env object    }// #### STATUS BRANCH Environment.Status={       frame: function(){      if (parent && parent.stat){         return parent.stat;  // status frame global viariable        } else {         return null;      }   }, // --   form: function(num){      if (Environment.Status.frame()) {	    if (num){	    		return Environment.Status.frame().document.forms[num];	    } else {		 	return Environment.Status.frame().document.forms[0];	    }      }   }, //--   // show text in status frame   show: function(msg){      if (Environment.Status.frame() != null){         stext=Environment.Status.frame().document.getElementById("status_text")         if (stext){            stext.innerHTML=msg         }      }   }, //--   // gets status variable value   get_var: function (name){      if (Environment.Status.frame() != null){         if (Environment.Status.frame()[name]) {            return(Environment.Status.frame()[name])      	} else {	        	return("")	      }	   }   }, // EOF   // sets status variable value   set_var: function(name,v){      if (Environment.Status.frame() != null){         Environment.Status.frame()[name]=v;      } 	}, //EOF   // storing fields values --------   get_field: function(name){      if (Environment.Status.form() != null){         if (Environment.Status.form()[name]) {		    return(Environment.Status.form()[name].value)         } else {            return("")         }      }   }, //EOF   status_set_field: function(name,v){      if (Environment.Status.form() != null){         if (Environment.Status.form()[name]) {            this.Environment.Status.form()[name].value=v         }       }   }   } // end of Statusvar $ENV = Environment;// ##############################################################################// #### DIALOGUES (Singleton)// ##############################################################################var Dialogues={     // **********************************   // **** SHOW EXISTING ITEMS      // **********************************   select_from_ab: function(fname) {	// fname = file name, that must be populated with selected value	theURL=$ENV.dbpath('web')+"/select_from_ab?openform&fname="+fname;	Helpers.dialogue(theURL,420,180);   },      select_company: function(c_name,c_id) {      theURL=contacts_path()+"/select_company?openform&c_name="+c_name+"&c_id="+c_id;      Helpers.dialogue(theURL,420,200);    },   create_person: function(c_name,c_id,last_name,first_name){      theURL=contacts_path()+"/osoba?OpenForm&cname="+c_name+"&cid="+c_id+"&lastname="+last_name+"&firstname="+first_name;      Helpers.dialogue(theURL,460,600);   }}
