(function(){currentPage=null;pageHistory=[];var animateX=-20;var animateInterval=24;var currentDialog=null;var currentWidth=0;var currentHash=location.hash;var hashPrefix="#_";addEventListener('load',function(event){var home=$('home');home.setAttribute('selected','true');showPage(home);setInterval(checkOrientAndLocation,300);},false);addEventListener('click',function(event){event.preventDefault();var link=event.target;while(link && link.localName && link.localName.toLowerCase() !='a'){link=link.parentNode;}if(link){if(link.href && link.getAttribute('rel')=='external'){window.location=link.href;}else if(link.hash){showPage(document.getElementById(link.hash.substr(1)));}}},true);function checkOrientAndLocation(){if(window.outerWidth !=currentWidth){currentWidth=window.outerWidth;document.body.setAttribute('orient',(currentWidth==320?'profile':'landscape'));}if(location.hash !=currentHash){currentHash=location.hash;var pageId=currentHash.substr(hashPrefix.length);var page=document.getElementById(pageId);if(page){var index=pageHistory.indexOf(pageId);var backwards=index !=-1;if(backwards){pageHistory.splice(index,pageHistory.length);}showPage(page,backwards);}}}function showPage(page,backwards){if(currentDialog){currentDialog.removeAttribute("selected");currentDialog=null;}location.href=currentHash=hashPrefix+page.id;pageHistory.push(page.id);var fromPage=currentPage;currentPage=page;if(fromPage){setTimeout(swipePage,0,fromPage,page,backwards);}}function swipePage(fromPage,toPage,backwards){toPage.style.left="100%";toPage.setAttribute("selected","true");var percent=100;var timer=setInterval(function(){percent+=animateX;if(percent<=0){percent=0;fromPage.removeAttribute("selected");clearInterval(timer);}fromPage.style.left=(backwards?(100-percent):(percent-100))+"%";toPage.style.left=(backwards?-percent:percent)+"%";},animateInterval);}})();var AJAX=function(url,callback){var request=new XMLHttpRequest();request.open('GET',url,true);request.onreadystatechange=function(){if(request.readyState==4 && request.status==200){eval(callback)(request.responseXML);}};request.send(null);};var CORE={'attr':{'lang':null,'feed':null},'news':{'com':{},'es':{},'fr':{},'de':{},'ru':{},'cn':{}},'load':function(lang,feed){CORE.reset();CORE.attr.lang=lang;CORE.attr.feed=feed;if(typeof(CORE.news[lang]) !='undefined' && typeof(CORE.news[lang][feed]) !='undefined'){CORE.show(lang,feed);}else{new AJAX('ajax.php?lang='+lang+'&feed='+encodeURIComponent(feed),'CORE.analyze');}},'analyze':function(xml){var lang=CORE.attr.lang;var feed=CORE.attr.feed;var item={};var objs=[];var i=0;if(!xml){return;}var items=CORE.parse(xml);var length=items.length;if(length===0){return;}for(i;i<length;i++){item=items[i];objs[i]={'link':item['link'],'title':item['title']}}CORE.news[lang][feed]=objs;objs={};CORE.show(lang,feed);},'show':function(lang,feed){var objs=CORE.news[lang][feed];var list=$(currentPage.id);var shot=(feed=='featured'||feed.indexOf('charts') !=-1);var item={};var html={};var i=0;while(list.hasChildNodes()){list.removeChild(list.childNodes[0]);}var length=objs.length;for(i;i<length;i++){item=objs[i];if(shot){html.img=new Image();html.img.src='http://'+(lang=='de'?'shots.websnapr.com':'enimages.websnapr.com')+'/?size=s&url='+encodeURIComponent(item.link);(function(link){html.img.onclick=function(){window.location=link;};})(item.link);}html.a=document.createElement('a');html.a.href=item.link;html.a.setAttribute('rel','external');html.a.innerHTML=item.title;html.a2=document.createElement('a');html.a2.href=item.link;html.a2.className='link';html.a2.setAttribute('rel','external');html.a2.appendChild(document.createTextNode(item.link.replace('http://','').replace('https://','')));html.p=document.createElement('p');html.p.className='clear';html.li=document.createElement('li');if(typeof(html.img) !='undefined'){html.li.appendChild(html.img);}html.li.appendChild(html.a);html.li.appendChild(html.a2);html.li.appendChild(html.p);list.appendChild(html.li);html={};}},'parse':function(xml){var items=[];var i=0,j=0;var rootNode=xml.documentElement;var childNode=rootNode.firstChild;while(childNode){childNode=childNode.nextSibling;}var itemNodes=xml.getElementsByTagName('item');for(i;i<itemNodes.length;i++){var item={};var child;for(j=0;j<itemNodes[i].childNodes.length;j++){child=itemNodes[i].childNodes[j];switch(child.nodeName){case "title":try{item.title=child.firstChild.nodeValue;}catch(e){}break;case "link":try{item.link=child.firstChild.nodeValue;}catch(e){}break;}}items.push(item);}return items;},'reset':function(){var list=$('list');var html={};while(list.hasChildNodes()){list.removeChild(list.childNodes[0]);}html.li=document.createElement('li');html.li.className='loading';html.li.appendChild(document.createTextNode('Loading...'));list.appendChild(html.li);}};function $(id){return document.getElementById(id);}