function Obsend()
{
if(document.getElementById("option1").value =="no")
{
alert("Please select options!");
document.getElementById("option1").focus();
}
else{
	
//if(document.getElementById("addthis").checked)
//{
//document.getElementById("addin").value=1;
//}else
//{
document.getElementById("addin").value=0;
//}

//if(document.getElementById("trail").checked)
//{
//document.getElementById("ProductNum").value=1;
//document.getElementById("trailin").value=1;
//}else
//{
document.getElementById("trailin").value=0;
//}
document.getElementById("BuyForm").submit();
}
}
function Buy_both()
{
	if(document.getElementById("option1").value =="no")
{
alert("Please select options!");
document.getElementById("option1").focus();
}	
else{	
if(document.getElementById("option2").value =="no")
{
alert("Please select options!");
document.getElementById("option2").focus();
}	
else{	
if(document.getElementById("option2").value !="")
{
document.getElementById("option").value=document.getElementById("option2").value;
}	
document.getElementById("addin").value=1;
document.getElementById("trailin").value=0;
document.getElementById("BuyForm").submit();
}
}
}
function Buy_try()
{
	if(document.getElementById("option1").value =="no")
{
alert("Please select options!");
document.getElementById("option1").focus();
}	
else{	
document.getElementById("addin").value=0;
document.getElementById("trailin").value=1;
document.getElementById("BuyForm").submit();
}
}
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*nDays);
 document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;domain=.pandabuy.com;expires="+expire.toGMTString();
}
function Get(namex){
  var cookieString = new String(document.cookie);
  var cookieHeader = namex + "=";
  var beginPosition = cookieString.indexOf(cookieHeader);
  if (beginPosition != -1){
    cookieString = cookieString.substring(beginPosition + cookieHeader.length);
    if (cookieString.indexOf(";")>-1){
	 cookieString = cookieString.substring(0, cookieString.indexOf(";"));
    }
    return unescape(cookieString);
  }
  return "";
}
function getElement(aID)
{
  return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}
function makeRequest(url){
  http_request=false;
  if(window.XMLHttpRequest){//Mozilla,Safari,...
     http_request=new XMLHttpRequest();
     if(http_request.overrideMimeType){
     http_request.overrideMimeType('text/xml');
   }
 }else if(window.ActiveXObject){//IE
   try{
   http_request=new ActiveXObject("Msxml2.XMLHTTP");
   }catch(e){
   try{
 		http_request=new ActiveXObject("Microsoft.XMLHTTP");
 	}catch(e){}
 	}
 }
 if(!http_request){
 	alert('Giving up:(Cannot create an XMLHTTP instance)');
 	return false;
 }
 return http_request;
}
function diggit(id)
{
	if (document.cookie)
	{
		var dugg = Get("newsdugg");
		if (dugg!="")
		{
			re = new RegExp("-" + id + "-", "ig");
			if (re.test(dugg))
			{
				re2 = new RegExp(id + "-", "ig");
				var c = dugg.replace(re2, "");
                SetCookie("newsdugg", c,1);
			}
			else
			{
                SetCookie("newsdugg", dugg + id + "-",1);
			}
		}
		else
		{
            SetCookie("newsdugg", "-" + id + "-",1);
		}
	}
    else
	{
		SetCookie("newsdugg", "-" + id + "-",1);
	}
	return true;
}
function flower(boardid,diggid,pid){
    var url = "/xhttp/index.asp?pid="+pid;
	var xhttp=makeRequest();
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
		{		
		           //从获取值中挑选
				   var str=xhttp.responseText;
				   var s = str.indexOf("#");
                   var len=str.length;
				   var endlen=s+1;
				   
				   getElement("span_"+diggid).innerHTML=str.substring(0,s); 
				   getElement("h_"+diggid).innerHTML='Digg'; 
				   diggit(diggid);
				   var n= Math.round(Math.random()*33);//33
	if(str.substring(endlen,len) == n){alert("Congratulations,you are winning,you can select a random gift from PandaBuy.com!");location="/Diaoyong/gift.asp?Num="+n;}
		}
	}
	xhttp.open("GET",url,true);
	xhttp.send(null);
}
function hc(boardid,diggid,pid){
getElement("span_"+diggid).innerHTML = '<img src="/images/top/loading.gif" width="24" height="24" />';
flower(boardid,diggid,pid);
}
function pass(nid){
document.getElementById(nid).style.display ="";
topass(nid,'pass');
}
function npass(nid){
document.getElementById(nid).style.display ="";
topass(nid,'npass');
}

function topass(nid,TT){
    var url = "/xhttp/pass.asp?nid="+nid+"&TT="+TT;
	var xhttp=makeRequest();
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
		{		
		           //从获取值中挑选
				   var strp=xhttp.responseText;
				   if(strp != ""){document.getElementById(nid).style.display ="none";}
				   if(strp == "1"){alert("Thanks for your votes!");}
				   if(strp == "0"){alert("I'm afraid you have voted!");}
		}
	}
	xhttp.open("GET",url,true);
	xhttp.send(null);
}

function Midd(){
    var url = "/xhttp/Code.asp";
	var xhttp=makeRequest();
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
		{		
		           //从获取值中挑选
				   var strp=xhttp.responseText;
				   if(strp != "")
				   {
					   var lx="?Mid="+strp;
					   document.getElementById("uck").value=lx;
				   }else{
					   var ln="?Type=PandaBuy.com";
					   document.getElementById("uck").value=ln;
				   }
		}
	}
	xhttp.open("GET",url,true);
	xhttp.send(null);
}
function Down(diggid,pid){
    var url = "/xhttp/Down.asp?pid="+pid;
	var xhttp=makeRequest();
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
		{		
		           //从获取值中挑选
				   var strp=xhttp.responseText;
				   if(strp != "")
				   {
				   getElement("span_"+diggid).innerHTML=strp; 
				   }else{
				   getElement("span_"+diggid).innerHTML="0"; 
				   }
		}
	}
	xhttp.open("GET",url,true);
	xhttp.send(null);
}
function Msent(Mid){
    var url = "/xhttp/Down.asp?Mid="+Mid;
	var xhttp=makeRequest();
	xhttp.open("GET",url,true);
	xhttp.send(null);
}
function findcard(uid){
    var url = "/xhttp/icard.asp?uid="+uid;
	var xhttp=makeRequest();
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
		{		
		           //从获取值中挑选
				   var strp=xhttp.responseText;
				   if(strp != "")
				   {
				   document.getElementById("iCard").value=strp; 
				   }else{
				   document.getElementById("iCard").value=""; 
				   }
		}
	}
	xhttp.open("GET",url,true);
	xhttp.send(null);
}
function   togo(t,prin){ 
  document.getElementById("Layer2").style.display="block";
  document.getElementById("mdiv").style.display="";   
  document.getElementById("mdiv").innerHTML=t;   
  document.getElementById(prin).onmouseout=function(){   
  document.getElementById("mdiv").style.display="none";   
  }   
  }
