/*
 * Ext JS Library 2.0
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.BLANK_IMAGE_URL = '../../resources/images/default/s.gif';

Ext.example = function(){
    var msgCt;

    function createBox(t, s){
        return ['<div class="msg">',
                '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
                '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
                '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
                '</div>'].join('');
    }
    return {
        msg : function(title, format){
            if(!msgCt){
                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
            }
            msgCt.alignTo(document, 't-t');
            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
            m.slideIn('t').pause(1).ghost("t", {remove:true});
        },

        init : function(){
            var t = Ext.get('exttheme');
            if(!t){ // run locally?
                return;
            }
            var theme = Cookies.get('exttheme') || 'aero';
            if(theme){
                t.dom.value = theme;
                Ext.getBody().addClass('x-'+theme);
            }
            t.on('change', function(){
                Cookies.set('exttheme', t.getValue());
                setTimeout(function(){
                    window.location.reload();
                }, 250);
            });

            var lb = Ext.get('lib-bar');
            if(lb){
                lb.show();
            }
        }
    };
}();

var guillemet='"';

Ext.example.shortBogusMarkup = 'Partie1';
Ext.example.bogusMarkup = "<center><style type="+guillemet+"text/css"+guillemet+">table.lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0 td {margin:0 !important;padding:0 !important;border:0 !important;}table.lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0 tr.lfmHead a:hover {background:url(http://cdn.last.fm/widgets/images/fr/header/radio/regular_blue.png) no-repeat 0 0 !important;}table.lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0 tr.lfmEmbed object {float:left;}table.lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0 tr.lfmFoot td.lfmConfig a:hover {background:url(http://cdn.last.fm/widgets/images/fr/footer/blue_np.png) no-repeat 0px 0 !important;;}table.lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0 tr.lfmFoot td.lfmView a:hover {background:url(http://cdn.last.fm/widgets/images/fr/footer/blue_np.png) no-repeat -85px 0 !important;}table.lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0 tr.lfmFoot td.lfmPopup a:hover {background:url(http://cdn.last.fm/widgets/images/fr/footer/blue_np.png) no-repeat -159px 0 !important;}</style><table class="+guillemet+"lfmWidgetradio_e2a8cc6d31dc7b07bfcb6cfc377da7f0"+guillemet+" cellpadding="+guillemet+"0"+guillemet+" cellspacing="+guillemet+"0"+guillemet+" border="+guillemet+"0"+guillemet+" style="+guillemet+"width:184px;"+guillemet+"><tr class="+guillemet+"lfmHead"+guillemet+"><td><a title="+guillemet+"Musique taguée pop"+guillemet+" href="+guillemet+"http://www.lastfm.fr/listen/globaltags/pop"+guillemet+" target="+guillemet+"_blank"+guillemet+" style="+guillemet+"display:block;overflow:hidden;height:20px;width:184px;background:url(http://cdn.last.fm/widgets/images/fr/header/radio/regular_blue.png) no-repeat 0 -20px;text-decoration:none;border:0;"+guillemet+"></a></td></tr><tr class="+guillemet+"lfmEmbed"+guillemet+"><td><object type="+guillemet+"application/x-shockwave-flash"+guillemet+" data="+guillemet+"http://cdn.last.fm/widgets/radio/22.swf"+guillemet+" codebase="+guillemet+"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"+guillemet+" id="+guillemet+"lfmEmbed_1241709501"+guillemet+" width="+guillemet+"184"+guillemet+" height="+guillemet+"140"+guillemet+"> <param name="+guillemet+"movie"+guillemet+" value="+guillemet+"http://cdn.last.fm/widgets/radio/22.swf"+guillemet+" /> <param name="+guillemet+"flashvars"+guillemet+" value="+guillemet+"lfmMode=radio&amp;radioURL=globaltags%2Fpop&amp;title=Musique+tagu%C3%A9e+pop&amp;theme=blue&amp;autostart=1&amp;lang=fr&amp;widget_id=radio_e2a8cc6d31dc7b07bfcb6cfc377da7f0"+guillemet+" /> <param name="+guillemet+"allowScriptAccess"+guillemet+" value="+guillemet+"always"+guillemet+" /> <param name="+guillemet+"allowNetworking"+guillemet+" value="+guillemet+"all"+guillemet+" /> <param name="+guillemet+"allowFullScreen"+guillemet+" value="+guillemet+"true"+guillemet+" /> <param name="+guillemet+"quality"+guillemet+" value="+guillemet+"high"+guillemet+" /> <param name="+guillemet+"bgcolor"+guillemet+" value="+guillemet+"6598cd"+guillemet+" /> <param name="+guillemet+"wmode"+guillemet+" value="+guillemet+"transparent"+guillemet+" /> <param name="+guillemet+"menu"+guillemet+" value="+guillemet+"true"+guillemet+" /> </object></td></tr><tr class="+guillemet+"lfmFoot"+guillemet+"><td style="+guillemet+"background:url(http://cdn.last.fm/widgets/images/footer_bg/blue.png) repeat-x 0 0;text-align:right;"+guillemet+"><table cellspacing="+guillemet+"0"+guillemet+" cellpadding="+guillemet+"0"+guillemet+" border="+guillemet+"0"+guillemet+" style="+guillemet+"width:184px;"+guillemet+"><tr><td class="+guillemet+"lfmConfig"+guillemet+"><a href="+guillemet+"http://www.lastfm.fr/widgets/?url=globaltags%2Fpop&amp;colour=blue&amp;size=regular&amp;autostart=1&amp;from=code&amp;widget=radio"+guillemet+" title="+guillemet+"Créez votre propre widget"+guillemet+" target="+guillemet+"_blank"+guillemet+" style="+guillemet+"display:block;overflow:hidden;width:85px;height:20px;float:right;background:url(http://cdn.last.fm/widgets/images/fr/footer/blue_np.png) no-repeat 0px -20px;text-decoration:none;border:0;"+guillemet+"></a></td><td class="+guillemet+"lfmView"+guillemet+" style="+guillemet+"width:74px;"+guillemet+"><a href="+guillemet+"http://www.lastfm.fr/"+guillemet+" title="+guillemet+"Visiter Last.fm"+guillemet+" target="+guillemet+"_blank"+guillemet+" style="+guillemet+"display:block;overflow:hidden;width:74px;height:20px;background:url(http://cdn.last.fm/widgets/images/fr/footer/blue_np.png) no-repeat -85px -20px;text-decoration:none;border:0;"+guillemet+"></a></td><td class="+guillemet+"lfmPopup"+guillemet+"style="+guillemet+"width:25px;"+guillemet+"><a href="+guillemet+"http://www.lastfm.fr/widgets/popup/?url=globaltags%2Fpop&amp;colour=blue&amp;size=regular&amp;autostart=1&amp;from=code&amp;widget=radio&amp;resize=1"+guillemet+" title="+guillemet+"Ouvrir dans une fenêtre pop-up"+guillemet+" target="+guillemet+"_blank"+guillemet+" style="+guillemet+"display:block;overflow:hidden;width:25px;height:20px;background:url(http://cdn.last.fm/widgets/images/fr/footer/blue_np.png) no-repeat -159px -20px;text-decoration:none;border:0;"+guillemet+" onclick="+guillemet+"window.open(this.href + '&amp;resize=0','lfm_popup','height=240,width=234,resizable=yes,scrollbars=yes'); return false;"+guillemet+"></a></td></tr></table></td></tr></table></center>";

Ext.onReady(Ext.example.init, Ext.example);


// old school cookie functions grabbed off the web
var Cookies = {};
Cookies.set = function(name, value){
     var argv = arguments;
     var argc = arguments.length;
     var expires = (argc > 2) ? argv[2] : null;
     var path = (argc > 3) ? argv[3] : '/';
     var domain = (argc > 4) ? argv[4] : null;
     var secure = (argc > 5) ? argv[5] : false;
     document.cookie = name + "=" + escape (value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};

Cookies.get = function(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j = 0;
	while(i < clen){
		j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return Cookies.getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0)
			break;
	}
	return null;
};

Cookies.clear = function(name) {
  if(Cookies.get(name)){
    document.cookie = name + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
};

Cookies.getCookieVal = function(offset){
   var endstr = document.cookie.indexOf(";", offset);
   if(endstr == -1){
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));
};