function clickproductstitleimg(msg){
    var pages = document.getElementById("productspages");
    pages = pages.getElementsByTagName("div");
    for (var i = 0; i <= pages.length - 1; i++) {
        if (pages[i].id.substr(0, 12) == "productspage") {
            var num = pages[i].id.substr(12, pages[i].id.length - 12);
            if (msg == num) {
                pages[i].style.display = "block";
            }
            else {
                pages[i].style.display = "none";
            }
        }
    }
}

function autolistclick(msg){

    var menurow = document.getElementById("tr-autolist");
    var menuitems = menurow.getElementsByTagName("td");
    var menuitem;
    var iteml;
    var itemm;
    var itemr;
    var name;
    var item = document.activeElement;
    
    if (item.id == 'td-autolist-none') 
        return;
    for (var i = 0; i <= menuitems.length - 1; i++) {
        var itemname = menuitems[i].id.substr(0, 8);
        if (itemname == 'menuitem') {
            name = menuitems[i].id.substr(menuitems[i].id.length - 1, 1);
            if (name == 'l') 
                menuitems[i].style.background = "url('images/autolistmenuul.jpg') no-repeat";
            if (name == 'm') 
                menuitems[i].style.background = "url('images/autolistmenuum.jpg')";
            if (name == 'r') 
                menuitems[i].style.background = "url('images/autolistmenuur.jpg') no-repeat";
        }
    }
    if (msg != null) {
        name = 'menuitem' + msg;
    }
    else {
        name = item.id.substr(0, item.id.length - 1);
    }
    
    iteml = document.getElementById(name + "l");
    itemm = document.getElementById(name + "m");
    itemr = document.getElementById(name + "r");
    iteml.style.background = "url('images/autolistmenual.jpg') no-repeat";
    itemm.style.background = "url('images/autolistmenuam.jpg')";
    itemr.style.background = "url('images/autolistmenuar.jpg') no-repeat";
}

function URL_Request(strName){
    var strHref = document.location.toString();
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    
    var arrTmp = strRight.split("&");
    for (var i = 0; i <= arrTmp.length - 1; i++) {
        var dIntPos = arrTmp[i].indexOf("=");
        var paraName = arrTmp[i].substr(0, dIntPos);
        var paraData = arrTmp[i].substr(dIntPos + 1);
        
        if (paraName.toUpperCase() == strName.toUpperCase()) {
            return paraData;
        }
    }
    return "";
}

function movescroll(){
    var item = document.activeElement;
    item.href = item.href + "&scrolltop=" + document.documentElement.scrollTop;
}

var len;
var currentindex;
var isrolling;

function rollingimg(){
    if (isrolling) {
        currentindex += 1;
        if (currentindex == len) 
            currentindex = 0;
        var inf = "li:eq(" + currentindex + ")";
        $("#spbb").find(inf).click();
    }
}


function startrollimg(){
    var lilist = $("#spbb").find("li");
    
    lilist.bind('mouseenter', function(){
        isrolling = false;
    });
    lilist.bind('mouseleave', function(){
        isrolling = true;
    });
    
    lilist.bind('click', function(){
        var index = $($(this)).index();
        $("#qh").fadeOut(500, function(){
            currentindex = index;
            var inf = "li:eq(" + currentindex + ")";
            $("#qh").empty();
            $("#qh").append($("#spbb").find(inf).find("div").html());
            $("#qh").fadeIn(500);
        });
    });
    len = lilist.length;
    currentindex = 0;
    $("#spbb").find("li:eq(0)").click();
    isrolling = true;
    setInterval('rollingimg()', 5000);
    
}

$(document).ready(function(){

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-24735989-5']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



    $("#head").load("head.html");
    $("#footer").load("footer.html");
    
    var select = URL_Request("select");
    var scrolltop = URL_Request("scrolltop");
    if (scrolltop != '') {
        document.documentElement.scrollTop = scrolltop;
    }
    
    if (select != '') {
        clickproductstitleimg(select);
    }
    
    startrollimg();
    
    
});



