
function fromSubmit() {
    if (document.getElementById("tag").innerHTML == "按课程") {
        window.location.href = "/search.aspx?m=kecheng&biaoti=" + document.getElementById("key_value").value;
    } else {
        window.location.href = "/search.aspx?m=ask&biaoti=" + document.getElementById("key_value").value;
    }
   

    return false;
}
function onKeyDown() {
    var code = event.keyCode;
    if (code == 13) {
        fromSubmit();
        return false;
    }

}
//设置表情
function get_biaoqing(g1, g2)
{
    document.getElementById(g1).value = document.getElementById(g1).value + "<img src='" + g2 + "'>";
    document.getElementById(g1).focus();
}

function user_laoshi() {
    if (document.getElementById("shijian_qian").value != "" && document.getElementById("shijian_hou").value != "") {
        window.location.href = "/search.aspx?m=user_laoshi&dtime=" + document.getElementById("shijian_qian").value + "between" + document.getElementById("shijian_hou").value + "";
    }
    return false;
}

function user_order() {
    if (document.getElementById("shijian_qian").value != "" && document.getElementById("shijian_hou").value != "") {
        window.location.href = "/search.aspx?m=user_order&dtime=" + document.getElementById("shijian_qian").value + "between" + document.getElementById("shijian_hou").value + "";
    }
    return false;
}

function user_ask() {
    window.location.href = "/search.aspx?m=user_ask&dtime=" + document.getElementById("shijian_qian").value + "between" + document.getElementById("shijian_hou").value + "";
    return false;
}



var request = false;
try {
    request = new XMLHttpRequest();
} catch (trymicrosoft) {
    try {
        request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
        try {
            request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (failed) {
            request = false;
        }
    }
}

if (!request) {
    alert2("Error initializing XMLHttpRequest!");
}
function ajax_getRootPath1() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
    return (postPath);
}


function bofangqi(id, yonghuming) {
    if (id != "") {

        var url = "/bofang.aspx?id=" + id + "&yonghuming=" + escape(yonghuming) + "&sid=" + Math.random();
       // document.write(url);
        request.open("GET", url, true);
        request.onreadystatechange = bofangqi_loadPage;
        request.send(null);
    }

}

function bofangqi_loadPage() {
    if (request.readyState == 4) {
        if (request.status == 200) {
            if (request.responseText != "") {
                var response = request.responseText.split("|");
                document.getElementById("moren").style.display = "none";
                if (response[0] == "login") {
                    document.getElementById("login").style.display = "";
                  //  document.getElementById("login").innerHTML = response[1];
                } else if (response[0] == "buy") {
                    document.getElementById("buy").style.display = "";
                    document.getElementById("lianjie").href = response[1];
                }
                else if (response[0] == "mediaplayer") {
                    document.getElementById("mediaplayer").style.display = "";
                    bfq_wz(response[1]);
                }
                else {
                    document.getElementById("video").style.display="";
                    bfq(response[1]);
                }

            }


        }


    }
}
function bfq_wz(dizhi) {
    jwplayer("mediaplayer").setup({
        file: "" + dizhi + "",
        image: "/bofangqi/ad.jpg",
        width: "923",
        height: "565",
        skin: "/bofangqi/skin-ingben/skin.xml",
        screencolor: "#1ff",
        autostart: "true"
    });

}
function bfq(dizhi)
{

    document.getElementById("video").innerHTML = "<object class=\"player\" type=\"application/x-shockwave-flash\" data=\"/template/default/images/player_flv_maxi.swf\" width=\"923\" height=\"565\">                <param name=\"movie\" value=\"/template/default/images/player_flv_maxi.swf\" />                <param name=\"allowFullScreen\" value=\"true\" />                <param name=\"FlashVars\" value=\"flv=" + dizhi + "&amp;width=923&amp;height=565&amp;autoplay=1&amp;showstop=1&amp;showvolume=1&amp;showtime=1&amp;startimage=/medias/startimage_en.jpg&amp;showfullscreen=1\" />                  </object>";
}

//设置收藏
function shoucang(url,yonghuming,id) {
    if (yonghuming != "") {
        if (document.getElementById("bianhao").innerHTML == id) {
            alert("已经收藏过了");
        }
        else {
            document.getElementById("bianhao").innerHTML = id;
            url = url + "&sid=" + Math.random();
            // document.write(url);
            request.open("GET", url, true);
            request.onreadystatechange = shoucang_loadPage;
            request.send(null);
        }
    }
    else {
        alert("请先登陆后才可以收藏题库");
    }
}

function shoucang_loadPage() {
    if (request.readyState == 4) {
        if (request.status == 200) {
            if (request.responseText != "") {
                if (request.responseText == "ok") {
                    document.getElementById("xingxing_" + document.getElementById("bianhao").innerHTML + "").src = "/template/default/images/sc_2.png";
                }
            }


        }


    }
}
//end
//checkbox全选
function checkbox_xuan(g1)
{	
	 
	 var boxes = document.getElementsByName(g1); 
	 for (var i = 0; i < boxes.length; i++)   
		{
			boxes[i].checked=true;
		}
	 if($('#qxs').attr('checked')==false){
	  for (var i = 0; i < boxes.length; i++)   
		{
			boxes[i].checked=false;
		}
	  };
	 }
	
//购物车删除
function del_cart()
{
    var boxes = document.getElementsByName("cart_ch"); 
    var t2=0;
    var t1="";
    for (var i = 0; i < boxes.length; i++)   
    {
     if (boxes[i].checked)   
     {
        t2=t2+1;
        if(t2==1)
        {
        t1=t1+boxes[i].value;
        }
        else
        {
        t1=t1+","+boxes[i].value;
        }
     }
    }
	if(t1=="")
	{
		alert2("请先选择后删除");
	}
	else
	{
		var tiao_url = "/pay/cart.aspx?type=del&id="+t1;
             window.location.href = tiao_url;
        window.event.returnValue = false;	
	}
}
//收藏删除
function del_history() {
    var boxes = document.getElementsByName("cart_ch");
    var t2 = 0;
    var t1 = "";
    for (var i = 0; i < boxes.length; i++) {
        if (boxes[i].checked) {
            t2 = t2 + 1;
            if (t2 == 1) {
                t1 = t1 + boxes[i].value;
            }
            else {
                t1 = t1 + "," + boxes[i].value;
            }
        }
    }
    if (t1 == "") {
        alert2("请先选择后删除");
    }
    else {
        var tiao_url = "/Execution.aspx?t=history&type=del&tip_string=收藏记录删除成功！&id=" + t1 + "";
        window.location.href = tiao_url;
        window.event.returnValue = false;
    }
}
//购物车位置改变数量
function get_shuliang(id) {
        var tiao_url = "cart.aspx?type=shuliang&shuliang=" + document.getElementById("shuliang").value + "&id=" + id;
        window.location.href = tiao_url;
        window.event.returnValue = false;
    }

//跳转
function login_tiao() {
    window.location.href = "/default.aspx?login&tipurl=" + window.location.href.replace("&", "fzw123");
    window.event.returnValue = false;
}
//end

//导航
function on_page(g1) {

    for (i = 1; i <= 8; i++) {

        if (g1 == i) {
            document.getElementById("pic_d" + i).className = "on";
        }
        else {
            document.getElementById("pic_d" + i).className = "";
        }

    }


}
//会员中心导航
function user_top_on(g1) {

    for (i = 1; i <= 10; i++) {
        if (document.getElementById("user_top" + i)) {
            if (g1 == i) {
                document.getElementById("user_top" + i).className = "on";
            }
            else {
                document.getElementById("user_top" + i).className = "";
            }
        }

    }


}


//加和减
function set_jj(type, id,shuliang) {
    if (type == "+") {
        document.getElementById(id).innerHTML = parseInt(document.getElementById(id).innerHTML) + 1;
    }
    else {

        if (parseInt(document.getElementById(id).innerHTML) - 1 < shuliang) {
            document.getElementById(id).innerHTML = shuliang;
        }
        else {
            document.getElementById(id).innerHTML = parseInt(document.getElementById(id).innerHTML) - 1;
        }
    }
}

//设置全局页面变化XZ2 XZ
function on_a(g1) {

    for (i = 1; i <= 10; i++) {
        if (document.getElementById("div_a" + i)) {
            if (i == g1) {
                document.getElementById("div_a" + i).className = 'xz2';

            }
            else {
                document.getElementById("div_a" + i).className = 'xz';

            }
        }

    }
}



//评论
function pinglun(g1) {

    if (document.getElementById(g1).val() == "来说两句吧..." || document.getElementById(g1).val() == "") {
        alert("内容不可以为空");
        document.getElementById(g1).focus();
        return false;
    }


}

//问答
function onask() {
    if (document.getElementById("neirong2").value == "请输入问答内容..." || document.getElementById("neirong2").value == "") {
        alert("内容不可以为空");
        document.getElementById("neirong2").focus();
        return false;
    }
    if (document.getElementById("biaoti").value == "") {
        alert("标题不可以为空");
        document.getElementById("biaoti").focus();
        return false;
    }

}
//RSS
function onrss() {
    if (document.getElementById("xingming").value == "") {
        alert("姓名不可以为空");
        document.getElementById("xingming").focus();
        return false;
    }
    if (document.getElementById("youxiang").value == "") {
        alert("邮箱不可以为空");
        document.getElementById("youxiang").focus();
        return false;
    }
     if (document.getElementById("kechengbianhao").value == "") {
        alert("课程不可以为空");
        document.getElementById("kechengbianhao").focus();
        return false;
    }

}

//登录
function login() {
    if (document.getElementById("yonghuming").value == "") {
        alert("不可以为空");
        document.getElementById("yonghuming").focus();
        return false;
    }
    else {
        var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if (myreg.test(document.getElementById("yonghuming").value)) {
            $('.yonghushuru').attr('name', 'email');
           
        }
    }
    if (document.getElementById("mima").value == "") {
        alert("密码不可以为空");
        document.getElementById("mima").focus();
        return false;
    }
}
//获取js radio
function get_radio(id) {
    var temp = document.getElementsByName(id);
    var radiovalue = "";
    for (i = 0; i < temp.length; i++) {

        //遍历Radio

        if (temp[i].checked) {
            radiovalue = temp[i].value;
        }
    }
    document.getElementById("TextBox10").value = radiovalue;
    return radiovalue;
}
//收货地址
function set_add() {
    if (document.getElementById("TextBox1").value == "") {
        alert2("收货人姓名不可以为空");
        document.getElementById("TextBox1").focus();
        return false;
    }
    if (document.getElementById("TextBox2").value == "") {
        alert2("街道地址不可以为空");
        document.getElementById("TextBox2").focus();
        return false;
    }
    if (document.getElementById("TextBox4").value == "" && document.getElementById("TextBox6").value == "") {
        alert2("手机号码或固定电话请填一项");
        document.getElementById("TextBox4").focus();
        return false;
    }
    if (document.getElementById("TextBox4").value != "") {
        var myreg = /^1+\d{10}$/;
        if (!myreg.test(document.getElementById("TextBox4").value)) {
            document.getElementById("tip4").innerHTML = "请输入有效的手机号";
            document.getElementById("TextBox4").focus();
            return false;
        }
        else {
            document.getElementById("tip4").innerHTML = "";
        }

    }

    var t1 = "";
    var list = document.getElementById("DropDownList1");
    for (var i = 0; i < list.options.length; i++) {
        if (list.options[i].selected) {
            t1 = list.options[i].value;
        }
    }

    if (t1 == "省份") {

        document.getElementById("tip").innerHTML = "省份不可以为空";

        document.getElementById("DropDownList1").focus();
        return false;
    }
    else {
        document.getElementById("tip").innerHTML = "";
    }

    var t2 = "";
    var list = document.getElementById("DropDownList2");
    for (var i = 0; i < list.options.length; i++) {
        if (list.options[i].selected) {
            t2 = list.options[i].value;
        }
    }
    if (t2 == "地级市") {
        document.getElementById("tip").innerHTML = "地级市不可以为空";
        document.getElementById("DropDownList2").focus();
        return false;
    }
    else {
        document.getElementById("tip").innerHTML = "";
    }

    var t3 = "";
    var list = document.getElementById("DropDownList3");
    for (var i = 0; i < list.options.length; i++) {
        if (list.options[i].selected) {
            t3 = list.options[i].value;
        }
    }
    if (t3 == "市、县级市") {
        document.getElementById("tip").innerHTML = "市、县级市不可以为空";
        document.getElementById("DropDownList3").focus();
        return false;
    }
    else {
        document.getElementById("tip").innerHTML = "";
    }

    document.getElementById("TextBox8").value = t1 + "-" + t2 + "-" + t3;

}
//购物车
function order() {
    if (get_radio("addlist") == "") {
        alert2("请选择地址");
        return false;
    }
    if (get_radio("addlist") == "0") 
    {
        if (document.getElementById("mendian").value == "") 
        {
                if (document.getElementById("shoujianrenxingming").value == "") 
                {
                    alert2("收件人姓名不可以为空");
                    document.getElementById("shoujianrenxingming").focus();
                    return false;
                }

                if (document.getElementById("jiedaodizhi").value == "") {
                    alert2("详细地址不可以为空");
                    document.getElementById("jiedaodizhi").focus();
                    return false;
                }


                if (document.getElementById("shoujihaoma").value == "") {
                   alert2("手机号码不可以为空");
                    return false;
                }
           

                var t1 = "";
                var list = document.getElementById("DropDownList1");
                for (var i = 0; i < list.options.length; i++) {
                    if (list.options[i].selected) {
                        t1 = list.options[i].value;
                    }
                }
                if (t1 == "省份") {
                    alert2("省份不可以为空");
                    document.getElementById("DropDownList1").focus();
                    return false;
                }

	            var t2 = "";
                var list = document.getElementById("DropDownList2");
                for (var i = 0; i < list.options.length; i++) {
                    if (list.options[i].selected) {
                        t2 = list.options[i].value;
                    }
                }
                if (t2 == "地级市") {
                    alert2("地级市不可以为空");
                    document.getElementById("DropDownList2").focus();
                    return false;
                }

                var t3 = "";
                var list = document.getElementById("DropDownList3");
                for (var i = 0; i < list.options.length; i++) {
                    if (list.options[i].selected) {
                        t3 = list.options[i].value;
                    }
                }
                if (t3 == "市、县级市") {
                    alert2("市、县级市不可以为空");
                    document.getElementById("DropDownList3").focus();
                    return false;
                }

                document.getElementById("suozaidiqu").value = t1 + "-" + t2 + "-" + t3;
            	
	             if (document.getElementById("zhifufangshi").value == "") {
                    alert2("请选择支付方式");
                    document.getElementById("zhifufangshi").focus();
                    return false;
                }
        }
        else
        {
         if (document.getElementById("shoujianrenxingming").value == "") 
                {
                    alert2("收件人姓名不可以为空");
                    document.getElementById("shoujianrenxingming").focus();
                    return false;
                }

  


                if (document.getElementById("shoujihaoma").value == "") {
                   alert2("手机号码不可以为空");
                    return false;
                }
        }
	
    }
   
  

}
//会员地址
function user_address() {
    if (document.getElementById("shoujianrenxingming").value == "") {
        alert2("收件人姓名不可以为空");
        document.getElementById("shoujianrenxingming").focus();
        return false;
    }

    if (document.getElementById("jiedaodizhi").value == "") {
        alert2("详细地址不可以为空");
        document.getElementById("jiedaodizhi").focus();
        return false;
    }


    if (document.getElementById("shoujihaoma").value == "") {
        alert2("手机号码不可以为空");
        document.getElementById("shoujihaoma").focus();
        return false;
    }
   

    var t1 = "";
    var list = document.getElementById("DropDownList1");
    for (var i = 0; i < list.options.length; i++) {
        if (list.options[i].selected) {
            t1 = list.options[i].value;
        }
    }
    if (t1 == "省份") {
        alert2("省份不可以为空");
        document.getElementById("DropDownList1").focus();
        return false;
    }

	var t2 = "";
    var list = document.getElementById("DropDownList2");
    for (var i = 0; i < list.options.length; i++) {
        if (list.options[i].selected) {
            t2 = list.options[i].value;
        }
    }
    if (t2 == "地级市") {
        alert2("地级市不可以为空");
        document.getElementById("DropDownList2").focus();
        return false;
    }

    var t3 = "";
    var list = document.getElementById("DropDownList3");
    for (var i = 0; i < list.options.length; i++) {
        if (list.options[i].selected) {
            t3 = list.options[i].value;
        }
    }
    if (t3 == "市、县级市") {
        alert2("市、县级市不可以为空");
        document.getElementById("DropDownList3").focus();
        return false;
    }

    document.getElementById("suozaidiqu").value = t1 + "-" + t2 + "-" + t3;
	
}
//注册
//注册
function reg() {

    if (document.getElementById("ver-mid").checked == false) {
        alert('您还没有同意英本教育使用服务协议');
        return false;
    }

    var arr = new Array();

    arr = document.getElementById("yonghuming").value.split(" ");

    if (arr.length != 1) {

        alert("用户名不能包含空格");
        document.getElementById("yonghuming").value = document.getElementById("yonghuming").value.replace(" ", "");
        document.getElementById("yonghuming").focus();
        return false;

    }


  
    var length = document.getElementById("yonghuming").value.replace(/[^\x00-\xff]/g, "**").length
    if (length < 4) {
        alert("用户名：请输入4-25个字符，一个汉字为两个字符，推荐使用中文");
        document.getElementById("yonghuming").focus();
        return false;
    }
    if (length > 25) {
        alert("用户名：请输入4-25个字符，一个汉字为两个字符，推荐使用中文");
        document.getElementById("yonghuming").focus();
        return false;
    }
     
if (document.getElementById("email").value == "") {
alert("邮箱不可以为空");

        document.getElementById("email").focus();
        return false;
    }
    else {
        var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if (!myreg.test(document.getElementById("email").value)) {
         alert("请输入有效的E_mail！");
          
            document.getElementById("email").focus();
            return false;
        }

    }
    

       if (document.getElementById("mima").value.length <= 5)
	{
	    alert("密码不可以为空");
		document.getElementById("mima").focus();
		return false;
	}

document.getElementById("yonghuming").value=document.getElementById("shoujihaoma").value;

	if (document.getElementById("mima_").value.length <= 5)
	{
	    alert("确认密码不可以为空");
		document.getElementById("mima_").focus();
		return false;
	}


	if (document.getElementById("mima_").value != document.getElementById("mima").value)
	{
	    alert("确认密码跟密码不一致");
	    document.getElementById("mima_").focus();
		return false;	
	}
	


}

//修改会员资料
function user_edit() {






    if (document.getElementById("shouji").value == "") {
        alert("手机号不可以为空以为空")
        document.getElementById("shouji").focus();
        return false;
    }
    else {
        var myreg = /^1+\d{10}$/;
        if (!myreg.test(document.getElementById("shouji").value)) {
            alert("请输入有效的手机号");
            document.getElementById("shouji").focus();
            return false;
        }


    }
    if (document.getElementById("zhenshixingming").value == "") {
        alert("真实姓名不可以为空");
        document.getElementById("zhenshixingming").focus();
        return false;
    }


    if (document.getElementById("shengri").value == "") {
        alert("生日不可以为空");
        document.getElementById("shengri").focus();
        return false;
    }

    
	}


//修改密码
	function pwd() {

    if (document.getElementById("OldPassword").value.length <= 5) {
        alert("旧密码不可以为空");
        document.getElementById("OldPassword").focus();
        return false;
    }


    if (document.getElementById("mima").value.length <= 5) {

        alert("新密码不可以为空");
        document.getElementById("mima").focus();
        return false;
    }


    if (document.getElementById("mima_").value != document.getElementById("mima").value) {

        alert("确认新密码跟新密码不一致");
        document.getElementById("mima_").focus();
        return false;
    }
  

}



//加入收藏

function AddFavorite(sURL, sTitle) {

    sURL = encodeURI(sURL);
    try {

        window.external.addFavorite(sURL, sTitle);

    } catch (e) {

        try {

            window.sidebar.addPanel(sTitle, sURL, "");

        } catch (e) {

            alert2("加入收藏失败，请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");

        }

    }

}

//设为首页

function SetHome(url) {

    if (document.all) {

        document.body.style.behavior = 'url(#default#homepage)';

        document.body.setHomePage(url);

    } else {

        alert2("您好,您的浏览器不支持自动设置页面为首页功能,请您手动在浏览器里设置该页面为首页!");

    }

}

//设置颜色和尺码
function get_beizhu(type, g1, chanpinbianhao) {
    if (type == "yanse") {
        document.getElementById("yanse").value = g1;
    }
    else {
        document.getElementById("chicun").value = g1;
    }
    if (document.getElementById("yanse").value == "") {
       // alert2("请选择颜色");
    }
    else if (document.getElementById("chicun").value == "") {
        //alert2("请选择尺寸");
    }
    else {
        document.getElementById("beizhu").value = "尺寸：" + document.getElementById("chicun").value + "&nbsp;&nbsp;" + "颜色：" + document.getElementById("yanse").value;

        var url = "/Single.aspx?m=beizhu&yanse=" + escape(document.getElementById("yanse").value) + "&chicun=" + escape(document.getElementById("chicun").value) + "&chanpinbianhao=" + chanpinbianhao + "&sid=" + Math.random();
      //  document.write(url);
        request.open("GET", url, true);
        request.onreadystatechange = beizhu_loadPage;
        request.send(null);

    }

    function beizhu_loadPage() {
        if (request.readyState == 4) {
            if (request.status == 200) {
                if (request.responseText != "") {
                    var response = request.responseText.split("|");

                    document.getElementById("jiage_view").innerHTML = response[0];
                    document.getElementById("kucun").innerHTML = response[1];
                    document.getElementById("jiage").value = response[0];
                }

            }


        }
    }
    

}