
/** NicerSelector zamění klasický selectbox za skinovatelný selectbox
 *
 *  @author SomeBW
 *  @param selboxClass - třída selectboxů
 *  @param skin - (nepovinný parametr) skin v následujícím formátu: "{
 *      west: 'class name', //třída css k nastylování pravého boxu
 *      middle: 'class name', //třída css k nastylování prostředního boxu s obsahem
 *      east: 'class name', //třída css k nastylování levého boxu
 *  }"
 *  @param behavior - (nepovinný parametr) chování selectboxu v následujícím formátu: "{
 *      clickableOn: 'left|middle|right|all', // klikatelné na left - levý box, middle - střední box, right - pravý box, all - celá plocha (jakýkoliv box)
 *      attachClassName: 'true|false' // připojit css třídu vybrané položky k zobrazení vybrané položky v horním boxu
 *  }
 */
function NicerSelectors( selboxClass, skin, behavior )
{
    var selectors = new Array();

    if ( !isSet( behavior ) )
    {
        var behavior = {};
    }

    /*
     *  inicializece selectorů
     */
    this.init = function()
    {
        var foundedEls = getAllClassElements( document.body, selboxClass );

        if ( !isSet( behavior.clickableOn ) )
        {

            behavior.clickableOn = 'all';
        }

        if ( !isSet( behavior.attachClassName ) )
        {
            behavior.attachClassName = false;
        }
        
        for ( var i = 0; i < foundedEls.length; i++ )
        {
            if ( foundedEls[i].tagName.toLowerCase() == 'select' && !inSelboxArray( foundedEls[i] ) )
            {
                selectors[selectors.length] = new NicerSelector( foundedEls[i] );
            }
        }
    }

	/*
     *  vyhledá selector podle původního selectboxu
     *
     *  @param el - element selectboxu
     */
    this.getSelectorBySelectbox = function( el )
    {
        for ( var i = 0; i < selectors.length; i++ )
        {
            if ( selectors[i].selbox == el )
            {
                return selectors[i];
            }
        }

        return false;
    }

    /*
     *  obnoví zobrazení selectboxů
     *
     */
    this.update = function()
    {
        this.init();
    }

    
    /*
     *  zjistí, zda je již selectbox nahrazen selectorem
     *
     *  @param el - element selectboxu
     */
    function inSelboxArray( el )
    {
        for ( var i = 0; i < selectors.length; i++ )
        {
            if ( selectors[i].selbox == el )
            {
                return true;
            }
        }

        return false;
    }

    /*
     *  třída, vytvářející selector
     *
     *  @param selbox - element selectboxu
     */
    function NicerSelector( selbox )
    {
        var myself = this;
        this.list = Array();
        this.selbox = selbox;

        if ( isSet( skin ) )
        {
            this.skin = skin;
        }
        else
        {
            this.skin = false;
        }

        this.behavior = behavior;
        
        /*this.remove = function()
        {
            this.selItemContainer.removeAllChildren( true );
            this.selectList.removeAllChildren( true );
        }*/

        this.clickStatus = false;

        this.selectedKey = this.selbox.selectedIndex;
		this.selectedValue = this.selbox.options[this.selectedKey].value;
        this.clickableEl = null;

		

        if ( this.skin == false )
        {
            this.selectedItem = new Element( 'div', null, {position: 'relative', cssFloat: 'left', styleFloat: 'left', backgroundColor: '#FFFFFF', top: '0px', left: '0px'}, null );
            this.selectedItem.className = this.selbox.className;
            this.selbox.parentNode.insertBefore( this.selectedItem, this.selbox );
            this.clickableEl = this.selectedItem;
        }
        else
        {
            this.selItemContainer = new Element( 'div', null, {position: 'relative', cssFloat: 'left', styleFloat: 'left', overflow: 'hidden', whiteSpace: 'nowrap'}, null );
            this.selItemContainer.className = this.selbox.className;
            this.selbox.parentNode.insertBefore( this.selItemContainer, this.selbox );
            var selItemLeftSide = new Element( 'div', null, {cssFloat: 'left', styleFloat: 'left', cursor: 'inherit'}, null, this.selItemContainer );
            selItemLeftSide.className = this.skin.west;
            var selItemRightSide = new Element( 'div', null, {cssFloat: 'right', styleFloat: 'right', cursor: 'inherit'}, null, this.selItemContainer );
            selItemRightSide.className = this.skin.east;
            this.selectedItem = new Element( 'div', null, {position: 'relative', overflow: 'hidden', cursor: 'inherit'}, null, this.selItemContainer );
            this.selectedItem.className = this.skin.middle;

//alert(parseInt( this.selItemContainer.getStyle('test', 'width').width.replace( new RegExp(/^([0-9]+).*$/), '$1') ));
			if ( parseInt( Dimensions.getStyle(this.selItemContainer, "width").replace( new RegExp(/^([0-9]+).*$/), '$1') ) == 0 )
			{
				this.selectedItem.style.width = getLongestItem()+'em';
			}

            switch ( this.behavior.clickableOn )
            {
                case 'left':
                    this.clickableEl = selItemLeftSide;
                    break;
                case 'middle':
                    this.clickableEl = this.selectedItem;
                    break;
                case 'right':
                    this.clickableEl = selItemRightSide;
                    break;
                case 'all':
                    this.clickableEl = this.selItemContainer;
                    break;
                default:
                    break;
            }
        }

        this.clickableEl.style.cursor = 'pointer';
        this.selbox.style.display = 'none';
        this.selectedText = new Element('div', null, {display: 'block'}, null, this.selectedItem);

        if ( this.behavior.clickableOn != 'middle' && this.behavior.clickableOn != 'all' )
        {
            this.selectedText.cursor = 'default';
        }

        /*
         *  inicializace selectoru
         */
        this.init = function()
        {
            this.selectList = new Element( 'div', null, {cssFloat: 'left', styleFloat: 'left', borderLeft: '1px solid #CDCDCD', borderBottom: '1px solid #CDCDCD', borderRight: '1px solid #CDCDCD', backgroundColor: '#FFFFFF', textAlign: 'center', display: 'none', position: 'absolute'}, null, this.selectedItem );

            this.clickableEl.onclick = function()
            {
                if ( myself.selectList.style.display == 'none' )
                {
                    myself.selectList.style.display = 'block';
                    myself.clickStatus = true;
                    var newLeft;
                    var newTop = Dimensions.getTopRelativeByPage( myself.selectedItem ) + Dimensions.getHeight( myself.selectedItem );
                    var newWidth;

                    if ( myself.skin == false )
                    {
                        newLeft = Dimensions.getLeftRelativeByPage( myself.selectedItem ) + 1;
                        newWidth = Dimensions.getWidth( myself.selectedItem ) - 2;
                    }
                    else
                    {
                        newLeft = Dimensions.getLeftRelativeByPage( selItemLeftSide );
                        newWidth = Dimensions.getWidth( selItemLeftSide ) + Dimensions.getWidth( myself.selectedItem ) + Dimensions.getWidth( selItemRightSide ) - 2;
                    }
                    document.body.appendChild( myself.selectList );
                    myself.selectList.style.top = newTop+'px';
                    myself.selectList.style.left = newLeft+'px';
                    myself.selectList.style.width = newWidth+'px';

                    document.body.onclick = function()
                    {
                        for (i = 0; i < selectors.length; i++)
                        {
                            if ( selectors[i].clickStatus == false && selectors[i].selectList.style.display == 'block' )
                            {
                                selectors[i].selectList.style.display = 'none';
                            }

                            selectors[i].clickStatus = false;
                        }
                    };

                }
                else
                {
                    myself.selectedItem.appendChild( myself.selectList );
                    myself.selectList.style.top = '100%';
                    myself.selectList.style.left = '-1px';
                    myself.selectList.style.display = 'none';
                }

            };

            var options = myself.selbox.options;

            for ( var i = 0; i < options.length; i++ )
            {
                var key = i;

                this.list[key] = {
                    element : document.createElement('div'),
                    textValue :  options[key].innerHTML
                };

                this.list[key].element.innerHTML = this.list[key].textValue;
                this.list[key].element.className = myself.selbox.options[i].className;
                this.list[key].element.style.cursor = 'pointer';
                this.list[key].element.style.display = 'block';
                this.list[key].element.style.margin = '0';
                this.list[key].element.key = key;

                this.list[key].element.onclick = function()
                {
                    myself.selectKey( this.key );


                    
                };

                this.selectList.appendChild(this.list[key].element);
            }
        }


		/*
         *  vybere hodnotu podle klíče (vybraného indexu selectboxu), do
         *  @param key - klíč
         */
		this.selectKey = function( key )
		{
			select( key );

			if ( isFunction( myself.selbox.onchange ) )
			{
				myself.selbox.onchange();
			}
		}

		/*
         *  vybere hodnotu podle hodnoty value v selectboxu (vybraného hodnoty selectboxu)
         *  @param value - hodnota v selectboxu (parametr value)
         */
		this.selectValue = function( value )
		{
			var options = myself.selbox.options;

			for ( var i = 0; i < options.length; i++ )
			{
				if ( options[i].value == value )
				{
					this.selectKey( i );
					break;
				}
			}

		}

		/*
         *  zjistí, zda zadanou hodnotu sedlectbox obsahuje
         *  @param value - hodnota v selectboxu (parametr value)
         */
		this.hasValue = function( value )
		{
			var options = myself.selbox.options;

			for ( var i = 0; i < options.length; i++ )
			{
				if ( options[i].value == value )
				{
					return true;
				}
			}

			return false;

		}

        /*
         *  obnoví hodnotu selectoru
         */
        this.updateValue = function()
        {
			if ( isFunction(this.select) )
			{
	            this.select( this.selbox.selectedIndex );
			}
        }

        /*
         *  vybere hodnotu podle klíče (vybraného indexu selectboxu), do
         *  @param key - klíč
         */
        function select( key )
        {
            if ( key != -1 && isSet( myself.list[key].textValue ) )
            {
                var ee;
                //var actItem = this.list[key];
                try
                {
                    myself.selectedText.innerHTML = myself.list[key].textValue;
                }
                catch(ee)
                {
                    var ee2;

                    try
                    {
                        myself.selectedText.innerText = myself.list[key].textValue;
                        
                    }
                    catch(ee2)
                    {
                        alert( "Error in using innerHTML or innerText function, if you are using fucking IE, check if your select element isn't child of 'p' element" );
                    }
                }
                
                myself.list[myself.selectedKey].element.style.display = 'block';
                myself.selectedKey = key;
				myself.selectedValue = myself.selbox.options[myself.selectedKey].value;

                if ( behavior.attachClassName )
                {
                    if ( myself.skin == false )
                    {
                        myself.selectedItem.className = myself.list[myself.selectedKey].element.className+' '+myself.selbox.className;
                    }
                    else
                    {
                        myself.selItemContainer.className = myself.list[myself.selectedKey].element.className+' '+myself.selbox.className;
                    }
                }

                myself.list[myself.selectedKey].element.style.display = 'none';
                myself.selbox.selectedIndex = key;
            }
        }

		function getLongestItem( )
		{
			var options = myself.selbox.options;

			var longestItemLength = 0;
			var longestItemText = '';

			for ( var i = 0; i < options.length; i++ )
			{
				if ( options[i].innerHTML.length > longestItemLength )
				{
					longestItemLength = options[i].innerHTML.length;
					longestItemText = options[i].innerHTML;

				}
			}
			return longestItemLength;
		}

        this.init();
        select( this.selectedKey );

    }

    this.init();
}

function Element( tag, params, style, inner, appendTo )
{
    var element = document.createElement( tag );

    if ( isSet( params ) )
    {
        for ( var i in params ){
            element.setAttribute(i, params[i]);
        }
    }
    if ( isSet( style ) )
    {
        for ( var i in style )
        {
            element.style[i] = style[i];
        }
    }
    if ( isSet( appendTo ) )
    {
        appendTo.appendChild( element );
    }

    if ( isSet( inner ) )
    {
        element.innerHTML = inner;
    }

    return element;
}

var Dimensions = {
        getHeight: function(element){
		var ee;

		try
                {
			var $cs = document.defaultView.getComputedStyle(element,'');
			$val = style2px($cs.getPropertyValue("height"));
		}
		catch(ee)
                {
			$val = (element.offsetHeight);
			if ($val < 0) $val = 0;
		}

		return $val;
        },


	getWidth: function(element){
		var ee;

		try
                {
			var $cs = document.defaultView.getComputedStyle(element,'');
			$val = style2px($cs.getPropertyValue("width"));
		}
		catch(ee)
                {
			$val = (element.offsetWidth);
			if ($val < 0) $val = 0;
		}

		return $val;
        },

        getTop: function(element){
		var ee;
		try
                {
			var cs = document.defaultView.getComputedStyle(element,'');
			rValue = style2px(cs.getPropertyValue("top"));
		}
		catch(ee){
			rValue = (element.offsetTop);
			if (rValue < 0) rValue = 0;
		}
		return rValue;
        },

        getTopRelativeByPage: function(element){


                var first = true;
                var rValue = 0;

                while (element.tagName.toLowerCase() != "html")
                {
                    if (first == true)
                    {
                        //alert('top: '+element.className)
                        var ee;
                        try
                        {
                                var cs = document.defaultView.getComputedStyle(element,'');
                                rValue = style2px(cs.getPropertyValue("top"));
                                //alert('top: '+element.className+', '+style2px(cs.getPropertyValue("top")))
                        }
                        catch(ee){
                                rValue = (element.offsetTop);
                                //alert('top: '+element.className+', '+rValue)
                        }
                        first = false;
                    }
                    else
                    {
                        if (this.getStyle(element, "position").toLowerCase() == "relative" || this.getStyle(element, "position").toLowerCase() == "absolute" )
                        {
                            
                            var ee;
                            try
                            {
                                    cs = document.defaultView.getComputedStyle(element,'');
                                    rValue += style2px(cs.getPropertyValue("top"));
                                    //alert('top: '+element.className+', '+style2px(cs.getPropertyValue("top")))
                            }
                            catch(ee){
                                    var tempVal = element.offsetTop;
                                    rValue += tempVal;
                                    //alert('top: '+element.className+', '+tempVal)
                            }
                        }
                    }
                    element = element.parentNode;
                    //alert(element.tagName);
                }

                return rValue;
        },



        getTopRelativeByPage2: function(element){


                var first = true;
                var rValue = 0;

                while (element.tagName.toLowerCase() != "html")
                {
                    if (first == true)
                    {
                        //alert('top: '+element.className)
                        var ee;
                        try
                        {
                                var cs = document.defaultView.getComputedStyle(element,'');
                                rValue = style2px(cs.getPropertyValue("top"));
                                //alert('top: '+element.className+', '+style2px(cs.getPropertyValue("top")))
                        }
                        catch(ee){
                                rValue = (element.offsetTop);
                                //alert('top: '+element.className+', '+rValue)
                        }
                        first = false;
                    }
                    else
                    {
                        if (this.getStyle(element, "position").toLowerCase() == "relative" || this.getStyle(element, "position").toLowerCase() == "absolute" )
                        {

                            var ee;
                            try
                            {
                                    cs = document.defaultView.getComputedStyle(element,'');
                                    rValue += style2px(cs.getPropertyValue("top"));
                                    //alert('top: '+element.className+', '+style2px(cs.getPropertyValue("top")))
                            }
                            catch(ee){
                                    var tempVal = element.offsetTop;
                                    rValue += tempVal;
                                    //alert('top: '+element.className+', '+tempVal)
                            }
                        }
                    }
                    element = element.parentNode;
                    //alert(element.tagName);
                }

                return rValue;
        },


        getLeftRelativeByPage: function(element){


                var first = true;
                var rValue = 0;

                while (element.tagName.toLowerCase() != "html")
                {
                    if (first == true)
                    {
                        var ee;
                        //alert('left: '+element.className)
                        try
                        {
                                var cs = document.defaultView.getComputedStyle(element,'');
                                rValue = style2px(cs.getPropertyValue("left"));
                                //alert('left: '+element.className+', '+style2px(cs.getPropertyValue("left")))
                        }
                        catch(ee){
                                rValue = (element.offsetLeft);
                                //alert('left: '+element.className+', '+rValue)
                        }
                        first = false;
                    }
                    else
                    {
                        if (this.getStyle(element, "position").toLowerCase() == "relative" || this.getStyle(element, "position").toLowerCase() == "absolute" )
                        {
                            var ee;
                            try
                            {
                                    cs = document.defaultView.getComputedStyle(element,'');
                                    rValue += style2px(cs.getPropertyValue("left"));
                                    //alert('left: '+element.className+', '+style2px(cs.getPropertyValue("left")))
                            }
                            catch(ee){
                                    var tempVal = element.offsetLeft;

                                        rValue += tempVal;
                                        //alert('left: '+element.className+', '+tempVal)
                            }
                        }
                    }
                    element = element.parentNode;
                }

                return rValue;
        },

        getLeft: function(element){
		var ee;

		try
                {
			var cs = document.defaultView.getComputedStyle(element,'');
			rValue = style2px(cs.getPropertyValue("left"));
		}
		catch(ee){
			rValue = (element.offsetLeft);
			if (rValue < 0) rValue = 0;
		}

		return rValue;
        },

    getStyle: function( el, styleProp )
    {
			var element = el;
			var output = false;
			
			if ( element.currentStyle )
			{
				var exceptions = {
					ie: {
						'float' : 'styleFloat'
					},
					firefox: {
						'float' : 'cssFloat'
					}
				};

				styleProp = styleProp.toDromedar( '-', true );

				if ( isSet( exceptions.ie[styleProp] ) )
				{
					styleProp = exceptions.ie[styleProp];
				}
				
				output = element.currentStyle[styleProp];
			}
			else if ( window.getComputedStyle )
			{
				output = document.defaultView.getComputedStyle( element, null ).getPropertyValue( styleProp );
			}

			return output;
    },



    getCompStyle: function(el, pseudo)
    {
        this.el = el;

        this.getPropertyValue = function(prop)
        {
            var re = /(\-([a-z]){1})/g;
            if (prop == 'float') prop = 'styleFloat';

            if (re.test(prop))
            {
                prop = prop.replace(re, function (){return arguments[2].toUpperCase();})
            }

            return el.currentStyle[prop] ? el.currentStyle[prop] : null;
        }
        
        return this;
    }
};

String.prototype.toDromedar = function( separator, firstLower )
{
	var items = this.split( separator );
	var output = '';
	var start = 0;

	if ( isSet( firstLower ) && firstLower == true )
	{
		start = 1;
		output = items[0].toString();
	}

	for ( var i = start; i < items.length; i++ )
	{
		output += items[i].toString().firstUpper();
	}

	return output;
}

String.prototype.firstUpper = function()
{
	var firstPart = this.substr( 0, 1 ).toUpperCase();
	var secondPart = this.substr( 1 );

	return firstPart+secondPart;
}

String.prototype.toInt = function()
{
	var output = this.replace( new RegExp(/^(-?[0-9]+).*$/), '$1');

	if ( !isInt( output ) )
	{
		output = 0;
	}
	
	return parseInt( output );
}

function isInt( value )
{
	if ( value.search( new RegExp( /^(-?[0-9]+)$/ ) ) )
	{
		return false;
	}
	else
	{
		return true;
	}
}


var Css = {
    getCompStyle: function( elem, styleProp )
    {
        var retVal = false;

        if (elem.currentStyle)
        {
            retVal = elem.currentStyle[styleProp];
        }
        else if (window.getComputedStyle)
        {
            retVal = document.defaultView.getComputedStyle( elem, null ).getPropertyValue( styleProp );
        }

        return retVal;
    },

    hasClassName: function( element, className )
    {
        return element.className.match( new RegExp( "(^|\\s)"+className+"(\\s|$)" ) );
    },

    addClassName: function( element, className )
    {
        if ( !Css.hasClassName( element, className ) )
        {
            element.className = element.className+' '+className;
            return true;
        }
        else
        {
            return false
        }
    },

    removeClassName: function( element, className )
    {
        element.className.replace( new RegExp( "^"+className+"\\s" ), '' );
        element.className.replace( new RegExp( "\\s"+className+"$" ), '' );
        element.className.replace( new RegExp( "\\s"+className+"\\s" ), ' ' );

        return true;
    }
}

/*Object.prototype.hasClassName = function( className )
{
    if ( isElement( this ) )
    {
        return this.className.match( new RegExp( "(^|\\s)"+className+"(\\s|$)" ) );
    }

    return false;
}*/

function hasClassName( parentEl, className )
{
    if ( isElement( parentEl ) )
    {
        return parentEl.className.match( new RegExp( "(^|\\s)"+className+"(\\s|$)" ) );
    }

    return false;
}

/*Object.prototype.getAllClassElements = function ( className )
{
    if ( isElement( this ) )
    {
        var parentEl = this;
        var elements = Array();
        var nodes = parentEl.getElementsByTagName('*');

        for ( var i = 0; i < nodes.length; i++ )
        {
            if ( nodes[i].hasClassName( className ) )
            {
                elements[elements.length] = nodes[i];
            }
        }

        if ( elements.length == 0 )
        {
            elements = false;
        }

        return elements;

    }

    return false
}*/


function getAllClassElements( parentEl, className )
{
    if ( !isElement( parentEl ) )
    {
        parentEl = document.body;
    }

    var elements = Array();
    var nodes = parentEl.getElementsByTagName('*');

    for ( var i = 0; i < nodes.length; i++ )
    {
        if ( hasClassName( nodes[i], className ) )
        {
            elements[elements.length] = nodes[i];
        }
    }

    if ( elements.length == 0 )
    {
        elements = false;
    }

    return elements;
}

/*Object.prototype.removeAllChildren = function( withParent )
{
    if ( isElement( this ) )
    {
        var parentEl = this;

        var children = parentEl.getElementsByTagName('*');

        for (var i = 0; i < children.length; i++)
        {
            parentEl.removeChild( children[i] );
        }

        if ( withParent )
        {
            parentEl.parentNode.removeChild( parentEl );
        }
    }
}*/

/** funkce isSet zjistí existenci nebo prázdnou hodnotu objektu
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isSet( obj )
{
    return ( typeof( obj ) != 'undefined' && obj != null );
}

/** funkce isSet zjistí prázdnou hodnotu objektu
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isEmpty( obj )
{
    return ( !isSet( obj ) || obj == '' || obj == 0 );
}

/** funkce isElement zjistí, zda je objekt element
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isElement( obj )
{
    if ( isSet( obj ) )
    {
        return isSet( obj.tagName );
    }
    else
    {
        return false;
    }
}

/** funkce isFunction zjistí, zda je objekt funkce
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isFunction( obj )
{
    return typeof( obj ) == 'function';
}

/** funkce isFunction zjistí, zda je objekt funkce
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isString( obj )
{
    return typeof( obj ) == 'string';
}

/** funkce isArray zjistí, zda je objekt pole
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isArray( obj )
{
    return ( typeof( obj ) == 'object' && obj instanceof Array  );
}

/** funkce isObjArray zjistí, zda je objekt pole objektu
 *
 *  @author SomeBW
 *  @param obj - objekt ke kontrole
 */
function isObjArray( obj )
{
    if ( isSet( obj ) )
    {
		try
		{
			for ( var i in obj )
			{
				return true;
			}
		}
		catch (e)
		{
		}
    }
    
    return false;
}

/** funkce inArray zjistí existenci objektu v poli
 *
 *  @author SomeBW
 *  @param item - objekt
 *  @param arrayObj - pole
 */
function inArray( item, arrayObj )
{
	if ( isObjArray( arrayObj ) )
    {
        for ( var i in arrayObj )
        {
            if ( arrayObj[i] == item )
            {
                return true;
            }
        }
    }
    else if ( isArray( arrayObj )  )
    {
        for ( var i = 0; i < arrayObj.length; i++ )
        {
            if ( arrayObj[i] == item )
            {
                return true;
            }
        }
    }

    return false;
}

function alertEr( val )
{
    if ( isObjArray( val ) )
    {
        var retVal = 'Array = ';
        var nesting = 0;
        getString( val );
    }
    else if ( isString( val ) )
    {
        retVal = val;
    }

    function getString( values )
    {
        nesting += 1;
        retVal += ' {'
        if ( isObjArray( values ) )
        {
            for ( var key in values )
            {
                retVal += '\n'+charRepeat('\t', nesting)+key;

                if (!isArray(values[key]))
                {
                    retVal += ' : \''+values[key]+'\'';
                }
                else
                {
                    getString(values[key]);
                }
            }
        }
        nesting -= 1;
        retVal += '\n'+charRepeat('\t', nesting)+'}';
    }
    alert(retVal);
}

function charRepeat( character, repeat )
{
    var retVal = '';

    for (var i = 0; i < repeat; i++)
    {
        retVal += character
    }

    return retVal;
}


