
(function($){
    $.wiseup = {
    	classLanguageFlag:'.language-flag',
        languageForm:"#languageForm",
        folders:{
            js:"assets/js/",
            css:"assets/css/",
            wiseupJs:"wiseup/",
            wiseupCss:"wiseup/",
            jsPlugins:"plugins/"
        },
        ready:false,
        loadedPlugins:[]
    };
    $.extend($.wiseup,{
        modules: {
            ajax:{
                targetAttr:'rel',
                requires:[$.wiseup.folders.wiseupJs+'wiseup.ajax.js']
            },
            modal:{
                requires:[$.wiseup.folders.wiseupJs+'wiseup.modal.js']
            }
        },
        requires:function(dependencies,callback){
            jsPattern=new RegExp(/\.js$/i);
            cssPattern=new RegExp(/\.css$/i);
            //string com javascript que vai ser executado em eval
            var str="Sexy({cache:true,defer:true})";
            for(i in dependencies){
                if(typeof $.wiseup.loadedPlugins.indexOf(dependencies[i]) >-1)
                    continue;
                if(jsPattern.test(dependencies[i]))
                    str+=".js('"+$.wiseup.baseUrl+$.wiseup.folders.js+dependencies[i]+"')";
                else if(cssPattern.test(dependencies[i]))
                    str+=".css('"+$.wiseup.baseUrl+$.wiseup.folders.css+dependencies[i]+"')";
                eval(str.substr(0,str.length-1)+","+(callback || function(){})+");");
                $.wiseup.loadedPlugins.push(dependencies[i]);
            }
            return $.wiseup;
        },
        load:function(pluginName,ready){
            $.wiseup.ready=false;
            dependencies=null;
            ready=ready || function(){};
            dependencies=eval("$.wiseup.modules."+pluginName+".requires");
            if(dependencies!==null)
                $.wiseup.requires(
                    dependencies,
                    ready
                );
            else
                ready();
            return $.wiseup;
        },
        init:function(callback,target){
        	$(document).ready(function(){$.wiseup.initLanguage()});
            setInterval(function(){
                if($.wiseup.ready !== false){
                    $.wiseup.ready;
                    $.wiseup.ready=false;
                }
            },200);
            return $.wiseup;
        },
        changeLanguage:function(language, midia){
	    	$('#lang').val(language);
	    	$('#midiaId').val(midia);
	    //midiaId = midia;
	    	$($.wiseup.languageForm).submit();
    	},
    	initLanguage:function(){
    		
    		$($.wiseup.classLanguageFlag).each(function(){
    			$(this).click(function(){
    				$.wiseup.changeLanguage($(this).attr('rel'), $(this).attr('relm'));
    			});
    		});
    	}
    });
    $.wiseup.init();
}(jQuery));
/**
 * Sexy.js v0.8
 * http://sexyjs.com/
 *
 * Copyright 2010, Dave Furfero
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://sexyjs.com/license
 */
(function(k,l,q){var h=k.location,o=h.protocol+"//"+h.hostname+(h.port!==""?":"+h.port:""),f="__",m=["html","json","jsonp","script","style","text","xml"],e,b;function c(i){if(!(this instanceof c)){return new c(i);}this.cfgs=[];this.setup(i);}c.prototype={setup:function(i){this.cfg=i||{};return this;},sajax:function(x){var v=this.cfgs,w=v.length,s=v[w-1],z=x.dataType,r=x.url.indexOf("http")===0&&x.url.indexOf(o)===-1,u=z==="script",B=z==="style",i=w>0?r&&(u||B)?true:x.defer:false,A=x.success||(u||B?p:g),y=x.error||q.noop,n=x.complete||q.noop;v.push(q.extend(true,x,this.cfg,x,{sendAfterSend:[],dataType:(!r&&u||B)?"text":z,success:function(D,C){if(!s||f in s){if(u&&!r){q.globalEval(D);}else{if(B&&!r){D=q.styleEval(D);}}x.status=r?"success":C;x[f]=A.call(x,D,s&&s[f],v[w+1],x.status);if(x.nextSuccess){x.nextSuccess();}else{if(x.sendAfterSuccess){x.sendAfterSuccess();}}}else{s.nextSuccess=q.proxy(function(){x.success(D,C);},x);}},error:function(E,C,D){y.call(x,E,C,D);},complete:function(D,C){n.call(x,D,C);}}));function t(){var C,D;if(B&&r){q.getCSS(x.url,x.success);}else{q.ajax(x);}if(x.sendAfterSend.length>0){for(C=0,D=x.sendAfterSend.length;C<D;++C){x.sendAfterSend[C]();}}}if(i){s.sendAfterSuccess=t;this.lastDefer=x;}else{if(this.lastDefer){this.lastDefer.sendAfterSend.push(t);}else{t();}}return this;},bundle:function(){var r=arguments,t=q.isFunction(r[r.length-1])?Array.prototype.pop.call(r):p,s,u;for(s=0,u=r.length-1;s<u;++s){this.text(r[s],j);}return this.text(r[s],function(w,v,n,i){var x=j(w,v);q.globalEval(x);return t(x,v,n,i);});}};function g(i){return i;}function p(n,i){return i;}function j(n,i){return(i||"")+n;}function d(i){c.prototype[i]=function(n,s,r){if(typeof n==="string"){if(typeof s!=="boolean"){r=s;s=false;}n={url:n,defer:s,success:r};}n.dataType=i;return this.sajax(n);};}for(e=0,b=m.length;e<b;++e){d(m[e]);}c.prototype.js=c.prototype.script;c.prototype.css=c.prototype.style;function a(i){c[i]=function(){return c.prototype[i].apply(new c(),arguments);};}for(e in c.prototype){a(e);}k.Sexy=q.sajax=c;})(this,this.document,(function(f,b,g){g.styleEval=function(l){var k=/\S/;if(l&&k.test(l)){var i=b.getElementsByTagName("head")[0]||b.documentElement,j=b.createElement("style");j.type="text/css";if(j.styleSheet){j.styleSheet.cssText=l;}else{j.textContent=l;}i.insertBefore(j,i.lastChild);return j;}};var d=b.getElementsByTagName("head")[0],a=/loaded|complete/,e={},c=0,h;g.getCSS=function(j,i,l){if(g.isFunction(i)){l=i;i={};}var k=b.createElement("link");k.rel="stylesheet";k.type="text/css";k.media=i.media||"screen";k.href=j;if(i.charset){k.charset=i.charset;}if(i.title){l=(function(m){return function(){k.title=i.title;m(k,"success");};})(l);}if(k.readyState){k.onreadystatechange=function(){if(a.test(k.readyState)){k.onreadystatechange=null;l(k,"success");}};}else{if(k.onload===null&&k.all){k.onload=function(){k.onload=null;l(k,"success");};}else{e[k.href]=function(){l(k,"success");};if(!c++){h=f.setInterval(function(){var r,o,q=b.styleSheets,m,n=q.length;while(n--){o=q[n];if((m=o.href)&&(r=e[m])){try{r.r=o.cssRules;throw"SECURITY";}catch(p){if(/SECURITY/.test(p)){r(k,"success");delete e[m];if(!--c){h=f.clearInterval(h);}}}}}},13);}}}d.appendChild(k);};return g;})(this,this.document,this.jQuery));
