// JavaScript Document for products show
//评论分页，firefox不分
function ProReviews_Pagination(txtDivID,thisURL,thisURLpara,thisIsBegin)
{
	if(GetOS()=="Firefox")
	{
		document.getElementById(txtDivID).innerHTML = "";
		document.write("<script type=\"text/javascript\" src=\"/ajax/pro_rev_list_all.asp?"+thisURLpara+"\"></script>")
	}
	else
	{
		PaginationAjax(txtDivID,thisURL,thisURLpara,thisIsBegin)
	}
}




//订单
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)
{
//var strOrderExpand="";
	if (AddMethod=="Single")
	{
		var oSize=document.getElementById(id_e_in_size);
		var oColor=document.getElementById(id_e_in_color);
		var oQty=document.getElementById(id_e_in_qty);

		if ((IsOrderNeedSize(isNeedSize,id_e_in_size)==false)||(IsOrderNeedColor(isNeedColor,id_e_in_color)==false)||(IsOrderNeedQty(isNeedQty,id_e_in_qty)==false))
		{
			if (IsOrderNeedSize(isNeedSize,id_e_in_size)==false)
			{
				alert("Please select Size/Spec.");
				return false;
			}
			if (IsOrderNeedColor(isNeedColor,id_e_in_color)==false)
			{
				alert("Please select Color/Style.");
				return false;
			}
			if (IsOrderNeedQty(isNeedQty,id_e_in_qty)==false)
			{
				alert("Please input Quantity.");
				return false;
			}
			return false;
		}

		if ((oSize!="")&&(oSize!=null))
		{
			document.formOrderAdd.oSize.value=oSize.value;
		}
		if ((oColor!="")&&(oColor!=null))
		{
			document.formOrderAdd.oColor.value=oColor.value;
		}
		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";
	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, false);
	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.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
}




//计算单款产品金额小计(价格x数量)
function ProSignleSubTotal(thisInputID,thisInputValueOri,ProPrice,thisSpanID,PriceCurrency)
{
	var thisInputValue;
	var thisSubTotalValue;
	var txt_thisSpan="";
	thisInputValue=thisInputID.value;
	if ((ProPrice!="")&&(ProPrice!=null)&&(ProPrice!=0))
	{
		thisSubTotalValue=GetDecimal2Num(thisInputValue*ProPrice,2);
		txt_thisSpan = PriceCurrency + thisSubTotalValue;
		document.getElementById(thisSpanID).innerHTML = txt_thisSpan;
	}
	else if (thisInputValue==thisInputValueOri)
	{
		document.getElementById(thisSpanID).innerHTML = txt_thisSpan;
	}
}

//通过产品关键字取得关联产品，新系统中暂停使用
function ProRelatedProductsByKeywods(thisProID){
	CreateXMLHttp();
	var url = "../ajax/pro_correlative_by_kw.asp?thisProID=" + escape(thisProID);
//	xmlHttp.open("GET", url, true);
	xmlHttp.open("GET", url, false);
	xmlHttp.onreadystatechange = function(){HandleRequest("areaCorrelativeProducts")};
	xmlHttp.send(null);
}


