﻿function div_left_mouseover(ev, target) {
    target.className = "div_left_on";
}

function div_left_mouseout(ev, target) {
    target.className = "div_left";
}


function div_right_mouseover(ev, target) {
    target.className = "div_right_on";
}

function div_right_mouseout(ev, target) {
    target.className = "div_right";
}


function toleft() {
    Ext.EventManager.removeListener("div_right", "mousedown", toRight);
    Ext.EventManager.removeListener("div_left", "mousedown", toleft);
    t = setInterval("scroll()", 50);
}

function toRight() {
    Ext.EventManager.removeListener("div_left", "mousedown", toleft);
    Ext.EventManager.removeListener("div_right", "mousedown", toRight);
    t1 = setInterval("scroll2()", 50);
}



function scroll() {
    if (tt > -880) {
        tt -= 80;

        if (Ext.isIE) {
            div_show_scroll_curr.dom.style.left = tt;
        }
        else {
            div_show_scroll_curr.dom.style.left = tt + "px";
        }
    }
    else {
        clearInterval(t);

        var div_right = Ext.get("div_right");
        div_right.on("mousedown", toRight);

        var div_left = Ext.get("div_left");
        div_left.on("mousedown", toleft);
    }
}


function scroll2() {

    if (tt < 0) {
        tt += 80;

        if (Ext.isIE) {
            div_show_scroll_curr.dom.style.left = tt;
        }
        else {
            div_show_scroll_curr.dom.style.left = tt + "px";
        }
    }
    else {
        clearInterval(t1);

        var div_left = Ext.get("div_left");
        div_left.on("mousedown", toleft);

        var div_right = Ext.get("div_right");
        div_right.on("mousedown", toRight);
    }
}





function toProducts(ev, target) {
    tt = -880;
    div_show_scroll_product.dom.style.display = "block";
    div_show_scroll_news.dom.style.display = "none";
    div_show_scroll_hydt.dom.style.display = "none";
    div_show_scroll_contractMe.dom.style.display = "none";
    div_bottomBarButton.dom.className = "div_bottomBarButton_products";
    div_show_scroll_curr = div_show_scroll_product;
}

function toNews(ev, target) {
    tt = -880;
    div_show_scroll_product.dom.style.display = "none";
    div_show_scroll_news.dom.style.display = "block";
    div_show_scroll_hydt.dom.style.display = "none";
    div_show_scroll_contractMe.dom.style.display = "none";
    div_bottomBarButton.dom.className = "div_bottomBarButton_news";
    div_show_scroll_curr = div_show_scroll_news;
}


function toHydt(ev, target) {

    tt = -880;
    div_show_scroll_product.dom.style.display = "none";
    div_show_scroll_news.dom.style.display = "none";
    div_show_scroll_hydt.dom.style.display = "block";
    div_show_scroll_contractMe.dom.style.display = "none";
    div_bottomBarButton.dom.className = "div_bottomBarButton_yyhy";
    div_show_scroll_curr = div_show_scroll_hydt;
}

function toContactMe(ev, target) {

    tt = 0;
    div_show_scroll_product.dom.style.display = "none";
    div_show_scroll_news.dom.style.display = "none";
    div_show_scroll_hydt.dom.style.display = "none";
    div_show_scroll_contractMe.dom.style.display = "block";
    div_bottomBarButton.dom.className = "div_bottomBarButton_contractMe";
    div_show_scroll_curr = div_show_scroll_contractMe;
}


function go2Products() {
    window.location.href = "show.aspx?type=cpzs";
}

function go2News() {
    window.location.href = "show.aspx?type=xwdt";
}


function go2Yyhy() {
    window.location.href = "show.aspx?type=yyhy";
}


function go2Lxwm() {
    window.location.href = "show.aspx?type=lxwm";
}


var div_show_scroll_product;
var div_show_scroll_news;
var div_show_scroll_hydt;
var div_show_scroll_contractMe;

var div_show_scroll_curr;


var t;
var t1;
var tt = -880;
var div_bottomBarButton;


var curr_show = 1;


//QQ联系
function qqContractME(qq) {
    window.location.href = "http://wpa.qq.com/msgrd?V=1&Uin=" + qq + "&Exe=QQ&Site=im.qq.com&Menu=No";
}

//加入收藏
function AddFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    } catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        } catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

//设为首页
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(document.URL);
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {//火狐浏览器
                alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config, 然后将项 signed.applets.codebase_principal_support 值该为true");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', document.URL);
    }
}




Ext.onReady
(
	function() {


	    var div_left = Ext.get("div_left");
	    div_left.on("mouseover", div_left_mouseover);
	    div_left.on("mouseout", div_left_mouseout);
	    div_left.on("mousedown", toleft);


	    var div_right = Ext.get("div_right");
	    div_right.on("mouseover", div_right_mouseover);
	    div_right.on("mouseout", div_right_mouseout);
	    div_right.on("mousedown", toRight);


	    div_show_scroll_product = Ext.get("div_show_scroll_product");
	    div_show_scroll_news = Ext.get("div_show_scroll_news");
	    div_show_scroll_hydt = Ext.get("div_show_scroll_hydt");
	    div_show_scroll_contractMe = Ext.get("div_show_scroll_contractMe");

	    div_bottomBarButton = Ext.get("div_bottomBarButton");

	    div_show_scroll_curr = div_show_scroll_product;


	    var div_products = Ext.get("div_products");
	    div_products.on("mouseover", toProducts);
	    div_products.on("mousedown", go2Products);

	    var div_news = Ext.get("div_news");
	    div_news.on("mouseover", toNews);
	    div_news.on("mousedown", go2News);

	    var div_hydt = Ext.get("div_hydt");
	    div_hydt.on("mouseover", toHydt);
	    div_hydt.on("mousedown", go2Yyhy);

	    var div_contactMe = Ext.get("div_contactMe");
	    div_contactMe.on("mouseover", toContactMe);
	    div_contactMe.on("mousedown", go2Lxwm);

	}
);





