﻿var QSite = {
                'comment' : function(url) {
                    return;
                }
                , 'share' : function(url) {
                    //We have to attach a click event to the Add this widget's close button
					setTimeout("QSite.addthisHook();", 100);
                    addthis_sendto();
                }
				, 'addthisHook': function() {
					if(typeof(_atw) == "undefined") {
						setTimeout("QSite.addthisHook();", 50);
						return;
					}
                    if(typeof(_atw._clb_old) == "undefined") {
						_atw._clb_old = _atw.clb;
						_atw.clb = function() {
							QSite.unPauseSwf('#flashcontent');
							return _atw._clb_old();
						}
                    }
				}
                , 'modalPanel': function(el, offsetSelector) 
                        {
                            var ovr = $('<div></div>').attr({'class':'overlay-container'}).append($('<div></div>').attr({'class':'overlay-content'})).append($('<span></span>').attr({'class':'close'}));
                            
                            if (el)
                            {
                                $(el).each(function() {$(ovr).find('.overlay-content').append($(this).contents())});
                            }
                            
                            ovr.destroy = function(){
                                if ($(el))
                                {
                                    $(el).append($(ovr).contents());
									$(el).find('.close').remove();
									try 
									{
									    QSite.unPauseSwf('#flashcontent');
									}
									catch(e)
									{
									}
                                }
                                $(this).fadeOut(500).contents().each(function(){$(this).remove()}).remove();
                                $(window).resize(function(){});
                            }
                            
                            ovr.resize = $(ovr).css({'top':($(offsetSelector).offset().top + 20) + 'px', 'left':($(offsetSelector).offset().left + 20) + 'px','width':($(offsetSelector).width() - 40) + 'px','height':($(offsetSelector).height() - 40) + 'px'});
                            
                            
                            $(ovr)  .find('.close')
                                    .each(function(){
                                        $(this) .append($('<a></a>')
                                                .attr({'href':'#','onclick':'return false;'})
                                                .append('<span class="white">Close</span>X')
                                     )}
                            )        .bind( "click"
                                            , ovr
                                            , function() {
                                                ovr.destroy();
                                            });
                            
                            $(window).bind("resize", this, function() {$(ovr).css({'top':($(offsetSelector).offset().top + 20) + 'px', 'left':($(offsetSelector).offset().left + 20) + 'px','width':($(offsetSelector).width() - 40) + 'px','height':($(offsetSelector).height() - 40) + 'px'});});
                            
                            $('body').append(ovr);
                            $('.overlay-container').animate({'opacity':0},0).animate({'opacity':'.9'},500);
                        }
                    ,'unPauseSwf':function(el)
                    {
                        if(el){
                            $(el).get(0).unpauseFlash();
                        }
                    }
                };