// JavaScript Document
// class TtipData
// code by Azer Manafov (azerman[at]hotmail[dot]com)

// cursor position trailing
var GLB_CURSOR            =  {x:-1, y:-1};
var HELPER_EVENT_HANDLERS = new Array( );
var FN_WINDOW_ONLOAD      = cursorposinit;

var HTM_RET = (HTM_RET == undefined)?0:HTM_RET;
var HTM_WRT = (HTM_WRT == undefined)?1:HTM_WRT;
var HTM_INS = (HTM_INS == undefined)?2:HTM_INS;


window.onload = cursorposinit;
function cursorposinit()
{	
    if ( window.Event )
	{	document.captureEvents(Event.MOUSEMOVE |  Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEOVER | Event.MOUSEOUT | Event.CLICK );
	}
	document.onmousemove = mouseEventHandler;
	document.onmousedown = mouseEventHandler;
	document.onmouseup   = mouseEventHandler;
	document.onmouseover = mouseEventHandler;
	document.onmouseout  = mouseEventHandler;
	document.onclick     = mouseEventHandler;
    FN_WINDOW_ONLOAD     = null;//prevent from repeated call

}
function mouseEventHandler(e)
{
	e = e || window.event;
	for( var hlp in HELPER_EVENT_HANDLERS )
	{   if ( HELPER_EVENT_HANDLERS[hlp].onMouseEvent ) 
		     GLB_CURSOR = HELPER_EVENT_HANDLERS[hlp].onMouseEvent(e);
		else HELPER_EVENT_HANDLERS[hlp](e);
	}
}
// end cursor position trailing

//start clsCallbackList -  callback stack class
function clsCallbackList( )
{
    var m_arCallbackFun = new Array( );

	this.addCallback    = function( fun, bAfter,name )
	{   var bAfter = (bAfter != undefined )?bAfter:false;
	    var name   = (name   != undefined )?name:"";
        for ( var i = 0; i < m_arCallbackFun.length; i++ )
		{   if ( m_arCallbackFun[i].callback == fun ) return;
		}
		var ob = new Object( );
		ob.callback = fun;
		ob.name     = name;
		ob.after    = bAfter;
		m_arCallbackFun.push( ob );
	}
	this.remCallback = function ( fun )
	{   for ( var i = 0; i < m_arCallbackFun.length; i++ )
		{   if ( m_arCallbackFun[i].callback == fun )
			{   m_arCallbackFun.splice( i,1);
				return;
			}
		}
	}
	this.call       = function( index )
	{   if ( typeof index == 'string' )
		{   for ( var i = 0; i < m_arCallbackFun.length; i++ )
			{   if ( m_arCallbackFun[i].name == index )
				     return m_arCallbackFun[i].callback();
			}
			return;
		}
	    if ( index > -1 && index < m_arCallbackFun.length )
		     return m_arCallbackFun[index].callback();
	}
	this.count      = function( ) { return m_arCallbackFun.length; }
	this.name       = function( index )
	{   if ( typeof index == 'string' )
		{   for ( var i = 0; i < m_arCallbackFun.length; i++ )
			{   if ( m_arCallbackFun[i].name == index )
				     return i;//return index
			}
			return -1;
		}
	    if ( index > -1 && index < m_arCallbackFun.length )
		     return m_arCallbackFun[index].name;
	}
	this.callAfter  = function( index )
	{   if ( index > -1 && index < m_arCallbackFun.length )
		     return m_arCallbackFun[index].after;
	}
};// end clsCallbackList
function clsMouseEventsHandle( visihlp )
{
	var m_arEvt     = new Array( );
	var m_visihlp   = (visihlp == 'undefined')?new clsViewHelper():visihlp;
	
	m_visihlp.registerHelper( handleMouseEvent );
	this.evobject   = function( ev_name, ev_flag, ev_callback, ev_ident, ev_param )
	{
		this.name     = ev_name;
		this.flag     = ev_flag;
		this.callback = ev_callback;
		this.ident    = ev_ident;
		this.param    = ev_param;
	}
	this.addEventA  = function( evp )
	{   for ( var i = 0; i < m_arEvt.length; i++ )
			if ( m_arEvt[i].name == evp.name ) return;
		var ev = new Object( );
		ev = evp;
	    m_arEvt.push( ev );
	}
	this.addEvent   = function( ev_name, ev_flag, ev_callback, e_ident, ev_param )
	{   var ev  = new this.evobject( ev_name, ev_flag, ev_callback, e_ident, ev_param );
		this.addEventA( ev );
	}
    function is_ident( objchk, ident )
	{   var objret = null;
	    if ( ident == undefined || ident == "" ) return null;
		var objtmp = objchk;
		while( objtmp )
		{   if ( objtmp.id && objtmp.id.indexOf( ident ) != -1)
			{   objret = objtmp;
				break;
			}
			objtmp = objtmp.parentNode;
		}
		return objret;
	}
	function handleMouseEvent( e )
	{
        e = e || window.event;
		if ( !e ) return null;

		
		for ( var i = 0; i < m_arEvt.length; i++ )
		{   if ( e.type == m_arEvt[i].name )
			{    var prop    = new Object( );
			     prop.flag   = m_arEvt[i].flag;
			     prop.param  = m_arEvt[i].param;
			     prop.target = m_visihlp.getEventTarget( e );
				 prop.obj    = (prop.target)?is_ident( prop.target,m_arEvt[i].ident ):null;
				 prop.e      = e;
				 m_arEvt[i].callback( prop );
			     return prop;
			}
		}
	    return null;
	}

};

function clsTtipData( id, iconWidth, iconHeight, imgW, imgH, iconOn, iconOff, tipImage )
{
	var m_id		   = id;
	var m_icon         = id+'3';
	var m_image        = id+'2';
	var m_movie	       = null;
	
	var m_iconOn       = iconOn;
	var m_iconOff      = iconOff;
	var m_tipImage     = tipImage;
	var m_link         = "#";
	var m_alttxt       = '';
	var m_bblend       = false;//true;
	var m_connectid    = "";

	var m_iconPos      = new function () { this.x = 0; this.y = 0; this.width = 0; this.height = 0; }
	m_iconPos.width    = iconWidth;
	m_iconPos.height   = iconHeight;
	var m_imafePos     = new function () { this.x = 0; this.y = 0; this.width = 0; this.height = 0; }
	m_imafePos.x       = -iconWidth/2;
	m_imafePos.y       = -iconHeight/2;
	m_imafePos.width   = imgW;
	m_imafePos.height  = imgH;

	var m_imgState     = 0;
	var m_img          = new Image( );
	
	this.isActive      = true;
	this.setconnectid  = function( connectid ) { m_connectid = connectid; }
	this.getconnectid  = function( ) { return m_connectid; }
	
	this.getId         = getId;
	this.getIconOn     = getIconOn;
	this.getIconOff    = getIconOff;
	this.getImgTtip	   = getImgTtip;

	this.getLink	   = getLink;
	this.setLink	   = setLink;
	this.getAlttxt	   = getAlttxt;
	this.setAlttxt	   = setAlttxt;
	this.setMovie      = setMovie;
	this.getMovie      = getMovie;
	this.setIconPos    = setIconPos;
	this.setImagePos   = setImagePos;
	this.enableBlend   = enableBlend;
	this.canBlend      = canBlend;
	this.correctTtipPos= correctTtipPos;

	this.isImgComplete = isImgComplete;
	this.isEqual       = isEqual;
	this.showThis      = showThis;
	this.showIcon      = showIcon;
	this.showImage     = showImage;
	this.showMovie     = showMovie;
	this.iconBlend     = iconBlend;
	this.iconSet       = iconSet;
	this.getIconRect   = getIconRect;
	this.getImageRect  = getImageRect;


	if ( clsTtipData.HELPER  ==  undefined || !clsTtipData.HELPER )
	     clsTtipData.HELPER = new clsViewHelper( );
	if ( clsTtipData.IMGS_PATH  ==  undefined || !clsTtipData.IMGS_PATH )
	     clsTtipData.IMGS_PATH   =  "images";
	if ( clsTtipData.VIEW_RIGHT	==  undefined || !clsTtipData.VIEW_RIGHT )
		 clsTtipData.VIEW_RIGHT  = 800;
	if ( clsTtipData.VIEW_BOTTOM == undefined || !clsTtipData.VIEW_BOTTOM )
		 clsTtipData.VIEW_BOTTOM = 600;
	if ( clsTtipData.REF_LT_OBJ  == undefined || !clsTtipData.REF_LT_OBJ )
	     clsTtipData.REF_LT_OBJ = "mapRefPoint";

	m_img.onload  = onImgload;
	m_img.onabort = onImgAbort;
	m_img.onerror = onImgError;
	m_img.src     = getImgTtip( );

	function onImgload     ( ) { onComplete(1); }
	function onImgError    ( ) { onComplete(2); }
	function onImgAbort    ( ) { onComplete(2); }
	function onComplete    ( state ) 
	{   m_imgState = state; 
		if ( m_imgState == 1)
		{	if ( m_imafePos.width  == 0 ) m_imafePos.width  = m_img.width;
			if ( m_imafePos.height == 0 ) m_imafePos.height = m_img.height;
		}
	}
	
	function isImgComplete ( ) { return (m_imgState)?true:false; }
    function correctTtipPos( )
	{	var helper = clsTtipData.HELPER;
		var thisObj= helper.getElement( m_id );
		if ( !thisObj ) return;
		var thisPos= [parseInt(thisObj.style.left), parseInt(thisObj.style.top)];

		if ( thisPos[0] + m_imafePos.width > clsTtipData.VIEW_RIGHT )
		     m_imafePos.x = -(thisPos[0] + m_imafePos.width - clsTtipData.VIEW_RIGHT );
		if ( thisPos[1] + m_imafePos.height > clsTtipData.VIEW_BOTTOM )
		     m_imafePos.y = -(thisPos[1] +  m_imafePos.height - clsTtipData.VIEW_BOTTOM );
	}

	function getId 		( )	{ return m_id; }
	function getIconOn 	( )	{ return clsTtipData.IMGS_PATH + '/' + m_iconOn; }
	function getIconOff	( ) { return clsTtipData.IMGS_PATH + '/' + m_iconOff; }
	function getImgTtip	( ) { return clsTtipData.IMGS_PATH + '/' + m_tipImage; }
	
	function getIconRect( )	{ return m_iconPos;	}
	function getImageRect( )
	{   if ( m_imafePos.width  == 0 ) m_imafePos.width  = m_img.width; 
	    if ( m_imafePos.height == 0 ) m_imafePos.height = m_img.height; 
		return m_imafePos;	
	}
	function getLink	( ) { return m_link; }
	function setLink	( linktxt ) { m_link = linktxt; }
	function getAlttxt	( ) { return m_alttxt; }
	function setAlttxt	( alttxt ) { m_alttxt = alttxt; }
	function setMovie	( obj ) { m_movie = obj;}
	function getMovie	( ) { return m_movie;}
	
	function enableBlend( blend ) { m_bblend = blend; }
	function canBlend	( ) { return m_bblend; }
	
	function setIconPos	( x,y ) { m_iconPos.x = x; m_iconPos.y = y; }
	function setImagePos( x,y )
	{   if ( x != undefined ) m_imafePos.x = x; 
		if ( y != undefined ) m_imafePos.y = y; 
		clsTtipData.HELPER.setDivPos( m_image,{ x : m_imafePos.x, y : m_imafePos.y} );
	}
	
	function isEqual    ( behav ) { return (m_id == behav.getId());}
	function showThis   ( show ) { clsTtipData.HELPER.setVisible( m_id,    show);}
	function showIcon   ( show ) { clsTtipData.HELPER.setVisible( m_icon,  show);} 
	function showImage  ( show ) { clsTtipData.HELPER.setVisible( m_image, show);}
	function showMovie  ( show ) { clsTtipData.HELPER.setVisible( m_movie, show);}
	function iconBlend  ( val  ) { clsTtipData.HELPER.setOpacity( m_icon,  val);}
	function iconSet    ( onoff)
	{   if ( onoff == 'off' )
		     clsTtipData.HELPER.swapImages(m_icon,getIconOff());
		else clsTtipData.HELPER.swapImages(m_icon,getIconOn());
	}

};// end class clsTtipData

function clsFlashLayer( id, f_name, width, height, flashvars)
{
	var m_genericId  = id;
	var m_id         = 'movie'+id;
	var m_style      = new Object();
	var m_shtml      = '';
	var m_fname      = f_name;
	var m_width      = width;
	var m_height     = height;
	var m_sflashvars = flashvars;
	
	this.createFlashLayer	= createFlashLayer;
	this.getGenericId       = getGenericId;
	this.getId				= getId;
	this.preStyle			= preStyle;
	this.setStyle			= setStyle;
	this.resStyle			= resStyle;
	
	function getGenericId    ( ) { return m_genericId; }
	function getId    		 ( ) { return m_id; }
	function getDiv          ( ) { return getElement(m_id); }
	function createFlashLayer( )
	{	
		document.write(getFlashContent( m_width, m_height, m_fname, m_sflashvars));
		setStyle( );
	}
	function resStyle( ) { m_style = new Object( ); }
	function preStyle( )
	{	resStyle( );
		for ( var i=0; i < arguments.length; i=i+2)
		{	var currArg = arguments[i].toLowerCase();    
			m_style[currArg] = arguments[i+1];
	  	}
	}
	function setStyle( )
	{	var obj = getElement( m_id );
		if ( !obj ) return;
		
		for ( var i in m_style)
		      setStyleA( obj, i,m_style[i]);
	}
	function setOpacity(elm,val)
	{   elm.style.zoom     = 1;
        elm.style.filter   = "alpha(opacity=" + parseFloat(val*100) + ")";
        elm.style.opacity  = parseFloat(val); 
        return elm;
    }
	function camelize ( val )
	{
        return val.replace(/-(.)/g, function(m, l) { return l.toUpperCase()});
    }
	
	function setStyleA( elm,prop,val)
	{
        if ( prop == 'opacity') return setOpacity( elm,parseFloat(val));
        if ( prop == 'float'  ) prop = (window.attachEvent) ? 'styleFloat' : 'cssFloat';
        prop = camelize( prop );
        unit = (prop=='zIndex'||prop=='zoom' ) ? '':'px';
        elm.style[prop] = (typeof val=='string') ? val : val+unit;
        return elm;
    }
	
	function getFlashContent( width, height, movie, flashvars)
	{	
		var str='';		
		str+=' <OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"';
		str+=' width="'+width+'" height="'+height+'">\n';

		str+=' <param name="movie"     value="'+movie+'" /> \n';
		str+=' <param name="quality"   value="high" /> \n';
		str+=' <param name="loop"      value="true" /> \n';
		str+=' <param name="wmode"     value="transparent" /> \n';
		
		if ( flashvars )
		     str+=' <param name="flashvars" value="'+flashvars+'" /> \n';
		
		var str2='<embed pluginpage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high"';
	
		str2+=' width="'+width+'" height="'+height+'"';
		str2+=' src="'+movie+'"';
		str2+=' wmode="transparent"';
		str2+=' flashvars="'+flashvars+'"';
		str2+=' > \n';
		
		str+=str2;
		str+='</OBJECT>\n';
		return str;
	}
	function getElement( id )
	{	if ( document.getElementById )
	         return document.getElementById( id );
		if ( document.all!=null )
      		 return document.all   [id];
    	else return document.layers[id];
	}
};
// class clsViewHelper
function clsViewHelper()
{
	var tipBkgColor         = "#f6e9cf";

	this.appendStyle        = appendStyle;
	this.disableSelection   = disableSelection;
	this.clone              = clone;
	this.createDivLayer     = createDivLayer;
	this.findPos			= findPos;
	this.getbaseurl         = function( site )
	{   var url = self.location.href;
	    url = url.toLowerCase();
	    var u1 = url.lastIndexOf( "http://" );
	    if ( u1 < 0 ) u1 = 0;
	    var u2 = url.indexOf( "/",url.lastIndexOf( site ));
	    var base = self.location.href.substring(u1,u2+1 );
//	    var base = url.substring(u1,u2+1 );
	    return base;
	}
	this.getElement			= getElement;
	this.getEventTarget     = getEventTarget;
    this.getCursorPos       = function( ) { return m_cursor_pos; }
	
	this.getInnerText       = getInnerText;
	this.getInstanceId      = function getInstanceId( ) { return "helper"+m_instanceid; }
	
	this.getObjectRect      = getObjectRect;
	this.getStyle           = getStyle;
	this.goToUrl            = goToUrl;

	this.ltrim				= ltrim;
	this.objSetStyle        = objSetStyle;
	this.onMouseEvent		= onMouseEvent;
	this.pointInObject		= pointInObject;
	this.registerHelper     = registerHelper;
	this.removeHelper       = removeHelper;
	this.rtrim				= rtrim;
	
	this.setDivPos			= setDivPos;
	this.setOpacity 		= setOpacity;
	this.setStyleA          = setStyleA;
	this.setVisible 		= setVisible;
	this.showTtip   		= showTtip;
	this.swapImages 		= swapImages;

	this.trim				= trim;
	

	var bAllSupport         = document.all!=null;
	var m_cursor_pos		= { x:-1, y:-1 };
	var m_instanceid        = 0;
	
	if ( clsViewHelper.INSTANCE == undefined )
	     clsViewHelper.INSTANCE = 0;
	else clsViewHelper.INSTANCE++;
	clsViewHelper.TTIP_DIV_ID = 'tipView';
	clsViewHelper.TTIP_ZINDEX = 40;
	
	m_instanceid = clsViewHelper.INSTANCE;
	
	registerHelper( this );

    function appendStyle    ( styleSheet )
    {   if ( !styleSheet || !styleSheet.length) return;
        var head  = document.getElementsByTagName("head")[0];
	    var style = document.createElement('style');
	    style.setAttribute("type", "text/css");
	    if ( style.styleSheet)
	    { style.styleSheet.cssText = styleSheet;
	    }
	    else
	    {  var cssText = document.createTextNode(styleSheet);
	       style.appendChild(cssText);
	    }
	    head.appendChild(style);
    }
	function camelize ( val )
	{
        return val.replace(/-(.)/g, function(m, l) { return l.toUpperCase()});
    }
//http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone
	function clone          ( obj )
	{   if(obj == null || typeof(obj) != 'object')
	        return obj;

	    var temp = new obj.constructor(); // changed (twice)
	    for( var key in obj)
	         temp[key] = clone(obj[key]);
	    return temp;
		
	}
	function createDivLayer ( parent, idName, divstyles, before ) //divstyles object contains <style>:<value>
    {   if ( !document.createElement ) return null;
		var ttipNode = document.createElement("div");
		ttipNode.setAttribute("id", idName );
		if ( divstyles != undefined )
		     objSetStyle( ttipNode, divstyles );
		parent = getElement( parent );
		if ( before != undefined )
		{    before = getElement( before );
		     parent.insertBefore( ttipNode, before );
		}
		else parent.appendChild( ttipNode );
        return ttipNode;
    }
	function dcdSpaces( src )
	{	var i;
		while( ( i = src.indexOf( "&nbsp;")) != -1 )
		{   src = src.substring( 0, i ) + ' ' + src.substring( i+6 );
		}
		return src;
	}
//http://www.dynamicdrive.com/dynamicindex9/noselect.htm	
    function disableSelection( target )
    {
        if ( typeof target.onselectstart!="undefined" ) //IE route
             target.onselectstart=function(){return false}
        else if (typeof target.style.MozUserSelect!="undefined" ) //Firefox route
             target.style.MozUserSelect="none";
        else //All other route (ie: Opera)
             target.onmousedown=function(){return false}
    }
// http://blog.firetree.net/2005/07/04/javascript-find-position/	
// from http://www.quirksmode.org/js/findpos.html#
	function findPos        ( id )
	{  	var pos  = { x : -1, y : -1 };
		var obj  = getElement( id );
	  	if ( obj == undefined || obj == null ) return pos; 
		if ( obj.offsetParent )
		{	pos.x = obj.offsetLeft;
			pos.y = obj.offsetTop;
			while ( (obj = obj.offsetParent))
			{	if ( obj == document.body) break;
			    if (obj.scrollLeft) { pos.x -= obj.scrollLeft;}// ?
				if (obj.scrollTop ) { pos.y -= obj.scrollTop; }// ?
			    pos.x += obj.offsetLeft;
				pos.y += obj.offsetTop;
			}
		}
		return pos;
	}
	function getElement     ( id )
	{	if ( typeof id == 'object') return id;
	    if ( document.getElementById )
	         return document.getElementById( id );
		if ( bAllSupport )
      		 return document.all   [id];
    	else return document.layers[id];
	}
	function getEventTarget ( e )
	{   e = e || window.event;
		if ( !e ) return null;
		var obj = (e.target)?e.target:e.srcElement;
		if ( obj.nodeType == 3)
			 obj = obj.parentNode;
		return obj;
	}
	function getInnerText   ( id )
	{   var obj     = getElement( id );
		if ( !obj ) return "";
	    var s = obj.innerText;
		if ( s == undefined)
		{    s = obj.innerHTML.replace(/<[^>]+>/g,"");
	    }
	    return s;
    }
	function getObjectRect  ( id )
	{   var rc  = { left :  -1, top: 0, width : 0, height : 0 };
		var obj = getElement( id );
	  	if ( obj == undefined || obj == null )
		     return rc;
		var coord = findPos( obj );
		rc.left   = coord.x;
		rc.top    = coord.y;

        if ( browser.isIcab || browser.isMac )
		{   rc.width  = obj.offsetWidth;
		    rc.height = obj.offsetHeight;
			return rc;
		}

		rc.width  = obj.clientWidth;
		rc.height = obj.clientHeight;
		return rc;
	}
 // as TinyMCE 
    function getPos     ( n )
    {
	    n = getElement( n );
		if ( !n ) return {x : -1, y : -1};
		
    	var boxModel = !browser.isIE || document.compatMode == "CSS1Compat"; 
		var x = 0, y = 0, e,  r;
		// Use getBoundingClientRect on IE, Opera has it but it's not perfect
		if ( n && browser.isIE )
		{   n = n.getBoundingClientRect();
			e = boxModel ? document.documentElement : document.body;
			x = ""; // Remove border width
			x = ( x == 'medium' || boxModel && !browser.isIE6x) && 2 || x;
			n.top += window.self != window.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset

			return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
		}

		r = n;
		while (r)
		{   x += r.offsetLeft || 0;
			y += r.offsetTop  || 0;
			r  = r.offsetParent;
		}
		r = n;
		while (r) 
		{   // Opera 9.25 bug fix, fixed in 9.50
			if (!/^table-row|inline.*/i.test( getStyle(r, "display", 1))) 
			{   x -= r.scrollLeft || 0;
				y -= r.scrollTop  || 0;
			}
			r = r.parentNode;
			if ( r == document.body)
				 break;
		}
		return {x : x, y : y};
	}

    function getStyle   ( elm, style, c)
    {   elm = getElement(elm);
		if (!elm)
			return false;
		// Gecko
		if ( document.defaultView && c)
		{   // Remove camelcase
			style = style.replace(/[A-Z]/g, function(a){ return '-' + a;});
			try
			{   return document.defaultView.getComputedStyle(elm, null).getPropertyValue(style);
			}
			catch (ex)
			{   // Old safari might fail
				return null;
			}
		}
		// Camelcase it, if needed
		style = style.replace(/-(\D)/g, function(a, b){ return b.toUpperCase(); });
		if ( style == 'float')
			 style = browser.isIE ? 'styleFloat' : 'cssFloat';
		// IE & Opera
		if ( elm.currentStyle && c )
			 return elm.currentStyle[style];
		return elm.style[style];
	}
	function goToUrl( strUrl)
	{	window.location.target = '_self';
		window.location=strUrl;
	//	window.location.href = strUrl;
		return true;
	}
	function isWhitespace( charToCheck, whitespaceChars )
	{   var whitespaceChars = (whitespaceChars != undefined )?whitespaceChars:" \t\n\r\f";
		return (whitespaceChars.indexOf( charToCheck ) != -1);
    }
	function ltrim( src, whitespaceChars )
	{   if ( !src.length ) return "";
		var posL = 0;
		while( isWhitespace(src.charAt(posL),whitespaceChars) && posL < src.length ) posL++;
		return src.substring( posL );
	}
    function objSetStyle    ( id, divstyles )
    {   var obj = getElement(id);
        if ( obj == undefined || !obj ) return;
        for ( var i in   divstyles )
        {   var c = i.replace(/-(\D)/g, function(a, b){ return b.toUpperCase(); });
            obj.style[c] = divstyles[i];
        }
    }  
	
	function onMouseEvent   ( e )
	{   var cursor = {x:-1, y:-1};
		e = e || window.event;
		if ( !e ) return cursor;
	
		if ( e.pageX || e.pageY )
		{   cursor.x = e.pageX;
			cursor.y = e.pageY;
		} 
		else
		{   var de = document.documentElement;
			var b  = document.body;
			cursor.x = e.clientX + 
				( de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
			cursor.y = e.clientY + 
				(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
		}
		m_cursor_pos = cursor;	 
		return cursor;
	}
	function pointInObject( id, w, h )
	{	var rc   = getObjectRect( id );
		if ( rc.left < 0 ) return false;
		var bRet = false;
		w    = (w != undefined && w > 0 )?w:(( rc.width  > 0)?rc.width :60);
		h    = (h != undefined && w > 0 )?h:(( rc.height > 0)?rc.height:60);
		if ( (rc.left  <= m_cursor_pos.x && m_cursor_pos.x <= rc.left +w) &&  
		     (rc.top   <= m_cursor_pos.y && m_cursor_pos.y <= rc.top  +h))
		      bRet = true;
//window.status = "ret: " + bRet + "; x: " + m_cursor_pos.x + "; y: " +  m_cursor_pos.y + "; left: "+ rc.left + "; top: " + rc.top + "; right: " + (rc.left+w-1) + "; bottom: " + (rc.top+h-1);
		return bRet;	  
	}
	function registerHelper( helper )
	{   for( var hlp in HELPER_EVENT_HANDLERS )
		{   if ( HELPER_EVENT_HANDLERS[hlp].getInstanceId && helper.getInstanceId )
			{   if ( HELPER_EVENT_HANDLERS[hlp].getInstanceId() == helper.getInstanceId())
	        		 return;
			}
			else
			{   if ( HELPER_EVENT_HANDLERS[hlp] == helper )
				     return;
			}
		}
		HELPER_EVENT_HANDLERS.push(helper);
	}
	function removeHelper   ( helper )
	{   for( var hlp in HELPER_EVENT_HANDLERS )
		{   if ( HELPER_EVENT_HANDLERS[hlp].getInstanceId && helper.getInstanceId )
			{   if ( HELPER_EVENT_HANDLERS[hlp].getInstanceId() == helper.getInstanceId())
			    {    HELPER_EVENT_HANDLERS.splice(hlp,1);
	        		 return;
	        	}
			}
			else
			{   if ( HELPER_EVENT_HANDLERS[hlp] == helper )
			    {    HELPER_EVENT_HANDLERS.splice(hlp,1);
	        		 return;
	        	}
			}
		}	
	}
	function rtrim( src,whitespaceChars )
	{   if ( !src.length ) return "";
		var posR = src.length - 1;
		while( isWhitespace(src.charAt(posR),whitespaceChars) && posR > 0 ) posR--;
		return src.substring( 0,posR+1);
	}
	function setDivPos      ( id, pos )//pos.x & pos.y numeric
	{	var obj     = getElement( id );
		if ( !obj ) return;
		if ( obj.style )
		{	obj.style.left = pos.x+'px';
			obj.style.top  = pos.y+'px';
		}
	}
	function setOpacity     ( id, value )
	{	var obj = getElement(id);
		if ( obj == undefined || !obj ) return;
		obj.style.opacity      = value/10;
		if ( browser.isIE55 || browser.isIE6x )
			 obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=\''+value*10 +'\')';
		else obj.style.filter = 'alpha(opacity=' + value*10 + ')';
	}
	function setStyleA( elm,prop,val)
	{
        if ( prop == 'opacity') return setOpacity( elm,parseFloat(val));
        if ( prop == 'float'  ) prop = (window.attachEvent) ? 'styleFloat' : 'cssFloat';
        prop = camelize( prop );
        unit = (prop=='zIndex'||prop=='zoom' ) ? '':'px';
        elm.style[prop] = (typeof val=='string') ? val : val+unit;
        return elm;
    }
	function setVisible     ( id, enable )
	{	
		if ( id <=0 ) return;
		var obj     = ( typeof id == 'object')?id:getElement( id );
		if ( enable == true )
		     enable = 'visible';

	    var NNtype  ='show'; 
	    var IEtype  ='visible'; 
		var WC3type ='visible';
		
		if ( enable != 'visible' )
		{   NNtype  = 'hidden';
			IEtype  = 'hidden';
			WC3type = 'hidden';
		}
		try
		{  
		    if ( document.getElementById )
				 obj.style.visibility = WC3type;
			else
				if ( document.layers )
					obj.visibility = NNtype;
			else
				if ( document.all )
					 obj.style.visibility = IEtype;
					 
		}
		catch(err) { window.status = err.description+"; Id: "+id; }
	}
	function showTtip       ( name, enable, tipTxt,xoffset, yoffset )
	{
		var ttipNode = getElement( clsViewHelper.TTIP_DIV_ID );
		if ( ttipNode == null )
		{	if ( !document.createElement ) return;
		    var ttipNode = document.createElement("div");
		    document.body.appendChild(ttipNode);
		    ttipNode.setAttribute("id", name );
		    ttipNode.style.position   = "absolute";
		    ttipNode.style.background = tipBkgColor;
		    ttipNode.style.border     = "1pt black solid";
		    ttipNode.style.visibility = "hidden";
		    ttipNode.style.left       = "0px";
		    ttipNode.style.top        = "0px";
		    ttipNode.style.zIndex     = clsViewHelper.TTIP_ZINDEX;
		}
		var parent = getElement(name);
		var zindex = clsViewHelper.TTIP_ZINDEX;
		
		if ( parent )
		     zindex = parent.style.zIndex + 1;

		ttipNode.style.zIndex = (zindex >= clsViewHelper.TTIP_ZINDEX)?zindex:clsViewHelper.TTIP_ZINDEX;

		var ptob = findPos   ( name );
		if ( !xoffset ) xoffset=0;
		if ( !yoffset ) yoffset=40;
		if ( enable )
		{   if ( !tipTxt ) return;
			var str ='';
			str+='<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tipTxt+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</B>';
		
			ttipNode.style.pixelLeft = ptob.x+xoffset;
			ttipNode.style.pixelTop  = ptob.y+yoffset;
			ttipNode.innerHTML = str;
			setVisible( clsViewHelper.TTIP_DIV_ID, 'visible');
		}
		else
		{
			setVisible( clsViewHelper.TTIP_DIV_ID, 'hidden');
		}
	}
	function swapImages     ( id, img )
	{	var obj = (typeof id == 'object')?id:getElement(id);
		if ( obj == undefined || !obj ) return;
		obj.src = img;
	}
	function trim( str,whitespaceChars )
	{   //str = dcdSpaces( str ); 
		return ltrim(rtrim(str,whitespaceChars),whitespaceChars);
	}
	
};// end class clsViewHelper

//class clsXmlParser
function clsXmlParser()
{   
    this.parseText = function(text, callback)
	{
		if ( typeof DOMParser != "undefined")
		{   var xml = (new DOMParser()).parseFromString(text, "application/xml");
			xml.onload = function()
            {   if ( (xml = xmlError(xml)) && callback != undefined )
                      callback( xml );
            }
			return xml;
		}
		else 
			if (typeof ActiveXObject != "undefined")
			{   var xml = new ActiveXObject("Microsoft.XMLDOM");
				xml.async="false";
				xml.loadXML(text);
				return xmlError( xml );
			}
		else
		{   // As a last resort, try loading the document from a data: URL
			// This is supposed to work in Safari. Thanks to Manos Batsis and
			// his Sarissa library (sarissa.sourceforge.net) for this technique.
			var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text);
			var request = new XMLHttpRequest();
			request.open ( "GET", url, false);
			request.send ( null );
			return request.responseXML;
		}
	}
    this.parseFile = function( file, callback )
	{
		if ( typeof DOMParser != "undefined")
		{
			var xml = document.implementation.createDocument("","",null);
            xml.load( file );
			xml.onload = function()
            {   if ( (xml = xmlError(xml)) )
                      callback( xml );
            }
			return xml;
		}
		else 
			if (typeof ActiveXObject != "undefined")
			{   var xml = new ActiveXObject("Microsoft.XMLDOM");
				xml.async="false";
				xml.load( file );
				if ( (xml = xmlError( xml )) )
				{   callback( xml );
				}
				return  xml;
			}
		return null;	
	}
	function xmlError( xml )
	{   var s = '';
	    if ( browser.isIE )
		{   if ( xml.parseError.errorCode )
			{   s += "Error Code: "   + xml.parseError.errorCode + "\n";
				s += "Error Reason: " + xml.parseError.reason    + "\n";
				s += "Error Line: "   + xml.parseError.line      + "\n";
				xml = null;
			}
		}
		else
		{   try
			{   if ( xml.documentElement && xml.documentElement.nodeName == "parsererror")
				{   s += xml.documentElement.childNodes[0].nodeValue;
					s = s.replace(/</g, "&lt;");
					xml = null;
				}
			}
			catch(e) { s = e.message; }
		}
		if ( s.length )
		     alert(s);
		return xml;
	}
}; // end class clsXmlParser
//	    getCSSValueOf( 'table.menuline','backgroundColor');
function getCSSValueOf( selector, stylename)
{   if ( document.styleSheets )
	{   var sr    = '';
		var theRules = new Array();
		for ( var i = 0; i < document.styleSheets.length; i++ )
		{   if (document.styleSheets[i].cssRules)
				theRules = document.styleSheets[i].cssRules
			else if (document.styleSheets[i].rules)
				theRules = document.styleSheets[i].rules
			else break;

			for ( var j = 0; j < theRules.length; j++ )
			{   sr = theRules[j].selectorText.toLowerCase( );
				if ( sr.indexOf(selector) != -1 )
				{   if ( theRules[j].style[stylename])
						 return theRules[j].style[stylename];
					return null;	 
				}
			}
		}
	}
    return null;
}
function getFunctionName(theFunction)//debug stack
{   // mozilla makes it easy. I love mozilla.
	if(theFunction.name)
	{   return theFunction.name;
	}
	// try to parse the function name from the defintion
	var definition = theFunction.toString();
	var name = definition.substring(definition.indexOf('function') + 8,definition.indexOf('('));
	if ( name )
		return name;
	// sometimes there won't be a function name 
	// like for dynamic functions
	return "anonymous";
}

//default helper object
visi     = new clsViewHelper( );
xmlparse = new clsXmlParser ( );

