﻿var s1,s2,s3,s4,s5,s6,s7,pro_all,center1_pros,i,pclosed,QQtop;
$(function(){
    var bar = $(".head_ba"),sub = $(".submune"),kinds = $(".center_left_kinds"),kinds_bar=$(".kinds_bar"),kong=$(".center_left_kong");
    var time;
    var crtitel = $(".center_right_titel"),crtext = $(".center_right_text");
    var pbars = $(".bar"),p=$(".bar p"),rows1=$(".rows1"),nva_list=$(".nva_list");
    var about = $("#about_left_list").children();
    var showNews=$("#showNews tr td:even"),showNews1=$("#showNews1 tr td:even"),showNews3=$("#showNews3 tr td:even");
    var name=$("input[name='name']"),tel=$("input[name='tel']"),qq=$("input[name='qq']"),email=$("input[name='email']"),kind=$("input[name='kind']"),scyq=$("input[name='scyq']"),tsyq=$("input[name='tsyq']"),sex=$(".sex"); 
    var sname=$("#showname"),stel=$("#showtel"),semail=$("#showemail");
    var QQ=$("#QQ");
    pro_all=$("#pro_all"),center1_pros=$(".center1_pros"),i=1,pclosed=$("#closed");
    bar.each(function(index){
        $(this).hover(function(){
            if(index==0||index==3){
                return false;
            }
            time = setTimeout(function(){
                sub.css({opacity:.7}).eq(index).slideDown(400);
            },300);
            
            var subson = sub.eq(index).children();
            subson.each(function(i){
                $(this).hover(function(){
                    $(this).css("background-color","#9b0302").children().css("color","#ffff00");
                },function(){
                    $(this).css("background-color","").children().css("color","");
                });
            }); 
        },function(){
            sub.eq(index).slideUp(100);
            clearTimeout(time);
        });
    });
    center1_pros.click(function(){
        if(pro_all.css("display")=='none'){
            setTimeout(function(){
                up();  
            },240);
        }else{
            setTimeout(function(){
                down(); 
            },240);
        }       
    });
    pclosed.find("img").click(function(){
        down();
    });
    kinds.each(function(index){
        $(this).hover(function(){
            $(this).css({"border":"2px solid #a67f80","border-right":"","background-color":"#f6f5f1"});
            kong.eq(index).css("background-color","#f6f5f1");
            kinds_bar.eq(index).show();
        },function(){
            $(this).css({"border-top":"1px solid #ffffff","border-bottom":"1px solid #d3c7ad","border-left":"","background-color":""});
            kinds_bar.eq(index).hide();
            kong.eq(index).css("background-color","");
        });
    }); 
    crtitel.each(function(index){
        $(this).click(function(){
            crtitel.css("background-image","none");
            $(this).css("background-image","url('../Images/bg3.jpg')");
            crtext.hide();
            crtext.eq(index).show();
        });
    });
    pbars.each(function(index){
        $(this).click(function(){
            pbars.children().css({"border-left-color":"#d4d8d7","border-right-color":"#d4d8d7","border-bottom":"0","background-color":""});
            p.css({"border-left":"1px solid #d4d8d7","border-right":"1px solid #d4d8d7","color":""});
            $(this).children().css({"border-left-color":"#191919","border-right-color":"#191919"});
            p.eq(index).css({"border-left":"1px solid #191919","border-right":"1px solid #191919","border-bottom":"1px solid #ffffff","color":"#f00607"});
            rows1.eq(index).css("background-color","#191919");
            nva_list.hide();
            nva_list.eq(index).show();
        });
    });
    about.each(function(){
        $(this).hover(function(){
            $(this).css({"background-color":"#ffffff","color":"#f09451"});
        },function(){
            $(this).css({"background-color":"","color":""});
        });
    });
    showNews.each(function(index){
        $(this).hover(function(){
            $(this).css({"color":"#f39321","cursor":"pointer"}).click(function(){
                location.href="../News/NewsItem.aspx?NewsID="+(index-(-1))+"&type=c";
            });    
        },function(){
            $(this).css("color","");
        });
    });
    showNews1.each(function(index){
        $(this).hover(function(){
            $(this).css({"color":"#f39321","cursor":"pointer"}).click(function(){
                location.href="../News/NewsItem.aspx?NewsID="+(index-(-1))+"&type=i";
            });    
        },function(){
            $(this).css("color","");
        });
    });
    showNews3.each(function(index){
        $(this).hover(function(){
            $(this).css({"color":"#f39321","cursor":"pointer"}).click(function(){
                location.href="../News/NewsItem.aspx?NewsID="+(index-(-1))+"&type=k";
            });    
        },function(){
            $(this).css("color","");
        });
    });
    nva_list.eq(1).find("table tr").each(function(index){
        $(this).hover(function(){
            if(index==0){
                return false;
            }else{
            $(this).css("background-color","#e5e6e6");
            }
        },function(){
            if(index==0){
                return false;
            }
            $(this).css("background-color","");
        });
    });
    
    name.blur(function(){
        if(name.val()==""){
            sname.html("姓名不能为空！");
            s1=false;
        }else{
            sname.html("");
            s1=true;
        }
    });
    sex.each(function(index){
        $(this).click(function(){
            if($(this).attr("checked")=="checked"){
                return false;
            }
            sex.attr("checked","");
            $(this).attr("checked","checked");
        });
    });
    tel.blur(function(){
        if(tel.val()==""){
            stel.html("联系方式不能为空！");
            s2=false;
        }else{
            stel.html("");
            s2=true;
        }
    });
    email.blur(function(){
        var reg=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
        if(email.val()==""){
            semail.html("电子邮箱不能为空！");
        }else{
            if(!reg.test(email.val())){
                semail.html("邮箱输入错误！"); 
                email.focus();
                s3=false;
                return false;
            }else{
                semail.html("");
                s3=true;
            }
        }
    });
    qq.blur(function(){
        if(qq.val()==""){
            s4=false;
        }else{
            s4=true;
        }
    });
    kind.blur(function(){
        if(kind.val()==""){
            s5=false;
        }else{
            s5=true;
        }
    });
    scyq.blur(function(){
        if(scyq.val()==""){
            s6=false;
        }else{
            s6=true;
        }
    });
    tsyq.blur(function(){
        if(tsyq.val()==""){
            s7=false;
        }else{
            s7=true;
        }   
    });
});
$(this).scroll(function(){
    var bodyTop=0;
    var bodyHeight=$("body").height();
    if(typeof window.pageYOffset!="undefined"){
        bodyTop=window.pageYOffset;
    }else if(typeof document.compatMode!="undefined"&&document.compatMode!="BackCompat"){
        bodyTop=document.documentElement.scrollTop;
    }else if(document.body!="undefined"){
        bodyTop=document.body.scrollTop;
    }
    $("#QQ").css("top",-bodyHeight+500+bodyTop);
});

function aa(){
   if(s1==true&&s2==true&&s3==true&&s4==true&&s5==true&&s6==true&&s7==true){
    return true;
   }else{
    alert("对不起，您提交的信息不能为空！");
    return false;
   }
}
function up(){
    center1_pros.children("img").css("border-top","none");
    i++;
    if(i<=11){
        pro_all.css({"height":30*i,"top":584-30*i}).show();
    }else{
        i=1;
        return false;
    }
    setTimeout('up()',20);
}
function down(){
    i++;
    if(i<11){
        pro_all.css({"height":330-30*i,"top":254+30*i}).show();
    }else{
        i=1;
        center1_pros.children("img").css("border-top","2px solid #e0e1dc");
        pro_all.hide();
        return false;
    }
    setTimeout('down()',20);
}
