-
Notifications
You must be signed in to change notification settings - Fork 17
/
JY.min.js
1 lines (1 loc) · 27.9 KB
/
JY.min.js
1
!function(t){function e(t){var e=Array.prototype.slice.call(arguments,1);return function(n){return t.apply(this,[n].concat(e))}}var n={},i=[],r=!!document.all,s=Array.prototype.slice,o=document,a=/ +/,c=/^[\s\xA0]+/,u=/[\s\xA0]+$/,h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/;splitRex=/(\.\w+)|(\[\w+=[\"\']\w+[\"\']\])/,attrRex=/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,n=n.prototype={byId:function(t,e){return("string"==typeof t?(e||document).getElementById(t):t)||null},getCtx:function(t,e){return this.byId(t,e).getContext||alert("您的浏览器不支持html5元素,请更换浏览器,推荐使用360极速或谷歌或ie9以上版本的浏览器内核."),this.byId(t,e).getContext("2d")||null},bind:function(t,e,i){return t=n.byId(t),n.event.add(t,e,i),n},unbind:function(t,e,i){return t=n.byId(t),n.event.remove(t,e,i),n},one:function(t,e,i){return t=n.byId(t),n.event.add(t,e,i,"one"),n},on:function(t,e,i,r){return"function"==typeof i?(r=i,n.event.add(t,e,r)):"string"==typeof e&&n.event.add(t,e,r,"delegate",i),n},off:function(t,e,i,r){var s="";return"function"==typeof i?r=i:"string"==typeof i&&(s="delegate"),n.event.remove(t,e,r,s,i),n},delegate:function(t,e,i,r){return n.event.add(t,i,r,"delegate",e),n},undelegate:function(t,e,i,r){return target=n.byId(t),n.event.remove(t,i,r),n},live:function(t,e,i){return n.event.add(document,e,i,"delegate",t),n},ready:function(e){return i.push(e),r?(n.unbind(document,"readystatechange",n.DOMContentLoaded),n.bind(document,"readystatechange",n.DOMContentLoaded)):n.bind(t,"DOMContentLoaded",n.DOMContentLoaded),n},_startReady:function(){for(var t=0,e=i.length;t<e;t++)setTimeout(i[t],25);return n},DOMContentLoaded:function(e){return r?"complete"!==document.readyState&&"interactive"!==document.readyState||(n.unbind(document,"readystatechange",n.DOMContentLoaded),n._startReady()):(n.unbind(t,"DOMContentLoaded",n.DOMContentLoaded),n._startReady()),n},parent:function(t){t=n.byId(t);var e=t.parentNode;return e&&11!==e.nodeType?e:null},child:function(t){t=n.byId(t);for(var e=t.firstChild,i=new l;e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},next:function(t){return this._brother(t,"nextSibling")},prev:function(t){return this._brother(t,"previousSibling")},first:function(t){return t=n.byId(t).firstChild,t&&1!=t.nodeType?this.next(t):t},last:function(t){return t=n.byId(t).lastChild,t&&1!=t.nodeType?this.prev(t):t},_brother:function(t,e){t=n.byId(t);do t=t[e];while(t&&1!=t.nodeType);return t},css:function(t,e,i){if(t=n.byId(t),"object"==typeof e){for(var r in e)this.css(t,r,e[r]);return this}return i?n._assign(t,e,i,"style"):n.curCss(t,e)},curCss:function(t,e){return o.defaultView?(this.curCss=function(t,e){return o.defaultView.getComputedStyle(t,null)[e]},this.curCss(t,e)):(this.curCss=function(t,e){return t.currentStyle?t.currentStyle[e]:t.style[e]},this.curCss(t,e))},attr:function(t,e,i){return t=n.byId(t),n._assign(t,e,i,"attribute")},_assign:function(t,e,i,r){if(!t)return this;if("string"==typeof e){if("undefined"==typeof i)return("style"===r?t[r][e]:t.getAttribute(e))||"";"style"===r?t[r][e]=i:t.setAttribute(e,i)}else for(var s in e)n._assign(t,s,e[s],r)},hide:function(t){return t=n.byId(t),n.css(t,"display","none"),this},show:function(t){return t=n.byId(t),n.css(t,"display","block"),this},extend:function(){var t=arguments[0]||{},e=arguments[1];if("function"==typeof t&&(t=t.prototype),"object"==typeof e){for(var n in e)t[n]=e[n];arguments.length>2&&arguments.callee.apply(this,[t].concat(s.call(arguments,2)))}return t},addClass:function(t,e){if(t=n.byId(t),!t)return this;if(t.addClass)t.addClass(e);else if(!n.hasClass(t,e)){var i=n.attr(t,"class");i=i?i+" "+e:e,n.attr(t,"class",i)}return t},hasClass:function(t,e){var t=n.byId(t);if(t.hasClass)return t.hasClass(e);var i=(n.attr(t,"class"),new RegExp("\\b"+e+"\\b"));return i.test(t.className)},byClass:function(t,e,i){if(o.getElementsByClassName)return i?Array.prototype.slice.call(o.getElementsByClassName(t)):l.prototype.init.call(null,o.getElementsByClassName(t));e=e?n.byId(e).childNodes:o.getElementsByTagName("*");for(var r=(new RegExp("\\b"+t+"\\b"),i?[]:new l),s=null,a=0,c=e.length;a<c;a++)s=e[a],n.hasClass(s,t)&&r.push(s);return r},removeClass:function(t,e){if(t=n.byId(t),!t)return this;for(var i=n.attr(t,"class").split(a),r=[],s=0;s<i.length;s++)i[s]!==e&&r.push(i[s]);return n.attr(t,"class",r.join(" ")),this},byTag:function(t,e,i){e=e||o;var r=e.getElementsByTagName(t);return r=n.makeArr(r)},hover:function(t,e,i){return n.bind(t,"mouseover",function(){e?e.call(t):null}).bind(t,"mouseout",function(){i?i.call(t):e.call(t)}),this},query:function(){return this.makeArr(this._query.apply(this,arguments))},_query:function(t,e,i){if(e=e||o,o.querySelectorAll)return e.querySelectorAll(t);i=i||[];var r=t.split(a),s=r.shift();if(s){var c=s.split(splitRex);s=c[0];var u=h.exec(s);u[1]?i=i.concat(n.byTag(s,e,1)):u[2]?i=i.concat(n.byClass(u[2],e,1)):u[3]&&(i=i.concat(n.byId(u[3],e)));for(var l=[],d=0,f=r.length;d<f;d++){l=[];for(var p=0,y=i.length;p<y;p++)l=l.concat(arguments.callee(r.join(" "),i[p]))}i=0==l.length?i:l}return i},filter:function(t,e){},makeArr:function(t){for(var e=new l,n=0,i=t.length;n<i;n++)e.push(t[n]);return e},ajax:function(t){var e=new d;return e.send(t)},get:function(){var t=arguments,e={};e.url=t[0],e.data=t[1]||{},e.success=t[2]||null,e.dataType=t[3]||"html",(new d).send(e)},post:function(){var t=arguments,e={};e.url=t[0],e.data=t[1]||{},e.success=t[2]||null,e.type="POST",e.dataType=t[3]||"html",(new d).send(e)},parseJson:function(t){return"string"==typeof t?new Function("return "+t)():t},method:function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);t&&t.apply(null,e)},param:function(t){if("string"==typeof t)return t;var e=[];for(var n in t)"object"==typeof t[n]?e.push(n+"="+this.param(t[n])):e.push(n+"="+t[n]);return e.join("&")},is:function(t,e){return!!e&&n.query.filter(e,t).length>0},each:function(t,e){for(var n=0,i=t.length;n<i&&(void 0===t[n]||e.call(t[n],t[n],n)!==!1);n++);return this},position:function(t){return t=n.byId(t),{x:t.getBoundingClientRect().left+o.documentElement.scrollLeft,y:t.getBoundingClientRect().top+o.documentElement.scrollTop}},offset:function(t){return t=n.byId(t),{x:t.getBoundingClientRect().left+o.documentElement.scrollLeft,y:t.getBoundingClientRect().top+o.documentElement.scrollTop}},toggleClass:function(t,e){return n.hasClass(t,e)?n.removeClass(t,e):n.addClass(t,e),this},trim:function(t){return null==t?"":t.toString().replace(c,"").replace(u,"")},_domInsert:function(t,e,n){var i=document.createElement("div"),r=document.createDocumentFragment();"string"==typeof e?i.innerHTML=e:i.appendChild(e);for(var s=i.firstChild;s;s=s.nextSibling)1!==s.nodeType&&3!==s.nodeType||s===i||r.appendChild(s);return n.call(t,r),t},convertDOM:function(t){if("string"==typeof t){var e=document.createElement("div");e.innerHTML=t;var i=n.child(e);return 1==i.length?i[0]:i}return t},append:function(t,e){return t=this.byId(t),this._domInsert(t,e,function(t){this.appendChild(t)})},remove:function(t){t=this.byId(t);var e=this.parent(t);e?e.removeChild(t):null},prepend:function(t,e){return t=this.byId(t),this._domInsert(t,e,function(t){this.insertBefore(t,this.firstChild)})},before:function(t,e){return t=this.byId(t),this._domInsert(t,e,function(e){this.parentNode.insertBefore(e,t)})},after:function(t,e){return t=this.byId(t),this._domInsert(t,e,function(e){this.parentNode.insertBefore(e,n.next(t))})},toText:function(t,e){if(t=this.byId(t),null==e){var n=document.createElement("div");return n.appendChild(document.createTextNode(t.innerHTML)),n.innerHTML}return t.appendChild(document.createTextNode(e)),t},text:function(t,e){if(t=this.byId(t),null==e){var n=document.createElement("div");return n.appendChild(document.createTextNode(t.innerHTML)),n.innerHTML}return t.innerHTML="",t.appendChild(document.createTextNode(e.toString())),t},html:function(t,e){return t=this.byId(t),null==e?t.innerHTML:(t.innerHTML="",t.innerHTML=e,t)},mouseDrag:function(t,e,i,r,s){function o(t){n.mouseDrag.event=t,n.mouseDrag.prevEvent=c,c=t}var a=null,c={};r=r||"mousedown",s=s||"mouseup",n.bind(t,r,function(i){o(i),n.bind(t,"mousemove",o),e.call(this,i),a=setInterval(n.proxyFunc(e,this),15)}).bind(t,s,function(e){clearInterval(a),n.unbind(t,"mousemove",o),delete n.mouseDrag.prevEvent,delete n.mouseDrag.event,c=null,i.call(this,e)})},proxyFunc:function(t,e){return function(){t.apply(e,Array.prototype.slice.call(arguments))}},resolve:function(t,i,r,s,o){var a=+new Date,c=i,u=o;for(n.resolve.time=n.resolve.time||null,n.resolve.isEnd=n.resolve.isEnd||!1;c<r&&+new Date-a<50;c++)if(!s||void 0!==s[c])if(s){if(t.call(s[c],s[c],c)===!1){clearTimeout(n.resolve.time),n.resolve.isEnd=!0;break}}else if(t(c)===!1){clearTimeout(n.resolve.time),n.resolve.isEnd=!0;break}if(clearTimeout(n.resolve.time),c<r&&!n.resolve.isEnd){var h=arguments.callee;n.resolve.time=setTimeout(e(h,t,c,r,s,o),50)}else"function"==typeof u?u.call(null):void 0},hits:function(t,e,n){n=n||0;var i=!1,r=!1,s=e.width-n,o=t.width-n,a=e.height-n,c=t.height-n;return i=t.x>e.x?t.x-e.x<s:!(t.x<e.x)||e.x-t.x<o,r=t.y>e.y?t.y-e.y<a:!(t.y<e.y)||e.y-t.y<c,i&&r},loadFile:function(t,e,i,r){var s=t.split(",");if("script"===e){var o=0;n.each(s,function(t,e){var r=document.createElement("script");n.append(document.body,r),void 0!==r.onreadystatechange?r.onreadystatechange=function(){"loaded"==r.readyState&&(o++,o==s.length&&(i?i.call(this):null))}:n.bind(r,"load",function(t){o++,o==s.length&&(i?i.call(this):null)}),r.src=t})}else if("image"===e){var o=0;n.each(s,function(t,e){var r=document.createElement("img"),a=document.createElement("div");n.css(a,{width:"0px",height:"0px",overflow:"hidden"}),n.append(a,r),n.append(document.body,a),void 0!==r.onreadystatechange?("complete"!=r.readyState&&"loaded"!=r.readyState||(o++,o==s.length&&i.call(this)),r.onreadystatechange=function(){"complete"!=r.readyState&&"loaded"!=r.readyState||(o++,o==s.length&&i.call(this))}):r.onload=function(t){o++,o==s.length&&i.call(this)},r.src=t})}else if("swf"===e&&swfobject){var o=0,a=document.createElement("div");n.attr(a,"id",r),n.css(a,{width:"0px",height:"0px",overflow:"hidden"}),n.append(document.body,a),swfobject.embedSWF(t,r,1,1,"10.0.0","expressInstall.swf",{},{},{},i)}},progressbar:function(t,e,i){var r=document.createElement("div");n.width(r,i),n.addClass(r,"progressbar");var s=document.createElement("div");n.width(s,t/e*i),n.addClass(s,"progress"),n.append(r,s);var o=document.createElement("div");return o.innerHTML=t+"/"+e,n.css(o,{position:"absolute",textAlign:"center",top:"0px",width:i+"px","text-align":"center"}),n.addClass(o,"percent"),n.append(r,o),n.outerHTML(r)},outerHTML:function(t){t=n.byId(t);var e=o.createElement("div");n.append(e,t);var i=e.innerHTML;return delete e,i}},n.each(["Height","Width"],function(){var t=this,e=this.toLowerCase();n[e]=function(i,r){if(i=n.byId(i),r)return r="string"==typeof r?r:r+"px",n.css(i,e,r),this;if(i==window)return"CSS1Compat"==document.compatMode&&document.documentElement["client"+t]||document.body["client"+t];if(i==document)return Math.max(document.documentElement["client"+t],document.body["scroll"+t],document.documentElement["scroll"+t],document.body["offset"+t],document.documentElement["offset"+t]);var s=0,a="height"==e?["Top","Bottom"]:["Left","Right"];return o.defaultView?s=parseFloat(n.curCss(i,e)):(s=i["offset"+t],n.each(a,function(){s-=parseFloat(n.css(i,"border"+this+"Width")),s-=parseFloat(n.css(i,"padding"+this))})),Math.round(s)}});var l=function(){};l.prototype=new Array,l.prototype.constructor=l,n.extend(l,{each:function(t){return n.each(this,t),this},_assign:function(t,e){this.each(function(){n[e](this,t)})},css:function(){return 2==arguments.length?(e(this._assign,"css").apply(this,arguments),this):void n.css(this[0],arguments[0])},attr:function(){e(this._assign,"attr").apply(this,arguments)},init:function(){for(var t=new l,e=arguments[0],n=null,i=0,r=e.length;i<r;i++)n=e[i],1===n.nodeType&&t.push(n);return t},concat:function(t){return l.prototype.init.call(null,Array.prototype.slice.call(this).concat(Array.prototype.slice.call(t)))},first:function(){return this[0]},last:function(){return this[this.length-1]},child:function(){var t=new l;return this.each(function(){n.child(this).each(function(){t.push(this)})}),t},eq:function(t){return this[t]},find:function(t){var e=new l;return this.each(function(){var i=n.query.find(t,this).set;Array.prototype.push.apply(e,i)}),e},filter:function(t){var e=n.query.filter(t,this);return n.makeArr(e)},parents:function(t){var e=new l,i=new l;return this.each(function(){for(var t=n.parent(this);t&&9!==t.nodeType;)e.push(t),t=n.parent(t)}),i=n.makeArr(n.unique(n.query.filter(t,e)))},closest:function(t){var e=new l;return this.each(function(){for(var i=n.parent(this);i&&9!==i.nodeType;){if(n.is([i],t)){e.push(i);break}i=n.parent(i)}}),n.unique(e)}}),n.each(["height","width","position"],function(){var t=this;l.prototype[t]=function(e){if(1==this.length)return e?(n[t](this[0],e),this):n[t](this[0]);var i=[];return this.each(function(){i.push(n[t](this,e))}),e?this:i}}),n.each(["bind","unbind","show","hide","addClass","toggleClass","removeClass","live","one","delegate"],function(){var t=this;return l.prototype[t]=function(){var e=Array.prototype.slice.call(arguments,0);return this.each(function(){n[t].apply(this,[this].concat(e))}),this},this}),n.cache={},n.CID=0,n.event={getData:function(e){var i;return i=e===t?"JY_win":e===document?"JY_doc":n.attr(e,"JY_data")},add:function(t,e,i,r,s){t.addEventListener?this.add=function(t,e,i,r,s){if(!t||3===t.nodeType||8===t.nodeType)return this;s=s||"";var o=this.getData(t);o||(o="JY_"+n.CID,n.attr(t,"JY_data",o),n.CID++);var a=!0;n.cache[o]&&n.cache[o][e+s]||(a=!1),i=this._proxy.apply(this,Array.prototype.slice.call(arguments,0)),a||(n.cache[o][e+s].handle=i,t.addEventListener(e,i,!1))}:this.add=function(t,e,n){return t?(n=this._proxy.apply(this,Array.prototype.slice.call(arguments,0)),void t.attachEvent("on"+e,n)):this},this.add.apply(this,Array.prototype.slice.call(arguments,0))},_proxy:function(t,e,i,r,s){var o=this.getData(t);s=s||"",n.cache[o]=n.cache[o]||{},n.cache[o][e+s]=n.cache[o][e+s]||[];var a=n.cache[o][e+s],c=this,u=i;return i=function(o){if(o.target=o.target||o.srcElement,o.stop=function(){o.preventDefault(),o.stopPropagation()},"delegate"===r){var a=new l;return"object"==typeof s?s.constructor===l?a=s:a.push(s):a=n.query(s,t),n.each(a,function(){o.target===this&&u.call(this,o)}),!1}u.call(t,o)||(o.preventDefault?o.preventDefault():null),"one"===r&&c.remove(t,e,i)},i.oldHandle=u,a.push(i),function(t){n.each(a,function(e){e.call(this,t)})}},remove:function(t,e,i,r,s){var o,a=this,c=this.getData(t);if(o=!!c&&(n.cache[c][e+s]||!1),i){var u=0;n.each(o,function(t,e){i==t.oldHandle?delete o[e]:u++}),0===u&&this.remove(t,e+s)}else o&&(n.each(o,function(t,e){delete o[e]}),n.cache[c][e+s]=null,a.deleteEvt(t,e,o.handle))},deleteEvt:function(t,e,n){t.removeEventListener?this.deleteEvt=function(t,e,n){t.removeEventListener(e,n,!1)}:this.deleteEvt=function(t,e,n){t.detachEvent("on"+e,n)}}},n.draw={cache:{},setStyle:function(t){this.cache=t},setPosition:function(t,e,i){n.css(t,{left:e+"px",top:i+"px"})},point:function(t,e,i){var r=document.createElement("i");return n.css(r,this.cache),n.append(t,r),this.setPosition(r,e,i),r.x=e,r.y=i,r.width=parseInt(this.cache.width),r.height=parseInt(this.cache.height),r},line:function(t,e,i,r){var s=e.x-t.x,o=e.y-t.y,a=parseInt(this.cache.width),c=parseInt(Math.sqrt(s*s+o*o))/a,u=Math.atan2(s,o);n.resolve(function(){var e=t.x+Math.sin(u)*a,s=t.y+Math.cos(u)*a;n.draw.point(i,e,s),t.x=e,t.y=s,r?r({x:e,y:s}):null},1,c)}},t.JY=n,t.List=l;var d=function(){};d.prototype={create:function(){var t,e=["MSXML2.XMLHTTP.6.0","MSXML3.XMLHTTP","Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0"];try{t=new XMLHttpRequest}catch(r){for(var n=0,i=e.length;n<i;n++)try{t=new ActiveXObject(e[n]);break}catch(t){}}finally{return t}},send:function(t){var e=this,i=e.create();if(dataType=t.dataType||"html",t.contentType=t.contentType||"application/x-www-form-urlencoded",void 0==t.async&&(t.async=!0),t.async&&(i.onreadystatechange=function(){4==i.readyState&&n.method(t.success,e.format(i.responseText,i.responseXML,t.dataType))}),"GET"!=t.type&&t.type){i.open("POST",t.url,t.async),i.setRequestHeader("Content-Type",t.contentType);try{i.send(n.param(t.data))}catch(e){n.method(t.error,e)}}else{var r=t.url.split("?");r[1]?t.url+="&"+n.param(t.data):t.url=r[0]+"?"+n.param(t.data),i.open("GET",t.url,t.async),i.send(null)}return t.async||n.method(t.success,e.format(i.responseText,i.responseXML,t.dataType)),i},format:function(t,e,i){switch(i){case"xml":return e;case"json":return n.parseJson(t);case"html":default:return t}}}}(window),function(){function t(t,e,n){this.style=n||{},t=t||0,e=e||0,this.width=t,this.height=e,this.x=0,this.y=0,this.data=null,this.init=function(t,e,n){JY.extend(this.style,n||{}),this.DOM=document.createElement("i"),this.width=t||this.width,this.height=e||this.height,JY.extend(this.style,{position:"absolute",overflow:"hidden",width:this.width+"px",height:this.height+"px"}),JY.css(this.DOM,this.style)},this.init(),this.remove=function(){JY.remove(this.DOM)},this.addChild=function(t){JY.append(this.DOM,t.DOM)},this.setPosition=function(t,e){return this.x=null==t?this.x:t,this.y=null==e?this.y:e,JY.css(this.DOM,{left:this.x+"px",top:this.y+"px"}),this},this.setStyle=function(t){return JY.css(this.DOM,t),this}}var e={STATE_SYSTEM_WAIT_FOR_CLOSE:0,STATE_SYSTEM_TITLE:1,STATE_SYSTEM_INSTRUCTIONS:2,STATE_SYSTEM_NEW_GAME:3,STATE_SYSTEM_GAME_OVER:4,STATE_SYSTEM_NEW_LEVEL:5,STATE_SYSTEM_LEVEL_IN:6,STATE_SYSTEM_GAME_PLAY:7,STATE_SYSTEM_LEVEL_OUT:8,STATE_SYSTEM_WAIT:9},n=function(t){this.timer=null,this.func=new Function,this.stage=t,t&&(this.stage.width=JY.width(t),this.stage.height=JY.height(t)),this.lastState=null,this.currentState=null,this.nextState=null,this.game=new i,this.waitCount=0,this.waitTime=30,this.titleScreen=null,this.InstructionsScreen=null,this.scoreScreen=null,this.gameOverScreen=null,this.frequency=100},i=function(){};i.prototype={gameOver:function(t){t.checkState(e.STATE_SYSTEM_GAME_OVER)},newGame:function(t){t.checkState(e.STATE_SYSTEM_NEW_LEVEL)},newLevel:function(){}},n.prototype={init:function(){this.checkState(e.STATE_SYSTEM_TITLE)},setStage:function(t){this.stage=t,this.stage.width=JY.width(t),this.stage.height=JY.height(t)},startTimer:function(){var t=this;t.timer||(t.timer=setInterval(JY.proxyFunc(t.runGame,t),t.frequency))},runGame:function(){this.func()},checkState:function(t){switch(this.lastState=this.currentState,this.currentState=t,t){case e.STATE_SYSTEM_WAIT_FOR_CLOSE:this.func=this.waitClose;break;case e.STATE_SYSTEM_TITLE:this.func=this.setTitle;break;case e.STATE_SYSTEM_INSTRUCTIONS:this.func=this.setInstructions;break;case e.STATE_SYSTEM_NEW_GAME:this.func=this.systemNewGame;break;case e.STATE_SYSTEM_GAME_OVER:this.func=this.gameOver;break;case e.STATE_SYSTEM_NEW_LEVEL:this.func=this.newLevel;break;case e.STATE_SYSTEM_LEVEL_IN:this.func=this.levelIn;break;case e.STATE_SYSTEM_GAME_PLAY:this.func=this.gamePlay;break;case e.STATE_SYSTEM_LEVEL_OUT:this.func=this.levelOut;break;case e.STATE_SYSTEM_WAIT:this.func=this.wait}},setTitle:function(){this.addChild(this.titleScreen),this.checkState(e.STATE_SYSTEM_WAIT),this.nextState=e.STATE_SYSTEM_INSTRUCTIONS},setInstructions:function(){this.addChild(this.InstructionsScreen),JY.touch(this.InstructionsScreen,JY.proxyFunc(this.okButtonClickListener,this)),this.nextState=e.STATE_SYSTEM_NEW_GAME,this.stopTimer()},systemNewGame:function(){this.game.newGame(),this.addChild(this.scoreScreen),this.checkState(e.STATE_SYSTEM_NEW_LEVEL)},gameOver:function(){this.clearState(),this.addChild(this.gameOverScreen),JY.touch(this.gameOverScreen,JY.proxyFunc(this.okButtonClickListener,this)),this.nextState=e.STATE_SYSTEM_TITLE,this.stopTimer()},newLevel:function(){this.game.newLevel(),this.checkState(e.STATE_SYSTEM_LEVEL_IN)},gamePlay:function(){this.game.runGame()},wait:function(){this.waitCount++,this.waitCount>this.waitTime&&this.checkState(e.STATE_SYSTEM_WAIT_FOR_CLOSE)},waitClose:function(){this.okButtonClickListener(),waitCount=0},levelIn:function(){waitTime=10,this.checkState(e.STATE_SYSTEM_WAIT),this.nextState=e.STATE_SYSTEM_GAME_PLAY},clearState:function(){var t=this,e=JY.child(t.stage);JY.each(e,function(){t.removeChild(this)}),this.stopTimer()},okButtonClickListener:function(t){switch(this.nextState){case e.STATE_SYSTEM_TITLE:this.removeChild(this.gameOverScreen),this.startTimer();break;case e.STATE_SYSTEM_INSTRUCTIONS:this.removeChild(this.titleScreen);break;case e.STATE_SYSTEM_NEW_GAME:this.removeChild(this.InstructionsScreen),this.startTimer()}this.checkState(this.nextState)},removeChild:function(e){e.constructor==t?JY.remove(e.DOM):JY.remove(e)},addChild:function(e){return e.constructor==t?JY.append(this.stage,e.DOM):JY.append(this.stage,e),this},stopTimer:function(){clearInterval(this.timer),this.timer=null}},window.JYG=n,window.JYGSTATE=e,window.Game=i,window.Sprite=t,Function.prototype.method=function(t,e){if("object"==typeof t)for(var n in t)this.prototype[n]=t[n];else this.prototype[t]=e;return this},Function.method("inherits",function(t){var e={},n=this.prototype=new t;return this.method("uber",function(i){i in e||(e[i]=0);var r,s,o=e[i],a=t.prototype;if(o){for(;o;)a=a.constructor.prototype,o-=1;r=a[i]}else r=n[i],r==this[i]&&(r=a[i]);return e[i]+=1,s=r.apply(this,Array.prototype.slice.apply(arguments,[1])),e[i]-=1,s}),this})}(),function(t){var e=function(t,e){this._textStack=[],null!==t&&void 0!==t||(t={x:0,y:0}),this._position=t,this._context=e};e.prototype={_position:null,_textStack:null,_currentOptionSet:null,_newOptionSet:function(){null==this._currentOptionSet&&(this._currentOptionSet={text:"",family:"",size:"",weight:"",style:"",color:""})},position:function(t,e){this._position.x=t,this._position.y=e},family:function(t){return this._newOptionSet(),this._currentOptionSet.family=t,this},size:function(t){return this._newOptionSet(),this._currentOptionSet.size=t,this},weight:function(t){return this._newOptionSet(),this._currentOptionSet.weight=t,this},style:function(t){return this._newOptionSet(),this._currentOptionSet.style=t,this},color:function(t){return this._newOptionSet(),this._currentOptionSet.color=t,this},append:function(t){return this._newOptionSet(),this._currentOptionSet.text=t,this._textStack.push(this._currentOptionSet),this._currentOptionSet=null,this},newLine:function(){return this.append("\n"),this},render:function(){if(0!=this._textStack.length){var t={text:"",family:"",size:"",weight:"",style:""},e={x:0,y:0};this._context.save();for(var n=0,i=this._textStack.length;n<i;n++){var r=this._textStack[n];r.family&&(t.family=r.family),r.size&&(t.size=r.size),r.weight&&(t.weight=r.weight),r.style&&(t.style=r.style),this._context.font=JY.trim(t.weight+" "+t.style+" "+t.size+" "+t.family),r.color&&(this._context.fillStyle=r.color);for(var s=r.text,o=s.split(" "),a=0,c=o.length;a<c;a++){var u=" "+o[a],h=this._context.measureText(u).width;"\n"!=s?(this._context.fillText(u,this._position.x+e.x,this._position.y+e.y),e.x+=h):(this._position.y+=20,e.x=0)}}this._context.restore()}}};var n=function(){this.canvas,this.context,this.size};n.prototype={init:function(t){this.canvas=document.getElementById(t),this.context=this.canvas.getContext("2d"),this.size={x:this.canvas.width,y:this.canvas.height}},render:function(){this.context.clearRect(0,0,this.size.x,this.size.y)}};var i={updatePerSecond:60,_loopInterval:null,_prevTime:null,init:function(){this.bindControl(),this._prevTime=(new Date).getTime(),this._loopInterval=window.setInterval(this.gameLoop.bind(this),1e3/this.updatePerSecond)},gameLoop:function(){var t=(new Date).getTime(),e=t-this._prevTime;this.update(e),this._prevTime=t},update:function(t){},bindControl:function(){},handleInput:function(t,e){}},r=function(){this.size={x:0,y:0},this.cut={size:{x:0,y:0},pos:{x:0,y:0}},this.x=0,this.y=0,this.context=null,this.img=null,this.init=function(t,e,n,i){this.context=t,this.img=e,n?this.cut=n:null,i?this.size=i:null},this.setPosition=function(t,e){this.x=t||this.x,this.y=e||this.y,this.context.save();var n=this.cut,i=this.size;this.context.drawImage(this.img,n.x,n.y,i.x,i.y,this.x,this.y,this.size.x,this.size.y),this.context.restore()},this.setCut=function(t,e){this.context.save();var n={x:t,y:e},i=this.cut.size;this.context.drawImage(this.img,n.x,n.y,i.x,i.y,t,e,this.size.x,this.size.y),this.context.restore()}};t.Sprite5=r,t.Game5=i,t.GameCanvas=n,t.CanvasText=e}(window),JY.cookie=function(t,e,n){var i=document.cookie,r=null;if(1==arguments.length){if(i&&""!==i)for(var s=i.split(";"),o=0,a=s.length;o<a;o++){var c=JY.trim(s[o]);if(c.substring(0,t.length+1)==t+"="){r=decodeURIComponent(c.substring(t.length+1));break}}}else{n=n||{};var u="";if(n.expires){var h;switch(n.expires.constructor){case Number:h=new Date,h.setTime(h.getTime()+1e3*n.expires*60*60*24),h=h.toUTCString();break;case String:h=n.expires;break;default:h=n.expires.toUTCString()}u="; expires="+h}var l=n.path?"; path="+n.path:"",d=n.domain?"; domain="+n.domain:"",f=n.secure?"; secure":"";document.cookie=[t,"=",encodeURIComponent(e),u,l,d,f].join("")}return r},JY.soundManage={movieName:"",lastUrl:"",init:function(t,e,n,i){this.movieName=n;var r=this;JY.loadFile(t,"script",function(){r.loadSWF(e,i)})},loadSWF:function(t,e){var n=this.movieName||"playSound",i=document.createElement("div");JY.attr(i,"id",n),JY.css(i,{width:"0px",height:"0px",overflow:"hidden"}),JY.append(document.body,i),swfobject.embedSWF(t,n,1,1,"10.0.0","",{},{},{},e)},loaded:function(){this.isload=!0},loadSound:function(t,e){var n=null,i=this;return e=e||"",setTimeout(function(){if(i.thisMovie(i.movieName)){i.thisMovie(i.movieName).loadFile(t,e),i.lastUrl=t;var r=setInterval(function(){i.isload&&(clearInterval(r),n?n.call(i):null)},50)}},1e3),{done:function(t){n=t||n}}},play:function(t,e){var n=this;return n.thisMovie(n.movieName)&&(t=t||this.lastUrl,e=e||!1,this.thisMovie(this.movieName).onPlay(t,e)),this},stop:function(t){var e=this;return e.thisMovie(e.movieName)&&(t=t||this.lastUrl,this.thisMovie(this.movieName).onStop(t)),this},thisMovie:function(t){return navigator.appName.indexOf("Microsoft")!=-1?window[t]:document[t]}},function(t){var e={touch:function(e,n,i){function r(t){if(!o)return i.call(this,t,"touch")}var s,o=!1;"function"==typeof n?(i=n,t.on(e,"touchstart",function(){o=!0}),t.on(e,"touchmove",function(t){s=!0}).on(e,"touchend",function(t){if(t.preventDefault(),!s){var e=i.call(this,t,"touch");e===!1&&(t.preventDefault(),t.stopPropagation())}s=!1})):(t.on(e,"touchstart",n,function(){o=!0}),t.on(e,"touchmove",n,function(t){s=!0}).on(e,"touchend",n,function(t){if(t.preventDefault(),!s){var e=t.changedTouches[0];t.pageX=e.pageX,t.pageY=e.pageY;var n=i.call(this,t,"touch");n===!1&&(t.preventDefault(),t.stopPropagation())}s=!1})),t.on(e,"mousedown",n,r)},touchStart:function(e,n){function i(t){if(!r)return n.call(this,t)}var r=!1;t.on(e,"touchstart",function(t){var e=t.changedTouches[0];return t.pageX=e.pageX,t.pageY=e.pageY,n.call(this,t,"touchstart")}),t.on(e,"mousedown",trigger,i)},touchMove:function(e,n){function i(t){if(!r)return n.call(this,t,"touchmove")}var r=!1;t.on(e,"touchmove",function(t){var e=t.changedTouches[0];return t.pageX=e.pageX,t.pageY=e.pageY,n.call(this,t,"touchmove")}),t.on(e,"mousemove",trigger,i)},touchEnd:function(e,n){function i(t){if(!r)return n.call(this,t,"touchend")}var r=!1;t.on(e,"touchend",function(t){var e=t.changedTouches[0];return t.pageX=e.pageX,t.pageY=e.pageY,n.call(this,t,"touchend")}),t.on(e,"mouseup",trigger,i)},swipeLeft:function(e,n){var i={},r={};t.touchStart(ojb,function(t){i={x:t.pageX,y:t.pageY}}),t.touchEnd(e,function(t){if(r={x:t.pageX,y:t.pageY},t.start=i,t.end=r,r.x>i.x+10)return n.call(this,t,"swipeLeft")})},swipeRight:function(){var e={},n={};t.touchStart(ojb,function(t){e={x:t.pageX,y:t.pageY}}),t.touchEnd(obj,function(t){if(n={x:t.pageX,y:t.pageY},t.start=e,t.end=n,n.x<e.x+10)return fn.call(this,t,"swipeRight")})},swipe:function(e,n){var i={},r={};t.touchStart(ojb,function(t){i={x:t.pageX,y:t.pageY}}),t.touchEnd(e,function(t){return r={x:t.pageX,y:t.pageY},t.start=i,t.end=r,r.x>i.x+10?n.call(this,t,"swipe"):r.x<i.x+10?n.call(this,t,"swipe"):r.y>i.y+10?n.call(this,t,"swipe"):r.y<i.y+10?n.call(this,t,"swipe"):void 0})}};JY.extend(JY,e)}(JY);