
/*  new/common/js/jquery.popupWindow.js  */
(function($){ 		  
	$.fn.popupWindow = function(instanceSettings){
		
		return this.each(function(){
		
		$(this).click(function(){
		
		$.fn.popupWindow.defaultSettings = {
			centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left
			centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left
			height:500, // sets the height in pixels of the window.
			left:0, // left position when the window appears.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
			resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			width:500, // sets the width in pixels of the window.
			windowName:null, // name of window set from the name attribute of the element that invokes the click
			windowURL:null, // url used for the popup
			top:0, // top position when the window appears.
			toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
		};
		
		settings = $.extend({}, $.fn.popupWindow.defaultSettings, instanceSettings || {});
		
		var windowFeatures =    'height=' + settings.height +
								',width=' + settings.width +
								',toolbar=' + settings.toolbar +
								',scrollbars=' + settings.scrollbars +
								',status=' + settings.status + 
								',resizable=' + settings.resizable +
								',location=' + settings.location +
								',menuBar=' + settings.menubar;

				settings.windowName = this.name || settings.windowName;
				settings.windowURL = settings.windowURL?settings.windowURL:this.href;
				var centeredY,centeredX;
			
				if(settings.centerBrowser){
						
					if ($.browser.msie) {//hacked together for IE browsers
						centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
						centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
					}else{
						centeredY = window.screenY + (((window.outerHeight/2) - (settings.height/2)));
						centeredX = window.screenX + (((window.outerWidth/2) - (settings.width/2)));
					}
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else if(settings.centerScreen){
					centeredY = (screen.height - settings.height)/2;
					centeredX = (screen.width - settings.width)/2;
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
				}else{
					window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top).focus();	
				}
				return false;
			});
			
		});	
	};
})(jQuery);

/*  new/common/js/global_async.js  */
$(document).ready(function(){
    if ('function' === typeof $().popupWindow)
    {
        $('a.tw', '#share-links').popupWindow({
            centerBrowser:1,
            windowURL:'http://twitter.com/intent/follow?region=follow&screen_name=avaaz',
            windowName:'twitter_popup_follow'
        });
    }
});

/*  common/js/ZeroClipboard.js  */
// Simple Set Clipboard System
// Author: Joseph Huckaby

var ZeroClipboard = {

	version: "1.0.7",
	clients: {}, // registered upload clients on page, indexed by id
	moviePath: 'ZeroClipboard.swf', // URL to movie
	nextId: 1, // ID of next movie

	$: function(thingy) {
		// simple DOM lookup utility function
		if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
		if (!thingy.addClass) {
			// extend element with a few useful methods
			thingy.hide = function() { this.style.display = 'none'; };
			thingy.show = function() { this.style.display = ''; };
			thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
			thingy.removeClass = function(name) {
				var classes = this.className.split(/\s+/);
				var idx = -1;
				for (var k = 0; k < classes.length; k++) {
					if (classes[k] == name) { idx = k; k = classes.length; }
				}
				if (idx > -1) {
					classes.splice( idx, 1 );
					this.className = classes.join(' ');
				}
				return this;
			};
			thingy.hasClass = function(name) {
				return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
			};
		}
		return thingy;
	},

	setMoviePath: function(path) {
		// set path to ZeroClipboard.swf
		this.moviePath = path;
	},

	dispatch: function(id, eventName, args) {
		// receive event from flash movie, send to client
		var client = this.clients[id];
		if (client) {
			client.receiveEvent(eventName, args);
		}
	},

	register: function(id, client) {
		// register new client to receive events
		this.clients[id] = client;
	},

	getDOMObjectPosition: function(obj, stopObj) {
		// get absolute coordinates for dom element
		var info = {
			left: 0,
			top: 0,
			width: obj.width ? obj.width : obj.offsetWidth,
			height: obj.height ? obj.height : obj.offsetHeight
		};

		while (obj && (obj != stopObj)) {
			info.left += obj.offsetLeft;
			info.top += obj.offsetTop;
			obj = obj.offsetParent;
		}
		return info;
	},

	Client: function(elem) {
		// constructor for new simple upload client
		this.handlers = {};

		// unique ID
		this.id = ZeroClipboard.nextId++;
		this.movieId = 'ZeroClipboardMovie_' + this.id;

		// register client with singleton to receive flash events
		ZeroClipboard.register(this.id, this);

		// create movie
		if (elem) this.glue(elem);
	}
};

ZeroClipboard.Client.prototype = {

	id: 0, // unique ID for us
	ready: false, // whether movie is ready to receive events or not
	movie: null, // reference to movie object
	clipText: '', // text to copy to clipboard
	handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
	cssEffects: true, // enable CSS mouse effects on dom container
	handlers: null, // user event handlers

	glue: function(elem, appendElem, stylesToAdd) {
        var addedStyle;
		// glue to DOM element
		// elem can be ID or actual DOM element object
		this.domElement = ZeroClipboard.$(elem);

		// float just above object, or zIndex 99 if dom element isn't set
		var zIndex = 99;
		if (this.domElement.style.zIndex) {
			zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
		}

		if (typeof(appendElem) === 'string') {
			appendElem = ZeroClipboard.$(appendElem);
		}
		else if (appendElem === undefined) {
			appendElem = document.getElementsByTagName('body')[0];
		}

        this.appendElem = appendElem;

		// find X/Y position of domElement
		var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
		// create floating DIV above element
		this.div = document.createElement('div');
		var style = this.div.style;
		style.position = 'absolute';
		style.left = '' + box.left + 'px';
		style.top = '' + box.top + 'px';
		style.width = '' + box.width + 'px';
		style.height = '' + box.height + 'px';
		style.zIndex = zIndex;

		if (typeof(stylesToAdd) === 'object') {
			for (addedStyle in stylesToAdd) {
				style[addedStyle] = stylesToAdd[addedStyle];
			}
		}

		// style.backgroundColor = '#f00'; // debug

		appendElem.appendChild(this.div);

		this.div.innerHTML = this.getHTML( box.width, box.height );
	},

	getHTML: function(width, height) {
		// return HTML for movie
		var html = '';
		var flashvars = 'id=' + this.id +
			'&width=' + width +
			'&height=' + height;

		if (navigator.userAgent.match(/MSIE/)) {
			// IE gets an OBJECT tag
			var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
			html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
		}
		else {
			// all other browsers get an EMBED tag
			html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
		}
		return html;
	},

	hide: function() {
		// temporarily hide floater offscreen
		if (this.div) {
			this.div.style.left = '-2000px';
		}
	},

	show: function() {
		// show ourselves after a call to hide()
		this.reposition();
	},

	destroy: function() {
		// destroy control and floater
		if (this.domElement && this.div) {
			this.hide();
			this.div.innerHTML = '';

			var body = document.getElementsByTagName('body')[0];
			try { body.removeChild( this.div ); } catch(e) {;}

			this.domElement = null;
			this.div = null;
		}
	},

	reposition: function(elem) {
		// reposition our floating div, optionally to new container
		// warning: container CANNOT change size, only position
		if (elem) {
			this.domElement = ZeroClipboard.$(elem);
			if (!this.domElement) this.hide();
		}

		if (this.domElement && this.div) {
			var box = ZeroClipboard.getDOMObjectPosition(this.domElement, this.appendElem);
			var style = this.div.style;
			style.left = '' + box.left + 'px';
			style.top = '' + box.top + 'px';
            style.width = '' + box.width + 'px';
            style.height = '' + box.height + 'px';
            this.div.innerHTML = this.getHTML( box.width, box.height );
		}
	},

	setText: function(newText) {
		// set text to be copied to clipboard
		this.clipText = newText;
		if (this.ready) this.movie.setText(newText);
	},

	addEventListener: function(eventName, func) {
		// add user event listener for event
		// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
		eventName = eventName.toString().toLowerCase().replace(/^on/, '');
		if (!this.handlers[eventName]) this.handlers[eventName] = [];
		this.handlers[eventName].push(func);
	},

	setHandCursor: function(enabled) {
		// enable hand cursor (true), or default arrow cursor (false)
		this.handCursorEnabled = enabled;
		if (this.ready) this.movie.setHandCursor(enabled);
	},

	setCSSEffects: function(enabled) {
		// enable or disable CSS effects on DOM container
		this.cssEffects = !!enabled;
	},

	receiveEvent: function(eventName, args) {
		// receive event from flash
		eventName = eventName.toString().toLowerCase().replace(/^on/, '');

		// special behavior for certain events
		switch (eventName) {
			case 'load':
				// movie claims it is ready, but in IE this isn't always the case...
				// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
				this.movie = document.getElementById(this.movieId);
				if (!this.movie) {
					var self = this;
					setTimeout( function() { self.receiveEvent('load', null); }, 1 );
					return;
				}

				// firefox on pc needs a "kick" in order to set these in certain cases
				if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
					var self = this;
					setTimeout( function() { self.receiveEvent('load', null); }, 100 );
					this.ready = true;
					return;
				}

				this.ready = true;
                try {
                    this.movie.setText( this.clipText );
                    this.movie.setHandCursor( this.handCursorEnabled );
                } catch (e) {
                    //silently skip IE8 error
                    // Upgrade ZeroClipboard to latest version
                    // Remove this if the STO Wizard layout + DM does not pass tests
                }


				break;

			case 'mouseover':
				if (this.domElement && this.cssEffects) {
					this.domElement.addClass('hover');
					if (this.recoverActive) this.domElement.addClass('active');
				}
				break;

			case 'mouseout':
				if (this.domElement && this.cssEffects) {
					this.recoverActive = false;
					if (this.domElement.hasClass('active')) {
						this.domElement.removeClass('active');
						this.recoverActive = true;
					}
					this.domElement.removeClass('hover');
				}
				break;

			case 'mousedown':
				if (this.domElement && this.cssEffects) {
					this.domElement.addClass('active');
				}
				break;

			case 'mouseup':
				if (this.domElement && this.cssEffects) {
					this.domElement.removeClass('active');
					this.recoverActive = false;
				}
				break;
		} // switch eventName

		if (this.handlers[eventName]) {
			for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
				var func = this.handlers[eventName][idx];

				if (typeof(func) == 'function') {
					// actual function reference
					func(this, args);
				}
				else if ((typeof(func) == 'object') && (func.length == 2)) {
					// PHP style object + method, i.e. [myObject, 'myMethod']
					func[0][ func[1] ](this, args);
				}
				else if (typeof(func) == 'string') {
					// name of function
					window[func](this, args);
				}
			} // foreach event handler defined
		} // user defined handler for event
	}

};

/*  common/js/Share.js  */
if (!window.share_data) {
    window.share_data = {};
}
if (!window.Share) {
    Share = {
        event_id: 0,
        results: {},
        URLdata: [],
        shareCallback: [],
        petition_id: false,
        resetUrls: function () {
            this.urls = {};
            this.urlsA = [];
        },
        addQS: function (d, c) {
            var a = [];
            for (var b in c) if (c[b]) a.push(b.toString() + '=' + encodeURIComponent(c[b]));
            return d + '?' + a.join('&');
        },
        getUrl: function (a) {
            return a.getAttribute('share_url') || window.location.href;
        },
        getType: function (a) {
            return a.getAttribute('type') || 'button_count';
        },
        pretty: function (a) {
            return a >= 1e+07 ? Math.round(a / 1e+06) + 'M' : (a >= 10000 ? Math.round(a / 1000) + 'K' : a);
        },
        updateButton: function (a) {
            var cid = $(a).attr('sharecid');
            var type = $(a).attr('sharetype');
            for (h in this.results[cid]) {
                if (this.results[cid]) {
                    a[type + '_count'] = this.results[cid][type + '_count'];
                } else {
                    a[type + '_count'] = 0;
                }
                this.displayBox(a, 0);
            }

        },
        getWindowInnerSize: function () {
            var width = 0;
            var height = 0;
            var elem = null;
            if ('innerWidth' in window) {
                // For non-IE
                width = window.innerWidth;
                height = window.innerHeight;
            } else {
                // For IE,
                if (('BackCompat' === window.document.compatMode)
                    && ('body' in window.document)) {
                    elem = window.document.body;
                } else if ('documentElement' in window.document) {
                    elem = window.document.documentElement;
                }
                if (elem !== null) {
                    width = elem.offsetWidth;
                    height = elem.offsetHeight;
                }
            }
            return [width, height];
        },
        getParentCoords: function () {
            var width = 0;
            var height = 0;
            if ('screenLeft' in window) {
                // IE-compatible variants
                width = window.screenLeft;
                height = window.screenTop;
            } else if ('screenX' in window) {
                // Firefox-compatible
                width = window.screenX;
                height = window.screenY;
            }
            return [width, height];
        },
        getCenteredCoords: function (width, height) {
            var parentSize = this.getWindowInnerSize();
            var parentPos = this.getParentCoords();
            var xPos = parentPos[0] +
                Math.max(0, Math.floor((parentSize[0] - width) / 2));
            var yPos = parentPos[1] +
                Math.max(0, Math.floor((parentSize[1] - height) / 2));
            return [xPos, yPos];
        },
        displayBox: function (a, d) {
            var type = $(a).attr('sharetype');
            if (typeof(a[type + '_count']) == 'number' && a[type + '_count'] >= d) {
                $('.' + $(a).attr('sharetype') + '_share_counter_' + $(a).attr('sharecid')).each(function () {
                    $(this).html(Share.pretty(a[type + '_count']))
                });
            }
        },
        addEvent: function (href) {
            if ('undefined' !== typeof rsvp_event_id) {
                return href + '&id=' + rsvp_event_id + '';
            }
            return href;
        },
        renderButton: function (c) {
            var bIsMobile = (window.bIsMobile != undefined) ? window.bIsMobile : false;
            var cid = $(c).attr('sharecid');
            var type = $(c).attr('sharetype');
            var lang = $(c).attr('sharelang');
            var href = $(c).attr('href');
            var method = $(c).attr('sharemethod');
            if (!method || bIsMobile) {
                method = 'share';
            }
            /***************************FACEBOOK**************************/
            var global_response = null;

            function is_valid_post_response(response) {
                return (typeof response !== 'undefined' && response !== null && typeof response.post_id !== 'undefined');
            }
            
            var stream_callback = function (post) {
                if (is_valid_post_response(post)) {
                    // Save share action id
                    $.ajax({
                        url:'/act/ajax_save_fb_share.php',
                        dataType: 'json',
                        type: 'POST',
                        data: {
                            user_hash: getUserHash(true),
                            action_type: 'og.shares',
                            action_id: post.post_id
                        }
                    });
                }           
                $(document).facebookReady(function () {
                    FB.getLoginStatus(
                        function (response) {
                            if (response.session) {
                                //login_response(response);
                                var a = document.createElement('script');
                                
                                if (is_valid_post_response(post)) {
                                    var send_data = {
                                        action: 'save_share_counter',
                                        cid: cid,
                                        lang: lang,
                                        random: Math.random(),
                                        value: 'shared',
                                        fb_uid: response.session.uid
                                    };
                                    if (Share.petition_id) {
                                        send_data.petition_id = Share.petition_id;
                                    }
                                    a.src = Share.addQS('/act/facebook.php', send_data);
                                } else {
                                    var send_data = {
                                        action: 'save_share_counter',
                                        cid: cid,
                                        lang: lang,
                                        random: Math.random(),
                                        value: 'closed',
                                        fb_uid: response.session.uid
                                    };
                                    if (Share.petition_id) {
                                        send_data.petition_id = Share.petition_id;
                                    }
                                    a.src = Share.addQS('/act/facebook.php', send_data);
                                }
                                Share.insert(a);
                                if ('undefined' !== typeof post && null !== post && post.post_id) {
                                    Share.updateHiddenCounter(c, 'shared', { fb_uid: response.session.uid });
                                } else {
                                    Share.updateHiddenCounter(c, 'closed', { fb_uid: response.session.uid });
                                }
                            } else {
                                //FB.login(login_response);
                            }
                        }
                    );
                });
            };
            var facebook_click = function (e) {
                var $el = $(this);
                e.preventDefault();
                $('body').trigger('sharing_started');
                Share.updateCounter(c);

                var login_response = function (response) {
                    if (response.session) {
                        Share.updateHiddenCounter(c, 'user_clicked', { fb_uid: response.session.uid });
                        global_response = response;
                    }
                };

                if (method === 'tagging' && (typeof($.fn.FBTagFriendsWidget) == 'function')) {
                    var options = {sMethod: method};
                    if (!window.oFBTagWidget) {
                        if ($el.data('title')) {
                            $('#dialogTagFBFriendsTitle').html($el.data('title'));
                        }
                        if ($el.data('description')) {
                            $('#dialogTagFBFriendsText').html($el.data('description'));
                        }

                        // check if scope was provided let's use it
                        if ($el.data('scope') !== undefined) {
                            options.scope = $el.data('scope');
                        }

                        window.oFBTagWidget = $('div#dialogTagFBFriends').FBTagFriendsWidget(options);
                    }
                    window.oFBTagWidget.process(null, cid);
                } else {
                    $(document).facebookReady(function () {
                        if ($.inArray(method, ['stream.dm', 'stream.fbdm', 'share', 'stream.taggingdm']) > -1) {
                            FB.ui({
                                display: 'popup',
                                method: 'share',
                                href: Share.addEvent(share_data[cid].facebook.href)
                            }, stream_callback);
                        } else {
                            FB.getLoginStatus(
                                function (response) {
                                    share_data[cid].facebook.href = Share.addEvent(share_data[cid].facebook.href);

                                    var fb_object = {
                                        display: 'popup',
                                        method: method,//'stream.publish',
                                        attachment: $.extend({}, share_data[cid].facebook),
                                        action_links: share_data[cid].facebook.action_links
                                    };

                                    if ($el.data('custom_fb_wall_url') && method === 'stream.publish') {
                                        fb_object.attachment.href = $el.data('custom_fb_wall_url');
                                    }

                                    if ('stream.share' === method) {
                                        fb_object.u = share_data[cid].facebook.href;
                                        fb_object.t = share_data[cid].facebook.name;
                                        fb_object.attachment = '';
                                        fb_object.action_links = '';
                                    }
                                    if (fb_object.attachment) {
                                        if ($el.data('title')) {
                                            fb_object.attachment.name = $el.data('title');
                                        }
                                        if ($el.data('description')) {
                                            fb_object.attachment.description = $el.data('description');
                                        }
                                    }

                                    if (response.session) {
                                        login_response(response);
                                        if (share_data[cid].facebook.status && '' !== share_data[cid].facebook.status) {
                                            fb_object.message = share_data[cid].facebook.status;
                                        }
                                        FB.ui(
                                            fb_object,
                                            stream_callback
                                        );
                                    } else {
                                        FB.ui(
                                            fb_object,
                                            stream_callback
                                        );
                                    }
                                }
                            );
                        }
                    });

                    Share.displayBox(this, 1);

                    $('body').trigger('sharing_complete');

                    return false;
                }
            };

            /***********************END OF FACEBOOK***********************/

            /***************************ORKUT ****************************/
            var orkut_click = function () {
                $('body').trigger('sharing_started');

                Share.updateCounter(c);
                window.open(decodeURIComponent(Share.addEvent(share_data[cid].orkut.href)), "orkutwindow", "status=1,toolbar=1,height=650,width=1024");

                $('body').trigger('sharing_complete');

                return false;
            };
            /************************END OF ORKUT*************************/

            /****************************TUMBLR***************************/
            var tumblr_click = function () {
                $('body').trigger('sharing_started');

                Share.updateCounter(c);
                var coordinates = Share.getCenteredCoords(500, 420);
                window.open('http://www.tumblr.com/share/link?url=' + Share.addEvent(share_data[cid].tumblr.href) + '&name=' + share_data[cid].tumblr.text + '&description=' + share_data[cid].tumblr.description, "tweetwindow", "status=1,toolbar=1,height=420,width=500" + ",left=" + coordinates[0] + ",top=" + coordinates[1]);

                $('body').trigger('sharing_complete');
                return false;
            };
            /************************END OF TUMBLR*************************/

            /****************************TWITTER ***************************/
            var twitter_click = function () {
                $('body').trigger('sharing_started');

                Share.updateCounter(c);
                var coordinates = Share.getCenteredCoords(500, 350);
                var sWindowUrl = 'http://twitter.com/share?related=Avaaz&url=' + Share.addEvent(share_data[cid].twitter.href) + '&text=' + encodeURIComponent(share_data[cid].twitter.text) /*decodeURIComponent(j)*/;

                if (typeof(sRetweetUrl) != 'undefined') {
                    sWindowUrl = sRetweetUrl;
                }


                window.open(sWindowUrl, "tweetwindow", "status=1,toolbar=1,height=350,width=500" + ",left=" + coordinates[0] + ",top=" + coordinates[1]);

                $('body').trigger('sharing_complete');
                return false;
            };
            /************************END OF TWITTER*************************/

            /*************************** VK ****************************/
            var vk_click = function () {
                Share.updateCounter(c);
                window.open(decodeURIComponent(Share.addEvent(share_data[cid].vk.href)), "vkwindow", "status=1,toolbar=1,height=650,width=1024");
                return false;
            };
            /************************END OF VK*************************/

            var isValidSelector = function (selector) {
                try {
                    var $element = $(selector);
                } catch(error) {
                    return false;
                }
                return ($element.length > 0);
            };

            /****************************EMAIL ***************************/
            var email_click = function () {

                $('body').trigger('sharing_started');

                Share.updateCounter(c);
                if (!c.email_clicked) {
                    c.email_count += 1;
                    c.email_clicked = true;
                }

                var bStats = true;
                if ($(this).data('stats')) {
                    bStats = !!$(this).data('stats');
                }

                var sSubject = $(this).data('subject');
                if (sSubject !== undefined) {
                    if (isValidSelector(sSubject)) {
                        sSubject = $(sSubject).val();
                    }
                } else {
                    sSubject = '';
                }

                var sBody = $(this).data('body');
                if (sBody !== undefined) {
                    var body = $(sBody).val();
                    if (isValidSelector(sBody) && body !== undefined && body !== '') {
                        sBody = body;
                    }
                } else {
                    sBody = '';
                }


                var domain = GetEmailDomain();
                var mailto = true;
                domain = domain && !$(c).data('mobile') ? domain : 'other';

                sBody = getEdgeData({event: (('undefined' !== typeof rsvp_event_id) ? 'id=' + rsvp_event_id : '')}, (sBody !== '' ? sBody : share_data[cid].email.body));
                sBody = $('<textarea />').html(sBody).text();

                switch (domain) {
                    case 'gmail':
                        mailto = false;
                        href = Share.addQS('https://mail.google.com/mail/', {
                            view: 'cm',
                            fs: 1,
                            to: '',
                            su: sSubject !== '' ? sSubject : share_data[cid].email.subject,
                            body: sBody,
                            ui: 2,
                            shva: 1
                        });
                        break;
                    default:
                        href = Share.addQS('mailto:', {
                            subject: sSubject !== '' ? sSubject : share_data[cid].email.subject,
                            body: sBody
                        });
                        break;
                }
                var send_data = {campaign_id: cid, domain: domain};
                if (Share.petition_id) {
                    send_data.petition_id = Share.petition_id;
                }
                if (bStats) {
                    jQuery.post('/act/ajax_send_stats.php', send_data, function () {
                    });
                }

                Share.displayBox(this, 1);
                $('body').trigger('sharing_complete');

                if (!mailto) {
                    window.open(href, "emailwindow", "status=1,toolbar=1,height=650,width=1024");
                } else {
                    $(c).attr('target', '_blank');
                    $(c).attr('href', href);
                    return true;
                }

                return false;
            };
            var email_popup = null;
            var email_click_popup = function () {

                var bStats = true;
                if ($(this).data('stats')) {
                    bStats = !!$(this).data('stats');
                }
                var domain = GetEmailDomain();
                if (!c.email_clicked) {
                    c.email_count += 1;
                    c.email_clicked = true;
                    var send_data = {campaign_id: cid, domain: domain};
                    if (Share.petition_id) {
                        send_data.petition_id = Share.petition_id;
                    }
                    if (bStats) {
                        jQuery.post('/act/ajax_send_stats.php', send_data, function () {
                        });
                    }
                }
                if (email_popup) {
                    email_popup.trigger('click');
                } else {
                    if (!window.colorbox_dialogs) {
                        colorbox_dialogs = {};
                    }
                    colorbox_dialogs.email_popup = $.colorbox(
                        {
                            opacity: 0.5,
                            inline: true,
                            href: "#" + $(c).attr('use_popup'),
                            showClose: ('undefined' !== typeof $(c).data('showclose') ? $(c).data('showclose') : true),
                            onClosed: function () {
                                openid.closeColorbox();
                            },
                            onComplete: function () {
                                $(this).colorbox.resize();
                            }
                        });
                }
                //$(c).attr('href', href);
                Share.displayBox(this, 1);
                return false;
            }
            /************************END OF EMAIL*************************/
            if (type != 'email')
                $(c).click(function () {
                    return false;
                }); // fix for IE redirect
            if (share_data[cid] && share_data[cid][type]) {
                switch (type) {
                    case 'facebook':
                        /****************** ADD FACEBOOK SHARE URL ******************/
                        $(c).attr('href', this.addQS('http://www.avaaz.org/act/facebook_share.php', {
                            cid: cid,
                            lang: lang,
                            src: 'sp'
                        }));
                        $(c).click(facebook_click);
                        /************************************************************/
                        break;
                    case 'orkut':
                        /****************** ADD ORKUT SHARE URL ******************/
                        $(c).attr('href', share_data[cid].orkut.href);

                        $(c).click(orkut_click);
                        /************************************************************/
                        break;
                    case 'tumblr':
                        /****************** ADD TUMBLR SHARE URL ******************/
                        $(c).attr('href', 'http://www.tumblr.com/share/link?url=' + share_data[cid].tumblr.href + '&name=' + share_data[cid].tumblr.text + '&description=' + share_data[cid].tumblr.description);
                        $(c).click(tumblr_click);
                        /************************************************************/
                        break;
                    case 'twitter':
                        /****************** ADD TWITTER SHARE URL ******************/
                        $(c).attr('href', 'http://twitter.com/share?related=Avaaz&url=' + share_data[cid].twitter.href + '&text=' + share_data[cid].twitter.text);
                        $(c).click(twitter_click);
                        /************************************************************/
                        break;
                    case 'email':
                        /****************** ADD EMAIL SHARE URL ******************/
                        $(c).attr('href', 'javascript:void(0);');

                        $(c).click(function (e) {
                            if (!window.useContactImporter || window.isContactImporterV1) {
                                if ($(this).attr('use_popup')) {
                                    e.preventDefault();
                                    return email_click_popup.apply(this);
                                } else {
                                    return email_click.apply(this);
                                }
                            }
                        });

                        /************************************************************/
                        break;
                    case 'vk':
                        /****************** ADD VK SHARE URL ******************/
                        $(c).attr('href', share_data[cid].vk.href);
                        $(c).click(vk_click);
                        /************************************************************/
                        break;
                }
            }
            c.fb_rendered = true;
        },
        insert: function (a) {
            (document.getElementsByTagName('HEAD')[0] || document.body).appendChild(a);
        },
        renderAll: function () {
            $('.share').filter(function () {
                return ('undefined' === typeof $(this).attr('sharetype') ? false : true);
            }).each(function (i) {
                Share.URLdata[i] = this;
            });
            var c = Share.URLdata;
            var a = c.length;
            for (var b = 0; b < a; b++) {
                if (!c[b].fb_rendered && $(c[b]).hasClass('janrain-share') === false) {
                    this.renderButton(c[b]);
                }
                if (this.results[$(c[b]).attr('sharecid')]) this.updateButton(c[b]);
            }
        },
        fetchData: function () {
            var data = {};
            for (var h in Share.URLdata) {
                if ('function' === typeof Share.URLdata[h])
                    continue;
                var link = Share.URLdata[h];
                var type = $(link).attr('sharetype');
                var cid = $(link).attr('sharecid');
                if (share_data[cid]) {
                    if ('undefined' === typeof data[cid]) {
                        data[cid] = {};
                    }
                    if ('undefined' === typeof data[cid]['type']) {
                        data[cid]['type'] = {};
                    }
                    data[cid]['type'][type] = 1;
                    /** ADDON FOR PETITIONS ***/
                    if (share_data[cid].petition) {
                        Share.petition_id = share_data[cid].petition;
                    }
                }
            }
            var send_data = {
                v: '1.0',
                action: 'get_share_count',
                format: 'json',
                data: data
            };
            if (Share.petition_id) {
                send_data.petition_id = Share.petition_id;
            }
            this.resetUrls();

            $.ajax(
                {
                    url: '/act/share_stats.php?' + $.param(send_data),
                    type: 'GET',
                    dataType: 'json',
                    success: function (data) {
                        if (data)
                            share_render(data);
                    }
                }
            );
        },
        runShareCallback: function (type) {
            for (var i = 0; i <= Share.shareCallback.length; i++) {
                if ('function' === typeof Share.shareCallback[i]) {
                    Share.shareCallback[i](type);
                }
            }
        },
        updateCounter: function (el) {
            el = $(el);
            if (Share.updateHiddenCounter(el, 'clicked', {})) {
                var elShareButton = el[0];
                var sType = $(elShareButton).attr('sharetype');
                if ($.inArray(sType, ['twitter', 'tumblr', 'orkut', 'email', 'vk']) != -1) {
                    if (!elShareButton[sType + '_clicked']) {
                        elShareButton[sType + '_count'] += 1;
                        elShareButton[sType + '_clicked'] = true;
                    }
                } else {
                    if (sType == 'facebook') {
                        if (!elShareButton['fb_clicked']) {
                            elShareButton['facebook_count'] += 1;
                            elShareButton['fb_clicked'] = true;
                        }
                    }
                }
                Share.displayBox(elShareButton, 1);
                Share.runShareCallback(sType);
            }
        },
        updateHiddenCounter: function (el, sAction, oExtras) {
            var iCid = $(el).attr('sharecid');
            var sType = $(el).attr('sharetype');
            var sLang = $(el).attr('sharelang');
            if (iCid && sType && sLang) {
                if (sType == 'email') {
                    return Share.updateEmailCounter(el);
                } else {
                    var oSendData = {
                        action: 'save_share_counter',
                        cid: iCid,
                        lang: sLang,
                        random: Math.random(),
                        value: sAction
                    };
                }
                if (Share.petition_id) {
                    oSendData.petition_id = Share.petition_id;
                }
                $.extend(oSendData, oExtras);
                var sclick = document.createElement('script');
                var sUpdateScripts = {
                    email: 'ajax_send_stats',
                    facebook: 'facebook',
                    twitter: 'twitter',
                    tumblr: 'tumblr',
                    orkut: 'orkut',
                    vk: 'vkontakte'
                };
                if (typeof sUpdateScripts[sType] !== 'undefined') {
                    sclick.src = Share.addQS('/act/' + sUpdateScripts[sType] + '.php', oSendData);
                    Share.insert(sclick);
                    return true;
                }
            }
            return false;
        },
        updateEmailCounter: function (el) {
            var bStats = true;
            if ($(el).data('stats')) {
                bStats = !!$(el).data('stats'); // convert to boolean
            }
            if (bStats) {
                var sDomain = GetEmailDomain();
                sDomain = sDomain && !$(el).data('mobile') ? sDomain : 'other';
                oSendData = {
                    campaign_id: $(el).attr('sharecid'),
                    domain: sDomain
                };
                if (Share.petition_id) {
                    oSendData.petition_id = Share.petition_id;
                }
                $.post('/act/ajax_send_stats.php', oSendData);
                return true;
            }
            return false;
        },
        renderPass: function () {
            Share.renderAll();
            if (Share.URLdata.length > 0) {
                Share.fetchData();
            }
        },
        _onFirst: function () {
            this.resetUrls();
            window.share_render = function (b) {
                for (var h in b) Share.results[h] = b[h];
                Share.renderAll();
            };
            this.renderPass();
        },
        init: function () {
            if (typeof bDoNotRunShare === 'undefined' || !bDoNotRunShare) {
                Share._onFirst();
            }
        }
    };
    $(document).ready(function () {
        Share.init();
    });
}

/*  new/common/js/front-sign-form.js  */
function showLightBox() {
    hs.htmlExpand(null, {
            contentId: 'block-lightbox',
            align:'center',
            fadeInOut: true,
            dimmingOpacity:0.75 ,
            slideshowGroup: 'html',
            numberPosition: null,
            outlineType: ''
    });
}

function copy_select() {
    this.select();
}

$("#sform_copy_text").click(copy_select);
function loadClipButtonFront (){
    var elm = this;
    ZeroClipboard.setMoviePath( '/common/js/ZeroClipboard.swf');
    var clip = new ZeroClipboard.Client();
    clip.setText( '' ); // will be set later on mouseDown
    clip.setHandCursor( true );
    clip.setCSSEffects( true );
    clip.addEventListener( 'mouseDown', function(client) {
            // set text to copy here
            clip.setText($("#sform_copy_text").val());
            $("#sform_copy_text").focus().get(0).select();
            // alert("mouse down");
    } );
    // set the clip text to our innerHTML
    clip.glue(this, $("#sform_copy_button").parent()[0]);
}

function loadFrontClip() {
    $("#sform_copy_button").parent().css({'position': 'relative'});
    $("#sform_copy_button").each(loadClipButtonFront);
}

function lightbox_close() {
    $('#lightbox-before').show();
    $('#lightbox-after').hide();
}

function send_lightboxform(form) {
    $('#lightbox-loading-animation').show();
    var send_data = $(form).formHash();
    SetEmailDomain(send_data.Email);
    $.ajax({
        url:'/act/?r=act_ajax', dataType: 'json',
        type: 'POST',
        data: send_data,
        success: function (html) {
            $('#lightbox-loading-animation').hide();
            $('#lightbox-before').fadeOut('slow', function(){$('#lightbox-after').fadeIn('fast', function(){
                $(form).get(0).reset();
                $.colorbox.resize();
                setTimeout(loadFrontClip, 2000);
                $('#block-welcome-to-avaaz').show();
            });});

        }
    });
}

function check_postcode(select, postcode) {
    var $labelfor = $('label[for="form-joinus-postcode"]');
    if ('' != $labelfor.html()) {
        $labelfor.data('realValue', $labelfor.html());
    }
    if (!postcode.disabled) {
        $(postcode).data('realValue', postcode.value);
    }
    postcode.disabled = false;
    $labelfor.html('');
    $(postcode).val('checking...');
    $.ajax({
        url: '/act/index.php?r=ajaxCheckCountry',
        dataType: 'html',
        type: 'POST',
        async:false,
        data: {
            country: $(select).val()
        },
        success:function (data){
            if (data!='1') {
                $(postcode).data('hasPostcode', false);
                var rv;
                rv = $(postcode).data('realValue');
                $(postcode).val('');
                form_joinus.element(postcode);
                postcode.disabled = true;
            } else {
                $(postcode).data('hasPostcode', true);
                var rv;
                rv = $(postcode).data('realValue');
                $(postcode).val(rv);
                $labelfor.html($labelfor.data('realValue'));
            }
        }
    });
}

$(document).ready(function(){
    $('#form-joinus-country').change(function(){
    check_postcode(this, $('#form-joinus-postcode').get(0));
    });

    $(".link_actionsignup").colorbox({opacity:0.5,inline:true, href:"#block-lightbox", onComplete: function(){$(this).colorbox.resize();}, onClosed: lightbox_close});
    var $_GET = getArgs();

    if ($_GET['action'] && 'signup' === $_GET['action']) {
        $(".link_actionsignup").eq(0).trigger('click');
        if ($_GET['email']) {
            $('#form-joinus-email').val($_GET['email']).trigger('blur');
        }
    }

    //$("#sform_copy_button").parent().parent().css({'position': 'relative'});
    //$("#sform_copy_button").parent().each(loadClipButtonFront);
    //$("#sform_copy_button").each(loadClipButtonFront);

    /*jQuery.validator.addMethod("defaultInvalid", function(value, element) {
      return value != element.defaultValue;
    }, "");*/

    jQuery.validator.addMethod("specialpostcode", function(value, element) {
      if (true === $(element).data('hasPostcode')) {
      return value != '' && value != element.defaultValue;
      } else {
      return true;
      }
  }, "");
});
$('#form-joinus-email').ready(
function(){
    var timeout;
    var wrong_timeout;
    var wrong = false;
    var KEY = {
            UP: 38,
            DOWN: 40,
            DEL: 46,
            TAB: 9,
            RETURN: 13,
            ESC: 27,
            COMMA: 188,
            PAGEUP: 33,
            PAGEDOWN: 34,
            BACKSPACE: 8
        };
    var lastKeyPressCode;
    function onBlurE(){
        var obj = $('#form-joinus-email').get(0);
        var email_pattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))\s*$/;
        if(!email_pattern.test(obj.value)){
            if(obj.value != ''){
            }
        }
    }
    function onChange(){
        var obj = $('#form-joinus-email').get(0);
        if (obj.value != obj.lastValue){
            $(obj).css('background-image', "url('/images/upload_mini.gif')");
            $(obj).css('background-position', "right center");
            $(obj).css('background-repeat', "no-repeat");
            var email_pattern = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))\s*$/;
            if(!email_pattern.test(obj.value)){
                if(obj.value != ''){
                } else {
                }
                clearTimeout(wrong_timeout);
                wrong_timeout = setTimeout(function(){
                    $(obj).css('background-image', "none");
                    if (!wrong) {
                        $('.user_not_exists').show();
                        $('.user_exists').hide();
                        wrong = true;
                        $.colorbox.resize();
                        $('#form-joinus-email').focus();
                    }

                }, 1000);
            }else{
                wrong = false;
                $(obj).css('background-image', "url('/images/upload_mini.gif')");
                $(obj).css('background-position', "right center");
                $(obj).css('background-repeat', "no-repeat");
                $.get('/act/index.php?r=checkemailexists&Email=' + encodeURIComponent(obj.value),{}, function(data){
                    $(obj).css('background-image', "none");
                    results = data.split('|');
                    if (results[0] == 'true'){
                        $('.user_not_exists').hide();
                        $('.user_exists').show();
                        is_simple = true;
                    } else {
                        $('.user_not_exists').show();
                        $('.user_exists').hide();
                        is_simple = false;
                    }
                    $.colorbox.resize();
                    $('#form-joinus-email').focus();
                });
            }
        }
        obj.lastValue = obj.value;
    };
//    $('#EmailSimpleForm').keyup(ff).change(ff);
    //$('#EmailSimpleForm').blur(onBlurE);
    $('#form-joinus-email').bind(($.browser.opera ? "keypress" : "keydown"), function(event){
        lastKeyPressCode = event.keyCode;
        switch(event.keyCode) {
            case KEY.UP:
                event.preventDefault();
//                onChange(0, true);
                break;

            case KEY.DOWN:
                event.preventDefault();
//                onChange(0, true);
                break;

            case KEY.PAGEUP:
                event.preventDefault();
//                onChange(0, true);
                break;

            case KEY.PAGEDOWN:
                event.preventDefault();
//                onChange(0, true);
                break;

            // matches also semicolon
            case KEY.TAB:
            case KEY.RETURN:

                break;

            case KEY.ESC:
                break;

            default:
                clearTimeout(timeout);
                timeout = setTimeout(onChange, 400);
                break;
        }
    });


});


function initFormJoinUs (lang, errorMessage, errorMessages, errorMessageEmail) {
    update_country_by_ajax({
        'val' : false,
        'el' : '#form-joinus-country, #front-form-country',
        'lang' : lang
    });
    jQuery.validator.messages.required = "";
    var form_joinus = $("#form-joinus").validate({
        showErrors: function(errorMap, errorList) {
             var errors = form_joinus.numberOfInvalids();
            if (errors) {
                var message = errors == 1
                    ? errorMessage
                    : errorMessages;
                $("div.error span").html(message.replace('{0}', errors));
                $("div.error").show();
            } else {
                $("div.error").hide();
            }
            this.defaultShowErrors();
        },
        errorPlacement: function(error, element) {
                var html = error.html();
                if ('' !== html){
                    $("div.error span").html(html);
                    $("div.error").show();
                    $.colorbox.resize();
                } else {
                   var errors = form_joinus.numberOfInvalids();
                    if (errors) {
                        var message = errors == 1
                            ? errorMessage
                            : errorMessages;
                        $("div.error span").html(message.replace('{0}', errors));
                        $("div.error").show();
                    } else {
                        $("div.error").hide();
                    }
                }
        },
        /*invalidHandler: function(e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                var message = errors == 1
                    ? 'You missed 1 field. It has been highlighted below'
                    : 'You missed ' + errors + ' fields.  They have been highlighted below';
                $("div.error span").html(message);
                $("div.error").show();
            } else {
                $("div.error").hide();
            }
            $.colorbox.resize();
        },*/
        onkeyup: false,
        submitHandler: function(form) {
            $("div.error").hide();
            send_lightboxform(form);
        },
        messages: {
            Email: {
                required: "",
                email: errorMessageEmail,
                remote: jQuery.validator.format("{0} is already taken, please enter a different address.")
            }
        },
        debug:true
    });
}

/*  common/js/frontcounter.js  */
function FrontCounter(id, type, cid, undef, thousand_separator) {
    type = (type === undef ? 'total' : type);
    this['frontcounter_' + type] = {};
    var fc  = this['frontcounter_' + type];
    fc.id   = id;
    fc.type = type;
    fc.cid = (cid === undef ? 0 : parseInt(cid));
    fc.num  = 0;
    fc.max  = 0;
    fc.timerId;
    fc.plus = 1;
    fc.timeout = 0;
    fc.first_ajax = true;
    fc.ajax_counter_timer;
    fc.thousand_separator = typeof thousand_separator === 'undefined' ? ',' : thousand_separator;

    fc.showCounter = function() {
        document.getElementById(fc.id).innerHTML = '' + fc.addCommas(fc.num);
    }

    fc.getSumm = function (nnm, nnm2)
    {
        var rand;
        if (nnm2<10)
        {
            rand = nnm + 1
            timeout = 1200;
        }
        else if (nnm2<100)
        {
            rand = nnm + Math.floor((Math.random()*9)+1);
            timeout = 0;
        }
        else if (nnm2<1000)
        {
            rand  = nnm + Math.floor((Math.random()*91)+10);
            timeout = 100;
        }
        else if (nnm2 < 10000)
        {
            rand  = nnm + Math.floor((Math.random()*901)+100);
            timeout = 100;
        }
        else if (nnm2 < 100000)
        {
            rand  = nnm + Math.floor((Math.random()*2001)+1000);
            timeout = 100;
        }
        else if (nnm2 < 1000000)
        {
            rand  = nnm + Math.floor((Math.random()*10001)+1000);
            timeout = 100;
        }
        else if (nnm2 <= 100000000)
        {
            rand  = nnm + Math.floor((Math.random()*800000)+10000);
            timeout = 100;
        }
        else
        {
            rand = nnm + fc.plus;
        }
        return rand;
    }

    fc.startCounter = function()
    {
        var rand;
        if (fc.timerId)
        {
            clearTimeout(fc.timerId);
        }
        if (fc.num <= fc.max)
        {
            fc.showCounter();
            rand = fc.getSumm(fc.num, fc.max);
            if(rand > fc.max)
            {
                var num2 = fc.max - fc.num;
                fc.num = fc.getSumm(fc.num, num2);
            }
            else
            {
                fc.num = rand;
            }
            if (timeout > 10)
         fc.timerId = setTimeout(fc.startCounter, timeout);
        else {
         fc.timerId = false;
         fc.startCounter();
        }
            fc.timerId = setTimeout(fc.startCounter, timeout);
        } else if (fc.first_ajax) {
            fc.ajaxCounter();
        }

    }
    fc.addCommas = function(nStr)
    {
        nStr += '';
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + fc.thousand_separator + '$2');
        }
        return x1 + x2;
    }
    fc.ajaxCounter = function() {
        if (fc.ajax_counter_timer) {
            clearTimeout(fc.ajax_counter_timer);
        }

        $.ajax({
            url: '/act/ajax_counter.php?type=' + fc.type + (fc.cid ? '&cid=' + fc.cid : '') + (fc.lang ? '&lang=' + fc.lang : ''),
            dataType: 'json',
            type: 'GET',
            success: function (json) {
                var slowdown = false;
                if (json) {
                    if (0 == json.paused) {
                        if(Math.abs(fc.max - json.total) < 10) {
                            slowdown = true;
                        }
                        fc.max = json.total;
                    }
                }
                fc.first_ajax = false;
                fc.startCounter();
                fc.ajax_counter_timer = setTimeout(fc.ajaxCounter, slowdown ? 40000 : 20000);
            }
        });
    };
    fc.startCounter();
}

/*  common/js/user_activity2.js  */
if (!window.UserActivityStream) {
    function empty (mixed_var) {
	var key;
	if (mixed_var === "" ||
	    mixed_var === 0 ||
	    mixed_var === "0" ||
	    mixed_var === null ||
	    mixed_var === false ||
	    typeof mixed_var === 'undefined'
	){
	    return true;
	}
	if (typeof mixed_var == 'object') {
	    for (key in mixed_var) {
		return false;
	    }
	    return true;
	}
	return false;
    }
    function UserActivityStream(type, load_id, cid, uid, blurbs, limit, lang, width, rtl) {
	this['UserActivityStream_' + type] = {};
	var self = this['UserActivityStream_' + type];
    self.version = 2;
	self.load_id = load_id;
	self.$load_id = $('#' + load_id);
	self.type = type;//ua or fua
	self.key = Math.floor(Math.random() * 9999999);
	self.cid = cid;
	self.uid = uid;
	self.blurbs = blurbs;
	self.limit = limit;
	self.lang = lang;
	self.width = width;
	self.load_type = 'ajax'; // can be 'ajax' = same server and 'script' = debug from other server
	self.load_limit = self.limit * 3;
	self.overload_time = 5000;
	self.additional_time = 5;
	self.ajax_timeout;
	self.shownext_timeout;
	self.use_translate = false;
	self.one_user_time = 0;
	self.QUEUE = [];
	self.data = [];
	self.static_height = false;
	self.loaded_limit = 0;
	self.updater_time_id;
	self.loaded = {};
	self.rtl = rtl;
	self.loggin = false;
	self.entries_cnt = 0;
	self.load = function () {
	    self.loadActivity();
	    self.timeUpdater();
	}
	self.timeUpdater = function() {
	    var updatetime = false;
	    if(self.updater_time_id) {
		clearTimeout(self.updater_time_id);
		updatetime = true;
	    }
	    if(0 < self.QUEUE.length &&  true === updatetime) {
		self.updateOldEntry(1);
		self.updateOldEntryHTML();
	    }
	    self.updater_time_id = setTimeout(self.timeUpdater, 1200);
	}
	/**
	*   Function for remove data from array and update array length;
	*
	**/
	self.remove = function (list, index) {
	    for (var i=index+1; i<list.length; ++i)
		list[i-1] = list[i];
	    list.length--;
	}
	self.log = function (what, name) {
	    if (!self.loggin) {
		return;
	    }
	    if (name) {
		console.log(' -- ' + name + ' -- ');
	    }
	    console.log(what);
	}
	/**
	*    function for load new data that came from ajax request
	*/
	self.load_data = function() {
	    var first_load = false;
	    var newEntry;
	    if (empty(self.QUEUE)) {
		self.loadDataConteiner();
		self.loadActivityHTML(self.data, true);
		self.showNext();
	    } else {
		var newEntry = self.getNewEntry(self.data);
		self.entries_cnt = newEntry.length;
		self.QUEUE = self.setQUEUE(newEntry, self.QUEUE);
		self.loadActivityHTML(newEntry, false);
	    }
	}
	/**
	*   Update html for one entry with new time
	*
	**/
	self.updateOneOldEntryHTML = function(user) {
	    $('#prettytime_u_'+self.key+'_u_'+user.id, self.$load_id).html(self.prettyDate(user.last_date));
	}
	/**
	*   Update html for entries with new time
	*
	**/
	self.updateOldEntryHTML = function() {
	    for(var h in self.QUEUE) {
		self.updateOneOldEntryHTML(self.QUEUE[h]);
	    }
	}
	/**
	*   Show list with slideshow effect
	**/
	self.showNext= function() {
	    if(self.shownext_timeout) {
		clearTimeout(self.shownext_timeout);
	    }
	    if (self.loaded_limit >= self.limit && false === self.static_height){
		if (3 < $('#ua_container', self.$load_id).height()) {
		self.static_height = true;
		$('#ua_container', self.$load_id).css({height:($('#ua_container', self.$load_id).height() + 3) + 'px', overflow:'hidden'});
	    }

	    }
	    if(self.QUEUE.length > self.limit) {
		var last = self.QUEUE.length - 1;
		var first = self.QUEUE.length - self.limit -1;
		var lastid = self.QUEUE[last].id;
		var lastidminus1 = self.QUEUE[last - 1].id;
		$('#activity_user_id_'+self.QUEUE[first+1].id, self.$load_id).removeClass('first');
		$('#activity_user_id_'+self.QUEUE[first].id, self.$load_id).addClass('first');
		self.QUEUE[first].last_date = 0;
		self.updateOneOldEntryHTML(self.QUEUE[first]);
		$('#activity_user_id_'+self.QUEUE[first].id, self.$load_id).slideDown(1000,
		    function(){
			$('#activity_user_id_' + lastid, self.$load_id).remove();
		self.remove(self.QUEUE, last);
		self.shownext_timeout = setTimeout(self.showNext, 1500);
		    }
		);
	    } else {
		self.shownext_timeout = setTimeout(self.showNext, 1500);
	    }

	}
	/**
	*   Update time for old entries
	*
	*   time in seconds
	*
	**/
	self.updateOldEntry = function(time) {
	    for(h in self.QUEUE) {
                self.QUEUE[h].last_date = (1 * self.QUEUE[h].last_date) + (1 * (time?time:self.additional_time));
	    }
	}
	/**
	*   Get new entry that not loaded
	**/
	self.getNewEntry = function(entries) {
	    var newentries = [];
	    for(h in entries) {
		var entry = entries[h];
		if (!self.loaded[entry.id])
		    newentries.push(entry);
	    }
	    return newentries;
	}
	/**
	*   Update queue with new entries
	**/
	self.setQUEUE = function (newdata, data) {
	    var mdata = [];
	    for(var h in newdata) {
		mdata.push(newdata[h]);
	    }
	    for(var h in data) {
		mdata.push(data[h]);
	    }
	    return mdata;
	}
	/**
	*   Create html for entries on campaign page
	*
	**/
	self.getActivityHTML = function (data, first_load) {
        var html ='';
        if (true === first_load) {
            for (var h = data.length; h > self.limit; h--) {
                var index = h -1;
                self.loaded[data[index].id] = true;
                self.remove(data, index);
            }
        }
        for(var h in data) {
            //if (self.loaded_limit >= self.limit && true === first_load) break;
            var user = data[h];
            if (self.loaded[user.id]) {
                continue;
            }
            if (true === first_load) {
                self.QUEUE[h] = data[h];
            }
            self.loaded[user.id] = true;
            self.loaded_limit++;
            if (/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(user.name)) {
                continue;
            }
            html += '<li id="activity_user_id_'+user.id+'"  style="'+(self.loaded_limit > self.limit?'display:none;':'')+'"  class="' + ((1 == (h + 1) && true === first_load)?' first':'')+ '">';
            if ('' == self.rtl) {
                html += '    <div class="time-ago" id="prettytime_u_'+self.key+'_u_'+user.id+'">' +self.prettyDate(user.last_date)+'</div>';
                //html += '    <div class="flag"><img src="/new/images/blue/flags/fr.png" width="29" height="35" alt="fr" style="background-image: url(/images/flags/' + (user.cc+'').toLowerCase() +'.gif); background-position:7px 7px;background-repeat: no-repeat;"/></div>';
                html += '    <div class="flag">';
                html += '       <div class="flag-place">';
                html += '           <span class="flag-' + (user.cc+'').toLowerCase() +' user_activity_flag23x14"><img src="/images/spacer.gif" /></span><span class="ua-flag-overground"><img src="/images/spacer.gif" /></span>';
                html += '       </div>';
                html += '    </div>';
                html += '    <div class="info">';
                html += '        <p class="person"><big>' + (user.name?user.name:'Laila') + '</big>, ' + (user.country?user.country:'Afghanistan') + (!empty(self.show_region) && !empty(user.st)?', ' + user.st:'') + '</p>';
                html += '    </div>';
            } else {
                html += '    <div class="info">';
                html += '        <p class="person"><big>' + (user.name?user.name:'Laila') + '</big>, ' + (user.country?user.country:'Afghanistan') + (!empty(self.show_region) && !empty(user.st)?', ' + user.st:'') + '</p>';
                html += '    </div>';
                //html += '    <div class="flag"><img src="/new/images/blue/flags/fr.png" width="29" height="35" alt="fr" style="background-image: url(/images/flags/' + (user.cc+'').toLowerCase() +'.gif); background-position:7px 7px;background-repeat: no-repeat;"/></div>';
                html += '    <div class="flag">';
                html += '       <div class="flag-place">';
                html += '           <span class="flag-' + (user.cc+'').toLowerCase() +' user_activity_flag23x14"><img src="/images/spacer.gif" /></span><span class="ua-flag-overground"><img src="/images/spacer.gif" /></span>';
                html += '       </div>';
                html += '    </div>';
                html += '    <div class="time-ago" id="prettytime_u_'+self.key+'_u_'+user.id+'">' +self.prettyDate(user.last_date)+'</div>';
            }

            html += '</li>';
            //html += '<li style="'+(self.loaded_limit > self.limit?'display:none;':'')+'" class="Comment ' + ((self.limit == (h + 1) && true === first_load)?' Last':'')+ '" id="activity_user_id_'+user.id+'" ><table celpadding="0" cellspacing="0" width="100%"><tr><td><img src="/images/spacer.gif" style="width:16px; height:11px;background-image: url(/images/flags/all-images.png); background-repeat: no-repeat;" class="'+ 'sprite-' + (user.cc+'').toLowerCase() +'"/>&nbsp;&nbsp;' + (user.name?user.name:'Laila') + ',&nbsp;<span style="font-size:11px; color:#6D6E70;">' + (user.country?user.country:'Afghanistan') + '</span></td><td><div style="text-align:right;"><em style="font-size:11px;" id="prettytime_u_'+self.key+'_u_'+user.id+'">' +self.prettyDate(user.last_date)+'</em></div></td></tr><tr><td colspan="2"><a style="padding-left:24px;" href="/'+(user.lang?user.lang:'en')+'/'+user.cn+'/?fpla">'+(empty(user.ct)?user.cn.toLowerCase():user.ct.toLowerCase())+'</a></td></tr></table></li>';

        }
        return html;
	}
	/**
	*   Create html for entries on front page
	*
	**/
	 self.getActivityFUAHTML = function (data, first_load) {
	    var html ='';

        // Adds 'www.' to the start of domains without subdomains
        var url_domain = '';
        if ((typeof window.location.protocol !== "undefined") && (typeof window.location.hostname !== "undefined")) {
            url_domain = window.location.protocol + '//';
            if (window.location.hostname.split('.')[0].toLowerCase() == 'avaaz') {
                url_domain += 'https:' === window.location.protocol?'secure.':'www.';
            }
            url_domain += window.location.hostname;
        }
        url_domain += '/';

	    if (true === first_load) {
		for (var h = data.length; h > self.limit; h--) {
		    var index = h -1;
		    self.loaded[data[index].id] = true;
		    self.remove(data, index);
		}
	    }
	    for(h in data) {
		var user = data[h];
		if (self.loaded[user.id]) {
		    continue;
		}
		if (true === first_load) {
		    self.QUEUE[h] = data[h];
		}
		self.loaded[user.id] = true;
		self.loaded_limit++;
		if (/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(user.name)) {
		    continue;
		}
		html += '<li id="activity_user_id_'+user.id+'"  style="'+(self.loaded_limit > self.limit?'display:none;':'')+'"  class="' + ((1 == (h + 1) && true === first_load)?' first':'')+ '">';
		if ('' == self.rtl) {
		    html += '    <div class="time-ago" id="prettytime_u_'+self.key+'_u_'+user.id+'">' +self.prettyDate(user.last_date)+'</div>';
		    //html += '    <div class="flag"><img src="/new/images/blue/ua_flag_bg.png" width="27" height="31" alt="fr" style="background-image: url(/images/flags/' + (user.cc+'').toLowerCase() +'.gif); background-position:7px 7px;background-repeat: no-repeat;"/></div>';
		    html += '    <div class="flag">';
		    html += '       <div class="flag-place">';
		    html += '           <span class="flag-' + (user.cc+'').toLowerCase() +' user_activity_flag23x14"><img src="/images/spacer.gif" /></span><span class="ua-flag-overground"><img src="/images/spacer.gif" /></span>';
		    html += '       </div>';
		    html += '    </div>';
		    html += '    <div class="info">';
		    html += '        <p class="person"><big>' + (user.name?user.name:'Laila') + '</big>, ' + (user.country?user.country:'Afghanistan') + '</p>';
		    html += '        <p class="action"><a href="'+url_domain+(user.lang?user.lang:'en')+'/'+user.cn+'/?fpla">'+(empty(user.ct)?user.cn.toLowerCase():user.ct.toLowerCase())+'</a></p>';
		    html += '    </div>';
		} else {
		    html += '    <div class="info">';
		    html += '        <p class="person"><big>' + (user.name?user.name:'Laila') + '</big>, ' + (user.country?user.country:'Afghanistan') + '</p>';
		    html += '        <p class="action"><a href="'+url_domain+(user.lang?user.lang:'en')+'/'+user.cn+'/?fpla">'+(empty(user.ct)?user.cn.toLowerCase():user.ct.toLowerCase())+'</a></p>';
		    html += '    </div>';
		    //html += '    <div class="flag"><img src="/new/images/blue/flags/fr.png" width="29" height="35" alt="fr" style="background-image: url(/images/flags/' + (user.cc+'').toLowerCase() +'.gif); background-position:7px 7px;background-repeat: no-repeat;"/></div>';
		    html += '    <div class="flag">';
		    html += '       <div class="flag-place">';
		    html += '           <span class="flag-' + (user.cc+'').toLowerCase() +' user_activity_flag23x14"><img src="/images/spacer.gif" /></span><span class="ua-flag-overground"><img src="/images/spacer.gif" /></span>';
		    html += '       </div>';
		    html += '    </div>';
		    html += '    <div class="time-ago" id="prettytime_u_'+self.key+'_u_'+user.id+'">' +self.prettyDate(user.last_date)+'</div>';

		}

		html += '</li>';
		//html += '<li style="'+(self.loaded_limit > self.limit?'display:none;':'')+'" class="Comment ' + ((self.limit == (h + 1) && true === first_load)?' Last':'')+ '" id="activity_user_id_'+user.id+'" ><table celpadding="0" cellspacing="0" width="100%"><tr><td><img src="/images/spacer.gif" style="width:16px; height:11px;background-image: url(/images/flags/all-images.png); background-repeat: no-repeat;" class="'+ 'sprite-' + (user.cc+'').toLowerCase() +'"/>&nbsp;&nbsp;' + (user.name?user.name:'Laila') + ',&nbsp;<span style="font-size:11px; color:#6D6E70;">' + (user.country?user.country:'Afghanistan') + '</span></td><td><div style="text-align:right;"><em style="font-size:11px;" id="prettytime_u_'+self.key+'_u_'+user.id+'">' +self.prettyDate(user.last_date)+'</em></div></td></tr><tr><td colspan="2"><a style="padding-left:24px;" href="/'+(user.lang?user.lang:'en')+'/'+user.cn+'/?fpla">'+(empty(user.ct)?user.cn.toLowerCase():user.ct.toLowerCase())+'</a></td></tr></table></li>';

	    }
	    return html;
	}

	/**
	*    Add new entries on the page
	*
	**/

	self.loadActivityHTML = function(data, first_load) {
	    var html = '';
	    if ('fua' === self.type) {
		html = self.getActivityFUAHTML(data, first_load);
	    } else {
		html = self.getActivityHTML(data, first_load);
	    }
	    if (!empty(html)) {
		$('#ua_scroll_block', self.$load_id).after(html);
	    }
	}
	self.loadDataConteiner = function () {
	    $('#block-happening-live', self.$load_id).html(self.getDataConteinerHTML());
	    $('.title-ribbon, .photo-ribbon', '#block-happening-live', self.$load_id).wrap('<div class="rtlwrap">');
	}
	self.getDataConteinerHTML = function () {
	    var html = '';
		html += '<div class="block-inner">';
		html += '    <div class="title-ribbon"><h2 class="title" '+self.rtl+'>'+('ua' === self.type?self.blurbs.RecentPetitionSigners:self.blurbs.HappeningRightNow)+'</h2></div>';
		html += '    <div class="content">';
		html += '        <div class="content-top"></div>';
		html += '        <div class="content-mid" id="ua_container" '+self.rtl+'>';
		html += '            <ul id="happening-scroller">';
		html += '            <li id="ua_scroll_block" style="display:none;"></li>';
		html += '            </ul>';
		html += '        </div>';
		html += '        <div class="content-btm"></div>';
		html += '    </div>';
		html += '</div>';
	    return html;
	}
	self.sort_by_date = function (a, b) {
	    if (a.last_date == b.last_date){
		return 0;
	    }
	    return (a.last_date < b.last_date)?-1:1;
	}
	self.ajaxLoad = function () {
		if(self.ajax_timeout) {
			clearTimeout(self.ajax_timeout);
		}
	    if (self.QUEUE.length > self.limit) {
		self.ajax_timeout = setTimeout(self.ajaxLoad, self.overload_time);
		return;
	    }
	    $.ajax({ url:'/act/get_user_activity.php', dataType: 'json', type: 'GET', data:{cid: self.cid, lang: self.lang, uid: self.uid, /*time: self.one_user_time,*/ type: self.type}, success:function(data) {
		self.one_user_time = self.one_user_time + self.additional_time;
		if (data.disabled) {
		    self.showDisableActivity();
		} else {
		    data.sort(self.sort_by_date);
		    self.data = data;
		    self.load_data();
		    self.ajax_timeout = setTimeout(self.ajaxLoad, self.overload_time);
		}
	    }});
	}
	self.scriptLoad = function () {
	    if(self.ajax_timeout) {
			clearTimeout(self.ajax_timeout);
	    }
	    if ((self.QUEUE.length) > self.limit) {
			self.ajax_timeout = setTimeout(self.scriptLoad, self.overload_time);
			return;
	    }
	    $.ajax({
			url:'/act/get_user_activity.php',
			dataType: 'jsonp',
			jsonpCallback: 'UserActivityCallback.dataLoader',
			type: 'GET',
			data:{cid: self.cid, lang: self.lang, uid: self.uid, /*time: self.one_user_time,*/ type: self.type}});
	}
	self.dataLoader = function (data) {
		self.one_user_time = self.one_user_time + self.additional_time;
		if (data.disabled) {
		    self.showDisableActivity();
		} else {
		    data.sort(self.sort_by_date);
		    self.data = data;
		    self.load_data();
		    self.ajax_timeout = setTimeout(self.scriptLoad, (self.entries_cnt > self.limit)?1500:self.overload_time);
		}
		$('script','head').filter(function(){
		    if (/act\/get_user_activity.php/.test(this.src)){
			return true;
		    }
		    return false;
		}).each(function(){$(this).remove();});
	}
	self.loadActivity = function () {
	    switch (self.load_type) {
		case 'ajax':
		    self.ajaxLoad();
		    break;
		case 'script':
		    self.scriptLoad();
		    break;
	    }
	}
	/**
	* INSERT ELEMT INTO HEADER
	*/
	self.insert = function (element) {
	    (document.getElementsByTagName('HEAD')[0] || document.body).appendChild(element);
	}

	self.addConteiner = function() {
	    if ('' !== self.load_id) {
		$('#'+self.load_id).html(self.getConteinerHTML());
	    } else {
		document.write(self.getConteinerHTML());
	    }

	}

	self.getConteinerHTML = function() {
	    var html = '';
	    html += '<div id="block-happening-live" class="block row-1 row-first block-blue block-ribbontitle block-scroller"><table width="100%"><tr><td align="center" valign="middle"><img src="/images/ajax-loader.gif"/></td></tr></table></div>';

	    return html;
	}
	self.prettyDate = function (time){
	    var date = new Date((time.toString() || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
		    //diff = (((_self.calcTime('0')).getTime() - date.getTime()) / 1000),
		diff = parseInt(time),
		    day_diff = Math.floor(diff / 86400);
	    if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
		    return self.blurbs.PrettyTimeMonthAgo;

	    return day_diff == 0 && (
			    diff < 5 && self.blurbs.PrettyTimeJustNow.replace("{time}", diff) ||
		    diff < 60 && self.blurbs.PrettyTimeSecondsAgo.replace("{time}", diff) ||
			    diff < 120 && self.blurbs.PrettyTimeMinuteAgo.replace("{time}", diff) ||
			    diff < 3600 && self.blurbs.PrettyTimeMinutesAgo.replace("{time}", Math.floor( diff / 60 )) ||
			    diff < 7200 && self.blurbs.PrettyTimeHourAgo ||
			    diff < 86400 && self.blurbs.PrettyTimeHoursAgo.replace("{time}", Math.floor( diff / 3600 ))) ||
			    day_diff == 1 && self.blurbs.PrettyTimeYesterday ||
			    day_diff < 7 && self.blurbs.PrettyTimeDaysAgo.replace("{time}", day_diff) ||
			    day_diff < 31 && self.blurbs.PrettyTimeWeeksAgo.replace("{time}", Math.ceil( day_diff / 7 ));
	}
	/**************CONSTRUCTOR ACTION***************/
	window['UserActivityCallback'] = self;
	self.addConteiner();
	$(document).ready(function(){self.load();});
	/*********END OF CONSTRUCTOR ACTION*************/
    };
};

/*  new/common/js/async_done.js  */
function async_load_function() {
    if (typeof(async_load) != 'undefined' && async_load) {
	var func = async_load.pop();
	while (func) {
	    func();
	    func = async_load.pop();
	};
    }
    setTimeout(async_load_function,1000);
};
async_load_function();
