var file;
var ml =true;
var width = 615;
var height = 440;

var Type;

function getType(){
	var pattern = /(.*)\.(.*)$/gi;
	var arr = pattern.exec(file);
	return RegExp.$2;
}

function thisMovie(movieName) {
// IE and Netscape refer to the movie object differently.
// This function returns the appropriate syntax depending on the browser.
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[movieName]
} else {
return document.embeds[movieName]
}
}
function writeDirectMovie(src, id, width, height){
	var b  = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' ID=" + id + " WIDTH=" + width + " HEIGHT=" + height + ">";
	b += "<PARAM NAME=movie VALUE='"+ src +"'>\n";
	b += "<PARAM NAME=quality VALUE=\"high\">\n";
	b += "<param name=\"scale\" value=\"exactfit\">\n";
	b += "<EMBED id="+ id +" src='" + src + "' loop=false menu=false scale=exactfit WIDTH=" + width + " HEIGHT=" + height + " TYPE='application/x-shockwave-flash' PLUGINSPAGE='=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash'></EMBED></OBJECT>";
	document.write(b);
}
function makeFlashPlayer(src, id, width, height){
	var a = document.getElementById("game-area");	
	var b  = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' ID=" + id + " WIDTH=" + width + " HEIGHT=" + height + ">";
	b += "<PARAM NAME=movie VALUE='"+ src +"'>\n";
	b += "<PARAM NAME=quality VALUE=\"high\">\n";
	b += "<param name=\"scale\" value=\"exactfit\">\n";
	b += "<EMBED id="+ id +" src='" + src + "' loop=false menu=false scale=exactfit WIDTH=" + width + " HEIGHT=" + height + " TYPE='application/x-shockwave-flash' PLUGINSPAGE='=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash'></EMBED></OBJECT>";
	a.innerHTML = b;	
}
function makeDcrPlayer(src, id, width, height){	
	var a = document.getElementById("game-area");
	var b  = "<object classid='clsid:166B1BCA-3F9C-11CF-8075-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,0,0,0' ID=" + id + " WIDTH=" + width + " HEIGHT=" + height + ">\n";
	b += "<PARAM NAME=src VALUE='"+ src +"'>\n";
	b += "<param name=swStretchStyle value='fill'>\n";
	b += "<embed src='" + src + "' WIDTH=" + width + " HEIGHT=" + height + " swStretchStyle=\"fill\" type=\"application/x-director\" scale=\"exactfit\" pluginspage=\"http://www.macromedia.com/shockwave/download/\"></embed></object>\n";	
	a.innerHTML = b;
}
function loaded(){
		var c = 0;
		var d = thisMovie('flash');
		if (d){
			try{
				c = d.PercentLoaded();
			}catch(e){
				c = 0;
			}
		}
		document.getElementById('prog-bar').style.width = c + "%";
		if(c<100) {
			setTimeout(loaded,300);
		}else{
			var my_div = document.getElementById('percent');
			my_div.innerHTML='Oyun yüklenmiyorsa <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" target=\"_blank\"> Flash Player </a> kurmanız gerekiyor olabilir. Yüklemek için <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" target=\"_blank\"> tıklayın... </a> ';					
		}	
}

function writeSwf(fileVar){
	file = fileVar.substring(1,fileVar.length);
	Type = getType();
	switch(Type){
	case "dcr":
		makeDcrPlayer(file, "director", width, height);
		break;
	case "dir":
		makeDcrPlayer(file, "director", width, height);
		break;
	default:				
		makeFlashPlayer(file, "flash", width, height);		
		break;
	}	
}
function play(fileVar){
	file = fileVar.substring(1,fileVar.length);
	Type = getType();
	switch(Type){
	case "dcr":
		var my_div = document.getElementById('percent');
		my_div.innerHTML='Oyun yüklenmiyorsa <a href=\"http://www.adobe.com/shockwave/download/\" target=\"_blank\"> Macromedia Shockwave </a> kurmanız gerekiyor olabilir. Yüklemek için <a href=\"http://www.adobe.com/shockwave/download/\" target=\"_blank\"> tıklayın... </a> ';
		break;
	case "dir":
		var my_div = document.getElementById('percent');
		my_div.innerHTML='Oyun yüklenmiyorsa <a href=\"http://www.adobe.com/shockwave/download/\" target=\"_blank\"> Macromedia Shockwave </a> kurmanız gerekiyor olabilir. Yüklemek için <a href=\"http://www.adobe.com/shockwave/download/\" target=\"_blank\"> tıklayın... </a> ';
		break;
	default:					
		loaded();
		break;
	}	
}
