// JavaScript Document for products show
//评论分页，firefox不分；2011-8-10，不区分浏览器
function ProReviews_Pagination(txtDivID,thisURL,thisURLpara,thisIsBegin){
	PaginationAjax(txtDivID,thisURL,thisURLpara,thisIsBegin)
}

//V2011-10-03:History sold, Digg, Product Review，同时输出
function ProAttendantNum(ProID) {
	CreateXMLHttp();
	var url = "/ajax/pro_attendant_num.asp?ProID=" + escape(ProID) + "&rnd=" + Math.random();
//	xmlHttp.open("GET", url, true);
	xmlHttp.open("GET", url, false);
//	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
	var str_return = xmlHttp.responseText;
	str_return = str_return.Trim();
	s_oValue=str_return.split("|");
//		if (s_oValue[0]!="") { InnerHTML("num_pro_sold_"+ProID,s_oValue[0]); }
		InnerHTML("num_pro_sold_"+ProID,s_oValue[0]);
		InnerHTML("num_pro_digg_"+ProID,s_oValue[1]);
		InnerHTML("num_pro_review_"+ProID,s_oValue[2]);
		InnerHTML("pro_rate_"+ProID,s_oValue[3]);
}

//V2011-10-03: 提交Digg，需同步处理；同时输出Digg数量和提示
function ProDiggIt(rProID) {
	CreateXMLHttp();
	var url = "/ajax/pro_digg_it.asp?ProID=" + rProID + "&rnd=" + Math.random()
//	xmlHttp.open("GET", url, true);
	xmlHttp.open("GET", url, false);
//	xmlHttp.onreadystatechange = function(){HandleRequest(rShowDivID)};
	xmlHttp.send(null);
	var str_return = xmlHttp.responseText;
	str_return = str_return.Trim();
	s_oValue=str_return.split("|");
	switch(s_oValue[0]) {
		case "er02001" : InnerHTML("sv_pro_digg_"+rProID,"Product is null"); break;
		case "er00002" : InnerHTML("sv_pro_digg_"+rProID,"Your IP is error."); break;
		case "er02501" : InnerHTML("sv_pro_digg_"+rProID,"Please digg it once in 24 hours."); break;
		case "er02502" :
			InnerHTML("sv_pro_digg_"+rProID,"Thank you.");
			InnerHTML("num_pro_digg_"+rProID,s_oValue[1]);
			break;
//		default :
	}
}



//技术支持
function ProTechService(ProSerID,txtDivID){
	CreateXMLHttp();
	var url = "/ajax/pro_service.asp?id=" + escape(ProSerID);
//	xmlHttp.open("GET", url, false);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
}

function ProViewsNum(ProID,txtDivID) {
	CreateXMLHttp();
	var url = "/ajax/pro_rev_num.asp?ProID=" + escape(ProID);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
}


//出售数量、推荐次数(Digg)
function ProSoldDiggNum(rProID,rShowDivID,rShowType) {
	CreateXMLHttp();
	var url = "/ajax/pro_sold_num.asp?ProID=" + escape(rProID) + "&ShowType=" + escape(rShowType) + "&rnd=" + Math.random();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(rShowDivID)};
	xmlHttp.send(null);
}





//订单
function IsOrderNeedSize(isNeedSize,id_e_in)
{
	var oSize=document.getElementById(id_e_in);
	if (isNeedSize=="Y")
	{
		if ((oSize.value=="")||(oSize==null))
		{
			document.getElementById("alert_o_need_"+id_e_in).innerHTML = "Please select Size/Spec.";
			document.getElementById("id_pro_b_item_"+id_e_in).className="pro_b_item_e";
			return false;
		}
		else
		{
			document.getElementById("alert_o_need_"+id_e_in).innerHTML = "";
			document.getElementById("id_pro_b_item_"+id_e_in).className="pro_b_item";
		}
	}
}

function IsOrderNeedColor(isNeedColor,id_e_in)
{
	var oColor=document.getElementById(id_e_in);
	if (isNeedColor=="Y")
	{
		if ((oColor.value=="")||(oColor==null))
		{
			document.getElementById("alert_o_need_"+id_e_in).innerHTML = "Please select Color/Style.";
			document.getElementById("id_pro_b_item_"+id_e_in).className="pro_b_item_e";
			return false;
		}
		else
		{
			document.getElementById("alert_o_need_"+id_e_in).innerHTML = "";
			document.getElementById("id_pro_b_item_"+id_e_in).className="pro_b_item";
		}
	}
}

function IsOrderNeedQty(isNeedQty,id_e_in)
{
	var oQty=document.getElementById(id_e_in);
	if (isNeedQty=="Y")
	{
		if ((oQty.value=="")||(oQty==null)||(oQty.value=="0"))
		{
			document.getElementById("alert_o_need_"+id_e_in).innerHTML = "Please input Quantity.";
			document.getElementById("id_pro_b_item_"+id_e_in).className="pro_b_item_e";
			return false;
		}
		else
		{
			document.getElementById("alert_o_need_"+id_e_in).innerHTML = "";
			document.getElementById("id_pro_b_item_"+id_e_in).className="pro_b_item";
		}
	}
}


function ShoppingCartAdd(ProID,AddMethod,isNeedSize,id_e_in_size,isNeedColor,id_e_in_color,isNeedQty,id_e_in_qty){
	
	
	if (isNeedSize=="Y"){
		var oSize=document.getElementById(id_e_in_size);
		if (IsOrderNeedSize(isNeedSize,id_e_in_size)==false){
			alert("Please select Size/Spec.");
			return false;
		}

		if ((oSize!="")&&(oSize!=null)){
			document.formOrderAdd.oSize.value=oSize.value;
		}
	}

	if (isNeedColor=="Y"){
		var oColor=document.getElementById(id_e_in_color);
		if (IsOrderNeedColor(isNeedColor,id_e_in_color)==false){
			alert("Please select Color/Style.");
			return false;
		}

		if ((oColor!="")&&(oColor!=null)){
			document.formOrderAdd.oColor.value=oColor.value;
		}
	}
	

	if (isNeedQty=="Y"){
		var oQty=document.getElementById(id_e_in_qty);
		if (IsOrderNeedQty(isNeedQty,id_e_in_qty)==false){
			alert("Please input Quantity.");
			return false;
		}
		if ((oQty!="")&&(oQty!=null)){
			document.formOrderAdd.oQty.value=oQty.value;
		}
		
	}
	
	

	document.formOrderAdd.ProID.value=ProID;
	document.formOrderAdd.AddMethod.value=AddMethod;
	document.formOrderAdd.Action.value="Add";
	if (AddMethod=="Single"){
		document.formOrderAdd.submit();
	}
	else if (AddMethod=="BuyItNow"){
		document.formOrderAdd.action="/app/order_express.asp";
		document.formOrderAdd.submit();
	}
	//window.location.href="/app/order.asp?ProID="+ProID+strOrderExpand+"&Action=Add"
}


function AddToFavorites(ProID,txtDivID)
{
	CreateXMLHttp();
	var url = "/ajax/add_to_favorites.asp?psid=" + escape(ProID);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
	
//	MyFavoritesRefresh("num_MyFavorites");
}
function MyFavoritesRefresh(txtDivID)
{
	CreateXMLHttp();
	var url = "/ajax/refresh_favorites.asp";
//	xmlHttp.open("GET", url, false);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
}

function MyFavoritesDelete(rProID){
if(confirm("Are your sure delete this product from Your Favorites?")){
	document.formMyFavoritesDelete.ProID.value=rProID;
	document.formMyFavoritesDelete.submit();
	}
}



//计算单款产品金额小计(价格x数量): 单币种；2010-11-25废止
function ProSignleSubTotal(thisInputID,thisInputValueOri,ProPrice,thisSpanID,CurrencySymbol)
{
	var thisInputValue;
	var thisSubTotalValue;
	var txt_thisSpan="";
	thisInputValue=thisInputID.value;
	if ((ProPrice!="")&&(ProPrice!=null)&&(ProPrice!=0))
	{
		var ProPrice=ProPrice.replace(",","");
		thisSubTotalValue=GetDecimal2Num(thisInputValue*ProPrice,2);
		txt_thisSpan = CurrencySymbol + thisSubTotalValue;
		document.getElementById(thisSpanID).innerHTML = txt_thisSpan;
	}
	else if (thisInputValue==thisInputValueOri)
	{
		document.getElementById(thisSpanID).innerHTML = txt_thisSpan;
	}
}

//计算单款产品金额小计(价格x数量): 多币种
function ProQtySubTotal(thisInputID,thisInputValueOri,ProPrice,thisSpanID)
{
	var thisInputValue;
	var thisSubTotalValue;
	var txt_thisSpan="";
	thisInputValue=thisInputID.value;
	if ((ProPrice!="")&&(ProPrice!=null)&&(ProPrice!=0))
	{
		if (thisInputValue!=thisInputValueOri)
		{
			var ProPrice=ProPrice.replace(",","");
			CreateXMLHttp();
			var url = "/ajax/curr_qty_subtotal.asp?ProPrice=" + escape(ProPrice) + "&Qty=" + escape(thisInputValue);
//			xmlHttp.open("GET", url, false);
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = function(){HandleRequest(thisSpanID)};
			xmlHttp.send(null);
		}
	}
}

