// JavaScript Document
	function tryToReceive(tid){
  		$.ajax({
  			type:"POST",
  			url:"<?php echo $this->baseUrl;?>/task/receivetask",
  			data:"tid="+tid,
  			success:function(msg){
  				if(msg==1){
  					alert("哈哈，你太慢啦，任务已经被人接了。");
  				}else if(msg==2){
  					alert("恭喜，任务已经成功接手，请尽快处理。");
  					$("#receivespan"+tid).html("成功接手");
  				}else if(msg==0){
  					alert("很抱歉，发布方删除了此次任务。");
  				}
  			}
  		});
  	}
	
  //把任务标志成已支付状态，表示我已经完成网上购买商品并已经支付	
  function iHavePayIt(tid,gid){
  		$.ajax({
  			type:"POST",
  			url:"<?php echo $this->baseUrl;?>/task/paythetask",
  			data:"tid="+tid+"&goodsid="+gid,
  			success:function(msg){
  				if(msg==1){
  					alert("你确定已经在网店上购买并支付了该商品。");
  					location.reload();
  				}else if(msg==0){
  					alert("支付失败。");
  				}
  			}
  		});
  	}
  	
  	//确定了接手方已经购买了货物，我需要去发货。
  	function iHaveDispatch(tid,gid){
  		$.ajax({
  			type:"POST",
  			url:"<?php echo $this->baseUrl;?>/task/dispatchgoods",
  			data:"tid="+tid+"&goodsid="+gid,
  			success:function(msg){
  				if(msg==1){
  					alert("您已经确认过支付情况，并已经在店铺上发货。");
  					location.reload();
  				}else if(msg==0){
  					alert("发货失败。");
  				}
  			}
  		});
  	}
  	
  	//验货收货后给发布方店铺好评，当前去确认已经做了好评。
  	function iHaveComment(tid,gid){
  		$.ajax({
  			type:"POST",
  			url:"<?php echo $this->baseUrl;?>/task/comment",
  			data:"tid="+tid+"&goodsid="+gid,
  			success:function(msg){
  				if(msg==1){
  					alert("已经验货并给了店铺好评。");
  					location.reload();
  				}else if(msg==0){
  					alert("验货和好评失败。");
  				}
  			}
  		});
  	}
  	//验货收货后给发布方店铺好评，当前去确认已经做了好评。
  	function iHaveGotComment(tid,gid){
  		$.ajax({
  			type:"POST",
  			url:"<?php echo $this->baseUrl;?>/task/confirmcomment",
  			data:"tid="+tid+"&goodsid="+gid,
  			success:function(msg){
  				if(msg==1){
  				alert("好评通过，任务完成。");
  				location.reload();
  			}else if(msg==0){
  				alert("好评确实失败。");
  			}
  			}
  		});
  	}
  	
  	
   //延长任务时间
   function timelag(tid){
   	 $.ajax({
   	 	type:"post",
   	 	url:"<?php echo $this->baseUrl;?>/task/addtime",
  		data:"tid="+tid,
  		success:function(msg){
  				alert("加时成功。");
  				location.reload();
  			}
   	 });
   }
   
   //任务置顶
   function topTask(tid){
   	$.ajax({
   		type:"post",
   	 	url:"<?php echo $this->baseUrl;?>/task/settasktotop",
  		data:"tid="+tid,
  		success:function(msg){
  			if(msg==1){
  				alert("置顶成功。");
  			}
  			}
   	});
   }
   
  //删除任务
  function deleteTask(tid){
  	$.ajax({
  		type:"post",
   	 	url:"<?php echo $this->baseUrl;?>/task/delecttask",
  		data:"tid="+tid,
  		success:function(msg){
  			if(msg==1){
  				alert("删除成功。");
  				location.reload();
  			}
  			if(msg==0){
  				alert("任务已经被接手，无法删除。");
  			}
  			}
  	});
  }
  
  //接手后退出任务
  function forbacktask(tid){
  	  	$.ajax({
  		type:"post",
   	 	url:"<?php echo $this->baseUrl;?>/task/forbacktask",
  		data:"tid="+tid,
  		success:function(msg){
  			if(msg==1){
  				alert("任务退出成功。");
  				location.reload();
  			}
  			if(msg==0){
  				alert("任务退出失败，可能是因为任务中部分商品已经购买支付。");
  			}
  			}
  	});
  }
  
  function letReceiveDoTheTask(tid,passornot){
  		$.ajax({
  		type:"post",
   	 	url:"<?php echo $this->baseUrl;?>/task/letreceiverdothetask",
  		data:"tid="+tid+"&passornot="+passornot,
  		success:function(msg){
  			if(msg==1){
  				alert("审核通过");
  				location.reload();
  			}
  			if(msg==0){
  				alert("审核不通过，任务回到可被接手状态");
  			}
  			}
  	});
  }

	
	//弹窗
	var userAgent=navigator.userAgent.toLowerCase();
	var is_opera=userAgent.indexOf("opera")!=-1&&opera.version();
	var is_moz=(navigator.product=="Gecko")&&userAgent.substr(userAgent.indexOf("firefox")+8,3);
	var is_ie=(userAgent.indexOf("msie")!=-1&&!is_opera)&&userAgent.substr(userAgent.indexOf("msie")+5,3);
	var is_ie7=userAgent.indexOf("msie 7.0")!=-1;
	String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"")};
	function openPrdUrl(url,obj){
		if(is_ie){
			try{
				window.open(url);
			}catch(e){
				try{
					alert('对不起，可能你使用了遨游浏览器，弹出的网址无法打开，请再一次点击');
					obj.onclick = function(){
						window.open(url);
					}
				}catch(ex){ }
			}
		}else if(prompt('请你使用 Ctrl+C 复制到剪贴板', url)){
			alert("您已经成功复制了网址，请粘贴到浏览器的地址栏，然后打开");
		}
		return false;
	}
	
	
function copyToClipboard(txt) {
      if(window.clipboardData) {
              window.clipboardData.clearData();      
              window.clipboardData.setData("Text", txt);
			  alert("复制成功，请用Ctrl+V复制到浏览器地址栏打开！");
      } else if(navigator.userAgent.indexOf("Opera") != -1) {
           window.location = txt;
		   alert("复制成功，请用Ctrl+V复制到浏览器地址栏打开！");    
      } else if (window.netscape) {
           try {      
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");      
           } catch (e) {      
                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");      
           }
           var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);      
           if (!clip)      
                return;      
           var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);      
           if (!trans)      
                return;      
           trans.addDataFlavor('text/unicode');      
           var str = new Object();      
           var len = new Object();      
           var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);      
           var copytext = txt;      
           str.data = copytext;      
           trans.setTransferData("text/unicode",str,copytext.length*2);
           var clipid = Components.interfaces.nsIClipboard;      
           if (!clip) {     
                return false;
		   }
           clip.setData(trans,null,clipid.kGlobalClipboard);
		   alert("复制成功，请用Ctrl+V复制到浏览器地址栏打开！");
      } else {
		   alert("您的浏览器不支持剪切板操作，请手动复制！");
	  }
	  
}

function decimal(num,v)
{
    var vv = Math.pow(10,v);
    return Math.round(num*vv)/vv;
}
