// JavaScript Document


var Rand = Math.random();
String.prototype.trima = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}


function cancel()
{
	$.unblockUI();
	//alert("fdf");
	
	}
	


	function calllogin(d)
{

											

		//$.blockUI({ message:"fdfd" }); 
 
        //setTimeout($.unblockUI, 2000); 
		
		
					  $.ajax({
					  type:"POST",
					  url:"../ticketing/login.asp",
					  data:"rnd="+Rand,
					   error: function(){
					  alert("文件错误");
					  return false;
					  },
					  success:function(html){
					  
					  switch (parseInt(html))
					  {
						  case 0:
						   var c="<span id=\"logintbl\"><table width=\"330\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" style=\"margin:5px\"><tr><td width=\"109\" height=\"25\" align=\"right\"><a href=\"http://passport.tickets.com.cn\"><img src=\"http://www.tickets.com.cn/newtickets/images/logingo.jpg\" border=\"0\"><\/a><\/td><\/tr><tr><td  align=\"left\"><img src=\"http://www.tickets.com.cn/newtickets/images/regu.gif\" align=\"absmidde\">&nbsp;<a href=\"http://passport.tickets.com.cn/reg.html\" target=\"_blank\" style=\"color:#ff6600\">请点这里快速注册<\/a><\/td><\/tr><\/table><\/span>";
						  $.blockUI({ message:c,
									css: { 
									top:  ($(window).height() - 80) /2 + 'px',  
									left: ($(window).width() - 350) /2 + 'px',  
									width: '350px'} 
									
                                    }); 
						 
						  $('.blockOverlay').attr('title','单击空白处关闭').click($.unblockUI); // setTimeout($.unblockUI, 2000); 
						  break;
						  case 1:
						  $.ajax({
						  type:"POST",
						  url:"../ticketing/getsche.asp",
						  data:"d="+d+"&rnd="+Rand,
						   error: function(){
						  alert("文件错误");
						  return false;
						  },
						  success:function(html){
							  ///////////////
							  
							  $.blockUI({ message:html,
									css: { 
									top:  ($(window).height() - 200) /2 + 'px',  
									left: ($(window).width() - 590) /2 + 'px',  
									width: '590px'} 
 }); 
							   $('.blockOverlay').attr('title','单击空白处关闭').click($.unblockUI); 
							  ///////////////

							  }
												
																	
						 });
						  break;
						  
						  
						  }

						  }
																
																
					 });
	
											
  
	
	}
	
	
function addbasekt(d)
{
	var vstr=$("#orderstr").val();
	var t=$("#pnum").val();

		
		/////////////
		//alert(vstr+"|"+t);
		
		
		 $.ajax({
						  type:"POST",
						  url:"addcart.asp",
						  data:"n="+t+"&str="+escape(vstr)+"&rnd="+Rand,
						  //data:"n="+t+"&rnd="+Rand,
						   error: function(){
						  alert("文件错误");
						  return false;
						  },
						  success:function(html){
							  ///////////////
							  
							//$("#btext").html("<font color=\"#ff0000\">本场次已添加到您的购票袋！<\/font>");
							//setTimeout(function(){cancel();},2000);
							
							var j=parseInt(html)
							switch (j)
							{
								case 0:
							
							$("#obox_msg").html("<font color=\"#ff0000\"><strong>您成功订购"+t+"了张票<\/strong><\/font>");
							break;
							case 1:
							$("#obox_msg").html("<font color=\"#ff0000\"><strong>您成功更新了本场票券数<\/strong><\/font>");
							break;
							}
							
						
							//  alert(html);
							  ///////////////

							  }
												
																	
						 });
		 
		// $("#orderstr").attr(vstr+"|"+t)
		$("#orderstr").attr("value","");
		$("#obox_btn").attr("disabled","disabled")
		/////////////
		
		
		

	
	
	
	
	}
	
	
	
function getmybasket(d)
{
		/////////////
$("#obox_btn").attr("disabled","")
		
		 $.ajax({
						  type:"POST",
						  url:"../ticketing/openbasket.asp",
						  data:"d="+d+"&rnd="+Rand,
						   error: function(){
						  alert("文件错误");
						  return false;
						  },
						  success:function(html){
							  ///////////////
							  
							 
							 var t=html.split("|")
							 
							 
								  switch (parseInt(t[0]))
								  {
								case 0:
								$("#obox_msg").html("<font color=\"#ff6600\">请输入您的订购数量:<\/font>");
								$("#obox_btn").attr("value","加入购票袋");
								$("#pnum").attr("value",1)
								  break;
								  case 1:
								$("#obox_msg").html("<font color=\"#0033FF\"><strong>该场次已在您的购票袋中:<\/strong><\/font>");
								$("#obox_btn").attr("value","修改票券数");
								$("#pnum").attr("value",t[1])
								
								  }

							  }
												
																	
						 });
		
		/////////////
	
	
	
	}
	
	
	
	////////////////////////
	var col_result=
{
	colshow:function(num,obj)
	{
		var o=document.getElementById("obox");
		o.style.display="block";
		document.getElementById("obox_msg").innerHTML="请输入您的订购数量";
		//document.getElementById("pnum").value="";
		var pos =new this.getXY(obj);
		var oxy=new this.divXY(o);
		var obtn=document.getElementById("obox_btn");
		var oLeft=oxy.width / 2;
		var oTop=oxy.height;
		//alert(parseInt(pos.left-oLeft) +"|"+ parseInt(pos.top-oTop))		
		var isIe = /msie/i.test(navigator.userAgent); 
		if(isIe)
		{
			o.style.left=parseInt(pos.left-oLeft)+20+"px";
			o.style.top=parseInt(pos.top-oTop)+"px";
		}
		else
		{
			o.style.left=parseInt(pos.left-oLeft)+20+"px";
			o.style.top=parseInt(pos.top-oTop)+"px";
		}
		obtn.onclick=function()
		{
			//alert(num);
			addbasekt(num);
			//$("#obox_msg").html("您的订购数量为："+"<font color='#FF3300'>"+$("#pnum").val()+"</font>");
		}
	},
	getXY:function(Obj)
	{
		for (var sumTop=0,sumLeft=0;Obj!=document.body;sumTop+=Obj.offsetTop,sumLeft+=Obj.offsetLeft, Obj=Obj.offsetParent);
		return {left:sumLeft,top:sumTop}
	},
	divXY:function(obj)
	{
		return{width:obj.offsetWidth, height:obj.offsetHeight}
	},
	closed:function()
	{
		document.getElementById("obox").style.display="none";
	}
}



function getoinfo(d)
{
	//$("#ostr").attr("value",d)
	
	getmybasket(d);
	var pd=$("#pd").text().replace(" 查看地图>> ","");
	var fn=$("#nn").text();
	var yd=$("#y_"+d).text();
	var pj=$("#p_"+d).text().replace("元","");
	if (pj=="VIP")
	{
	pj=pj.replace("VIP","2800")
	}
	
	var st=$("#s_"+d).text();
	$("#orderstr").attr("value",d+"|"+yd+"|"+pd+"|"+fn+"|"+pj+"|"+'2009-10-25');
	
	}