\n'
document.write(temp);
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var matchtowin = new Array(4);
var gameboard = new Array(4);
var newwin;
function launchwin(whichmovie)
{
var winurl;
var winname = "newindow";
var winfeatures = "height=160,width=180";
var top = (screen.availHeight/2)-80;
var left = (screen.availWidth/2)-90;
winurl = "../popups/" + whichmovie + ".html"
winfeatures += ",top=";
winfeatures += top;
winfeatures += ",left=";
winfeatures += left;
newwin = window.open(winurl,winname,winfeatures);
if(javascript_version > 1.0)
{
setTimeout('newwin.focus();',250);
}
}
function init(){
matchtowin[0] = new Array(4);
matchtowin[1] = new Array(4);
matchtowin[2] = new Array(4);
matchtowin[3] = new Array(4);
gameboard[0] = new Array(4);
gameboard[1] = new Array(4);
gameboard[2] = new Array(4);
gameboard[3] = new Array(4);
var beenthere= new Array(16);
for (x=0;x<16;++x){
beenthere[x]=0;
}
for (y=0;y<4;++y){
for (x=0;x<4;++x){
test=Math.round(Math.random()*15);
while (beenthere[test]!=0){
test=Math.round(Math.random()*15);
}
beenthere[test]=1;
gameboard[y][x]=test;
matchtowin[y][x]=y*4+x;
}
}
update();
}
function findx(piece){
var temp=0;
for (y=0;y<4;++y){
for (x=0;x<4;++x){
if (gameboard[y][x]==piece){
temp=x;
}
}
}
return temp;
}
function findy(piece){
var temp=0;
for (y=0;y<4;++y){
for (x=0;x<4;++x){
if (gameboard[y][x]==piece){
temp=y;
}
}
}
return temp;
}
function move(piece){
var tentObj = InternetExplorer ? tent : document.embeds[0];
var movex, movey, blankx, blanky, temp, dir=0;
movex=findx(piece);
movey=findy(piece);
blankx=findx(15);
blanky=findy(15);
if (movey>0){
if ((movex==blankx)&&(movey-1==blanky)){
dir=1;
}
}
if (movex>0){
if ((movex-1==blankx)&&(movey==blanky)){
dir=2;
}
}
if (movey<3){
if ((movex==blankx)&&(movey+1==blanky)){
dir=3;
}
}
if (movex<3){
if ((movex+1==blankx)&&(movey==blanky)){
dir=4;
}
}
if (dir!=0){
tentObj.TGotoFrame("/puzzle/"+movey+movex, (((piece+1)*100)/2 + (5*dir)));
tentObj.TPlay("/puzzle/"+movey+movex);
temp=gameboard[movey][movex]
gameboard[movey][movex]=gameboard[blanky][blankx];
gameboard[blanky][blankx]=temp;
}
}
function update(){
var tentObj = InternetExplorer ? tent : document.embeds[0];
for (y=0;y<4;++y){
for (x=0;x<4;++x){
tentObj.TGotoFrame("/puzzle/"+y+x, ((gameboard[y][x]+1)*100)/2);
}
}
}
function tent_DoFSCommand(command, args) {
var tentObj = InternetExplorer ? tent : document.embeds[0];
if (command=="slide"){
temp=parseInt(args);
move(temp);
}
if (command=="update"){
update();
}
if (command=="init"){
init();
}
}
function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset)
// set index of end of cookie value
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
return null;
}
}
function setCookie(name, value, expire) {
document.cookie = name + "=" + escape(value)
+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}
function chooseFrame(){
var value = getCookie("mwShells");
if(value == null){
PassFlash("1");
}else{
PassFlash("0");
}
}
function PassFlash(text){
window.document.movie.SetVariable("/:crap", text);
}
function cookieWrapper(){
var expdate = new Date()
expdate.setTime (expdate.getTime() + 60*1000)
setCookie("mwShells", 1, expdate);
}
//-->