 // Wonder Ticker v1.3 04 March 2008 // Use Freely as long as following disclaimer is intact ::
 //---------------------------------------------------------------
 // Cross Browser Multi-Directional Scroller v1.0 24th August 2004
 // Portion of the script written by Rik Comery. www.ricom.co.uk
 // For support, visit the "Resources" section at www.ricom.co.uk
 // All rights reserved.   
 // Featured in the SimplytheBest DHTML Scripts Library at http://simplythebest.net/scripts/ 
 //---------------------------------------------------------------
 // Portion of ticker scrolling by Rik Comery. http://www.ricom.co.uk
 // Portion of Json by Beautiful Beta. http://beautifulbeta.wikidot.com
 // Portion of modal windows by SoftComplex Inc. http://www.softcomplex.com
 // Snazzy borders by Stu Nicholls. http://www.cssplay.co.uk
 /* DEFINE SCROLLER ELEMENTS
   Define new scroller elements here in the following format.
   tkr_Article[i] = new Array ("display text", "URL", "frame target to load link in");i++  
   Note: If you do not want the item to be a link, change the URL value to "none".
 */

 ////// SCROLLER CONFIGURATION ///////////////////////////////////////////////////////////////////

 tkr_orientation = "horizontal";          // Orientation of scroller (Horizontal or vertical)
 tkr_scrollerHeight = "20";               // Height of Scroller.
 //tkr_scrollerWidth = '610';             // Width of entire scroller.
 //-------------------------------------------------------------- //tkr_orientation = "vertical";          // Orientation of scroller (Horizontal or vertical)
 //tkr_scrollerHeight = "200";            // Height of Scroller.
 //tkr_scrollerWidth = '200';             // Width of entire scroller.
 //-------------------------------------------------------------- tkr_borderWidth = 0;                     // Width of border. (use 0 for no border).
 tkr_borderColour = "#006600";            // Colour of scroller border. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red") 
 tkr_backColour = "#EDEDED";            // Colour of scroller background. (Use either hexadecimal or text values. e.g. "#FF0000" or "Red") 
 tkr_staticColour = "#EDEDED";          // Colour of scroller items that are NOT a link. (including tkr_scrollerDivider characters)
 //tkr_staticColour = tkr_linkColour;       // tkr_stopScroll = 1;                      // Pause the scroller on mouseOver. (use 0 for no.)
 tkr_textAlignment="left";                // Alignment of each scroller item.  Only really makes a difference on vertical scroller
                                          // (center, left, right, justify)
 //--------------------------------------------------------------
 // Scroller Links
 tkr_linkFont = "Arial";                // Font of scroller links;
 tkr_linkWeight = "400";                 // Weight of scroller links;
 tkr_linkColour = "#2e3192";            // Colour of scroller links
 tkr_linkSize = "11";                     // Size of links (in points)
//--------------------------------------------------------------
 // Scroller Links On MouseOver
 tkr_slinkFont = "arial";               // Font of scroller links;
 tkr_slinkWeight = "bold";                // Weight of scroller links;
 tkr_slinkColour = "#2e3192";             // Colour of scroller links
 tkr_slinkSize = "11";                    // Size of links (in points)

 tkr_scrollerDivider = " | ";             // Character to place between each scroller item. 
                                          // <img> tags can be used if an image is required. 
                                          // Use "0" for nothing.  For Vertical scrollers, it is best to use "<br>"
                                          //  | for horizontal
 //--------------------------------------------------------------
 var tkr_stop_scroller = false; var tkr_timer = 0;
 var tkr_windowopen = false;
 var tkr_array_index = -1; var tkr_d_height;
 var tkr_center_modal;
 //--------------------------------------------------------------
 tkr_Article = new Array; th_art=0;
 var tkr_numposts=7;
 //var tkr_numchars=1000; var tkr_N_BASEZINDEX = 0;
 //--------------------------------------------------------------
 style='<style type="text/css">';
 style+='div.tkr_rcScroller{font-family:'+tkr_linkFont+'; color:'+tkr_staticColour+'; font-size:'+tkr_linkSize+'px; font-weight:'+tkr_linkWeight+'; text-align:'+tkr_textAlignment+'}';
 style+='a.tkr_rcScroller,a.tkr_rcScroller:active,a.tkr_rcScroller:visited{cursor:pointer;color:'+tkr_linkColour+';text-decoration:none; font-weight:'+tkr_linkWeight+'}';
 style+='a.tkr_rcScroller:hover{color:'+tkr_slinkColour+';text-decoration:underline; font-weight:'+tkr_slinkWeight+'}'; 
 //--------------------------------------------------------------
 style+='table.tkr_dialogWindow {border-collapse: collapse;}';
 style+='.tkr_dialogWindow th {background-color: #fff; padding: 4px; border-collapse: collapse; border: 0;}';
 style+='.tkr_dialogWindow th img {cursor: pointer; margin: 3px 3px 0 0;}';
 style+='.tkr_dialogWindow td {border-collapse: collapse; border: 0; padding: 0;}';
 //--------------------------------------------------------------
 style+='#tkr_xsnazzy {background: transparent; margin:1em;}';
 style+='.tkr_xtop, .tkr_xbottom {display:block; background:transparent; font-size:1px;}';
 style+='.tkr_xb1, .tkr_xb2, .tkr_xb3, .tkr_xb4 {display:block; overflow:hidden;}';
 style+='.tkr_xb1, .tkr_xb2, .tkr_xb3 {height:1px;}';
 style+='.tkr_xb2, .tkr_xb3, .tkr_xb4 {background:#fff; border-left:1px solid #777; border-right:1px solid #777;}';
 style+='.tkr_xb1 {margin:0 5px; background:#777;}';
 style+='.tkr_xb2 {margin:0 3px; border-width:0 2px;}';
 style+='.tkr_xb3 {margin:0 2px;}';
 style+='.tkr_xb4 {height:2px; margin:0 1px;}';
 style+='.tkr_xboxcontent {display:block; background:#fff; border:0 solid #777; border-width:0 1px;}';
 //--------------------------------------------------------------
 style+='#tkr_page {font-size: 60.1%;font-family:verdana, helvetica, sans-serif;background-color:#fff;color: #546368;text-align: left;margin-left: 10px; padding: 1px;}'; style+='small.tkr_title {font-family: Arial, Helvetica, Sans-Serif;font-size: .94em;line-height: 1.5em;}';
 style+='h2.tkr_title {font-family: Arial, Helvetica, Sans-Serif;font-size: 18px;padding-bottom:4px;margin: 0px 0 0;}';
 style+='.tkr_narrowcolumn {font-size: 1.1em; text-align: left;line-height: 1.5em;float: left;margin: 0px 0 0;width: 490px;}';
 style+='.tkr_headline{border-bottom:1px dotted #ccc;}';
 style+='.tkr_body_preview{height:300px; overflow:auto; margin: 5px 0 0 0 ;}'; style+='<\/style>';
 document.writeln(style); //--------------------------------------------------------------
 // Build the scroller and place it on the page
 function tkr_buildScroller(){    scroller='<div id="tkr_div" style="';
    scroller+='height:'+tkr_scrollerHeight+'px;';
    scroller+='width:'+tkr_scrollerWidth+'; position:relative; background:url(/images/sfondo_ticker.jpg); background-repeat; repeat-x; overflow:hidden;">';
    scroller+='<div id="tkr_div1" style="position:relative; left:0; width:' + tkr_scrollerWidth + '">';
    scroller+='<table border="0" name="tkr_table" id="tkr_table"';
    if(tkr_orientation.toLowerCase()=="vertical"){scroller+='style="width:'+tkr_scrollerWidth+'"';}
    scroller+='><tr>';
    y=0;
    while(y<4){
      for(x=0; x<(tkr_Article.length); x++){
          if(tkr_orientation.toLowerCase()=="vertical"){scroller+='<tr>';}
          scroller+='<td ';
          if(tkr_orientation.toLowerCase()=="horizontal"){scroller+='nowrap';} if(tkr_stopScroll==1){scroller+=' onMouseOver="tkr_stopScroller();" onMouseOut="tkr_setWidth()"';}
          scroller+='><div class="tkr_rcScroller">';
          if(tkr_Article[x][1].toLowerCase()!="none"){scroller+='<a name="tkr_link" class="tkr_rcScroller" onmouseover="this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'" onclick="tkr_f_dialogOpen(' + x + ',510,450,event)">'+tkr_Article[x][0]+'<\/a>';
          }else{scroller+=tkr_Article[x][0];}
          scroller+='<\/div><\/td>';
          if(tkr_orientation.toLowerCase()=="vertical"){scroller+='<\/tr>';}
          if(tkr_scrollerDivider.toLowerCase() != "none"){scroller+='<td nowrap><div class="tkr_rcScroller">'+tkr_scrollerDivider+'<\/div><\/td>';}
      }
      y++;
    }
    scroller+='<\/tr><\/table><\/div><\/div>';
    document.getElementById('wonderticker').innerHTML = scroller; }
 //-------------------------------------------------------------- // Ensure the width of the scroller is divisible by 2. This allows smooth flowing of the scrolled content
 function tkr_setWidth(){
    if(tkr_stop_scroller == true) {tkr_stop_scroller = false;}    tableObj=document.getElementById("tkr_table");
    obj=document.getElementById("tkr_div1");
    objWidth=(tkr_orientation.toLowerCase()=="horizontal")?tkr_getOffset(tableObj,"width"):tkr_getOffset(tableObj,"height");
    HalfWidth=Math.floor(objWidth/2);
    newWidth = (HalfWidth*2)+2;
    obj.style.width=newWidth + "px";    tkr_moveLayer(obj, newWidth);
 } //--------------------------------------------------------------
 // Move the layer by one pixel to the left
 function tkr_moveLayer(obj, width){
    maxLeft = (0-(width/2)+2)/2;
    if(tkr_orientation.toLowerCase()=="horizontal"){
       obj.style.left=(parseInt(obj.style.left) <= maxLeft)?'0px':(parseInt(obj.style.left)-1) + 'px';
    }else{
       if(obj.style.top==""){obj.style.top=0;}
       if(parseInt(obj.style.top)<(0-(width/2)+6)){
          obj.style.top = '0px';
       }else{
          obj.style.top = (parseInt(obj.style.top)-1) + 'px';
       }
    }    clearTimeout(tkr_timer);
    tkr_timer = setTimeout ("tkr_moveLayer(obj, "+width+");", 20); }
 //-------------------------------------------------------------- // Get width and height of layer
 function tkr_getOffset(obj, dim){
    if(dim=="width"){
       oWidth = obj.offsetWidth;
       return oWidth;
    }
     else if(dim=="height")
    {
    oHeight = obj.offsetHeight;
    return oHeight;
    }
 }
 //------------------------------------------------------
 function tkr_stopScroller(){
       tkr_stop_scroller = true;       clearTimeout(tkr_timer);
 }
 //------------------------------------------------------ function tkr_runScroller(){
    if(tkr_stop_scroller == false){       tkr_setWidth();    }
 }
 //-------------------------------------------------------
 function WonderTicker(){
          var headID = document.getElementsByTagName("head")[0];
          var newScript = document.createElement('script');
          var label = '';
          newScript.type = 'text/javascript';
          if(tkr_label != ''){
             label = '/-/' + tkr_label;
          }
          newScript.src = 'http://' + tkr_url + '/feeds/posts/default' + label + '?alt=json-in-script&callback=tkr_showrecentposts';
          headID.appendChild(newScript);
 }
 //-------------------------------------------------------
 function tkr_showrecentposts(json) {
    if(json.feed.entry){
       if(json.feed.entry.length < tkr_numposts) {tkr_numposts = json.feed.entry.length};
       for(var i = 0; i < tkr_numposts; i++) {
           var entry = json.feed.entry[i];
           var posttitle = entry.title.$t;
           var posturl;
           if (i == json.feed.entry.length) break;
           for(var k = 0; k < entry.link.length; k++) {
               if(entry.link[k].rel == 'alternate') {
                  posturl = entry.link[k].href;
                  break;
               }
           }
           var postdate = entry.published.$t.substring(0,10);
           var postauthor = entry.author[0].name.$t;
           if("content" in entry){
              var postcontent = entry.content.$t;}
           else
              if("summary" in entry) {
                 var postcontent = entry.summary.$t;}
           else var postcontent = "";
           //if(postcontent.length > tkr_numchars) postcontent = postcontent.substring(0,tkr_numchars);
           tkr_Article[th_art] = new Array (posttitle, postauthor, postdate, postcontent); th_art++;
       }
    }else{
       tkr_Article[th_art] = new Array ("Ticker Error", "Ticker Error", "Ticker Error", "Ticker Error");
    }
    //---------------------------------------------------------
    tkr_buildScroller();
    setTimeout('tkr_runScroller()',2000)
 }
 //------------------------------------------------------------
 // this function makes the document numb to the mouse events by placing the transparent layer over it
 function tkr_f_putScreen (b_show) {
     if (b_show == null && !window.b_screenOn)
         return;
     if (b_show == false) {
         window.b_screenOn = false;
         if (e_screen) e_screen.style.display = 'none';
         return;
     }
     // create the layer if doesn't exist
     if (window.e_screen == null) {
         window.e_screen = document.createElement("div");
         e_screen.innerHTML = "&nbsp;";
         document.body.appendChild(e_screen);
         e_screen.style.position = 'absolute';
         e_screen.id = 'tkr_eScreen';
     }
     // set properties
     var a_docSize = tkr_f_documentSize();
     e_screen.style.left = a_docSize[2] + 'px';
     //e_screen.style.top = a_docSize[3] + 'px';
     e_screen.style.top = '0px';
     //e_screen.style.width = a_docSize[0] + 'px';
     e_screen.style.width = '1300px';
     //e_screen.style.height = a_docSize[1] + 'px';
     e_screen.style.height = '1700px';
     e_screen.style.zIndex = tkr_N_BASEZINDEX + a_windows.length * 2 - 1;
     e_screen.style.display = 'block';
     e_screen.style.background = "#333";
     if(navigator.appName=="Microsoft Internet Explorer"){
        e_screen.style.filter='alpha(opacity=40)';
     }else{
        e_screen.style.opacity=.40;
     }
 }
 //------------------------------------------------------------
 // returns the size of the document
 function tkr_f_documentSize () {
    var n_scrollX = 0,
    n_scrollY = 0;
    if (typeof(window.pageYOffset) == 'number') {
        n_scrollX = window.pageXOffset;
        n_scrollY = window.pageYOffset;
    }
    else if (document.body && (document.body.scrollLeft || document.body.scrollTop )) {
        n_scrollX = document.body.scrollLeft;
        n_scrollY = document.body.scrollTop;
    }
    else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        n_scrollX = document.documentElement.scrollLeft;
        n_scrollY = document.documentElement.scrollTop;
    }
    if (typeof(window.innerWidth) == 'number')
        return [window.innerWidth, window.innerHeight, n_scrollX, n_scrollY];
    if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
        return [document.documentElement.clientWidth, document.documentElement.clientHeight, n_scrollX, n_scrollY];
    if (document.body && (document.body.clientWidth || document.body.clientHeight))
        return [document.body.clientWidth, document.body.clientHeight, n_scrollX, n_scrollY];
    return [0, 0];
 }
 //------------------------------------------------------------
 function tkr_f_dialogOpen (th_array, d_width, d_height, e){
    if (!window.a_windows)
        window.a_windows = [];
    // create element for window
    var n_nesting = a_windows.length;
    var e_window = document.createElement("div");
    e_window.id = 'e_window_data';
    e_window.style.position = 'absolute';
    var n_width  = d_width + 'px';
    var n_height = d_height + 'px';
    a_docSize = tkr_f_documentSize ();
    e_window.style.left = ((a_docSize[0] - d_width) / 2) + a_docSize[2] + 'px';
    e_window.style.top  = ((a_docSize[1] - d_height) / 2) + a_docSize[3] + 'px';
    tkr_a_docSize = a_docSize;
    tkr_d_height = d_height;
    //var posy=30;
    // positioning near the ticker
    //var ev=(!e)?window.event:e;//Moz:IE
    //if (ev.pageY){posy=ev.pageY}//Mozilla or compatible
    //else if(ev.clientY){posy=ev.clientY}//IE or compatible
    //e_window.style.top  = posy + 'px';
    e_window.style.zIndex = tkr_N_BASEZINDEX + a_windows.length * 2 + 2;
    //---------------------------------------------------------
    var content = '<div id="tkr_xsnazzy" style="width:' + (parseInt(d_width)+15) + 'px;">';
    content += '<b class="tkr_xtop"><b class="tkr_xb1"></b><b class="tkr_xb2"></b><b class="tkr_xb3"></b><b class="tkr_xb4"></b></b>';
    content += '<div class="tkr_xboxcontent">';
    content += '<table class="tkr_dialogWindow">';
    content += '<tr><th onselectstart="return false">';
    content += '<img src="http://www.wonderticker.com/close.gif" onclick="tkr_f_dialogClose();" onmousedown="return false;" style="float:right"></th></tr><tr><td>';
    content += '<div id="tkr_page">';
    content += '<div class="tkr_narrowcolumn">';
    content += '<div class="tkr_headline">';
    content += '<h2 class="tkr_title" style="padding-top:10px;">'+ tkr_Article[th_array][0] +'</h2>';
    content += '<small class="tkr_title">' + tkr_Article[th_array][2] + ' by: <b>' + tkr_Article[th_array][1] + '</b></small>';
    content += '</div>';
    content += '<div class="tkr_body_preview">' + tkr_Article[th_array][3] + '</div>';
    //content += '<iframe src =' + '"http://www.wonderticker.com/adsense.html?' + tkr_adsense + ',' + tkr_adsense_slot + '" width=500 height=80 scrolling=no frameborder=0></iframe>';
    content += '</div>';
    content += '</div>';
    content += '</td></tr></table>';
    content += '</div>';
    content += '<b class="tkr_xbottom"><b class="tkr_xb4"></b><b class="tkr_xb3"></b><b class="tkr_xb2"></b><b class="tkr_xb1"></b></b>';
    content += '</div>';
    content += '</div>';
    e_window.innerHTML = content;
    //--------------------------------------------------------
    document.body.appendChild(e_window);
    a_windows[n_nesting] = e_window;
    // put the screen
    tkr_f_putScreen(true);
    tkr_windowopen = true;
    tkr_array_index = th_array;
    tkr_center_modal = setInterval("tkr_SetStatic()",1);
 }
 //------------------------------------------------------------
 function tkr_SetStatic(){
    a_docSize = tkr_f_documentSize ();
    document.getElementById("e_window_data").style.top = ((a_docSize[1] - tkr_d_height) / 2) + a_docSize[3] + 'px';
 }
 //------------------------------------------------------------
 function tkr_f_dialogClose () {
    clearInterval(tkr_center_modal);
    var n_nesting = a_windows.length - 1;
    // destroy element
    if (a_windows[n_nesting].removeNode)
        a_windows[n_nesting].removeNode(true);
    else if (document.body.removeChild)
        document.body.removeChild(a_windows[n_nesting]);
    a_windows[n_nesting] = null;
    a_windows.length = n_nesting;
    // move the screen
    tkr_f_putScreen(n_nesting ? true : false);
    tkr_windowopen = false;
 }
 // --------------------- START TICKER ------------------------
 //var tkr_oldLoad = window.onload;
 //window.onload=function(){
 //       if (tkr_oldLoad) tkr_oldLoad();
 //       WonderTicker();
 //}
