	/********************************************************************************	
	// JAVASCRIPT SOURCE
	// Main Module of Standard and useful Function for DHTML object modelling.
	//                                    merge with heats technologies .:
	// .Date - Dec 1999
	// .Last Update - 14.11.2001 - update getPage function
	// .Author - Matteo Ferretti
	********************************************************************************/
		
	var _by=1,_to=2,
		_strAPI="dHTML API - HEATS tech 2k1"
	
	function _msg(text,bIsTrap){if (bIsTrap) alert(text);return null;}

	/********************************************************************************
	Browse Check - For CrossBrowsing Reference.
	********************************************************************************/
	
	function browser(){
		// .: METHODS :.
			function _queryString(){
				var strQS=(self.location.search) ? "&"+unescape(self.location.search.substring(1)) : "",
					dummyID=strQS.match(/&[\w\s]*/gi),
					dummyVal=strQS.match(/=[\w\s]*/gi);
				if (!dummyID) return Array(0);
				var qsArgs=new Array(dummyID.length);
				for (var i=0;i<qsArgs.length;i++)
					qsArgs[i]=qsArgs[dummyID[i].substring(1)]=dummyVal[i].substring(1);
				return qsArgs;
			}
			
			function __findIMG(id, ref) {
				ref=!ref?document:ref;
				var _i=ref.images[id];if (_i) return _i
				
				if (bw.ns4)				
 					for (var i=0;i<ref.layers.length;i++)
						if (( _i =__findIMG(id,ref.layers[i].document)) !=null) return _i
		
				return null;
			}
			function __findFORM(id, ref) {
				ref=!ref?document:ref;
				var _i=ref.forms[id];if (_i) return _i
				
				if (bw.ns4)				
 					for (var i=0;i<ref.layers.length;i++)
						if (( _i =__findIMG(id,ref.layers[i].document)) !=null) return _i
		
				return null;
			}
			
			function _setImage(id,src){
				var img=__findIMG(id);				
				if (!img) _msg(".: "+_strAPI+" :.\n\n*** Sorry, but I can't see any images called '"+id+"'.\nCheck your code.",this.trapping);								
				img.src=src;
			}
			function _forms(id){
				var frm=__findFORM(id);
				if (!frm) _msg(".: "+_strAPI+" :.\n\n*** Sorry, but I can't see any forms called '"+id+"'.\nCheck your code.",this.trapping);
				return frm;
			}

			function _showProp(obj,output){
				var s="";
			
				for(var _currProp in obj)
					if (typeof(obj[_currProp]) != "function") 
						s+=_currProp+"="+obj[_currProp]+((!output)?"\n":"<br>");
			
				if (!output)
					alert("*** properties..\n\n"+s);
				else
					output.write("*** properties..<br><br>"+s);
			}
			
			function _getPage(url,bNoExt){
				url=url.toLowerCase();
				var ofs=url.lastIndexOf("/")+1;
					
				if (ofs>0){
					url=url.substr(ofs,url.length-ofs);
					
					ofs=url.indexOf("?");
					ofs=((ofs>url.indexOf("#") && url.indexOf("#")>-1)?url.indexOf("#"):ofs);

					url=(ofs>=0)?url.substr(0,ofs):url;
					
					if (bNoExt) url=url.substr(0,url.lastIndexOf("."))
					return url;
				}
				return "";
			}

			
			
			function _interface_set(id){return new _setObjectIstance(id);}
			
		// .: PROPERTIES :.			
			this.opera=(navigator.userAgent.lastIndexOf("Opera")!=-1)?1:0;
			this.ie=document.all?1:0;
			this.n=(navigator.appName=="Netscape")?1:0;
			
			this.dom=document.getElementById?1:0;
			
			this.ns4=document.layers?1:0;
			this.ns5=(this.n && this.dom)?1:0;
			
			this.ie4=(this.ie && !this.dom)?1:0;
			this.ie5=(this.ie && this.dom)?1:0;
			
			this.layerTag=this.ns4?"layer":"div";
			
			this.queryString=_queryString();
			
			this.bIsDHTML=(this.ns4 || this.ns5 || this.ie4 || this.ie5);
			
			this.trapping=1;
			
		// .: INTERFACES :.
			this.set=_interface_set;
			this.showProp=_showProp;
			this.getPage=_getPage;
			this.setImage=_setImage;
			this.forms=_forms;
						
		// Return function's pointer
			if (!this.bIsDHTML) 
				{return _msg(".: "+_strAPI+" :.\n\n*** Your browser does not recognize DHTML structure.",this.trapping);}
			else{ 
				if(this.opera && this.ie){return _msg(".: "+_strAPI+" :.\n\n*** OPERA in Explorer emulation does not recognize DHTML structure.",this.trapping);}
				else if(this.opera && this.n){return _msg(".: "+_strAPI+" :.\n\n*** OPERA in Netscape emulation does not recognize DHTML structure.",this.trapping);}
				else {return this;}
			}

	}
	
	var bw=new browser();
	
	/********************************************************************************
	Find a DHTML element 4 NS4.x- A CrossBrowser's Finder.
	********************************************************************************/
	function _ns_findDHTMLelement(id, ref) {
		ref=!ref?document.layers:ref;
		var _l=ref[id];	if (_l) return _l

		for (var i = 0; i < ref.length; i++)
	    	if (ref[i].layers.length > 0 && (_l = _ns_findDHTMLelement(id, ref[i].layers)) != null)
	        	return _l;

	  	return null;
	}
	
	/********************************************************************************
	Make Object - A CrossBrowser's Object Constructor.
	********************************************************************************/
	function _setObjectIstance(id){
		// .: METHODS :.
			function m_write(_string){		
				if (typeof(this.obj.innerHTML)!="undefined") 
					this.obj.innerHTML=_string;
				else if(bw.ns4){
					this.obj.document.open("text/html");
					this.obj.document.write(_string);
					this.obj.document.close();
				}
			}

			function m_move(x,y,method){method=!method?_to:method;this.css.left=this.x= ( (method==_to)?0:this.x)+ x;this.css.top=this.y=( (method==_to)?0:this.y)+ y;}
			function m_visible(bState){	if (typeof(bState)!="undefined") this.css.visibility=(bw.ns4)?(bState?"show":"hide"):(bState?"visible":"hidden"); return (this.css.visibility=="show"||this.css.visibility=="visible");}
			function m_setClip(t,r,b,l){if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r;this.css.clip.bottom=b;this.css.clip.left=l}else{this.css.clip="rect("+t+","+r+","+b+","+l+")";}}
			function m_bgcolor(color){if (typeof(this.css.bgColor)!="undefined") this.css.bgColor=color;else if (typeof(this.css.backgroundColor)!="undefined") this.css.backgroundColor=color;}

		// .: Checks & Setting Object's pointer :.
			if (!bw) _msg(".: "+_strAPI+" :.\n\n*** Sorry, but your browser can't create istance for DHTML object.",bw.trapping);
		
			_pntObject=bw.dom?document.getElementById(id):bw.ie?document.all[id]:bw.ns4?_ns_findDHTMLelement(id):null;
					
		// .: PROPERTIES :.
			this.obj=_pntObject;
				if (!_pntObject) return _msg(".: "+_strAPI+" :.\n\n*** I can't find object called '"+id+"'.\nCheck the full path.",bw.trapping);
			this.ref=bw.ns4?_pntObject.document:document;
			this.css=bw.ns4?_pntObject:_pntObject.style;
		
			this.x=this.css.left||this.css.pixelLeft||this.obj.offsetLeft||0
			this.y=this.css.top||this.css.pixelTop||this.obj.offsetTop||0
			this.w=this.ref.width||this.obj.offsetWidth||this.obj.pixelWidth||0
			this.h=this.ref.height||this.obj.offsetHeight||this.obj.pixelHeight||0
	
		// .: INTERFACES :.			
			this.write=m_write;
			this.move=m_move;
			this.visible=m_visible;
			this.setClip=m_setClip;
			this.bgcolor=m_bgcolor;


		// Return function's pointer
			return this;
		
	}
	/********************************************************************************
	pre Load Image - Load Images Object Constructor.
	********************************************************************************/
	function listImage(){
		var n=0,ofs=0,strName="";
		// .: METHODS :.
		function m_get(name){return this.images[this.names[name]].src;}
		// .: PROPERTIES :.
		this.images=new Array();
		this.names=new Array();
				
		for (var i=0;i<arguments.length;i++){
			n=this.images.length

			if (arguments[i]){
				this.images[n]=new Image();
				this.images[n].src=arguments[i];
				
				strName=arguments[i];
				ofs=strName.lastIndexOf("/")+1;
				if (ofs>0){
					strName=strName.substr(ofs,strName.lastIndexOf(".")-ofs);
					this.names[strName]=n;
				}
			}
			else
				this.images[n]=arguments[i];
		}
		// .: INTERFACES :.			
			this.get=m_get;
		// Return function's pointer
			return this;

	}
	/********************************************************************************
	List of Method's function
	********************************************************************************/
	function m_setAnImage(imageName,indexOfImage,imageReference){		 
		imageReference = (!imageReference) ? 'document' : imageReference;
		if (imageReference.images[imageName])
			imageReference.images[imageName].src = this.images[indexOfImage].src;
	}
	
	/********************************************************************************
	Cookie Object - A CrossBrowser's Cookie Object Constructor.
	********************************************************************************/
	function Cookie(document, name, hours, path, domain, secure){		
		this.$document = document;
		this.$name = name;
		
		// optional args.
		if (hours) this.$expiration = new Date((new Date()).getTime() + hours*3600000); else this._expiration = null;
		if (path) this.$path = path; else this.$path = null;
		if (domain) this.$domain = domain; else this.$domain = null;
		if (secure) this.$secure = true; else this.$secure = false;
		
		// private function 4 Public Methods

		function _cstore(){
			var _currProp = "",
				_scc="",
				_scCookie="";
							
			for(var _currProp in this) {
				if ((_currProp.charAt(0) == "$") || ((typeof this[_currProp]) == "function")) continue;

				if (_scc != "") _scc += "&";
				
				_scc += _currProp + ":" + escape(this[_currProp]);
			}

			_scCookie= this.$name + "=" + _scc;
	
			if (this._expiration)
				_scCookie += "; expires=" + this._expiration.toGMTString();
			
			_scCookie+=(this._path)?"; path=" + this._path:"";
			_scCookie+=(this._domain)?"; domain=" + this._domain:"";
			_scCookie+=(this._secure)?"; secure":"";
			
			this.$document.cookie = _scCookie;
		}
		
		function _cremove(){
			var _scCookie= this.$name + "=";
			
			_scCookie+=(this.$path)?"; path=" + this.$path:"";
			_scCookie+=(this.$domain)?"; domain=" + this.$domain:"";
			_scCookie+= "; expires=Fri, 02-Jan-1970 00:00:00 GMT";
			
			this.$document.cookie = _scCookie;
		}

		function _cload(){
			var _scCookie = this.$document.cookie,
				_startOfs=0,
				_endOfs=0,
				_aCookieValue="";
			
			if (_scCookie == "") return false;

			var _startOfs = _scCookie.indexOf(this.$name + "=");
			
			if (_startOfs == -1) return false;
			
			_startOfs += this.$name.length + 1;
			
			_endOfs = _scCookie.indexOf(';', _startOfs);
			
			if (_endOfs == -1) _endOfs = _scCookie.length;
			
			_scCookie = _scCookie.substring(_startOfs, _endOfs);

			var _aCookieValue = _scCookie.split('&');
			
			for(var i=0; i < _aCookieValue.length; i++)
				_aCookieValue[i] = _aCookieValue[i].split(':');

			for(var i = 0; i < _aCookieValue.length; i++) {
				this[_aCookieValue[i][0]] = unescape(_aCookieValue[i][1]);
			}
			
			return true;
		}

		this.store = _cstore;
		this.load = _cload;
		this.remove = _cremove;

	}
	/********************************************************************************
	Library Entry Point
	********************************************************************************/
	function main(){
		self.status=".: dHTML API toolbox library developed with HEATS technology is successfully loaded :.";
		if (typeof(init)!="undefined") init()
	}
	onload=main;

