var check;
function setVariables() {
tablewidth=30;  // logo width, in pixels
tableheight=50;  // logo height, in pixels
if (navigator.appName == "Netscape") {
horz=".left";
vert=".top";
docStyle="document.";
styleDoc="";
innerW="window.innerWidth";
innerH="window.innerHeight";
offsetX="window.pageXOffset";
offsetY="window.pageYOffset";
}
else {
horz=".pixelLeft";
vert=".pixelTop";
docStyle="";
styleDoc=".style";
innerW="document.body.clientWidth";
innerH="document.body.clientHeight";
offsetX="document.body.scrollLeft";
offsetY="document.body.scrollTop";
   }
}
function checkLocation() {
if (check) {
objectXY="buything";
var availableX=eval(innerW);
var availableY=eval(innerH);
var currentX=eval(offsetX);
var currentY=eval(offsetY);
x=availableX-tablewidth+currentX;
//y=availableY-tableheight+currentY;
y=currentY;

evalMove();
}
setTimeout("checkLocation()",0);
}
function evalMove() {
//eval(docStyle + objectXY + styleDoc + horz + "=" + x);
eval(docStyle + objectXY + styleDoc + vert + "=" + y);
}


	self.onError=null;
	currentX = currentY = 0;  
	whichIt = null;           
	lastScrollX = 0; lastScrollY = 0;
	NS = (document.layers) ? 1 : 0;
	IE = (document.all) ? 1: 0;
	function heartBeat() {
		if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
	    if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
		if(diffY != lastScrollY) {
	                percent = .1 * (diffY - lastScrollY);
	                if(percent > 0) percent = Math.ceil(percent);
	                else percent = Math.floor(percent);
					if(IE) document.all.buything.style.pixelTop += percent;
					if(NS) document.buything.top += percent; 
	                lastScrollY = lastScrollY + percent;}
		if(diffX != lastScrollX) {
			percent = .1 * (diffX - lastScrollX);
			if(percent > 0) percent = Math.ceil(percent);
			else percent = Math.floor(percent);
			if(IE) document.all.buything.style.pixelLeft += percent;
			if(NS) document.buything.left += percent;
			lastScrollX = lastScrollX + percent;	}		}
	function checkFocus(x,y) { 
	        stalkerx = document.buything.pageX;
	        stalkery = document.buything.pageY;
	        stalkerwidth = document.buything.clip.width;
	        stalkerheight = document.buything.clip.height;
	        if( (x > stalkerx && x < (stalkerx+stalkerwidth)) && (y > stalkery && y < (stalkery+stalkerheight))) return true;
	        else return false;}
	function grabIt(e) {
	    check = false;
		if(IE) {
			whichIt = event.srcElement;
			while (whichIt.id.indexOf("buything") == -1) {
				whichIt = whichIt.parentElement;
				if (whichIt == null) { return true; } }
			whichIt.style.pixelLeft = whichIt.offsetLeft;
		    whichIt.style.pixelTop = whichIt.offsetTop;
			currentX = (event.clientX + document.body.scrollLeft);
	   		currentY = (event.clientY + document.body.scrollTop); 	
		} else { 
	        window.captureEvents(Event.MOUSEMOVE);
	        if(checkFocus (e.pageX,e.pageY)) { 
	                whichIt = document.buything;
	                StalkerTouchedX = e.pageX-document.buything.pageX;
	                StalkerTouchedY = e.pageY-document.buything.pageY;} }
	    return true;	}
	function moveIt(e) {
		if (whichIt == null) { return false; }
		if(IE) {
		    newX = (event.clientX + document.body.scrollLeft);
		    newY = (event.clientY + document.body.scrollTop);
		    distanceX = (newX - currentX);    distanceY = (newY - currentY);
		    currentX = newX;    currentY = newY;
		    whichIt.style.pixelLeft += distanceX;
		    whichIt.style.pixelTop += distanceY;
			if(whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
			if(whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
			if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
			if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
			event.returnValue = false;
		} else { 
			whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
	        if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
	        if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
	        if( (whichIt.left + whichIt.clip.width) >= (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
	        if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
	        return false;}
	    return false;	}
	function dropIt() {whichIt = null;
	    if(NS) window.releaseEvents (Event.MOUSEMOVE);
	    return true;	}
	if(NS) {window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
		window.onmousedown = grabIt;
	 	window.onmousemove = moveIt;
		window.onmouseup = dropIt;	}
	if(IE) {
		document.onmousedown = grabIt;
	 	document.onmousemove = moveIt;
		document.onmouseup = dropIt;	}
	//if(NS || IE) action = window.setInterval("heartBeat()",1);


document.write ('<div id="buything" style=\"position:absolute; left:500px; top:0px; width:517px; z-index:1000\;display:none"> ');
document.write ('  <table width=\"510\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">');
document.write ('    <form  name="buydiv" action="https://www.cncard.com/purchase/step2.asp" method="POST" onsubmit="return checkformvalue(this)" target="_blank">' );
document.write ('      <tr> ');
document.write ('        <td background=\"/purchase/images/buy_top.gif\" height=\"32\">　　　　　　　　<font color=\"#FFFFFF\">（请填写您希望购买的数量）</font></td>');
document.write ('      </tr>');
document.write ('      <tr> ');
document.write ('        <td background=\"/purchase/images/buy_bg.gif\">');
document.write ('          <table width=\"504\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">');
document.write ('            <tr>');
document.write ('              <td align=\"center\">');
document.write ('                <table width=\"480\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">');
document.write ('                  <tr> ');
document.write ('                    <td height=15 colspan=\"4\"></td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=\"30\" width=\"20%\" align=\"right\">　会员登录名：&nbsp;</td>');
document.write ('                    <td width=\"29%\"> ');
document.write ('                      <input name=\"memname\" type=\"text\" size=\"10\" class=\"txt_bg\" readonly>');
document.write ('                    </td>');
document.write ('                    <td width=\"18%\" align=\"right\">会员级别：&nbsp;</td>');
document.write ('                    <td width=\"33%\"> ');
document.write ('                      <input name=\"memlevel\" type=\"text\" size=\"10\" class=\"txt_bg\" readonly>');
document.write ('                    </td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=\"30\" width=\"20%\" align=\"right\">　商品的名称：&nbsp;</td>');
document.write ('                    <td colspan=\"3\"> ');
document.write ('                      <input type=\"text\" name=\"cdescription\" class=\"txt_bg\" size=\"40\" readonly>');
document.write ('                    </td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=\"30\" width=\"20%\" align=\"right\">　商品的面值：&nbsp;</td>');
document.write ('                    <td width=\"29%\"> ');
document.write ('                      <input name=\"faceprice\" type=\"text\" size=\"10\" class=\"txt_bg\" readonly>');
document.write ('                    </td>');
document.write ('                    <td width=\"18%\" align=\"right\">会员价格：&nbsp;</td>');
document.write ('                    <td width=\"33%\"> ');
document.write ('                      <input name=\"cprice\" type=\"text\" size=\"7\" class=\"txt_bg\" readonly>');
document.write ('                    </td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td width=\"20%\" height=\"30\" align=\"right\">　购买的数量：&nbsp;</td>');
document.write ('                    <td width=\"29%\"> ');
document.write ('                      <select name=\"quantity\"  onChange="countpricebuytype();">');
document.write ('                        <option selected> 1 </option>');
document.write ('                        <option> 2 </option>');
document.write ('                        <option> 3 </option>');
document.write ('                        <option> 4 </option>');
document.write ('                        <option> 5 </option>');
document.write ('                      </select>');
document.write ('                    </td>');
document.write ('                    <td width=\"18%\" align=\"right\">总 价 格：&nbsp;</td>');
document.write ('                    <td width=\"33%\"> ');
document.write ('                      <input name=\"totalprice\" type=\"text\" size=\"7\" class=\"txt_bg\" readonly>');
document.write ('                    </td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=15 colspan=\"4\"></td>');
document.write ('                  </tr>');
document.write ('                  <tr align=\"center\"> ');
document.write ('                    <td height=15 colspan=\"4\"> ');
document.write ('                      <input name="category" type="hidden" size="7" ><input type=\"submit\" name=\"Submit\" value=\"提交订单\" class=button>');
document.write ('                      <input type=\"button\" name=\"Submit2\" value=\"关闭本页\" class=button onClick="unshowthing();">');
document.write ('                    </td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=15 colspan=\"4\"></td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=1 colspan=\"4\" background=\"/images/cnc_line.gif\"></td>');
document.write ('                  </tr>');
document.write ('                  <tr> ');
document.write ('                    <td height=60 colspan=\"4\" style=line-height:22px>　　　您在以前购物时选择了使用会员信息快速生成订单，因此会看到这个页面，如果<br>');
document.write ('                      　您希望继续使用云网传统的购物流程请点击这里到<a href=\"http://www.cncard.com/members/\" target=\"_blank\"><font color=\"#FF0000\"><u>会员中心</u></font></a>修改，您的设置将在下次<br>');
document.write ('                      　购买时生效。</td>');
document.write ('                  </tr>');
document.write ('                </table>');
document.write ('              </td>');
document.write ('            </tr>');
document.write ('          </table>');
document.write ('        </td>');
document.write ('      </tr>');
document.write ('      <tr>');
document.write ('        <td><img src=\"/purchase/images/buy_footer.gif\" width=\"510\" height=\"13\"></td>');
document.write ('      </tr>');
document.write ('    </form>');
document.write ('  </table>');
document.write ('</div>');


buything.style.top= (screen.height-400)/2;
buything.style.left= (screen.width-510)/2;

