function eLog(msg){    $("body").html("<p>Log:"+msg+"</p>");}var q,k;q=0;k=0;var news=new Array();var persistence=8000;function loadAjaxNews(){        try{        $.ajax({            type: "GET",            url: "xml/news.xml",            dataType: "xml",            success: function(xml) {                $(xml).find('news').each(function(){                                              $(this).find('item').each(function(){                                                                                news[q]={                            'id': $(this).find('id').text(),                             'h_title': $(this).find('h_title').text(),                            'h_subtitle': $(this).find('h_subtitle').text(),                            'h_image': $(this).find('h_image').text(),                            'link': $(this).find('link').text(),                            'dataDay': $(this).find('dataDay').text(),                            'dataMonth': $(this).find('dataMonth').text(),                            'dataYear': $(this).find('dataYear').text(),                            'd_title': $(this).find('d_title').text(),                            'd_content': $(this).find('d_content').text(),                            'd_image': $(this).find('d_image').text()                                                  };                        q++;                                                                            });                });                                    k=0;                runIt();            }                        });       }catch(e){                alert("Errore"+e);    }}function runIt(){        try{                    if(k<q){                        $('#news img#news_img').attr("src",news[k].h_image);                        if(news[k].id==4){                $('#news a#news_link').attr("href","/photocontest/index.jsp");            }else if(news[k].id==3){                $('#news a#news_link').attr("href","/events_Monster-Party.html");            }else if(news[k].id==2){                $('#news a#news_link').attr("href","/events_relieve-the-unveiling-of-the-monster-795.html");            }else if(news[k].id==1){                $('#news a#news_link').attr("href","/ciao-marco.html");            }                        $('#news div#news_content').html("<span>"+news[k].h_title+"</span> "+news[k].h_subtitle+"</p>");                                 if(q==1){                $('#news img#news_img').delay(1000).animate({                    'top':'0px'                },200)                $('#news #hider').animate({                    'width':'0px',                    'opacity':'0'                },400)                $('#news #news_content').fadeIn(10);            }else{                $('#news img#news_img').delay(1000).animate({                    'top':'0px'                },200).delay((persistence-2000)).animate({                    'top':'-200px'                },200).delay(1000);                  $('#news #hider').animate({                    'width':'0px',                    'opacity':'0'                },400).delay((persistence-400)).animate({                    'width':'354px',                    'opacity':'1'                },400);                $('#news div#news_content').fadeIn(10).delay(200).delay(persistence).delay(200).fadeOut(10);            }            k++;            if(k==q){                k=0;            }                       }                     }catch(e){        alert("Errore"+e);    }}function reposNews(){    var w=$(window).width()    if(w > 1212){        $("div#news").css('right',"0px");    }else{        $("#news").css('right',((1212-w)/2)+"px");    } }var userAgent = navigator.userAgent;if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {    jQuery(document).ready(function($) {        loadAjaxNews();               setInterval(function() {            runIt();        }, (persistence+1000));    });}else {    jQuery(document).ready(function($) {        loadAjaxNews();        reposNews();               setInterval(function() {            runIt();        }, (persistence+1000));    });    jQuery(window).resize(function() {        reposNews();    });}
