// JavaScript Document
//Modified by atom
//2009-2-3

//Clean the cache
$.ajaxSetup( {
	cache : false
});

// 模拟回车键--邮件订阅
function KeyDown() {
	if (event.keyCode == 13) {
		event.returnValue = false; // 不刷新界面
		// document.form1.loginsubmit.click(); //使用表单提交
		Subscribe(0);
	}
}

// 模拟回车键--用户登录
function LoginKeyDown() {
	if (event.keyCode == 13) {
		event.returnValue = false; // 不刷新界面
		// document.form1.loginsubmit.click(); //使用表单提交
		Js_userloginlocal();
	}
}

// 帐号长度检测开始
function Js_registerchecklocal() {
	var user_name = $("#user_name").val();

	if (user_name == "" || user_name.length < 5 || user_name.length > 30) {

		$("#usernamewrong")
				.html(
						'<font color=red><img src="images/27.gif" align="absmiddle">Please input your email</font>');
		$("#subbutton").attr("disabled", true);
		return false;
	} else {
		$("#usernamewrong").html("");
		registerCheck();
	}

}
// 帐号长度检测结束
// 用户注册，邮箱检测 2008-10-27 修改 by 李聪颖
function checkuser() {
	// alert("adasd");
	var email = $("#email").val();
	document.getElementById("username2").value = email;
	// var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
	var reEmail = /([A-Za-z0-9_-]+@[A-Za-z0-9-]+\.\w+)(\.{0,1}\w*)(\.{0,1}\w*)/;
	if (email == "" || reEmail.test(email) == false || email.match(/^\s*$|^c:\\con\\con$|[%,\'\*\"\s\t\<\>\&\\]/)) {
		$("#username_notice").html('Please enter your email address.');
		$("#username_img")
				.html(
						'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		return false;
	} else {
		$("#username_notice").html("");
		Js_registeremailcheck();
	}
}
// 婚纱活动用的的用户注册验证 checkuser_wedding
function checkuser_wedding() {
	var email = $("#email").val();
	document.getElementById("username2").value = email;
	var reEmail = /([A-Za-z0-9_-]+@[A-Za-z0-9-]+\.\w+)(\.{0,1}\w*)(\.{0,1}\w*)/;
	if (email == "" || reEmail.test(email) == false || email.match(/^\s*$|^c:\\con\\con$|[%,\'\*\"\s\t\<\>\&\\]/)) {
		$("#username_notice").html('Please enter your email address.');
		$("#username_img").html(
				'<img src="images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		return false;
	} else {
		$("#username_notice").html("");
		$("#username_img").html(
				'<img src="images/right.gif" align="absmiddle">');
		Js_registeremailcheck_wedding();
	}
}

// 邮箱唯一性检测开始
function Js_registeremailcheck() {
	var email = $("#email").val();
	if (email == "") {
		$("#username_notice")
				.html(
						'Please input a email as your passport.Example:abc@whosalesale-dress.net.');
		$("#username_img")
				.html(
						'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
	} else {
		$
				.ajax( {
					type : "get",
					url : "function/checkusername.php",
					data : "email=" + email,
					cache : false,
					beforeSend : function(XMLHttpRequest) {
						$("#username_notice").val("Checking...");
					},
					success : function(html) {
						html = html.replace(/[\r\n]/g, "");
						if (html == "ok") {
							$("#username_notice").html('');
							$("#username_img")
									.html(
											'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
							$("#subbutton").attr("disabled", false);
						} else {
							$("#username_notice")
									.html(
											'The email address has been registered.Please enter another one.');
							$("#username_img")
									.html(
											'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
							$("#subbutton").attr("disabled", true);
						}
					},
					complete : function(XMLHttpRequest, textStatus) {
						// $("#subbutton").val("Submit");
				},
				error : function() {
					// alert("error");
				}

				});

	}
}

// 婚纱活动用的的用户注册验证 Js_registeremailcheck_wedding
function Js_registeremailcheck_wedding() {
	var email = $("#email").val();
	if (email == "") {
		$("#username_notice")
				.html(
						'Please input a email as your passport.Example:abc@whosalesale-dress.net.');
		$("#username_img").html(
				'<img src="images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
	} else {
		$
				.ajax( {
					type : "get",
					url : "../../function/checkusername.php",
					data : "email=" + email,
					cache : false,
					beforeSend : function(XMLHttpRequest) {
						$("#username_notice").val("Checking...");
					},
					success : function(html) {
						// alert(html);
						if (html == "ok") {
							$("#username_notice").html('');
							$("#username_img")
									.html(
											'<img src="images/right.gif" align="absmiddle">');
							$("#subbutton").attr("disabled", false);
						} else {
							$("#username_notice")
									.html(
											'The email address has been registered.Please enter another one.');
							$("#username_img")
									.html(
											'<img src="images/wrong.gif" align="absmiddle">');
							$("#subbutton").attr("disabled", true);
						}
					},
					complete : function(XMLHttpRequest, textStatus) {
						// $("#subbutton").val("Submit");
				},
				error : function() {
					// alert("error");
				}
				});
	}
}

// 检测im选中状态
function Js_Checkim() {
	var imtype = $('[name="imtype"][checked=true]:radio').val();
	var imvalue = $("#imvalue").val();

	if (imtype == "msn" && imvalue != '') {
		document.getElementById("other[msn]").value = imvalue;
		document.getElementById("other[skype]").value = "";
		document.getElementById("other[qq]").value = "";
		document.getElementById("other[yahoo]").value = "";
	}

	else if (imtype == "skype" && imvalue != '') {
		document.getElementById("other[msn]").value = "";
		document.getElementById("other[skype]").value = imvalue;
		document.getElementById("other[qq]").value = "";
		document.getElementById("other[yahoo]").value = "";
	} else if (imtype == "yahoo" && imvalue != '') {
		document.getElementById("other[msn]").value = "";
		document.getElementById("other[skype]").value = "";
		document.getElementById("other[qq]").value = "";
		document.getElementById("other[yahoo]").value = imvalue;
	} else if (imtype == "qq" && imvalue != '') {
		document.getElementById("other[msn]").value = "";
		document.getElementById("other[skype]").value = "";
		document.getElementById("other[qq]").value = imvalue;
		document.getElementById("other[yahoo]").value = "";
	} else {

	}

}

// 婚纱活动20101210密码长度检测开始
function PasswordLongCheck_wedding() {
	var password = $("#password").val();
	if (password == "" || password.length < 6 || password.length > 20) {

		$("#UserPasswordCheck").html(
				"Your password must between 6-20 characters.");
		$("#userpassword_img").html(
				'<img src="images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		return false;
	} else {
		$("#UserPasswordCheck").html("");
		$("#userpassword_img").html(
				'<img src="images/right.gif" align="absmiddle">');
	}
}
// 密码长度检测开始
function PasswordLongCheck() {
	var password = $("#password").val();
	var conform_password = $("#conform_password").val();
	if (password == "" || password.length < 6 || password.length > 20) {
		$("#UserPasswordCheck").html(
				"Your password must between 6-20 characters.");
		$("#userpassword_img")
				.html(
						'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		return false;
	} else if (conform_password != password && conform_password != "") {
		if (conform_password != "" && conform_password != password) {
			if (password.length >= 6 && password.length <= 20) {
				$("#UserrePasswordCheck").html(
						"You didn't enter the same passward!");
				$("#userrepassword_img")
						.html(
								'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
				$("#UserPasswordCheck").html("");
				$("#userpassword_img")
						.html(
								'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
			} else {
				$("#UserrePasswordCheck").html(
						"Your password must between 6-20 characters.");
				$("#userrepassword_img")
						.html(
								'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
			}
		}
		$("#subbutton").attr("disabled", true);
		return false;
	} else if (conform_password == password) {
		$("#UserPasswordCheck").html("");
		$("#userpassword_img")
				.html(
						'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
		$("#UserrePasswordCheck").html("");
		$("#userrepassword_img")
				.html(
						'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
	} else {
		$("#UserPasswordCheck").html("");
		$("#userpassword_img")
				.html(
						'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
	}
}
// 密码长度检测结束

// 验证密码长度检测开始
function RePasswordLongCheck() {
	var conform_password = $("#conform_password").val();
	var password = $("#password").val();

	if (conform_password != password) {
		$("#UserrePasswordCheck").html("You didn't enter the same passward!");
		$("#userrepassword_img")
				.html(
						'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		return false;
	} else if (password == "" || password.length < 6 || password.length > 20) {
		$("#userrepassword_img")
				.html(
						'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		return false;
	} else {
		$("#UserrePasswordCheck").html("");
		$("#userrepassword_img")
				.html(
						'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
	}
	password_check();
}
// 验证密码长度检测结束

// 验证密码长度检测开始
// function RePasswordLongCheck(){
// var conform_password = $("#conform_password").val();
// var conform_password = $("#conform_password2").val();
// if(conform_password == "" || conform_password.length < 6 ||
// conform_password.length > 20){
// $("#UserPasswordCheck").html("Your password must between 6-20 characters.");
// $("#userpassword_img").html('<img src="themes/wholesale2010/images/wrong.gif"
// align="absmiddle">');
// $("#subbutton").attr("disabled",true);
// return false;
// }else{
// $("#UserPasswordReCheck").html("");
// $("#userpassword_img").html('<img src="themes/wholesale2010/images/right.gif"
// align="absmiddle">');
//	
// }
// password_check();
// }

// 密码合法性检测开始
function password_check() {
	var password = $("#password").val();
	var conform_password = $("#conform_password").val();
	if (password == "" || password != conform_password) {
		$("#UserPasswordCheck").html(
				"The two passwords you entered don't match. Please try again.");
		$("#userpassword_img")
				.html(
						'<img src="themes/wholesale2011/images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
		alert(conform_password);
		alert(password);
	}
	if (password != "" && password == conform_password) {
		$("#UserPasswordCheck").html("");
		$("#userpassword_img")
				.html(
						'<img src="themes/wholesale2011/images/right.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", false);
	}
}
function password_check_wedding() {
	var password = $("#password").val();
	var conform_password = $("#conform_password").val();
	if (password == "" || password != conform_password) {
		$("#UserPasswordCheck").html(
				"The two passwords you entered don't match. Please try again.");
		$("#userpassword_img").html(
				'<img src="images/wrong.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", true);
	}
	if (password != "" && password == conform_password) {
		$("#UserPasswordCheck").html("");
		$("#userpassword_img").html(
				'<img src="images/right.gif" align="absmiddle">');
		$("#subbutton").attr("disabled", false);
	}
}
// 密码合法性检测结束

// 添加购物车
function addToCart2(goods_id) {
	// var re = /[\r\n]+/mg; //替换换行符
	$
			.ajax( {
				type : "get",
				url : "function/goods_status.php",
				data : "goods_id=" + goods_id,
				cache : false,
				beforeSend : function(XMLHttpRequest) {
					// alert("adad");

				// $("#registeradd_state").val("loading...");
			},
				success : function(html) {
					// html =html.replace(re, "");
					if (html == "outofstock\r\n") {

						alert("out of stock...");

					} else {

						$("#hezctitle")
								.html(
										"<li>Please select the goods attribute <img src='images/add_to_cart_colse.gif' class='add_to_cart_colse' alt='colse' title='close' onClick='javascript:closeDiv()' /></li>");
						$("#hezcsmall").html(html);
						showDiv();

					}
				},
				complete : function(XMLHttpRequest, textStatus) {
					// $("#subbutton").val("Submit");
			},
			error : function() {
				// alert("error");
			}

			});

}

// 添加购物车2
function addToCart3(goods_id) {
	var goods = new Object(); // 新增
	var reNumber = /^\d+(\.\d+)?$/;
	var number = $("#number").val();
	var spec_arr = new Array();
	var formBuy = document.forms['ECS_FORMBUY'];
	if (formBuy) {
		spec_arr = getSelectedAttributes(formBuy);

		if (formBuy.elements['number']) {
			number = formBuy.elements['number'].value;
		}
	}

	// 定义婚纱的参数
	var customer_checkbox = 0;
	var bust = '';
	var waist = '';
	var hips = '';
	var clength = '';

	// 判断婚纱的参数属性 如果有 则 有婚纱 否则
	if (formBuy.elements['customer_checkbox']) {
		// 存在
		customer_checkbox = formBuy.elements['customer_checkbox'].value;

		// return false;
		if (customer_checkbox == 1) {

			bust = formBuy.elements['bust'].value;
			if (reNumber.test(bust) == false) {
				alert("please input the bust");
				document.getElementById("bust").value = '';
				document.getElementById("bust").focus();
				return false;
			}

			waist = formBuy.elements['waist'].value;
			if (reNumber.test(waist) == false) {
				alert("please input the waist");
				document.getElementById("waist").value = '';
				document.getElementById("waist").focus();
				return false;
			}

			hips = formBuy.elements['hips'].value;
			if (reNumber.test(hips) == false) {
				alert("please input the hips");
				document.getElementById("hips").value = '';
				document.getElementById("hips").focus();
				return false;
			}

			clength = formBuy.elements['clength'].value;
			if (reNumber.test(clength) == false) {
				alert("please input the length");
				document.getElementById("clength").value = '';
				document.getElementById("clength").focus();
				return false;
			}

			goods.customer_checkbox = customer_checkbox;
			goods.bust = bust;
			goods.waist = waist;
			goods.hips = hips;
			goods.clength = clength;

		}

	}
	// 处理婚纱

	// 新增 处理商品数量
	if (reNumber.test(number) == false || number < 1) {
		alert("please input the Quantity!");
		document.getElementById("number").value = '';
		document.getElementById("number").focus();
		return false;
	}

	$
			.ajax( {
				type : "get",
				url : "function/goods_addtocart.php",
				// data: "goods_id="+
				// goods_id+"&number="+number+"&spec_arr="+spec_arr,
				data : "goods_id=" + goods_id + "&number=" + number
						+ "&spec_arr=" + spec_arr + "&customer_checkbox="
						+ goods.customer_checkbox + "&bust=" + goods.bust
						+ "&waist=" + goods.waist + "&hips=" + goods.hips
						+ "&clength=" + goods.clength,
				cache : false,
				beforeSend : function(XMLHttpRequest) {
					// $("#registeradd_state").val("loading...");
			},
				success : function(html) {
					if (html == "outofstock") {
						alert("out of stock...");
					} else {

						$("#hezctitle")
								.html(
										"<li>The product has been added to your cart.</li>");
						$("#hezcsmall")
								.html(
										"<li>Thanks for your order, Now you can:</li><li><table align=\"center\"><tr><td><A href=\"Javascript::\"  style=\"cursor:pointer\" ><input type=\"button\" name=\"continue\" value=\"Continue Shopping\" onClick=\"javascript:closeDiv()\" ></A></td><td>&nbsp;</td><td><A href=\"flow.php\"><input type=\"button\" name=\"viewcart\" value=\"View Cart\"  onclick=\"gocart()\"></A></td></tr></table></li>");
						showDiv();

					}
				},
				complete : function(XMLHttpRequest, textStatus) {
					// $("#subbutton").val("Submit");
			},
			error : function() {
				// alert("error");
			}

			});

}

// order tracking 检测
function checktracking() {
	var ordernum = $("#ordernum").val();
	var tracknum = $("#tracknum").val();
	alert(ordernum);
	return false;
	if (ordernum == "" && tracknum == "") {

		alert("Please enter your order number or your order\'s tracking number to view order status.");

		return false;
	} else {
		// $("#UserPasswordCheck").html("");
		// $("#userpassword_img").html('<img
		// src="themes/wholesale2010/images/right.gif" align="absmiddle">');

	}

}

// 优惠码检测检测
function CheckVoucherCode() {
	var voucher_code = $("#verify-box").val();
	var re = /[\r\n]+/mg; // 替换换行符

	if (voucher_code == "") {

		$("#vouchercodestatus").html('Please input your voucher code.');

		return false;
	} else {
		//alert($("#rank_points_hidden").val());
		/*wtw20110607(version)，积分大于1000不能使用优惠码*/
		if($("#rank_points_hidden").val()!="undefined" && $("#rank_points_hidden").val()>1000) {
			$("#vouchercodestatus").html('Sorry! You can not use the Promotional Voucher Code for your rank points is not below 1000 or the order does not fit condition.');
			$("#verify-box").attr("value", "");// 设置优惠码为空
			return false;
		}
		$.ajax( {
			type : "get",
			url : "function/checkvouchercode.php",
			data : "voucher_code=" + voucher_code,
			cache : false,
			beforeSend : function(XMLHttpRequest) {
			},
			success : function(html) {
				html = html.replace(re, "");
				if(html.indexOf("Sorry")>=0) {
					$("#verify-box").attr("value", "");// 设置优惠码为空
				}
				if (html == "The promotional voucher has been expired.") {
					$("#verify-box").attr("value", "");// 设置优惠码为空
		}
		$("#vouchercodestatus").html(html);

	},
	complete : function(XMLHttpRequest, textStatus) {
	},
	error : function() {
		// alert("error");
		}

		});

	}

}

function goods_page_top_js(){
	var url="function/goods_page.php?site=top&"+document.getElementById('goods_page_url').value;
	$("#goods_page_top_js").load(url); 
}
function goods_page_foot_js(){
	var url="function/goods_page.php?site=foot&"+document.getElementById('goods_page_url').value;
	$("#goods_page_foot_js").load(url); 
}
function online_js(){
	$("#top-kefu-mid").load("function/online.php"); 
}
function forum_list_js(){
	$("#forum_list_js").load("function/index_forum_list.php"); 
}
function category_tree_title_js(){
	$("#category_tree_title_js").load("function/category_tree2.php"); 
}

function category_tree_title_us_js(){
	$("#category_tree_title_us_js").load("function/category_tree_us.php"); 
}
function invoice_query_show() {
	$("#invoice_query_list").load("function/invoice_query.php");
}
function get_total() {
	$("#no_record span").load("clear_goods_number.html");
}
function change_shipping_list() {
	// alert("asdsad");
	// $("#invoice_query_list").load("function/invoice_query.php");
	// $("#flow-shipping-list").load("function/flow-shipping-list.php");
	var v = Math.round(Math.random() * 1000);

	jQuery.post("function/flow-shipping-list.php", '', function(html) {
		$("#flow-shipping-list").html(html);
	});
}

function get_user_info() {
	$("#head-login").load("function/head_user_info.php");
}
$(function() {
	$("#history-list").load("function/get_view_info.php");
})

function get_mycart() {
	$("#get_mycart").load("mycart.php");
}

function get_news_index() {
	$("#holder").load("function/get_news_index.php");
}
// 处理投票 20100816
function vote(vote_id) {

	var re = /[\r\n]+/mg; // 替换换行符
	$.ajax( {
		type : "get",
		url : "vote1.php",
		data : "vote_id=" + vote_id,
		cache : false,
		beforeSend : function(XMLHttpRequest) {
		},
		success : function(html) {
			html = html.replace(re, "");
			if (html == "login") {
				alert("Please login.");
				window.open("../../user.php?act=login", "", "", "");
			} else if (html == "done") {
				alert("You have voted already.");
				// window.open("../../user.php?act=login","","","");
	} else {
		// $('vote_val').innerHTML = updated_result;
		$("#vote_val").html(html);
	}

},
complete : function(XMLHttpRequest, textStatus) {
},
error : function() {
	// alert("error");
	}

	});

}

function change_shipping_list() {
	// alert("asdsad");
	// $("#invoice_query_list").load("function/invoice_query.php");
	$("#flow-shipping-list").load("function/flow-shipping-list.php");
}

// 优势专题验证
function check_todayoffer() {
	var textfield = $("#textfield").val();
	var textfield2 = $("#textfield2").val();
	var textfield3 = $("#textfield3").val();
	var re = /[\r\n]+/mg; // 替换换行符
	if (textfield == "") {
		alert("Item number and link blanks should be filled out");
		return false;
	}
	if (textfield2 == "") {
		alert("Item number and link blanks should be filled out");
		return false;
	}
	if (textfield3 == "") {
		alert("Please enter the price of the linked product");
		return false;
	}
	if (isNaN(textfield3)) {
		alert('You need to fill in a digital price');
		document.getElementById("textfield3").value = '';
		document.getElementById("textfield3").focus();
		return false;
	}
	$
			.ajax( {
				type : "get",
				url : "function/todayoffer_check_goods_sn.php",
				data : "textfield=" + textfield + "&textfield2=" + textfield2
						+ "&textfield3=" + textfield3,
				cache : false,
				beforeSend : function(XMLHttpRequest) {

				},
				success : function(html) {
					// document.write(html);
				html = html.replace(re, "");

				if (html == "login") {
					alert('If not yet a member in wholesale-dress,please register first.');
					window.open("user.php?act=login", "", "", "");

				} else if (html == "1") {

					$("#todayoffer_note").fadeIn("3000", function() {
						offer_oc('close');
						setTimeout('change_hidden()', 4000);
					});

				} else {

					alert('Invalid product number');
					document.getElementById("textfield").value = '';
					document.getElementById("textfield").focus();

				}
			},
			complete : function(XMLHttpRequest, textStatus) {
				// $("#subbutton").val("Submit");
			},
			error : function() {
				// alert("error");
			}

			});

}
function change_hidden() {

	$("#todayoffer_note").fadeOut("6000", function() {

	});

	// document.getElementById("abc").style.display="none";
}

// bzm 2010-12-01 add UPS
function getUpsPackage(invoice_no) {
	$.ajax( {
		type : "GET",
		async : false,
		url : "user.php?act=getUpsPackage",
		data : "invoice_no=" + invoice_no,
		cache : false,
		beforeSend : function(XMLHttpRequest) {
		},
		success : function(html) {
			// alert(html);
		if (html) {
			document.getElementById('UpsPackageInfo').innerHTML = html;
		}
	},
	complete : function(XMLHttpRequest, textStatus) {
	},
	error : function() {
		// alert("error");
		return false;
	}
	});
}
// end

// bzm 2011-01-14 add 情人节活动
// 索取礼品卡
function getCard(order_id) {
	cardnum1 = document.getElementById('cardnum1').value;
	cardnum2 = document.getElementById('cardnum2').value;
	cardnum3 = document.getElementById('cardnum3').value;
	cardnum4 = document.getElementById('cardnum4').value;
	cardnum5 = document.getElementById('cardnum5').value;
	if (cardnum1 == "" && cardnum2 == "" && cardnum3 == "" && cardnum4 == ""
			&& cardnum5 == "") {
	}
	$.ajax( {
		type : "GET",
		async : false,
		url : "function/valentinesDayCard.php?act=getCard",
		data : "order_id=" + order_id,
		cache : false,
		beforeSend : function(XMLHttpRequest) {
		},
		success : function(html) {
			// alert(html);
		if (html == 'faild') {
			alert("Faild");
		} else {
			alert("Success");
			document.getElementById('cardBtn_' + order_id).innerHTML = '已经索取'
		}
	},
	complete : function(XMLHttpRequest, textStatus) {
	},
	error : function() {
		// alert("error");
		return false;
	}
	});
}

// 遮罩层 ml
function maskTo(cardid, cardpwd, imgid) {
	var carddiv1 = document.getElementById("carddiv1")
	carddiv1.innerHTML = "<div id='emailbg'><div onclick='closeCardDiv()' style='position:absolute;right:0;top:0;cursor:pointer;'><img src='images/close.gif' /></div><img src='images/"
			+ imgid
			+ ".jpg' /><div><center><button onclick='enableCard("
			+ cardid
			+ ","
			+ cardpwd
			+ ")'>Active</button></center></div></div>";

	var carddiv2 = document.getElementById("carddiv2");
	carddiv2.innerHTML = '<div id="emailbg2"></div>';

	var bgObj = document.getElementById("emailbg2");
	bgObj.style.width = document.body.offsetWidth + "px";
	bgObj.style.height = document.body.offsetHeight + "px";
}
function showpic(imgid) {
	var carddiv1 = document.getElementById("carddiv1")
	carddiv1.innerHTML = "<div id='emailbg'><div onclick='closeCardDiv()' style='position:absolute;right:0;top:0;cursor:pointer;'><img src='images/close.gif' /></div><img src='images/"
			+ imgid + ".jpg' /></div>";

	var carddiv2 = document.getElementById("carddiv2");
	carddiv2.innerHTML = '<div id="emailbg2"></div>';

	var bgObj = document.getElementById("emailbg2");
	bgObj.style.width = document.body.offsetWidth + "px";
	bgObj.style.height = document.body.offsetHeight + "px";
}
function closeCardDiv() {
	document.getElementById('emailbg').style.display = 'none';
	document.getElementById('emailbg2').style.display = 'none';
}
// 激活礼品卡
function enableCard(cardid, cardpwd) {
	$.ajax( {
		type : "GET",
		async : false,
		url : "function/valentinesDayCard.php?act=enableCard",
		data : "cardid=" + cardid + "&cardpwd=" + cardpwd,
		cache : false,
		beforeSend : function(XMLHttpRequest) {
		},
		success : function(html) {
			// alert(html);
		if (html == 'success') {
			alert("Activate successfully!");// 激活成功
		window.location.reload();
	} else if (html == 'repeat') {
		alert("Each time you can only ativate one gift card.");// 已经激活过一张，并且余额尚未用完
	} else if (html == 'invalid') {
		alert("Wrong card number or password!");// 输入的卡号或密码错误
	} else {
		alert("Invalid gift card!");// 系统错误，或者是要激活的卡已经激活过了，是无效卡号
	}
},
complete : function(XMLHttpRequest, textStatus) {
},
error : function() {
	// alert("error");
		return false;
	}
	});
}
// 结算页面激活礼品卡
function enableCardFlow() {
	cardid = document.getElementById('cardid').value;
	cardpwd = document.getElementById('cardpwd').value;
	if (cardid == "") {
		alert("Please enter the card number.");
		return false;
	}
	if (cardpwd == "") {
		alert("Please enter the card password.");
		return false;
	}
	$.ajax( {
		type : "GET",
		async : false,
		url : "function/valentinesDayCard.php?act=enableCard",
		data : "cardid=" + cardid + "&cardpwd=" + cardpwd,
		cache : false,
		beforeSend : function(XMLHttpRequest) {
		},
		success : function(html) {
			// alert(html);
		if (html == 'success') {
			alert("Activate successfully!");// 激活成功
		window.location.reload();
	} else if (html == 'repeat') {
		alert("Each time you can only ativate one gift card.");// 已经激活过一张，并且余额尚未用完
		window.location.reload();
	} else if (html == 'invalid') {
		alert("Wrong card number or password!");// 输入的卡号或密码错误
		window.location.reload();
	} else {
		alert("Invalid gift card!");// 系统错误，或者是要激活的卡已经激活过了，是无效卡号
		window.location.reload();
	}
},
complete : function(XMLHttpRequest, textStatus) {
},
error : function() {
	// alert("error");
		return false;
	}
	});
}

function change_goods_attr(goods_id) {
	var formBuy = document.forms['ECS_FORMBUY'];
	var spec_str = getSelectedAttributes(formBuy).toString();

	$.ajax( {
		type : "GET",
		async : false,
		url : "function/getstock.php",
		data : "goodsid=" + goods_id + "&spec_str=" + spec_str,
		cache : false,
		beforeSend : function(XMLHttpRequest) {
		},
		success : function(html) {
			var add_btn = document.getElementById('button_addtocart');
			if (html == 'success') {
				add_btn.style.display = "";
			} else if (html == "faild") {
				add_btn.style.display = "none";
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function() {
			// alert("error");
		return false;
	}
	});
}

/*******************************************************************************
 * 添加商品到wish list add hj 20110410
 */
function wish(goodsId) {
	var goods = new Object();
	var spec_arr = new Array();
	var formBuy = document.forms['ECS_FORMBUY'];
	// 检查是否有商品规格
	if (formBuy) {
		spec_arr = getSelectedAttributes(formBuy);
	}

	goods.spec = spec_arr;
	goods.goods_id = goodsId;

	Ajax.call('user.php?act=wish', 'goods=' + goods.toJSONString(),
			wishResponse, 'GET', 'JSON');

}

function weddingtowish(goodsId) {
	var goods = new Object();
	var spec_arr = new Array();
	var formBuy = document.forms['ECS_FORMBUY'];

	var customer_checkbox = 0;
	// 检查是否有商品规格
	if (formBuy) {
		spec_arr = getSelectedAttributes(formBuy);
	}

	if (formBuy.elements['customer_checkbox']) {
		// 存在
		customer_checkbox = formBuy.elements['customer_checkbox'].value;
		if (customer_checkbox == 1 || customer_checkbox == 0) {
			goods.customer_checkbox = customer_checkbox;
			// var reNumber = /^\d+(\d|(\.[1-9]{}))$/;
			// var reNumber =/^\d+(\.\d+)?$/;
			// 2010-10-23 add xg
			if (formBuy.elements['Bust']) {
				var bust = formBuy.elements['Bust'].value;
				goods.bust = bust;

			}
			if (formBuy.elements['Waist']) {
				var waist = formBuy.elements['Waist'].value;
				goods.waist = waist;

			}
			if (formBuy.elements['Hips']) {
				var hips = formBuy.elements['Hips'].value;
				goods.hips = hips;

			}
			if (formBuy.elements['Length']) {
				var clength = formBuy.elements['Length'].value;
				goods.clength = clength;

			}
			// 默认前4个 婚纱使用

			if (formBuy.elements['Shoulder']) {
				var shoulder = formBuy.elements['Shoulder'].value;
				goods.shoulder = shoulder;

			}
			if (formBuy.elements['Chest']) {
				var chest = formBuy.elements['Chest'].value;
				goods.chest = chest;

			}

			if (formBuy.elements['Sleeve']) {
				var sleeve = formBuy.elements['Sleeve'].value;
				goods.sleeve = sleeve;

			}
			if (formBuy.elements['Jacket_Length']) {
				var jlength = formBuy.elements['Jacket_Length'].value;
				goods.jlength = jlength;

			}
			if (formBuy.elements['Hip']) {
				var hip = formBuy.elements['Hip'].value;
				goods.hip = hip;

			}
			if (formBuy.elements['Pants_Length']) {
				var plength = formBuy.elements['Pants_Length'].value;
				goods.plength = plength;

			}

			// xg end

		}

	}

	goods.spec = spec_arr;
	goods.goods_id = goodsId;
	Ajax.call('user.php?act=wish', 'goods=' + goods.toJSONString(),
			wishResponse, 'GET', 'JSON');

}

/*******************************************************************************
 * 处理wish list商品的反馈信息 add hj 20110410
 */
function wishResponse(result) {
	alert(result.message);
}

function addToCart_ukraine2(goods_id) {
	var goods = new Object(); // 新增
	var reNumber = /^\d+(\.\d+)?$/;
	var number = $("#number").val();
	var spec_arr = new Array();
	var formBuy = document.forms['ECS_FORMBUY'];
	if (formBuy) {
		spec_arr = getSelectedAttributes(formBuy);

		if (formBuy.elements['number']) {
			number = formBuy.elements['number'].value;
		}
	}

	// 定义婚纱的参数
	var customer_checkbox = 0;
	var bust = '';
	var waist = '';
	var hips = '';
	var clength = '';

	// 判断婚纱的参数属性 如果有 则 有婚纱 否则
	if (formBuy.elements['customer_checkbox']) {
		// 存在
		customer_checkbox = formBuy.elements['customer_checkbox'].value;

		// return false;
		if (customer_checkbox == 1) {

			bust = formBuy.elements['bust'].value;
			if (reNumber.test(bust) == false) {
				alert("please input the bust");
				document.getElementById("bust").value = '';
				document.getElementById("bust").focus();
				return false;
			}

			waist = formBuy.elements['waist'].value;
			if (reNumber.test(waist) == false) {
				alert("please input the waist");
				document.getElementById("waist").value = '';
				document.getElementById("waist").focus();
				return false;
			}

			hips = formBuy.elements['hips'].value;
			if (reNumber.test(hips) == false) {
				alert("please input the hips");
				document.getElementById("hips").value = '';
				document.getElementById("hips").focus();
				return false;
			}

			clength = formBuy.elements['clength'].value;
			if (reNumber.test(clength) == false) {
				alert("please input the length");
				document.getElementById("clength").value = '';
				document.getElementById("clength").focus();
				return false;
			}

			goods.customer_checkbox = customer_checkbox;
			goods.bust = bust;
			goods.waist = waist;
			goods.hips = hips;
			goods.clength = clength;

		}

	}
	// 处理婚纱

	// 新增 处理商品数量
	if (reNumber.test(number) == false || number < 1) {
		alert("please input the Quantity!");
		document.getElementById("number").value = '';
		document.getElementById("number").focus();
		return false;
	}

	$
			.ajax( {
				type : "get",
				url : "../../function/goods_addtocart_ukraine.php",
				// data: "goods_id="+
				// goods_id+"&number="+number+"&spec_arr="+spec_arr,
				data : "goods_id=" + goods_id + "&number=" + number
						+ "&spec_arr=" + spec_arr + "&customer_checkbox="
						+ goods.customer_checkbox + "&bust=" + goods.bust
						+ "&waist=" + goods.waist + "&hips=" + goods.hips
						+ "&clength=" + goods.clength,
				cache : false,
				beforeSend : function(XMLHttpRequest) {
					// $("#registeradd_state").val("loading...");
			},
				success : function(html) {
					if (html == "outofstock") {
						alert("out of stock...");
					} else {

						$("#hezctitle")
								.html(
										"<li>The product has been added to your cart.</li>");
						$("#hezcsmall")
								.html(
										"<li>Thanks for your order, Now you can:</li><li><table align=\"center\"><tr><td><A href=\"Javascript::\"  style=\"cursor:pointer\" ><input type=\"button\" name=\"continue\" value=\"Continue Shopping\" onClick=\"javascript:closeDiv()\" ></A></td><td>&nbsp;</td><td><A href=\"../../flow.php\"><input type=\"button\" name=\"viewcart\" value=\"View Cart\"  onclick=\"gocart()\"></A></td></tr></table></li>");
						showDiv();

					}
				},
				complete : function(XMLHttpRequest, textStatus) {
					// $("#subbutton").val("Submit");
			},
			error : function() {
				// alert("error");
			}

			});

}

function addToCart_ukraine1(goods_id) {
	// var re = /[\r\n]+/mg; //替换换行符
	$
			.ajax( {
				type : "get",
				url : "../../function/goods_status_ukraine.php",
				data : "goods_id=" + goods_id,
				cache : false,
				beforeSend : function(XMLHttpRequest) {
					// alert("adad");

				// $("#registeradd_state").val("loading...");
			},
				success : function(html) {
					// html =html.replace(re, "");
					if (html == "outofstock\r\n") {

						alert("out of stock...");

					} else {

						$("#hezctitle")
								.html(
										"<li>Please select the goods attribute </li>");
						$("#hezcsmall").html(html);
						showDiv();

					}
				},
				complete : function(XMLHttpRequest, textStatus) {
					// $("#subbutton").val("Submit");
			},
			error : function() {
				// alert("error");
			}

			});

}

