﻿function rowOrderVO() {
}
//rowOrderVO.prototype.OrderID
rowOrderVO.prototype.EmailID = "";
rowOrderVO.prototype.ProduceID = 6001234
rowOrderVO.prototype.ProduceName = "六一啊喔鹅识字产品套装";
rowOrderVO.prototype.ProduceDescribe = "全套产品包含：<br/>3300个汉字动画的软件一套<br/>培养阅读绘本书籍光盘一张<br/>识字教学指导的书籍一本<br/>孩子游戏识字积木教具一套<br/>配套使用软件USB锁";
rowOrderVO.prototype.Unit = "套";
rowOrderVO.prototype.Amount = 1;
rowOrderVO.prototype.Price = 597;
rowOrderVO.prototype.Discount = 0;
//rowOrderVO.prototype.OrderDay
//rowOrderVO.prototype.PaiedDay
//rowOrderVO.prototype.SendoutDay
rowOrderVO.prototype.Express = "SF";
//rowOrderVO.prototype.ExpressID
rowOrderVO.prototype.PaybyWay = "货到付款";
rowOrderVO.prototype.PaybyBank = "货到付款";
//rowOrderVO.prototype.TakeoverDay
rowOrderVO.prototype.FromSite = document.URL;
rowOrderVO.prototype.FromUrl = "来源网址";
rowOrderVO.prototype.BuyerName = "";
rowOrderVO.prototype.Address1 = "";
rowOrderVO.prototype.Address2 = "";
rowOrderVO.prototype.Address3 = "";
rowOrderVO.prototype.Address = "";
rowOrderVO.prototype.Telphone = "";
rowOrderVO.prototype.Mobile = "";
rowOrderVO.prototype.QQorMSN = "";
rowOrderVO.prototype.Email = "";
rowOrderVO.prototype.BirthDay = "";
rowOrderVO.prototype.LeaveWord = "";
rowOrderVO.prototype.LogsID = 0;
function aoeCookieVO() {
}
this.defaultCookie = {
    UserID: 4531,
    User2ID: "61aoe@61aoe.com",
    EmailID: "61aoe@61aoe.com",
    SaveEmail: "4006005438@b.qq.com",
    Telphone: "4006005438",
    Mobile: "4006005438",
    QQ: "4006005438",
    QQscript: "http://b.qq.com/webc.htm?new=0&sid=4006005438&eid=218808P8z8p8R8p8P8y8q&o=www.61aoe.cn&q=7",
    LogsID: 0,
    FromUrl: ""
};
aoeCookieVO.prototype.UserID = getCookieVal("UserID");
aoeCookieVO.prototype.User2ID = getCookieVal("User2ID");
aoeCookieVO.prototype.EmailID = getCookieVal("EmailID");
aoeCookieVO.prototype.SaveEmail = getCookieVal("SaveEmail");
aoeCookieVO.prototype.Telphone = getCookieVal("Telphone");
aoeCookieVO.prototype.Mobile = getCookieVal("Mobile");
aoeCookieVO.prototype.QQ = getCookieVal("QQ");
aoeCookieVO.prototype.QQscript = getQQCookie();
aoeCookieVO.prototype.LogsID = getCookieVal("LogsID");
aoeCookieVO.prototype.FromUrl = getCookieVal("FromUrl");
aoeCookieVO.prototype.SERVER_NAME = getCookieVal("SERVER_NAME");

var aoeCookie;
var order;
var rowOrder;

$(function() {
    order = new DoOrder();
    rowOrder = new rowOrderVO();
    aoeCookie = new aoeCookieVO();

    //地址
    $("#select").json2select(areaJson);
    //$("#setOrder").click(setOrder_onclick);
    $("#form1").submit(setOrder_onclick);
    $(".EmailID").html(aoeCookie.EmailID);
    $(".SaveEmail").html("联系邮箱：" + aoeCookie.SaveEmail);
    $(".Telphone").html("订购电话：" + aoeCookie.Telphone);
    $(".Mobile").html("订购电话：" + aoeCookie.Mobile); ;
    $(".QQorMSN").attr("href", aoeCookie.QQscript);
    $(".QQ").html(aoeCookie.QQ);
	
 

});

function setOrder_onclick() {

    var flag = true;
    if (getText("#BuyerName") == "") {
        flag = false;
        $("#BuyerName").addClass("error");
    } else {
        $("#BuyerName").removeClass("error");
    }
    if (getText("#Address") == "") {
        flag = false;
        $("#Address").addClass("error");
    } else {
        $("#Address").removeClass("error");

    }
    if (!flag) {
        return flag;
    }
	document.getElementById("gIf").src = "http://www.61aoe.cn/google.htm";

    //rowOrder.OrderID
    rowOrder.EmailID = aoeCookie.EmailID;
    rowOrder.ProduceID = 6001234;
    rowOrder.ProduceName = $("#ProduceName").val();
    rowOrder.ProduceDescribe = "全套产品包含：<br/>3300个汉字动画的软件一套<br/>培养阅读绘本书籍光盘一张<br/>识字教学指导的书籍一本<br/>孩子游戏识字积木教具一套<br/>配套使用软件USB锁";
    rowOrder.Unit = "套";
    rowOrder.Amount = 1;
    //设置价格
    if(rowOrder.ProduceName=="《61aoe识字套装》+《5册同步阅读》787元，特优惠价697元")
    {
        rowOrder.Price = 697;
    }else if(rowOrder.ProduceName=="《61aoe识字套装》597元")
    {
        rowOrder.Price = 597;
    }else{
        rowOrder.Price = 190;  
    }    
    rowOrder.Discount = 0;
    //rowOrder.OrderDay
    //rowOrder.PaiedDay
    //rowOrder.SendoutDay
    rowOrder.Express = "SF";
    //rowOrder.ExpressID = "";
    rowOrder.PaybyWay = "货到付款";
    rowOrder.PaybyBank = "货到付款";
    //rowOrder.TakeoverDay = "";
    rowOrder.FromSite = document.URL;
    rowOrder.FromUrl = aoeCookie.FromUrl;
    rowOrder.BuyerName = getText("#BuyerName");
    rowOrder.Address1 = getText("select[name=sel0]");
    rowOrder.Address2 = getText("select[name=sel1]");
    rowOrder.Address3 = getText("select[name=sel2]");
    rowOrder.Address = getText("#Address");
    rowOrder.Telphone = getText("#Telphone");
    rowOrder.Mobile = getText("#Mobile");
    rowOrder.QQorMSN = getText("#QQorMSN");
    rowOrder.Email = getText("#Email");
    rowOrder.BirthDay = getText("#BirthDay");
    rowOrder.LeaveWord = getText("#LeaveWord");
    rowOrder.LogsID = aoeCookie.LogsID;

	$("#order1").hide();
	$("#order2").hide();
	$("#order3").show();
    order.doOrder(rowOrder, function(response) {
        if (response.result == "") {
            $("#order1").hide();
            $("#order2").show();
			$("#order3").hide();
			
        } else {
			$("#order1").show();
            $("#order2").hide();
			$("#order3").hide();
			
            alert(response.result + "服务器出错，请电话联系网站客服：4006005438");
        }
    });
    return false;
}
var defaultCookie;


//获取QQ的cookie
function getQQCookie() {
    var str = $.cookie("QQscript");
    if (str == null) {
        return defaultCookie["QQscript"];
    }

    return str;
}
//通过name来索引值，类似于Key----value的形式来得到value
function getCookieVal(name) {

    //name不合法时返回false
    if(name==null || name.toString().length==0)
    {
        return false;
    }
    var firstCharPos, lastCharPos;
    //cookie信息不存在时
    var theBigCookie = $.cookie("aoeCookie");
    if (theBigCookie == null) {
        return defaultCookie[name];
    }
    
    firstCharPos = theBigCookie.indexOf(name);
    if (firstCharPos != -1) {//skip 'name' and '='.
        firstCharPos += name.length + 1;
        //Find the end of the value string (i.e. the next';').
        lastCharPos = theBigCookie.indexOf('&', firstCharPos);
        if (lastCharPos == -1) lastCharPos = theBigCookie.length;
        //Return thevalue.
        return theBigCookie.substring(firstCharPos, lastCharPos);
    } else {
        return false;
    }
}
function getText(name) {
    return $.trim($(name).val());
}
var yodao_conversion_id = "224777";
var yodao_conversion_label = "landing";

// JavaScript Document
var emailFun={};
var remoteUrl ="";
var subEmailInfo="";
emailFun.isEmail = function(str) {   
        var re = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;   
        return re.test(str);   
}   
emailFun.subEmail=function(email){
	$(".subBtn").each(function(i){
		$(this).attr("src","http://www.61aoe.cn/images/10.gif");
	});
	var url=document.domain;
	var a1=$("#a1").val();
	var a3=document.domain+$("#a3").val();
	url=window.location.host;
	remoteUrl="http://vip.61aoe.cn:81/subEmail.aspx?date="+new Date()+"&a2="+document.domain+"&email="+email+"&a1="+a1+"&a3="+a3;
	if(emailFun.isEmail(email)){
		
        
	$.getScript(remoteUrl,function(){
		$(".subBtn").each(function(i){
			$(this).attr("src","http://www.61aoe.cn/images/bnt4.jpg");
		});

		if(subEmailInfo=="您已经订阅了我们的杂志!"){
			$.prompt("<br/><a class=down href='http://anpig.zhost.cn/六一啊喔鹅(61aoecn)识字免费版.exe'>点击下载免费版识字软件</a>");	
		}else{
			$.prompt(subEmailInfo);
			}
    });
	}else{
		$(".subBtn").each(function(i){
			$(this).attr("src","http://www.61aoe.cn/images/bnt4.jpg");
		});
		$.prompt("邮箱地址错误，请重新输入！");

	}
};

