/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

function SjDetectBrowser() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isWebTV       = (ua.indexOf('webtv') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : 
                        ( (ua.indexOf('mozilla') != -1) && 
				!this.isOpera && 
				!this.isSafari && 
				(ua.indexOf('spoofer') == -1) 
				&& (ua.indexOf('compatible') == -1) 
				&& (ua.indexOf('webtv') == -1) 
				&& (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);

   this.hasAll					= (document.all)		     ? true : false;	// document.all
   this.hasAnchors				= (document.anchors)		 ? true : false;	// document.anchors
   this.hasCookies				= (document.cookie)			 ? true : false;	// cookies enabled
   this.hasDocumentElement		= (document.documentElement) ? true : false;	// document.documentElement
   this.hasForms				= (document.forms)			 ? true : false;	// document.forms
   this.hasFrames	   			= (window.frames)			 ? true : false;	// window.frames
   this.hasGetElementById  		= (document.getElementById)	 ? true : false;	// document.getElementById
   this.hasGetElementsByTagName	= (document.getElementsByTagName) ? true : false;	// document.getElementsByTagName
   this.hasImages	   			= (document.images)			 ? true : false;	// document.images
   this.hasJava		   			= navigator.javaEnabled();						// Java enabled
   this.hasLayers	   			= (document.layers)			 ? true : false;	// document.layers
   this.hasLinks	   			= (document.links)		     ? true : false;	// document.links
   this.hasOption	   			= (window.Option)		     ? true : false;	// window.Option
   this.hasRegexp	   			= (window.RegExp)		     ? true : false;	// window.RegExp
   this.hasScreen	   			= (window.screen)		     ? true : false;	// window.screen
   
}

// utility function called by getCookie( )
SjDetectBrowser.prototype.getCookieVal=function(offset){
   var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

SjDetectBrowser.prototype.fixCookieDate=function(date){
   var base=new Date(0);
   var skew=base.getTime();
   if(skew>0)date.setTime(date.getTime()-skew);
}

// primary function to retrieve cookie by name
SjDetectBrowser.prototype.getCookie=function(name){
  var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return this.getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return "";
}

// store cookie value with optional details as needed
SjDetectBrowser.prototype.setCookie=function (name,value,expires,path,domain,secure){
   document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

// remove the cookie by setting ancient expiration date
SjDetectBrowser.prototype.deleteCookie=function (name,path,domain){
    if (this.getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

var sjIS = new SjDetectBrowser();
var sjDetectBrowserIncluded = true;

function S7ConfigObject(inVersion,inViewerRoot,inRoot)
{
	this.isVersion		= inVersion || "2.8";
	this.isViewerRoot	= inViewerRoot || "/is-viewers";
	this.isRoot		= inRoot || "/is/image/";
}

var S7Config		= new S7ConfigObject();

var sjroot		= S7Config.isViewerRoot;
var sjimageServer	= S7Config.isRoot;

if(Array.prototype.push && ([0].push(true)==true))
	Array.prototype.push = null;

if(!Array.prototype.push) {
	function array_push() {
		for(var i=0;i<arguments.length;i++){
			this[this.length]=arguments[i]
		};
		return this.length;
	}
	Array.prototype.push = array_push;
}

if(!Array.prototype.pop) {
	function array_pop(){
	    lastElement = this[this.length-1];
		this.length = Math.max(this.length-1,0);
	    return lastElement;
	}
	Array.prototype.pop = array_pop;
}


String.prototype.doubleNewlines = function() { 
	return this.replace( /(\r?\n|\r){1,2}/g, '\n\n' ); 
}

function sjPBreak(str) {
	return( (str.indexOf("?")>=0?"&":"?") );
};

sjDelimList = [' ', '\n', '\r'];

function sjGetKeyValue(inS, inKey) {
	var keyIdx = inS.indexOf(inKey);
	if (keyIdx == -1) {
		return null;
	}
	var eqIdx = inS.indexOf('=', keyIdx + inKey.length);
	if (eqIdx == -1) {
		return null;
	}
	var valStartIdx = eqIdx + 1;
	while ((valEndIdx < inS.length) && (inS.charAt(valStartIdx) == ' ')) {
		valStartIdx ++;
	}
	if (valStartIdx >= inS.length - 1) {
		return null;
	}
	var valEndIdx = valStartIdx + 1;
	while ((valEndIdx < inS.length) && !sjIsLineDelim(inS.charAt(valEndIdx))) {
		valEndIdx ++;
	}
	return inS.substring(valStartIdx+1, valEndIdx);
};

function sjIsLineDelim(inChar) {
	for (var i = 0; i < sjDelimList.length; i ++) {
		if (inChar == sjDelimList[i]) {
			return true;
		}
	}
	return false;
};

function sjGetElement(name) {
   if(typeof(name)!='string') return name;
   if (document.getElementById) 
	   return document.getElementById(name);
   else if (document.all) 
	   return document.all[name];
   else name=null;
   return name;
}

function sjGetElementDoc(name) {
   if (document.getElementById) 
	   return document.getElementById(name).ownerDocument;
   else if (document.all) 
	   return document.all[name].document;
   else name=null;
   return name;
}

function sjGetElementStyle(name) {
   if (document.getElementById) 
	   return document.getElementById(name).style;
   if (document.all) 
	   return document.all[name].style;
}

function sjGetObj(name){
  if (document.getElementById){
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }else if (document.all){
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
}

function sjGetTextContent(inNode) {
	var s = '';
	var children = inNode.childNodes;
	for(var i = 0; i < children.length; i++) {
		var child = children[i];
		if (child.nodeType == 3 /*Node.TEXT_NODE*/) s += child.data;
		else s += sjGetTextContent(child);
	}
	return s;
}

function sjCreateDiv(parentId,divId) {
	var parentElm = null;
      if (parentId != null) 
	    parentElm = sjGetElement(parentId);
   if (document.all) {
      if (parentElm == null) 
		  parentElm = document.body;
		 parentElm.insertAdjacentHTML('afterBegin',' <div unselectable="on" id="' + divId + 
												'" style="position:absolute;text-align:left;overflow:hidden;">'+' '+'</div> ');
   }
   else if (document.getElementById) {
      if (parentElm == null)
		  parentElm = document.body;
      var tempLayer = document.createElement('div');
      tempLayer.setAttribute('id',divId);
      tempLayer.setAttribute('style','position:absolute;text-align:left;overflow:hidden;');
      parentElm.appendChild(tempLayer);
   }
}

function sjGetWidth(name) {
   if (document.getElementById) 
	   return document.getElementById(name).style.width;
   if (document.all) 
	   return document.all[name].offsetWidth;
}

function sjGetHeight(name) {
   if (document.getElementById) 
	   return document.getElementById(name).style.height;
   if (document.all) 
	   return document.all[name].offsetHeight;
}


function sjGetX(layer) {
   layer=sjGetElementStyle(layer);
   if (document.getElementById) 
	   return parseInt(layer.left);
   if (document.all) 
	   return layer.pixelLeft;
}

function sjGetY(layer) {
   layer=sjGetElementStyle(layer);
   if (document.getElementById) 
	   return parseInt(layer.top);
   if (document.all) 
	   return layer.pixelTop;
}

function sjSetClip(layer,x,y,t,r,b,l) {
   layer=sjGetElementStyle(layer);
   if (document.getElementById) {
      layer.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)';
   } else if (document.all) {
      layer.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)';
      layer.pixelLeft=x;
      layer.pixelTop=y;
      layer.overflow='hidden';
   }
}

function sjSetWidth(layer,w) {
   layer=sjGetElementStyle(layer);
   if (document.getElementById)
      layer.width=parseInt(w)+'px';
   else if (document.all)
      layer.posWidth=parseInt(w)+'px';
}

function sjSetHeight(layer,h) {
   layer=sjGetElementStyle(layer);
   if (document.getElementById)
      layer.height=parseInt(h)+'px';
   else if (document.all)
      layer.posHeight=parseInt(h)+'px';
}

function sjZoomMap (inMapName, inXfactor, inYfactor) {
	if(inMapName){
	  if (document.all) {
		var map = document.all[inMapName];
		if (map){
			var areas = map.all.tags('AREA');
		}
	  } else if (document.getElementsByName) {
		var map = document.getElementsByName(inMapName)[0];
		if (map){
			var areas = map.getElementsByTagName('AREA');
		}
	  }
	  if (areas) {
		for (var a = 0; a < areas.length; a++) {
		  var coords = areas[a].getAttribute('coords').split(/\s*,\s*/);
		  if (areas[a].getAttribute('shape').toLowerCase() == 'rect' || areas[a].getAttribute('shape').toLowerCase() == 'poly') {
			for (var p = 0; p < coords.length; p += 2) {
			  coords[p] = Math.round(coords[p] * inXfactor);
			  coords[p + 1] = Math.round(coords[p + 1] * inYfactor);
			}
		  } else if (areas[a].getAttribute('shape').toLowerCase() == 'circle') {
			coords[0] = Math.round(coords[0] * inXfactor);
			coords[1] = Math.round(coords[1] * inYfactor);
			coords[2] = Math.round(coords[2] * (inXfactor < inYfactor ? inXfactor : inYfactor));
		  }
		  areas[a].setAttribute('coords',coords.join(', '));
		}
	  }
	}
}

function sjResetMap (inMapName) {
	if(inMapName){
	  if (document.all) {
		var map = document.all[inMapName];
		if (map){
			var areas = map.all.tags('AREA');
		}
	  } else if (document.getElementsByName) {
		var map = document.getElementsByName(inMapName)[0];
		if (map){
			var areas = map.getElementsByTagName('AREA');
		}
	  }
	  if (areas) {
		for (var a = 0; a < areas.length; a++) {
		  var coords = areas[a].getAttribute('origcoords').split(/\s*,\s*/);
		  areas[a].setAttribute('coords',coords.join(', '));
		}
	  }
	}
}

function sjSetLayerHTML(layer,html) {  
   if (navigator.userAgent.indexOf('MSIE 5.0') && navigator.userAgent.indexOf('Mac') != -1) html += '\n';
   if (document.getElementById){
      document.getElementById(layer).innerHTML=html;
   } else if (document.all) {
      layer=eval(layer);
      layer.innerHTML=html;
   } 	
}

function sjGetLayerHTML(layer) {
   if (document.getElementById){
      return document.getElementById(layer).innerHTML;
   } else if (document.all) {
      layer=eval(layer);
      return layer.innerHTML;
   }
}

function sjSetXY(layer,x,y) {
   layer=sjGetElementStyle(layer)
   if (document.getElementById) {
      layer.left=parseInt(x)+'px';
      layer.top=parseInt(y)+'px';
   } else if (document.all) {
      layer.pixelLeft=parseInt(x)+'px';
      layer.pixelTop=parseInt(y)+'px';
   } 
}

function sjSetCursor(curtype) { 
   var ua = navigator.userAgent.toLowerCase(); 
   var isIE = (ua.indexOf('msie') != -1); 
   var isMAC = (ua.indexOf('mac') != -1); 
	document.body.style.cursor = ((!isIE || isMAC) && curtype == 'hand')? 'pointer' : curtype;
	//if (document.all) document.body.style.cursor=curtype; 
}

// value must be "visible", "hidden", or "inherit".
function sjSetVisibility (layer, value){  
   layer=sjGetElementStyle(layer);
	if (layer) 
	  layer.visibility = value;
}

// return values as strings "visible", "hidden", or "inherit".
function sjGetVisibility (layer){  
   layer=sjGetElementStyle(layer);
	if (layer) 
	 return layer.visibility;
}

function sjGetZIndex (layer){ 
   layer=sjGetElementStyle(layer);
	if (layer) 
	  return (layer.zIndex);
	else return -1;
}

function sjSetZIndex (layer, z){ 
   layer=sjGetElementStyle(layer);
	if (layer) 
		layer.zIndex = z;
}

function sjSetBackColor (layer, color){ 
	if (color.toLowerCase() == "transparent"){
		color = "";
	}
   layer=sjGetElementStyle(layer);
	if(layer.background) 
		layer.background = color;
	else if(document.all || document.getElementById) 
		layer.backgroundColor = color;
}

sjSetBackImage = function (layer, imageURL) {
   layer=sjGetElementStyle(layer);
	if(layer.background) 
		layer.background.src = imageURL == 'none' ? null : imageURL;
	else if (document.all || document.getElementById)
		layer.backgroundImage = imageURL == 'none' ? 'none' : 'url(' + imageURL + ')';
}

function sjSetBorder (layer, width,style,color){ 
   stl=sjGetElementStyle(layer);
	stl.borderWidth = width + "px" || 0;  
	stl.borderStyle = style || 'solid';
	stl.borderColor = color || 'black';
}

function sjOpacity (layer,inOpacity) {
	if (inOpacity != null) {
		stl=sjGetElementStyle(layer);
	    if(inOpacity < 0) inOpacity = 0; 
		if(inOpacity > 99) inOpacity = 99;
		stl.opacity = (inOpacity / 100);
		stl.MozOpacity = (inOpacity / 100);
		stl.KhtmlOpacity = (inOpacity / 100);
		stl.filter = "alpha(opacity=" + inOpacity + ")";
		return stl.opacity;
	}
}

function sjGetMouseXY(e){
  var mousePos = {x: 0, y: 0};
	if (document.all) {
		mousePos.x = event.clientX + document.body.scrollLeft;
	    mousePos.y = event.clientY + document.body.scrollTop;
	} else {
        mousePos.x = e.pageX;
   	    mousePos.y = e.pageY;
	}
  return mousePos;
}

function sjGetPageCoords (element) {
  var coords = {x: 0, y: 0};
  while (element) {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
    element = element.offsetParent;
  }
  return coords;
}

function sjGetOffsets (evt) {
 if(evt){
  if (typeof evt.offsetX != 'undefined')
    return { x: evt.offsetX, y: evt.offsetY }
  else if (evt.target) {
    if (window.opera)
      var element = evt.target;
    else
      var element = evt.target.nodeType == 1 ? evt.target : evt.target.parentNode;
    var eventCoords = {
      x: evt.clientX + window.pageXOffset,
      y: evt.clientY + window.pageYOffset
    };
    var elCoords = sjGetPageCoords(element);
    return {x: eventCoords.x - elCoords.x, y: eventCoords.y - elCoords.y};
  }
 }
}
function SjElement(inParent, inElementId) {
	if (arguments[0] == 'empty') {
		return;
	}
    this._parent = inParent || self;
    this.window = (inParent && inParent.window) || self;
    this.document = (inParent && inParent.document) || self.document;
	this.name=this._elementId = inElementId || 'SjElement'+parseInt(SjElement.Count++);
    this.tag = null;
	this._x = 0;
	this._y = 0;
	this._z = 0;
	this._width = 0;
	this._height = 0;
	this._visible = false;
	this._opacity = 100;
	this._fadeTime = 2000;
	this._color = '';
	this._backColor = '';
	this._backImage = '';
	this._fadeid = null;
	this._content = sjGetElement(this._elementId);
	if (this._content){
		this._content._draggable = false;
	}
	SjElement.all[this._elementId] = this;
}

SjElement.prototype.getParent = function() {
	return this._parent;
};

SjElement.prototype.getElementId = function() {
	return this._elementId;
};

SjElement.prototype.getElement = function() {
	return sjGetElement(this._elementId);
};

SjElement.prototype.toString = function () {
	return 	'SjElement.all["'+this._elementId+'"]';
};

SjElement.prototype.visible = function(inVisible) {
	var the_element = sjGetElementStyle(this._elementId);
	if (inVisible != null && the_element) {
		this._visible = inVisible;
		if (inVisible) {
			//the_element.visibility = 'visible';
			the_element.visibility = 'inherit';
		} else {
			the_element.visibility = 'hidden';
		}
	}
	return this._visible;
}

SjElement.prototype.pageXY = function() {
		return sjGetPageCoords (sjGetElement(this._elementId));
};

SjElement.prototype.left = function(inX) {
	if (inX == null) {
		return this._x;
	} else {
   if (document.getElementById) {
      this._content.style.left=parseInt(inX)+'px';
   } else if (document.all) {
      this._content.style.pixelLeft=parseInt(inX)+'px';
   }
		this._x = parseInt(inX);
		this.fireEvent('setXY');
		return this._x;
	}
};

SjElement.prototype.top = function (inY) {
	if (inY == null) {
		return this._y;
	} else {
   if (document.getElementById) {
      this._content.style.top=parseInt(inY)+'px';
   } else if (document.all) {
      this._content.style.pixelTop=parseInt(inY)+'px';
   } 
		this._y = parseInt(inY);
		this.fireEvent('setXY');
		return this._y;
	}
};

SjElement.prototype.toXY = function(inX,inY) {
	var xy={x:this.left(inX),y:this.top(inY)};
	this.fireEvent('setXY');
	return xy;
}

SjElement.prototype.width = function (inWidth) {
	if (inWidth == null) {
		return this._width;
	} else {
	   if (document.getElementById)
		  this._content.style.width=inWidth+'px';
	   else if (document.all)
		  this._content.style.posWidth=inWidth+'px';
		this._width = inWidth;
		this.fireEvent('setSize');
		return this._width;
	}
};

SjElement.prototype.height = function (inHeight) {
	if (inHeight == null) {
		return this._height;
	} else {
	   if (document.getElementById)
		  this._content.style.height=inHeight+'px';
	   else if (document.all)
		  this._content.style.posHeight=inHeight+'px';
		this._height = inHeight;
		this.fireEvent('setSize');
		return this._height;
	}
};

SjElement.prototype.setSize = function (inWidth,inHeight) {
	var size={w:this.width(inWidth),h:this.height(inHeight)};
	this.fireEvent('setSize');
	return size;
};

SjElement.prototype.clip = function (inLeft,inTop,inRight,inBottom) {
		var the_element = sjGetElementStyle(this._elementId);
		var bw=parseInt(the_element.borderWidth);
		if (bw){
			sjSetClip(this._elementId,this._x,this._y,inTop,inRight+2*bw,inBottom+2*bw,inLeft);
		}else{
			sjSetClip(this._elementId,this._x,this._y,inTop,inRight,inBottom,inLeft);
		}
};

SjElement.prototype.setBorder = function (width,style,color){ 
   stl=sjGetElementStyle(this._elementId);
	stl.borderWidth = width + "px" || 0;  
	stl.borderStyle = style || 'solid';
	stl.borderColor = color || '#000000';
}

SjElement.prototype.getBorder = function (){ 
   stl=sjGetElementStyle(this._elementId);
	return parseInt(stl.borderWidth);  
}

SjElement.prototype.opacity = function (inOpacity) {
	if (inOpacity != null) {
		var e = sjGetElement(this._elementId);
	    if(inOpacity < 0) inOpacity = 0; 
		if(inOpacity > 99) inOpacity = 99;
		e.style.opacity = (inOpacity / 100);
		e.style.MozOpacity = (inOpacity / 100);
		e.style.KhtmlOpacity = (inOpacity / 100);
		e.style.filter = "alpha(opacity=" + inOpacity + ")";
		this._opacity = inOpacity;
	}
	return this._opacity;  
}

SjElement.prototype.zIndex = function (inZ) {
	if (inZ == null) {
		return this._z;
	} else {
		sjSetZIndex(this._elementId,inZ);
		this._z = inZ;
		return sjGetZIndex(this._elementId);
	}
};

SjElement.prototype.setFadeTime = function(inFadeTime) {
	this._fadeTime = inFadeTime;
};

SjElement.prototype.fadeIn = function(inFadeTime){
    if (this._fadeid) {
		clearTimeout(this._fadeid);
		this._fadeid = null;
	}
	this._opacity=0;
	this.fadeStartTime = new Date().getTime();
	this.fadeStartOpacity = this._opacity;
	this.fadeTo(99,inFadeTime);
};

SjElement.prototype.fadeOut = function(inFadeTime){
    if (this._fadeid) {
		clearTimeout(this._fadeid);
		this._fadeid = null;
	}
	this._opacity=99;
	this.fadeStartTime = new Date().getTime();
	this.fadeStartOpacity = this._opacity;
	this.fadeTo(0,inFadeTime);
};

SjElement.prototype.fadeTo = function(inOpacity,inFadeTime){
	if(this._opacity==null) return;
	
	var dt = new Date().getTime() - this.fadeStartTime;
	if (dt >= inFadeTime) {
	    this.opacity(inOpacity);
	    this.visible((this._opacity > 0)? true:false);
		clearTimeout(this._fadeid);
		this._fadeid = null;
		if (typeof this.afterFade == 'function'){
			this.afterFade(arguments.callee);
		}
		return;
	} else {
		var newOpacity = Math.round(this.fadeStartOpacity + (inOpacity - this.fadeStartOpacity) * dt / inFadeTime);
	    this.opacity(newOpacity);
	    this.visible((this._opacity > 0)? true:false);
		this._fadeid=setTimeout(this+'.fadeTo('+inOpacity+','+inFadeTime+')',5);
	}
};

SjElement.prototype.color = function (inColor) {
	if (inColor == null) {
		return this._color;
	} else {
		sjSetBackColor(this._elementId,inColor);
		this._color=inColor;
		return this._color;
	}
};

SjElement.prototype.background = function (inBackColor,inBackImage) {
    if (inBackColor)
		this._backColor = inBackColor;
    if (inBackImage)
		this._backImage = inBackImage;
};

//System Event
//event{type,x,y,button,keyCode,shiftKey,ctrlKey,altKey} 
SjElement.prototype.addEventHandler = function(eventName, handler){
	var obj = this;
	var x = 0;
	var y = 0;
	this._content = sjGetElement(this._elementId);
	this._content["on"+eventName.toLowerCase()] = function(event){ 
		if (!event) var event = window.event;
		var target = null;
		if (event.target) {
			target = (event.target.nodeType == 3) ? event.target.parentNode : event.target;
	    } else {
		    target = event.srcElement;
		}

		if (event.modifiers){
			event.shiftKey = ((event.modifiers & Event.SHIFT_MASK) != 0);
			event.altKey = ((event.modifiers & Event.ALT_MASK) != 0);
			event.ctrlKey = ((event.modifiers & Event.CONTROL_MASK) != 0);
			event.button	= event.which;
			event.keyCode	= event.which;
		}
		if (event.pageX || event.pageY){
			event.posx = event.pageX;
			event.posy = event.pageY;
		} else if (event.clientX || event.clientY){
			event.posx = event.clientX + document.body.scrollLeft;
			event.posy = event.clientY + document.body.scrollTop;
		}

            return handler(obj, event , target);
	}
}

SjElement.prototype.removeEventHandler = function(eventName, handler){
	this._content["on"+eventName.toLowerCase()] = null;
}

//Event
SjElement.prototype.makeEventObject = function(inAarguments){
	var eventobject = new Object();
	eventobject["type"] = inAarguments[0];
	eventobject["target"] = this;
	for (i = 1; i < inAarguments.length; i+=2){
		eventobject[inAarguments[i]] = inAarguments[i+1];
	}
	return eventobject;
};

SjElement.prototype.addEventListener = function(inType, inHandler){
	inType = inType.toLowerCase();
	if (!this.hashtable_eventlisteners){
		this.hashtable_eventlisteners = new SjHashtable();
	}
	var arrListeners = this.hashtable_eventlisteners.get(inType);
	if (!arrListeners){
		arrListeners = new Array();
		this.hashtable_eventlisteners.put(inType, arrListeners);
	}
	var index = this.indexOfEventListener(inType, inHandler);
	if (index == -1){
		arrListeners.push(inHandler);
	}
};

SjElement.prototype.removeEventListener = function(inType, inHandler){
	inType = inType.toLowerCase();
	if (this.hashtable_eventlisteners){
		var arrListeners = this.hashtable_eventlisteners.get(inType);
		if (arrListeners){
			var index = this.indexOfEventListener(inType, inHandler);
			if (index != -1){
				var arrListeners_temp = new Array();
				for (var i = 0; i < arrListeners.length; i++){
					if (arrListeners[i] != inHandler){
						arrListeners_temp.push(arrListeners[i]);
					}
				}
				this.hashtable_eventlisteners.put(inType, arrListeners_temp);
			}
		}
	}
};

SjElement.prototype.fireEventObject = function(inEvent){
	if (this.hashtable_eventlisteners && this.hashtable_eventlisteners.size() > 0){
		var arrListeners = this.hashtable_eventlisteners.get(inEvent.type.toLowerCase());
		if (arrListeners){
			var index;
			for (index = 0; index < arrListeners.length; index++){
				arrListeners[index](inEvent);
			}
		}
	}
};


SjElement.prototype.fireEvent = function(){
	var eventobject = this.makeEventObject(arguments);
	this.fireEventObject(eventobject);
};

SjElement.prototype.indexOfEventListener = function(inType, inHandler){
	var result = -1;
	inType = inType.toLowerCase();
	var index;
	if (this.hashtable_eventlisteners){
		var arrListeners = this.hashtable_eventlisteners.get(inType);
		if (arrListeners){
			for (index = 0; index < arrListeners.length; index++){
				if (arrListeners[index] == inHandler){
					result = index;
					break;
				}
			}
		}
	}
	return result;
};
////

SjElement.Count = 0;
SjElement.all = [];

function SjLayer(inParent, inElementId) {
	if (arguments[0] == 'empty') {
		return;
	}
	this.SjElement = SjElement;
	this.SjElement(inParent, inElementId);
	if (this._parent && this._parent._elementId){
		sjCreateDiv(this._parent._elementId , this._elementId);
	}else{
		sjCreateDiv(null , this._elementId);
	}
	this._content = sjGetElement(this._elementId);
};

SjLayer.prototype = new SjElement('empty');

sj_resource = new Object();
sj_resource.getResource  = function(inString){
var res = inString;
	for (var key in this) {
		if (typeof key == 'string') {
			var old;
			do {
				old = res
				res = res.replace('%' + key + '%', this[key]);
			} while (old != res);
		}
	}

	return res;
} 
sj_resource.NOT_FOUND = "Not found";
sj_resource.INVALID_PARAMETER = "Invalid parameter";
sj_resource.IMAGE_IS_NOT_SPECIFIED = "image is not specified";
sj_resource.CONTEXT_PROCESSING_FAILED = "context processing FAILED";
sj_resource.ERROR = "Error";
sj_resource.THERE_WAS_A_PROBLEM_RETRIEVING_DATA = "There was a problem retrieving data";
sj_resource.ERROR_LOADING_CONTEXT = "Error loading context";
sj_resource.PROBLEMS = "Problems";
sj_resource.HANDLER_COULD_NOT_BE_ATTACHED = "Handler could not be attached";
sj_resource.HANDLER_COULD_NOT_BE_REMOVED = "Handler could not be removed";
sj_resource.TO_PREVIOUS_PAGE = "To previous page";
sj_resource.TO_NEXT_PAGE = "To next page";
sj_resource.PLEASE_TRY_AGAIN_LATER = 'Please try again later...';
sj_resource.PAGE_XX_YY = 'Page %2*idx%-%2*idx+1%';
