﻿var position = 1;
var timer;
var time = 6000;
var headLine = new Array();
headLine[0] = '<a href="http://www.bikethongake.com/BikeNews/News?nID=87" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader25.png" width="599" height="280" alt="LAZER Helmet TREK" title="LAZER Helmet TREK"></a>';
headLine[1] = '<a href="http://www.bikethongake.com/BikePromotion/Promotion?pmID=24" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader22.png" width="599" height="280" alt="TREK 8500 2012" title="TREK 8500 2012"></a>';
headLine[2] = '<a href="http://www.bikethongake.com/BikeReview/Review?rpID=66" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader23.png" width="599" height="280" alt="TREK 4300 2012" title="TREK 4300 2012"></a>';
headLine[3] = '<a href="http://www.bikethongake.com/BikeProduct/product?pID=302" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader24.png" width="599" height="280" alt="DAHON ECO3 ราคาพิเศษ" title="DAHON ECO3 ราคาพิเศษ"></a>';
headLine[4] = '<a href="http://www.bikethongake.com/BikeReview/Review?rpID=45" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader14.png" width="599" height="280" ></a>';
headLine[5] = '<a href="http://www.bikethongake.com/BikeNews/News?nID=57" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader13.png" width="599" height="280" ></a>';
headLine[6] = '<a href="http://www.bikethongake.com/BikeNews/News?nID=56" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader12.png" width="599" height="280" ></a>';

//headLine[0] = '<a href="http://www.bikethongake.com/BikePromotion/Promotion?pmID=21" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader21.png" width="599" height="280" alt="TREK Elite 9.8 2011 Full carbon" title="TREK Elite 9.8 2011 Full carbon"></a>';
//headLine[6] = '<a href="http://www.bikethongake.com/BikeProduct/product?pID=73"><img src="../../Content/NewImage/headline/bikeheader6.png" width="599" height="280" ></a>';   //fox
//headLine[5] = '<a href="http://www.bikethongake.com/BikeNews/News?nID=56" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader12.png" width="599" height="280" ></a>';    //brooks
//headLine[6] = '<a href="http://www.bikethongake.com/BikeReview/Review?rpID=20" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader7.png" width="599" height="280" ></a>';   //orbea alma oms
//headLine[5] = '<a href="http://www.bikethongake.com/BikePromotion/Promotion?pmID=13" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader11.png" width="599" height="280" ></a>';
//headLine[2] = '<a href="http://www.bikethongake.com/BikePromotion/Promotion?pmID=16" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader16.png" width="599" height="280"></a>';
//headLine[3] = '<a href="http://www.bikethongake.com/BikePromotion/Promotion?pmID=17" title="สนใจ คลิ๊กชม"><img src="../../Content/NewImage/headline/bikeheader18.png" width="599" height="280"></a>';

function autoHeadline() {
    if (document.getElementById('page') != null)
        timer = setInterval('callHealline()', time);
}

function callHealline() {

    if (position == (headLine.length + 1))
        position = 1;
        
    changeHeadline(position)
    position++;
}

function clickHeadline(i) {
    if (timer != null)
        clearInterval(timer);

    changeHeadline(i);
}

function changeColor_li() {
    for (var i = 1; i <= headLine.length; i++) {
        if (i == position) {
            document.getElementById('li' + i).className = 'current';
        }
        else {
            document.getElementById('li' + i).className = '';
        }
    }
}

function changeHeadline(i) {
    var obj = document.getElementById('headline');
    var htmlHeadline = headLine[i - 1];

    obj.innerHTML = htmlHeadline;

    //change color li
    changeColor_li();
}
