//翻页的跳转
function GoToTheUrl(TheSelect)
{
	window.open(TheSelect.value,"_self");
}

//限制内容图片大小
function resize(o) {
	if (o.width>680) {
	o.style.width='680px';
	o.style.height='auto';
	}
}

//发送Ajax请求
function SendAjax(PostUrl)
{
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var linkurl="";
	if(PostUrl.indexOf("?")!=-1)
	{linkurl=PostUrl+"&rad="+Math.random();}
	else
	{linkurl=PostUrl+"?rad="+Math.random();}
	http_request.open("GET",linkurl,false);
	http_request.send(null);
	var returntxt=unescape(http_request.responseText)
	return returntxt;
}

//顶部导航切换
function GlobalNavChange(TheType,obj)
{
	if(TheType==0)
	{obj.className="";}
	else
	{obj.className="onfocus";}
}

//顶部搜索2跳转
function CommTopSearch2GoTo()
{
	var thevalue=document.getElementById("globalsearchPpJx").value;
	if(thevalue!="0")
	{
		location.href="Product_Show.asp?ProductID="+thevalue;
	}
}

//顶部品牌--更多的切换
function morebrand(TheType)
{
	var listobj=document.getElementById("morebrandList");
	var titleobj=document.getElementById("morebrandTitle");
	if (TheType==1)
	{
		listobj.style.display="block";
		titleobj.style.backgroundImage="url(images/bgn11.jpg)";
		titleobj.style.backgroundPosition="0px 0px";
		titleobj.style.textIndent="5px";
	}
	else
	{
		listobj.style.display="none";
		titleobj.style.backgroundImage="url(images/bgn10.jpg)";
		titleobj.style.backgroundPosition="right 4px";
		titleobj.style.textIndent="0px";
	}
}

//首页公告与自提点切换
function QhIndex_BeGgZt(TheType)
{
	switch(TheType)
	{
		case 1:
			document.getElementById("Index_BeGgZtTitle_1").className="onfocus";
			document.getElementById("Index_BeGgZtTitle_2").className="";
			document.getElementById("Index_BeGgZt_1").style.display="block";
			document.getElementById("Index_BeGgZt_2").style.display="none";
			break;
		case 2:
			document.getElementById("Index_BeGgZtTitle_1").className="";
			document.getElementById("Index_BeGgZtTitle_2").className="onfocus";
			document.getElementById("Index_BeGgZt_1").style.display="none";
			document.getElementById("Index_BeGgZt_2").style.display="block";
			break;
		default:
			break;
	}
}

//显示动画
function ShowFlash(flashWIDTH,flashHEIGHT,flashURL)
{
	document.writeln ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" WIDTH='+flashWIDTH+' HEIGHT='+flashHEIGHT+'>'); 
	document.writeln ('<PARAM NAME=movie VALUE="'+flashURL+'&rad='+Math.random()+'">'); 
	document.writeln ('<PARAM NAME=wmode VALUE=transparent>'); 
	document.writeln ('<PARAM NAME=loop VALUE=true>'); 
	document.writeln ('<PARAM NAME=quality VALUE=high>'); 
	document.writeln ('<EMBED src="'+flashURL+'&rad='+Math.random()+'" loop=true wmode=transparent quality=high swLiveConnect=FALSE WIDTH='+flashWIDTH+' HEIGHT='+flashHEIGHT+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>'); 
	document.writeln ('</OBJECT>'); 
}

//首页滚动手机配件
function Index_Sjpj(TheNum)
{
	var TextReturn="";
	var TheUl=document.getElementById("Index_Sjpj_Title");
	for(var i=0;i<TheUl.childNodes.length;i++)
	{
		if(i+1==TheNum)
		{
			TheUl.childNodes[i].style.borderBottomColor="#F6F9FE";
			TheUl.childNodes[i].style.backgroundImage="url(images/bgn22.gif)";
			TheUl.childNodes[i].style.color="#FE3102";
			TheUl.childNodes[i].style.fontWeight="bold";
			document.getElementById("paihangdiv"+(i+1)).style.display="block";
		}
		else
		{
			TheUl.childNodes[i].style.borderBottomColor="#C9E7F2"
			TheUl.childNodes[i].style.backgroundImage="url()";
			TheUl.childNodes[i].style.color="#464845";
			TheUl.childNodes[i].style.fontWeight="normal";
			document.getElementById("paihangdiv"+(i+1)).style.display="none";
		}
	}
}

//改变透明度参数：图片对象，透明度：1-100的值
function setAlpha(imgObj,opacityValue)
{
	imgObj.filters.alpha.opacity=parseInt(opacityValue);
}

//显示价格提示层
function PriceTip(theobj,TheTypeValue)
{
	var TheDl=theobj.parentNode;
	for(var i=0;i<TheDl.childNodes.length;i++)
	{
		if (TheDl.childNodes[i].className=="Allprice")
		{
			if(TheTypeValue==1)
			{TheDl.childNodes[i].style.display="block";}
			else
			{TheDl.childNodes[i].style.display="none";}
		}
	}
}

//显示商品详细信息
function ProductTip(ProductID,ProductObj,e)
{
	var objDiv=document.getElementById("DdDiv");
	if(objDiv!=null)
	{return;}
	
	var TheDD=ProductObj.parentNode.parentNode;
	if(ProductObj.TextNode=="img")
	{
		TheDD.style.backgroundColor="#EBF3F8";
		ProductObj.filters.alpha.opacity=parseInt(70);
	}
	var Jj="内容读取中<br /><img src='images/reading.gif' />";
	var objDiv =document.createElement("div");
	objDiv.id="DdDiv";
	var x = document.documentElement.scrollLeft+document.body.scrollLeft+ e.clientX+10;
	var y = document.documentElement.scrollTop+document.body.scrollTop+ e.clientY+10;
	var width = document.documentElement.clientWidth;
	var height = document.documentElement.clientHeight;
	divwidth = objDiv.offsetWidth;
	divheight = objDiv.offsetHeight;
	if (divwidth+x>=width+document.documentElement.scrollLeft+document.body.scrollLeft){x=x-divwidth-20;}
	if (divheight+y>=height+document.documentElement.scrollTop+document.body.scrollTop){y=y-(divheight+y-(height+document.documentElement.scrollTop+document.body.scrollTop));}
	
	objDiv.style.position="absolute";
	objDiv.style.left=x+"px";
	objDiv.style.top=y+"px";
	objDiv.className="ProductFdDiv";
	objDiv.innerHTML=Jj;
	
	document.body.appendChild(objDiv);
	ProductObj.onmouseout=function(){
		if(objDiv!=null){
			if(ProductObj.TextNode=="img")
			{
				TheDD.style.backgroundColor="#fff";
				ProductObj.filters.alpha.opacity=parseInt(100);
			}
			document.body.removeChild(objDiv);
			window.onerror=function(){return true;}
			}
		}
	objDiv.innerHTML=SendAjax("Ajax.asp?Action=GetProductTip&ProductID="+ProductID);
}

//显示商品详细信息移动
function ProductMoveTip(e)
{
	var objDiv=document.getElementById("DdDiv");
	if(objDiv==null)
	{return;}
	var x = document.documentElement.scrollLeft+document.body.scrollLeft +e.clientX+10;
	var y = document.documentElement.scrollTop+document.body.scrollTop + e.clientY+10;
	var width = document.documentElement.clientWidth;
	var height = document.documentElement.clientHeight;
	divwidth = objDiv.offsetWidth;
	divheight = objDiv.offsetHeight;
	if (divwidth+x>=width+document.documentElement.scrollLeft+document.body.scrollLeft){x=x-divwidth-20;}
	if (divheight+y>=height+document.documentElement.scrollTop+document.body.scrollTop){y=y-(divheight+y-(height+document.documentElement.scrollTop+document.body.scrollTop));}
	objDiv.style.left=x+"px";
	objDiv.style.top=y+"px";
}

//首页推荐手机切换
function Index_Tjsj(TheNum)
{
	var TheUl=document.getElementById("Index_Tjsj_Title");
	for(var i=0;i<TheUl.childNodes.length;i++)
	{
		if(i+1==TheNum)
		{
			TheUl.childNodes[i].className="onfocus";
			document.getElementById("Index_Tjsj_List_"+(i+1)).style.display="block";
		}
		else
		{
			TheUl.childNodes[i].className="";
			document.getElementById("Index_Tjsj_List_"+(i+1)).style.display="none";
		}
	}
}

//首页下载专区切换
function Index_Xzzx(TheNum)
{
	var TheUl=document.getElementById("Index_Xzzx_Title");
	for(var i=0;i<TheUl.childNodes.length-1;i++)
	{
		if(i+1==TheNum)
		{
			TheUl.childNodes[i].className="onfocus";
			document.getElementById("Index_Xzzx_List_"+(i+1)).style.display="block";
		}
		else
		{
			TheUl.childNodes[i].className="";
			document.getElementById("Index_Xzzx_List_"+(i+1)).style.display="none";
		}
	}
}

//下载专区列表OVER
function FileDownLoadOver(theobj)
{
	theobj.style.backgroundImage="url(images/bgn57.jpg)";
	theobj.onmouseout=function(){
		if(theobj!=null){
			theobj.style.backgroundImage="url(images/bgn55.jpg)";
			}
		}
}

//顶部商品搜索
function ProductSearch()
{
	var thewheretext="";
	var TheLb=document.getElementById("globalsearchLb").value;
	var TheJg=document.getElementById("globalsearchPrice").value;
	var TheText=document.getElementById("globalsearchText").value;
	if(TheLb!="0")
	{
		thewheretext=thewheretext+"?Sort1="+TheLb;
	}
	if(TheJg!="0")
	{
		if (thewheretext=="")
		{
			thewheretext=thewheretext+"?Price="+TheJg;
		}
		else
		{
			thewheretext=thewheretext+"&Price="+TheJg;
		}
	}
	if(TheText!="请输入商品关键字")
	{
		if (thewheretext=="")
		{
			thewheretext=thewheretext+"?Text="+TheText;
		}
		else
		{
			thewheretext=thewheretext+"&Text="+TheText;
		}
	}
	location.href="ProductSearch.asp"+thewheretext;
}

//产品列表切换背景
function ProductListQhBg(theobj)
{
	if(document.getElementById("RightProductList"))
	{
		theobj.style.backgroundImage="url(images/bgn65.jpg)";	
		theobj.onmouseout=function(){
			theobj.style.backgroundImage="url(images/bgn64.jpg)";
		}
	}
}

//选机中心
function FilterPhone(TheName,TheValue)
{
	var TheWebAdress=location.href.toLowerCase();
	if(TheWebAdress.indexOf("filterproduct_list.asp")==-1)
	{
		location.href="filterproduct_list.asp?GoTo=Yes|"+TheName+"|"+TheValue
	}
	else
	{
		document.getElementById("FilterHid"+TheName).value=TheValue;
		ShowFilterPhone();
	}
}

//选机中心显示方式切换
function FilterXsfs(thevalue)
{
	document.getElementById("FilterHidShow").value=thevalue;
	document.getElementById("FilterHidPage").value=1;
	ShowFilterPhone();
}

//选机中心排序方式切换
function FilterPxfs(thevalue)
{
	document.getElementById("FilterHidPvfs").value=thevalue;
	document.getElementById("FilterHidPage").value=1;
	ShowFilterPhone();
}

//选机中心条件重置
function FilterCztj()
{
	document.getElementById("FilterHidPp").value=0;
	document.getElementById("FilterHidJg").value=0;
	document.getElementById("FilterHidCs1").value=0;
	document.getElementById("FilterHidCs2").value=0;
	document.getElementById("FilterHidCs3").value=0;
	document.getElementById("FilterHidCs4").value=0;
	document.getElementById("FilterHidCs5").value=0;
	document.getElementById("FilterHidCs6").value=0;
	document.getElementById("FilterHidCs7").value=0;
	document.getElementById("FilterHidCs8").value=0;
	document.getElementById("FilterHidCs9").value=0;
	document.getElementById("FilterHidCs10").value=0;
	document.getElementById("FilterHidPage").value=1;
	ShowFilterPhone();
}

//选机中心翻页
function FilterFanYe(thevalue)
{
	document.getElementById("FilterHidPage").value=thevalue;
	ShowFilterPhone();
}

//添加产品对比蓝
function AddCpdbl(TheTitle,TheID)
{
	var CompIDStr;
	var CompTitleStr;
	var CompIDArr;
	var CompTitleArr;
	if(getCookie("CompID")==null || getCookie("CompID")=="")
	{
		SetCookie("CompID",TheID);
		SetCookie("CompTitle",TheTitle);
	}
	else
	{
		CompIDStr=getCookie("CompID")
		CompTitleStr=getCookie("CompTitle")
		CompIDArr=CompIDStr.split("|+|-|");
		CompTitleArr=CompTitleStr.split("|+|-|");
		if(CompIDArr.length>=6)
		{alert("对不起，您只能选取六款产品进行比较！！！");}
		else
		{
			var IsYou=false;
			for(var i=0;i<CompIDArr.length;i++)
			{
				if(parseInt(TheID)==parseInt(CompIDArr[i]))
				{
					alert("（"+TheTitle+"）已经被选择了！！！");
					IsYou=true;
				}
			}
			if(!IsYou)
			{
				CompIDStr=CompIDStr+"|+|-|"+TheID;
				CompTitleStr=CompTitleStr+"|+|-|"+TheTitle;
				SetCookie("CompID",CompIDStr);
				SetCookie("CompTitle",CompTitleStr)
			}
		}
	}
	ShowCpdbl();
}

//删除一个对比蓝的产品
function DelOneCpdbl(TheXh)
{
	var CompIDStr=getCookie("CompID");
	var CompTitleStr=getCookie("CompTitle");
	var CompIDArr=CompIDStr.split("|+|-|");
	var CompTitleArr=CompTitleStr.split("|+|-|");
	var TempCompIDStr="";
	var TempCompTitleArr="";
	for(var i=0;i<CompIDArr.length;i++)
	{
		if(parseInt(TheXh)!=parseInt(i))
		{
			if(TempCompIDStr=="")
			{
				TempCompIDStr=CompIDArr[i];
				TempCompTitleArr=CompTitleArr[i];
			}
			else
			{
				TempCompIDStr=TempCompIDStr+"|+|-|"+CompIDArr[i];
				TempCompTitleArr=TempCompTitleArr+"|+|-|"+CompTitleArr[i];
			}
		}
	}
	if (TempCompIDStr=="")
	{
		DelAllCpdbl();
	}
	else
	{
		SetCookie("CompID",TempCompIDStr);
		SetCookie("CompTitle",TempCompTitleArr);
		ShowCpdbl();	
	}
}

//清空对比蓝
function DelAllCpdbl()
{
	delCookie("CompID");
	delCookie("CompTitle");
	document.getElementById("xScrollStickList").innerHTML="";
	xScrollStickCopyStr=document.getElementById("xScrollStickID").innerHTML;
	ShowCpdbl();
}

var xScrollStickCopyStr="";
//显示对比蓝
function ShowCpdbl()
{
	if (getCookie("CompID")==null||getCookie("CompID")=="")
	{
		document.getElementById("xScrollStickID").innerHTML="<img src='images/basket.gif' width='67' style='margin-left:20px;' id='xScrollStickPicID' height='79' />";
	}
	else
	{
		if(document.getElementById("xScrollStickPicID"))
		{
			document.getElementById("xScrollStickID").innerHTML=xScrollStickCopyStr;
		}
		var CompIDStr=getCookie("CompID");
		var CompTitleStr=getCookie("CompTitle");
		var CompIDArr=CompIDStr.split("|+|-|");
		var CompTitleArr=CompTitleStr.split("|+|-|");
		var ShowText="";
		for(var i=0;i<CompIDArr.length;i++)
		{
			if(i!=0)
			{ShowText=ShowText+"|";}
			ShowText=ShowText+"<span onclick='DelOneCpdbl("+i+")' >"+CompTitleArr[i]+"</span>"
		}
		document.getElementById("xScrollStickList").innerHTML=ShowText;
	}
	document.getElementById("xScrollStickID").style.display="block";
}

//隐藏对比蓝
function HideCpdbl()
{
	document.getElementById("xScrollStickID").style.display="none";
}

//显示对比页面
function ShowDbPage()
{
	var CompIDStr=getCookie("CompID");
	var CompIDArr=CompIDStr.split("|+|-|");
	if(CompIDArr.length>=2)
	{return true;}
	else
	{
		alert("请至少选择两个产品");
		return false;
	}
}

//cookie操作===================开始
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
//cookie操作===================结束

//产品详细内的小图片OVER
function OverProductXxPicList(TheObj,BigUrl)
{
	TheObj.style.borderWidth="2px";
	TheObj.style.borderColor="#FF8500";
	SetProductXxPicList(BigUrl);
	TheObj.onmouseout=function(){
			TheObj.style.borderWidth="1px";
			TheObj.style.borderColor="#ccc";
	}
}

//设置图片
function SetProductXxPicList(BigUrl)
{
	//原图
	document.getElementById("mpd").innerHTML='<img id="mp" onMouseMove="javascript:slidebp(event);" onMouseOut="javascript:closebp();" style="cursor:pointer;" src="'+BigUrl+'" border="1" width="230" height="280">';
	//大图
	document.getElementById("bpd2").innerHTML='<img id="bp" src="'+BigUrl+'" width="920" height="1120">';
	//鼠标图
	document.getElementById("vpd2").innerHTML='<img id="vp" onMouseMove="javascript:slidebp(event);" onMouseOut="javascript:closebp();" style="cursor:pointer;" src="'+BigUrl+'" width="230" height="280">';
}

//产品选择价格
function ProductShowXzjg(ProductID,PriceID,TheObj,TheColor,BigUrl,Kc)
{
	SetProductXxPicList(BigUrl);	
	var TheTb=document.getElementById("ProductXxOther_thetb");
	var TheTbody;
	var TheTr;
	var TheTd;
	for(var i=0;i<TheTb.childNodes.length;i++)
	{
		TheTbody=TheTb.childNodes[i];
		for(var s=0;s<TheTbody.childNodes.length;s++)
		{
			TheTr=TheTbody.childNodes[s]
			for(var j=0;j<TheTr.childNodes.length;j++)
			{
				TheTd=TheTr.childNodes[j];
				if(TheTd.className=="mrtd_1_2")
				{
					TheTd.className="mrtd_1_1";
				}
				if(TheTd.className=="mrtd_2_2" && TheTd.previousSibling!=TheObj)
				{
					TheTd.className="mrtd_2_1";
				}
				if(TheTd==TheObj)
				{
					TheTd.className="mrtd_1_2";
					TheTd.nextSibling.className="mrtd_2_2";
				}
			}
		}
	}
	document.getElementById("ProductShowYxz").innerHTML="“"+TheColor+"”";
	switch(Kc)
	{
		case "1":
			document.getElementById("ProductShowKczt").innerHTML="(现货 <img src='images/bgn66.gif' onmouseover='ProductShowKcztTip(this)' align='absmiddle' />)";
			document.getElementById("ProductShowKcztsm").innerHTML=TheColor;
			document.getElementById("TheBtnthebuy").innerHTML="<img src='images/buy_2009.gif' onclick=AddCart("+ProductID+","+PriceID+",'Show') alt='立即购买' />";
			document.getElementById("TheBtnthejj").innerHTML="<img src='images/price-tip-setting.gif' onclick=TxJiangPrice("+ProductID+","+PriceID+") alt='降价提醒' />";
			break;
		case "2":
			document.getElementById("ProductShowKczt").innerHTML="(预定 <img src='images/bgn66.gif' onmouseover='ProductShowKcztTip(this)' align='absmiddle' />)";
			document.getElementById("ProductShowKcztsm").innerHTML="<strong>预订：</strong>您选择的颜色需预订，当天下午5点前订<br >货，第二天下午到货。注：部分行货需二至三<br >天到货。";
			document.getElementById("TheBtnthebuy").innerHTML="<img src='images/buy_2009.gif' onclick=AddCart("+ProductID+","+PriceID+",'Show') alt='立即购买' />";
			document.getElementById("TheBtnthejj").innerHTML="<img src='images/price-tip-setting.gif' onclick=TxJiangPrice("+ProductID+","+PriceID+") alt='降价提醒' />";
			break;
		case "3":
			document.getElementById("ProductShowKczt").innerHTML="(缺货 <img src='images/bgn66.gif' onmouseover='ProductShowKcztTip(this)' />)";
			document.getElementById("ProductShowKcztsm").innerHTML="<strong>缺货：</strong>您选择的颜色目前缺货，到货时间无法<br>预测！";
			document.getElementById("TheBtnthebuy").innerHTML="<img src='images/buy_none.gif' alt='无法购买' />";
			document.getElementById("TheBtnthejj").innerHTML="<img src='images/btn_notice.gif' onclick=TxDaohuo("+ProductID+","+PriceID+") alt='到货通知' />";
			break;
		case "4":
			document.getElementById("ProductShowKczt").innerHTML="(已下市 <img src='images/bgn66.gif' onmouseover='ProductShowKcztTip(this)' />)";
			document.getElementById("ProductShowKcztsm").innerHTML="<strong>已下市：</strong>该商品已经下市，市面上已经没有全<br>新机器";
			document.getElementById("TheBtnthebuy").innerHTML="<img src='images/buy_none.gif' alt='无法购买' />";
			document.getElementById("TheBtnthejj").innerHTML="";
			break;
		default : 
			break;
	}
}

//显示库存说明
function ProductShowKcztTip(TheObj)
{
	document.getElementById("ProductShowKcztsm").style.display="block";
	TheObj.onmouseout=function(){
		document.getElementById("ProductShowKcztsm").style.display="none";
		}
}

//降价提醒
function TxJiangPrice(ProductID,PriceID)
{
	if(PriceID==0)
	{
		alert("请选择颜色");
		return false;
	}
	else
	{
		/*显示背景*/
		var objBgDiv =document.createElement("div");
		var objBgDiv_X,objBgDiv_Y;
		objBgDiv.id="BigCartBg";
		objBgDiv.innerHTML="&nbsp;";
		document.body.appendChild(objBgDiv);
		if(document.documentElement.scrollWidth>=document.body.scrollWidth)
		{objBgDiv_X=document.documentElement.scrollWidth;}
		else
		{objBgDiv_X=document.body.scrollWidth;}
		if(document.documentElement.scrollHeight>=document.body.scrollHeight)
		{objBgDiv_Y=document.documentElement.scrollHeight;}
		else
		{objBgDiv_Y=document.body.scrollHeight;}
		objBgDiv.style.width=objBgDiv_X+"px";
		objBgDiv.style.height=objBgDiv_Y+"px";
		/*显示降价提醒表单*/
		var objDiv =document.createElement("div");
		objDiv.id="DropPriceForm";
		objDiv.style.width="457px";
		objDiv.style.height="213px";
		objDiv.style.position="absolute";
		objDiv.style.top=(document.documentElement.scrollTop+document.body.scrollTop+150)+"px";
		objDiv.style.left="50%";
		objDiv.style.marginLeft="-228px";
		var PostUrl="DropPriceForm.asp?ProductID="+ProductID+"&PriceID="+PriceID;
		objDiv.innerHTML=SendAjax(PostUrl);
		document.body.appendChild(objDiv);
	}
}

//隐藏降价提醒
function HideTxJiangPrice()
{
	if(document.getElementById("BigCartBg"))
	{
		document.body.removeChild(document.getElementById("BigCartBg"));
		document.body.removeChild(document.getElementById("DropPriceForm"));
	}
}

//发送降价提醒
function SendTxJiangPrice(ProductID,PriceID)
{
	var IsSend=true;
	var TxJiangPrice_Jsjg = document.getElementById("TxJiangPrice_Jsjg");
	var TxJiangPrice_Dxtz = document.getElementById("TxJiangPrice_Dxtz");
	var TxJiangPrice_Yjtz = document.getElementById("TxJiangPrice_Yjtz")
	if(TxJiangPrice_Jsjg.value=="" && IsSend)
	{
		alert("请输入接受价格!!!");
		TxJiangPrice_Jsjg.focus();
		IsSend=false;
	}
	if(TxJiangPrice_Dxtz.value=="" && TxJiangPrice_Yjtz.value=="" && IsSend)
	{
		alert("请输入手机号码或者电子邮箱!!!");
		TxJiangPrice_Dxtz.focus();
		IsSend=false;
	}
	if(IsSend)
	{
		var PostUrl="Ajax.asp?Action=SendTxJiangPrice&ProductID="+ProductID+"&PriceID="+PriceID+"&Jsjg="+TxJiangPrice_Jsjg.value+"&Dxtz="+TxJiangPrice_Dxtz.value+"&Yjtz="+TxJiangPrice_Yjtz.value+"";
		var TextReture=SendAjax(PostUrl);
		if(TextReture=="Success")
		{
			HideTxJiangPrice();
			alert("设置提醒成功")
		}
		else
		{alert("设置提醒失败")}
	}
}

//到货通知
function TxDaohuo(ProductID,PriceID)
{
	
	if(PriceID==0)
	{
		alert("请选择颜色");
		return false;
	}
	else
	{
		/*显示背景*/
		var objBgDiv =document.createElement("div");
		var objBgDiv_X,objBgDiv_Y;
		objBgDiv.id="BigCartBg";
		objBgDiv.innerHTML="&nbsp;";
		document.body.appendChild(objBgDiv);
		if(document.documentElement.scrollWidth>=document.body.scrollWidth)
		{objBgDiv_X=document.documentElement.scrollWidth;}
		else
		{objBgDiv_X=document.body.scrollWidth;}
		if(document.documentElement.scrollHeight>=document.body.scrollHeight)
		{objBgDiv_Y=document.documentElement.scrollHeight;}
		else
		{objBgDiv_Y=document.body.scrollHeight;}
		objBgDiv.style.width=objBgDiv_X+"px";
		objBgDiv.style.height=objBgDiv_Y+"px";
		/*显示降价提醒表单*/
		var objDiv =document.createElement("div");
		objDiv.id="DhNoteForm";
		objDiv.style.width="457px";
		objDiv.style.height="190px";
		objDiv.style.position="absolute";
		objDiv.style.top=(document.documentElement.scrollTop+document.body.scrollTop+180)+"px";
		objDiv.style.left="50%";
		objDiv.style.marginLeft="-228px";
		var PostUrl="DhNoteForm.asp?ProductID="+ProductID+"&PriceID="+PriceID;
		objDiv.innerHTML=SendAjax(PostUrl);
		document.body.appendChild(objDiv);	
	}
}

//隐藏到货通知
function HideTxDaohuo()
{
	if(document.getElementById("BigCartBg"))
	{
		document.body.removeChild(document.getElementById("BigCartBg"));
		document.body.removeChild(document.getElementById("DhNoteForm"));
	}
}

//发送到货通知
function SendTxDaohuo(ProductID,PriceID)
{
	var IsSend=true;
	var TxDaohuo_Dxtz = document.getElementById("TxDaohuo_Dxtz");
	var TxDaohuo_Yjtz = document.getElementById("TxDaohuo_Yjtz");
	if(TxDaohuo_Dxtz.value=="" && TxDaohuo_Yjtz.value=="" && IsSend)
	{
		alert("请输入手机号码或者电子邮箱!!!");
		TxDaohuo_Dxtz.focus();
		IsSend=false;
	}
	if(IsSend)
	{
		var PostUrl="Ajax.asp?Action=SendTxDaohuo&ProductID="+ProductID+"&PriceID="+PriceID+"&Dxtz="+TxDaohuo_Dxtz.value+"&Yjtz="+TxDaohuo_Yjtz.value+"";
		var TextReture=SendAjax(PostUrl);
		if(TextReture=="Success")
		{
			HideTxDaohuo();
			alert("设置提醒成功")
		}
		else
		{alert("设置提醒失败")}
	}
}

//显示相关资源
function ShowProductXxLink_Xglj(TheObj)
{
	if(document.getElementById("ProductXxLink_Xglj"))
	{
		document.getElementById("ProductXxLink_Xglj").style.display="block";
		TheObj.onmouseout=function(){
			document.getElementById("ProductXxLink_Xglj").style.display="none";
			}
	}
}

var ProductPjcpQb="Zd";
var ProductPjcpText_0_1="";
var ProductPjcpText_0_2="";
var ProductPjcpText_1="";
var ProductPjcpText_2="";
var ProductPjcpText_3="";
var ProductPjcpText_4="";
var ProductPjcpText_5="";
var ProductPjcpText_6="";
var ProductPjcpText_7="";

//相关配件产品初始化
function ProductPjcpInit(ProductID,TypeValue)
{
	if(TypeValue=="Mr")
	{
		ProductPjcpText_0_1=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=0&Ocl=Zd");
		ProductPjcpText_0_2=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=0&Ocl=Zk");
		ProductPjcpText_1=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=1");
		ProductPjcpText_2=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=2");
		ProductPjcpText_3=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=3");
		ProductPjcpText_4=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=4");
		ProductPjcpText_5=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=5");
		ProductPjcpText_6=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=6");
		ProductPjcpText_7=SendAjax("Ajax.asp?Action=ProductXgPjcp&ProductID="+ProductID+"&Xh=7");
		if(ProductPjcpText_0_1.indexOf("NoData")==-1)
		{document.getElementById("ProductPjcpNr_0").innerHTML=ProductPjcpText_0_1;}
		else
		{document.getElementById("ProductPjcpNr_0").innerHTML=ProductPjcpText_0_2;}
		document.getElementById("ProductPjcpNr_1").innerHTML=ProductPjcpText_1;
		document.getElementById("ProductPjcpNr_2").innerHTML=ProductPjcpText_2;
		document.getElementById("ProductPjcpNr_3").innerHTML=ProductPjcpText_3;
		document.getElementById("ProductPjcpNr_4").innerHTML=ProductPjcpText_4;
		document.getElementById("ProductPjcpNr_5").innerHTML=ProductPjcpText_5;
		document.getElementById("ProductPjcpNr_6").innerHTML=ProductPjcpText_6;
		document.getElementById("ProductPjcpNr_7").innerHTML=ProductPjcpText_7;
	}
	else
	{
		if(ProductPjcpQb=="Zd")
		{document.getElementById("ProductPjcpNr_0").innerHTML=ProductPjcpText_0_2;ProductPjcpQb="Zk";}
		else
		{document.getElementById("ProductPjcpNr_0").innerHTML=ProductPjcpText_0_1;ProductPjcpQb="Zd";}
	}
	
}

//相关配件产品切换
function ProductPjcpList(TheObj)
{
	var TheUl=document.getElementById("ProductPjcpTopUl");
	var TheLi;
	for(var i=0;i<TheUl.childNodes.length;i++)
	{
		TheLi=TheUl.childNodes[i];
		if(TheLi==TheObj)
		{
			TheLi.className='onfocus';
			document.getElementById("ProductPjcpNr_"+i).style.display="block";	
		}
		else
		{
			TheLi.className='';
			document.getElementById("ProductPjcpNr_"+i).style.display="none";	
		}
	}
}

//产品详细信息初始化
function ProductXxxxInit(ProductID)
{
	document.getElementById("ProductXxxxNr_0").innerHTML=SendAjax("Ajax.asp?Action=GetProductXxxxNr&ProductID="+ProductID+"");
	document.getElementById("ProductXxxxNr_1").innerHTML=SendAjax("Ajax.asp?Action=GetProductXxxxCs&ProductID="+ProductID+"");
	document.getElementById("ProductXxxxNr_2").innerHTML=SendAjax("Ajax.asp?Action=GetProductXxxxZjtp&ProductID="+ProductID+"");
}

//产品详细信息切换
function ProductXxxxLi(TheObj)
{
	var TheUl=document.getElementById("ProductXxxxTopUL");
	var TheLi;
	for(var i=0;i<TheUl.childNodes.length;i++)
	{
		TheLi=TheUl.childNodes[i];
		if(TheLi==TheObj)
		{
			TheLi.className='onfocus';
			if(i!=3)
			{document.getElementById("ProductXxxxNr_"+i).style.display="block";}
		}
		else
		{
			TheLi.className='';
			if(TheUl.childNodes[3]!=TheObj && i!=3){document.getElementById("ProductXxxxNr_"+i).style.display="none";}
		}
	}
}

//产品咨询翻页
function ConsultativeFanYe(thevalue)
{
	document.getElementById("ConsultativeHidPage").value=thevalue;
	ShowConsultative();
}

//产品咨询投票
function ConsultativeTp(thetype,id,n)
{
	
	var PostUrl="Ajax.asp?Action=ConsultativeTp&TheID="+id+"&thetype="+thetype;
	var TextReturn=SendAjax(PostUrl);
	if(TextReturn!="ChongFu")
	{
		OptionList=TextReturn.split("|");
		document.getElementById("Consultative_PleasedAmount_"+n).innerHTML="<img src='images/dot09.gif'  valign='middle'> 已投票("+OptionList[0]+")";
		document.getElementById("Consultative_UPleasedAmount_"+n).innerHTML="<img src='images/dot10.gif' valign='middle'> 已投票("+OptionList[1]+")";
	}
}

//产品咨询搜索
function SearchConsultative()
{
	
	var SearchConsultativetxt=document.getElementById("SearchConsultativetxt").value;
	if(SearchConsultativetxt=="请输入您要查找的答案")
	{alert("请输入您要查找的答案");}
	else
	{
		document.getElementById("ConsultativeHidSearchStr").value=SearchConsultativetxt;
		document.getElementById("ConsultativeHidPage").value="1";
		ShowConsultative();
	}
}

//显示添加产品咨询浮动框
function ShowConsultativeFdDiv()
{
	var theobj=document.getElementById("ConsultativeFdDiv");
	theobj.style.display="block";
	theobj.style.top=document.documentElement.scrollTop+document.body.scrollTop+"px";
	theobj.style.left="50%";
	theobj.style.marginLeft="-250px";
}

//关闭添加产品咨询浮动块
function CloseConsultativeFdDiv()
{
	var theobj=document.getElementById("ConsultativeFdDiv");
	theobj.style.display="none";
}

//验证产品咨询提交
function YzConsultativeFdForm()
{
	var IsSubmit=true;
	var ConsultativeFdTxt=document.getElementById("ConsultativeFdTxt");
	var ConsultativeFdArea=document.getElementById("ConsultativeFdArea");
	var ConsultativeHidID=document.getElementById("ConsultativeHidID");
	
	if(ConsultativeFdTxt.value=="" && IsSubmit)
	{
		alert("请输入网名！！！");
		ConsultativeFdTxt.focus();
		IsSubmit=false;
	}
	if(ConsultativeFdTxt.value.length<2 && IsSubmit)
	{
		alert("网名长度不小于2！！！");
		ConsultativeFdTxt.focus();
		IsSubmit=false;
	}
	if(ConsultativeFdArea.value=="" && IsSubmit)
	{
		alert("请输入内容！！！");
		ConsultativeFdArea.focus();
		IsSubmit=false;
	}
	if(ConsultativeFdArea.value.length<2 && IsSubmit)
	{
		alert("内容长度不小于10！！！");
		ConsultativeFdArea.focus();
		IsSubmit=false;
	}
	if(IsSubmit)
	{
		var PostUrl="Ajax.asp?Action=AddConsultativeFdForm"
		PostUrl=PostUrl+"&ProductID="+ConsultativeHidID.value+"&ConsultativeFdTxt="+ConsultativeFdTxt.value+"&ConsultativeFdArea="+ConsultativeFdArea.value+"";
		var TextReturn=SendAjax(encodeURI(PostUrl));
		if (TextReturn=="Yes")
		{
			alert("您好你们的咨询我们已经收到，我们会尽快回复您的信息并显示，谢谢！！！")
			CloseConsultativeFdDiv();
		}
	}
}

//判读是否有选中的复选框（一个都没有选中返回False,有则返回用"-"分割的值的字符串）
function ifChecked(chkboxname)
{
    var AC = false;
    var myValue = "";
    var myCount = 0;
    for (var i = 0; i < document.getElementsByName(chkboxname).length; i++)
	{
        var e = document.getElementsByName(chkboxname)[i];
        if (e.checked) 
		{
			if (myValue=="")
			{myValue = e.value;}
			else
			{myValue = myValue + "-" + e.value;}
            myCount = myCount + 1;
        }
    }
    if (myCount != 0)
	{
        AC = true;
    }
    else 
	{
        AC = false;
    }
    if (!AC) 
	{
        return false;
    }
    else
	{
        return myValue;
    } 
}

//推荐机型切换
function Tjjx_Qh(j,theLiboj)
{
	var TheUl=document.getElementById("LeftTjjxUl");
	for(var i=0;i<TheUl.childNodes.length;i++)
	{
		TheUl.childNodes[i].className="";
		document.getElementById("LeftTjjxList_"+(i+1)).style.display='none';
	}
	theLiboj.className="onfocus";
	document.getElementById("LeftTjjxList_"+j).style.display='block';
}

//推荐机型显示详细
function TjjxOne_Qh(theLiobj,TheType)
{
	var TheUl=document.getElementById("LeftTjjxListUl_"+TheType);
	for(var i=0;i<TheUl.childNodes.length;i++)
	{
		TheUl.childNodes[i].className="";
	}
	theLiobj.className="onfocus";
}
