// Copyright 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var g_notMsIECrap = 1;

document.createElement("canvas").getContext||(function(){g_notMsIECrap=0; var s=Math,j=s.round,F=s.sin,G=s.cos,V=s.abs,W=s.sqrt,k=10,v=k/2;function X(){return this.context_||(this.context_=new H(this))}var L=Array.prototype.slice;function Y(b,a){var c=L.call(arguments,2);return function(){return b.apply(a,c.concat(L.call(arguments)))}}var M={init:function(b){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var a=b||document;a.createElement("canvas");a.attachEvent("onreadystatechange",Y(this.init_,this,a))}},init_:function(b){b.namespaces.g_vml_||
b.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML");b.namespaces.g_o_||b.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML");if(!b.styleSheets.ex_canvas_){var a=b.createStyleSheet();a.owningElement.id="ex_canvas_";a.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}var c=b.getElementsByTagName("canvas"),d=0;for(;d<c.length;d++)this.initElement(c[d])},
initElement:function(b){if(!b.getContext){b.getContext=X;b.innerHTML="";b.attachEvent("onpropertychange",Z);b.attachEvent("onresize",$);var a=b.attributes;if(a.width&&a.width.specified)b.style.width=a.width.nodeValue+"px";else b.width=b.clientWidth;if(a.height&&a.height.specified)b.style.height=a.height.nodeValue+"px";else b.height=b.clientHeight}return b}};function Z(b){var a=b.srcElement;switch(b.propertyName){case "width":a.style.width=a.attributes.width.nodeValue+"px";a.getContext().clearRect();
break;case "height":a.style.height=a.attributes.height.nodeValue+"px";a.getContext().clearRect();break}}function $(b){var a=b.srcElement;if(a.firstChild){a.firstChild.style.width=a.clientWidth+"px";a.firstChild.style.height=a.clientHeight+"px"}}M.init();var N=[],B=0;for(;B<16;B++){var C=0;for(;C<16;C++)N[B*16+C]=B.toString(16)+C.toString(16)}function I(){return[[1,0,0],[0,1,0],[0,0,1]]}function y(b,a){var c=I(),d=0;for(;d<3;d++){var f=0;for(;f<3;f++){var h=0,g=0;for(;g<3;g++)h+=b[d][g]*a[g][f];c[d][f]=
h}}return c}function O(b,a){a.fillStyle=b.fillStyle;a.lineCap=b.lineCap;a.lineJoin=b.lineJoin;a.lineWidth=b.lineWidth;a.miterLimit=b.miterLimit;a.shadowBlur=b.shadowBlur;a.shadowColor=b.shadowColor;a.shadowOffsetX=b.shadowOffsetX;a.shadowOffsetY=b.shadowOffsetY;a.strokeStyle=b.strokeStyle;a.globalAlpha=b.globalAlpha;a.arcScaleX_=b.arcScaleX_;a.arcScaleY_=b.arcScaleY_;a.lineScale_=b.lineScale_}function P(b){var a,c=1;b=String(b);if(b.substring(0,3)=="rgb"){var d=b.indexOf("(",3),f=b.indexOf(")",d+
1),h=b.substring(d+1,f).split(",");a="#";var g=0;for(;g<3;g++)a+=N[Number(h[g])];if(h.length==4&&b.substr(3,1)=="a")c=h[3]}else a=b;return{color:a,alpha:c}}function aa(b){switch(b){case "butt":return"flat";case "round":return"round";case "square":default:return"square"}}function H(b){this.m_=I();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.fillStyle=this.strokeStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=k*1;this.globalAlpha=1;this.canvas=b;
var a=b.ownerDocument.createElement("div");a.style.width=b.clientWidth+"px";a.style.height=b.clientHeight+"px";a.style.overflow="hidden";a.style.position="absolute";b.appendChild(a);this.element_=a;this.lineScale_=this.arcScaleY_=this.arcScaleX_=1}var i=H.prototype;i.clearRect=function(){this.element_.innerHTML=""};i.beginPath=function(){this.currentPath_=[]};i.moveTo=function(b,a){var c=this.getCoords_(b,a);this.currentPath_.push({type:"moveTo",x:c.x,y:c.y});this.currentX_=c.x;this.currentY_=c.y};
i.lineTo=function(b,a){var c=this.getCoords_(b,a);this.currentPath_.push({type:"lineTo",x:c.x,y:c.y});this.currentX_=c.x;this.currentY_=c.y};i.bezierCurveTo=function(b,a,c,d,f,h){var g=this.getCoords_(f,h),l=this.getCoords_(b,a),e=this.getCoords_(c,d);Q(this,l,e,g)};function Q(b,a,c,d){b.currentPath_.push({type:"bezierCurveTo",cp1x:a.x,cp1y:a.y,cp2x:c.x,cp2y:c.y,x:d.x,y:d.y});b.currentX_=d.x;b.currentY_=d.y}i.quadraticCurveTo=function(b,a,c,d){var f=this.getCoords_(b,a),h=this.getCoords_(c,d),g={x:this.currentX_+
0.6666666666666666*(f.x-this.currentX_),y:this.currentY_+0.6666666666666666*(f.y-this.currentY_)};Q(this,g,{x:g.x+(h.x-this.currentX_)/3,y:g.y+(h.y-this.currentY_)/3},h)};i.arc=function(b,a,c,d,f,h){c*=k;var g=h?"at":"wa",l=b+G(d)*c-v,e=a+F(d)*c-v,m=b+G(f)*c-v,r=a+F(f)*c-v;if(l==m&&!h)l+=0.125;var n=this.getCoords_(b,a),o=this.getCoords_(l,e),q=this.getCoords_(m,r);this.currentPath_.push({type:g,x:n.x,y:n.y,radius:c,xStart:o.x,yStart:o.y,xEnd:q.x,yEnd:q.y})};i.rect=function(b,a,c,d){this.moveTo(b,
a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath()};i.strokeRect=function(b,a,c,d){var f=this.currentPath_;this.beginPath();this.moveTo(b,a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath();this.stroke();this.currentPath_=f};i.fillRect=function(b,a,c,d){var f=this.currentPath_;this.beginPath();this.moveTo(b,a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath();this.fill();this.currentPath_=f};i.createLinearGradient=function(b,
a,c,d){var f=new D("gradient");f.x0_=b;f.y0_=a;f.x1_=c;f.y1_=d;return f};i.createRadialGradient=function(b,a,c,d,f,h){var g=new D("gradientradial");g.x0_=b;g.y0_=a;g.r0_=c;g.x1_=d;g.y1_=f;g.r1_=h;return g};i.drawImage=function(b){var a,c,d,f,h,g,l,e,m=b.runtimeStyle.width,r=b.runtimeStyle.height;b.runtimeStyle.width="auto";b.runtimeStyle.height="auto";var n=b.width,o=b.height;b.runtimeStyle.width=m;b.runtimeStyle.height=r;if(arguments.length==3){a=arguments[1];c=arguments[2];h=g=0;l=d=n;e=f=o}else if(arguments.length==
5){a=arguments[1];c=arguments[2];d=arguments[3];f=arguments[4];h=g=0;l=n;e=o}else if(arguments.length==9){h=arguments[1];g=arguments[2];l=arguments[3];e=arguments[4];a=arguments[5];c=arguments[6];d=arguments[7];f=arguments[8]}else throw Error("Invalid number of arguments");var q=this.getCoords_(a,c),t=[];t.push(" <g_vml_:group",' coordsize="',k*10,",",k*10,'"',' coordorigin="0,0"',' style="width:',10,"px;height:",10,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]){var E=[];E.push("M11=",
this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",j(q.x/k),",","Dy=",j(q.y/k),"");var p=q,z=this.getCoords_(a+d,c),w=this.getCoords_(a,c+f),x=this.getCoords_(a+d,c+f);p.x=s.max(p.x,z.x,w.x,x.x);p.y=s.max(p.y,z.y,w.y,x.y);t.push("padding:0 ",j(p.x/k),"px ",j(p.y/k),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",E.join(""),", sizingmethod='clip');")}else t.push("top:",j(q.y/k),"px;left:",j(q.x/k),"px;");t.push(' ">','<g_vml_:image src="',b.src,
'"',' style="width:',k*d,"px;"," height:",k*f,'px;"',' cropleft="',h/n,'"',' croptop="',g/o,'"',' cropright="',(n-h-l)/n,'"',' cropbottom="',(o-g-e)/o,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",t.join(""))};i.stroke=function(b){var a=[],c=P(b?this.fillStyle:this.strokeStyle),d=c.color,f=c.alpha*this.globalAlpha;a.push("<g_vml_:shape",' filled="',!!b,'"',' style="position:absolute;width:',10,"px;height:",10,'px;"',' coordorigin="0 0" coordsize="',k*10," ",k*10,'"',' stroked="',
!b,'"',' path="');var h={x:null,y:null},g={x:null,y:null},l=0;for(;l<this.currentPath_.length;l++){var e=this.currentPath_[l];switch(e.type){case "moveTo":a.push(" m ",j(e.x),",",j(e.y));break;case "lineTo":a.push(" l ",j(e.x),",",j(e.y));break;case "close":a.push(" x ");e=null;break;case "bezierCurveTo":a.push(" c ",j(e.cp1x),",",j(e.cp1y),",",j(e.cp2x),",",j(e.cp2y),",",j(e.x),",",j(e.y));break;case "at":case "wa":a.push(" ",e.type," ",j(e.x-this.arcScaleX_*e.radius),",",j(e.y-this.arcScaleY_*e.radius),
" ",j(e.x+this.arcScaleX_*e.radius),",",j(e.y+this.arcScaleY_*e.radius)," ",j(e.xStart),",",j(e.yStart)," ",j(e.xEnd),",",j(e.yEnd));break}if(e){if(h.x==null||e.x<h.x)h.x=e.x;if(g.x==null||e.x>g.x)g.x=e.x;if(h.y==null||e.y<h.y)h.y=e.y;if(g.y==null||e.y>g.y)g.y=e.y}}a.push(' ">');if(b)if(typeof this.fillStyle=="object"){var m=this.fillStyle,r=0,n={x:0,y:0},o=0,q=1;if(m.type_=="gradient"){var t=m.x1_/this.arcScaleX_,E=m.y1_/this.arcScaleY_,p=this.getCoords_(m.x0_/this.arcScaleX_,m.y0_/this.arcScaleY_),
z=this.getCoords_(t,E);r=Math.atan2(z.x-p.x,z.y-p.y)*180/Math.PI;if(r<0)r+=360;if(r<1.0E-6)r=0}else{var p=this.getCoords_(m.x0_,m.y0_),w=g.x-h.x,x=g.y-h.y;n={x:(p.x-h.x)/w,y:(p.y-h.y)/x};w/=this.arcScaleX_*k;x/=this.arcScaleY_*k;var R=s.max(w,x);o=2*m.r0_/R;q=2*m.r1_/R-o}var u=m.colors_;u.sort(function(ba,ca){return ba.offset-ca.offset});var J=u.length,da=u[0].color,ea=u[J-1].color,fa=u[0].alpha*this.globalAlpha,ga=u[J-1].alpha*this.globalAlpha,S=[],l=0;for(;l<J;l++){var T=u[l];S.push(T.offset*q+
o+" "+T.color)}a.push('<g_vml_:fill type="',m.type_,'"',' method="none" focus="100%"',' color="',da,'"',' color2="',ea,'"',' colors="',S.join(","),'"',' opacity="',ga,'"',' g_o_:opacity2="',fa,'"',' angle="',r,'"',' focusposition="',n.x,",",n.y,'" />')}else a.push('<g_vml_:fill color="',d,'" opacity="',f,'" />');else{var K=this.lineScale_*this.lineWidth;if(K<1)f*=K;a.push("<g_vml_:stroke",' opacity="',f,'"',' joinstyle="',this.lineJoin,'"',' miterlimit="',this.miterLimit,'"',' endcap="',aa(this.lineCap),
'"',' weight="',K,'px"',' color="',d,'" />')}a.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",a.join(""))};i.fill=function(){this.stroke(true)};i.closePath=function(){this.currentPath_.push({type:"close"})};i.getCoords_=function(b,a){var c=this.m_;return{x:k*(b*c[0][0]+a*c[1][0]+c[2][0])-v,y:k*(b*c[0][1]+a*c[1][1]+c[2][1])-v}};i.save=function(){var b={};O(this,b);this.aStack_.push(b);this.mStack_.push(this.m_);this.m_=y(I(),this.m_)};i.restore=function(){O(this.aStack_.pop(),
this);this.m_=this.mStack_.pop()};function ha(b){var a=0;for(;a<3;a++){var c=0;for(;c<2;c++)if(!isFinite(b[a][c])||isNaN(b[a][c]))return false}return true}function A(b,a,c){if(!!ha(a)){b.m_=a;if(c)b.lineScale_=W(V(a[0][0]*a[1][1]-a[0][1]*a[1][0]))}}i.translate=function(b,a){A(this,y([[1,0,0],[0,1,0],[b,a,1]],this.m_),false)};i.rotate=function(b){var a=G(b),c=F(b);A(this,y([[a,c,0],[-c,a,0],[0,0,1]],this.m_),false)};i.scale=function(b,a){this.arcScaleX_*=b;this.arcScaleY_*=a;A(this,y([[b,0,0],[0,a,
0],[0,0,1]],this.m_),true)};i.transform=function(b,a,c,d,f,h){A(this,y([[b,a,0],[c,d,0],[f,h,1]],this.m_),true)};i.setTransform=function(b,a,c,d,f,h){A(this,[[b,a,0],[c,d,0],[f,h,1]],true)};i.clip=function(){};i.arcTo=function(){};i.createPattern=function(){return new U};function D(b){this.type_=b;this.r1_=this.y1_=this.x1_=this.r0_=this.y0_=this.x0_=0;this.colors_=[]}D.prototype.addColorStop=function(b,a){a=P(a);this.colors_.push({offset:b,color:a.color,alpha:a.alpha})};function U(){}G_vmlCanvasManager=
M;CanvasRenderingContext2D=H;CanvasGradient=D;CanvasPattern=U})();


var canvas;  
var ctx;
var yScrollLeft = 300;
var yScrollRight = 0;
var g_xScrollGames = 0;

/// Globals
var g_x = 400;
var g_y = 300;
var g_dx = 2;
var g_dy = 4;
var g_page = 0;
var g_deltaTime = 0.0;
var g_prevTime = 0;
var g_runningTime = 0;
var g_scroller;
var g_sparks;
var g_welder;
var g_gameButtons;
var g_gameSelections;
var g_folksDrew;
var g_folksSandy;
var g_folksRob;

var g_slideMMT;
var g_slideMMG;
var g_slideChatter;
var g_slideRabbit;


var WIDTH = 700;
var HEIGHT = 300; 
var g_image1 = new Image();

var g_homeImage0 = new Image();
var g_homeImage1 = new Image();
var g_appsImage0 = new Image();
var g_appsImage1 = new Image();
var g_gamesImage0 = new Image();
var g_gamesImage1 = new Image();
var g_techImage0 = new Image();
var g_techImage1 = new Image();
var g_folksImage0 = new Image();
var g_folksImage1 = new Image();
var g_linksImage0 = new Image();
var g_linksImage1 = new Image();

var g_apps_homeImage0  = new Image();
var g_apps_homeImage1  = new Image();
var g_apps_appsImage0  = new Image();
var g_apps_appsImage1  = new Image();
var g_apps_gamesImage0 = new Image();
var g_apps_gamesImage1 = new Image();
var g_apps_techImage0  = new Image();
var g_apps_techImage1  = new Image();
var g_apps_folksImage0 = new Image();
var g_apps_folksImage1 = new Image();
var g_apps_linksImage0 = new Image();
var g_apps_linksImage1 = new Image();


var g_ga_latest = new Image();
var g_ga_dsi = new Image();
var g_ga_ps2 = new Image();
var g_ga_symbian = new Image();
var g_ga_mobile = new Image();
var g_ga_special = new Image();
var g_ga_online = new Image();
var g_ga_nds = new Image();
var g_ga_gba = new Image();
var g_ga_psp = new Image();
var g_ga_pc = new Image();
var g_ga_wii = new Image();
var g_ga_web = new Image();
var g_ga_iphone = new Image();
var g_ga_art = new Image();
var g_ga_bltmobile = new Image();
var g_ga_gambling = new Image();


var g_ga_latest_ro = new Image();
var g_ga_dsi_ro = new Image();
var g_ga_ps2_ro = new Image();
var g_ga_symbian_ro = new Image();
var g_ga_mobile_ro = new Image();
var g_ga_special_ro = new Image();
var g_ga_online_ro = new Image();
var g_ga_nds_ro = new Image();
var g_ga_gba_ro = new Image();
var g_ga_psp_ro = new Image();
var g_ga_pc_ro = new Image();
var g_ga_wii_ro = new Image();
var g_ga_web_ro = new Image();
var g_ga_iphone_ro = new Image();
var g_ga_art_ro = new Image();
var g_ga_bltmobile_ro = new Image();
var g_ga_gambling_ro = new Image();


var g_textureCache = new OTextureCache();




////////////////////////////////////////////////////////////////////////////////
/// Define the scroller class
////////////////////////////////////////////////////////////////////////////////
function OScroller(l1, l2, l3, s1, s2, s3, useArrows)
{
    this.l1 = l1;
    this.l2 = l2;
    this.l3 = l3;
    
    this.s1 = s1;
    this.s2 = s2;
    this.s3 = s3;

    this.cx1 = 0;
    this.cx2 = 0;
    this.cx3 = 0;
    
    this.Update = function(dt) 
    { 
	this.cx1 += this.s1 * dt;
	this.cx2 += this.s2 * dt;
	this.cx3 += this.s3 * dt;
	
	var layer1 = document.getElementById(this.l1); 
	layer1.style.backgroundPosition = this.cx1 + "px " + "0px";
	
	var layer2 = document.getElementById(this.l2); 
	layer2.style.backgroundPosition = this.cx2 + "px " + "0px";
	
	var layer3 = document.getElementById(this.l3); 
	layer3.style.backgroundPosition = this.cx3 + "px " + "0px";
    }
}

////////////////////////////////////////////////////////////////////////////////
/// OVector2D object is a 
////////////////////////////////////////////////////////////////////////////////
function OVector2D(x, y)
{
    this.x = x;
    this.y = y;
}


////////////////////////////////////////////////////////////////////////////////
/// 
////////////////////////////////////////////////////////////////////////////////
OVector2D.prototype.set = function(px, py)
{
    this.x = px;
    this.y = py;
}

////////////////////////////////////////////////////////////////////////////////
/// 
////////////////////////////////////////////////////////////////////////////////
OVector2D.prototype.add = function(px, py) {
    this.x += px;
    this.y += py;
}

OVector2D.prototype.sub = function(px, py) {
    this.x -= px;
    this.y -= py;
}


////////////////////////////////////////////////////////////////////////////////
/// OParticle2D object is a 
////////////////////////////////////////////////////////////////////////////////
function OParticle2D(life, alpha, imageFile, ax, ay)
{
    this.state        = 0;
    this.time         = 0.0;
    this.life         = life;
    this.alpha        = alpha;
    this.pos      = new OVector2D(0,0);
    this.velocity = new OVector2D(0,0);
    this.scale    = new OVector2D(0,0);
    this.accel    = new OVector2D(ax, ay);
    this.image = new Image();
    this.image.src = imageFile;
}


////////////////////////////////////////////////////////////////////////////////
/// Set and 
////////////////////////////////////////////////////////////////////////////////
OParticle2D.prototype.set = function(px, py, vx, vy, sx, sy)
{
    this.pos.set(px, py);
    this.velocity.set(vx, vy);
    this.scale.set(sx, sy);
    this.state        = 1;
    this.time         = 0;
}


////////////////////////////////////////////////////////////////////////////////
/// Set and 
////////////////////////////////////////////////////////////////////////////////
OParticle2D.prototype.update = function(dt)
{
    if (this.state == 1) 
    {
	this.time += dt;
	if (this.time > this.life) 
	{
	    this.state = 0;
	}
	else
	{
	    this.pos.x += this.velocity.x * dt;
	    this.pos.y += this.velocity.y * dt;
	    this.velocity.add(this.accel.x * dt, this.accel.y * dt);
	}
    }
}

////////////////////////////////////////////////////////////////////////////////
/// 
////////////////////////////////////////////////////////////////////////////////
OParticle2D.prototype.render = function(ctx)
{
    if (this.state == 1) 
    {
	ctx.drawImage(this.image,this.pos.x, this.pos.y, 4, 4);
    }
}


////////////////////////////////////////////////////////////////////////////////
/// Set and 
////////////////////////////////////////////////////////////////////////////////
OParticle2D.prototype.running = function()
{
    return this.state;
}


////////////////////////////////////////////////////////////////////////////////
/// Simple texture caching class. Quite primitive actually.
/// 
////////////////////////////////////////////////////////////////////////////////
function OTextureCache()
{
    this.textures = new Array();
    this.loadCount = 0;
    this.textureCount = 0;
    
    this.maxCount = 59;
    this.maxTexture = 100;
    
    for (var i = 0; i < this.count; i++) 
    {
        this.textures.push(new Image());
    }


    g_apps_homeImage0.src  = "images/apps_home.png";
    g_apps_homeImage1.src  = "images/apps_home_ro.png";
    g_apps_appsImage0.src  = "images/apps_apps.png";
    g_apps_appsImage1.src  = "images/apps_apps_ro.png";
    g_apps_gamesImage0.src = "images/apps_games.png";
    g_apps_gamesImage1.src = "images/apps_games_ro.png";
    g_apps_techImage0.src  = "images/apps_tech.png";
    g_apps_techImage1.src  = "images/apps_tech_ro.png";
    g_apps_folksImage0.src = "images/apps_folks.png";
    g_apps_folksImage1.src = "images/apps_folks_ro.png";

    g_apps_linksImage0.src = "images/apps_links.png";
    g_apps_linksImage1.src = "images/apps_links_ro.png";
    g_homeImage0.src  = "images/home.png";
    g_homeImage1.src  = "images/home_ro.png";
    g_appsImage0.src  = "images/apps.png";
    g_appsImage1.src  = "images/apps_ro.png";
    g_gamesImage0.src = "images/games.png";
    g_gamesImage1.src = "images/games_ro.png";
    g_techImage0.src  = "images/tech.png";
    g_techImage1.src  = "images/tech_ro.png";

    g_folksImage0.src = "images/folks.png";
    g_folksImage1.src = "images/folks_ro.png";
    g_linksImage0.src = "images/links.png";
    g_linksImage1.src = "images/links_ro.png";
    g_image1.src =    "images/links_ro.png";
    g_ga_latest.src  = "buttons/plat_latest.jpg";
    g_ga_dsi.src     = "buttons/plat_dsi.jpg";
    g_ga_ps2.src     = "buttons/plat_ps2.jpg";
    g_ga_symbian.src = "buttons/plat_symbian.jpg";
    g_ga_mobile.src  = "buttons/plat_mobile.jpg";

    g_ga_special.src = "buttons/plat_special.jpg";
    g_ga_online.src  = "buttons/plat_online.jpg";
    g_ga_nds.src     = "buttons/plat_nds.jpg";
    g_ga_gba.src     = "buttons/plat_gba.jpg";
    g_ga_psp.src     = "buttons/plat_psp.jpg";
    g_ga_pc.src      = "buttons/plat_pc.jpg";
    g_ga_wii.src     = "buttons/plat_wii.jpg";
    g_ga_web.src     = "buttons/plat_web.jpg";
    g_ga_iphone.src  = "buttons/plat_iphone.jpg";
    g_ga_art.src     = "buttons/plat_art.jpg";

    g_ga_bltmobile.src = "buttons/plat_bltmobile.jpg";
    g_ga_gambling.src = "buttons/plat_gambling.jpg";
    g_ga_latest_ro.src = "buttons/plat_latest_ro.jpg";
    g_ga_dsi_ro.src    = "buttons/plat_dsi_ro.jpg";
    g_ga_ps2_ro.src    = "buttons/plat_ps2_ro.jpg";
    g_ga_symbian_ro.src = "buttons/plat_symbian_ro.jpg";
    g_ga_mobile_ro.src  = "buttons/plat_mobile_ro.jpg";
    g_ga_special_ro.src = "buttons/plat_special_ro.jpg";
    g_ga_online_ro.src  = "buttons/plat_online_ro.jpg";
    g_ga_nds_ro.src     = "buttons/plat_nds_ro.jpg";

    g_ga_gba_ro.src     = "buttons/plat_gba_ro.jpg";
    g_ga_psp_ro.src     = "buttons/plat_psp_ro.jpg";
    g_ga_pc_ro.src      = "buttons/plat_pc_ro.jpg";
    g_ga_wii_ro.src     = "buttons/plat_wii_ro.jpg";
    g_ga_web_ro.src     = "buttons/plat_web_ro.jpg";
    g_ga_iphone_ro.src  = "buttons/plat_iphone_ro.jpg";
    g_ga_art_ro.src       = "buttons/plat_art_ro.jpg";
    g_ga_bltmobile_ro.src = "buttons/plat_bltmobile_ro.jpg";
    g_ga_gambling_ro.src  = "buttons/plat_gambling_ro.jpg";

    this.textures[this.textureCount++] = "images/sandy_patersen.jpg";
    this.textures[this.textureCount++] = "images/drew_fisher.jpg";
    this.textures[this.textureCount++] = "images/rob_legg.jpg";
    this.textures[this.textureCount++] = "banners/absbanner.jpg";
    this.textures[this.textureCount++] = "banners/actibanner.jpg";
    this.textures[this.textureCount++] = "banners/actibanner_pc.jpg";
    this.textures[this.textureCount++] = "banners/agpbanner.jpg";
    this.textures[this.textureCount++] = "banners/akbbanner.jpg";
    this.textures[this.textureCount++] = "banners/aliboxingbanner.jpg";
    this.textures[this.textureCount++] = "banners/alienbankbanner.jpg";
    this.textures[this.textureCount++] = "banners/armoredbanner.jpg";
    this.textures[this.textureCount++] = "banners/arrbanner.jpg";
    this.textures[this.textureCount++] = "banners/avp2banner.jpg";
    this.textures[this.textureCount++] = "banners/babyzbanner.jpg";
    this.textures[this.textureCount++] = "banners/blackbanner.jpg";
    this.textures[this.textureCount++] = "banners/bratz4realbanner.jpg";
    this.textures[this.textureCount++] = "banners/bratzforever_banner.jpg";
    this.textures[this.textureCount++] = "banners/c64banner.jpg";
    this.textures[this.textureCount++] = "banners/castlebanner.jpg";
    this.textures[this.textureCount++] = "banners/ccbanner.jpg";
    this.textures[this.textureCount++] = "banners/chainzbanner.jpg";
    this.textures[this.textureCount++] = "banners/cherrybanner.jpg";
    this.textures[this.textureCount++] = "banners/chinabanner.jpg";
    this.textures[this.textureCount++] = "banners/cyberbanner.jpg";
    this.textures[this.textureCount++] = "banners/diamondsbanner.jpg";
    this.textures[this.textureCount++] = "banners/eltigre_banner.jpg";
    this.textures[this.textureCount++] = "banners/eqbanner.jpg";
    this.textures[this.textureCount++] = "banners/flintbanner.jpg";
    this.textures[this.textureCount++] = "banners/foxbanner.jpg";
    this.textures[this.textureCount++] = "banners/girlsreallyrockbanner.jpg";
    this.textures[this.textureCount++] = "banners/greekbanner.jpg";
    this.textures[this.textureCount++] = "banners/herbiebanner.jpg";
    this.textures[this.textureCount++] = "banners/holdembanner.jpg";
    this.textures[this.textureCount++] = "banners/hrbanner.jpg";
    this.textures[this.textureCount++] = "banners/iosirisbanner.jpg";
    this.textures[this.textureCount++] = "banners/jjbanner.jpg";
    this.textures[this.textureCount++] = "banners/jlabanner.jpg";
    this.textures[this.textureCount++] = "banners/muabanner.jpg";
    this.textures[this.textureCount++] = "banners/nakedbrosbanner.jpg";
    this.textures[this.textureCount++] = "banners/nbbps2banner.jpg";
    this.textures[this.textureCount++] = "banners/nbbwiibanner.jpg";
    this.textures[this.textureCount++] = "banners/oblivianbanner.jpg";
    this.textures[this.textureCount++] = "banners/osiris_onlinebanner.jpg";
    this.textures[this.textureCount++] = "banners/osiris_pspbanner.jpg";
    this.textures[this.textureCount++] = "banners/osirisbanner.jpg";
    this.textures[this.textureCount++] = "banners/photiquebanner.jpg";
    this.textures[this.textureCount++] = "banners/pokerbanner.jpg";
    this.textures[this.textureCount++] = "banners/powerchipsbanner.jpg";
    this.textures[this.textureCount++] = "banners/sbspanishbanner.jpg";
    this.textures[this.textureCount++] = "banners/sbtosbanner.jpg";
    this.textures[this.textureCount++] = "banners/sbtosbannerps2.jpg";
    this.textures[this.textureCount++] = "banners/sc3banner.jpg";
    this.textures[this.textureCount++] = "banners/shrek2banner.jpg";
    this.textures[this.textureCount++] = "banners/sjbanner.jpg";
    this.textures[this.textureCount++] = "banners/snakes2banner.jpg";
    this.textures[this.textureCount++] = "banners/spidey2banner.jpg";
    this.textures[this.textureCount++] = "banners/tankbanner.jpg";
    this.textures[this.textureCount++] = "banners/th1gametapbanner.jpg";
    this.textures[this.textureCount++] = "banners/th2gametapbanner.jpg";
    this.textures[this.textureCount++] = "banners/thebankbanner.jpg";
    this.textures[this.textureCount++] = "banners/tweetybanner.jpg";
    this.textures[this.textureCount++] = "banners/un_ip_3ds.jpg";
    this.textures[this.textureCount++] = "banners/un_ip_and.jpg";
    this.textures[this.textureCount++] = "banners/wcbanner.jpg";
    this.textures[this.textureCount++] = "banners/wildbanner.jpg";
    this.textures[this.textureCount++] = "banners/xmen2banner.jpg";
    this.textures[this.textureCount++] = "banners/xmenlegendsbanner.jpg";
    this.textures[this.textureCount++] = "banners/xmldemobanner.jpg";
    this.textures[this.textureCount++] = "banners/zoey101gbabanner.jpg";
    this.textures[this.textureCount++] = "banners/zoey101ndsbanner.jpg";
}


////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
OTextureCache.prototype.loadNext = function()
{
    this.loadCount = 0;
    if (this.textureCount > this.maxTexture)
    {
	return 1;
    }
    
    if (this.loadCount < this.maxCount) 
    {
	if (this.loadCount == 0) { this.loadCount++; g_apps_homeImage0.src  = "images/apps_home.png"; return 0; }
	if (this.loadCount == 1) { this.loadCount++; g_apps_homeImage1.src  = "images/apps_home_ro.png"; return 0; }
	if (this.loadCount == 2) { this.loadCount++; g_apps_appsImage0.src  = "images/apps_apps.png"; return 0; }
	if (this.loadCount == 3) { this.loadCount++; g_apps_appsImage1.src  = "images/apps_apps_ro.png"; return 0; }
	if (this.loadCount == 4) { this.loadCount++; g_apps_gamesImage0.src = "images/apps_games.png"; return 0; }
	if (this.loadCount == 5) { this.loadCount++; g_apps_gamesImage1.src = "images/apps_games_ro.png"; return 0; }
	if (this.loadCount == 6) { this.loadCount++; g_apps_techImage0.src  = "images/apps_tech.png"; return 0; }
	if (this.loadCount == 7) { this.loadCount++; g_apps_techImage1.src  = "images/apps_tech_ro.png"; return 0; }
	if (this.loadCount == 8) { this.loadCount++; g_apps_folksImage0.src = "images/apps_folks.png"; return 0; }
	if (this.loadCount == 9) { this.loadCount++; g_apps_folksImage1.src = "images/apps_folks_ro.png"; return 0; }
	
	if (this.loadCount == 10) { this.loadCount++; g_apps_linksImage0.src = "images/apps_links.png"; return 0; }
	if (this.loadCount == 11) { this.loadCount++; g_apps_linksImage1.src = "images/apps_links_ro.png"; return 0; }
	if (this.loadCount == 12) { this.loadCount++; g_homeImage0.src  = "images/home.png"; return 0; }
	if (this.loadCount == 13) { this.loadCount++; g_homeImage1.src  = "images/home_ro.png"; return 0; }
	if (this.loadCount == 14) { this.loadCount++; g_appsImage0.src  = "images/apps.png"; return 0; }
	if (this.loadCount == 15) { this.loadCount++; g_appsImage1.src  = "images/apps_ro.png"; return 0; }
	if (this.loadCount == 16) { this.loadCount++; g_gamesImage0.src = "images/games.png"; return 0; }
	if (this.loadCount == 17) { this.loadCount++; g_gamesImage1.src = "images/games_ro.png"; return 0; }
	if (this.loadCount == 18) { this.loadCount++; g_techImage0.src  = "images/tech.png"; return 0; }
	if (this.loadCount == 19) { this.loadCount++; g_techImage1.src  = "images/tech_ro.png"; return 0; }
	
	if (this.loadCount == 20) { this.loadCount++; g_folksImage0.src = "images/folks.png"; return 0; }
	if (this.loadCount == 21) { this.loadCount++; g_folksImage1.src = "images/folks_ro.png"; return 0; }
	if (this.loadCount == 22) { this.loadCount++; g_linksImage0.src = "images/links.png"; return 0; }
	if (this.loadCount == 23) { this.loadCount++; g_linksImage1.src = "images/links_ro.png"; return 0; }
	if (this.loadCount == 24) { this.loadCount++; g_image1.src =    "images/links_ro.png";    return 0; }
	if (this.loadCount == 25) { this.loadCount++; g_ga_latest.src  = "buttons/plat_latest.jpg"; return 0; }
	if (this.loadCount == 26) { this.loadCount++; g_ga_dsi.src     = "buttons/plat_dsi.jpg"; return 0; }
	if (this.loadCount == 27) { this.loadCount++; g_ga_ps2.src     = "buttons/plat_ps2.jpg"; return 0; }
	if (this.loadCount == 28) { this.loadCount++; g_ga_symbian.src = "buttons/plat_symbian.jpg"; return 0; }
	if (this.loadCount == 29) { this.loadCount++; g_ga_mobile.src  = "buttons/plat_mobile.jpg"; return 0; }
	
	if (this.loadCount == 30) { this.loadCount++; g_ga_special.src = "buttons/plat_special.jpg"; return 0; }
	if (this.loadCount == 31) { this.loadCount++; g_ga_online.src  = "buttons/plat_online.jpg"; return 0; }
	if (this.loadCount == 32) { this.loadCount++; g_ga_nds.src     = "buttons/plat_nds.jpg"; return 0; }
	if (this.loadCount == 33) { this.loadCount++; g_ga_gba.src     = "buttons/plat_gba.jpg"; return 0; }
	if (this.loadCount == 34) { this.loadCount++; g_ga_psp.src     = "buttons/plat_psp.jpg"; return 0; }
	if (this.loadCount == 35) { this.loadCount++; g_ga_pc.src      = "buttons/plat_pc.jpg"; return 0; }
	if (this.loadCount == 36) { this.loadCount++; g_ga_wii.src     = "buttons/plat_wii.jpg"; return 0; }
	if (this.loadCount == 37) { this.loadCount++; g_ga_web.src     = "buttons/plat_web.jpg"; return 0; }
	if (this.loadCount == 38) { this.loadCount++; g_ga_iphone.src  = "buttons/plat_iphone.jpg"; return 0; }
	if (this.loadCount == 39) { this.loadCount++; g_ga_art.src     = "buttons/plat_art.jpg"; return 0; }
	
	if (this.loadCount == 40) { this.loadCount++; g_ga_bltmobile.src = "buttons/plat_bltmobile.jpg"; return 0; }
	if (this.loadCount == 41) { this.loadCount++; g_ga_gambling.src = "buttons/plat_gambling.jpg"; return 0; }
	if (this.loadCount == 42) { this.loadCount++; g_ga_latest_ro.src = "buttons/plat_latest_ro.jpg"; return 0; }
	if (this.loadCount == 43) { this.loadCount++; g_ga_dsi_ro.src    = "buttons/plat_dsi_ro.jpg"; return 0; }
	if (this.loadCount == 44) { this.loadCount++; g_ga_ps2_ro.src    = "buttons/plat_ps2_ro.jpg"; return 0; }
	if (this.loadCount == 45) { this.loadCount++; g_ga_symbian_ro.src = "buttons/plat_symbian_ro.jpg"; return 0; }
	if (this.loadCount == 46) { this.loadCount++; g_ga_mobile_ro.src  = "buttons/plat_mobile_ro.jpg"; return 0; }
	if (this.loadCount == 47) { this.loadCount++; g_ga_special_ro.src = "buttons/plat_special_ro.jpg"; return 0; }
	if (this.loadCount == 48) { this.loadCount++; g_ga_online_ro.src  = "buttons/plat_online_ro.jpg"; return 0; }
	if (this.loadCount == 49) { this.loadCount++; g_ga_nds_ro.src     = "buttons/plat_nds_ro.jpg"; return 0; }
	
	if (this.loadCount == 50) { this.loadCount++; g_ga_gba_ro.src     = "buttons/plat_gba_ro.jpg"; return 0; }
	if (this.loadCount == 51) { this.loadCount++; g_ga_psp_ro.src     = "buttons/plat_psp_ro.jpg"; return 0; }
	if (this.loadCount == 52) { this.loadCount++; g_ga_pc_ro.src      = "buttons/plat_pc_ro.jpg"; return 0; }
	if (this.loadCount == 53) { this.loadCount++; g_ga_wii_ro.src     = "buttons/plat_wii_ro.jpg"; return 0; }
	if (this.loadCount == 54) { this.loadCount++; g_ga_web_ro.src     = "buttons/plat_web_ro.jpg"; return 0; }
	if (this.loadCount == 55) { this.loadCount++; g_ga_iphone_ro.src  = "buttons/plat_iphone_ro.jpg"; return 0; }
	if (this.loadCount == 56) { this.loadCount++; g_ga_art_ro.src       = "buttons/plat_art_ro.jpg"; return 0; }
	if (this.loadCount == 57) { this.loadCount++; g_ga_bltmobile_ro.src = "buttons/plat_bltmobile_ro.jpg"; return 0; }
	if (this.loadCount == 58) { this.loadCount++; g_ga_gambling_ro.src  = "buttons/plat_gambling_ro.jpg"; return 0; }
	
	this.loadCount++;
	return;
    }


    if (this.textureCount == 0) { this.textures[this.textureCount] = "banners/absbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 1) { this.textures[this.textureCount] = "banners/actibanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 2) { this.textures[this.textureCount] = "banners/actibanner_pc.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 3) { this.textures[this.textureCount] = "banners/agpbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 4) { this.textures[this.textureCount] = "banners/akbbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 5) { this.textures[this.textureCount] = "banners/aliboxingbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 6) { this.textures[this.textureCount] = "banners/alienbankbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 7) { this.textures[this.textureCount] = "banners/armoredbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 8) { this.textures[this.textureCount] = "banners/arrbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 9) { this.textures[this.textureCount] = "banners/avp2banner.jpg"; this.textureCount++; return 0; }
    
    if (this.textureCount == 10) { this.textures[this.textureCount] = "banners/babyzbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 11) { this.textures[this.textureCount] = "banners/blackbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 12) { this.textures[this.textureCount] = "banners/bratz4realbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 13) { this.textures[this.textureCount] = "banners/bratzforever_banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 14) { this.textures[this.textureCount] = "banners/c64banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 15) { this.textures[this.textureCount] = "banners/castlebanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 16) { this.textures[this.textureCount] = "banners/ccbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 17) { this.textures[this.textureCount] = "banners/chainzbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 18) { this.textures[this.textureCount] = "banners/cherrybanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 19) { this.textures[this.textureCount] = "banners/chinabanner.jpg"; this.textureCount++; return 0; }
    
    if (this.textureCount == 20) { this.textures[this.textureCount] = "banners/cyberbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 21) { this.textures[this.textureCount] = "banners/diamondsbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 22) { this.textures[this.textureCount] = "banners/eltigre_banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 23) { this.textures[this.textureCount] = "banners/eqbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 24) { this.textures[this.textureCount] = "banners/flintbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 25) { this.textures[this.textureCount] = "banners/foxbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 26) { this.textures[this.textureCount] = "banners/girlsreallyrockbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 27) { this.textures[this.textureCount] = "banners/greekbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 28) { this.textures[this.textureCount] = "banners/herbiebanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 29) { this.textures[this.textureCount] = "banners/holdembanner.jpg"; this.textureCount++; return 0; }
    
    if (this.textureCount == 30) { this.textures[this.textureCount] = "banners/hrbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 31) { this.textures[this.textureCount] = "banners/iosirisbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 32) { this.textures[this.textureCount] = "banners/jjbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 33) { this.textures[this.textureCount] = "banners/jlabanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 34) { this.textures[this.textureCount] = "banners/muabanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 35) { this.textures[this.textureCount] = "banners/nakedbrosbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 36) { this.textures[this.textureCount] = "banners/nbbps2banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 37) { this.textures[this.textureCount] = "banners/nbbwiibanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 38) { this.textures[this.textureCount] = "banners/oblivianbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 39) { this.textures[this.textureCount] = "banners/osiris_onlinebanner.jpg"; this.textureCount++; return 0; }
    
    if (this.textureCount == 40) { this.textures[this.textureCount] = "banners/osiris_pspbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 41) { this.textures[this.textureCount] = "banners/osirisbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 42) { this.textures[this.textureCount] = "banners/photiquebanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 43) { this.textures[this.textureCount] = "banners/pokerbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 44) { this.textures[this.textureCount] = "banners/powerchipsbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 45) { this.textures[this.textureCount] = "banners/sbspanishbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 46) { this.textures[this.textureCount] = "banners/sbtosbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 47) { this.textures[this.textureCount] = "banners/sbtosbannerps2.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 48) { this.textures[this.textureCount] = "banners/sc3banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 49) { this.textures[this.textureCount] = "banners/shrek2banner.jpg"; this.textureCount++; return 0; }
    
    if (this.textureCount == 50) { this.textures[this.textureCount] = "banners/sjbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 51) { this.textures[this.textureCount] = "banners/snakes2banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 52) { this.textures[this.textureCount] = "banners/spidey2banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 53) { this.textures[this.textureCount] = "banners/tankbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 54) { this.textures[this.textureCount] = "banners/th1gametapbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 55) { this.textures[this.textureCount] = "banners/th2gametapbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 56) { this.textures[this.textureCount] = "banners/thebankbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 57) { this.textures[this.textureCount] = "banners/tweetybanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 58) { this.textures[this.textureCount] = "banners/un_ip_3ds.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 59) { this.textures[this.textureCount] = "banners/un_ip_and.jpg"; this.textureCount++; return 0; }
    
    if (this.textureCount == 60) { this.textures[this.textureCount] = "banners/wcbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 61) { this.textures[this.textureCount] = "banners/wildbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 62) { this.textures[this.textureCount] = "banners/xmen2banner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 63) { this.textures[this.textureCount] = "banners/xmenlegendsbanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 64) { this.textures[this.textureCount] = "banners/xmldemobanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 65) { this.textures[this.textureCount] = "banners/zoey101gbabanner.jpg"; this.textureCount++; return 0; }
    if (this.textureCount == 66) { this.textures[this.textureCount] = "banners/zoey101ndsbanner.jpg"; this.textureCount++; return 0; }
   
   this.textureCount++;
   return 1;
}



////////////////////////////////////////////////////////////////////////////////
/// Define a simple particle emitter class
/// 
/// atype - 0 = "point emitter"
///       - 1 = "verticle line emitter" -> centered at position
/// 
////////////////////////////////////////////////////////////////////////////////
function OParticleMgr2D(life, atype, rate, adim, speed, nemitters, ax, ay)
{
    this.maxCount  = life * rate * nemitters;
    this.speed     = speed;
    this.atype     = atype;
    this.adim      = adim;
    this.rate      = rate;
    this.state     = 0;
    this.pos       = new OVector2D(0,0);
    this.particles = new Array();
    
    for (var i = 0; i < this.maxCount; i++) 
    {
        this.particles.push(new OParticle2D(life, 0, "images/spark.png", ax, ay));
    }
}


////////////////////////////////////////////////////////////////////////////////
/// Burst the particles
////////////////////////////////////////////////////////////////////////////////
OParticleMgr2D.prototype.burst = function(px, py)
{
    // Loop through the list and apply the initial mathematics.
    this.pos.set(px, py);
    if (this.atype == 0) 
    {
	var count = this.rate;
	for (var i = 0; i < this.maxCount && count > 0; i++) 
	{
	   if (this.particles[i].running() == 0) 
	   {
	       count--;
	       var rand1 = Math.random();
	       var rand2 = Math.random();

	       // compute the direction
	       var theta = Math.PI * (rand1);
	       var vx = Math.cos(theta);
	       var vy = Math.sin(theta);
	       var ppx = (this.adim * rand2 * vx) + px;
	       var ppy = (this.adim * rand2 * vy) + py;
	       
	       // get the starting point
	       this.particles[i].set(ppx, ppy, vx * this.speed, vy * this.speed, 1, 1);
	   }
	}
     }
    // Loop through the list and apply the initial mathematics.
    if (this.atype == 1) 
    {
	var count = this.rate;
	var offset = 2.0 * this.adim;
	for (var i = 0; i < this.maxCount && count > 0; i++) 
	{
	   if (this.particles[i].running() == 0) 
	   {
	       count--;
	       var rand1 = Math.random();
	       var rand2 = Math.random();
	       var rand3 = Math.random();

	       // compute the direction
	       var theta = Math.PI * (rand1);
	       var vx = Math.cos(theta);
	       var vy = Math.sin(theta);
	       var ppx = (rand2 * vx) + px;
	       var ppy = (rand2 * vy) + py + offset * (0.5 - rand3);
	       
	       // get the starting point
	       this.particles[i].set(ppx, ppy, vx * this.speed, vy * this.speed, 1, 1);
	   }
	}
     }
};


////////////////////////////////////////////////////////////////////////////////
/// Update the particles
///
////////////////////////////////////////////////////////////////////////////////
OParticleMgr2D.prototype.update = function(dt)
{
    for (var i = 0; i < this.maxCount; i++) 
    {
       this.particles[i].update(dt);
    }
}


////////////////////////////////////////////////////////////////////////////////
/// Render the particles
////////////////////////////////////////////////////////////////////////////////
OParticleMgr2D.prototype.render = function(ctx)
{
    for (var i = 0; i < this.maxCount; i++) 
    {
       this.particles[i].render(ctx);
    }
}


////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
OParticleMgr2D.prototype.burstAtDiv = function(div)
{
    var divs = document.getElementById(div);
    if (divs) {
	var px = divs.style.left + divs.style.width*0.5;
	var py = divs.style.top + divs.style.height*0.5;
	this.burst(px, py);
    }
}


////////////////////////////////////////////////////////////////////////////////
/// Define the game update class
////////////////////////////////////////////////////////////////////////////////
function OGameSelections()
{
    this.current = 1;
    this.state   = 0;
    this.selections = new Array();
    this.text      = new Array();
    
    this.selections.push(new String());
    this.text.push(new String());
    
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/un_ip_3ds.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/un_ip_and.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/photiquebanner.jpg\"/></div> <div id=\"C_gameImage2\"><img src=\"banners/sjbanner.jpg\"/></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/iosirisbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/thebankbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/alienbankbanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/osirisbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/nbbwiibanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/bratz4realbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/girlsreallyrockbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/eltigre_banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/sc3banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage5\"><img src=\"banners/zoey101ndsbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage6\"><img src=\"banners/bratzforever_banner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/armoredbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/wcbanner.jpg\" alt=\"Pic2\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/chinabanner.jpg\" alt=\"Pic3\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/osiris_onlinebanner.jpg\" alt=\"Pic4\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/aliboxingbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/avp2banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/oblivianbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/shrek2banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage5\"><img src=\"banners/foxbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage6\"><img src=\"banners/castlebanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/spidey2banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/sbtosbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/sbspanishbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/osiris_pspbanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/nakedbrosbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/ccbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/actibanner_pc.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/nbbps2banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/sbtosbannerps2.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/actibanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/zoey101gbabanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/muabanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/babyzbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/diamondsbanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/snakes2banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/xmenlegendsbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/xmen2banner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/chainzbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/powerchipsbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/eqbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/hrbanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/th1gametapbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/th2gametapbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/c64banner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/xmldemobanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/cyberbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/tankbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/absbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/arrbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage5\"><img src=\"banners/akbbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage6\"><img src=\"banners/agpbanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/blackbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/cherrybanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/greekbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/holdembanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage5\"><img src=\"banners/pokerbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage6\"><img src=\"banners/wildbanner.jpg\" alt=\"\" /></div>"));
    this.selections.push(new String("<div id=\"C_gameImage1\"><img src=\"banners/herbiebanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage2\"><img src=\"banners/flintbanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage3\"><img src=\"banners/tweetybanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage4\"><img src=\"banners/jlabanner.jpg\" alt=\"\" /></div> <div id=\"C_gameImage5\"><img src=\"banners/jjbanner.jpg\" alt=\"\" /></div>"));

    // latest
    this.text.push(new String("<p>These are our latest projects. Some haven't been announced but check back from time to time and see what's going on.</p>"));
    
    // dsi
    this.text.push(new String("<p>These are the DSi titles based primarily on a modified version of our NDS engine.</p>"));
    
    // iphone
    this.text.push(new String("<p>Although there are iPhone titles currently in development these titles have been released with the exception of Alien Bank which is due out in March 2011.</p>"));
    
    // wii
    this.text.push(new String("<p>These are BLTs Wii titles. Like other platforms, these titles were developed with BLTs multi-platform engine.</p>"));
    
    // nds
    this.text.push(new String("<p> BLT has developed a number of titles for the NDS based on the Bratz license. These titles have historically sold quite well.</p>"));
    
    // online
    this.text.push(new String("<p>Online has a number of definitions here. Armored Storm and World Combat are multiplayer online games in the tradional sense. In 2003, BLT did a project for China Mobile which was the start of our on-line server development.</p>"));
    
    // mobile
    this.text.push(new String("<p> The Mobile catagory are some of our commercial developments built with J2ME and BREW. These titles were mostly developed for other companies.</p>"));
    
    // psp
    this.text.push(new String("<p>BLT has developed Sony PSP titles. The Spider-man 2 project started out as a port to the 2-byte based Japanese market and grew into something a good deal bigger. Sponge Bob - Truth or Square was a platformer developed for THQ.</p>"));
    
    // pc
    this.text.push(new String("<p>BLT has released several PC titles. Generally, these are based on off-skus of titles developed for our publishing partners.</p>"));
    
    // ps2
    this.text.push(new String("<p>The first title BLT released with Activision Anthology for the PS2. In addition to being well reviewed it started the retro trend for console emulation of early game systems like the Atari 2600.</p>"));
    
    // gba
    this.text.push(new String("<p>The first engine written at BLT was for the GBA in 2001 but it wasn't used until 2005; but at that point it was used heavily.</p>"));
    
    // symbian
    this.text.push(new String("<p>Early in BLTs history we worked closely with Nokia during their N-Gage investment. BLT developed the X-Men Legends series and despite the N-Gages 100Mhz processor and 8Megs of RAM BLT was able to produce impressive titles. </p>"));
    
    // web
    this.text.push(new String("<p>BLT developed a series of web titles with our publisher Mumbo Jumbo.</p>"));
    
    // special
    this.text.push(new String("<p> From time to time BLT engages a customer on a non-traditional game or technology development effort. The Tony Hawk titles were prepared for GameTap. While these were small projects they had their challenges. BLT has a long-standing relationship with Texas Instruments and have found ourselves porting technology to their chip-sets as proof-of-concept demonstrations.</p>"));
    
    // bltmobile
    this.text.push(new String("<p>Early in the start of the Mobile gaming era BLT created a label (BLT Mobile) and developed several titles for that label. These titles were primarily developed in J2ME.</p>"));
    
    // gambling
    this.text.push(new String("<p>BLT has also developed a number of gaming titles in J2ME.</p>"));
    
    // art
    this.text.push(new String("<p>With a strong team of pixel artists BLT would often provide services to other companies developing mobile titles. All of the projects listed here only involved art development.</p>"));
    
}



////////////////////////////////////////////////////////////////////////////////
/// Main selection update function
////////////////////////////////////////////////////////////////////////////////
OGameSelections.prototype.Update = function(index)
{
    if (document.images) 
    {
	var divGameSel = document.getElementById("mainCenter");
	divGameSel.innerHTML = this.selections[this.current];
	
	var divTextSel = document.getElementById("screenTextSide");
	divTextSel.innerHTML = this.text[this.current];
    }
}


////////////////////////////////////////////////////////////////////////////////
/// Main selection update function
////////////////////////////////////////////////////////////////////////////////
OGameSelections.prototype.SetIndex = function(index)
{
    this.current = index;    
}


////////////////////////////////////////////////////////////////////////////////
/// Define the "fade in" class
/// 
////////////////////////////////////////////////////////////////////////////////
function ODivFadeIn(divVar, rate, wait)
{
    this.divVar     = divVar;
    this.fadeVar    = 0;
    this.fadeInRate = rate;
    this.fadeInWait = wait;
    var divSel = document.getElementById(divVar);
    divSel.style.opacity = 0;
}


////////////////////////////////////////////////////////////////////////////////
/// Main selection update function
////////////////////////////////////////////////////////////////////////////////
ODivFadeIn.prototype.Update = function(dt)
{
    if (this.fadeVar == 1.0)
    {
       return;
    }
    
    this.fadeInWait -= dt;
    if (this.fadeInWait < 0.0) 
    {
	this.fadeVar += this.fadeInRate * dt;
	if (this.fadeVar > 1.0) 
        {
	    this.fadeVar = 1.0;
	}
    
	var divSel = document.getElementById(this.divVar);
	divSel.style.opacity = this.fadeVar;
    }
}


////////////////////////////////////////////////////////////////////////////////
/// Define the "slide in" class
/// 
////////////////////////////////////////////////////////////////////////////////
function ODivSlideIn(divVar, rate, wait, emitter, xStart, yStart)
{
    this.divVar     = divVar;
    this.slideVar    = 0;
    this.slideInRate = rate;
    this.slideInWait = wait;
    this.xStart      = xStart;
    this.yStart      = yStart;
    
    var divSel = document.getElementById(divVar);
    this.width = 520;
    divSel.style.width = "0px";
}


////////////////////////////////////////////////////////////////////////////////
/// Main selection update function
////////////////////////////////////////////////////////////////////////////////
ODivSlideIn.prototype.Update = function(dt, ctx)
{
    if (this.slideVar == 1.0)
    {
       return;
    }
    
    this.slideInWait -= dt;
    if (this.slideInWait < 0.0) 
    {
	this.slideVar += this.slideInRate * dt;
	if (this.slideVar > 1.0) 
        {
	    this.slideVar = 1.0;
	}
	var outVar = WJS.Math.Transitions.easeInQuad(this.slideVar);
	var divSel = document.getElementById(this.divVar);
	var offset = outVar * this.width;
	divSel.style.width = (offset) + "px";
    }
}


////////////////////////////////////////////////////////////////////////////////
// Over the button function
////////////////////////////////////////////////////////////////////////////////
function oB(b) 
{
  if (document.images) 
  {
      if (g_page == 3) 
      {
	  if (b==1) { document["a_butHome"].src       = g_apps_homeImage1.src; }
	  else if (b==2) { document["a_butGames"].src = g_apps_gamesImage1.src; }
	  else if (b==3) { document["a_butApps"].src  = g_apps_appsImage1.src; }
	  else if (b==4) { document["a_butTech"].src  = g_apps_techImage1.src; }
	  else if (b==5) { document["a_butFolks"].src = g_apps_folksImage1.src; }
	  else if (b==6) { document["a_butLinks"].src = g_apps_linksImage1.src; }
      }
      else
      {
	  if (b==1) { document["butHome"].src       = g_homeImage1.src; }
	  else if (b==2) { document["butGames"].src = g_gamesImage1.src; }
	  else if (b==3) { document["butApps"].src  = g_appsImage1.src; }
	  else if (b==4) { document["butTech"].src  = g_techImage1.src; }
	  else if (b==5) { document["butFolks"].src = g_folksImage1.src; }
	  else if (b==6) { document["butLinks"].src = g_linksImage1.src; }
      }
  }

}
 

////////////////////////////////////////////////////////////////////////////////
// Over the button function
////////////////////////////////////////////////////////////////////////////////
function uB(b) 
{
  if (document.images) 
  {
      if (g_page == 3) 
      {
	  if (b==1) { document["a_butHome"].src       = g_apps_homeImage0.src; }
	  else if (b==2) { document["a_butGames"].src = g_apps_gamesImage0.src; }
	  else if (b==3) { document["a_butApps"].src  = g_apps_appsImage0.src; }
	  else if (b==4) { document["a_butTech"].src  = g_apps_techImage0.src; }
	  else if (b==5) { document["a_butFolks"].src = g_apps_folksImage0.src; }
	  else if (b==6) { document["a_butLinks"].src = g_apps_linksImage0.src;  }
      }
      else
      {
	  if (b==1) { document["butHome"].src       = g_homeImage0.src; }
	  else if (b==2) { document["butGames"].src = g_gamesImage0.src; }
	  else if (b==3) { document["butApps"].src  = g_appsImage0.src; }
	  else if (b==4) { document["butTech"].src  = g_techImage0.src; }
	  else if (b==5) { document["butFolks"].src = g_folksImage0.src; }
	  else if (b==6) { document["butLinks"].src = g_linksImage0.src;  }
      }
  }
}


////////////////////////////////////////////////////////////////////////////////
// Over the button function
////////////////////////////////////////////////////////////////////////////////
function oB1(b) 
{
    if (document.images) 
    {
	g_gameSelections.SetIndex(b);
	if (b == 1)      { 	    
	    document["ga_latest"].src  = g_ga_latest_ro.src; 
	    g_sparks.burst(230, 210);
	}
	else if (b == 2) { 
	    document["ga_dsi"].src     = g_ga_dsi_ro.src; 
	    g_sparks.burst(240, 220);
	}
	else if (b == 3) { 
	    document["ga_iphone"].src  = g_ga_iphone_ro.src; 
	    g_sparks.burst(240, 260);
	}
	else if (b == 4) { 
	    document["ga_wii"].src     = g_ga_wii_ro.src; 
	    g_sparks.burst(240, 280);
	}
	else if (b == 5) {
	    document["ga_nds"].src     = g_ga_nds_ro.src; 
	    g_sparks.burst(240, 300);
	}
	else if (b == 6) { 
	    document["ga_online"].src  = g_ga_online_ro.src; 
	    g_sparks.burst(240, 320);
	}
	else if (b == 7) { 
	    document["ga_mobile"].src  = g_ga_mobile_ro.src; 
	    g_sparks.burst(240, 340);
	}
	else if (b == 8) { 
	    document["ga_psp"].src     = g_ga_psp_ro.src; 
	    g_sparks.burst(240, 360);
	}
	else if (b == 9) { 
	    document["ga_pc"].src      = g_ga_pc_ro.src; 
	    g_sparks.burst(240, 380);
	}
	else if (b == 10) { 
	    document["ga_ps2"].src     = g_ga_ps2_ro.src; 
	    g_sparks.burst(240, 400);
	}
	else if (b == 11) { 
	    document["ga_gba"].src     = g_ga_gba_ro.src; 
	    g_sparks.burst(240, 420);
	}
	else if (b == 12) { 
	    document["ga_symbian"].src = g_ga_symbian_ro.src; 
	    g_sparks.burst(240, 440);
	}
	else if (b == 13) { 
	    document["ga_web"].src     = g_ga_web_ro.src; 
	    g_sparks.burst(240, 460);
	}
	else if (b == 14) { 
	    document["ga_special"].src = g_ga_special_ro.src; 
	    g_sparks.burst(240, 480);
	}
	else if (b == 15) { 
            document["ga_bltmobile"].src  = g_ga_bltmobile_ro.src; 
	    g_sparks.burst(240, 500);
	}
	else if (b == 16) { 
	    document["ga_gambling"].src  = g_ga_gambling_ro.src; 
	    g_sparks.burst(240, 520);
	}
	else if (b == 17) { 
	    document["ga_art"].src  = g_ga_art_ro.src; 
	    g_sparks.burst(240, 540);
	}
    }
}
 

////////////////////////////////////////////////////////////////////////////////
// Over the button function
////////////////////////////////////////////////////////////////////////////////
function uB1(b) 
{
    if (document.images) 
    {
	if (b == 1)      { 
	    document["ga_latest"].src  = g_ga_latest.src; 
        }
 	else if (b == 2) { 
	    document["ga_dsi"].src     = g_ga_dsi.src; 
	}
	else if (b == 3) { 
	    document["ga_iphone"].src  = g_ga_iphone.src; 
	}
	else if (b == 4) { 
	    document["ga_wii"].src     = g_ga_wii.src; 
	}
	else if (b == 5) {
	    document["ga_nds"].src     = g_ga_nds.src; 
	}
	else if (b == 6) { 
	    document["ga_online"].src  = g_ga_online.src; 
	}
	else if (b == 7) { 
	    document["ga_mobile"].src  = g_ga_mobile.src; 
	}
	else if (b == 8) { 
	    document["ga_psp"].src     = g_ga_psp.src; 
	}
	else if (b == 9) { 
	    document["ga_pc"].src      = g_ga_pc.src; 
	}
	else if (b == 10) { 
	    document["ga_ps2"].src     = g_ga_ps2.src; 
	}
	else if (b == 11) { 
	    document["ga_gba"].src     = g_ga_gba.src; 
	}
	else if (b == 12) { 
	    document["ga_symbian"].src = g_ga_symbian.src; 
	}
	else if (b == 13) { 
	    document["ga_web"].src     = g_ga_web.src; 
	}
	else if (b == 14) { 
	    document["ga_special"].src = g_ga_special.src; 
	}
	else if (b == 15) { 
            document["ga_bltmobile"].src  = g_ga_bltmobile.src; 
	}
	else if (b == 16) { 
	    document["ga_gambling"].src  = g_ga_gambling.src; 
	}
	else if (b == 17) { 
	    document["ga_art"].src  = g_ga_art.src; 
	}
    }
}


//////////////////////////////////////////////////////////////////////////////
// Main initialization function
//////////////////////////////////////////////////////////////////////////////
function init(pageNo) 
{
    g_page = pageNo;
    canvas = document.getElementById("canvas");
    ctx = canvas.getContext("2d");
//    preload(pageNo);
    g_gameSelections = new OGameSelections();

  if (pageNo == 1) {
    g_scroller = new OScroller("newsReportL0", "newsReportL1", "newsReportL2", -22, -8, 0, false);
  }  
  if (pageNo == 2) {
      g_gameButtons = new OGameButtons(40, 10.1, 1.57, 0.3, 0.90, 180);
      g_sparks = new OParticleMgr2D(1.0, 0, 50, 50, 200.0, 10, 290, -100);
  }  
  if (pageNo == 3) {
      g_slideMMT     = new ODivSlideIn("travelApp",  0.4, 0.4, g_sparks, 190, 370);
      g_slideRabbit  = new ODivSlideIn("rabbitApp",  0.8, 0, g_sparks,   190, 520);
      g_slideChatter = new ODivSlideIn("chatterApp", 0.6, 1, g_sparks,   190, 670);
      g_slideMMG     = new ODivSlideIn("golfApp",    0.7, 2, g_sparks,   190, 820);
  }
  if (pageNo == 5) {
      g_folksDrew = new ODivFadeIn("DrewFisher", 0.5, 0);
      g_folksSandy = new ODivFadeIn("SandyPetersen", 0.5, 1);
      g_folksRob = new ODivFadeIn("RobLegg", 0.5, 2);
  }
  
  setInterval("draw()", 10);

}


//////////////////////////////////////////////////////////////////////////////
// Draw routine for main 
//////////////////////////////////////////////////////////////////////////////
function draw() 
{
    var timeDate = new Date();
    ms = timeDate.getMilliseconds();

    if (g_prevTime > ms) 
    {
	g_deltaTime = ((1000 - g_prevTime) + ms) * 0.001;
    }
    else
    {
	g_deltaTime = (ms - g_prevTime) * 0.001;
    }
    g_runningTime += g_deltaTime;
    g_prevTime = ms;
        
    // Scroll the news
    if (g_page== 1) 
    {
	g_scroller.Update(g_deltaTime);
    }
    
    if (g_page == 2) 
    {
	ctx.clearRect(0, 0, 1000, 1000);
	g_gameButtons.Update(g_runningTime);
	if (g_notMsIECrap)
	{
	    g_sparks.update(g_deltaTime);
	    g_sparks.render(ctx);
	}
	g_gameSelections.Update(0);
    }
    else if (g_page == 3) 
    {
	ctx.clearRect(0, 0, 1000, 1000);
	g_slideMMT.Update(g_deltaTime, ctx);
	g_slideChatter.Update(g_deltaTime, ctx);
	g_slideRabbit.Update(g_deltaTime, ctx);
	g_slideMMG.Update(g_deltaTime, ctx);

	var backGround = document.getElementById("backGround"); 
	backGround.style.backgroundPosition = g_xScrollGames + "px " + "0px";
	g_xScrollGames += 20.0 * g_deltaTime;
    }
    
    else if (g_page == 4) 
    {
	var right = document.getElementById("constructionStrip"); 
	right.style.backgroundPosition = g_xScrollGames*(-10) + "px " + "0px";
    }

    else if (g_page == 5) 
    {
      g_folksDrew.Update(g_deltaTime);
      g_folksSandy.Update(g_deltaTime);
      g_folksRob.Update(g_deltaTime);
    }
    
    // Scroll the lower strip
    if (g_page != 3) 
    {
	var right = document.getElementById("gameStrip"); 
	right.style.backgroundPosition = g_xScrollGames + "px " + "0px";
	g_xScrollGames += 20.0 * g_deltaTime;
    }
}



//////////////////////////////////////////////////////////////////////////////
// Preload all of the textures
//////////////////////////////////////////////////////////////////////////////
function preload(pageNo) 
{
    g_apps_homeImage0.src  = "images/apps_home.png";
    g_apps_homeImage1.src  = "images/apps_home_ro.png";
    g_apps_appsImage0.src  = "images/apps_apps.png";
    g_apps_appsImage1.src  = "images/apps_apps_ro.png";
    g_apps_gamesImage0.src = "images/apps_games.png";
    g_apps_gamesImage1.src = "images/apps_games_ro.png";
    g_apps_techImage0.src  = "images/apps_tech.png";
    g_apps_techImage1.src  = "images/apps_tech_ro.png";
    g_apps_folksImage0.src = "images/apps_folks.png";
    g_apps_folksImage1.src = "images/apps_folks_ro.png";
    g_apps_linksImage0.src = "images/apps_links.png";
    g_apps_linksImage1.src = "images/apps_links_ro.png";
    
    g_homeImage0.src  = "images/home.png";
    g_homeImage1.src  = "images/home_ro.png";
    g_appsImage0.src  = "images/apps.png";
    g_appsImage1.src  = "images/apps_ro.png";
    g_gamesImage0.src = "images/games.png";
    g_gamesImage1.src = "images/games_ro.png";
    g_techImage0.src  = "images/tech.png";
    g_techImage1.src  = "images/tech_ro.png";
    g_folksImage0.src = "images/folks.png";
    g_folksImage1.src = "images/folks_ro.png";
    g_linksImage0.src = "images/links.png";
    g_linksImage1.src = "images/links_ro.png";
    g_image1.src =    "images/links_ro.png";   
       
    g_ga_latest.src  = "buttons/plat_latest.jpg";
    g_ga_dsi.src     = "buttons/plat_dsi.jpg";
    g_ga_ps2.src     = "buttons/plat_ps2.jpg";
    g_ga_symbian.src = "buttons/plat_symbian.jpg";
    g_ga_mobile.src  = "buttons/plat_mobile.jpg";
    g_ga_special.src = "buttons/plat_special.jpg";
    g_ga_online.src  = "buttons/plat_online.jpg";
    g_ga_nds.src     = "buttons/plat_nds.jpg";
    g_ga_gba.src     = "buttons/plat_gba.jpg";
    g_ga_psp.src     = "buttons/plat_psp.jpg";
    g_ga_pc.src      = "buttons/plat_pc.jpg";
    g_ga_wii.src     = "buttons/plat_wii.jpg";
    g_ga_web.src     = "buttons/plat_web.jpg";
    g_ga_iphone.src  = "buttons/plat_iphone.jpg";
    g_ga_art.src     = "buttons/plat_art.jpg";
    g_ga_bltmobile.src = "buttons/plat_bltmobile.jpg";
    g_ga_gambling.src = "buttons/plat_gambling.jpg";

    g_ga_latest_ro.src = "buttons/plat_latest_ro.jpg";
    g_ga_dsi_ro.src    = "buttons/plat_dsi_ro.jpg";
    g_ga_ps2_ro.src    = "buttons/plat_ps2_ro.jpg";
    g_ga_symbian_ro.src = "buttons/plat_symbian_ro.jpg";
    g_ga_mobile_ro.src  = "buttons/plat_mobile_ro.jpg";
    g_ga_special_ro.src = "buttons/plat_special_ro.jpg";
    g_ga_online_ro.src  = "buttons/plat_online_ro.jpg";
    g_ga_nds_ro.src     = "buttons/plat_nds_ro.jpg";
    g_ga_gba_ro.src     = "buttons/plat_gba_ro.jpg";
    g_ga_psp_ro.src     = "buttons/plat_psp_ro.jpg";
    g_ga_pc_ro.src      = "buttons/plat_pc_ro.jpg";
    g_ga_wii_ro.src     = "buttons/plat_wii_ro.jpg";
    g_ga_web_ro.src     = "buttons/plat_web_ro.jpg";
    g_ga_iphone_ro.src  = "buttons/plat_iphone_ro.jpg";
    g_ga_art_ro.src       = "buttons/plat_art_ro.jpg";
    g_ga_bltmobile_ro.src = "buttons/plat_bltmobile_ro.jpg";
    g_ga_gambling_ro.src  = "buttons/plat_gambling_ro.jpg";






}



////////////////////////////////////////////////////////////////////////////////
/// move the game buttons
///
/// function OGameButtons(40, PI, 2, 0.99)
///
////////////////////////////////////////////////////////////////////////////////
function OGameButton(name, phase, xOffset)
{
    this.name  = name;
    this.phase = phase;
    this.xOffset = xOffset;
    
    this.Process = function(time, amp, freq) 
    { 
	var layer  = document.getElementById(this.name); 
	var offset = this.xOffset + (amp * Math.sin((time * freq) + this.phase));
	layer.style.left = offset + "px ";
    }
}


////////////////////////////////////////////////////////////////////////////////
/// move the game buttons
///
/// function OGameButtons(40, PI, 2, 0.99)
///
////////////////////////////////////////////////////////////////////////////////
function OGameButtons(amp, freq, phase, phaseDelta, fall, xOffset)
{
    this.amp        = amp;
    this.freq       = freq;
    this.fall       = fall;

    this.buttons0 = new OGameButton("C_latest", phase, xOffset);    phase = phase + phaseDelta;
    this.buttons1 = new OGameButton("C_dsi", phase, xOffset);       phase = phase + phaseDelta;
    this.buttons2 = new OGameButton("C_iphone", phase, xOffset);    phase = phase + phaseDelta;
    this.buttons3 = new OGameButton("C_wii", phase, xOffset);       phase = phase + phaseDelta;
    this.buttons4 = new OGameButton("C_nds", phase, xOffset);       phase = phase + phaseDelta;
    this.buttons5 = new OGameButton("C_online", phase, xOffset);    phase = phase + phaseDelta;
    this.buttons6 = new OGameButton("C_mobile", phase, xOffset);    phase = phase + phaseDelta;
    this.buttons7 = new OGameButton("C_psp", phase, xOffset);      phase = phase + phaseDelta;
    this.buttons8 = new OGameButton("C_pc", phase, xOffset);       phase = phase + phaseDelta;
    this.buttons9 = new OGameButton("C_ps2", phase, xOffset);      phase = phase + phaseDelta;
    this.buttons10 = new OGameButton("C_gba", phase, xOffset);      phase = phase + phaseDelta;
    this.buttons11 = new OGameButton("C_symbian", phase, xOffset);  phase = phase + phaseDelta;
    this.buttons12 = new OGameButton("C_web", phase, xOffset);       phase = phase + phaseDelta;
    this.buttons13 = new OGameButton("C_special", phase, xOffset);   phase = phase + phaseDelta;
    this.buttons14 = new OGameButton("C_bltmobile", phase, xOffset);phase = phase + phaseDelta;
    this.buttons15 = new OGameButton("C_gambling", phase, xOffset); phase = phase + phaseDelta;
    this.buttons16 = new OGameButton("C_art", phase, xOffset);       phase = phase + phaseDelta;
        
    this.Update = function(time) 
    { 
	if (this.amp <=0) return;
	
	this.buttons0.Process(time, this.amp, this.freq);
	this.buttons1.Process(time, this.amp, this.freq);
	this.buttons2.Process(time, this.amp, this.freq);
	this.buttons3.Process(time, this.amp, this.freq);
	this.buttons4.Process(time, this.amp, this.freq);
	this.buttons5.Process(time, this.amp, this.freq);
	this.buttons6.Process(time, this.amp, this.freq);
	this.buttons7.Process(time, this.amp, this.freq);
	this.buttons8.Process(time, this.amp, this.freq);
	this.buttons9.Process(time, this.amp, this.freq);
	this.buttons10.Process(time, this.amp, this.freq);
	this.buttons11.Process(time, this.amp, this.freq);
	this.buttons12.Process(time, this.amp, this.freq);
	this.buttons13.Process(time, this.amp, this.freq);
	this.buttons14.Process(time, this.amp, this.freq);
	this.buttons15.Process(time, this.amp, this.freq);
	this.buttons16.Process(time, this.amp, this.freq);
	this.amp = this.amp * this.fall;
    }
}


var WJS = {
  Version: 'Whiptail Javascript Lib 1.0',
  Extensions: {} 
};


WJS.Math = {};

WJS.Math.Transitions = {

    easeInQuad: function(pos){ return Math.pow(pos, 2); },

    easeOutQuad: function(pos){ return -(Math.pow((pos-1), 2) -1); },

    easeInOutQuad: function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,2); return -0.5 * ((pos-=2)*pos - 2);  },

    easeInCubic: function(pos){ return Math.pow(pos, 3); },

    easeOutCubic: function(pos){return (Math.pow((pos-1), 3) +1); },

    easeInOutCubic: function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,3); return 0.5 * (Math.pow((pos-2),3) + 2); },

    easeInQuart: function(pos){ return Math.pow(pos, 4); },

    easeOutQuart: function(pos){ return -(Math.pow((pos-1), 4) -1) },

    easeInOutQuart: function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4); return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2);  },

    easeInQuint: function(pos){ return Math.pow(pos, 5); },

    easeOutQuint: function(pos){ return (Math.pow((pos-1), 5) +1);  },

    easeInOutQuint: function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,5); return 0.5 * (Math.pow((pos-2),5) + 2);  },

    easeInSine: function(pos){ return -Math.cos(pos * (Math.PI/2)) + 1;  },

    easeOutSine: function(pos){ return Math.sin(pos * (Math.PI/2));  },

    easeInOutSine: function(pos){ return (-.5 * (Math.cos(Math.PI*pos) -1)); },

    easeInExpo: function(pos){ return (pos==0) ? 0 : Math.pow(2, 10 * (pos - 1)); },

    easeOutExpo: function(pos){ return (pos==1) ? 1 : -Math.pow(2, -10 * pos) + 1; },

    easeInBack: function(pos){ var s = 1.70158; return (pos)*pos*((s+1)*pos - s);  },

    easeOutBack: function(pos){ var s = 1.70158; return (pos=pos-1)*pos*((s+1)*pos + s) + 1; },

    easeInOutBack: function(pos){ var s = 1.70158; if((pos/=0.5) < 1) return 0.5*(pos*pos*(((s*=(1.525))+1)*pos -s)); return 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos +s) +2);  },

    elastic: function(pos) { return -1 * Math.pow(4,-8*pos) * Math.sin((pos*6-1)*(2*Math.PI)/2) + 1; },

    swingFromTo: function(pos) { var s = 1.70158; return ((pos/=0.5) < 1) ? 0.5*(pos*pos*(((s*=(1.525))+1)*pos - s)) : 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos + s) + 2);  },

    swingFrom: function(pos) { var s = 1.70158; return pos*pos*((s+1)*pos - s);  },

    swingTo: function(pos) { var s = 1.70158; return (pos-=1)*pos*((s+1)*pos + s) + 1;  },
    
    easeInCirc: function(pos){ return -(Math.sqrt(1 - (pos*pos)) - 1);  },

    easeOutCirc: function(pos){ return Math.sqrt(1 - Math.pow((pos-1), 2))  },

    easeInOutCirc: function(pos){ if((pos/=0.5) < 1) return -0.5 * (Math.sqrt(1 - pos*pos) - 1); return 0.5 * (Math.sqrt(1 - (pos-=2)*pos) + 1);  },

    easeFromTo: function(pos) { if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4);    return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2);  },
    
    easeFrom: function(pos) { return Math.pow(pos,4); },
  
    easeTo: function(pos) { return Math.pow(pos,0.25); },


    easeInOutExpo: function(pos){ if(pos==0) return 0; if(pos==1) return 1;
    if((pos/=0.5) < 1) return 0.5 * Math.pow(2,10 * (pos-1));
    return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
    },

    easeOutBounce: function(pos){
    if ((pos) < (1/2.75)) {
      return (7.5625*pos*pos);
    } else if (pos < (2/2.75)) {
      return (7.5625*(pos-=(1.5/2.75))*pos + .75);
    } else if (pos < (2.5/2.75)) {
      return (7.5625*(pos-=(2.25/2.75))*pos + .9375);
    } else {
      return (7.5625*(pos-=(2.625/2.75))*pos + .984375);
    }
  },

  bounce: function(pos) {
    if (pos < (1/2.75)) {
        return (7.5625*pos*pos);
    } else if (pos < (2/2.75)) {
        return (7.5625*(pos-=(1.5/2.75))*pos + .75);
    } else if (pos < (2.5/2.75)) {
        return (7.5625*(pos-=(2.25/2.75))*pos + .9375);
    } else {
        return (7.5625*(pos-=(2.625/2.75))*pos + .984375);
    }
  },
  
  bouncePast: function(pos) {
    if (pos < (1/2.75)) {
        return (7.5625*pos*pos);
    } else if (pos < (2/2.75)) {
        return 2 - (7.5625*(pos-=(1.5/2.75))*pos + .75);
    } else if (pos < (2.5/2.75)) {
        return 2 - (7.5625*(pos-=(2.25/2.75))*pos + .9375);
    } else {
        return 2 - (7.5625*(pos-=(2.625/2.75))*pos + .984375);
    }
  }
};



