//$.AjaxifyDebug = true;

var timer;
var numberTimer;

$(document).ready(function() {   
 
 adVisibility();
	
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
     //hide bar for iphone
	if (document.getElementById){
		var obj = document.getElementById('barcontainer');
		obj.style.display = "none";
	}


} else {

	menuFix();

}

});

function showGame(id){
	
	var game = new Array();
	var width = new Array();
	var height = new Array();
	
	game[1]="http://ninjakiwifiles.com/Games/gameswfs/bloonstd4.swf";
	width[1] = 640;
	height[1] = 640;
	
	game[2]="http://uwadb.com/games/bowman2.swf";
	width[2] = 718;
	height[2] = 535;
	
	game[3]="http://www.ninjakiwifiles.com/Games/gameswfs/desktoptdpro.swf";
	width[3] = 500;
	height[3] = 700;
	
	game[4]="http://www.freegames.ws/games/flash_games/helicopter_game/helicopter.swf";
	width[4] = 400;
	height[4] = 300;
	
	game[5]="http://uploads.ungrounded.net/404000/404612_Portal.swf";
	width[5] = 500;
	height[5] = 890;
	
	game[6]="http://www.freewebarcade4.com/media/thelaststand.swf";
	width[6] = 800;
	height[6] = 420;
	
	game[7]="http://armorgames.com/files/games/dolphin-olympics-2-2019.swf";
	width[7] = 640;
	height[7] = 480;
	
	game[8]="http://www.addictinggames.com/D78AQSAKQLQWI9/2159.swf";
	width[8] = 810;
	height[8] = 500;
	
	game[9]="http://www.addictinggames.com/D78AQSAKQLQWI9/2598.swf";
	width[9] = 792;
	height[9] = 600;
	
	game[10]="http://www.fasco-csc.com/works/crimson/crimson_room_e.swf";
	width[10] = 560;
	height[10] = 400;
	
	game[11]="http://www.eyezmaze.com/grow/cube/grow-cub.swf";
	width[11] = 550;
	height[11] = 400;
	
	game[12]="http://www.neave.com/games/get_game.php?swf=spaceinvaders";
	width[12] = 500;
	height[12] = 410;
		
	game[13]="http://www.silvergames.com/flash/99-bricks.swf";
	width[13] = 500;
	height[13] = 400;
	
	game[14]="http://srv2.victorygaming.com/defender2/index.swf";
	width[14] = 540;
	height[14] = 540;
	
	game[15]="http://www.freegaming.de/components/flash//TowerDefense.swf?affiliate_id=941efa0f97e566c4";
	width[15] = 800;
	height[15] = 543;
	
	game[16]="http://www.games.pixelshocks.com/games/td2/ptdii.swf";
	width[16] = 550;
	height[16] = 950;
	
	game[18]="http://armorgames.com//files/games/gemcraft-1716.swf";
	width[18] = 640;
	height[18] = 480;
		
	game[19]="http://www.gamesvine.com/games/AntiTD.swf";
	width[19] = 590;
	height[19] = 700;
		
	game[20]="http://www.ferryhalim.com/orisinal/g3/00bells.swf";
	width[20] = 750;
	height[20] = 500;
		
	game[21]="http://www.pixeljam.com/dinorun/dinorun.swf";
	width[21] = 801;
	height[21] = 450;
			
	game[22]="http://www.2flashgames.com/2fgkjn134kjlh1cfn81vc34/flash/f-Vector-Runner-7260.swf";
	width[22] = 640;
	height[22] = 480;
			
	game[23]="http://www.nekogames.jp/shockwave/cursor10.swf";
	width[23] = 550;
	height[23] = 400;
			
	game[24]="http://www.vectorpark.com/levers/LeversGame.swf";
	width[24] = 620;
	height[24] = 500;
			
	game[25]="http://www.ferryhalim.com/orisinal/g3/00pig.swf";
	width[25] = 500;
	height[25] = 500;			
	
	game[26]="http://www.gamedesign.jp/flash/chatnoir/chatnoir.swf";
	width[26] = 600;
	height[26] = 480;
	
	game[27]="http://cache.armorgames.com/files/games/pirate-defense-3593.swf";
	width[27] = 600;
	height[27] = 650;
	
	game[28]="http://games.mochiads.com/c/g/loops-of-zen/loops_of_zen.swf";
	width[28] = 500;
	height[28] = 500; //FUCK YOU THIS IS HORRIBLE
	
	game[29]="http://uwadb.com/games/bridge.swf";
	width[29] = 800;
	height[29] = 550;
	
	game[30]="http://regretfulmorning.com/wp-content/uploads/2008/11/splitter.swf";
	width[30] = 640;
	height[30] = 480;
	
	game[31]="http://www.channel4.com/microsites/G/TGSR/prog-swfs/thegreatspermrace.swf";
	width[31] = 620;
	height[31] = 500;
	
	game[32]="http://games.engineering.com/icebreaker/icebreaker.swf";
	width[32] = 550;
	height[32] = 420;
	
	game[33]="http://games.engineering.com/icebreaker2/icebreaker2.swf";
	width[33] = 550;
	height[33] = 420;
	
	game[34]="http://games.mochiads.com/c/g/onslaught-2_1/Onslaught2.1_ma.swf";
	width[34] = 720;
	height[34] = 550; //jk lol <3
	
	game[35]="http://media1.thegamehomepage.com/swf/rr1.swf";
	width[35] = 640;
	height[35] = 480;
	
	game[36]="http://games.komix-games.com/seed.swf";
	width[36] = 825;
	height[36] = 600;
	
	game[37]="http://uwadb.com/games/robot.swf";
	width[37] = 640;
	height[37] = 480;
	
	
	
	
	if(game[id]){
		//embed flash
		swfobject.embedSWF(game[id], "gamediv", width[id], height[id], "9.0.0");
		//show modal
		$("#gamediv").modal();
		//get container
		var gameContainer = document.getElementById('simplemodal-container');
		//resize div
		gameContainer.style.width = width[id] + 'px';
		gameContainer.style.height = height[id] + 'px';
		//trigger resize modal
		$(window).trigger('resize.simplemodal');
	}
	
}

function menuFix(){
    var gamewindow = document.getElementById('gamemenu');

	if (window.innerHeight < 630) {
		gamewindow.style.height = (window.innerHeight - 70) + "px";
		gamewindow.style.overflowY = "scroll";
		gamewindow.style.overflowX = "hidden";
	} else {
		gamewindow.style.height = "";
		gamewindow.style.overflowY = "";
		gamewindow.style.overflowX = "";
	}
}

function adVisibility(){
	$().ajaxify({
		link:'http://uwadb.com/chat/showad.php',
		target: '#adshow',
		method:'POST',
		loading_img:'http://uwadb.com/chat/loading.gif',
		loading_target:'#hidden',
		event:false,

		onSuccess:function(options,data){

			if (document.getElementById){
			var adsetting = document.getElementById('adshow');

				if(adsetting.innerHTML == "show"){
					var adbox = document.getElementById('guestadboxtop');
					adbox.style.display = "";					
				}
			}		
		}
	});
}

//scroll fix for IE
window.onload = function ()
		{
			if(document.all) {
				var codeFix = document.all.tags("div");
				for (var codeI = 0; codeI < codeFix.length; codeI++)
				{
					if (codeFix[codeI].className == "scroll" && (codeFix[codeI].scrollWidth > codeFix[codeI].clientWidth || codeFix[codeI].clientWidth == 0))
					codeFix[codeI].style.height = (codeFix[codeI].clientHeight + 34) + "px";
				}
			}
		}

