/* --------------------

    This file contains the functions controlling the main site and widgets.
    It contains functions for adding, and removing widgets, and functions for storing this
    information in cookies. It also contains the required glow scripting for the add widgets menu.

-------------------- */
// function for dropdown menu on navbar
function nav()
   {
   var w = document.myform.mylist.selectedIndex;
   var url_add = document.myform.mylist.options[w].value;
   window.location.href = url_add;
   }

function nav2()
   {
   var w = document.myform1.mylist1.selectedIndex;
   var url_add = document.myform1.mylist1.options[w].value;
   window.location.href = url_add;
   }

// widget_sortable is a variable for the sortable so we can reference it later
var widget_sortable;
// global_timer and thisObject is used for overlayText hints
var global_timer; var thisObject;

  glow.ready(function(){
    widget_sortable = new glow.widgets.Sortable(
        '#cols .col1, #cols .col2, #cols .col3',
        {
            draggableOptions : {
                handle : 'strong'
            }
            ,// function for updating widget order
            onSort : function () {
              storeOrder();
            }
            
        }
    );
 
  });
//-- ooooooooooooooooooooooooooo load glow script oooooooooooooooooooooooooo 

//-- ooooooooooooooo function for storing order in a cookie ooooooooooooooo
function storeOrder() {
var order1 = [];
var order2 = [];
var order3 = [];
// get the widget orders from all columns
glow.dom.get('#cols .col1 > *').sort().each(function () {order1.push(glow.dom.get(this).attr('id'));});
glow.dom.get('#cols .col2 > *').sort().each(function () {order2.push(glow.dom.get(this).attr('id'));});
glow.dom.get('#cols .col3 > *').sort().each(function () {order3.push(glow.dom.get(this).attr('id'));});
// remove uniq identifier part
for (i = 0;i < order1.length;i++)
  if (order1[i] != null)
    order1[i] = removeUniq(order1[i]);

for (i = 0;i < order2.length;i++)
  if (order2[i] != null)
    order2[i] = removeUniq(order2[i]);

for (i = 0;i < order3.length;i++)
  if (order3[i] != null)
    order3[i] = removeUniq(order3[i]);

// combine into one variable.
// , = widget separator 
// | = column separator
// TODO separate widget id number from widget id with # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var order = order1.join(',') + '|' + order2.join(',') + '|' + order3.join(',');

var expires = new Date();
expires.setDate(expires.getDate()+180); // days the order is stored
// store the order into a cookie
document.cookie = "widgets=" + escape(order) + " ;expires="+expires.toGMTString();
}
//-- ooooooooooooo end function for storing order in a cookie ooooooooooooo


//-- oooooooooooooo function for removing order from cookie ooooooooooooooo
function removeOrder(order) {
var expires = new Date();
expires.setDate(expires.getDate()-1); // -1 days means the cookie has expired so the browser will clear it
document.cookie = "widgets= ;expires="+expires.toGMTString();
// remove default tabs for widgets with tabs
// TODO, more general remove function
document.cookie = "tab_kulturnyheter= ;expires="+expires.toGMTString();
document.cookie = "tab_twitter= ;expires="+expires.toGMTString();
document.cookie = "tab_feature= ;expires="+expires.toGMTString();
window.location.href = window.location.href;
}
//-- oooooooooooo end function for removing order from cookie ooooooooooooo


//-- oooooooooooooooooooo function for removing widget oooooooooooooooooooo
function removeWidget(widget_id) {
var parent = document.getElementById(widget_id).parentNode;
var widget = document.getElementById(widget_id);
parent.removeChild(widget);
storeOrder();
updateAddList();
}
function removeWidget2(widget_id) {
var parent = document.getElementById(widget_id).parentNode;
var widget = document.getElementById(widget_id);
parent.removeChild(widget);
storeOrder();
updateAddList();
}
//-- oooooooooooooooooo end function for removing widget oooooooooooooooooo


//-- oooooooooooooooooo get widget_id without uniq part ooooooooooooooooooo
function removeUniq(widget_id_uniq) {
var widget_id_array = widget_id_uniq.split("#");
return widget_id_array[0];
}
//-- oooooooooooooooo end get widget_id without uniq part ooooooooooooooooo


//-- oooooooooooooo function for checking if widget is added oooooooooooooo
// returns first widget found in the following form: widget_id#uniqid
function isAdded(widget_id) {
var order1 = [];
var order2 = [];
var order3 = [];
// get widgets from columns
glow.dom.get('#cols .col1 > *').sort().each(function () {order1.push(glow.dom.get(this).attr('id'));});
glow.dom.get('#cols .col2 > *').sort().each(function () {order2.push(glow.dom.get(this).attr('id'));});
glow.dom.get('#cols .col3 > *').sort().each(function () {order3.push(glow.dom.get(this).attr('id'));});
var found = "";
// search the columns for widget_id
for (i2 = 0;i2 < order1.length;i2++)
  if (order1[i2] != null)
    if (widget_id == removeUniq(order1[i2])) {
      found = order1[i2];
      break;
    }

if (found == "")
  for (i2 = 0;i2 < order2.length;i2++)
    if (order2[i2] != null)
    if (widget_id == removeUniq(order2[i2])) {
      found = order2[i2];
        break;
      }
if (found == "")
  for (i2 = 0;i2 < order3.length;i2++)
    if (order3[i2] != null)
    if (widget_id == removeUniq(order3[i2])) {
      found = order3[i2];
        break;
      }
return found;
}
//-- oooooooooooo end function for checking if widget is added oooooooooooo


//-- oooooooooooooooooooo function for adding a widget oooooooooooooooooooo
function addWidget(widget_id, column) {
// function for loading the widget content
if (isAdded(widget_id) != "") {
  removeWidget(isAdded(widget_id));
  updateAddList();
}
else {
  var request = glow.net.get("oop_widget3.php?widget_id="+widget_id, {
    onLoad: function(response) {
      var newWidget = glow.dom.create(response.text());
      newWidget.prependTo('#'+column);
      widget_sortable.addItems(newWidget);
      storeOrder();
      updateAddList();
    }});
}
}
//-- oooooooooooooooooo end function for adding a widget oooooooooooooooooo


//-- ooooooooooooooo function for updating add widgets list ooooooooooooooo
// TODO: This script has the number of columns as a constant!
function updateAddList() {
var order1 = [];
var order2 = [];
var order3 = [];
// get widgets from columns
glow.dom.get('#cols .col1 > *').sort().each(function () {order1.push(glow.dom.get(this).attr('id'));});
glow.dom.get('#cols .col2 > *').sort().each(function () {order2.push(glow.dom.get(this).attr('id'));});
glow.dom.get('#cols .col3 > *').sort().each(function () {order3.push(glow.dom.get(this).attr('id'));});
// remove uniq identifier part
for (i2 = 0;i2 < order1.length;i2++)
  if (order1[i2] != null)
    order1[i2] = removeUniq(order1[i2]);

for (i2 = 0;i2 < order2.length;i2++)
  if (order2[i2] != null)
    order2[i2] = removeUniq(order2[i2]);

for (i2 = 0;i2 < order3.length;i2++)
  if (order3[i2] != null)
    order3[i2] = removeUniq(order3[i2]);
// check widgets exists and update widget list
var list = glow.dom.get("#addWidgets").children();
var leftdiv;
for (i = 0;i < list.length;i++) {
  if (list.item(i).getAttribute("id") == "addWidget") {
    leftdiv = glow.dom.get(list.children()[i]).get(".checkbox_left");
    if (leftdiv.attr("id") == undefined)
        leftdiv = glow.dom.get(list.children()[i]).get(".checkbox_leftchecked");
    if (isAdded(leftdiv.attr("id")) != "")
      leftdiv.attr("class", "checkbox_leftchecked");
    else
      leftdiv.attr("class", "checkbox_left");
  }
}
}
//-- ooooooooooooo end function for updating add widgets list ooooooooooooo

//-- oooooooooooooooooooooooooo add widget panel oooooooooooooooooooooooooo
var addWidgets;

glow.ready(function(){
  addWidgets = new glow.widgets.Panel("#addWidgets", {
    width: 540,
    theme: "dark",
    modal: false,
    anim: "fade"
  });
  updateAddList();
  // Display is none as default so it doesn't show up when the page is loading, now unhide it.
  var tmp = glow.dom.get("#addWidgets");
  tmp.css("display", "");
});

function Show_Stuff(Click_Menu)
// Function that will swap the display/no display for
// all content within span tags
{
if (Click_Menu.style.display == "none")
{
Click_Menu.style.display = "";
}
else
{
Click_Menu.style.display = "none";
}
}


function widgetmove_onmouseover(id) {
// Function for adding borders to widget when in focus
    glow.dom.get("#" + id).addClass("widgetmove");
}

function widgetmove_onmouseout(id) {
// Function for removing borders from widget when blurred
    glow.dom.get("#" + id).removeClass("widgetmove");
    // Remove 'top' style class left if widget was moved
    glow.dom.get("#" + id).css("top", "");
}







/* --------------------

    This file contains functions availble to and used by many different widgets
    such as a tab menu script and an overlay text script.

-------------------- */



//-- ooooooooooooooooooooooooooo load script based on easytab  ooooooooooooooooooooooo 

var tablink_idname = new Array();
var tabcontent_idname = new Array();
var tabcount = new Array();
var loadtabs = new Array();

function add_tab(name, count, loadtab) {
  tablink_idname[name] = "tablink_" + name;
  tabcontent_idname[name] = "tabcontent_" + name;
  tabcount[name] = count;
  loadtabs[name] = loadtab;
  easytabs(name, loadtab);
}

function easytabs(name, active) {
  for (i=1;i <= tabcount[name];i++){
    document.getElementById(tablink_idname[name]+"_"+i).className='tab'+i;
    document.getElementById(tabcontent_idname[name]+"_"+i).style.display = 'none';
  }
  document.getElementById(tablink_idname[name]+"_"+active).className='tab'+active+' tabactive';
  document.getElementById(tabcontent_idname[name]+"_"+active).style. display = 'block';
  // store to cookie
  var expires = new Date();
  expires.setDate(expires.getDate()+180); // days the order is stored
  document.cookie = "tab_" + removeUniq(name) + "=" + escape(active) + " ;expires="+expires.toGMTString();
}

glow.ready(function(){
  for (menu in tablink_idname)
    easytabs(menu, loadtabs[menu]);
});

//-- ooooooooooooooooooooooooooo end easytab script ooooooooooooooooooooooo 

//-- oooooooooooooooooooooooooo add overlay text oooooooooooooooooooooooooo
var overlayText;

glow.ready(function(){
  overlayText = new glow.widgets.Overlay("#overlayText", {
    width: 150,
    modal: false,
    anim: "fade"
  });
  // Display is none as default so it doesn't show up when the page is loading, now unhide it.
  var tmp = glow.dom.get("#overlayText");
  tmp.css("display", "");
});

function showOverlayText(content) {
  var overlay = glow.dom.get("#overlayText");
  overlay.html(content);
  var overlayParent = glow.dom.get(thisObject);
  overlayText.show();
  var overlaywidth = overlay.width() + parseInt(overlay.css("border-left-width")) + parseInt(overlay.css("border-right-width"))
    + parseInt(overlay.css("padding-left")) + parseInt(overlay.css("padding-right"));
  var scroll = glow.dom.get(window).scrollTop();
  overlayText.setPosition(overlayParent.offset().left - overlaywidth, overlayParent.offset().top - scroll);
}

function hideOverlayText() {
  overlayText.hide();
}


glow.ready(function(){
    glow.net.get("themes.txt", {
     /*   onLoad: function(response) {
            var select_list = glow.dom.create(response.text());
            select_list.insertAfter('#theme_def');
        }*/
    });

});

function change_theme() {
    var i = document.theme_form.theme_select.selectedIndex;
    var order = document.theme_form.theme_select.options[i].value;
    var expires = new Date();
    expires.setDate(expires.getDate()+180); // days the order is stored
    // store the order into a cookie
    document.cookie = "widgets=" + escape(order) + " ;expires="+expires.toGMTString();
    window.location.href = window.location.href;
}
// store current playing clip in currentClip
var currentClip;
function showAreenaRadio(idAreena){
  var oldPlayers = glow.dom.get("#radio_player");
  //var flashWidth = 255;
  oldPlayers.each(function(){
    //glow.dom.get(this).parent().css("min-height", "26px");
    glow.dom.get(this).parent().get("br").destroy();
  });
  oldPlayers.destroy();
  glow.dom.get("p#arena_radio_flash").destroy();

  if (currentClip != idAreena) {
    var element = glow.dom.get(thisObject).parent();
    //element.css("min-height","50px");
    //element.html(element.html() + '<object class="YleAreenaPlayer" id="radio_player" width="' + flashWidth + '" height="169"><param name="src" value="http://arenan.yle.fi/player/Application.swf?external=true&language=sv&clip=' + idAreena + '&firstClipName=&layout=embeded&embedTitle=title&embedDuration=&embedChannel=&initialPreview=https%3A/kulturen.fi/style/black/top-line.png"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed name="arenaplayer" id="arenaplayer" src="http://areena.yle.fi/player/Application.swf?external=true&language=sv&clip=' + idAreena + '&firstClipName=&layout=embeded&embedTitle=title&embedDuration=&embedChannel=&initialPreview=https%3A/kulturen.fi/style/black/top-line.png" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + flashWidth + '" height="169"></embed></object>');
    element.html(element.html() + '<p id="arena_radio_flash"></p>');
    new glow.embed.Flash(
    "http://arenan.yle.fi/player/Application.swf?external=true&language=sv&clip=" + idAreena + "&firstClipName=&layout=embeded&embedTitle=title&embedDuration=&embedChannel=&initialPreview=https%3A/kulturen.fi/style/black/top-line.png", 
    "p#arena_radio_flash", 
    "9",
    {
            height: "169px",
            width: "255px",
            params: {
                allowscriptaccess: "always",
                allowfullscreen: "true"
                }
    }).embed();

    currentClip = idAreena;
  }
  else
    currentClip = 0;
}


//-- oooooooooooooooooooooooooo add areena player oooooooooooooooooooooooooo
var areena;

glow.ready(function(){
  areena = new glow.widgets.Panel("#areena", {
    width: 440,
    theme: "dark",
    modal: true,
    anim: "fade"
  });

  glow.events.addListener(areena, "afterHide", function(event) {
    // clear src and thereby destroy video inside to free up resources
    var tmp = glow.dom.get("#arenaplayer");
    tmp.attr("src", "");
  });
  // Display is none as default so it doesn't show up when the page is loading, now unhide it.
  var tmp = glow.dom.get("#areena");
  tmp.css("display", "");
});
function showAreena(idAreena){
    new glow.embed.Flash(
    "http://arenan.yle.fi/player/Application.swf?external=true&language=sv&clip=" + idAreena + "&firstClipName=&layout=embeded&embedTitle=title&embedDuration=&embedChannel=&initialPreview=https%3A/kulturen.fi/style/black/top-line.png", 
    "p#arenaplayer", 
    "9",
    {
            height: "225px",
            width: "400px",
            params: {
                allowscriptaccess: "always",
                allowfullscreen: "true"
                }
    }).embed();

  areena.show();
}


// store current playing clip in currentClip
var currentClip;
function showBBCRadio(idBBC){
  var oldPlayers = glow.dom.get("#radio_player");
  var flashWidth = 255;
  oldPlayers.each(function(){
    //glow.dom.get(this).parent().css("min-height", "26px");
    glow.dom.get(this).parent().get("br").destroy();
  });
  oldPlayers.destroy();

  if (currentClip != idBBC) {
    var element = glow.dom.get(thisObject).parent();
    //element.css("min-height","50px");
    element.html(element.html() + '<embed type="application/x-shockwave-flash" id="radio_player" src="http://www.bbc.co.uk/emp/9player.swf?revision=10344_10570" style="" id="bbc_emp_embed_bip-play-emp" name="bbc_emp_embed_bip-play-emp" bgcolor="#000000" quality="high" wmode="default" allowfullscreen="true" allowscriptaccess="always" flashvars="embedReferer=&embedPageUrl=http://www.bbc.co.uk/iplayer/episode/' + idBBC + '/Top_Gear_Series_13_Episode_1_(new_series)/?t=00m01s&domId=bip-play-emp&config=http://www.bbc.co.uk/emp/iplayer/config.xml&playlist=http://www.bbc.co.uk/iplayer/playlist/' + idBBC + '&holdingImage=http://node2.bbcimg.co.uk/iplayer/images/episode/{$itemDatas[sec1].videoembed_id}_640_360.jpg&config_settings_bitrateFloor=0&config_settings_bitrateCeiling=2500&config_settings_transportHeight=35&config_settings_cueItem=b00ldy1k:875&config_settings_showPopoutCta=false&config_messages_diagnosticsMessageBody=Insufficient bandwidth to stream this programme. Try downloading instead, or see our diagnostics page.&config_settings_language=en&guidance=unset" width="259" height="166">');
    currentClip = idBBC;
  }
  else
    currentClip = 0;
}


//-- oooooooooooooooooooooooooo add areena player oooooooooooooooooooooooooo
var introplayer;

glow.ready(function(){
  introplayer = new glow.widgets.Panel("#introplayer", {
    width: 680,
    theme: "dark",
    modal: true,
    anim: "fade"
  });

  glow.events.addListener(introplayer, "afterHide", function(event) {
    // clear src and thereby destroy video inside to free up resources
    var tmp = glow.dom.get("#iplayer");
    tmp.attr("src", "");
  });
  // Display is none as default so it doesn't show up when the page is loading, now unhide it.
  var tmp = glow.dom.get("#introplayer");
  tmp.css("display", "");
});
function showIntroVideo(){
    new glow.embed.Flash(
    "http://vimeo.com/moogaloop.swf?clip_id=10383848&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1", 
    "p#iplayer", 
    "9",
    {
            height: "400px",
            width: "640px",
            params: {
                allowscriptaccess: "always",
                allowfullscreen: "true"
                }
    }).embed();

  introplayer.show();
}



function popupplayer(link, date, title, embedVideo, videoembed_id)
{
    popupplayer_window = window.open('popupplayer.php?link=' + link + '&date=' + date + '&title=' + title + '&embedVideo=' + embedVideo + '&videoembed_id=' + videoembed_id + '&templateName=popupplayer','popupplayer','width=340,height=300,location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no');
    popupplayer_window.focus();
}

// store current playing clip in currentClip_svt
var currentClip_svt;
function showSVT(idSVT){
  var oldPlayers = glow.dom.get("#svt_player");
  var flashWidth = 255;
  oldPlayers.each(function(){
    //glow.dom.get(this).parent().css("min-height", "26px");
    glow.dom.get(this).parent().get("br").destroy();
  });
  oldPlayers.destroy();

  if (currentClip_svt != idSVT) {
    var element = glow.dom.get(thisObject).parent();
    //element.css("min-height","50px");
    element.html(element.html() + '<br /><object width="259" height="166" id="svt_player"><param name="movie" value="http://svt.se/embededflash/' + idSVT + '/play.swf"></param><param name="wmode" value="transparent"></param><param name="allowfullscreen" value="true"></param><param name="allowScriptAccess" value="sameDomain"></param><embed id="svt_player" src="http://svt.se/embededflash/' + idSVT + '/play.swf" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowScriptAccess="sameDomain" width="259" height="166"></embed></object>');
    currentClip_svt = idSVT;
  }
  else
    currentClip_svt = 0;
}


/* --------------------

    Ticker javascript

-------------------- */

/* TODO: rethink names
ticker_hover_animup
ticker_buttons_animin()
etc.
*/

// Some variables
var ticker_hover_fadein = 0.3; // Seconds to fade in the hover element
var ticker_hover_fadeout = 0.3; // Seconds to fade out the hover element
var ticker_fadein = 2; // Seconds to fade in a subject
var ticker_show_time = 1500; // Time in ms to show a subject
var ticker_fadeout = 1; // Seconds to fade out a subject
var container_height;
var container_newheight = "32px";

var ticker_data;
var ticker_cur = 0;

// Start ticker when page has loaded
glow.ready(function () {
    ticker_width = glow.dom.get(".ticker").css("width");
    ticker_data = glow.dom.get("#ticker_raw_data").html().split("¤");
    ticker_hoverup_width = glow.dom.get(".ticker_hoverup_hide").css("margin-left");
    ticker_hoverdown_height = glow.dom.get(".ticker_hoverdown_hide").css("margin-top");
    container_height = glow.dom.get("#ticker_container").css("height");
    glow.events.addListener(".ticker", "mouseover", ticker_buttons_animin);
    glow.events.addListener(".ticker_hoverup_hide", "mouseover", ticker_buttons_animin);
    glow.events.addListener(".ticker_hoverdown_hide", "mouseover", ticker_buttons_animin);
    glow.events.addListener(".ticker", "mouseout", ticker_buttons_animout);
    glow.events.addListener(".ticker_hoverup_hide", "mouseout", ticker_buttons_animout);
    glow.events.addListener(".ticker_hoverdown_hide", "mouseout", ticker_buttons_animout);
    ticker_auto();
});

function ticker_buttons_animin() {
    if (ticker_hover_animup != null) {
        ticker_hover_animup.destroy();
        ticker_hover_animdown.destroy();
    }
    ticker_reset();
    //glow.dom.get("#ticker_container").css("height", container_newheight);
    glow.anim.css("#ticker_container", ticker_hover_fadein, {"height": container_newheight}, {tween: glow.tweens.easeOut()}).start();
    ticker_hover_animup = glow.anim.css(".ticker_hoverup_hide", ticker_hover_fadein, {"margin-left": "0px"}, {tween: glow.tweens.easeOut()}).start();
    ticker_hover_animdown = glow.anim.css(".ticker_hoverdown_hide", ticker_hover_fadein, {"margin-top": "0px"}, {tween: glow.tweens.easeOut()}).start();
}

function ticker_buttons_animout() {
    if (ticker_hover_animup != null) {
        ticker_hover_animup.destroy();
        ticker_hover_animdown.destroy();
    }
    if (ticker_timer != null)
        clearTimeout(ticker_timer);
    //glow.dom.get("#ticker_container").css("height", container_height);
    glow.anim.css("#ticker_container", ticker_hover_fadeout, {"height": container_height}, {tween: glow.tweens.easeIn()}).start();
    ticker_hover_animup = glow.anim.css(".ticker_hoverup_hide", ticker_hover_fadeout, {"margin-left": ticker_hoverup_width}, {tween: glow.tweens.easeIn()}).start();
    ticker_hover_animdown = glow.anim.css(".ticker_hoverdown_hide", ticker_hover_fadeout, {"margin-top": ticker_hoverdown_height}, {tween: glow.tweens.easeIn()}).start();
    ticker_timer = setTimeout("ticker_anim_out();", ticker_show_time);
}

function ticker_reset() {
    ticker_anim.stop();
    ticker_anim.destroy();
    if (ticker_timer != null)
        clearTimeout(ticker_timer);
    glow.dom.get(".ticker_text").css("width", ticker_width);
    glow.dom.get(".ticker_text").css("opacity", 1);
}

function ticker_update() {
    ticker_inner_data = ticker_data[ticker_cur].split("\n");
    glow.dom.get('.ticker_link').attr("href", (ticker_inner_data[0]));
    glow.dom.get('.ticker_time').html(ticker_inner_data[1]);
    glow.dom.get('.ticker_header1').html(ticker_inner_data[2]);
    glow.dom.get('.ticker_header2').html(ticker_inner_data[3]);
}

function ticker_counter(direction, rotate) {
// direction: +1 for increase and -1 for decrease
// rotate: true = jumps from end to beginning and vice versa
ticker_cur = ticker_cur + direction;
var max = ticker_data.length - 1;
if (ticker_cur < 0)
    if (rotate)
        ticker_cur = max;
    else
        ticker_cur = 0;
else if (ticker_cur > max)
    if (rotate)
        ticker_cur = 0;
    else
        ticker_cur = max;
ticker_update();
}

var ticker_anim = null;
var ticker_timer = null;
var ticker_hover_animup = null;
var ticker_hover_animdown = null;

// Anim in
function ticker_auto() {
    ticker_counter(+1, true);
    ticker_anim = glow.anim.css(".ticker_text", ticker_fadein, {"width": ticker_width}, {onComplete: ticker_anim_show}).start();
}
// Anim show
function ticker_anim_show() {
    if (ticker_timer != null)
        clearTimeout(ticker_timer);
    ticker_timer = setTimeout("ticker_anim_out();", ticker_show_time);
}
// Anim out
function ticker_anim_out() {
    ticker_anim = glow.anim.fadeOut(".ticker_text", ticker_fadeout, {onComplete: ticker_anim_reset}).start();
}
// Reset and set to anim in
function ticker_anim_reset() {
    glow.dom.get(".ticker_text").css("width", "0px");
    glow.dom.get(".ticker_text").css("opacity", 1);
    ticker_auto();
}


