function setCookie (name, value, expires, path, domain, secure) 
{
	
	 if (expires)
	 {
	 	var d = new Date(expires);
		utc = d.toUTCString();
	 }
	 
     document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + utc : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
		
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

   var NicePopup = NicePopup || {};
            NicePopup.Mask = new Class({
                Implements: [Options, Events],

                elements: {},
                fx: {},
                isSupplementary: false,
                state: 'hide',
                positionFunction: null,
                hiddenElements: [],
                availableTransitions: ['slideup', 'slidedown', 'slideleft', 'slideright', 'slidecenter', 'shuttervertical', 'shutterhorizontal', 'none', 'slideup+fade', 'slidedown+fade', 'slideleft+fade', 'slideright+fade', 'slidecenter+fade', 'shuttervertical+fade', 'shutterhorizontal+fade', 'fade', 'none+fade', 'random'],

                'options': {
                    'enable': true,
                    'color': '#000',
                    'opacity': 0.5,
                    'styles': {
                        'position': 'fixed',
                        'top': 0,
                        'left': 0
                    },
                    'transitions': {
                        'show': 'random',
                        'hide': 'random',
                        'duration': 300,
                        'equation': 'expo:out'
                    }
                },

                initialize: function (options) {
                    this.setOptions(options);

                    if (this.options.enable === false) return false;
                    
                    this.isIE6 = Browser.ie6;
                    this.buildHTML();
                    this.position('init');
                },

                buildHTML: function () {
                    this.options.styles.position = this.isIE6 ? 'absolute' : this.options.styles.position;
                    this.elements.mask = new Element('DIV', {
                        'styles': Object.merge(this.options.styles, {
                            'background-color': this.options.color,
                            'opacity': this.options.opacity,
                            'display': 'none'
                        })
                    }).inject(document.id(document.body), 'inside');
                   
                    this.fx.mask = new Fx.Morph(this.elements.mask, {
                        'duration': this.options.transitions.duration,
                        'transition': this.options.transitions.equation,
                        'link': 'cancel'
                    });
                    
                    if (this.options.transitions.show.test('^shuttervertical|shutterhorizontal|random', 'i') || this.options.transitions.hide.test('^shuttervertical|shutterhorizontal|random', 'i')) {
                        this.isSupplementary = true;
                        this.supplementaryHTML();
                    }
                },
                
                supplementaryHTML: function () {
                    this.elements.supplement = this.elements.mask.clone(false).inject(document.id(document.body), 'inside');
                    this.fx.supplement = new Fx.Morph(this.elements.supplement, {
                        'duration': this.options.transitions.duration,
                        'transition': this.options.transitions.equation,
                        'link': 'cancel',
                        'onCancel': function () {
                            this.elements.supplement.setStyle('display', 'none');
                        }.bind(this),
                        'onComplete': function () {
                            this.elements.supplement.setStyle('display', 'none');
                        }.bind(this)
                    });                    
                },

                position: function (action) {
                    var size = document.getSize();
                    var scroll = document.getScroll();
                    var scrollSize = document.getScrollSize();

                    this.elements.mask.store('size', {
                        'x': size.x,
                        'y': size.y,
                        'sx': scroll.x,
                        'sy': scroll.y,
                        'ssx': scrollSize.x,
                        'ssy': scrollSize.y
                    });
                    
                    // Stop here if only initialize action
                    if (action == 'init') {
                        this.isSupplementary && this.elements.supplement.store('size', this.elements.mask.retrieve('size'));
                        return false;
                    }

                    if (this.isSupplementary) {
                        this.elements.supplement.store('size', size);
                        this.elements.supplement.setStyle('display', 'none');
                    }
               
                    this.elements.mask.setStyles({
                        'width': this.state == 'show' ? (this.isIE6 ? scrollSize.x : size.x) : 0,
                        'height': this.state == 'show' ? (this.isIE6 ? scrollSize.y : size.y) : 0,
                        'top': 0,
                        'left': 0,
                        'opacity': this.state == 'show' ? this.options.opacity : 0
                    });
                    // cancel Fx transition
                    this.fx.mask && this.fx.mask.cancel();
                    this.fx.supplement && this.fx.supplement.cancel();
                },

                display: function (action, display) {
                    this.isIE6 && this.position('init');
                    var size = this.elements.mask.retrieve('size');
                    var scrollSize = document.getScrollSize();
                 
                    if (this.isIE6) {
                        this.elements.mask.setStyles({
                            'top': size.sy,
                            'left': size.sx
                        });
                    }
                    
                    // Use random effect
                    if (action.test('random', 'i')) {
                        action = this.availableTransitions.slice(0,-1).getRandom();
                    } 

                    var actionMethod = action.toLowerCase().match(/^(\w+)\s?\+\s?(\w+)$/) || [null, action.toLowerCase(), null];
                    
                    var opacity = {};
                    switch (actionMethod[2] + display.capitalize()) {
                        case 'fadeShow':
                            this.fx.mask.set({'opacity': 0});
                            this.isSupplementary && this.fx.supplement.set({'opacity': 0});
                            opacity = {'opacity': this.options.opacity};
                            break;
                        case 'fadeHide':
                            this.fx.mask.set({'opacity': this.options.opacity});
                            this.isSupplementary && this.fx.supplement.set({'opacity': this.options.opacity});
                            opacity = {'opacity': 0};
                            break;
                    }
                    
                    if (display == 'show') {
                        this.elements.mask.setStyle('display', 'block');
                        this.isSupplementary && this.elements.supplement.setStyles({'display': 'block', 'left': this.isIE6 ? this.elements.mask.retrieve('size').sx : 0, 'top': this.isIE6 ? this.elements.mask.retrieve('size').sy : 0, 'width': 0, 'height': 0, 'opacity': this.options.opacity});
                    }
                    
                    this.isSupplementary && this.fx.supplement.cancel();
        
                    var chainFn = function () {
                        this.state = display;
                        if (display == 'show') {  
                            this.elements.mask.setStyles({
                                'width': this.elements.mask.retrieve('size')[this.isIE6 ? 'ssx' : 'x'],
                                'height': this.elements.mask.retrieve('size')[this.isIE6 ? 'ssy' : 'y'],
                                'top': 0,
                                'left': 0
                            });
                            this.isSupplementary && this.elements.supplement.setStyle('display', 'none');
                        } else {
                            this.elements.mask.setStyles({
                                'display': 'none',
                                'width': 0,
                                'height': 0,
                                'top': this.isIE6 ? this.elements.mask.retrieve('size').sy : 0,
                                'left': this.isIE6 ? this.elements.mask.retrieve('size').sx : 0,
                                'opacity': this.options.opacity
                            });
                            this.isIE6 && this.toggleDangerElements('show');
                        }

                        this.fireEvent(this.state.toLowerCase() + 'Complete', display);
                    }.bind(this)
        
                    this.animation(display, actionMethod[1], size, opacity, chainFn).chain(chainFn);

                },
                
                animation: function (display, transition, size, opacity, chainFn) {
                    switch(transition + display.capitalize()) {
                       
                        case 'slideupShow': 
                            return this.fx.mask.set({'width': size.x}).start(Object.merge({'height': [size.y]}, opacity));
                            break;   

                        case 'slidedownShow': 
                            return this.fx.mask.set({'width': size.x}).start(Object.merge({'height': [0, size.y], 'top': [size.y + (this.isIE6 ? size.sy : 0), this.isIE6 ? size.sy : 0]}, opacity));
                            break;  

                        case 'slideleftShow': 
                            return this.fx.mask.set({'height': size.y}).start(Object.merge({'width': [0, size.x]}, opacity)); 
                            break;  

                        case 'sliderightShow': 
                            return this.fx.mask.set({'height': size.y}).start(Object.merge({'width': [0, size.x], 'left': [size.x, this.isIE6 ? size.sx : 0]}, opacity));
                            break;  

                        case 'slidecenterShow': 
                            return this.fx.mask.set({'top': (size.y / 2) + (this.isIE6 ? size.sy : 0), 'left': (size.x / 2) + (this.isIE6 ? size.sx : 0)}).start(Object.merge({'top': this.isIE6 ? size.sy : 0, 'left': this.isIE6 ? size.sx : 0, 'width': [0, size.x], 'height': [0, size.y] }, opacity));
                            break;  
                    
                        case 'shutterhorizontalShow':
                            this.fx.supplement.set({'width': size.x, 'top': size.y + (this.isIE6 ? size.sy : 0)}).start(Object.merge({'display': 'block', 'top': (size.y /2) + (this.isIE6 ? size.sy : 0), 'height': [0, (size.y / 2)]}, opacity));
                            return this.fx.mask.set({'width': size.x}).start(Object.merge({'height': [0, size.y / 2]}, opacity));
                            break;
                            
                        case 'shutterverticalShow':
                            this.fx.supplement.set({'height': size.y, 'left': size.x}).start(Object.merge({'display': 'block', 'left': (size.x / 2) + (this.isIE6 ? size.sx : 0), 'width': [0, size.x / 2]}, opacity));
                            return this.fx.mask.set({'height': size.y}).start(Object.merge({'width': [0, size.x / 2]}, opacity));
                            break;
                            
                        case 'fadeShow':
                            return this.fx.mask.set({'width': size.x, 'height': size.y, 'opacity': 0}).start(Object.merge({'opacity': this.options.opacity}, opacity));
                            break;  
                        
                        case 'noneShow': 
                            this.fx.mask.set(Object.merge({'width': size.x, 'height': size.y}, opacity)); 
                            chainFn.call(this);
                            break;  
                            
                        case 'slideupHide':  
                            return this.fx.mask.set({'width': size.x}).start(Object.merge({'height': [size.y, 0]}, opacity));   
                            break; 

                        case 'slidedownHide':  
                            return this.fx.mask.set({'width': size.x}).start(Object.merge({'top': [this.isIE6 ? size.sy : 0, size.y + (this.isIE6 ? size.sy : 0)], 'height': [size.y, 0]}, opacity));
                            break;

                        case 'slideleftHide':  
                            return this.fx.mask.set({'height': size.y}).start(Object.merge({'width': [size.x, 0]}, opacity));   
                            break; 

                        case 'sliderightHide':  
                            return this.fx.mask.set({'height': size.y}).start(Object.merge({'width': [size.x, 0], 'left': [this.isIE6 ? size.sx : 0, size.x]}, opacity));
                            break;

                        case 'slidecenterHide': 
                            return this.fx.mask.set({'width': size.x, 'height': size.y}).start(Object.merge({'top': [this.isIE6 ? size.sy : 0, (size.y / 2) + (this.isIE6 ? size.sy : 0)], 'left': [this.isIE6 ? size.sx : 0, (size.x / 2) + (this.isIE6 ? size.sx : 0)], 'width': 0, 'height': 0 }, opacity));
                            break;
                            
                        case 'shutterhorizontalHide':
                            this.fx.supplement.set({'width': size.x, 'left': 0, 'top': (size.y / 2) + (this.isIE6 ? size.sy : 0)}).start(Object.merge({'display': 'block', 'height': [(size.y / 2), 0], 'top': size.y + (this.isIE6 ? size.sy : 0)}, opacity));
                            return this.fx.mask.set({'width': size.x}).start(Object.merge({'height': [size.y / 2, 0]}, opacity));
                            break;
                            
                        case 'shutterverticalHide':
                            this.fx.supplement.set({'height': size.y, 'top': this.isIE6 ? size.sy : 0}).start(Object.merge({'display': 'block', 'left': [size.x / 2, size.x], 'width': [size.x / 2, 0]}, opacity));
                            return this.fx.mask.set({'height': size.y}).start(Object.merge({'width': [size.x / 2, 0]}, opacity));
                            break;
                            
                        case 'fadeHide': 
                            return this.fx.mask.set({'width': size.x, 'height': size.y, 'opacity': this.options.opacity}).start(Object.merge({'opacity': 0}, opacity)); 
                            break
                        
                        case 'noneHide':  
                            this.fx.mask.set(Object.merge({'width': 0, 'height': 0}, opacity));
                            chainFn.call(this);
                            break;
                    }
                    return this.fx.mask;
                },
                
                isTransitionsAvailable: function (transition) {
                    if (this.availableTransitions.indexOf(transition.replace(/\s+/g, '').toLowerCase()) == -1) {
                        throw new Error('You use a wrong transition effect');  
                        return false;
                    }
                    return true;
                },

                show: function () {
                    if (this.isTransitionsAvailable(this.options.transitions.show) && this.options.enable) {
                        this.isIE6 && this.toggleDangerElements('hide');
                        this.state = 'show';
                        this.fireEvent(this.state);
                        this.display(this.options.transitions.show, this.state);
                        
                        this.positionFunction = this.position.bind(this);
                        window.addEvent('resize', this.positionFunction);
                        this.isIE6 && window.addEvent('scroll', this.positionFunction);
                    }
                },

                hide: function () {
                    if (this.isTransitionsAvailable(this.options.transitions.hide) && this.options.enable) {
                        this.state = 'hide';
                        this.fireEvent(this.state);
                        this.display(this.options.transitions.hide, this.state);
                        
                        if (typeOf(this.positionFunction) == 'function') {
                            window.removeEvent('resize', this.positionFunction);
                            this.isIE6 && window.removeEvent('scroll', this.positionFunction);
                        }
                    } else {
                        this.isIE6 && this.toggleDangerElements('show');
                    }
                },
                
                toggleDangerElements: function (action) {
                    switch (action) {
                        case 'show':
                            this.hiddenElements.each(function (object) {
                                typeOf(object.element) == 'element' && object.element.setStyle('visibility', object.style);
                            }, this)
                            break;
                        case 'hide':
                            document.getElements('select', 'object').each(function (element) {
                                this.hiddenElements.push({'element': element, 'style': element.getStyle('visibility')});
                                element.setStyle('visibility', 'hidden');
                            }, this);
                            break
                    }
                }
            });
            
            
            NicePopup.Window = new Class({
                Implements: [Options, Events],

                elements: {},
                scrollDelta: {},
                fx: {},
                mask: null,
                
                scrollDirect: {
                    'last': {'x': 0, 'y': 0},
                    'current': {'x': 0, 'y': 0}
                },
                functionEvents: {},
                extendenLand: {'width': 0, 'height': 0},
                               
                availableTransitions: ['slideup', 'slidedown', 'slideleft', 'slideright', 'slidecenter', 'fade', 'none', 'random'],
               
                'options': {
                    'enable': true,
                    'classes': {'container': 'nicePopup', 'close': 'nicePopupClose', 'content': 'nicePopupContent'},
                    'width': '300px',
                    'height': '300px',
                    'data': '<div align=center>Simple hello text</div><br />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
                    'close': {
                        'position': 'left',
                        'escape': true
                    },
                    'resize': {
                        'method': 'scroll',
                        'padding': 15
                    },
                    
                    'transitions': {
                        'show': 'random',
                        'hide': 'random',
                        'duration': 'short',
                        'equation': 'cubic:out',
                        'opacity': {'show': 1, 'hide': 0},
                        'padding': 50
                    }
                },

                initialize: function (options) {
                    this.setOptions(options);

                    if (this.options.enable === false) return false;
                    this.size = {'width': this.options.width.toInt(), 'height': this.options.height.toInt()};
                    this.isIE6 = Browser.ie6;
                    
                    window.addEvent('domready', function() {
                        this.scrollDelta = document.getScroll();
                        this.scrollSize = document.getScrollSize();
                    }.bind(this));
                    
                    this.buildHTML();
                },

                buildHTML: function () {
                    this.elements.container = new Element('DIV', {
                        'class': this.options.classes.container,
                        'styles': {
                            'position': this.isIE6 ? 'absolute': 'fixed',
                            'width': this.size.width,
                            'height': this.size.height,
                            'display': 'none',
                            'visibility': 'hidden',
                            'z-index': 9999
                        }
                    }).inject(document.id(document.body));
                    
                    this.elements.close = new Element('DIV', {
                        'class': this.options.classes.close + ' ' + this.options.close.position,
                        'styles': {
                            'position': 'absolute',
                            'cursor': 'pointer'
                        },
                        'events': {
                            'click': this.hide.bind(this)
                        }
                    }).inject(this.elements.container);

                    // Fix png image on close
                    if (this.isIE6 && this.elements.close.getStyle('background-image') != 'none') {
                        var bgURL = this.elements.close.getStyle('background-image').match(/url\((?:"|')(.*?)(?:"|')\)/);
                        bgURL !== null && bgURL[1].test(/\.png$/) && this.elements.close.setStyles({
                            'background-image': 'none',
                            'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bgURL[1] + "', sizingMethod=crop)"
                        });
                    } 
                  
                    this.elements.content = new Element('DIV', {
                        'html': this.options.data,
                        'class': this.options.classes.content
                    }).inject(this.elements.container);
                    
                    this.fx.popap = new Fx.Morph(this.elements.container, {
                        'duration': this.options.transitions.duration,
                        'transition': this.options.transitions.equation,
                        'link': 'cancel'
                    });
                    
                    this.fx.content = new Fx.Tween(this.elements.content, {
                        'duration': 'short',
                        'link': 'cancel'
                    });
                },
                
                center: function (nodelta) {
                    var size = window.getSize();
                    var scroll = document.getScroll();
                    switch (this.options.resize.method) {
                        case 'fit':
                            var styles = {};
                            if (size.x < (this.size.width + this.extendenLand.width) + (this.options.resize.padding * 2)) {
                                styles = Object.merge(styles, {
                                    'width': size.x - this.extendenLand.width - (this.options.resize.padding * 2),
                                    'height': this.size.height,
                                    'left': this.options.resize.padding + (this.isIE6 ? scroll.x : 0)});
                            } else {
                                styles = Object.merge(styles, {
                                    'width': this.size.width, 
                                    'height': this.size.height,
                                    'left': (size.x / 2 + (this.isIE6 ? scroll.x : 0)) - this.options.width.toInt() / 2});
                            }

                            if (size.y < (this.size.height + this.extendenLand.height) + (this.options.resize.padding * 2)) {
                                styles = Object.merge(styles, {
                                    'height': size.y - this.extendenLand.width -  (this.options.resize.padding * 2), 
                                    'top': this.options.resize.padding + (this.isIE6 ? scroll.y : 0)});
                            } else  {
                                styles = Object.merge(styles, {
                                    'height': this.size.height, 
                                    'top': (size.y / 2 + (this.isIE6 ? scroll.y : 0)) - this.size.height / 2});
                            }
                            this.fx.popap.set(styles);
                            break;
                        case 'scroll':
                            var styles = {'width': this.size.width, 'height': this.size.height};
   
                            if (size.x < this.size.width + this.extendenLand.width + (this.options.resize.padding * 2)) {
                                styles = Object.merge(styles,{'left': this.options.resize.padding + (this.isIE6 ? scroll.x : 0)});
                            } else {
                                styles = Object.merge(styles,{'left': (size.x / 2 + (this.isIE6 ? scroll.x : 0)) - this.options.width.toInt() / 2});
                        
                            }
                            if (size.y < this.size.height + this.extendenLand.height + (this.options.resize.padding * 2)) {
                                styles = Object.merge(styles, {'top': this.options.resize.padding + (this.isIE6 ? scroll.y : 0)});
                            } else  {
                                styles = Object.merge(styles, {'top': (size.y / 2 + (this.isIE6 ? scroll.y : 0)) - this.size.height / 2});
                            }
                    
                            this.fx.popap.set(styles);
                            
                            // Renew delta value
                            if (!nodelta) {
                                this.scrollSize = document.getScrollSize();
                                this.scrollDelta = scroll;
                            }
                            break;
                    } 
                },
               
                getScrollDirection: function (scroll) {
                    this.scrollDirect.last = this.scrollDirect.current;
                    this.scrollDirect.current = scroll;
                    
                    
                    if (this.scrollDirect.last.x > this.scrollDirect.current.x) {  
                        this.scrollDirect.move = 'left'; 
                    } else if (this.scrollDirect.last.x < this.scrollDirect.current.x) {  
                        this.scrollDirect.move = 'right';
                    }
                
                    if (this.scrollDirect.last.y > this.scrollDirect.current.y) {  
                        this.scrollDirect.move = 'up'; 
                    } else if (this.scrollDirect.last.y < this.scrollDirect.current.y) {  
                        this.scrollDirect.move = 'down';
                    } 
                },
                               
                scroll: function () {
                    if (this.options.resize.method == 'scroll') {
                        
                        var scroll = document.getScroll();
                        size = window.getSize(),
                        position = this.elements.container.getPosition(),
                        scrollY = (scroll.y - this.scrollDelta.y) <= 0 ? 0 : scroll.y - this.scrollDelta.y,
                        scrollX = (scroll.x - this.scrollDelta.x) <= 0 ? 0 : scroll.x - this.scrollDelta.x;
                        
                        this.getScrollDirection(scroll);

                        // Force delta on scrolled to begin
                        this.scrollDelta.y = (scrollY <= 0) ? scroll.y : this.scrollDelta.y;
                        this.scrollDelta.x = (scrollX <= 0) ? scroll.x : this.scrollDelta.x;
                        
                        
                        this.isIE6 && this.center(true); 
                        
                        // Scroll by Y coordinate
                        if ((size.y + scrollY) < (this.size.height + this.extendenLand.height) + (this.options.resize.padding * 2) && this.scrollSize.y != (scroll.y + size.y)) {
                            this.fx.popap.set({'top': this.isIE6 ? scroll.y - scrollY + this.options.resize.padding : -scrollY + this.options.resize.padding}); 
                        } 
                        else if ((scrollY + size.y > (this.size.height + this.extendenLand.height) && size.y < (this.size.height + this.extendenLand.height)) || (this.scrollSize.y == (scroll.y + size.y) && (this.size.height + this.extendenLand.height) > size.y)) {  
                            this.fx.popap.set({'top': this.isIE6 ? (scroll.y + (size.y - (this.size.height + this.extendenLand.height)) - this.options.resize.padding) : -((this.size.height + this.extendenLand.height) - size.y + this.options.resize.padding)});
                            if (this.scrollDirect.move == 'up') {
                                this.scrollDelta.y = this.isIE6 ? (position.y - this.options.resize.padding) : (scroll.y + position.y - this.options.resize.padding);  
                            }
                        }

                        //Scroll by X coordinate
                        if ((size.x + scrollX) < (this.size.width + this.extendenLand.width) + (this.options.resize.padding * 2) && this.scrollSize.x != (scroll.x + size.x)) {
                            this.fx.popap.set({'left': this.isIE6 ? scroll.x - scrollX + this.options.resize.padding : -scrollX + this.options.resize.padding}); 
                        } 
                        else if ((scrollX + size.x > (this.size.width + this.extendenLand.width) && size.x < (this.size.width + this.extendenLand.width)) || (this.scrollSize.x == (scroll.x + size.x) && (this.size.width + this.extendenLand.width) > size.x)) {
                            this.fx.popap.set({'left': this.isIE6 ? (scroll.x + (size.x - (this.size.width + this.extendenLand.width)) - this.options.resize.padding) : -((this.size.width + this.extendenLand.width) - size.x + this.options.resize.padding)});
                            
                            if (this.scrollDirect.move == 'left') {
                                this.scrollDelta.x = this.isIE6 ? (position.x - this.options.resize.padding) : (scroll.x + position.x - this.options.resize.padding);    
                            }
                        }
                        
                    } else if (this.options.resize.method == 'fit' && this.isIE6) {
                        this.center(); 
                    }
                },
                
                display: function (action, display) {
               
                    // Use random effect
                    if (action.test('random', 'i')) {
                        action = this.availableTransitions.slice(0, -1).getRandom();
                    } 
                    
                    // console.log(action);
                    this.fx.popap.cancel();

                    var actionMethod = action.replace(/\s+/g, '').toLowerCase();
                    
                    var extened = {'visibility': 'visible'};
                    switch (display) {
                        case 'show':
                            this.fx.popap.set({'opacity': this.options.transitions.opacity.hide});
                            extened = Object.merge(extened, {'opacity': this.options.transitions.opacity.show});
                            this.elements.container.setStyle('display', 'block');
                            this.fx.content.set('opacity', 1);
                            break;
                        case 'hide':
                            this.fx.popap.set({'opacity': this.options.transitions.opacity.show});
                            extened = Object.merge(extened, {'opacity': this.options.transitions.opacity.hide});
                            break;
                    }
                    
                    if (actionMethod == 'slidecenter') {
                        this.fx.content.cancel();
                        this.fx.content.set('opacity', 0);
                    }
                    
                   
                    var position = this.elements.container.getPosition();
                    
                    var chainFn = function () {
                        this.state = display;
                       
                        switch (display) {
                            case 'show':
                                var computedSize = this.elements.container.getComputedSize();
                              
                                this.extendenLand = {'width': computedSize.computedLeft + computedSize.computedRight, 'height': computedSize.computedBottom + computedSize.computedTop};
                                actionMethod == 'slidecenter' && this.fx.content.start('opacity', 1);
                                break;
                            case 'hide':
                                this.elements.container.setStyles({
                                    'display': 'none',
                                    'visibility': 'hidden'
                                });
                                break;
                        }
                        this.fireEvent(this.state.toLowerCase() + 'Complete', display);
                    }.bind(this)
                   
                    this.animation(display, actionMethod, position, extened, chainFn).chain(chainFn);
                },
                
                animation: function (display, transition, position, extened, chainFn) {
                    switch(transition + display.capitalize()) {
                        case 'slideupShow': 
                            return this.fx.popap.start(Object.merge({'top': [position.y - this.options.transitions.padding, position.y]}, extened));
                            break;   

                        case 'slidedownShow': 
                            return this.fx.popap.start(Object.merge({'top': [position.y + this.options.transitions.padding, position.y]}, extened));
                            break;  

                        case 'slideleftShow': 
                            return this.fx.popap.start(Object.merge({'left': [position.x + this.options.transitions.padding, position.x]}, extened)); 
                            break;  

                        case 'sliderightShow': 
                            this.fx.popap.start(Object.merge({'left': [position.x - this.options.transitions.padding, position.x]}, extened)); 
                            break;  

                        case 'slidecenterShow':                    
                            return this.fx.popap.start(Object.merge({'top': [position.y + (this.size.height / 2), position.y], 'left': [position.x + (this.size.width / 2), position.x], 'width': [0, this.size.width], 'height': [0, this.size.height] }, extened));
                            break;  
  
                        case 'fadeShow':
                            return this.fx.popap.start(Object.merge({'opacity': this.options.transitions.opacity.show}, extened));
                            break;  
                        
                        case 'noneShow': 
                            this.fx.popap.set({'visibility': 'visible', 'opacity': 1}); 
                            chainFn.call(this);
                            break;  
                            
                        case 'slideupHide':  
                            return this.fx.popap.start(Object.merge({'top': [position.y, position.y - this.options.transitions.padding]}, extened));
                            break; 

                        case 'slidedownHide':  
                            return this.fx.popap.start(Object.merge({'top': [position.y, position.y + this.options.transitions.padding]}, extened));
                            break;

                        case 'slideleftHide':  
                            return this.fx.popap.start(Object.merge({'left': [position.x, position.x + this.options.transitions.padding]}, extened)); 
                            break; 

                        case 'sliderightHide':  
                            return this.fx.popap.start(Object.merge({'left': [position.x, position.x - this.options.transitions.padding]}, extened)); 
                            break;

                        case 'slidecenterHide': 
                            return this.fx.popap.start(Object.merge({'top': [position.y, position.y + (this.size.height / 2)], 'left': [position.x, position.x + (this.size.width / 2)], 'width': [this.size.width, 0], 'height': [this.size.height, 0] }, extened));
                            break;
                            
                        case 'fadeHide': 
                            return this.fx.popap.start(Object.merge({'opacity': this.options.transitions.opacity.hide}, extened));
                            break
                        
                        case 'noneHide':  
                            this.fx.popap.set({'opacity': 0, 'visibility': 'hidden'});
                            chainFn.call(this);
                            break;
                    }
                    return this.fx.popap;
                },
                
                isTransitionsAvailable: function (transition) {
                    if (this.availableTransitions.indexOf(transition.replace(/\s+/g, '').toLowerCase()) == -1) {
                        throw new Error('You use a wrong transition effect');  
                        return false;
                    }
                    return true;
                },
                
                show: function () {
                    if (this.isTransitionsAvailable(this.options.transitions.show) && this.options.enable) {
                      
                        this.state = 'show';
                        
                        this.center();
                        this.fireEvent(this.state);
                        this.display(this.options.transitions.show, this.state);
                        
                        this.functionEvents = {
                            'resize': this.center.bind(this),
                            'scroll': this.scroll.bind(this),
                            'keyup': function (e) {
                                (this.options.close.escape && e.key == 'esc') && this.hide();
                            }.bind(this)  
                        };
                        
                        window.addEvents({
                            'resize': this.functionEvents.resize,
                            'scroll': this.functionEvents.scroll
                        });
                    
                        document.addEvent('keyup', this.functionEvents.keyup);
                       
                    }
                },
                
                hide: function () {
                    if (this.isTransitionsAvailable(this.options.transitions.hide) && this.options.enable) {
                        this.state = 'hide';
                        
                        this.fireEvent(this.state);
                        this.display(this.options.transitions.hide, this.state);
                         
                        window.removeEvent('resize', this.functionEvents.resize); 
                        window.removeEvent('scroll', this.functionEvents.scroll); 
                        document.removeEvent('keyup', this.functionEvents.keyup);
                    }

                }
                    
            });
            
            
            NicePopup.Trigger = new Class({
                Implements: [Options, Events],

                elements: {},
                mask: null,
                window: null,
                direction: null,
				direction_x: null,
				doc_width: null,
				doc_height: null,
                idle: false,
                counter: 0,          
               
                'options': {
					'cookie':60,
					'counts':0,
                    'enable': true,
                    'mask': {},
                    'window': {}
                },

                initialize: function (options) {
                    
                    this.setOptions(options);

                    if (this.options.enable === false) return false;
                    
					
					cookie=getCookie('NicePopup');
					
					if (cookie=='1') return false;
					else 
					{
						var d = new Date();

						setCookie('NicePopup','1',( d.getTime()+this.options.cookie*1000),'/');
					}
					
                    this.mask = new NicePopup.Mask(this.options.mask);
                    this.window = new NicePopup.Window(this.options.window);
                    
                    
                    this.mask.addEvent('showComplete', this.window.show.bind(this.window))
                    
                    this.mask.addEvent('hideComplete', function () {
                        this.idle = false; 
                    }.bind(this))
                   
                    
                    this.window.addEvent('hideComplete', function () {
                        this.mask.hide();
                        if (this.mask.options.enable === false) {
                            this.idle = false;
                        }
                    }.bind(this))
                    
					
	
					
					
					//alert(this.doc_width);
                    this.tracking();
                    document.addEvent('mouseleave', function (e) {
                        if (this.observer(e) === true) {
                            this.show();
                        }
                    }.bind(this));
                },
                
                tracking: function () {
                    var last, current = {};
                    document.addEvent('mousemove', function (e) {
                        last = current; 
                        current = e.page; 
                       
                        if (last.y > current.y) {  
                            this.direction = 'up'; 
                        } else if (last.y < current.y) {  
                            this.direction = 'down';
                        } 
                        if (last.x > current.x) {  
                            this.direction_x = 'left'; 
                        } else if (last.x < current.x) {  
                            this.direction_x = 'right';
                        } 
					/*	this.doc_width=(window.innerWidth)?window.innerWidth: 
    ((document.all)?document.body.offsetWidth:null); 
/*this.doc_height=(window.innerHeight)?window.innerHeight: 
    ((document.all)?document.body.offsetHeight:null);*/
	
						//if ((current.y<=10 && this.direction == 'up') /*|| ((current.y>=(this.doc_height-10)) && this.direction == 'down')*/ || ((current.x>=(this.doc_width-10)) && this.direction_x == 'right') || (current.x<=10 && this.direction_x == 'left')) 
						/*{
							
							alert(this.direction);
							alert(e.page.y);
							this.show();
						}*/
                    }.bind(this));
                },
                
                observer: function (e) {
					
                    switch (true) {
                        case Browser.safari && Browser.Platform.mac:
                            return (this.direction == 'up' || this.direction == 'down' || this.direction_x == 'left' || this.direction_x == 'right');
                            break;
                        default: 
                            return (e.client.y <= 10 && this.direction == 'up') || ( this.direction == 'down') || (this.direction_x == 'left') || (this.direction_x == 'right');
                            break;
                    }  
                },
                

                show: function () {
                    if (this.idle) return false;
					
					if (this.options.counts!=0 )
					{
					if (this.options.counts<=this.counter) return false;
					else this.counter++;
					}
					
                    this.idle = true;
                    if (this.mask.options.enable) {
                        return this.mask.show();
                    }
                    this.window.show();
                   
                }
            });


