var detectableWithVB	= false;
var pluginFound			= false;

function detectPlugin() {

	navigator.plugins.refresh( false );

	var pluginType = "application/vnd.igloader";
	var mimetype = navigator.mimeTypes[ pluginType ];

	if ( mimetype ) {
 
		if( mimetype.enabledPlugin && mimetype.type == pluginType ) {
			showPlugin();
		} else {
			getPlugin();
		}
		
		return;
	} 
	
	showPlugin();
	
}

function getPlugin() {

	var replace = document.getElementById( "igl_content" );
	
	var output = "";
	
	output = output + "<p>The latest igLoader plugin is required to play" + ig_gamename + "</p>";
	output = output + "<ol>";
	output = output + "<li class=\"big\"><strong>1</strong><img src=\"" + ig_gameicon + "\" width=\"70\" height=\"59\"/><p><strong><a href=\"/igloader/igLoader_setup.exe\">Get the latest igLoader plugin and Play " + ig_gamename + " Now!</a></strong></p></li>";
	output = output + "<li><strong>2</strong><p>Click run in the box that appears <img src=\"/images/bg_igloader_run.gif\" /></p></li>";
	output = output + "<li><strong>3</strong><p>After the download is finished, click <strong>\"Run\"</strong> again <img src=\"/images/bg_igloader_run.gif\" /></p></li>";
	output = output + "<li><strong>4</strong><p>All done. <a href=\"javascript:reloadPlugin();\">Now you can play your game. Enjoy!</a></p></li>";
	output = output + "</ol>";	
	output = output + "</div>";
	
	replace.innerHTML = output;

}

function showPlugin() {

	var replace = document.getElementById( "igl_content" );
	
	var output = "";
	
 	output = output + "<object classid='CLSID:D1548A26-B8F6-4e86-AE74-E7062CCC2E2A' ";
	output = output + "codebase='http://www.miniclip.com/igloader/igloader.CAB#Version=-1,-1,-1,-1' ";
	output = output + "width='" + ig_width + "' height='" + ig_height + "'>\n";
	output = output + "<param name='type' value='application/vnd.igloader' />\n";
	output = output + "<param name='pluginspage' value='http://igloader.com/download/igLoader_setup.exe' />\n";
	output = output + "<param name='width' value='" + ig_width + "' />\n";
	output = output + "<param name='height' value='" + ig_height + "' />\n";
	output = output + "<param name='config_url' value='" + ig_location + ".xml'/>\n";
	output = output + "<embed type='application/vnd.igloader' ";
	output = output + "pluginspage='http://igloader.com/download/igLoader_setup.exe' ";
	output = output + "pluginurl='http://igloader.com/download/igLoader_setup.exe' ";
	output = output + "width='" + ig_width + "' ";
	output = output + "height='" + ig_height + "' ";
	output = output + "config_url='" + ig_location + ".xml'>\n";
	output = output + "</embed>";
	output = output + "</object>";
	
	replace.innerHTML = output;
							
}

function reloadPlugin() {
	
	navigator.plugins.refresh( true );
	window.location.href = window.location.href;

}

detectPlugin();
