/*
 * jqModal - Minimalist Modaling with jQuery
 *   (http://dev.iceburg.net/jquery/jqModal/)
 *
 * Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 * 
 * $Version: 03/01/2009 +r14
 */
(function($) {
$.fn.jqm=function(o){
var p={
overlay: 50,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: F,
ajaxText: '',
target: F,
modal: F,
toTop: F,
onShow: F,
onHide: F,
onLoad: F
};
return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;
H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};
if(p.trigger)$(this).jqmAddTrigger(p.trigger);
});};

$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};
$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};
$.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t);});};
$.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)});};

$.jqm = {
hash:{},
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);
 if(c.modal) {if(!A[0])L('bind');A.push(s);}
 else if(c.overlay > 0)h.w.jqmAddClose(o);
 else o=F;

 h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;
 if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}

 if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
  r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
 else if(cc)h.w.jqmAddClose($(cc,h.w));

 if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);	
 (c.onShow)?c.onShow(h):h.w.show();e(h);return F;
},
close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
 if(A[0]){A.pop();if(!A[0])L('unbind');}
 if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
 if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
},
params:{}};
var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),F=false,
i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),
e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},
L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() {
 if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};
})(jQuery);


/**
 * Copyright (c) 2005 - 2010, James Auldridge
 * All rights reserved.
 *
 * Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
 *  http://code.google.com/p/cookies/wiki/License
 *
 */
var jaaulde=window.jaaulde||{};jaaulde.utils=jaaulde.utils||{};jaaulde.utils.cookies=(function(){var resolveOptions,assembleOptionsString,parseCookies,constructor,defaultOptions={expiresAt:null,path:'/',domain:null,secure:false};resolveOptions=function(options){var returnValue,expireDate;if(typeof options!=='object'||options===null){returnValue=defaultOptions;}else
{returnValue={expiresAt:defaultOptions.expiresAt,path:defaultOptions.path,domain:defaultOptions.domain,secure:defaultOptions.secure};if(typeof options.expiresAt==='object'&&options.expiresAt instanceof Date){returnValue.expiresAt=options.expiresAt;}else if(typeof options.hoursToLive==='number'&&options.hoursToLive!==0){expireDate=new Date();expireDate.setTime(expireDate.getTime()+(options.hoursToLive*60*60*1000));returnValue.expiresAt=expireDate;}if(typeof options.path==='string'&&options.path!==''){returnValue.path=options.path;}if(typeof options.domain==='string'&&options.domain!==''){returnValue.domain=options.domain;}if(options.secure===true){returnValue.secure=options.secure;}}return returnValue;};assembleOptionsString=function(options){options=resolveOptions(options);return((typeof options.expiresAt==='object'&&options.expiresAt instanceof Date?'; expires='+options.expiresAt.toGMTString():'')+'; path='+options.path+(typeof options.domain==='string'?'; domain='+options.domain:'')+(options.secure===true?'; secure':''));};parseCookies=function(){var cookies={},i,pair,name,value,separated=document.cookie.split(';'),unparsedValue;for(i=0;i<separated.length;i=i+1){pair=separated[i].split('=');name=pair[0].replace(/^\s*/,'').replace(/\s*$/,'');try
{value=decodeURIComponent(pair[1]);}catch(e1){value=pair[1];}if(typeof JSON==='object'&&JSON!==null&&typeof JSON.parse==='function'){try
{unparsedValue=value;value=JSON.parse(value);}catch(e2){value=unparsedValue;}}cookies[name]=value;}return cookies;};constructor=function(){};constructor.prototype.get=function(cookieName){var returnValue,item,cookies=parseCookies();if(typeof cookieName==='string'){returnValue=(typeof cookies[cookieName]!=='undefined')?cookies[cookieName]:null;}else if(typeof cookieName==='object'&&cookieName!==null){returnValue={};for(item in cookieName){if(typeof cookies[cookieName[item]]!=='undefined'){returnValue[cookieName[item]]=cookies[cookieName[item]];}else
{returnValue[cookieName[item]]=null;}}}else
{returnValue=cookies;}return returnValue;};constructor.prototype.filter=function(cookieNameRegExp){var cookieName,returnValue={},cookies=parseCookies();if(typeof cookieNameRegExp==='string'){cookieNameRegExp=new RegExp(cookieNameRegExp);}for(cookieName in cookies){if(cookieName.match(cookieNameRegExp)){returnValue[cookieName]=cookies[cookieName];}}return returnValue;};constructor.prototype.set=function(cookieName,value,options){if(typeof options!=='object'||options===null){options={};}if(typeof value==='undefined'||value===null){value='';options.hoursToLive=-8760;}else if(typeof value!=='string'){if(typeof JSON==='object'&&JSON!==null&&typeof JSON.stringify==='function'){value=JSON.stringify(value);}else
{throw new Error('cookies.set() received non-string value and could not serialize.');}}var optionsString=assembleOptionsString(options);document.cookie=cookieName+'='+encodeURIComponent(value)+optionsString;};constructor.prototype.del=function(cookieName,options){var allCookies={},name;if(typeof options!=='object'||options===null){options={};}if(typeof cookieName==='boolean'&&cookieName===true){allCookies=this.get();}else if(typeof cookieName==='string'){allCookies[cookieName]=true;}for(name in allCookies){if(typeof name==='string'&&name!==''){this.set(name,null,options);}}};constructor.prototype.test=function(){var returnValue=false,testName='cT',testValue='data';this.set(testName,testValue);if(this.get(testName)===testValue){this.del(testName);returnValue=true;}return returnValue;};constructor.prototype.setOptions=function(options){if(typeof options!=='object'){options=null;}defaultOptions=resolveOptions(options);};return new constructor();})();(function(){if(window.jQuery){(function($){$.cookies=jaaulde.utils.cookies;var extensions={cookify:function(options){return this.each(function(){var i,nameAttrs=['name','id'],name,$this=$(this),value;for(i in nameAttrs){if(!isNaN(i)){name=$this.attr(nameAttrs[i]);if(typeof name==='string'&&name!==''){if($this.is(':checkbox, :radio')){if($this.attr('checked')){value=$this.val();}}else if($this.is(':input')){value=$this.val();}else
{value=$this.html();}if(typeof value!=='string'||value===''){value=null;}$.cookies.set(name,value,options);break;}}}});},cookieFill:function(){return this.each(function(){var n,getN,nameAttrs=['name','id'],name,$this=$(this),value;getN=function(){n=nameAttrs.pop();return!!n;};while(getN()){name=$this.attr(n);if(typeof name==='string'&&name!==''){value=$.cookies.get(name);if(value!==null){if($this.is(':checkbox, :radio')){if($this.val()===value){$this.attr('checked','checked');}else
{$this.removeAttr('checked');}}else if($this.is(':input')){$this.val(value);}else
{$this.html(value);}}break;}}});},cookieBind:function(options){return this.each(function(){var $this=$(this);$this.cookieFill().change(function(){$this.cookify(options);});});}};$.each(extensions,function(i){$.fn[i]=this;});})(window.jQuery);}})();


/*
* jQuery Timer Plugin
* http://www.evanbot.com/article/jquery-timer-plugin/23
*
* @version      1.0
* @copyright    2009 Evan Byrne (http://www.evanbot.com)
*/

jQuery.timer = function (time, func, callback) {
    var a = { timer: setTimeout(func, time), callback: null }
    if (typeof (callback) == 'function') { a.callback = callback; }
    return a;
};

jQuery.clearTimer = function (a) {
    clearTimeout(a.timer);
    if (typeof (a.callback) == 'function') { a.callback(); };
    return this;
};



/*
* Facebox (for jQuery)
* version: 1.2 (05/05/2008)
* @requires jQuery v1.2 or later
*
* Examples at http://famspam.com/facebox/
*
* Licensed under the MIT:
*   http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
*
* Usage:
*  
*  jQuery(document).ready(function() {
*    jQuery('a[rel*=facebox]').facebox() 
*  })
*
*  <a href="#terms" rel="facebox">Terms</a>
*    Loads the #terms div in the box
*
*  <a href="terms.html" rel="facebox">Terms</a>
*    Loads the terms.html page in the box
*
*  <a href="terms.png" rel="facebox">Terms</a>
*    Loads the terms.png image in the box
*
*
*  You can also use it programmatically:
* 
*    jQuery.facebox('some html')
*
*  The above will open a facebox with "some html" as the content.
*    
*    jQuery.facebox(function($) { 
*      $.get('blah.html', function(data) { $.facebox(data) })
*    })
*
*  The above will show a loading screen before the passed function is called,
*  allowing for a better ajaxy experience.
*
*  The facebox function can also display an ajax page or image:
*  
*    jQuery.facebox({ ajax: 'remote.html' })
*    jQuery.facebox({ image: 'dude.jpg' })
*
*  Want to close the facebox?  Trigger the 'close.facebox' document event:
*
*    jQuery(document).trigger('close.facebox')
*
*  Facebox also has a bunch of other hooks:
*
*    loading.facebox
*    beforeReveal.facebox
*    reveal.facebox (aliased as 'afterReveal.facebox')
*    init.facebox
*
*  Simply bind a function to any of these hooks:
*
*   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
*
*/
(function ($) {
    $.facebox = function (data, klass, id, settings) {
        if (id == undefined || id == null) {
            ts = new Date();
            ts = ts.getTime();
            id = "facebox" + ts;
        }
        $.facebox.settings.id = id;
        $.facebox.loading(settings);

        if (data.ajax) fillFaceboxFromAjax(data.ajax);
        else if (data.image) fillFaceboxFromImage(data.image);
        else if (data.div) fillFaceboxFromHref(data.div);
        else if ($.isFunction(data)) data.call($);
        else $.facebox.reveal(data, klass);
    }

    /*
    * Public, $.facebox methods
    */

    $.extend($.facebox, {
        settings: {
            opacity: 0.25,
            overlay: true,
            overlayClosable: false,
            loadingImage: '/Pages/images/contest/loading.gif',
            closeImage: '/Pages/images/contest/closelabel.gif',
            imageTypes: ['png', 'jpg', 'jpeg', 'gif'],
            allowEscape: false,
            id: 'test',
            faceboxHtml: '\
    <div class="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div class="footer"> \
                  <a href="#" class="close"> \
                    <img src="/images/facebox/closelabel.jpg" title="close" class="close_image" /> \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
        },

        loading: function (settings) {
            init(settings);
            if ($('#' + $.facebox.settings.id + ' .loading').length == 1) return true;
            showOverlay();

            $('#' + $.facebox.settings.id + ' .content').empty();
            $('#' + $.facebox.settings.id + ' .body').children().hide().end().
        append('<div class="loading"><img src="' + $.facebox.settings.loadingImage + '"/></div>');

            $('#' + $.facebox.settings.id).css({
                top: getPageScroll()[1] + (getPageHeight() / 10),
                left: 385.5
            }).show();

            if ($.facebox.settings.allowEscape) {
                $(document).bind('keydown.facebox', function (e) {
                    var id = $.facebox.settings.id;
                    if (e.keyCode == 27) $.facebox.close(id);
                    return true;
                })
            }
            $(document).trigger('loading.facebox')
        },

        reveal: function (data, klass) {
            $(document).trigger('beforeReveal.facebox');
            if (klass) $('#' + $.facebox.settings.id + ' .content').addClass(klass);
            $('#' + $.facebox.settings.id + ' .content').append(data);
            $('#' + $.facebox.settings.id + ' .loading').remove();
            $('#' + $.facebox.settings.id + ' .body').children().fadeIn('normal');
            var zi = 100 + ($(".facebox").length * 2);
            $('#' + $.facebox.settings.id).css('z-index', zi).css('left', $(window).width() / 2 - ($('#' + $.facebox.settings.id + ' table').width() / 2));
            $(document).trigger('reveal.facebox').trigger('afterReveal.facebox');
        },

        close: function (id) {
            $(document).trigger('close.facebox', [id]);
            return false
        }
    })

    /*
    * Public, $.fn methods
    */

    $.fn.facebox = function (settings) {
        init(settings);

        function clickHandler() {
            $.facebox.loading(true);

            // support for rel="facebox.inline_popup" syntax, to add a class
            // also supports deprecated "facebox[.inline_popup]" syntax
            var klass = this.rel.match(/facebox\[?\.(\w+)\]?/);
            if (klass) klass = klass[1];

            fillFaceboxFromHref(this.href, klass);
            return false;
        }

        return this.click(clickHandler);
    }

    /*
    * Private methods
    */

    // called one time to setup facebox on this page
    function init(settings) {

        if ($("#" + $.facebox.settings.id + ".facebox").length > 0) return true;

        $(document).trigger('init.facebox');
        makeCompatible();

        var imageTypes = $.facebox.settings.imageTypes.join('|');
        $.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i');

        if (settings) $.extend($.facebox.settings, settings);
        $('form').append($($.facebox.settings.faceboxHtml).attr("id", $.facebox.settings.id));

        var preload = [new Image(), new Image()];
        preload[0].src = $.facebox.settings.closeImage;
        preload[1].src = $.facebox.settings.loadingImage;

        $('#' + $.facebox.settings.id).find('.b:first, .bl, .br, .tl, .tr').each(function () {
            preload.push(new Image());
            preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1');
        })

        $('#' + $.facebox.settings.id + ' .close').click(function (e) {
            e.preventDefault();
            $.facebox.close($(this).parents(".facebox").attr("id"));
        })
        $('#' + $.facebox.settings.id + ' .close_image').attr('src', $.facebox.settings.closeImage);
    }

    // getPageScroll() by quirksmode.com
    function getPageScroll() {
        var xScroll, yScroll;
        if (self.pageYOffset) {
            yScroll = self.pageYOffset;
            xScroll = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
            yScroll = document.documentElement.scrollTop;
            xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
            yScroll = document.body.scrollTop;
            xScroll = document.body.scrollLeft;
        }
        return new Array(xScroll, yScroll)
    }

    // Adapted from getPageSize() by quirksmode.com
    function getPageHeight() {
        var windowHeight;
        if (self.innerHeight) {	// all except Explorer
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowHeight = document.body.clientHeight;
        }
        return windowHeight
    }

    // Backwards compatibility
    function makeCompatible() {
        var $s = $.facebox.settings;

        $s.loadingImage = $s.loading_image || $s.loadingImage;
        $s.closeImage = $s.close_image || $s.closeImage;
        $s.imageTypes = $s.image_types || $s.imageTypes;
        $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml;
    }

    // Figures out what you want to display and displays it
    // formats are:
    //     div: #id
    //   image: blah.extension
    //    ajax: anything else
    function fillFaceboxFromHref(href, klass) {
        // div
        if (href.match(/#/)) {
            var url = window.location.href.split('#')[0];
            var target = href.replace(url, '');
            var mclone = $(target).clone().show();
            $.facebox.reveal(mclone, klass);
            $(target).remove();

            // image
        } else if (href.match($.facebox.settings.imageTypesRegexp)) {
            fillFaceboxFromImage(href, klass);
            // ajax
        } else {
            fillFaceboxFromAjax(href, klass);
        }
    }

    function fillFaceboxFromImage(href, klass) {
        var image = new Image();
        image.onload = function () {
            $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass);
        }
        image.src = href
    }

    function fillFaceboxFromAjax(href, klass) {
        $.get(href, function (data) { $.facebox.reveal(data, klass) })
    }

    function skipOverlay() {
        return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
    }

    function showOverlay() {
        if (skipOverlay()) return

        if ($('#' + $.facebox.settings.id + '_overlay.facebox_overlay').length == 0)
            $("body").append('<div id="' + $.facebox.settings.id + '_overlay" class="facebox_overlay facebox_hide"></div>')

        var id = $.facebox.settings.id;
        var zi = 99 + ($(".facebox").length * 2);

        var over = $('#' + id + '_overlay.facebox_overlay').attr("rel", id).hide().addClass("facebox_overlayBG")
              .css('opacity', $.facebox.settings.opacity)
	          .css('z-index', zi);

        if ($.facebox.settings.overlayClosable) {
            over.click(function () {
                $(document).trigger('close.facebox', [$(this).attr("rel")])
                $(this).remove()
            });
        }
        over.fadeIn(200);
        return false;
    }

    function hideOverlay(id) {
        if (skipOverlay()) return

        if (id != undefined) {
            $('#' + id + '_overlay.facebox_overlay').fadeOut(200, function () {
                $('#' + id + '_overlay.facebox_overlay').removeClass("facebox_overlayBG")
                $('#' + id + '_overlay.facebox_overlay').addClass("facebox_hide")
                $('#' + id + '_overlay.facebox_overlay').remove()
            })
        }
        else {
            $('.facebox_overlay').fadeOut(200, function () {
                $('.facebox_overlay').removeClass("facebox_overlayBG")
                $('.facebox_overlay').addClass("facebox_hide")
                $('.facebox_overlay').remove()
            })
        }

        return false
    }

    /*
    * Bindings
    */

    $(document).bind('close.facebox', function (e, id) {
        $(document).unbind('keydown.facebox')
        if (id != undefined) {
            $('#' + id).fadeOut(function () {
                $('#' + id + ' .content').removeClass().addClass('content')
                hideOverlay(id)
                $('#' + id + ' .loading').remove()
            })
        }
        else {
            $('.facebox').fadeOut(function () {
                $('.facebox .content').removeClass().addClass('content')
                hideOverlay()
                $('.facebox .loading').remove()
            })
        }

    })

})(jQuery);

/*
* nyroModal v2.0.0
* Core
*
* Commit a771d6237dc7c3a278f6 (05/07/2011) * 
* 
* Included parts:
* - anims.fade
* - filters.title
* - filters.gallery
* - filters.link
* - filters.dom
* - filters.data
* - filters.image
* - filters.swf
* - filters.form
* - filters.formFile
* - filters.iframe
* - filters.iframeForm
* - filters.embedly
*/
/*
* nyroModal v2.0.0
* Core
*
*/
jQuery(function ($, undefined) {

    var $w = $(window),
		$d = $(document),
		$b = $('body'),
		baseHref = $('base').attr('href'),
    // nyroModal Object
		_nmObj = {
		    filters: [], // List of filters used
		    callbacks: {}, // Sepcific callbacks
		    loadFilter: undefined, // Name of the filter used for loading

		    modal: false, // Indicates if it's a modal window or not
		    closeOnEscape: true, // Indicates if the modal should close on Escape key
		    closeOnClick: true, // Indicates if a click on the background should close the modal
		    useKeyHandler: false, // Indicates if the modal has to handle key down event

		    showCloseButton: true, // Indicates if the closeButonn should be added
		    closeButton: '<a href="#" class="nyroModalClose nyroModalCloseButton nmReposition" title="close">Close</a>', // Close button HTML

		    stack: false, // Indicates if links automatically binded inside the modal should stack or not
		    nonStackable: 'form', // Filter to not stack DOM element

		    header: undefined, // header include in every modal
		    footer: undefined, // footer include in every modal

		    // Specific confirguation for gallery filter
		    galleryLoop: true, // Indicates if the gallery should loop
		    galleryCounts: true, // Indicates if the gallery counts should be shown
		    ltr: true, // Left to Right by default. Put to false for Hebrew or Right to Left language. Used in gallery filter

		    // Specific confirguation for image filter
		    imageRegex: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', // Regex used to detect image link

		    selIndicator: 'nyroModalSel', // Value added when a form or Ajax is sent with a filter content

		    swfObjectId: undefined, // Object id for swf object
		    swf: {	// Default SWF attributes
		        allowFullScreen: 'true',
		        allowscriptaccess: 'always',
		        wmode: 'transparent'
		    },

		    store: {}, // Storage object for filters.
		    errorMsg: 'An error occured', // Error message
		    elts: {	// HTML elements for the modal
		        all: undefined,
		        bg: undefined,
		        load: undefined,
		        cont: undefined,
		        hidden: undefined
		    },
		    sizes: {	// Size information
		        initW: undefined, // Initial width
		        initH: undefined, // Initial height
		        w: undefined, 	// width
		        h: undefined, 	// height
		        minW: undefined, // minimum Width
		        minH: undefined, // minimum height
		        wMargin: undefined, // Horizontal margin
		        hMargin: undefined	// Vertical margin
		    },
		    anim: {	// Animation names to use
		        def: undefined, 		// Default animation set to use if sspecific are not defined or doesn't exist
		        showBg: undefined, 	// Set to use for showBg animation
		        hideBg: undefined, 	// Set to use for hideBg animation
		        showLoad: undefined, // Set to use for showLoad animation
		        hideLoad: undefined, // Set to use for hideLoad animation
		        showCont: undefined, // Set to use for showCont animation
		        hideCont: undefined, // Set to use for hideCont animation
		        showTrans: undefined, // Set to use for showTrans animation
		        hideTrans: undefined, // Set to use for hideTrans animation
		        resize: undefined		// Set to use for resize animation
		    },

		    _open: false, // Indicates if the modal is open
		    _bgReady: false, // Indicates if the background is ready
		    _opened: false, // Indicates if the modal was opened (useful for stacking)
		    _loading: false, // Indicates if the loading is shown
		    _animated: false, // Indicates if the modal is currently animated
		    _transition: false, //Indicates if the modal is in transition
		    _nmOpener: undefined, // nmObj of the modal that opened the current one in non stacking mode
		    _nbContentLoading: 0, // Counter for contentLoading call
		    _scripts: '', // Scripts tags to be included
		    _scriptsShown: '', //Scripts tags to be included once the modal is swhon

		    // save the object in data
		    saveObj: function () {
		        this.opener.data('nmObj', this);
		    },
		    // Open the modal
		    open: function () {
		        if (this._nmOpener)
		            this._nmOpener._close();
		        this.getInternal()._pushStack(this.opener);
		        this._opened = false;
		        this._bgReady = false;
		        this._open = true;
		        this._initElts();
		        this._load();
		        this._nbContentLoading = 0;
		        this._callAnim('showBg', $.proxy(function () {
		            this._bgReady = true;
		            if (this._nmOpener) {
		                // fake closing of the opener nyroModal
		                this._nmOpener._bgReady = false;
		                this._nmOpener._loading = false;
		                this._nmOpener._animated = false;
		                this._nmOpener._opened = false;
		                this._nmOpener._open = false;
		                this._nmOpener.elts.cont = this._nmOpener.elts.hidden = this._nmOpener.elts.load = this._nmOpener.elts.bg = this._nmOpener.elts.all = undefined;
		                this._nmOpener.saveObj();
		                this._nmOpener = undefined;
		            }
		            this._contentLoading();
		        }, this));
		    },

		    // Resize the modal according to sizes.initW and sizes.initH
		    // Will call size function
		    // @param recalc boolean: Indicate if the size should be recalaculated (useful when content has changed)
		    resize: function (recalc) {
		        if (recalc) {
		            this.elts.hidden.append(this.elts.cont.children().first().clone());
		            this.sizes.initW = this.sizes.w = this.elts.hidden.width();
		            this.sizes.initH = this.sizes.h = this.elts.hidden.height();
		            this.elts.hidden.empty();
		        } else {
		            this.sizes.w = this.sizes.initW;
		            this.sizes.h = this.sizes.initH;
		        }
		        this._unreposition();
		        this.size();
		        this._callAnim('resize', $.proxy(function () {
		            this._reposition();
		        }, this));
		    },

		    // Update sizes element to not go outsize the viewport.
		    // Will call 'size' callback filter
		    size: function () {
		        var maxHeight = this.getInternal().fullSize.viewH - this.sizes.hMargin,
					maxWidth = this.getInternal().fullSize.viewW - this.sizes.wMargin;
		        if (this.sizes.minW && this.sizes.minW > this.sizes.w)
		            this.sizes.w = this.sizes.minW;
		        if (this.sizes.minH && this.sizes.minH > this.sizes.h)
		            this.sizes.h = this.sizes.minH;
		        if (this.sizes.h > maxHeight || this.sizes.w > maxWidth) {
		            // We're gonna resize the modal as it will goes outside the view port
		            this.sizes.h = Math.min(this.sizes.h, maxHeight);
		            this.sizes.w = Math.min(this.sizes.w, maxWidth);
		        }
		        this._callFilters('size');
		    },

		    // Get the nmObject for a new nyroModal
		    getForNewLinks: function (elt) {
		        var ret;
		        if (this.stack && (!elt || this.isStackable(elt))) {
		            ret = $.extend(true, {}, this);
		            ret._nmOpener = undefined;
		            ret.elts.all = undefined;
		        } else {
		            ret = $.extend({}, this);
		            ret._nmOpener = this;
		        }
		        ret.filters = [];
		        ret.opener = undefined;
		        ret._open = false;
		        return ret;
		    },

		    // Indicate if an element can be stackable or not, regarding the nonStackable setting
		    isStackable: function (elt) {
		        return !elt.is(this.nonStackable);
		    },

		    // key handle function.
		    // Will call 'keyHandle' callback filter
		    keyHandle: function (e) {
		        this.keyEvent = e;
		        this._callFilters('keyHandle');
		        this.keyEvent = undefined;
		        delete (this.keyEvent);
		    },

		    // Get the internal object
		    getInternal: function () {
		        return _internal;
		    },

		    // Internal function for closing a nyroModal
		    // Will call 'close' callback filter
		    _close: function () {
		        this.getInternal()._removeStack(this.opener);
		        this._opened = false;
		        this._open = false;
		        this._callFilters('close');
		    },
		    // Public function for closing a nyroModal
		    close: function () {
		        this._close();
		        this._callFilters('beforeClose');
		        var self = this;
		        this._unreposition();
		        self._callAnim('hideCont', function () {
		            self._callAnim('hideLoad', function () {
		                self._callAnim('hideBg', function () {
		                    self._callFilters('afterClose');
		                    self.elts.cont.remove();
		                    self.elts.hidden.remove();
		                    self.elts.load.remove();
		                    self.elts.bg.remove();
		                    self.elts.all.remove();
		                    self.elts.cont = self.elts.hidden = self.elts.load = self.elts.bg = self.elts.all = undefined;
		                });
		            });
		        });
		    },

		    // Init HTML elements
		    _initElts: function () {
		        if (!this.stack && this.getInternal().stack.length > 1)
		            this.elts = this.getInternal().stack[this.getInternal().stack.length - 2]['nmObj'].elts;
		        if (!this.elts.all || this.elts.all.closest('body').length == 0)
		            this.elts.all = this.elts.bg = this.elts.cont = this.elts.hidden = this.elts.load = undefined;
		        if (!this.elts.all)
		            this.elts.all = $('<div />').appendTo(this.getInternal()._container);
		        if (!this.elts.bg)
		            this.elts.bg = $('<div />').hide().appendTo(this.elts.all);
		        if (!this.elts.cont)
		            this.elts.cont = $('<div />').hide().appendTo(this.elts.all);
		        if (!this.elts.hidden)
		            this.elts.hidden = $('<div />').hide().appendTo(this.elts.all);
		        this.elts.hidden.empty();
		        if (!this.elts.load)
		            this.elts.load = $('<div />').hide().appendTo(this.elts.all);
		        this._callFilters('initElts');
		    },

		    // Trigger the error
		    // Will call 'error' callback filter
		    _error: function () {
		        this._callFilters('error');
		    },

		    // Set the HTML content to show.
		    // - html: HTML content
		    // - selector: selector to filter the content
		    // Will init the size and call the 'size' function.
		    // Will call 'filledContent' callback filter
		    _setCont: function (html, selector) {
		        if (selector) {
		            var tmp = [],
						i = 0;
		            // Looking for script to store them
		            html = html
						.replace(/\r\n/gi, 'nyroModalLN')
						.replace(/<script(.|\s)*?\/script>/gi, function (x) {
						    tmp[i] = x;
						    return '<pre class=nyroModalScript rel="' + (i++) + '"></pre>';
						});
		            var cur = $('<div>' + html + '</div>').find(selector);
		            if (cur.length) {
		                html = cur.html()
							.replace(/<pre class="?nyroModalScript"? rel="?(.?)"?><\/pre>/gi, function (x, y, z) { return tmp[y]; })
							.replace(/nyroModalLN/gi, "\r\n");
		            } else {
		                // selector not found
		                this._error();
		                return;
		            }
		        }
		        this.elts.hidden
					.append(this._filterScripts(html))
					.prepend(this.header)
					.append(this.footer)
					.wrapInner('<div class="nyroModal' + ucfirst(this.loadFilter) + '" />');

		        // Store the size of the element
		        this.sizes.initW = this.sizes.w = this.elts.hidden.width();
		        this.sizes.initH = this.sizes.h = this.elts.hidden.height();
		        var outer = this.getInternal()._getOuter(this.elts.cont);
		        this.sizes.hMargin = outer.h.total;
		        this.sizes.wMargin = outer.w.total;

		        this.size();

		        this.loading = false;
		        this._callFilters('filledContent');
		        this._contentLoading();
		    },

		    // Filter an html content to remove the script[src] and store them appropriately if needed
		    // - data: Data to filter
		    _filterScripts: function (data) {
		        if (typeof data != 'string')
		            return data;

		        this._scripts = [];
		        this._scriptsShown = [];
		        var start = 0,
					stStart = '<script',
					stEnd = '</script>',
					endLn = stEnd.length,
					pos,
					pos2,
					tmp;
		        while ((pos = data.indexOf(stStart, start)) > -1) {
		            pos2 = data.indexOf(stEnd) + endLn;
		            tmp = $(data.substring(pos, pos2));
		            if (!tmp.attr('src') || tmp.attr('rel') == 'forceLoad') {
		                if (tmp.attr('rev') == 'shown')
		                    this._scriptsShown.push(tmp.get(0));
		                else
		                    this._scripts.push(tmp.get(0));
		            }
		            data = data.substring(0, pos) + data.substr(pos2);
		            start = pos;
		        }
		        return data;
		    },

		    // Check if the nmObject has a specific filter
		    // - filter: Filter name
		    _hasFilter: function (filter) {
		        var ret = false;
		        $.each(this.filters, function (i, f) {
		            ret = ret || f == filter;
		        });
		        return ret;
		    },

		    // Remove a specific filter
		    // - filter: Filter name
		    _delFilter: function (filter) {
		        this.filters = $.map(this.filters, function (v) {
		            if (v != filter)
		                return v;
		        });
		    },

		    // Call a function against all active filters
		    // - fct: Function name
		    // return an array of all return of callbacks; keys are filters name
		    _callFilters: function (fct) {
		        this.getInternal()._debug(fct);
		        var ret = [],
					self = this;
		        $.each(this.filters, function (i, f) {
		            ret[f] = self._callFilter(f, fct);
		        });
		        if (this.callbacks[fct] && $.isFunction(this.callbacks[fct]))
		            this.callbacks[fct](this);
		        return ret;
		    },

		    // Call a filter function for a specific filter
		    // - f: Filter name
		    // - fct: Function name
		    // return the return of the callback
		    _callFilter: function (f, fct) {
		        if (_filters[f] && _filters[f][fct] && $.isFunction(_filters[f][fct]))
		            return _filters[f][fct](this);
		        return undefined;
		    },

		    // Call animation callback.
		    // Will also call beforeNNN and afterNNN filter callbacks
		    // - fct: Animation function name
		    // - clb: Callback once the animation is done
		    _callAnim: function (fct, clb) {
		        this.getInternal()._debug(fct);
		        this._callFilters('before' + ucfirst(fct));
		        if (!this._animated) {
		            this._animated = true;
		            if (!$.isFunction(clb)) clb = $.noop;
		            var set = this.anim[fct] || this.anim.def || 'basic';
		            if (!_animations[set] || !_animations[set][fct] || !$.isFunction(_animations[set][fct]))
		                set = 'basic';
		            _animations[set][fct](this, $.proxy(function () {
		                this._animated = false;
		                this._callFilters('after' + ucfirst(fct));
		                clb();
		            }, this));
		        }
		    },

		    // Load the content
		    // Will call the 'load' function of the filter specified in the loadFilter parameter
		    _load: function () {
		        this.getInternal()._debug('_load');
		        if (!this.loading && this.loadFilter) {
		            this.loading = true;
		            this._callFilter(this.loadFilter, 'load');
		        }
		    },

		    // Show the content or the loading according to the current state of the modal
		    _contentLoading: function () {
		        if (!this._animated && this._bgReady) {
		            if (!this._transition && this.elts.cont.html().length > 0)
		                this._transition = true;
		            this._nbContentLoading++;
		            if (!this.loading) {
		                if (!this._opened) {
		                    this._opened = true;
		                    if (this._transition) {
		                        var fct = $.proxy(function () {
		                            this._writeContent();
		                            this._callFilters('beforeShowCont');
		                            this._callAnim('hideTrans', $.proxy(function () {
		                                this._transition = false;
		                                this._callFilters('afterShowCont');
		                                this.elts.cont.append(this._scriptsShown);
		                                this._reposition();
		                            }, this));
		                        }, this);
		                        if (this._nbContentLoading == 1) {
		                            this._unreposition();
		                            this._callAnim('showTrans', fct);
		                        } else {
		                            fct();
		                        }
		                    } else {
		                        this._callAnim('hideLoad', $.proxy(function () {
		                            this._writeContent();
		                            this._callAnim('showCont', $.proxy(function () {
		                                this.elts.cont.append(this._scriptsShown);
		                                this._reposition();
		                            }, this));
		                        }, this));
		                    }
		                }
		            } else if (this._nbContentLoading == 1) {
		                var outer = this.getInternal()._getOuter(this.elts.load);
		                this.elts.load
							.css({
							    position: 'fixed',
							    top: (this.getInternal().fullSize.viewH - this.elts.load.height() - outer.h.margin) / 2,
							    left: (this.getInternal().fullSize.viewW - this.elts.load.width() - outer.w.margin) / 2
							});
		                if (this._transition) {
		                    this._unreposition();
		                    this._callAnim('showTrans', $.proxy(function () {
		                        this._contentLoading();
		                    }, this));
		                } else {
		                    this._callAnim('showLoad', $.proxy(function () {
		                        this._contentLoading();
		                    }, this));
		                }
		            }
		        }
		    },

		    // Write the content in the modal.
		    // Content comes from the hidden div, scripts and eventually close button.
		    _writeContent: function () {
		        this.elts.cont
					.empty()
					.append(this.elts.hidden.contents())
					.append(this._scripts)
					.append(this.showCloseButton ? this.closeButton : '')
					.css({
					    position: 'fixed',
					    width: this.sizes.w,
					    height: this.sizes.h,
					    top: (this.getInternal().fullSize.viewH - this.sizes.h - this.sizes.hMargin) / 2,
					    left: (this.getInternal().fullSize.viewW - this.sizes.w - this.sizes.wMargin) / 2
					});
		    },

		    // Reposition elements with a class nmReposition
		    _reposition: function () {
		        var elts = this.elts.cont.find('.nmReposition');
		        if (elts.length) {
		            var space = this.getInternal()._getSpaceReposition();
		            elts.each(function () {
		                var me = $(this),
							offset = me.offset();
		                me.css({
		                    position: 'fixed',
		                    top: offset.top - space.top,
		                    left: offset.left - space.left
		                });
		            });
		            this.elts.cont.after(elts);
		        }
		        this.elts.cont.css('overflow', 'auto');
		        this._callFilters('afterReposition');
		    },

		    // Unreposition elements with a class nmReposition
		    // Exaclty the reverse of the _reposition function
		    _unreposition: function () {
		        this.elts.cont.css('overflow', '');
		        var elts = this.elts.all.find('.nmReposition');
		        if (elts.length)
		            this.elts.cont.append(elts.removeAttr('style'));
		        this._callFilters('afterUnreposition');
		    }
		},
		_internal = {
		    firstInit: true,
		    debug: false,
		    stack: [],
		    fullSize: {
		        w: 0,
		        h: 0,
		        wW: 0,
		        wH: 0,
		        viewW: 0,
		        viewH: 0
		    },
		    nyroModal: function (opts, fullObj) {
		        if (_internal.firstInit) {
		            _internal._container = $('<div />').appendTo($b);
		            $w.smartresize($.proxy(_internal._resize, _internal));
		            $d.bind('keydown.nyroModal', $.proxy(_internal._keyHandler, _internal));
		            _internal._calculateFullSize();
		            _internal.firstInit = false;
		        }
		        return this.nmInit(opts, fullObj).each(function () {
		            _internal._init($(this).data('nmObj'));
		        });
		    },
		    nmInit: function (opts, fullObj) {
		        return this.each(function () {
		            var me = $(this);
		            if (fullObj)
		                me.data('nmObj', $.extend(true, { opener: me }, opts));
		            else
		                me.data('nmObj',
							me.data('nmObj')
								? $.extend(true, me.data('nmObj'), opts)
								: $.extend(true, { opener: me }, _nmObj, opts));
		        });
		    },
		    nmCall: function () {
		        return this.trigger('nyroModal');
		    },

		    nmManual: function (url, opts) {
		        $('<a href="' + url + '"></a>').nyroModal(opts).trigger('nyroModal');
		    },
		    nmData: function (data, opts) {
		        this.nmManual('#', $.extend({ data: data }, opts));
		    },
		    nmObj: function (opts) {
		        $.extend(true, _nmObj, opts);
		    },
		    nmInternal: function (opts) {
		        $.extend(true, _internal, opts);
		    },
		    nmAnims: function (opts) {
		        $.extend(true, _animations, opts);
		    },
		    nmFilters: function (opts) {
		        $.extend(true, _filters, opts);
		    },
		    nmTop: function () {
		        if (_internal.stack.length)
		            return _internal.stack[_internal.stack.length - 1]['nmObj'];
		        return undefined;
		    },

		    _debug: function (msg) {
		        if (this.debug && window.console && window.console.log)
		            window.console.log(msg);
		    },

		    _container: undefined,

		    _init: function (nm) {
		        nm.filters = [];
		        $.each(_filters, function (f, obj) {
		            if (obj.is && $.isFunction(obj.is) && obj.is(nm)) {
		                nm.filters.push(f);
		            }
		        });
		        nm._callFilters('initFilters');
		        nm._callFilters('init');
		        nm.opener
					.unbind('nyroModal.nyroModal nmClose.nyroModal nmResize.nyroModal')
					.bind({
					    'nyroModal.nyroModal': function (e) { nm.open(); return false; },
					    'nmClose.nyroModal': function () { nm.close(); return false; },
					    'nmResize.nyroModal': function () { nm.resize(); return false; }
					});
		    },

		    _scrollWidth: (function () {
		        var scrollbarWidth;
		        if ($.browser.msie) {
		            var $textarea1 = $('<textarea cols="10" rows="2"></textarea>')
							.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo($b),
						$textarea2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>')
							.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo($b);
		            scrollbarWidth = $textarea1.width() - $textarea2.width();
		            $textarea1.add($textarea2).remove();
		        } else {
		            var $div = $('<div />')
						.css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: -1000 })
						.prependTo($b).append('<div />').find('div')
							.css({ width: '100%', height: 200 });
		            scrollbarWidth = 100 - $div.width();
		            $div.parent().remove();
		        }
		        return scrollbarWidth;
		    })(),

		    _selNyroModal: function (obj) {
		        return $(obj).data('nmObj') ? true : false;
		    },

		    _selNyroModalOpen: function (obj) {
		        var me = $(obj);
		        return me.data('nmObj') ? me.data('nmObj')._open : false;
		    },

		    _keyHandler: function (e) {
		        var nmTop = $.nmTop();
		        if (nmTop && nmTop.useKeyHandler) {
		            return nmTop.keyHandle(e);
		        }
		    },
		    _pushStack: function (obj) {
		        this.stack = $.map(this.stack, function (elA) {
		            if (elA['nmOpener'] != obj.get(0))
		                return elA;
		        });
		        this.stack.push({
		            nmOpener: obj.get(0),
		            nmObj: $(obj).data('nmObj')
		        });
		    },
		    _removeStack: function (obj) {
		        this.stack = $.map(this.stack, function (elA) {
		            if (elA['nmOpener'] != obj.get(0))
		                return elA;
		        });
		    },
		    _resize: function () {
		        var opens = $(':nmOpen').each(function () {
		            $(this).data('nmObj')._unreposition();
		        });
		        this._calculateFullSize();
		        opens.trigger('nmResize');
		    },
		    _calculateFullSize: function () {
		        this.fullSize = {
		            w: $d.width(),
		            h: $d.height(),
		            wW: $w.width(),
		            wH: $w.height()
		        };
		        this.fullSize.viewW = Math.min(this.fullSize.w, this.fullSize.wW);
		        this.fullSize.viewH = Math.min(this.fullSize.h, this.fullSize.wH);
		    },
		    _getCurCSS: function (elm, name) {
		        var ret = parseInt($.curCSS(elm, name, true));
		        return isNaN(ret) ? 0 : ret;
		    },
		    _getOuter: function (elm) {
		        elm = elm.get(0);
		        var ret = {
		            h: {
		                margin: this._getCurCSS(elm, 'marginTop') + this._getCurCSS(elm, 'marginBottom'),
		                border: this._getCurCSS(elm, 'borderTopWidth') + this._getCurCSS(elm, 'borderBottomWidth'),
		                padding: this._getCurCSS(elm, 'paddingTop') + this._getCurCSS(elm, 'paddingBottom')
		            },
		            w: {
		                margin: this._getCurCSS(elm, 'marginLeft') + this._getCurCSS(elm, 'marginRight'),
		                border: this._getCurCSS(elm, 'borderLeftWidth') + this._getCurCSS(elm, 'borderRightWidth'),
		                padding: this._getCurCSS(elm, 'paddingLeft') + this._getCurCSS(elm, 'paddingRight')
		            }
		        };

		        ret.h.outer = ret.h.margin + ret.h.border;
		        ret.w.outer = ret.w.margin + ret.w.border;

		        ret.h.inner = ret.h.padding + ret.h.border;
		        ret.w.inner = ret.w.padding + ret.w.border;

		        ret.h.total = ret.h.outer + ret.h.padding;
		        ret.w.total = ret.w.outer + ret.w.padding;

		        return ret;
		    },
		    _getSpaceReposition: function () {
		        var outer = this._getOuter($b),
					ie7 = $.browser.msie && $.browser.version < 8 && !(screen.height <= $w.height() + 23);
		        return {
		            top: $w.scrollTop() - (!ie7 ? outer.h.border / 2 : 0),
		            left: $w.scrollLeft() - (!ie7 ? outer.w.border / 2 : 0)
		        };
		    },

		    _getHash: function (url) {
		        if (typeof url == 'string') {
		            var hashPos = url.indexOf('#');
		            if (hashPos > -1)
		                return url.substring(hashPos);
		        }
		        return '';
		    },
		    _extractUrl: function (url) {
		        var ret = {
		            url: undefined,
		            sel: undefined
		        };

		        if (url) {
		            var hash = this._getHash(url),
						hashLoc = this._getHash(window.location.href),
						curLoc = window.location.href.substring(0, window.location.href.length - hashLoc.length),
						req = url.substring(0, url.length - hash.length);
		            ret.sel = hash;
		            if (req != curLoc && req != baseHref)
		                ret.url = req;
		        }
		        return ret;
		    }
		},
		_animations = {
		    basic: {
		        showBg: function (nm, clb) {
		            nm.elts.bg.css({ opacity: 0.7 }).show();
		            clb();
		        },
		        hideBg: function (nm, clb) {
		            nm.elts.bg.hide();
		            clb();
		        },
		        showLoad: function (nm, clb) {
		            nm.elts.load.show();
		            clb();
		        },
		        hideLoad: function (nm, clb) {
		            nm.elts.load.hide();
		            clb();
		        },
		        showCont: function (nm, clb) {
		            nm.elts.cont.show();
		            clb();
		        },
		        hideCont: function (nm, clb) {
		            nm.elts.cont.hide();
		            clb();
		        },
		        showTrans: function (nm, clb) {
		            nm.elts.cont.hide();
		            nm.elts.load.show();
		            clb();
		        },
		        hideTrans: function (nm, clb) {
		            nm.elts.cont.show();
		            nm.elts.load.hide();
		            clb();
		        },
		        resize: function (nm, clb) {
		            nm.elts.cont.css({
		                width: nm.sizes.w,
		                height: nm.sizes.h,
		                top: (nm.getInternal().fullSize.viewH - nm.sizes.h - nm.sizes.hMargin) / 2,
		                left: (nm.getInternal().fullSize.viewW - nm.sizes.w - nm.sizes.wMargin) / 2
		            });
		            clb();
		        }
		    }
		},
		_filters = {
		    basic: {
		        is: function (nm) {
		            return true;
		        },
		        init: function (nm) {
		            if (nm.opener.attr('rev') == 'modal')
		                nm.modal = true;
		            if (nm.modal)
		                nm.closeOnEscape = nm.closeOnClick = nm.showCloseButton = false;
		            if (nm.closeOnEscape)
		                nm.useKeyHandler = true;
		        },
		        initElts: function (nm) {
		            nm.elts.bg.addClass('nyroModalBg');
		            if (nm.closeOnClick)
		                nm.elts.bg.unbind('click.nyroModal').bind('click.nyroModal', function (e) {
		                    e.preventDefault();
		                    nm.close();
		                });
		            nm.elts.cont.addClass('nyroModalCont');
		            nm.elts.hidden.addClass('nyroModalCont nyroModalHidden');
		            nm.elts.load.addClass('nyroModalCont nyroModalLoad');
		        },
		        error: function (nm) {
		            nm.elts.hidden.addClass('nyroModalError');
		            nm.elts.cont.addClass('nyroModalError');
		            nm._setCont(nm.errorMsg);
		        },
		        beforeShowCont: function (nm) {
		            nm.elts.cont
						.find('.nyroModal').each(function () {
						    var cur = $(this);
						    cur.nyroModal(nm.getForNewLinks(cur), true);
						}).end()
						.find('.nyroModalClose').bind('click.nyroModal', function (e) {
						    e.preventDefault();
						    nm.close();
						});
		        },
		        keyHandle: function (nm) {
		            // used for escape key
		            if (nm.keyEvent.keyCode == 27 && nm.closeOnEscape) {
		                nm.keyEvent.preventDefault();
		                nm.close();
		            }
		        }
		    },

		    custom: {
		        is: function (nm) {
		            return true;
		        }
		    }
		};

    // Add jQuery call fucntions
    $.fn.extend({
        nm: _internal.nyroModal,
        nyroModal: _internal.nyroModal,
        nmInit: _internal.nmInit,
        nmCall: _internal.nmCall
    });

    // Add global jQuery functions
    $.extend({
        nmManual: _internal.nmManual,
        nmData: _internal.nmData,
        nmObj: _internal.nmObj,
        nmInternal: _internal.nmInternal,
        nmAnims: _internal.nmAnims,
        nmFilters: _internal.nmFilters,
        nmTop: _internal.nmTop
    });

    // Add jQuery selectors
    $.expr[':'].nyroModal = $.expr[':'].nm = _internal._selNyroModal;
    $.expr[':'].nmOpen = _internal._selNyroModalOpen;
});

// Smartresize plugin
(function ($, sr) {

    // debouncing function from John Hann
    // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
    var debounce = function (func, threshold, execAsap) {
        var timeout;

        return function debounced() {
            var obj = this, args = arguments;
            function delayed() {
                if (!execAsap)
                    func.apply(obj, args);
                timeout = null;
            };

            if (timeout)
                clearTimeout(timeout);
            else if (execAsap)
                func.apply(obj, args);

            timeout = setTimeout(delayed, threshold || 100);
        };
    };
    // smartresize
    jQuery.fn[sr] = function (fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };

})(jQuery, 'smartresize');
// ucFirst
function ucfirst(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: ucfirst('kevin van zonneveld');
    // *     returns 1: 'Kevin van zonneveld'
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}
/*
* nyroModal v2.0.0
* 
* Fade animations
* 
* Depends:
* 
*/
jQuery(function ($, undefined) {
    $.nmAnims({
        fade: {
            showBg: function (nm, clb) {
                nm.elts.bg.fadeTo(250, 0.7, clb);
            },
            hideBg: function (nm, clb) {
                nm.elts.bg.fadeOut(clb);
            },
            showLoad: function (nm, clb) {
                nm.elts.load.fadeIn(clb);
            },
            hideLoad: function (nm, clb) {
                nm.elts.load.fadeOut(clb);
            },
            showCont: function (nm, clb) {
                nm.elts.cont.fadeIn(clb);
            },
            hideCont: function (nm, clb) {
                nm.elts.cont.css('overflow', 'hidden').fadeOut(clb);
            },
            showTrans: function (nm, clb) {
                nm.elts.load
					.css({
					    position: nm.elts.cont.css('position'),
					    top: nm.elts.cont.css('top'),
					    left: nm.elts.cont.css('left'),
					    width: nm.elts.cont.css('width'),
					    height: nm.elts.cont.css('height'),
					    marginTop: nm.elts.cont.css('marginTop'),
					    marginLeft: nm.elts.cont.css('marginLeft')
					})
					.fadeIn(function () {
					    nm.elts.cont.hide();
					    clb();
					});
            },
            hideTrans: function (nm, clb) {
                nm.elts.cont.css('visibility', 'hidden').show();
                nm.elts.load
					.css('position', nm.elts.cont.css('position'))
					.animate({
					    top: nm.elts.cont.css('top'),
					    left: nm.elts.cont.css('left'),
					    width: nm.elts.cont.css('width'),
					    height: nm.elts.cont.css('height'),
					    marginTop: nm.elts.cont.css('marginTop'),
					    marginLeft: nm.elts.cont.css('marginLeft')
					}, function () {
					    nm.elts.cont.css('visibility', '');
					    nm.elts.load.fadeOut(clb);
					});
            },
            resize: function (nm, clb) {
                nm.elts.cont.animate({
                    width: nm.sizes.w,
                    height: nm.sizes.h,
                    top: (nm.getInternal().fullSize.viewH - nm.sizes.h - nm.sizes.hMargin) / 2,
                    left: (nm.getInternal().fullSize.viewW - nm.sizes.w - nm.sizes.wMargin) / 2
                }, clb);
            }
        }
    });
    // Define fade aniamtions as default
    $.nmObj({ anim: { def: 'fade'} });
});
/*
* nyroModal v2.0.0
* 
* Title filter
* 
* Depends:
* 
* Before:
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        title: {
            is: function (nm) {
                return nm.opener.is('[title]');
            },
            beforeShowCont: function (nm) {
                var offset = nm.elts.cont.offset();
                nm.store.title = $('<h1 />', {
                    text: nm.opener.attr('title')
                }).addClass('nyroModalTitle nmReposition');
                nm.elts.cont.prepend(nm.store.title);
            },
            close: function (nm) {
                if (nm.store.title) {
                    nm.store.title.remove();
                    nm.store.title = undefined;
                    delete (nm.store.title);
                }
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Gallery filter
* 
* Depends:
* - filters.title
* 
* Before: filters.title
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        gallery: {
            is: function (nm) {
                var ret = nm.opener.is('[rel]:not([rel=external], [rel=nofollow])');
                if (ret) {
                    var rel = nm.opener.attr('rel'),
						indexSpace = rel.indexOf(' '),
						gal = indexSpace > 0 ? rel.substr(0, indexSpace) : rel,
						links = $('[href][rel="' + gal + '"], [href][rel^="' + gal + ' "]');
                    if (links.length < 2)
                        ret = false;
                    if (ret && nm.galleryCounts && !nm._hasFilter('title'))
                        nm.filters.push('title');
                }
                return ret;
            },
            init: function (nm) {
                nm.useKeyHandler = true;
            },
            keyHandle: function (nm) {
                // used for arrows key
                if (!nm._animated && nm._opened) {
                    if (nm.keyEvent.keyCode == 39 || nm.keyEvent.keyCode == 40) {
                        nm.keyEvent.preventDefault();
                        nm._callFilters('galleryNext');
                    } else if (nm.keyEvent.keyCode == 37 || nm.keyEvent.keyCode == 38) {
                        nm.keyEvent.preventDefault();
                        nm._callFilters('galleryPrev');
                    }
                }
            },
            initElts: function (nm) {
                var rel = nm.opener.attr('rel'),
					indexSpace = rel.indexOf(' ');
                nm.store.gallery = indexSpace > 0 ? rel.substr(0, indexSpace) : rel;
                nm.store.galleryLinks = $('[href][rel="' + nm.store.gallery + '"], [href][rel^="' + nm.store.gallery + ' "]');
                nm.store.galleryIndex = nm.store.galleryLinks.index(nm.opener);
            },
            beforeShowCont: function (nm) {
                if (nm.galleryCounts && nm.store.title && nm.store.galleryLinks && nm.store.galleryLinks.length > 1) {
                    var curTitle = nm.store.title.html();
                    nm.store.title.html((curTitle.length ? curTitle + ' - ' : '') + (nm.store.galleryIndex + 1) + '/' + nm.store.galleryLinks.length);
                }
            },
            filledContent: function (nm) {
                var link = this._getGalleryLink(nm, -1),
					append = nm.elts.hidden.find(' > div');
                if (link) {
                    $('<a />', {
                        text: 'previous',
                        href: '#'
                    })
						.addClass('nyroModalPrev')
						.bind('click', function (e) {
						    e.preventDefault();
						    nm._callFilters('galleryPrev');
						})
						.appendTo(append);
                }
                link = this._getGalleryLink(nm, 1);
                if (link) {
                    $('<a />', {
                        text: 'next',
                        href: '#'
                    })
						.addClass('nyroModalNext')
						.bind('click', function (e) {
						    e.preventDefault();
						    nm._callFilters('galleryNext');
						})
						.appendTo(append);
                }
            },
            close: function (nm) {
                nm.store.gallery = undefined;
                nm.store.galleryLinks = undefined;
                nm.store.galleryIndex = undefined;
                delete (nm.store.gallery);
                delete (nm.store.galleryLinks);
                delete (nm.store.galleryIndex);
                if (nm.elts.cont)
                    nm.elts.cont.find('.nyroModalNext, .nyroModalPrev').remove();
            },
            galleryNext: function (nm) {
                this._getGalleryLink(nm, 1).nyroModal(nm.getForNewLinks(), true).click();
            },
            galleryPrev: function (nm) {
                this._getGalleryLink(nm, -1).nyroModal(nm.getForNewLinks(), true).click();
            },
            _getGalleryLink: function (nm, dir) {
                if (nm.store.gallery) {
                    if (!nm.ltr)
                        dir *= -1;
                    var index = nm.store.galleryIndex + dir;
                    if (nm.store.galleryLinks && index >= 0 && index < nm.store.galleryLinks.length)
                        return nm.store.galleryLinks.eq(index);
                    else if (nm.galleryLoop && nm.store.galleryLinks)
                        return nm.store.galleryLinks.eq(index < 0 ? nm.store.galleryLinks.length - 1 : 0);
                }
                return undefined;
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Link filter
* 
* Depends:
* 
* Before: filters.gallery
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        link: {
            is: function (nm) {
                var ret = nm.opener.is('[href]');
                if (ret)
                    nm.store.link = nm.getInternal()._extractUrl(nm.opener.attr('href'));
                return ret;
            },
            init: function (nm) {
                nm.loadFilter = 'link';
                nm.opener.unbind('click.nyroModal').bind('click.nyroModal', function (e) {
                    e.preventDefault();
                    nm.opener.trigger('nyroModal');
                });
            },
            load: function (nm) {
                $.ajax({
                    url: nm.store.link.url,
                    data: nm.store.link.sel ? [{ name: nm.selIndicator, value: nm.store.link.sel.substring(1)}] : undefined,
                    success: function (data) {
                        nm._setCont(data, nm.store.link.sel);
                    },
                    error: function () {
                        nm._error();
                    }
                });
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Dom filter
* 
* Depends:
* - filters.link
* 
* Before: filters.link
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        dom: {
            is: function (nm) {
                return nm._hasFilter('link') && !nm.store.link.url && nm.store.link.sel;
            },
            init: function (nm) {
                nm.loadFilter = 'dom';
            },
            load: function (nm) {
                nm.store.domEl = $(nm.store.link.sel);
                if (nm.store.domEl.length)
                    nm._setCont(nm.store.domEl.contents());
                else
                    nm._error();
            },
            close: function (nm) {
                if (nm.store.domEl && nm.elts.cont)
                    nm.store.domEl.append(nm.elts.cont.find('.nyroModalDom').contents());
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Data filter
* 
* Depends:
* - filters.link
* 
* Before: filters.dom
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        data: {
            is: function (nm) {
                var ret = nm.data ? true : false;
                if (ret) {
                    nm._delFilter('dom');
                }
                return ret;
            },
            init: function (nm) {
                nm.loadFilter = 'data';
            },
            load: function (nm) {
                nm._setCont(nm.data);
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Image filter
* 
* Depends:
* - filters.link
* 
* Before: filters.data
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        image: {
            is: function (nm) {
                return (new RegExp(nm.imageRegex, 'i')).test(nm.opener.attr('href'));
            },
            init: function (nm) {
                nm.loadFilter = 'image';
            },
            load: function (nm) {
                var url = nm.opener.attr('href');
                $('<img />')
					.load(function () {
					    nm.elts.cont.addClass('nyroModalImg');
					    nm.elts.hidden.addClass('nyroModalImg');
					    nm._setCont(this);
					}).error(function () {
					    nm._error();
					})
					.attr('src', url);
            },
            size: function (nm) {
                if (nm.sizes.w != nm.sizes.initW || nm.sizes.h != nm.sizes.initH) {
                    var ratio = Math.min(nm.sizes.w / nm.sizes.initW, nm.sizes.h / nm.sizes.initH);
                    nm.sizes.w = nm.sizes.initW * ratio;
                    nm.sizes.h = nm.sizes.initH * ratio;
                }
                var img = nm.loading ? nm.elts.hidden.find('img') : nm.elts.cont.find('img');
                img.attr({
                    width: nm.sizes.w,
                    height: nm.sizes.h
                });
            },
            close: function (nm) {
                if (nm.elts.cont) {
                    nm.elts.cont.removeClass('nyroModalImg');
                    nm.elts.hidden.removeClass('nyroModalImg');
                }
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* SWF filter
* 
* Depends:
* - filters.link
* 
* Before: filters.image
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        swf: {
            idCounter: 1,
            is: function (nm) {
                return nm._hasFilter('link') && nm.opener.is('[href$=".swf"]');
            },
            init: function (nm) {
                nm.loadFilter = 'swf';
            },
            load: function (nm) {
                if (!nm.swfObjectId)
                    nm.swfObjectId = 'nyroModalSwf-' + (this.idCounter++);
                var url = nm.store.link.url,
					cont = '<div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + nm.swfObjectId + '" width="' + nm.sizes.w + '" height="' + nm.sizes.h + '"><param name="movie" value="' + url + '"></param>',
					tmp = '';
                $.each(nm.swf, function (name, val) {
                    cont += '<param name="' + name + '" value="' + val + '"></param>';
                    tmp += ' ' + name + '="' + val + '"';
                });
                cont += '<embed src="' + url + '" type="application/x-shockwave-flash" width="' + nm.sizes.w + '" height="' + nm.sizes.h + '"' + tmp + '></embed></object></div>';
                nm._setCont(cont);
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Form filter
* 
* Depends:
* 
* Before: filters.swf
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        form: {
            is: function (nm) {
                var ret = nm.opener.is('form');
                if (ret)
                    nm.store.form = nm.getInternal()._extractUrl(nm.opener.attr('action'));
                return ret;
            },
            init: function (nm) {
                nm.loadFilter = 'form';
                nm.opener.unbind('submit.nyroModal').bind('submit.nyroModal', function (e) {
                    e.preventDefault();
                    nm.opener.trigger('nyroModal');
                });
            },
            load: function (nm) {
                var data = nm.opener.serializeArray();
                if (nm.store.form.sel)
                    data.push({ name: nm.selIndicator, value: nm.store.form.sel.substring(1) });
                $.ajax({
                    url: nm.store.form.url,
                    data: data,
                    type: nm.opener.attr('method') ? nm.opener.attr('method') : 'get',
                    success: function (data) {
                        nm._setCont(data, nm.store.form.sel);
                    },
                    error: function () {
                        nm._error();
                    }
                });
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Form file filter
* 
* Depends:
* 
* Before: filters.form
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        formFile: {
            is: function (nm) {
                var ret = nm.opener.is('form[enctype="multipart/form-data"]');
                if (ret) {
                    nm._delFilter('form');
                    if (!nm.store.form)
                        nm.store.form = nm.getInternal()._extractUrl(nm.opener.attr('action'));
                }
                return ret;
            },
            init: function (nm) {
                nm.loadFilter = 'formFile';
                nm.store.formFileLoading = false;
                nm.opener.unbind('submit.nyroModal').bind('submit.nyroModal', function (e) {
                    if (!nm.store.formFileIframe) {
                        e.preventDefault();
                        nm.opener.trigger('nyroModal');
                    } else {
                        nm.store.formFileLoading = true;
                    }
                });
            },
            initElts: function (nm) {
                var inputSel;
                if (nm.store.form.sel)
                    inputSel = $('<input />', {
                        'type': 'hidden',
                        name: nm.selIndicator,
                        value: nm.store.form.sel.substring(1)
                    }).appendTo(nm.opener);
                function rmFormFileElts() {
                    if (inputSel) {
                        inputSel.remove();
                        inputSel = undefined;
                        delete (inputSel);
                    }
                    nm.store.formFileIframe.attr('src', 'about:blank').remove();
                    nm.store.formFileIframe = undefined;
                    delete (nm.store.formFileIframe);
                }
                nm.store.formFileIframe = $('<iframe name="nyroModalFormFile" src="javascript:\'\';" id="nyromodal-iframe-' + (new Date().getTime()) + '"></iframe>')
					.hide()
					.load(function () {
					    if (nm.store.formFileLoading) {
					        nm.store.formFileLoading = false;
					        var content = nm.store.formFileIframe
									.unbind('load error')
									.contents().find('body').not('script[src]');
					        if (content && content.html() && content.html().length) {
					            rmFormFileElts();
					            nm._setCont(content.html(), nm.store.form.sel);
					        } else {
					            // Not totally ready, try it in a few secs
					            var nbTry = 0;
					            fct = function () {
					                nbTry++;
					                var content = nm.store.formFileIframe
												.unbind('load error')
												.contents().find('body').not('script[src]');
					                if (content && content.html() && content.html().length) {
					                    nm._setCont(content.html(), nm.store.form.sel);
					                    rmFormFileElts();
					                } else if (nbTry < 5) {
					                    setTimeout(fct, 25);
					                } else {
					                    rmFormFileElts();
					                    nm._error();
					                }
					            };
					            setTimeout(fct, 25);
					        }
					    }
					})
					.error(function () {
					    rmFormFileElts();
					    nm._error();
					});
                nm.elts.all.append(nm.store.formFileIframe);
                nm.opener
					.attr('target', 'nyroModalFormFile')
					.submit();
            },
            close: function (nm) {
                nm.store.formFileLoading = false;
                if (nm.store.formFileIframe) {
                    nm.store.formFileIframe.remove();
                    nm.store.formFileIframe = undefined;
                    delete (nm.store.formFileIframe);
                }
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Iframe filter
* 
* Depends:
* - filters.link
* 
* Before: filters.formFile
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        iframe: {
            is: function (nm) {
                var target = nm.opener.attr('target') || '',
					rel = nm.opener.attr('rel') || '',
					opener = nm.opener.get(0);
                return !nm._hasFilter('image') && (target.toLowerCase() == '_blank'
					|| rel.toLowerCase().indexOf('external') > -1
					|| (opener.hostname && opener.hostname.replace(/:\d*$/, '') != window.location.hostname.replace(/:\d*$/, '')));
            },
            init: function (nm) {
                nm.loadFilter = 'iframe';
            },
            load: function (nm) {
                nm.store.iframe = $('<iframe src="javascript:\'\';" id="nyromodal-iframe-' + (new Date().getTime()) + '"></iframe>');
                nm._setCont(nm.store.iframe);
            },
            afterShowCont: function (nm) {
                nm.store.iframe.attr('src', nm.opener.attr('href'));
            },
            close: function (nm) {
                if (nm.store.iframe) {
                    nm.store.iframe.remove();
                    nm.store.iframe = undefined;
                    delete (nm.store.iframe);
                }
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Iframe form filter
* 
* Depends:
* - filters.iframe
* 
* Before: filters.iframe
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        iframeForm: {
            is: function (nm) {
                var ret = nm._hasFilter('iframe') && nm.opener.is('form');
                if (ret) {
                    nm._delFilter('iframe');
                    nm._delFilter('form');
                }
                return ret;
            },
            init: function (nm) {
                nm.loadFilter = 'iframeForm';
                nm.store.iframeFormLoading = false;
                nm.store.iframeFormOrgTarget = nm.opener.attr('target');
                nm.opener.unbind('submit.nyroModal').bind('submit.nyroModal', function (e) {
                    if (!nm.store.iframeFormIframe) {
                        e.preventDefault();
                        nm.opener.trigger('nyroModal');
                    } else {
                        nm.store.iframeFormLoading = true;
                    }
                });
            },
            load: function (nm) {
                nm.store.iframeFormIframe = $('<iframe name="nyroModalIframeForm" src="javascript:\'\';" id="nyromodal-iframe-' + (new Date().getTime()) + '"></iframe>');
                nm._setCont(nm.store.iframeFormIframe);
            },
            afterShowCont: function (nm) {
                nm.opener
					.attr('target', 'nyroModalIframeForm')
					.submit();
            },
            close: function (nm) {
                nm.store.iframeFormOrgTarget ? nm.opener.attr('target', nm.store.iframeFormOrgTarget) : nm.opener.removeAttr('target');
                delete (nm.store.formFileLoading);
                delete (nm.store.iframeFormOrgTarget);
                if (nm.store.iframeFormIframe) {
                    nm.store.iframeFormIframe.remove();
                    nm.store.iframeFormIframe = undefined;
                    delete (nm.store.iframeFormIframe);
                }
            }
        }
    });
});
/*
* nyroModal v2.0.0
* 
* Embedly filter
* 
* Depends:
* - filters.link
* 
* Before: filters.iframeForm
*/
jQuery(function ($, undefined) {
    $.nmFilters({
        embedly: {
            is: function (nm) {
                // Regex from https://github.com/embedly/embedly-jquery
                var embedlyReg = /http:\/\/(.*youtube\.com\/watch.*|.*\.youtube\.com\/v\/.*|youtu\.be\/.*|.*\.youtube\.com\/user\/.*|.*\.youtube\.com\/.*#.*\/.*|m\.youtube\.com\/watch.*|m\.youtube\.com\/index.*|.*\.youtube\.com\/profile.*|.*justin\.tv\/.*|.*justin\.tv\/.*\/b\/.*|.*justin\.tv\/.*\/w\/.*|www\.ustream\.tv\/recorded\/.*|www\.ustream\.tv\/channel\/.*|www\.ustream\.tv\/.*|qik\.com\/video\/.*|qik\.com\/.*|qik\.ly\/.*|.*revision3\.com\/.*|.*\.dailymotion\.com\/video\/.*|.*\.dailymotion\.com\/.*\/video\/.*|www\.collegehumor\.com\/video:.*|.*twitvid\.com\/.*|www\.break\.com\/.*\/.*|vids\.myspace\.com\/index\.cfm\?fuseaction=vids\.individual&videoid.*|www\.myspace\.com\/index\.cfm\?fuseaction=.*&videoid.*|www\.metacafe\.com\/watch\/.*|www\.metacafe\.com\/w\/.*|blip\.tv\/file\/.*|.*\.blip\.tv\/file\/.*|video\.google\.com\/videoplay\?.*|.*revver\.com\/video\/.*|video\.yahoo\.com\/watch\/.*\/.*|video\.yahoo\.com\/network\/.*|.*viddler\.com\/explore\/.*\/videos\/.*|liveleak\.com\/view\?.*|www\.liveleak\.com\/view\?.*|animoto\.com\/play\/.*|dotsub\.com\/view\/.*|www\.overstream\.net\/view\.php\?oid=.*|www\.livestream\.com\/.*|www\.worldstarhiphop\.com\/videos\/video.*\.php\?v=.*|worldstarhiphop\.com\/videos\/video.*\.php\?v=.*|teachertube\.com\/viewVideo\.php.*|www\.teachertube\.com\/viewVideo\.php.*|www1\.teachertube\.com\/viewVideo\.php.*|www2\.teachertube\.com\/viewVideo\.php.*|bambuser\.com\/v\/.*|bambuser\.com\/channel\/.*|bambuser\.com\/channel\/.*\/broadcast\/.*|www\.schooltube\.com\/video\/.*\/.*|bigthink\.com\/ideas\/.*|bigthink\.com\/series\/.*|sendables\.jibjab\.com\/view\/.*|sendables\.jibjab\.com\/originals\/.*|www\.xtranormal\.com\/watch\/.*|socialcam\.com\/v\/.*|www\.socialcam\.com\/v\/.*|dipdive\.com\/media\/.*|dipdive\.com\/member\/.*\/media\/.*|dipdive\.com\/v\/.*|.*\.dipdive\.com\/media\/.*|.*\.dipdive\.com\/v\/.*|v\.youku\.com\/v_show\/.*\.html|v\.youku\.com\/v_playlist\/.*\.html|www\.snotr\.com\/video\/.*|snotr\.com\/video\/.*|video\.jardenberg\.se\/.*|.*yfrog\..*\/.*|tweetphoto\.com\/.*|www\.flickr\.com\/photos\/.*|flic\.kr\/.*|twitpic\.com\/.*|www\.twitpic\.com\/.*|twitpic\.com\/photos\/.*|www\.twitpic\.com\/photos\/.*|.*imgur\.com\/.*|.*\.posterous\.com\/.*|post\.ly\/.*|twitgoo\.com\/.*|i.*\.photobucket\.com\/albums\/.*|s.*\.photobucket\.com\/albums\/.*|phodroid\.com\/.*\/.*\/.*|www\.mobypicture\.com\/user\/.*\/view\/.*|moby\.to\/.*|xkcd\.com\/.*|www\.xkcd\.com\/.*|imgs\.xkcd\.com\/.*|www\.asofterworld\.com\/index\.php\?id=.*|www\.asofterworld\.com\/.*\.jpg|asofterworld\.com\/.*\.jpg|www\.qwantz\.com\/index\.php\?comic=.*|23hq\.com\/.*\/photo\/.*|www\.23hq\.com\/.*\/photo\/.*|.*dribbble\.com\/shots\/.*|drbl\.in\/.*|.*\.smugmug\.com\/.*|.*\.smugmug\.com\/.*#.*|emberapp\.com\/.*\/images\/.*|emberapp\.com\/.*\/images\/.*\/sizes\/.*|emberapp\.com\/.*\/collections\/.*\/.*|emberapp\.com\/.*\/categories\/.*\/.*\/.*|embr\.it\/.*|picasaweb\.google\.com.*\/.*\/.*#.*|picasaweb\.google\.com.*\/lh\/photo\/.*|picasaweb\.google\.com.*\/.*\/.*|dailybooth\.com\/.*\/.*|brizzly\.com\/pic\/.*|pics\.brizzly\.com\/.*\.jpg|img\.ly\/.*|www\.tinypic\.com\/view\.php.*|tinypic\.com\/view\.php.*|www\.tinypic\.com\/player\.php.*|tinypic\.com\/player\.php.*|www\.tinypic\.com\/r\/.*\/.*|tinypic\.com\/r\/.*\/.*|.*\.tinypic\.com\/.*\.jpg|.*\.tinypic\.com\/.*\.png|meadd\.com\/.*\/.*|meadd\.com\/.*|.*\.deviantart\.com\/art\/.*|.*\.deviantart\.com\/gallery\/.*|.*\.deviantart\.com\/#\/.*|fav\.me\/.*|.*\.deviantart\.com|.*\.deviantart\.com\/gallery|.*\.deviantart\.com\/.*\/.*\.jpg|.*\.deviantart\.com\/.*\/.*\.gif|.*\.deviantart\.net\/.*\/.*\.jpg|.*\.deviantart\.net\/.*\/.*\.gif|plixi\.com\/p\/.*|plixi\.com\/profile\/home\/.*|plixi\.com\/.*|www\.fotopedia\.com\/.*\/.*|fotopedia\.com\/.*\/.*|photozou\.jp\/photo\/show\/.*\/.*|photozou\.jp\/photo\/photo_only\/.*\/.*|instagr\.am\/p\/.*|instagram\.com\/p\/.*|skitch\.com\/.*\/.*\/.*|img\.skitch\.com\/.*|https:\/\/skitch\.com\/.*\/.*\/.*|https:\/\/img\.skitch\.com\/.*|share\.ovi\.com\/media\/.*\/.*|www\.questionablecontent\.net\/|questionablecontent\.net\/|www\.questionablecontent\.net\/view\.php.*|questionablecontent\.net\/view\.php.*|questionablecontent\.net\/comics\/.*\.png|www\.questionablecontent\.net\/comics\/.*\.png|picplz\.com\/user\/.*\/pic\/.*\/|twitrpix\.com\/.*|.*\.twitrpix\.com\/.*|www\.someecards\.com\/.*\/.*|someecards\.com\/.*\/.*|some\.ly\/.*|www\.some\.ly\/.*|pikchur\.com\/.*|achewood\.com\/.*|www\.achewood\.com\/.*|achewood\.com\/index\.php.*|www\.achewood\.com\/index\.php.*|www\.whosay\.com\/content\/.*|www\.whosay\.com\/photos\/.*|www\.whosay\.com\/videos\/.*|say\.ly\/.*|www\.whitehouse\.gov\/photos-and-video\/video\/.*|www\.whitehouse\.gov\/video\/.*|wh\.gov\/photos-and-video\/video\/.*|wh\.gov\/video\/.*|www\.hulu\.com\/watch.*|www\.hulu\.com\/w\/.*|hulu\.com\/watch.*|hulu\.com\/w\/.*|.*crackle\.com\/c\/.*|www\.fancast\.com\/.*\/videos|www\.funnyordie\.com\/videos\/.*|www\.funnyordie\.com\/m\/.*|funnyordie\.com\/videos\/.*|funnyordie\.com\/m\/.*|www\.vimeo\.com\/groups\/.*\/videos\/.*|www\.vimeo\.com\/.*|vimeo\.com\/groups\/.*\/videos\/.*|vimeo\.com\/.*|vimeo\.com\/m\/#\/.*|www\.ted\.com\/talks\/.*\.html.*|www\.ted\.com\/talks\/lang\/.*\/.*\.html.*|www\.ted\.com\/index\.php\/talks\/.*\.html.*|www\.ted\.com\/index\.php\/talks\/lang\/.*\/.*\.html.*|.*nfb\.ca\/film\/.*|www\.thedailyshow\.com\/watch\/.*|www\.thedailyshow\.com\/full-episodes\/.*|www\.thedailyshow\.com\/collection\/.*\/.*\/.*|movies\.yahoo\.com\/movie\/.*\/video\/.*|movies\.yahoo\.com\/movie\/.*\/trailer|movies\.yahoo\.com\/movie\/.*\/video|www\.colbertnation\.com\/the-colbert-report-collections\/.*|www\.colbertnation\.com\/full-episodes\/.*|www\.colbertnation\.com\/the-colbert-report-videos\/.*|www\.comedycentral\.com\/videos\/index\.jhtml\?.*|www\.theonion\.com\/video\/.*|theonion\.com\/video\/.*|wordpress\.tv\/.*\/.*\/.*\/.*\/|www\.traileraddict\.com\/trailer\/.*|www\.traileraddict\.com\/clip\/.*|www\.traileraddict\.com\/poster\/.*|www\.escapistmagazine\.com\/videos\/.*|www\.trailerspy\.com\/trailer\/.*\/.*|www\.trailerspy\.com\/trailer\/.*|www\.trailerspy\.com\/view_video\.php.*|www\.atom\.com\/.*\/.*\/|fora\.tv\/.*\/.*\/.*\/.*|www\.spike\.com\/video\/.*|www\.gametrailers\.com\/video\/.*|gametrailers\.com\/video\/.*|www\.koldcast\.tv\/video\/.*|www\.koldcast\.tv\/#video:.*|techcrunch\.tv\/watch.*|techcrunch\.tv\/.*\/watch.*|mixergy\.com\/.*|video\.pbs\.org\/video\/.*|www\.zapiks\.com\/.*|tv\.digg\.com\/diggnation\/.*|tv\.digg\.com\/diggreel\/.*|tv\.digg\.com\/diggdialogg\/.*|www\.trutv\.com\/video\/.*|www\.nzonscreen\.com\/title\/.*|nzonscreen\.com\/title\/.*|app\.wistia\.com\/embed\/medias\/.*|https:\/\/app\.wistia\.com\/embed\/medias\/.*|hungrynation\.tv\/.*\/episode\/.*|www\.hungrynation\.tv\/.*\/episode\/.*|hungrynation\.tv\/episode\/.*|www\.hungrynation\.tv\/episode\/.*|indymogul\.com\/.*\/episode\/.*|www\.indymogul\.com\/.*\/episode\/.*|indymogul\.com\/episode\/.*|www\.indymogul\.com\/episode\/.*|channelfrederator\.com\/.*\/episode\/.*|www\.channelfrederator\.com\/.*\/episode\/.*|channelfrederator\.com\/episode\/.*|www\.channelfrederator\.com\/episode\/.*|tmiweekly\.com\/.*\/episode\/.*|www\.tmiweekly\.com\/.*\/episode\/.*|tmiweekly\.com\/episode\/.*|www\.tmiweekly\.com\/episode\/.*|99dollarmusicvideos\.com\/.*\/episode\/.*|www\.99dollarmusicvideos\.com\/.*\/episode\/.*|99dollarmusicvideos\.com\/episode\/.*|www\.99dollarmusicvideos\.com\/episode\/.*|ultrakawaii\.com\/.*\/episode\/.*|www\.ultrakawaii\.com\/.*\/episode\/.*|ultrakawaii\.com\/episode\/.*|www\.ultrakawaii\.com\/episode\/.*|barelypolitical\.com\/.*\/episode\/.*|www\.barelypolitical\.com\/.*\/episode\/.*|barelypolitical\.com\/episode\/.*|www\.barelypolitical\.com\/episode\/.*|barelydigital\.com\/.*\/episode\/.*|www\.barelydigital\.com\/.*\/episode\/.*|barelydigital\.com\/episode\/.*|www\.barelydigital\.com\/episode\/.*|threadbanger\.com\/.*\/episode\/.*|www\.threadbanger\.com\/.*\/episode\/.*|threadbanger\.com\/episode\/.*|www\.threadbanger\.com\/episode\/.*|vodcars\.com\/.*\/episode\/.*|www\.vodcars\.com\/.*\/episode\/.*|vodcars\.com\/episode\/.*|www\.vodcars\.com\/episode\/.*|confreaks\.net\/videos\/.*|www\.confreaks\.net\/videos\/.*|video\.allthingsd\.com\/video\/.*|aniboom\.com\/animation-video\/.*|www\.aniboom\.com\/animation-video\/.*|clipshack\.com\/Clip\.aspx\?.*|www\.clipshack\.com\/Clip\.aspx\?.*|grindtv\.com\/.*\/video\/.*|www\.grindtv\.com\/.*\/video\/.*|ifood\.tv\/recipe\/.*|ifood\.tv\/video\/.*|ifood\.tv\/channel\/user\/.*|www\.ifood\.tv\/recipe\/.*|www\.ifood\.tv\/video\/.*|www\.ifood\.tv\/channel\/user\/.*|logotv\.com\/video\/.*|www\.logotv\.com\/video\/.*|lonelyplanet\.com\/Clip\.aspx\?.*|www\.lonelyplanet\.com\/Clip\.aspx\?.*|streetfire\.net\/video\/.*\.htm.*|www\.streetfire\.net\/video\/.*\.htm.*|trooptube\.tv\/videos\/.*|www\.trooptube\.tv\/videos\/.*|www\.godtube\.com\/featured\/video\/.*|godtube\.com\/featured\/video\/.*|www\.godtube\.com\/watch\/.*|godtube\.com\/watch\/.*|www\.tangle\.com\/view_video.*|mediamatters\.org\/mmtv\/.*|www\.clikthrough\.com\/theater\/video\/.*|soundcloud\.com\/.*|soundcloud\.com\/.*\/.*|soundcloud\.com\/.*\/sets\/.*|soundcloud\.com\/groups\/.*|snd\.sc\/.*|www\.last\.fm\/music\/.*|www\.last\.fm\/music\/+videos\/.*|www\.last\.fm\/music\/+images\/.*|www\.last\.fm\/music\/.*\/_\/.*|www\.last\.fm\/music\/.*\/.*|www\.mixcloud\.com\/.*\/.*\/|www\.radionomy\.com\/.*\/radio\/.*|radionomy\.com\/.*\/radio\/.*|www\.entertonement\.com\/clips\/.*|www\.rdio\.com\/#\/artist\/.*\/album\/.*|www\.rdio\.com\/artist\/.*\/album\/.*|www\.zero-inch\.com\/.*|.*\.bandcamp\.com\/|.*\.bandcamp\.com\/track\/.*|.*\.bandcamp\.com\/album\/.*|freemusicarchive\.org\/music\/.*|www\.freemusicarchive\.org\/music\/.*|freemusicarchive\.org\/curator\/.*|www\.freemusicarchive\.org\/curator\/.*|www\.npr\.org\/.*\/.*\/.*\/.*\/.*|www\.npr\.org\/.*\/.*\/.*\/.*\/.*\/.*|www\.npr\.org\/.*\/.*\/.*\/.*\/.*\/.*\/.*|www\.npr\.org\/templates\/story\/story\.php.*|huffduffer\.com\/.*\/.*|www\.audioboo\.fm\/boos\/.*|audioboo\.fm\/boos\/.*|boo\.fm\/b.*|www\.xiami\.com\/song\/.*|xiami\.com\/song\/.*|www\.saynow\.com\/playMsg\.html.*|www\.saynow\.com\/playMsg\.html.*|listen\.grooveshark\.com\/s\/.*|radioreddit\.com\/songs.*|www\.radioreddit\.com\/songs.*|radioreddit\.com\/\?q=songs.*|www\.radioreddit\.com\/\?q=songs.*|espn\.go\.com\/video\/clip.*|espn\.go\.com\/.*\/story.*|abcnews\.com\/.*\/video\/.*|abcnews\.com\/video\/playerIndex.*|washingtonpost\.com\/wp-dyn\/.*\/video\/.*\/.*\/.*\/.*|www\.washingtonpost\.com\/wp-dyn\/.*\/video\/.*\/.*\/.*\/.*|www\.boston\.com\/video.*|boston\.com\/video.*|www\.facebook\.com\/photo\.php.*|www\.facebook\.com\/video\/video\.php.*|www\.facebook\.com\/v\/.*|cnbc\.com\/id\/.*\?.*video.*|www\.cnbc\.com\/id\/.*\?.*video.*|cnbc\.com\/id\/.*\/play\/1\/video\/.*|www\.cnbc\.com\/id\/.*\/play\/1\/video\/.*|cbsnews\.com\/video\/watch\/.*|www\.google\.com\/buzz\/.*\/.*\/.*|www\.google\.com\/buzz\/.*|www\.google\.com\/profiles\/.*|google\.com\/buzz\/.*\/.*\/.*|google\.com\/buzz\/.*|google\.com\/profiles\/.*|www\.cnn\.com\/video\/.*|edition\.cnn\.com\/video\/.*|money\.cnn\.com\/video\/.*|today\.msnbc\.msn\.com\/id\/.*\/vp\/.*|www\.msnbc\.msn\.com\/id\/.*\/vp\/.*|www\.msnbc\.msn\.com\/id\/.*\/ns\/.*|today\.msnbc\.msn\.com\/id\/.*\/ns\/.*|multimedia\.foxsports\.com\/m\/video\/.*\/.*|msn\.foxsports\.com\/video.*|www\.globalpost\.com\/video\/.*|www\.globalpost\.com\/dispatch\/.*|guardian\.co\.uk\/.*\/video\/.*\/.*\/.*\/.*|www\.guardian\.co\.uk\/.*\/video\/.*\/.*\/.*\/.*|bravotv\.com\/.*\/.*\/videos\/.*|www\.bravotv\.com\/.*\/.*\/videos\/.*|video\.nationalgeographic\.com\/.*\/.*\/.*\.html|dsc\.discovery\.com\/videos\/.*|animal\.discovery\.com\/videos\/.*|health\.discovery\.com\/videos\/.*|investigation\.discovery\.com\/videos\/.*|military\.discovery\.com\/videos\/.*|planetgreen\.discovery\.com\/videos\/.*|science\.discovery\.com\/videos\/.*|tlc\.discovery\.com\/videos\/.*|.*amazon\..*\/gp\/product\/.*|.*amazon\..*\/.*\/dp\/.*|.*amazon\..*\/dp\/.*|.*amazon\..*\/o\/ASIN\/.*|.*amazon\..*\/gp\/offer-listing\/.*|.*amazon\..*\/.*\/ASIN\/.*|.*amazon\..*\/gp\/product\/images\/.*|.*amazon\..*\/gp\/aw\/d\/.*|www\.amzn\.com\/.*|amzn\.com\/.*|www\.shopstyle\.com\/browse.*|www\.shopstyle\.com\/action\/apiVisitRetailer.*|api\.shopstyle\.com\/action\/apiVisitRetailer.*|www\.shopstyle\.com\/action\/viewLook.*|gist\.github\.com\/.*|twitter\.com\/.*\/status\/.*|twitter\.com\/.*\/statuses\/.*|www\.twitter\.com\/.*\/status\/.*|www\.twitter\.com\/.*\/statuses\/.*|mobile\.twitter\.com\/.*\/status\/.*|mobile\.twitter\.com\/.*\/statuses\/.*|https:\/\/twitter\.com\/.*\/status\/.*|https:\/\/twitter\.com\/.*\/statuses\/.*|https:\/\/www\.twitter\.com\/.*\/status\/.*|https:\/\/www\.twitter\.com\/.*\/statuses\/.*|https:\/\/mobile\.twitter\.com\/.*\/status\/.*|https:\/\/mobile\.twitter\.com\/.*\/statuses\/.*|www\.crunchbase\.com\/.*\/.*|crunchbase\.com\/.*\/.*|www\.slideshare\.net\/.*\/.*|www\.slideshare\.net\/mobile\/.*\/.*|slidesha\.re\/.*|scribd\.com\/doc\/.*|www\.scribd\.com\/doc\/.*|scribd\.com\/mobile\/documents\/.*|www\.scribd\.com\/mobile\/documents\/.*|screenr\.com\/.*|polldaddy\.com\/community\/poll\/.*|polldaddy\.com\/poll\/.*|answers\.polldaddy\.com\/poll\/.*|www\.5min\.com\/Video\/.*|www\.howcast\.com\/videos\/.*|www\.screencast\.com\/.*\/media\/.*|screencast\.com\/.*\/media\/.*|www\.screencast\.com\/t\/.*|screencast\.com\/t\/.*|issuu\.com\/.*\/docs\/.*|www\.kickstarter\.com\/projects\/.*\/.*|www\.scrapblog\.com\/viewer\/viewer\.aspx.*|ping\.fm\/p\/.*|chart\.ly\/symbols\/.*|chart\.ly\/.*|maps\.google\.com\/maps\?.*|maps\.google\.com\/\?.*|maps\.google\.com\/maps\/ms\?.*|.*\.craigslist\.org\/.*\/.*|my\.opera\.com\/.*\/albums\/show\.dml\?id=.*|my\.opera\.com\/.*\/albums\/showpic\.dml\?album=.*&picture=.*|tumblr\.com\/.*|.*\.tumblr\.com\/post\/.*|www\.polleverywhere\.com\/polls\/.*|www\.polleverywhere\.com\/multiple_choice_polls\/.*|www\.polleverywhere\.com\/free_text_polls\/.*|www\.quantcast\.com\/wd:.*|www\.quantcast\.com\/.*|siteanalytics\.compete\.com\/.*|statsheet\.com\/statplot\/charts\/.*\/.*\/.*\/.*|statsheet\.com\/statplot\/charts\/e\/.*|statsheet\.com\/.*\/teams\/.*\/.*|statsheet\.com\/tools\/chartlets\?chart=.*|.*\.status\.net\/notice\/.*|identi\.ca\/notice\/.*|brainbird\.net\/notice\/.*|shitmydadsays\.com\/notice\/.*|www\.studivz\.net\/Profile\/.*|www\.studivz\.net\/l\/.*|www\.studivz\.net\/Groups\/Overview\/.*|www\.studivz\.net\/Gadgets\/Info\/.*|www\.studivz\.net\/Gadgets\/Install\/.*|www\.studivz\.net\/.*|www\.meinvz\.net\/Profile\/.*|www\.meinvz\.net\/l\/.*|www\.meinvz\.net\/Groups\/Overview\/.*|www\.meinvz\.net\/Gadgets\/Info\/.*|www\.meinvz\.net\/Gadgets\/Install\/.*|www\.meinvz\.net\/.*|www\.schuelervz\.net\/Profile\/.*|www\.schuelervz\.net\/l\/.*|www\.schuelervz\.net\/Groups\/Overview\/.*|www\.schuelervz\.net\/Gadgets\/Info\/.*|www\.schuelervz\.net\/Gadgets\/Install\/.*|www\.schuelervz\.net\/.*|myloc\.me\/.*|pastebin\.com\/.*|pastie\.org\/.*|www\.pastie\.org\/.*|redux\.com\/stream\/item\/.*\/.*|redux\.com\/f\/.*\/.*|www\.redux\.com\/stream\/item\/.*\/.*|www\.redux\.com\/f\/.*\/.*|cl\.ly\/.*|cl\.ly\/.*\/content|speakerdeck\.com\/u\/.*\/p\/.*|www\.kiva\.org\/lend\/.*|www\.timetoast\.com\/timelines\/.*|storify\.com\/.*\/.*|.*meetup\.com\/.*|meetu\.ps\/.*|www\.dailymile\.com\/people\/.*\/entries\/.*|.*\.kinomap\.com\/.*|www\.metacdn\.com\/api\/users\/.*\/content\/.*|www\.metacdn\.com\/api\/users\/.*\/media\/.*|prezi\.com\/.*\/.*|.*\.uservoice\.com\/.*\/suggestions\/.*|formspring\.me\/.*|www\.formspring\.me\/.*|formspring\.me\/.*\/q\/.*|www\.formspring\.me\/.*\/q\/.*|twitlonger\.com\/show\/.*|www\.twitlonger\.com\/show\/.*|tl\.gd\/.*|www\.qwiki\.com\/q\/.*|crocodoc\.com\/.*|.*\.crocodoc\.com\/.*|https:\/\/crocodoc\.com\/.*|https:\/\/.*\.crocodoc\.com\/.*)/i;
                var ret = nm._hasFilter('link') && nm.opener.attr('href') && nm.opener.attr('href').match(embedlyReg) !== null;
                if (ret)
                    nm._delFilter('iframe');
                return ret;
            },
            init: function (nm) {
                nm.loadFilter = 'embedly';
                nm.store.embedly = {};
            },
            load: function (nm) {
                $.ajax({
                    url: 'http://api.embed.ly/1/oembed',
                    dataType: 'jsonp',
                    data: 'wmode=transparent&url=' + nm.opener.attr('href'),
                    success: function (data) {
                        if (data.type == 'error')
                            nm._error();
                        else if (data.type == 'photo') {
                            nm.filters.push('image');
                            $('<img />')
								.load(function () {
								    nm.elts.cont.addClass('nyroModalImg');
								    nm.elts.hidden.addClass('nyroModalImg');
								    nm._setCont(this);
								}).error(function () {
								    nm._error();
								})
								.attr('src', data.url);
                        } else {
                            nm.store.embedly.w = data.width;
                            nm.store.embedly.h = data.height;
                            nm._setCont('<div>' + data.html + '</div>');
                        }
                    }
                });
            },
            size: function (nm) {
                if (nm.store.embedly.w && !nm.sizes.h) {
                    nm.sizes.w = nm.store.embedly.w;
                    nm.sizes.h = nm.store.embedly.h;
                }
            }
        }
    });
});

/* jquery.bb.watermark.js
* BradBamford's Easy Watermark v1.0
* Date: Wed Mar 09 21:23:05 2010 -0500

* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.

*/
jQuery(function ($) {
	$.fn.watermark = function (options) {

		var defaults = {
			text: null,
			color: "#cccccc",
			fontSize: ".875em",
			top: "1px",
			left: "5px",
			className: "watermark"
		};

		return this.filter('input:text').each(function () {
			defaults.text = $(this).attr("title");

			settings = $.extend({}, defaults, options);

			var wrapper$ = $("<span />", { "style": "position:relative" });
			$(this).after(wrapper$).detach().appendTo(wrapper$);

			var watermark$ = $("<label />", { "text": settings.text, "for": $(this).attr("id"), "class": settings.className });
			watermark$.css({
				"position": "absolute",
				"top": settings.top,
				"left": settings.left,
				"z-index": "1",
				"color": settings.color,
				"font-size": settings.fontSize				
			});
			watermark$.appendTo(wrapper$);

			$(this).focus(function () {
				if (this.value == "") { watermark$.hide(); }
			});

			$(this).blur(function () {
				if (this.value == '') { watermark$.show(); }
			});

			if (!$(this).val() == "") { watermark$.hide(); }

		});
	};
});


/*-------------------------------------------------------------------- 
* jQuery plugins: toEm() and toPx()
* by Scott Jehl (scott@filamentgroup.com), http://www.filamentgroup.com
* Copyright (c) Filament Group
* Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
* Article: http://www.filamentgroup.com/lab/update_jquery_plugin_for_retaining_scalable_interfaces_with_pixel_to_em_con/
* Options:  	 								
scope: string or jQuery selector for font-size scoping		  
* Usage Example: $(myPixelValue).toEm(); or $(myEmValue).toPx();
--------------------------------------------------------------------*/

$.fn.toEm = function (settings) {
    settings = jQuery.extend({
        scope: 'body'
    }, settings);
    var that = parseInt(this[0], 10);
    var scopeTest = jQuery('<div style="display: none; font-size: 1em; margin: 0; padding:0; height: auto; line-height: 1; border:0;">&nbsp;</div>').appendTo(settings.scope);
    var scopeVal = scopeTest.height();
    scopeTest.remove();
    return (that / scopeVal).toFixed(8) + 'em';
};


$.fn.toPx = function (settings) {
    settings = jQuery.extend({
        scope: 'body'
    }, settings);
    var that = parseFloat(this[0]);
    var scopeTest = jQuery('<div style="display: none; font-size: 1em; margin: 0; padding:0; height: auto; line-height: 1; border:0;">&nbsp;</div>').appendTo(settings.scope);
    var scopeVal = scopeTest.height();
    scopeTest.remove();
    return Math.round(that * scopeVal) + 'px';
};


/*-------------------------------------------------------------------- 
* JQuery Plugin: "EqualHeights"
* by:	Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com)
*
* Copyright (c) 2008 Filament Group
* Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
*
* Description: Compares the heights or widths of the top-level children of a provided element 
and sets their min-height to the tallest height (or width to widest width). Sets in em units 
by default if pxToEm() method is available.
* Dependencies: jQuery library, pxToEm method	(article: 
http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)							  
* Usage Example: $(element).equalHeights();
Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
* Version: 2.0, 08.01.2008
--------------------------------------------------------------------*/

$.fn.equalHeights = function (px) {
    $(this).each(function () {
        var currentTallest = 0;
        $(this).children().each(function (i) {
            if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
        });
        //currentTallest = $(currentTallest).toEm(); //use ems unless px is specified
        // for ie6, set height since min-height isn't supported
        if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({ 'height': currentTallest }); }
        //var str = 'min-height: ' + currentTallest + '; height: auto !important; height: ' + currentTallest;
        //$(this).children().attr('style', str);
        $(this).children().css({ 'min-height': currentTallest });
    });
    return this;
};







