//Format for each new article:
//  Index 0: Title
//  Index 1: Headline
//  Index 2: Source
//  Index 3: Date
//  Index 4: Summary - ALWAYS end with '...'
//  Index 5: Link
var BreachNews = [




 [
            "Google Fires Engineer For Privacy Breach",
            "Engineer accessed  confidential client information",
            "<i>--- CNN",
            "Sept 15, 2010 ---</i>",
            "Google confirmed on Tuesday that it fired an employee earlier this year for violating its policies on accessing the accounts of its users, specifically children...",
            "http://articles.cnn.com/2010-09-15/tech/google.privacy.firing_1_google-voice-privacy-breach-google-employee?_s=PM:TECH" ],
 [
            "Blue Cross Client Information Leak",
            "Online Security Breach Exposes Personal Info.",
            "<i>--- KPBS.org",
            "June 24, 2010 ---</i>",
            "CALIFORNIA - Anthem Blue Cross says more than 200,000 applicants for insurance may have had their personal information compromised. The company says a security breach of its website led to unauthorized access....",
            "http://www.kpbs.org/news/2010/jun/24/online-security-breach-anthem-blue-cross-exposes-p/" ],
 [
            "Facebook Data Breach",
            "100 Million User Details Published Online",
            "<i>--- MSNBC",
            "July 29, 2010 ---</i>",
            "The personal details of 100 million Facebook users has been collected and published online in a downloadable file, meaning they will now be unable to make their publicly available information private...",
            "http://www.msnbc.msn.com/id/38463013" ],
 [
            "Law Firm Suing China Suffers Attack",
            "Gipson Hoffman & Pancione attacked",
            "<i>--- Information Week",
            "Jan 14, 2010 ---</i>",
            "Calif.-based CYBERsitter is suing the People's Republic of China for distributing Web filtering software with  stolen code. This week, the law firm representing the company said that it had been targeted in a cyber attack from China...",
            "http://www.informationweek.com/news/security/attacks/showArticle.jhtml?articleID=222301001" ],







        [
            "Hackers for Hire",
            "Hacking for Fun and Profit in China's Underworld",
            "<i>--- NY Times",
            "Feb 02, 2010 ---</i>",
            "Internet security experts say China has legions of hackers, and that they are behind an escalating number of global attacks to steal credit card numbers, commit corporate espionage and other nefarious activities...",
            "http://www.nytimes.com/2010/01/13/world/asia/13beijing.html" ],

        [
            "Digital River Sues over Breach",
            "Indian company steals customer data",
            "<i>--- Star Tribune",
            "June 4, 2010 ---</i>",
            "200,000 customers' data stolen and attempted sale to Colorado marketing company stopped...",
            "http://www.startribune.com/local/95584209.html?elr=KArksLckD8EQDUoaEyqyP4O:DW3ckUiD3aPc:_Yyc:aUac8HEaDiaMDCinchO7DU" ],

        [
            "Canada: Breaches Soar in 09",
            "",
            "<i>--- Globe and Mail",
            "Sept 26 2009 ---</i>",
            "IT security breaches cost the average Canadian organization $834,149 in 2009, almost double that of 2008, pointing to a disturbing trend...",
            "http://www.theglobeandmail.com/news/technology/it-security-breaches-soar-in-2009/article1305011/" ],

        [
            "Rock You Password Theft",
            "",
            "<i>--- Computerworld.com",
            "Feb 17 2010 ---</i>",
            "Social netoworking password service hacked. Over 30 million passwords exposed...",
            "http://www.computerworld.com/s/article/9142327/RockYou_hack_exposes_names_passwords_of_30M_accountsm" ]
    ];



var SecurityNews = [

[
            "Data Breach Costs On Rise",
            "Annual study finds costs of breaches increasing",
            "<i>--- IT Business.ca",
            "May 5, 2010 ---</i>",
            "Data breach costs increased last year to $204 per compromised customer record, according to the Ponemon Institute's annual study. The average total cost of a data breach rose from $6.65 million in 2008 to $6.75 million in 2009...",
            "http://www.itbusiness.ca/it/client/en/home/News.asp?id=56164" ],

[
            "Survey: IT Managers Blame Insiders",
            "",
            "<i>--- CNET News",
            "Aug 24, 2009 ---</i>",
            "IT managers in small and midsize businesses blame their fellow workers for online security breaches...",
            "http://news.cnet.com/Discover-security-breach,-blame-the-co-workers/2100-7355_3-6204295.html" ],

[
            "Google Under Fire From Privacy Commissioner",
            "Canada Privacy Commissioner Urges Significant Changes",
            "<i>--- Government of Canada",
            "Oct 19, 2010 ---</i>",
            "Google Street View cars inappropriately collected personal information such as e-mails, usernames, passwords, phone numbers and addresses; Commissioner recommends stronger controls....",
            "http://www.priv.gc.ca/media/nr-c/2010/nr-c_101019_e.cfm" ],
[
            "2010 Study: hacking greatest threat to enterprise IT security",
            "75% of enterprises attacked; avg cost $2 million per year",
            "<i>--- Symantec",
            "Feb 22, 2010 ---</i>",
            "Study based on 2,100 enterprise CIOs and IT Mgrs from 27 countries in early 2010. 42%  rate security their top issue and 75% experienced cyber attacks in the past 12 months...",
            "http://www.symantec.com/about/news/release/article.jsp?prid=20100221_01" ],
[
            "Google Docs Shared Without Permission",
            "Google Privacy Blunder Puts Records at Risk",
            "<i>--- TechCrunch.com",
            "May 7, 2010 ---</i>",
            "A 'bug' in Google Docs placed thousands of files into the wrong hands, due to a technical problem with the system. Google acted to remedy the situation, but in many cases the damage had been done, with hundreds of unauthorized records falling into the wrong hands...",
            "http://techcrunch.com/2009/03/07/huge-google-privacy-blunder-shares-your-docs-without-permission/" ],


[
            "Global State of Security Report: PWC and CIO Magazine",
            "Cloud Computing a major security concern",
            "<i>--- PWC Global",
            "Jan 10, 2010 ---</i>",
            "Among many points of agreement, the security of online information is a major concern for business leaders and CIOs alike...",
            "http://www.pwc.com/gx/en/information-security-survey/index.jhtml" ],
[
            "Banks increase security spend",
            "Financial institutions increase security spending, as penalties rise",
            "<i>--- SC Magazine UK",
            "June 9, 2010 ---</i>",
            "Financial institutions are investing heavily in information security in light of a growing number of threats and increased regulatory pressure...",
            "http://www.scmagazineuk.com/financial-institutions-increase-security-spending-as-threats-and-regulatory-penalties-rise/article/171986/" ]


];



function BuildNewsArticlesForTicker( news_article_array )
{
    var news_html_all = new Array();

    for( i=0 ; i<news_article_array.length ; i++ )
    {
        var news_html_each = "";

        news_html_each=
            '<b><a href="' + news_article_array[i][5] + '" target="_blank" title="">' + news_article_array[i][0] + '</a></b><br />'
            +   (news_article_array[i][1].length==0 ? '' : (news_article_array[i][1] + '<br />'))
            +   news_article_array[i][2] + ' ' + news_article_array[i][3] +'<br />'
            +   news_article_array[i][4] + '<a href="' + news_article_array[i][5] + '" target="_blank" title="">more</a><br /><br />'

        news_html_all[i] = news_html_each;
    }

    return news_html_all;
}


// The time (msec) to freeze the news article when it is fully displayed
var time_to_freeze_article = 10000;

// Size of new ticker DIV height (pixel), need to be the same size as #ticker_container
var ticker_div_height = 120

function NewsTickerDivVariables( news_articles_structured, div_id ) {
    // current news article being displayed
    this.current_article_index = 0;

    // Format the structured news articles into array of HTMLs
    this.article_array = BuildNewsArticlesForTicker( news_articles_structured );

    this.div_id = div_id;

    // Function to get the next news article (in html)
    this.get_next_article = function() {
            this.current_article_index += 1;
            if( this.current_article_index>=this.article_array.length )
                this.current_article_index = 0;
            return this.article_array[this.current_article_index];
        };
}

var breach_news_div_var;
var security_news_div_var;

//scroller's speed
var sspeed=5;
var resumesspeed=sspeed


$( function()
{
    breach_news_div_var = new NewsTickerDivVariables( BreachNews, 'breach_news_ticker' );
    security_news_div_var = new NewsTickerDivVariables( SecurityNews, 'security_news_ticker' );

    breach_news_div_var.var_name = 'breach_news_div_var';
    security_news_div_var.var_name = 'security_news_div_var';

    start();

});

function start() {
        if (document.all) {
            iemarquee_prepare(breach_news_div_var);
            iemarquee_prepare(security_news_div_var);

            // Freeze the scrolling for a while
            setTimeout("ieslide()", time_to_freeze_article)

        } else if (document.getElementById) {
            ns6marquee_prepare(breach_news_div_var);
            ns6marquee_prepare(security_news_div_var);

            // Freeze the scrolling for a while
            setTimeout("ns6slide()", time_to_freeze_article)
        }
}

function iemarquee_prepare( news_ticker ){
        news_ticker.iediv=eval(news_ticker.div_id)

        news_ticker.iediv.style.pixelTop=0;
        news_ticker.iediv.innerHTML = news_ticker.article_array[0];
}

function ieslide(){
        if (breach_news_div_var.iediv.style.pixelTop >= ticker_div_height*(-1)){

                // scroll the page up
                if( breach_news_div_var.iediv.style.pixelTop>0 && breach_news_div_var.iediv.style.pixelTop<=sspeed )
                {
                    // The article will be in full view
                    breach_news_div_var.iediv.style.pixelTop=0;
                    security_news_div_var.iediv.style.pixelTop=0;
                }
                else
                {
                    breach_news_div_var.iediv.style.pixelTop-=sspeed;
                    security_news_div_var.iediv.style.pixelTop-=sspeed;
                }

                if( breach_news_div_var.iediv.style.pixelTop==0 ) {
                    setTimeout("ieslide()",time_to_freeze_article)
                } else {
                    setTimeout("ieslide()",100)
                }
        }
        else{
                // Finish sliding to the top

                // Prepare the next breach and security articles to display
                breach_news_div_var.iediv.innerHTML = breach_news_div_var.get_next_article();
                security_news_div_var.iediv.innerHTML = security_news_div_var.get_next_article();

                // Move the ticker below the view
                breach_news_div_var.iediv.style.pixelTop = ticker_div_height;
                security_news_div_var.iediv.style.pixelTop = ticker_div_height;

                // Freeze the scrolling for a while
                ieslide();
        }
}

function ns6marquee_prepare( news_ticker ){
        var test = document.getElementById(news_ticker.div_id);
        news_ticker.ns6div=eval( document.getElementById(news_ticker.div_id) )

        news_ticker.ns6div.style.top="0px";
        news_ticker.ns6div.innerHTML=news_ticker.article_array[0];
}

function ns6slide(){
        if (parseInt(breach_news_div_var.ns6div.style.top) >= ticker_div_height*(-1)){

                var cur_divtop = parseInt(breach_news_div_var.ns6div.style.top);
                var new_divtop = 0;

                // scroll the page up
                if( cur_divtop>0 && cur_divtop<=sspeed )
                {
                    // The article will be in full view
                    new_divtop = 0;
                }
                else
                {
                    new_divtop = cur_divtop - sspeed;
                }

                breach_news_div_var.ns6div.style.top = new_divtop + "px";
                security_news_div_var.ns6div.style.top = new_divtop + "px";

                if (new_divtop==0) {
                    setTimeout("ns6slide()",time_to_freeze_article)
                } else {
                    setTimeout("ns6slide()",100)
                }
        }
        else {
                // Finish sliding to the top

                // Put in the next article to scroll
                breach_news_div_var.ns6div.innerHTML = breach_news_div_var.get_next_article();
                security_news_div_var.ns6div.innerHTML = security_news_div_var.get_next_article();

                // Move the ticker below the view
                breach_news_div_var.ns6div.style.top = ticker_div_height + "px";
                security_news_div_var.ns6div.style.top = ticker_div_height + "px";

                ns6slide();
        }
}





