﻿//购物 1个
function CartAdd(pID,pN,pB)
{
	if(pB==1)
	{
		window.location.href="/User/UserCart.aspx?id="+pID+"&n="+pN;
	}
	else
	{
		FLogin.DivOpen();
		//window.location.href="/User/Login.aspx?URL="+document.URL;
	}
}

//购物 多个
function CartAdd_M(pName,pB)
{
	if(pB!=1)
	{
		FLogin.DivOpen();
		//window.location.href="/User/Login.aspx?URL="+document.URL;
		return;
	}
	
	var obj=document.getElementsByName(pName);
	var str="";
	for(var i=0;i<obj.length;i++)
	{
		if(obj[i].checked)
		{
			str+=obj[i].value+",";
		}
	}
	
	if(str.length==0)
	{
		alert("请先选择商品。");
		return;
	}
	else
	{
		str=str.substring(0,str.length-1);
	}
	
	window.location.href="/User/UserCart.aspx?str="+str;
}

//收藏
function CotAdd(pID,pB)
{
	if(pB==1)
	{
		window.location.href="/User/Collection.aspx?id="+pID;
	}
	else
	{
		FLogin.DivOpen();
		//window.location.href="/User/Login.aspx?URL="+document.URL;
	}
}

//单选按钮选中
function SetSelectText(pTxtID,pSelID)
{
	$('#'+pTxtID).attr('value',$("#"+pSelID).find('option:selected').text());
}

function PPT(pPrefix,pSelID,pMax,pNSelStyle,pNOthStyle,pCSelStyle)
{
	for(var i=1;i<=pMax;i++)
	{
		document.getElementById("ppt"+i).className=pNOthStyle;
		document.getElementById("ppt_"+i).className="hidden";
	}
	document.getElementById("ppt"+pSelID).className=pNSelStyle;
	document.getElementById("ppt_"+pSelID).className=pCSelStyle;
}

function ContinueShop()
{
	window.history.go(-1);
}

function addEvent(o,c,h)
{
	if(o.attachEvent)
	{
		o.attachEvent('on'+c,h);
	}
	else
	{
		o.addEventListener(c,h,false);
	}
}

function home_yan(pB)
{
	var obj=document.getElementById("Code");
	if(pB==1)
	{
		obj.focus();
		return;
	}
	
	var obj1=document.getElementById('imgCode');
	obj.value="";
	
	obj1.className="";
	obj1.src='/yan.ashx?a='+Math.random();
}

function FloatDiv(pMessage,pDivID,pIframeID,pIframeSrc,pIframeWidth,pIframeHeight,pTop)
{
	var fDivID=pDivID;
	var IframeID=pIframeID;
	var IframeSrc=pIframeSrc;
	var IframeWidth=pIframeWidth;
	var IframeHeight=pIframeHeight;
	var fTop=pTop;
	var IsLoadBody=false;
	var message=pMessage;
	
	var objDiv;
	
	//初始
	FloadHtml=function()
	{
		
		objDiv=document.createElement("div");
		objDiv.id=fDivID;
		objDiv.style.left=(window.screen.width-IframeWidth)/2+"px";
		objDiv.style.position="absolute";
		objDiv.style.zIndex = 2010;
		objDiv.style.display='none';
		objDiv.innerHTML=SCHTML();
		document.body.appendChild(objDiv);
	}
	
	SCHTML=function()
	{
		return "<div class='f_div_"+pDivID+"'><table width='100%'>"+
		"<tr><td>"+pMessage+"</td><td align='right'><a href='javascript:ThisClose()'><b>关闭</b></a></td></tr></table>"+
		"<div class='f_iframe_"+pDivID+"'><iframe id='"+IframeID+"' src='"+IframeSrc+"?a="+Math.random()+"' frameborder='0'  width='100%' height='"+IframeHeight+"' scrolling='auto'></iframe></div>";
	}
	
	ThisClose=function()
	{
		document.getElementById(fDivID).style.display='none';
	}
	
	this.DivOpen=function()
	{
		if(!IsLoadBody)
		{
			FloadHtml();
			IsLoadBody=true;
		}
		
		fTop=(document.documentElement.scrollTop+IframeHeight+50)+"px";
		objDiv.style.top=fTop;
		objDiv.style.display="";
		document.getElementById(IframeID).src=IframeSrc+"?url="+window.location.href+"&a="+Math.random();
	}
	
	this.DivClose=function()
	{
		document.getElementById(fDivID).style.display='none';
	}
}

var FLogin=new FloatDiv("请先登录","htmFLogin","htmIframe","/User/FLogin.aspx",500,150,0);