/*
    Coded by Steven Bower (cc) 2009
    TurnWheel Designs http://turnwheel.com/
    BPWebDesign http://bpwebdesign.com/
    
    Converted to jQuery from original source file marquee.js
*/

var MARINT; // Global variable (used for Marquee Interval)
$(function() {
    // Configuration Variables
    var delay = 2000; // Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
    var speed = 2; // Specify marquee scroll speed (larger is faster 1-10)
    var pause = true; // Pause marquee onMousever (true or false)
    
    // Marquee Variables
    var marquee = $('#vmarquee');
    var containerHeight = $('#marqueecontainer').height();
    var actualheight = marquee.height();
    
    // Ensure Proper Height
    if (containerHeight > actualheight) $('#marqueecontainer').height(actualheight);
    
    // if Opera or Netscape 7x, add scrollbars to scroll and exit
    if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1) {
        var css = {
            height: containerHeight+'px',
            overflow: 'scroll'
        };
        marquee.css(css);
        $('#newOne').css(css);
        return;
    }
    
    setTimeout('MARINT=setInterval("scrollmarquee('+speed+')",80)',delay);
    
    if (pause) {
        $('#marqueecontainer').mouseover(function() {
            clearInterval(MARINT);
        }).mouseout(function() {
            MARINT = setInterval('scrollmarquee('+speed+')',80);
        });
    }
});

// Global function to scroll marquee (use with setInterval)
var scrollmarquee = function(speed) {
    var marquee = $('#vmarquee'); // Marquee Element
    var height = parseInt(marquee.height()); // Get height
    
    // Move area up
    marquee.css('top',parseInt(marquee.css('top'))-speed+'px');
    
    // Check if we need to go to top
    if (parseInt(marquee.css('top'))+10  <= height*(-1)) marquee.css('top',0);
};