  function parts(key,x,y,zoom,fileext){
        this.enable = true; 
	this.key = key;
	if (x) this.x = x;
	else this.x = 0;
        if (y) this.y = y;
        else this.y = 0;
	if (zoom) this.zoom = zoom;
        else this.zoom = 1;
	this.layer = "";
        this.color = "";
        this.filename = "";
        if (fileext) this.ext = fileext;
        else this.ext = ".bmp";
        this.partsurl = "";

        this.lenzcolor = "";
	this.alphatype = "";
	this.alpha = "";
        this.bottomalpha = "";
	this.list = "";
	this.angle = 0;
  }	
  parts.prototype.urlstring = function() {
        var text = "";
        var name =""; 
        if (this.filename != "" ) {
        	name = this.filename.substring(0,this.filename.lastIndexOf(".")) + this.ext;
		text = "&" + this.key + "=" + name;
	}
        if (this.x != 0) text = text + "&" + this.key + "x=" + this.x;
        if (this.y != 0) text = text + "&" + this.key + "y=" + this.y;
        if (this.zoom != 1) text = text + "&" + this.key + "zoom=" + this.zoom;
        if (this.angle != 0) text = text + "&" + this.key + "rot=" + this.angle;
        if (this.layer != "") text = text + "&" + this.key + "l=" + this.layer;
        if (this.color != "") text = text + "&" + this.key + "color=" + this.color;
        if (this.lenzcolor != "") {
		text = text + "&" + this.key + "lenzcolor=" + this.lenzcolor;
        	text = text + "&" + this.key + "alphatype=" + this.alphatype;
        	text = text + "&" + this.key + "alpha=" + this.alpha;
        	text = text + "&" + this.key + "bottomalpha=" + this.bottomalpha;
	}
	if (this.partsurl != "") text = text + "&" + this.key + "url=" + escape(this.partsurl); 
        
	return text;
  }
  

  function simlet(cls,item,id,exename,host){
        if (!exename) this.exename = "SimletEx.exe";
        else this.exename = exename;
	if (host) this.host = host;
	else this.host = "210.249.70.213"; 
	this.cls = cls;
	this.item = item;
        this.id = id;
	this.imageid = "";
	this.logonid = "";
        this.itype = "";
	this.zoom = 1;
        this.baseurl = "";
        this.partslist = new Array();
        this.img = new Image();
  }
  simlet.prototype.geturl = function(zoom,exename){
        var text = "";
        if (exename)
		text = "http://" + this.host + "/Simlet/" + exename + "?";
        else 
		text = "http://" + this.host + "/Simlet/" + this.exename + "?";
        text = text + "class=" + this.cls + "&item=" + this.item;
        for (key in this.partslist){
                if (this.partslist[key].enable) 
			text = text + this.partslist[key].urlstring();
	}
	if (zoom){
		if (zoom != 1) text = text + "&zoom=" + zoom;
	} 
	else if (this.zoom != 1) text = text + "&zoom=" + this.zoom;  
	if (this.baseurl != "" ) text = text + "&baseurl=" + escape(this.baseurl);
        if (this.imageid != "") text = text + "&imageid=" + this.imageid; 
        if (this.logonid != "") text = text + "&logonid=" + this.logonid; 
        if (this.itype != "") text = text + "&itype=" + this.itype; 
        return text;
  }
  simlet.prototype.addparts = function(parts){
	this.partslist[parts.key] = parts;
        return this.partslist.length; 
  }
  simlet.prototype.delparts = function (parts){
	this.partslist[parts.key] = "";
        return this.partslist.length;
  }
  simlet.prototype.queryparts = function (parts){
	return this.partslist[parts.key];
  }

  simlet.prototype.updateImage = function(){
	this.img.src = this.geturl();
  }

  simlet.prototype.getImage = function(){
//alert('ok');
//	this.img.src = this.geturl();
        return this.img;
  }

  simlet.prototype.makepictureHtml = function(divid,Exfunc,loadfunc){
       var text = "";
        if (!divid) divid = this.id; 
	text = '<div class="' + this.cls + '" id="' + divid + '">';
	if (Exfunc) text = text + '<a href="#" onclick="' + Exfunc + '(' + this.id + '.geturl(1)' + ');return false;">';
        text = text + '<img id="img' + this.id + '" border="0"';
	if (loadfunc) text = text + ' onLoad="' + loadfunc + '()"'
	text = text + ' src="' + this.geturl() + '">';
	if (Exfunc) text = text + '</a>';
	text = text + '</div>';
	return text;
  }
  simlet.prototype.updateimage = function(url){
	if (url)
		document.getElementById("img" + this.id).src = url; 
	else	       
		document.getElementById("img" + this.id).src = this.geturl(); 
  }		 

	 
  function partslist(cls,dir,list,comment,pagesize,label,id,parts,host,hidecomment,cursor,shift){
        this.cls = cls;
        this.id = id;
	this.folder = dir + "/";
        this.list = list;
        this.comment = comment;
        this.hidecomment = hidecomment;
        this.index = 0;
        this.selindex = -1;
	this.count = list.length;
        this.pagesize = pagesize;
        this.label = label;
	this.selframe = 3; 
	if (host) this.host = host;
	else this.host = "210.249.70.213"; 
	if (cursor) this.cursor = cursor;
	else this.cursor = "hand"; 
        this.parts = parts;
        if(shift){
		var newlist = new Array();
		var newcomment = new Array();
                var index = shift;
                for (i=0;i<list.length;i++){
			if (index >= list.length) index = 0;
			newlist[i] = list[index];
			newcomment[i] = comment[index];
			index++;   
		}
		this.list = newlist;
		this.comment = newcomment; 
	}

  }
  partslist.prototype.geturl = function(pos){
	var parts = this.list[pos + this.index] + "";
	var text = "http://" + this.host + "/Simlet/" + this.cls + "/" + this.folder; 
        text = text + parts;
        return text;
  }
  partslist.prototype.getcomment = function(pos){
	var text = "";
        if (this.comment)
		text = this.comment[pos + this.index] + "";
        return text;
  }
  partslist.prototype.makelistHtml = function(id,cols,setfunc,callbackfunc,nextstr,backstr,rmvstr,spanid,funcparam){
        if (nextstr) next = nextstr;
	else next = ">>"; 
        if (backstr) back = backstr;
	else back = "<<";
	this.callback = callbackfunc;
        this.spanid = spanid;
        rows = Math.ceil(this.pagesize / cols); 
	var text = '<div class="partslist" id="' + id + '">';
        text = text + '<div class="nextback">';
	text = text + '<div class="backbutton"><div style="cursor:' + this.cursor + '" onclick="' + this.id + '.goBack();return false;">' + back + '</div></div>';
	text = text + '<div class="nextbutton"><div style="cursor:' + this.cursor + '" onclick="' + this.id + '.goNext();return false;">' + next + '</div></div>';
	if(rmvstr) text = text + '<div class="removebutton"><div style="cursor:' + this.cursor + '" onclick="Remove(' + this.id + ');return false;">' + rmvstr + '</div></div>';
	text = text + '</div>';
        text = text + '<table class="picture" id="' + this.id + 'pic"><tr>';

        for (j=0;j<rows;j++){
		text = text + '<tr>';
		for(i=0;i<cols;i++){
			n = j*cols + i;
			if (n>= this.pagesize) break;
			text = text + '<td class="pic" valign="top">';
			text = text + '<a href="#" onClick="' + setfunc + '(';
        		if(this.parts) text = text + n + "," + this.id;
        		else text = text + n;
			if(funcparam) text = text + ',' + funcparam;
                        text = text + ");return false;";
        		text = text + '">';
        		text = text + '<img class="' + this.id + '" id="' + this.id + n + '" border="0" src=' + this.geturl(n) + '>';
			text = text + '</a>';
			comment = "";
			if (this.comment && !this.hidecomment){
				 comment = this.comment[n];
				text = text + '<div class="' + this.id + 'comment" id="' + this.id + 'comment' + n + '"><pre>' + comment + '</pre></div>';
			}
			text = text + '</td>';
        	}
		text = text + '</tr>';
        }

	text = text + '</table></div>';
        return text;
  }

  partslist.prototype.makelistHtml2 = function(id,cols,setfunc,callbackfunc,nextstr,backstr,rmvstr,spanid){
        if (nextstr) next = nextstr;
	else next = ">>"; 
        if (backstr) back = backstr;
	else back = "<<";
	this.callback = callbackfunc;
        this.spanid = spanid;
        rows = Math.ceil(this.pagesize / cols); 
	var text = '<div class="partslist" id="' + id + '">';
        text = text + '<div class="nextback">';
	text = text + '<div class="backbutton"><div style="cursor:' + this.cursor + '" onclick="' + this.id + '.goBack();return false;">' + back + '</div></div>';
	text = text + '<div class="nextbutton"><div style="cursor:' + this.cursor + '" onclick="' + this.id + '.goNext();return false;">' + next + '</div></div>';
	if(rmvstr) text = text + '<div class="removebutton"><div style="cursor:' + this.cursor + '" onclick="Remove(' + this.id + ');return false;">' + rmvstr + '</div></div>';
	text = text + '</div>';
        text = text + '<table class="picture" id="' + this.id + 'pic"><tr>';

        for (j=0;j<rows;j++){
		text = text + '<tr>';
		for(i=0;i<cols;i++){
			n = j*cols + i;
			if (n>= this.pagesize) break;
			text = text + '<td class="pic" valign="top">';
			text = text + '<a href="#" onClick="' + setfunc + '(';
//        		text = text + "'" + this.id + "'," + n + ");return false;";
        		text = text + n + ");return false;";
        		text = text + '">';
        		text = text + '<img class="' + this.id + '" id="' + this.id + n + '" border="0" src=' + this.geturl(n) + '>';
			text = text + '</a>';
			comment = "";
			if (this.comment && !this.hidecomment){
				 comment = this.comment[n];
				text = text + '<div class="' + this.id + 'comment" id="' + this.id + 'comment' + n + '"><pre>' + comment + '</pre></div>';
			}
			text = text + '</td>';
        	}
		text = text + '</tr>';
        }

	text = text + '</table></div>';
        return text;
  }

  partslist.prototype.makelistHtml3 = function(id,cols,setfunc,callbackfunc,nextstr,backstr,rmvstr,spanid,funcparam){
        if (nextstr) next = nextstr;
	else next = ">>"; 
        if (backstr) back = backstr;
	else back = "<<";
	this.callback = callbackfunc;
        this.spanid = spanid;
        rows = Math.ceil(this.pagesize / cols); 
        var text = "";
	var text = '<div class="partslist" id="' + id + '">';
/*
        text = text + '<div class="nextback">';
	text = text + '<div class="backbutton"><div style="cursor:' + this.cursor + '" onclick="' + this.id + '.goBack();return false;">' + back + '</div></div>';
	text = text + '<div class="nextbutton"><div style="cursor:' + this.cursor + '" onclick="' + this.id + '.goNext();return false;">' + next + '</div></div>';
	if(rmvstr) text = text + '<div class="removebutton"><div style="cursor:' + this.cursor + '" onclick="Remove(' + this.id + ');return false;">' + rmvstr + '</div></div>';
	text = text + '</div>';
*/
        text = text + '<table class="picture" id="' + this.id + 'pic"><tr>';

        for (j=0;j<rows;j++){
		text = text + '<tr>';
		for(i=0;i<cols;i++){
			n = j*cols + i;
			if (n>= this.pagesize) break;
			text = text + '<td class="pic" valign="top">';
			text = text + '<a href="#" onClick="' + setfunc + '(';
        		if(this.parts) text = text + n + "," + this.id;
        		else text = text + n;
			if(funcparam) text = text + ',' + funcparam;
                        text = text + ");return false;";
        		text = text + '">';
        		text = text + '<img class="' + this.id + '" id="' + this.id + n + '" border="0" src=' + this.geturl(n) + '>';
			text = text + '</a>';
			comment = "";
			if (this.comment && !this.hidecomment){
				 comment = this.comment[n];
				text = text + '<div class="' + this.id + 'comment" id="' + this.id + 'comment' + n + '"><pre>' + comment + '</pre></div>';
			}
			text = text + '</td>';
        	}
		text = text + '</tr>';
        }

	text = text + '</table></div>';
        return text;
  }


  partslist.prototype.getfilename = function(pos){
	return this.list[pos + this.index] + "";
  }
  partslist.prototype.goNext = function(){
	this.index = this.index + this.pagesize;
        if (this.index >= this.count) this.index = 0;
	if (this.index + this.pagesize > this.count) this.index = this.count - this.pagesize;
        for (i=0;i<this.pagesize;i++){
	    if (this.index + i < this.count){	
	    	document.getElementById(this.id + i).src = this.geturl(i);
               	if(this.comment && !this.hidecomment){
                    var text = this.getcomment(i); 
		    if (text != "")
			document.getElementById(this.id + "comment" + i).innerHTML = "<pre>" + text + "</pre>";
		    else
			document.getElementById(this.id + "comment" + i).innerHTML = "";
		}
	    }
	}
	if (this.callback) this.callback(this.getPosition(),this,this.spanid);
  }
  partslist.prototype.goBack = function(){
	if (this.index == 0) this.index = this.index = this.count - this.pagesize;
	else this.index = this.index - this.pagesize;
 	if (this.index<0) this.index = 0;
        for (i=0;i<this.pagesize;i++){
	    if (this.index + i < this.count){	
		document.getElementById(this.id + i).src = this.geturl(i);
               	if(this.comment && !this.hidecomment){
                    var text = this.getcomment(i); 
		    if (text != "")
			document.getElementById(this.id + "comment" + i).innerHTML = "<pre>" + text + "</pre>";
		    else
			document.getElementById(this.id + "comment" + i).innerHTML = "";
		}
	    }
	}
	if (this.callback) this.callback(this.getPosition(),this,this.spanid);
  }
  partslist.prototype.getPosition = function(){
      	var start = this.index+1;
        var end = this.index + this.pagesize;
	var text = "(" + start + "-" + end + " /" + this.count + ")";
	return text;
  }	
  partslist.prototype.updateSelframe = function(){
	for(i=0;i<this.pagesize;i++) document.getElementById(this.id + i).border = 0;
	if (this.selindex < 0) return;
	var n = this.selindex - this.index;
	if(n>=0 && n< this.pagesize) document.getElementById(this.id + n).border=this.selframe;
  }

  function itemlist(cls,dir,list,comment,pagesize,label,id,parts,host,hidecomment,cursor,ext,zoom,simlet,sim){
        this.cls = cls;
        this.id = id;
	this.folder = dir + "\\";
        this.list = list;
        this.comment = comment;
        this.hidecomment = hidecomment;
        this.index = 0;
        this.selindex = -1;
	this.count = list.length;
        this.pagesize = pagesize;
        this.label = label;
	this.selframe = 3; 
	if (host) this.host = host;
	else this.host = "210.249.70.213"; 
	if (cursor) this.cursor = cursor;
	else this.cursor = "hand"; 
        this.simlet = simlet;
        this.parts = parts;
        if (ext) this.ext = ext;
        else this.ext = ".bmp";
        if(zoom) this.zoom = zoom
        else this.zoom = "1";
        if (sim) this.sim = sim;
        this.applyparts = false; 
  }

  itemlist.prototype = new partslist("","","","","","","","","","","");
  itemlist.prototype.constructor = itemlist;

  itemlist.prototype.geturl = function(pos){
	var items = this.list[pos + this.index] + "";
        var saveitem;
        var savepartslist;
        if (this.sim){
                savepartslist = this.sim.partslist;
                if(!this.applyparts) this.sim.partslist = "";
        	saveitem = this.sim.item;
		this.sim.item = this.folder + items;
	}
        var savefile = this.parts.filename;
        var saveurl = this.parts.partsurl;
        this.parts.filename = items + "\\" + items + this.ext;
	if (this.sim) this.parts.partsurl = this.sim.geturl(); 
        var text = this.simlet.geturl(this.zoom,"");
        this.parts.filename = savefile;
        this.parts.partsurl = saveurl;
        if (this.sim){
		this.sim.item = saveitem;
		this.sim.partslist = savepartslist;
	}
        return text;
  }

  itemlist.prototype.updatelist = function(){
        for (i=0;i<this.pagesize;i++){
	    if (this.index + i < this.count){	
	    	document.getElementById(this.id + i).src = this.geturl(i);
               	if(this.comment && !this.hidecomment){
                    var text = this.getcomment(i); 
		    if (text != "")
			document.getElementById(this.id + "comment" + i).innerHTML = "<pre>" + text + "</pre>";
		    else
			document.getElementById(this.id + "comment" + i).innerHTML = "";
		}
	    }
	}
  }

/*
  itemlist.prototype.getfilename = function(pos){
        var items = this.list[pos + this.index] + "";
        return items + "\\" + items; 
  }
*/
