/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/

/*
PLEASE READ:
Absolutely everything in this script is SILLY.  I know this.  IE's rendering of certain pixels doesn't make sense, so neither does this code!
*/

var DD_belatedPNG = {
    ns: 'DD_belatedPNG',
    imgSize: {},
    delay: 10,
    nodesFixed: 0,
    createVmlNameSpace: function () { /* enable VML */
        if (document.namespaces && !document.namespaces[this.ns]) {
            document.namespaces.add(this.ns, 'urn:schemas-microsoft-com:vml');
        }
    },
    createVmlStyleSheet: function () { /* style VML, enable behaviors */
        /*
            Just in case lots of other developers have added
            lots of other stylesheets using document.createStyleSheet
            and hit the 31-limit mark, let's not use that method!
            further reading: http://msdn.microsoft.com/en-us/library/ms531194(VS.85).aspx
        */
        var screenStyleSheet, printStyleSheet;
        screenStyleSheet = document.createElement('style');
        screenStyleSheet.setAttribute('media', 'screen');
        document.documentElement.firstChild.insertBefore(screenStyleSheet, document.documentElement.firstChild.firstChild);
        if (screenStyleSheet.styleSheet) {
            var shapes = ['shape','rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group','textbox'];
            
            screenStyleSheet = screenStyleSheet.styleSheet;
            var ns = this.ns
            $.each(shapes, function()
            {
                screenStyleSheet.addRule(ns + '\\:' + this, "behavior: url(#default#VML)"); 
            });
            
            screenStyleSheet.addRule(this.ns + '\\:shape', 'position:absolute;');
            screenStyleSheet.addRule('img.' + this.ns + '_sizeFinder', 'behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;'); /* large negative top value for avoiding vertical scrollbars for large images, suggested by James O'Brien, http://www.thanatopsic.org/hendrik/ */
            this.screenStyleSheet = screenStyleSheet;
            
            /* Add a print-media stylesheet, for preventing VML artifacts from showing up in print (including preview). */
            /* Thanks to Rйmi Prйvost for automating this! */
            printStyleSheet = document.createElement('style');
            printStyleSheet.setAttribute('media', 'print');
            document.documentElement.firstChild.insertBefore(printStyleSheet, document.documentElement.firstChild.firstChild);
            printStyleSheet = printStyleSheet.styleSheet;
            
            $.each(shapes, function()
            {
                printStyleSheet.addRule(ns + '\\:' + this, "display: none !important;"); 
            });
            printStyleSheet.addRule('img.' + this.ns + '_sizeFinder', '{display: none !important;}');
        }
    },
    readPropertyChange: function () {
        var el, display, v;
        el = event.srcElement;
        if (!el.vmlInitiated) {
            return;
        }
        if (event.propertyName.search('background') != -1 || event.propertyName.search('border') != -1) {
            DD_belatedPNG.applyVML(el);
        }
        if (event.propertyName == 'style.display') {
            display = (el.currentStyle.display == 'none') ? 'none' : 'block';
            for (v in el.vml) {
                if (el.vml.hasOwnProperty(v)) {
                    el.vml[v].shape.style.display = display;
                }
            }
        }
        if (event.propertyName.search('filter') != -1) {
            DD_belatedPNG.vmlOpacity(el);
        }
    },
    vmlOpacity: function (el) {
        if (el.currentStyle.filter.search('lpha') != -1) {
            var trans = el.currentStyle.filter;
            trans = parseInt(trans.substring(trans.lastIndexOf('=')+1, trans.lastIndexOf(')')), 10)/100;
            el.vml.color.shape.style.filter = el.currentStyle.filter; /* complete guesswork */
            el.vml.image.fill.opacity = trans; /* complete guesswork */
        }
    },
    handlePseudoHover: function (el) {
        setTimeout(function () { /* wouldn't work as intended without setTimeout */
            DD_belatedPNG.applyVML(el);
        }, 1);
    },
    /**
    * This is the method to use in a document.
    * @param {String} selector - REQUIRED - a CSS selector, such as '#doc .container'
    **/
    fix: function (selector) {
        if (this.screenStyleSheet) {
            var selectors, i;
            selectors = selector.split(','); /* multiple selectors supported, no need for multiple calls to this anymore */
            for (i=0; i<selectors.length; i++) {
                this.screenStyleSheet.addRule(selectors[i], 'behavior:expression(DD_belatedPNG.fixPng(this))'); /* seems to execute the function without adding it to the stylesheet - interesting... */
            }
        }
    },
    applyVML: function (el) {
        el.runtimeStyle.cssText = '';
        this.vmlFill(el);
        this.vmlOffsets(el);
        this.vmlOpacity(el);
        if (el.isImg) {
            this.copyImageBorders(el);
        }
    },
    attachHandlers: function (el) {
        var self, handlers, handler, moreForAs, a, h;
        self = this;
        handlers = {resize: 'vmlOffsets', move: 'vmlOffsets'};
        if (el.nodeName == 'A') {
            moreForAs = {mouseleave: 'handlePseudoHover', mouseenter: 'handlePseudoHover', focus: 'handlePseudoHover', blur: 'handlePseudoHover'};
            for (a in moreForAs) {          
                if (moreForAs.hasOwnProperty(a)) {
                    handlers[a] = moreForAs[a];
                }
            }
        }
        if (el.nodeName == 'B') {
            moreForAs = {mouseleave: 'handlePseudoHover', mouseenter: 'handlePseudoHover', focus: 'handlePseudoHover', blur: 'handlePseudoHover'};
            for (a in moreForAs) {          
                if (moreForAs.hasOwnProperty(a)) {
                    handlers[a] = moreForAs[a];
                }
            }
        }
        for (h in handlers) {
            if (handlers.hasOwnProperty(h)) {
                handler = function () {
                    self[handlers[h]](el);
                };
                el.attachEvent('on' + h, handler);
            }
        }
        el.attachEvent('onpropertychange', this.readPropertyChange);
    },
    giveLayout: function (el) {
        el.style.zoom = 1;
        if (el.currentStyle.position == 'static') {
            el.style.position = 'relative';
        }
    },
    copyImageBorders: function (el) {
        var styles, s;
        styles = {'borderStyle':true, 'borderWidth':true, 'borderColor':true};
        for (s in styles) {
            if (styles.hasOwnProperty(s)) {
                el.vml.color.shape.style[s] = el.currentStyle[s];
            }
        }
    },
    vmlFill: function (el) {
        if (!el.currentStyle) {
            return;
        } else {
            var elStyle, noImg, lib, v, img, imgLoaded;
            elStyle = el.currentStyle;
        }
        for (v in el.vml) {
            if (el.vml.hasOwnProperty(v)) {
                el.vml[v].shape.style.zIndex = elStyle.zIndex;
            }
        }
        el.runtimeStyle.backgroundColor = '';
        el.runtimeStyle.backgroundImage = '';
        noImg = true;
        if (elStyle.backgroundImage != 'none' || el.isImg) {
            if (!el.isImg) {
                el.vmlBg = elStyle.backgroundImage;
                el.vmlBg = el.vmlBg.substr(5, el.vmlBg.lastIndexOf('")')-5);
            }
            else {
                el.vmlBg = el.src;
            }
            lib = this;
            if (!lib.imgSize[el.vmlBg]) { /* determine size of loaded image */
                img = document.createElement('img');
                lib.imgSize[el.vmlBg] = img;
                img.className = lib.ns + '_sizeFinder';
                img.runtimeStyle.cssText = 'behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;'; /* make sure to set behavior to none to prevent accidental matching of the helper elements! */
                imgLoaded = function () {
                    this.width = this.offsetWidth; /* weird cache-busting requirement! */
                    this.height = this.offsetHeight;
                    lib.vmlOffsets(el);
                };
                img.attachEvent('onload', imgLoaded);
                img.src = el.vmlBg;
                img.removeAttribute('width');
                img.removeAttribute('height');
                document.body.insertBefore(img, document.body.firstChild);
            }
            el.vml.image.fill.src = el.vmlBg;
            noImg = false;
        }
        el.vml.image.fill.on = !noImg;
        el.vml.image.fill.color = 'none';
        el.vml.color.shape.style.backgroundColor = elStyle.backgroundColor;
        el.runtimeStyle.backgroundImage = 'none';
        el.runtimeStyle.backgroundColor = 'transparent';
    },
    /* IE can't figure out what do when the offsetLeft and the clientLeft add up to 1, and the VML ends up getting fuzzy... so we have to push/enlarge things by 1 pixel and then clip off the excess */
    vmlOffsets: function (el) {
        var thisStyle, size, fudge, makeVisible, bg, bgR, dC, altC, b, c, v;
        thisStyle = el.currentStyle;
        size = {'W':el.clientWidth+1, 'H':el.clientHeight+1, 'w':this.imgSize[el.vmlBg].width, 'h':this.imgSize[el.vmlBg].height, 'L':el.offsetLeft, 'T':el.offsetTop, 'bLW':el.clientLeft, 'bTW':el.clientTop};
        fudge = (size.L + size.bLW == 1) ? 1 : 0;
        /* vml shape, left, top, width, height, origin */
        makeVisible = function (vml, l, t, w, h, o) {
            vml.coordsize = w+','+h;
            vml.coordorigin = o+','+o;
            vml.path = 'm0,0l'+w+',0l'+w+','+h+'l0,'+h+' xe';
            vml.style.width = w + 'px';
            vml.style.height = h + 'px';
            vml.style.left = l + 'px';
            vml.style.top = t + 'px';
        };
        makeVisible(el.vml.color.shape, (size.L + (el.isImg ? 0 : size.bLW)), (size.T + (el.isImg ? 0 : size.bTW)), (size.W-1), (size.H-1), 0);
        makeVisible(el.vml.image.shape, (size.L + size.bLW), (size.T + size.bTW), (size.W), (size.H), 1 );
        bg = {'X':0, 'Y':0};
        if (el.isImg) {
            bg.X = parseInt(thisStyle.paddingLeft, 10) + 1;
            bg.Y = parseInt(thisStyle.paddingTop, 10) + 1;
        }
        else {
            for (b in bg) {
                if (bg.hasOwnProperty(b)) {
                    this.figurePercentage(bg, size, b, thisStyle['backgroundPosition'+b]);
                }
            }
        }
        el.vml.image.fill.position = (bg.X/size.W) + ',' + (bg.Y/size.H);
        bgR = thisStyle.backgroundRepeat;
        dC = {'T':1, 'R':size.W+fudge, 'B':size.H, 'L':1+fudge}; /* these are defaults for repeat of any kind */
        altC = { 'X': {'b1': 'L', 'b2': 'R', 'd': 'W'}, 'Y': {'b1': 'T', 'b2': 'B', 'd': 'H'} };
        if (bgR != 'repeat' || el.isImg) {
            c = {'T':(bg.Y), 'R':(bg.X+size.w), 'B':(bg.Y+size.h), 'L':(bg.X)}; /* these are defaults for no-repeat - clips down to the image location */
            if (bgR.search('repeat-') != -1) { /* now let's revert to dC for repeat-x or repeat-y */
                v = bgR.split('repeat-')[1].toUpperCase();
                c[altC[v].b1] = 1;
                c[altC[v].b2] = size[altC[v].d];
            }
            if (c.B > size.H) {
                c.B = size.H;
            }
            el.vml.image.shape.style.clip = 'rect('+c.T+'px '+(c.R+fudge)+'px '+c.B+'px '+(c.L+fudge)+'px)';
        }
        else {
            el.vml.image.shape.style.clip = 'rect('+dC.T+'px '+dC.R+'px '+dC.B+'px '+dC.L+'px)';
        }
    },
    figurePercentage: function (bg, size, axis, position) {
        var horizontal, fraction;
        fraction = true;
        horizontal = (axis == 'X');
        switch(position) {
            case 'left':
            case 'top':
                bg[axis] = 0;
                break;
            case 'center':
                bg[axis] = 0.5;
                break;
            case 'right':
            case 'bottom':
                bg[axis] = 1;
                break;
            default:
                if (position.search('%') != -1) {
                    bg[axis] = parseInt(position, 10) / 100;
                }
                else {
                    fraction = false;
                }
        }
        bg[axis] = Math.ceil(  fraction ? ( (size[horizontal?'W': 'H'] * bg[axis]) - (size[horizontal?'w': 'h'] * bg[axis]) ) : parseInt(position, 10)  );
        if (bg[axis] % 2 === 0) {
            bg[axis]++;
        }
        return bg[axis];
    },
    fixPng: function (el) {
        el.style.behavior = 'none';
        var lib, els, nodeStr, v, e;
        if (el.nodeName == 'BODY' || el.nodeName == 'TD' || el.nodeName == 'TR') { /* elements not supported yet */
            return;
        }
        el.isImg = false;
        if (el.nodeName == 'IMG') {
            if(el.src.toLowerCase().search(/\.png$/) != -1) {
                el.isImg = true;
                el.style.visibility = 'hidden';
            }
            else {
                return;
            }
        }
        else if (el.currentStyle.backgroundImage.toLowerCase().search('.png') == -1) {
            return;
        }
        lib = DD_belatedPNG;
        el.vml = {color: {}, image: {}};
        els = {shape: {}, fill: {}};
        for (v in el.vml) {
            if (el.vml.hasOwnProperty(v)) {
                for (e in els) {
                    if (els.hasOwnProperty(e)) {
                        nodeStr = lib.ns + ':' + e;
                        el.vml[v][e] = document.createElement(nodeStr);
                    }
                }
                el.vml[v].shape.stroked = false;
                el.vml[v].shape.appendChild(el.vml[v].fill);
                el.parentNode.insertBefore(el.vml[v].shape, el);
            }
        }
        el.vml.image.shape.fillcolor = 'none'; /* Don't show blank white shapeangle when waiting for image to load. */
        el.vml.image.fill.type = 'tile'; /* Makes image show up. */
        el.vml.color.fill.on = false; /* Actually going to apply vml element's style.backgroundColor, so hide the whiteness. */
        lib.attachHandlers(el);
        lib.giveLayout(el);
        lib.giveLayout(el.offsetParent);
        el.vmlInitiated = true;
        lib.applyVML(el); /* Render! */
    }
};
try {
    document.execCommand("BackgroundImageCache", false, true); /* TredoSoft Multiple IE doesn't like this, so try{} it */
} catch(r) {}
DD_belatedPNG.createVmlNameSpace();
DD_belatedPNG.createVmlStyleSheet();

/**
 * jQuery.Preload - Multifunctional preloader
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
 * Dual licensed under MIT and GPL.
 * Date: 3/25/2009
 * @author Ariel Flesler
 * @version 1.0.8
 */
;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		guid: 1,
		global: {},
		regex: /^([0-9]+)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseInt(result[1], 10);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			if (!element.$timers) 
				element.$timers = {};
			
			if (!element.$timers[label])
				element.$timers[label] = {};
			
			fn.$timerID = fn.$timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.$timerID = fn.$timerID;
			
			if (!element.$timers[label][fn.$timerID]) 
				element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);
			
			if ( !this.global[label] )
				this.global[label] = [];
			this.global[label].push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = element.$timers, ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.$timerID ) {
							window.clearInterval(timers[label][fn.$timerID]);
							delete timers[label][fn.$timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					element.$timers = null;
			}
		}
	}
});

if (jQuery.browser.msie)
	jQuery(window).one("unload", function() {
		var global = jQuery.timer.global;
		for ( var label in global ) {
			var els = global[label], i = els.length;
			while ( --i )
				jQuery.timer.remove(els[i], label);
		}
	});

var initFunctions = new Array()
//==============================================================================
function initAll(space)
{
    for(i in initFunctions)
        initFunctions[i](space)
    
    if($.browser.msie && $.browser.version == '6.0')
        DD_belatedPNG.fix('a, b, i, li, div, img, h1')
}
//==============================================================================
$(document).ready(
    function()
    {
        try
        {
            document.execCommand("BackgroundImageCache", false, true)
        }
        catch(e){}
        
        initAll()
    }
)
//==============================================================================
function initHoverFix(space)
{
    $('.hover').hover(
        function(e)
        {
            //$this = $(getTarget(e))
            //$parent = $this.hasClass('.hover') ? $this : $this.parents('.hover').eq(0)
            //$('.popup', $parent).show()
            $('.popup', this).show()
        },
        function()
        {
            $('.popup', this).not('.cms-no').hide()
        }
    )
}
initFunctions.push(initHoverFix)
//==============================================================================
function initCommonUtils()
{
    if(!$('body').attr('initCommonUtils'))
    {
        $('._errors_ a').click(function()
            {
                var $ul = $(this).next('ul')
                if($ul.hasClass('showUl'))
                    $ul.removeClass('showUl')
                else
                    $ul.addClass('showUl')
                return false
            })
        $('._errors_ > ul, ._errors_ > ul > li > ul').css('display', 'block')
        $('body').attr('initCommonUtils', 1)
    }
}
initFunctions.push(initCommonUtils);
//==============================================================================

//==============================================================================
String.prototype.format = function() {
    var s = this,
        i = arguments.length;

    while (i--) {
        s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
    }
    return s;
}
//==============================================================================
function getValue(value)
{
    return 1 * (value + '').replace('px', '')
}
//==============================================================================
function gv(value)
{
    return Number(value)
}
//==============================================================================
function closeFancyBox()
{
    if($('#fancy_outer').css('display').toLowerCase() == 'block')
        $('#fancy_close').click()
}
//==============================================================================
function setRealWidth(item)
{
    var elem = $(item)
    if(elem.css('width') == 'auto')
        elem.css('width',
            elem.parent().width() -
            getValue(elem.css('padding-left')) -
            getValue(elem.css('padding-right')) -
            getValue(elem.css('border-left-width')) -
            getValue(elem.css('border-right-width')) +
            'px'
        )
}
//==============================================================================
function getFullHeight(elem)
{
    return elem.height() +
        getValue(elem.css("padding-bottom")) + getValue(elem.css("padding-top")) +
        getValue(elem.css("margin-bottom")) + getValue(elem.css("margin-top")) +
        getValue(elem.css("border-bottom-width")) +
        getValue(elem.css("border-top-width"))
}
//==============================================================================
function getFullWidth(elem)
{
    return elem.width() +
        getValue(elem.css("padding-left")) + getValue(elem.css("padding-right")) +
        getValue(elem.css("margin-left")) + getValue(elem.css("margin-right")) +
        getValue(elem.css("border-left-width")) +
        getValue(elem.css("border-right-width"))
}
//==============================================================================
function trim(str)
{
    str = str.replace(/^\s+/, '')
    for(var i = str.length - 1; i >= 0; i--)
    {
        if(/\S/.test(str.charAt(i)))
        {
            str = str.substring(0, i + 1)
            break
        }
    }
    return str
}
//==============================================================================
function processErrors(res)
{
    var e = ''
    var parts = res.split('<e>')
    res = parts[0]
    if(parts.length > 1)
    {
        parts = parts[1].split('</e>')
        e = jQuery.trim(parts[0])
        res += parts[1]
    }
    if(e.length > 0)
    {
        confirm(e)
//        $('#left_panel .errors').html(e)
    }
    return trim(res)
}
//==============================================================================
function getTarget(event)
{
    if(event.target)
        return event.target
    else
        return event.srcElement
}
//==============================================================================
/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr, level)
{
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0; j < level+1; j++) level_padding += "    ";
	
	if(typeof(arr) == 'object')
    { //Array/Hashes/Objects
		for(var item in arr)
        {
			var value = arr[item];
			
			if(typeof(value) == 'object')
            { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			}
            else
            {
                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
        }
	}
    else
    { //Stings/Chars/Numbers etc.
        dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
} 
//==============================================================================


// ColorBox v1.3.17.1 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
// Copyright (c) 2011 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(a,b,c){function bc(b){if(!T){O=b,_(a.extend(J,a.data(O,e))),x=a(O),P=0,J.rel!=="nofollow"&&(x=a("."+X).filter(function(){var b=a.data(this,e).rel||this.rel;return b===J.rel}),P=x.index(O),P===-1&&(x=x.add(O),P=x.length-1));if(!R){R=S=!0,q.show();if(J.returnFocus)try{O.blur(),a(O).one(k,function(){try{this.focus()}catch(a){}})}catch(c){}p.css({opacity:+J.opacity,cursor:J.overlayClose?"pointer":"auto"}).show(),J.w=Z(J.initialWidth,"x"),J.h=Z(J.initialHeight,"y"),W.position(0),n&&y.bind("resize."+o+" scroll."+o,function(){p.css({width:y.width(),height:y.height(),top:y.scrollTop(),left:y.scrollLeft()})}).trigger("resize."+o),ba(g,J.onOpen),I.add(C).hide(),H.html(J.close).show()}W.load(!0)}}function bb(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;J.slideshow&&x[1]?(d=function(){E.text(J.slideshowStop).unbind(c).bind(i,function(){if(P<x.length-1||J.loop)a=setTimeout(W.next,J.slideshowSpeed)}).bind(h,function(){clearTimeout(a)}).one(c+" "+j,e),q.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,J.slideshowSpeed)},e=function(){clearTimeout(a),E.text(J.slideshowStart).unbind([i,h,j,c].join(" ")).one(c,d),q.removeClass(b+"on").addClass(b+"off")},J.slideshowAuto?d():e()):q.removeClass(b+"off "+b+"on")}function ba(b,c){c&&c.call(O),a.event.trigger(b)}function _(b){for(var c in b)a.isFunction(b[c])&&c.substring(0,2)!=="on"&&(b[c]=b[c].call(O));b.rel=b.rel||O.rel||"nofollow",b.href=b.href||a(O).attr("href"),b.title=b.title||O.title,typeof b.href=="string"&&(b.href=a.trim(b.href))}function $(a){return J.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(a)}function Z(a,b){b=b==="x"?y.width():y.height();return typeof a=="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function Y(c,d){var e=b.createElement("div");c&&(e.id=f+c),e.style.cssText=d||"";return a(e)}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:!1},e="colorbox",f="cbox",g=f+"_open",h=f+"_load",i=f+"_complete",j=f+"_cleanup",k=f+"_closed",l=f+"_purge",m=a.browser.msie&&!a.support.opacity,n=m&&a.browser.version<7,o=f+"_IE6",p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J={},K,L,M,N,O,P,Q,R,S,T,U,V,W,X=f+"Element";W=a.fn[e]=a[e]=function(b,c){var f=this,g;if(!f[0]&&f.selector)return f;b=b||{},c&&(b.onComplete=c);if(!f[0]||f.selector===undefined)f=a("<a/>"),b.open=!0;f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b)),a(this).addClass(X)}),g=b.open,a.isFunction(g)&&(g=g.call(f)),g&&bc(f[0]);return f},W.init=function(){y=a(c),q=Y().attr({id:e,"class":m?f+(n?"IE6":"IE"):""}),p=Y("Overlay",n?"position:absolute":"").hide(),r=Y("Wrapper"),s=Y("Content").append(z=Y("LoadedContent","width:0; height:0; overflow:hidden"),B=Y("LoadingOverlay").add(Y("LoadingGraphic")),C=Y("Title"),D=Y("Current"),F=Y("Next"),G=Y("Previous"),E=Y("Slideshow").bind(g,bb),H=Y("Close")),r.append(Y().append(Y("TopLeft"),t=Y("TopCenter"),Y("TopRight")),Y(!1,"clear:left").append(u=Y("MiddleLeft"),s,v=Y("MiddleRight")),Y(!1,"clear:left").append(Y("BottomLeft"),w=Y("BottomCenter"),Y("BottomRight"))).children().children().css({"float":"left"}),A=Y(!1,"position:absolute; width:9999px; visibility:hidden; display:none"),a("body").prepend(p,q.append(r,A)),s.children().hover(function(){a(this).addClass("hover")},function(){a(this).removeClass("hover")}).addClass("hover"),K=t.height()+w.height()+s.outerHeight(!0)-s.height(),L=u.width()+v.width()+s.outerWidth(!0)-s.width(),M=z.outerHeight(!0),N=z.outerWidth(!0),q.css({"padding-bottom":K,"padding-right":L}).hide(),F.click(function(){W.next()}),G.click(function(){W.prev()}),H.click(function(){W.close()}),I=F.add(G).add(D).add(E),s.children().removeClass("hover"),p.click(function(){J.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;R&&J.escKey&&b===27&&(a.preventDefault(),W.close()),R&&J.arrowKey&&x[1]&&(b===37?(a.preventDefault(),G.click()):b===39&&(a.preventDefault(),F.click()))})},W.remove=function(){q.add(p).remove(),a("."+X).removeData(e).removeClass(X)},W.position=function(a,c){function g(a){t[0].style.width=w[0].style.width=s[0].style.width=a.style.width,B[0].style.height=B[1].style.height=s[0].style.height=u[0].style.height=v[0].style.height=a.style.height}var d,e=0,f=0;q.hide(),J.fixed&&!n?q.css({position:"fixed"}):(e=y.scrollTop(),f=y.scrollLeft(),q.css({position:"absolute"})),J.right!==!1?f+=Math.max(y.width()-J.w-N-L-Z(J.right,"x"),0):J.left!==!1?f+=Z(J.left,"x"):f+=Math.max(y.width()-J.w-N-L,0)/2,J.bottom!==!1?e+=Math.max(b.documentElement.clientHeight-J.h-M-K-Z(J.bottom,"y"),0):J.top!==!1?e+=Z(J.top,"y"):e+=Math.max(b.documentElement.clientHeight-J.h-M-K,0)/2,q.show(),d=q.width()===J.w+N&&q.height()===J.h+M?0:a,r[0].style.width=r[0].style.height="9999px",q.dequeue().animate({width:J.w+N,height:J.h+M,top:e,left:f},{duration:d,complete:function(){g(this),S=!1,r[0].style.width=J.w+N+L+"px",r[0].style.height=J.h+M+K+"px",c&&c()},step:function(){g(this)}})},W.resize=function(a){if(R){a=a||{},a.width&&(J.w=Z(a.width,"x")-N-L),a.innerWidth&&(J.w=Z(a.innerWidth,"x")),z.css({width:J.w}),a.height&&(J.h=Z(a.height,"y")-M-K),a.innerHeight&&(J.h=Z(a.innerHeight,"y"));if(!a.innerHeight&&!a.height){var b=z.wrapInner("<div style='overflow:auto'></div>").children();J.h=b.height(),b.replaceWith(b.children())}z.css({height:J.h}),W.position(J.transition==="none"?0:J.speed)}},W.prep=function(b){function h(b){W.position(b,function(){function o(){m&&q[0].style.removeAttribute("filter")}var b,d,g,h,j=x.length,k,n;!R||(n=function(){clearTimeout(V),B.hide(),ba(i,J.onComplete)},m&&Q&&z.fadeIn(100),C.html(J.title).add(z).show(),j>1?(typeof J.current=="string"&&D.html(J.current.replace(/\{current\}/,P+1).replace(/\{total\}/,j)).show(),F[J.loop||P<j-1?"show":"hide"]().html(J.next),G[J.loop||P?"show":"hide"]().html(J.previous),b=P?x[P-1]:x[j-1],g=P<j-1?x[P+1]:x[0],J.slideshow&&E.show(),J.preloading&&(h=a.data(g,e).href||g.href,d=a.data(b,e).href||b.href,h=a.isFunction(h)?h.call(g):h,d=a.isFunction(d)?d.call(b):d,$(h)&&(a("<img/>")[0].src=h),$(d)&&(a("<img/>")[0].src=d))):I.hide(),J.iframe?(k=a("<iframe/>").addClass(f+"Iframe")[0],J.fastIframe?n():a(k).one("load",n),k.name=f+ +(new Date),k.src=J.href,J.scrolling||(k.scrolling="no"),m&&(k.frameBorder=0,k.allowTransparency="true"),a(k).appendTo(z).one(l,function(){k.src="//about:blank"})):n(),J.transition==="fade"?q.fadeTo(c,1,o):o(),y.bind("resize."+f,function(){W.position(0)}))})}function g(){J.h=J.h||z.height(),J.h=J.mh&&J.mh<J.h?J.mh:J.h;return J.h}function d(){J.w=J.w||z.width(),J.w=J.mw&&J.mw<J.w?J.mw:J.w;return J.w}if(!!R){var c=J.transition==="none"?0:J.speed;y.unbind("resize."+f),z.remove(),z=Y("LoadedContent").html(b),z.hide().appendTo(A.show()).css({width:d(),overflow:J.scrolling?"auto":"hidden"}).css({height:g()}).prependTo(s),A.hide(),a(Q).css({"float":"none"}),n&&a("select").not(q.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(j,function(){this.style.visibility="inherit"}),J.transition==="fade"?q.fadeTo(c,0,function(){h(0)}):h(c)}},W.load=function(b){var c,d,g=W.prep;S=!0,Q=!1,O=x[P],b||_(a.extend(J,a.data(O,e))),ba(l),ba(h,J.onLoad),J.h=J.height?Z(J.height,"y")-M-K:J.innerHeight&&Z(J.innerHeight,"y"),J.w=J.width?Z(J.width,"x")-N-L:J.innerWidth&&Z(J.innerWidth,"x"),J.mw=J.w,J.mh=J.h,J.maxWidth&&(J.mw=Z(J.maxWidth,"x")-N-L,J.mw=J.w&&J.w<J.mw?J.w:J.mw),J.maxHeight&&(J.mh=Z(J.maxHeight,"y")-M-K,J.mh=J.h&&J.h<J.mh?J.h:J.mh),c=J.href,V=setTimeout(function(){B.show()},100),J.inline?(Y().hide().insertBefore(a(c)[0]).one(l,function(){a(this).replaceWith(z.children())}),g(a(c))):J.iframe?g(" "):J.html?g(J.html):$(c)?(a(Q=new Image).addClass(f+"Photo").error(function(){J.title=!1,g(Y("Error").text("This image could not be loaded"))}).load(function(){var a;Q.onload=null,J.scalePhotos&&(d=function(){Q.height-=Q.height*a,Q.width-=Q.width*a},J.mw&&Q.width>J.mw&&(a=(Q.width-J.mw)/Q.width,d()),J.mh&&Q.height>J.mh&&(a=(Q.height-J.mh)/Q.height,d())),J.h&&(Q.style.marginTop=Math.max(J.h-Q.height,0)/2+"px"),x[1]&&(P<x.length-1||J.loop)&&(Q.style.cursor="pointer",Q.onclick=function(){W.next()}),m&&(Q.style.msInterpolationMode="bicubic"),setTimeout(function(){g(Q)},1)}),setTimeout(function(){Q.src=c},1)):c&&A.load(c,J.data,function(b,c,d){g(c==="error"?Y("Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},W.next=function(){!S&&x[1]&&(P<x.length-1||J.loop)&&(P=P<x.length-1?P+1:0,W.load())},W.prev=function(){!S&&x[1]&&(P||J.loop)&&(P=P?P-1:x.length-1,W.load())},W.close=function(){R&&!T&&(T=!0,R=!1,ba(j,J.onCleanup),y.unbind("."+f+" ."+o),p.fadeTo(200,0),q.stop().fadeTo(300,0,function(){q.add(p).css({opacity:1,cursor:"auto"}).hide(),ba(l),z.remove(),setTimeout(function(){T=!1,ba(k,J.onClosed)},1)}))},W.element=function(){return a(O)},W.settings=d,U=function(a){a.button!==0&&typeof a.button!="undefined"||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),bc(this))},a.fn.delegate?a(b).delegate("."+X,"click",U):a("."+X).live("click",U),a(W.init)})(jQuery,document,this)

//==============================================================================
function colorboxPositionFix()
{
    var body_w = $('body').outerWidth()
    var html_w = $('html').width()
    if(html_w > body_w)
        $('#colorbox').css('margin-left',  (body_w - html_w) / 2 + 'px')
    else
        $('#colorbox').css('margin-left',  '0px')
}
//==============================================================================
function initColorbox(space)
{
    $('.colorbox_gallery').colorbox({
        'current': '{current} из {total}'
    })
    $(window).resize(colorboxPositionFix())
}
initFunctions.push(initColorbox);
//==============================================================================


eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(p($){$.M.L=p(6){9 6=$.N({a:s,b:s,d:P,e:4,z:2,q:4,w:3,h:2,f:[A,u,x],c:[A,u,x],g:[r,r,r],m:1},6);9 l=\'\';9 7=J.E(\'7\');D(7.v){7.k=(6.d+6.b)*6.q+(6.z-1)*6.b;7.o=(6.a*6.e+6.a)*6.h+(6.w-1)*6.a;9 8=7.v(\'R\');8.H=\'t(\'+6.f[0]+\', \'+6.f[1]+\', \'+6.f[2]+\', \'+0.1*6.m+\')\';n(9 i=0;i<6.q;i++){8.B(i*6.d+i*6.b,0,6.d,7.o)}n(9 i=0;i<6.h;i++){8.B(0,i*6.e*6.a+i*6.a,7.k,6.a*6.e)}8.X=1;8.T=\'t(\'+6.c[0]+\', \'+6.c[1]+\', \'+6.c[2]+\', \'+1*6.m+\')\';9 C=7.o/6.a;n(9 i=1;i<=C;i++){9 y=i*6.a-0.5;8.U();8.V(0,y);8.W(7.k,y);8.Y();8.12()}9 l=7.11(\'Z/10\')}S{}j.Q(p(){$(j).I(\'G\',\'F(\'+6.g[0]+\',\'+6.g[1]+\',\'+6.g[2]+\') \'+\'K(\'+l+\')\')});O j}})(13);',62,66,'||||||options|canvas|context|var|baseline|gutter|baselineColor|moduleWidth|moduleHeight|moduleColor|backgroundColor|beltPeriod||this|width|pattern|opacity|for|height|function|gutterPeriod|255|18|rgba|61|getContext|beltFactor|66||gutterFactor|225|fillRect|count|if|createElement|rgb|background|fillStyle|css|document|url|gridPattern|fn|extend|return|54|each|2d|else|strokeStyle|beginPath|moveTo|lineTo|lineWidth|closePath|image|png|toDataURL|stroke|jQuery'.split('|'),0,{}));

//==============================================================================
function initModularGrid()
{
    $('#_debug').append('<br/>').append(
        $('<a href="#">#</a>').click(
            function(){
                if(this.visible_grid)
                {
                    $('body').gridPattern({
                        opacity:        0
                    });
                    this.visible_grid = 0
                }
                else
                {
                    var $body = $('body')
                    var baseline = parseInt($body.css('line-height'))
                    var $cell = $('#modular-grid-cell')
                    var body_margin_left = $cell.css('margin-left')
                    
                    $body.gridPattern({
                        baseline:       baseline,
                        gutter:         parseInt($cell.css('margin-right')),
                        moduleWidth:    $cell.width(),
                        moduleHeight:   1,
                        gutterFactor:   1,
                        gutterPeriod:   1,
                        beltFactor:     1,
                        beltPeriod:     1,
                        moduleColor:    [225, 61, 66],
                        baselineColor:  [225, 61, 66],
                        backgroundColor:[255, 255, 255],
                        opacity:        1
                    }).css('background-position', body_margin_left + ' top');
                    this.visible_grid = 1
                }
            }
        )
    )
}
initFunctions.push(initModularGrid);

















//==============================================================================
function confirmDelete()
{
    return confirm("Вы подтверждаете удаление?")
}
//==============================================================================
function initConfirmDelete()
{
    if(!$('body').attr('initConfirmDelete'))
    {
	    $('.button.delete').each(function(i){
	        var $this = $(this)
            $this.bind('click.confirm_delete', function(e){
                if(confirmDelete())
                {
                    return true
                }
                else
                {
                    e.stopImmediatePropagation()
                    return false
                }
            })
	    })
	    $('body').attr('initConfirmDelete', 1)
	}
}
initFunctions.push(initConfirmDelete)
//==============================================================================
function initSet()
{
    //$('.set .set-group:even').css('float', 'right')
}
initFunctions.push(initSet)
//==============================================================================
function initZebra()
{
    $('.zebra').children(':visible:even').addClass('even')
    $('.zebra').children(':visible:odd').addClass('odd')
}
initFunctions.push(initZebra)
//==============================================================================
function initDatePicker()
{
    if($.datepicker)
        $('input.date').datepicker({ dateFormat: 'yy-mm-dd' })
}
initFunctions.push(initDatePicker)
//==============================================================================
function initSelectWithChild()
{
    if(!$('body').attr('initSelectWithChild'))
    {
        $('select[rel]').each(function(i)
        {
            var $this = $(this)
            var rel = $this.attr('rel')
            var child = $('.f_' + rel + ' select')
            var child_node = child.clone()
            
            $(this).bind('change.select_with_child', function(e)
            {
                var $this = $(getTarget(e))
                var selected = $('option[selected]', $this)
                child.html('')
                
                $('option', child_node).each(function(i)
                {
                    var $this = $(this)
                    if($this.attr('rel') == selected.text() || i == 0)
                    {
                        $(this).clone(true).appendTo(child)
                    }
                })
                var delta = 2
                if($.browser.opera)
                    delta = 4
                child.width($this.width() + delta)
             }).trigger('change')
        })
        $('body').attr('initSelectWithChild', 1)
    }
}
initFunctions.push(initSelectWithChild)
//==============================================================================
function initBlockEditor()
{
    $('form .complex_field').each(function(i)
    {
        var $complex_field = $(this)
        var field = $complex_field.attr('rel')
        $('.icons .new.block-text', $complex_field).unbind('click.block_editor').
        bind('click.block_editor',
	        function(e)
	        {
                var $target = $(getTarget(e))
	            var block = $target.parents('label').eq(0)
                var new_block = $('label.f_.block-text', $complex_field).eq(0).
                    clone(true)
                new_block.removeClass('f_')
                $('textarea', new_block).attr('name', field + '[][BlockText]')
	            block.after(new_block)
                if(initTinyMCE)initTinyMCE()
	            return false
	        }
        )
        $('.icons .new.block-item', $complex_field).unbind('click.block_editor').
        bind('click.block_editor',
            function(e)
            {
                var $target = $(getTarget(e))
                var block = $target.parents('label').eq(0)
                var new_block = $('label.f_.block-item', $complex_field).eq(0).
                    clone(true)
                new_block.removeClass('f_')
                $('select', new_block).attr('name', field + '[][BlockItem]')
                block.after(new_block)
                return false
            }
        )
        $('.icons .delete', $complex_field).unbind('click.block_editor').
        bind('click.block_editor',
            function(e)
            {
                var $target = $(getTarget(e))
                var block = $target.parents('label').eq(0)
                block.remove()
                return false
            }
        )
        $('.icons .up', $complex_field).unbind('click.block_editor').
        bind('click.block_editor',
            function(e)
            {
                var $target = $(getTarget(e))
                var block = $target.parents('label').eq(0)
                var list = $('label', $complex_field)
                var index = list.index(block)
                if(index > 2)
                {
                    block.insertBefore(list.eq(index - 1))
                }
                return false
            }
        )
        $('.icons .down', $complex_field).unbind('click.block_editor').
        bind('click.block_editor',
            function(e)
            {
                var $target = $(getTarget(e))
                var block = $target.parents('label').eq(0)
                var list = $('label', $complex_field)
                var index = list.index(block)
                if(index < list.length)
                {
                    block.insertAfter(list.eq(index + 1))
                }
                return false
            }
        )
    })
}
initFunctions.push(initBlockEditor)
//==============================================================================
function initChildrenEditor()
{
    $('form .children').each(function(i)
    {
        var $mr_field = $(this)
        var field = $mr_field.attr('rel')
        $('.icons .new.block-item', $mr_field).unbind('click.mr_editor').
        bind('click.mr_editor',
            function(e)
            {
                var len = $('.child', $mr_field).length
                var block = $('.child', $mr_field).eq(0).clone(true)
                var html = block.html()
                html = html.replace(/\[0\]/gi, '[' + len + ']')
                block.html(html)
                block.removeClass('hidden')
                $mr_field.append(block)
                initChildrenEditor()
                return false
            }
        )
        $('.icons .delete', $mr_field).unbind('click.mr_editor').
        bind('click.mr_editor',
            function(e)
            {
                var $target = $(getTarget(e))
                var block = $target.parents('.child').eq(0)
                block.remove()
                return false
            }
        )
    })
}
initFunctions.push(initChildrenEditor);
//==============================================================================

















//==============================================================================
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
//==============================================================================
function initPreviewMakerCookie(space)
{
    if(document.cookie.indexOf('min_device_width') == -1)
    {
        setCookie("min_device_width", screen.width, "Mon, 01-Jan-2050 00:00:00 GMT", "/");
    }
}
initFunctions.push(initPreviewMakerCookie);





//==============================================================================
function jquerySlideShow_changeSlide()
{
    var slide_url = $('.jquery_slide_show img').attr('src')
    if(slide_url)
    {
        jquerySlideShow_showSlide(slide_url)
    }
    var cur_slide = slide_url ? slide_url.split('/').pop() : ''
    var params = '&command=GET_SLIDE&cur_slide=' + escape(cur_slide) + '&ajax=1'
    $.get(document.location + params,
        function(data)
        {
            jquerySlideShow_loadSlide(data)
        }
    )
}
//==============================================================================
function jquerySlideShow_showSlide(slide_url)
{
    var bg = $('.jquery_slide_show').css('background-image')
    if(bg.indexOf(slide_url) >= 0)
    {
        return
    }
    
    $('.jquery_slide_show').animate({opacity: 0}, 1000,
        function()
        {
            $('.jquery_slide_show').
                css('background-image', 'url("' + slide_url + '")').
                animate({opacity: 1}, 1000)
        }
    )
}
//==============================================================================
function jquerySlideShow_loadSlide(slide_url)
{
    $('.jquery_slide_show img').attr('src', slide_url)
}
//==============================================================================
function initJquerySlideShow(space)
{
    if(!self.initJquerySlideShowDone)
    {
        jquerySlideShow_changeSlide()
	    
	    $('.jquery_slide_show').append('<img/>')
	        .oneTime(1000,
                function(i)
                {
                    jquerySlideShow_changeSlide()
                }
            )
		    .everyTime(5000,
		        function(i)
		        {
                    jquerySlideShow_changeSlide()
		        }
		    )
        self.initJquerySlideShowDone = true
    }
}
initFunctions.push(initJquerySlideShow)
//==============================================================================








//==============================================================================
function initCagalogueElementView()
{
    $('ul.elements a').colorbox({
        current     : '{current} / {total}',
        onComplete  : function()
        {
            var $full_photo = $('.full-photo')
            $('ul.element-photos img').click(
            function()
            {
                var $this = $(this)
                var buf = $this.attr('src').split('/')
                var new_file_name = buf.pop()
                var new_folder = buf.pop()
                
                var buf = $full_photo.attr('src').split('/')
                buf.pop()
                buf.pop()
                buf.push(new_folder)
                buf.push(new_file_name)
                $full_photo.attr('src', buf.join('/'))
            })
        }
    })
}
//==============================================================================
function initCatalogue()
{
    if(!$('body').attr('initCatalogue'))
    {
        initCagalogueElementView()
        
        
        
        
        
        $('body').attr('initCatalogue', 1)
    }
}
initFunctions.push(initCatalogue);

/*
function initComCat(space)
{
    if(!$('body').attr('initComCat'))
    {
	    $('.producer h2.title').each(
	        function(i)
	        {
	            var text = $(this).html()
	            var words = text.split(' ')
	            $(this).html('<span>' + words.join('</span> <span>') + '</span>')
	        }
	    )
	    
	    $('.scrolling-list').each(function(){
	        var item = $(this)
	        var list = $('ul', item)
	        if(list.height() > item.height())
	        {
	            $('.list-up, .list-down', item).append('<sub></sub><sup></sup>').
	                show()
		        $('.list-up', item).click(listUp)
		        $('.list-down', item).click(listDown)
	        }
	    })
	    
	    initPhotoZoom()
	    initPrevNext()
	    
	    $('body').attr('initComCat', 1)
    }
}
initFunctions.push(initComCat)
//==============================================================================
function listDown(event)
{
    var target = getTarget(event)
    var container = $(target).parent().parent()
    var list = $('ul', container)
    var offset = $('li', list).height()
    var list_top = list.attr('offsetTop')
    if(list_top + list.height() > container.height())
    {
        list.css('top', (list_top - offset))
    }
}
//==============================================================================
function listUp(event)
{
    var target = getTarget(event)
    var container = $(target).parent().parent()
    var list = $('ul', container)
    var offset = $('li', list).height()
    var list_top = list.attr('offsetTop')
    if(list_top < 0)
    {
        list.css('top', (list_top + offset) + 'px')
    }
}
//==============================================================================
function initPhotoZoom()
{
    $('.element .ph').append('<div class="symbol popup"></div>')
    $('.element .ph div').bind('click.complex_catalogue', function(e){
        $('.element .ph').css('background-position', 'center center')
        
        $this = $(getTarget(e))
        $parent = $this.parents('.ph').eq(0)
        
        if(!$this.hasClass('top-ph'))
        {
            $this = $('.top-ph', $parent)
        }
        
        dst_opacity = Number($this.css('opacity')) == 0 ? 1 : 0;
        dst_bg_left = Number($this.css('opacity')) == 0 ? '-31px' : '0px';
        $this.animate({opacity:dst_opacity}, 1000)
        
        $('.symbol', $parent).css('background-position', dst_bg_left + ' 0px')
    }).css('opacity', 1).show()
    $('.element .ph .symbol').hide()
}
//==============================================================================
function initPrevNext()
{
    $('.element .prev').bind('click.comcat_prev', function(e){
    
    })
    $('.element .prev').bind('click.comcat_prev', function(e){
    
    })
}
//==============================================================================
*/











//==============================================================================
function eraseCookie(name) {
    createCookie(name,"",-1);
}
//==============================================================================
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
//==============================================================================
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
//==============================================================================
function initAllureColorbox(space)
{
    $('.c-box').colorbox({
        close: '&times;',
        current: '{current} / {total}'
    })
}
initFunctions.push(initAllureColorbox);
//==============================================================================
function initChangeDesignVersion(space)
{
    var $html = $('html')
    if(space)
        var $objects = $('.change_version', space)
    else
        var $objects = $('.change_version')
    
    var change_design = function()
    {
        if($html.hasClass('LV'))
        {
            $html.removeClass('LV')
            eraseCookie('LV')
        }
        else
        {
            $html.addClass('LV')
            createCookie('LV', '1', 100)
        }
        return false
    }
    
    $objects.click(change_design)
    
    if(document.cookie.indexOf('LVset') == -1)
    {
        $html.addClass('LV')
        createCookie('LV', '1', 100)
        createCookie('LVset', '1', 100)
    }
}
initFunctions.push(initChangeDesignVersion);
