/* 
Compiled  : 09.12.2009 15:14:10
Author    : Marc Janin (iguana.lu)
Copyright : www.iguana.lu
Contact   : For any questions, contact me by iguana.lu!
 */
function News() {this.btnUpcoming    = dojo.byId('btnUpcoming');this.btnShowAll   = dojo.byId('btnShowAll');this.resultContainer = dojo.byId('news_search_resultContainer');this.title = dojo.byId('titleNews');this.isFirstClick    = true;this.searchArg       = '';/*this.executeSearchAll();*/this.enableEventsAjax();this.enableEvents();};News.prototype.enableEvents = function() {var me = this;dojo.connect(me.btnUpcoming, 'onclick', null, function(event) {dojo.stopEvent(event);me.executeSearchUpcoming(); });dojo.connect(me.btnShowAll, 'onclick', null, function(event) {dojo.stopEvent(event);me.executeSearchAll(); });};News.prototype.enableEventsAjax = function() {var me = this;var btnShowFlyers = dojo.query('.btnShowFlyer');dojo.forEach(btnShowFlyers, function (btnShowFlyer) {dojo.connect(btnShowFlyer, 'onclick', null, function (event) {dojo.stopEvent(event);var idNews = btnShowFlyer.href.split('/')[btnShowFlyer.href.split('/').length-1];popup.setContent('<img id="photoPopupImg" src="/app/img/loading.circle.gif" alt="" />').setTitle('Loading photo...').show();dojo.xhrPost({url: btnShowFlyer.href,sync: false,handleAs: 'json',load: function(data) {if (!data.status) return;var img = dojo.create('img');img.src = data.href;dojo.connect(img, 'onload', null, function() {popup.setContent(img).setTitle('');});}});});});var btnDeletes = dojo.query('.btnDelete');for (var i=0; i<btnDeletes.length; i++) {dojo.connect(btnDeletes[i], 'onclick', null, function(event) {dojo.stopEvent(event);var currentElement = this;var params = currentElement.href.split('/');var res = confirm('Are you sure to delete this news?');if (!res) return;var div = currentElement.parentNode.parentNode.parentNode;div.style.backgroundColor = '#FF0000';dojo.xhrPost({url: currentElement.href,sync: true,handleAs: 'json',load: function(data) {if (!data.status) return;dojo.fadeOut({node: div, delay:0, duration: 1000, onEnd: function() {div.parentNode.removeChild(div);}}).play();}});});};};News.prototype.executeSearchAll = function() {this.setSearchArg("all");this.executeSearch();this.title.innerHTML = 'All News';};News.prototype.executeSearchUpcoming = function() {this.setSearchArg("upcoming");this.executeSearch();this.title.innerHTML = 'Upcoming News';};News.prototype.executeSearch = function() {var me = this;me.loadingProcessStarted();dojo.xhrPost({url: '/en/news/search/news?format=html',sync: true,/*handleAs: 'json',*/content: {searchArg:  me.getSearchArg() },load: function(data) {me.resultContainer.innerHTML = data;me.loadingProcessComplete();me.enableEventsAjax();new AdminControls();}});};News.prototype.loadingProcessStarted = function() {var me = this;me.btnUpcoming.style.color = '#808080';me.btnShowAll.style.color = '#808080';me.resultContainer.innerHTML = '<img src="/app/img/loading.circle.gif" alt="" />';};News.prototype.loadingProcessComplete = function() {var me = this;me.btnUpcoming.style.color = '#000';me.btnShowAll.style.color = '#000';};News.prototype.getSearchArg = function() {return this.searchArg;};News.prototype.setSearchArg = function(searchArg) {this.searchArg = searchArg;};dojo.addOnLoad(window, function() {new News();});
