function Prop(propFlowerObj, propEggObj, propFlowerFlashMap, propEggFlashMap, propCallback)
{
	//用户自定义函数
	this.callback;
	this.flowerObj;
	this.eggObj;
	this.flowerFlashMapX;
	this.flowerFlashMapY;
	this.eggFlashMapX;
	this.eggFlashMapY;
	this.init = function()
	{
		if (typeof(propCallback) == "function")
		{
			this.callback = propCallback;
		}		
		this.flowerObj = propFlowerObj;
		this.eggObj = propEggObj;
		this.flowerFlashMapX = propFlowerFlashMap[0];
		this.flowerFlashMapY = propFlowerFlashMap[1];
		this.eggFlashMapX = propEggFlashMap[0];
		this.eggFlashMapY = propEggFlashMap[1];	
	};
	
	this.eggFlashs = new Array(	"http://img2.wangyou.com/score/egg01.swf", 
								"http://img2.wangyou.com/score/egg02.swf",
								"http://img2.wangyou.com/score/egg03.swf",
								"http://img2.wangyou.com/score/egg04.swf"
								);
	this.flowerFlashs = new Array(	"http://img2.wangyou.com/score/flower01.swf",
								"http://img2.wangyou.com/score/flower02.swf",
								"http://img2.wangyou.com/score/flower03.swf",
								"http://img2.wangyou.com/score/flower04.swf"
								);
								
	this.getHost = function (url)
	{
		var host = "null";
		if(typeof url == "undefined" || null == url)
			url = window.location.href;
		return url;
	};
	
	this.showLoginForm = function (msg, obj)
	{
		if (!msg) msg = "砸人是要登录的哦！";
		QuickLoginForm.width = 216;
		QuickLoginForm.height = 106;
		QuickLoginForm.url = "/quick_login/index.php";
		QuickLoginForm.id = "prop-login-form";
		QuickLoginForm.msg = msg;
		if (obj) {
			QuickLoginForm.show(obj);
		} else {
			QuickLoginForm.show();
		}
	};
	
	this.giveLoginForm = function ()
	{
		QuickLoginForm.width = 216;
		QuickLoginForm.height = 106;
		QuickLoginForm.url = "/quick_login/index.php";
		QuickLoginForm.id = "prop-login-form";
		QuickLoginForm.msg = "送花是要登录的哦！";
		QuickLoginForm.show();
	};
	
	//取得最近送过花的银 
	//事件源, 道具名, 作品ID, 类型, 数目
	this.getLog = function (o, propName, sourceId, typeId, size)
	{
		var x = lib.x(o) + 16;
		var y = lib.y(o) + 18;
		QuickLoginForm.close("prop-login-form");
		var req = new Request(function()
					{
						if (req.xmlhttp.readyState == 4 && req.xmlhttp.status == 200)
						{
							var text = req.xmlhttp.responseText;
							if (text != "102") {
								var div = document.getElementById("propLogDiv");
								if (!div)
								{
									div = document.createElement("DIV");
									document.body.appendChild(div);
									div.id = "propLogDiv";
								}
								div.style.cssText = "position:absolute;left:" + x + "px;top:" + y + "px;width:100px;height:100px;color:white";
								div.innerHTML = text;
							} else {
								(new Prop).showLoginForm("请先登录！", o);
								return false;
							}
						}
					}
				);
		req.get("/action/score.php?p=log&propName=" + propName + "&sourceId=" + sourceId + "&typeId=" + typeId + "&size=" + size + "&s=" + Math.random());
		return false;
	};
	
	//关闭最近记录
	this.removeLog = function ()
	{
		var div = document.getElementById("propLogDiv");
		if (div)
		{
			document.body.removeChild(div);
		}
	};
	
	//设置可用的鸡蛋个数
	this.setEggNum = function (o)
	{
			var req = new Request(function()
			  {
			  		if (req.xmlhttp.readyState == 4 && req.xmlhttp.status == 200)
			  		{
			  			o.title = "您还有" + req.xmlhttp.responseText + "颗鸡蛋可以扔！";
			  		}
			  });
			req.get("/action/score.php?p=getEggNum");
	}
	
	
	//加载鲜花鸡蛋
	this.load = function (sourceId, typeId, pid)
	{
		var flowerObj = this.flowerObj;
		var eggObj = this.eggObj;
		var req = new Request(function()
		  {
		  		if (req.xmlhttp.readyState == 4 && req.xmlhttp.status == 200)
		  		{
		  			if (req.xmlhttp.responseText == 102)//没有登录
		  			{
		  				this.showLoginForm();
					}
					else
					{
						var s,always;
		  				always = req.xmlhttp.responseText;
		  				s = always.split(",");
		  				var eggs = s[0];
		  				var flowers = s[1];
		  				if (flowerObj)
		  				{
		  					flowerObj.innerHTML = flowers;
		  				}
		  				if (eggObj)
		  				{
		  					eggObj.innerHTML = eggs;
		  				}
					}
		  		}
		  });
		req.get("/action/score.php?p=Default&sourceId=" + sourceId + "&typeId=" + typeId + "&sourcePid=" + pid);
		return false;
	}
	
	//加载效果
	this.propFlashDiv;
	this.loadFlash = function (swf, flashX, flashY)
	{
		//加载扔鸡蛋页面 falsh
		var w = 450;
		var h = 360;
		var body = lib.getBody();
	
		propFlashDiv = document.createElement("DIV");
		document.body.appendChild(propFlashDiv);
		propFlashDiv.style.cssText = "position:absolute;left:" + flashX + "px;top:" + flashY + "px;width:" + w + "px;height:" + h + "px;z-index:1000;";
		propFlashDiv.innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+w+"\" height=\""+h+"\" style=\"z-index:1000;\"><param name=\"movie\" value=\""+swf+"\"/><param name=\"src\" value=\""+swf+"\"/><param name=\"quality\" value=\"high\"/><embed src=\"" + swf + "\"" + swf + " width=\"" + w + "\" height=\"" + h + "\" wmode=\"transparent\"></embed></object>";
		setTimeout("propFlashDiv.innerHTML='';document.body.removeChild(propFlashDiv);", 5000);
	}
	
	//砸鸡蛋
	//事件源, 作品ID, 类型, 作品PID
	this.egg = function (o, sourceId, typeId, sourcePid)
	{
		var prop = new Prop();
		var eggFlashs = this.eggFlashs;
		var eggFlashMapX = this.eggFlashMapX;
		var eggFlashMapY = this.eggFlashMapY;
		var eggObj = this.eggObj;
		var current_url = this.getHost();
		var callback = this.callback;
		if (cookie.get("wangyoulogin") == null || cookie.get("wangyoulogin") == "" || (cookie.get("wangyoulogin")).length != 32)
		{
			this.showLoginForm();
		}
		else
		{
			var req = new Request(function()
			  {
			  		if (req.xmlhttp.readyState == 4 && req.xmlhttp.status == 200)
			  		{
			  			if (req.xmlhttp.responseText == 102)//没有登陆
			  			{
			  				this.showLoginForm();
						}
						else if (req.xmlhttp.responseText == 101)//查询错误
			  			{
							alert("查询错误");
						}
			  			else if (req.xmlhttp.responseText == 100)//有没有鸡蛋
			  			{
			  				var t_url = "/action/buyEgg.php?typeId=" + typeId;
							window.open(t_url,"","height=400,width=400,top=100,left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no");
						}
				  		else if (req.xmlhttp.responseText == 201)
				  		{
				  			alert("送过花就别再扔鸡蛋了吧？！");
				  		}
				  		else if (req.xmlhttp.responseText == 202)
			  			{
			  				alert("都扔过了还扔啊,欺负人啊!明天再来吧!");
			  			}
			  			else if (req.xmlhttp.responseText == 301)
			  			{
			  				alert("客官,不要自己扔自己鸡蛋吧!");
			  			}
			  			else if (req.xmlhttp.responseText == 300)//扔完了
			  			{
			  				var number = Math.round(Math.random()*3);
			  				
			  				//加载效果
			  				prop.loadFlash(eggFlashs[number], eggFlashMapX, eggFlashMapY);
			  				prop.setNum(eggObj, 1);
			  				
			  				//调用回调函数
			  				if (typeof(callback) == "function")
			  				{
			  					callback(o, "egg", sourceId, typeId, sourcePid);
			  				}
			  			}
			  			else //鸡蛋的数目
			  			{
							alert(req.xmlhttp.responseText);
			  			}
			  		}
			  });
			req.get("/action/score.php?p=Egg&sourceId=" + sourceId + "&typeId=" + typeId + "&sourcePid=" + sourcePid);
			return false;
		}
	};
	
	//送鲜花啊
	this.flower = function (o, sourceId,typeId,sourcePid)
	{
	
		var prop = new Prop();
		var flowerFlashs = this.flowerFlashs;
		var flowerFlashMapX = this.flowerFlashMapX;
		var flowerFlashMapY = this.flowerFlashMapY;
		var flowerObj = this.flowerObj;
		var current_url = this.getHost();
		if ((cookie.get("wangyoulogin") == null)||(cookie.get("wangyoulogin") == "")||((cookie.get("wangyoulogin")).length != 32))
		{
			this.giveLoginForm();
		}
		else
		{
			var req = new Request(function()
			  {
			  		if (req.xmlhttp.readyState == 4 && req.xmlhttp.status == 200)
			  		{
			  			if (req.xmlhttp.responseText == 102)//没有登录
			  			{
							(new Prop).giveLoginForm();
						}
						else if (req.xmlhttp.responseText == 101)//查询错误
			  			{
							alert("查询错误");
						}
						else if (req.xmlhttp.responseText == 201)//送过花
			  			{
			  				alert("客官,今天送过花了,明天再来看偶吧!");
			  			}
			  			else if (req.xmlhttp.responseText == 202)//送过花
			  			{
			  				alert("扔过鸡蛋就别再送花了吧？！");
			  			}
			  			else if(req.xmlhttp.responseText == 301)
			  			{
			  				alert("客官,不要给自己送花吧！");
			  			}
			  			else if (req.xmlhttp.responseText == 300)//没有送过，送
			  			{
			  				var number = Math.round(Math.random()*2);
			  				
			  				//加载flsh效果
			  				prop.loadFlash(flowerFlashs[number], flowerFlashMapX, flowerFlashMapY);
			  				prop.setNum(flowerObj, 1);
			  				
			  				//调用回调函数
			  				if (typeof(callback) == "function")
			  				{
			  					callback(o, "flower", sourceId, typeId, sourcePid);
			  				}
			  			}
			  			else
			  			{
							alert(req.xmlhttp.responseText);
			  			}
			  		}
			  });
	
			 
			req.get("/action/score.php?p=Flower&sourceId=" + sourceId + "&typeId=" + typeId + "&sourcePid=" + sourcePid);
			return false;
		}
	};
	
	//将某个元素里的内容加1
	this.setNum = function (ids, num)
	{
		if (typeof(ids) == "string")
		{
			var _ids = ids.split(",");
			for (var i=0; i<_ids.length; i++)
			{
				var o = document.getElementById(_ids[i]);
				if (typeof(o) == "object")
				{
					var n = lib.intval(o.innerHTML) + 1;
					o.innerHTML = n;
				}
			}
		}
		if (typeof(ids) == "object")
		{
			var n = lib.intval(ids.innerHTML) + 1;
			ids.innerHTML = n;
		}
	}
	
	this.buy = function (buy_egg,flowers,typeId)
	{
		if(document.postform.buy_egg.value == "")
		{
			alert("请输入购买鸡蛋数目！");
			document.postform.buy_egg.focus();
			return false;
		}
	
		var x,y;
		x = flowers - (buy_egg*5);
		y = Math.floor(x/5);
		if((buy_egg*5) >flowers)
		{
			alert("鲜花数不够！");
			return false;
		}
		var req = new Request(function()
		  {
		  		if (req.xmlhttp.readyState == 4 && req.xmlhttp.status == 200)
		  		{
		  			if (req.xmlhttp.responseText == 102)//没有登陆
		  			{
		  				(new Prop).showLoginForm();
					}
					else if (req.xmlhttp.responseText == 501)
		  			{
						alert("鲜花数不够。");
		  			}
		  			else if (req.xmlhttp.responseText == 502)
		  			{
						alert("购买失败！");
		  			}
			  		else if (req.xmlhttp.responseText == 500)
			  		{
			  			alert("购买成功！");
		  				document.getElementById("flower_number").innerHTML = x;
		  				document.getElementById("egg_number").innerHTML = y;
		  				document.getElementById("buy_egg").value = "";
			  		}
		  			else
		  			{
	
		  			}
		  		}
		  });
		req.get("/action/score.php?p=Buy&buy_egg=" + buy_egg + "&flower=" + flowers + "&typeId=" + typeId);
		return false;
	}
}
