/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.3
*/
var FlashDetect = new function(){
	var self = this;
	self.installed = false;
	self.raw = "";
	self.major = -1;
	self.minor = -1;
	self.revision = -1;
	self.revisionStr = "";
	var activeXDetectRules = [
		{
			"name":"ShockwaveFlash.ShockwaveFlash.7",
			"version":function(obj){
				return getActiveXVersion(obj);
			}
		},
		{
			"name":"ShockwaveFlash.ShockwaveFlash.6",
			"version":function(obj){
				var version = "6,0,21";
				try{
					obj.AllowScriptAccess = "always";
					version = getActiveXVersion(obj);
				}catch(err){}
				return version;
			}
		},
		{
			"name":"ShockwaveFlash.ShockwaveFlash",
			"version":function(obj){
				return getActiveXVersion(obj);
			}
		}
	];
	var getActiveXVersion = function(activeXObj){
		var version = -1;
		try{
			version = activeXObj.GetVariable("$version");
		}catch(err){}
		return version;
	};
	var getActiveXObject = function(name){
		var obj = -1;
		try{
			obj = new ActiveXObject(name);
		}catch(err){}
		return obj;
	};
	var parseActiveXVersion = function(str){
		var versionArray = str.split(",");//replace with regex
		return {
			"raw":str,
			"major":parseInt(versionArray[0].split(" ")[1], 10),
			"minor":parseInt(versionArray[1], 10),
			"revision":parseInt(versionArray[2], 10),
			"revisionStr":versionArray[2]
		};
	};
	var parseStandardVersion = function(str){
		var descParts = str.split(/ +/);
		var majorMinor = descParts[2].split(/\./);
		var revisionStr = descParts[3];
		return {
			"raw":str,
			"major":parseInt(majorMinor[0], 10),
			"minor":parseInt(majorMinor[1], 10), 
			"revisionStr":revisionStr,
			"revision":parseRevisionStrToInt(revisionStr)
		};
	};
	var parseRevisionStrToInt = function(str){
		return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
	};
	self.majorAtLeast = function(version){
		return self.major >= version;
	};
	self.FlashDetect = function(){
		if(navigator.plugins && navigator.plugins.length>0){
			var type = 'application/x-shockwave-flash';
			var mimeTypes = navigator.mimeTypes;
			if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
				var version = mimeTypes[type].enabledPlugin.description;
				var versionObj = parseStandardVersion(version);
				self.raw = versionObj.raw;
				self.major = versionObj.major;
				self.minor = versionObj.minor; 
				self.revisionStr = versionObj.revisionStr;
				self.revision = versionObj.revision;
				self.installed = true;
			}
		}else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
			var version = -1;
			for(var i=0; i<activeXDetectRules.length && version==-1; i++){
				var obj = getActiveXObject(activeXDetectRules[i].name);
				if(typeof obj == "object"){
					self.installed = true;
					version = activeXDetectRules[i].version(obj);
					if(version!=-1){
						var versionObj = parseActiveXVersion(version);
						self.raw = versionObj.raw;
						self.major = versionObj.major;
						self.minor = versionObj.minor; 
						self.revision = versionObj.revision;
						self.revisionStr = versionObj.revisionStr;
					}
				}
			}
		}
	}();
};
FlashDetect.release = "1.0.3";

function FlashWrite(nameFlash) {
	if (FlashDetect.installed) {
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="900" height="290" id="flash" ALIGN="">');
		document.write('<PARAM NAME="movie" VALUE="/content/flash/'+nameFlash+'.swf"/>');
		document.write('<PARAM NAME="quality" VALUE="high"/>');
		document.write('<PARAM NAME="bgcolor" VALUE="#ffffff"/>');
		document.write('<PARAM NAME="wmode" VALUE="transparent"/>');
		document.write('<PARAM NAME="menu" VALUE="false"/>');
		document.write('<PARAM NAME="loop" VALUE="true"/>');
		document.write('<EMBED src="/content/flash/'+nameFlash+'.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="900" height="290" NAME="flash" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
		document.write('</OBJECT>');
	} else {
		document.write('<img class="homeFlash" src="/content/img/no-script-' + nameFlash + '.jpg" alt="" width="900" height="290" alt="" />');
	}
}




function FlashHome(nameFlash) {
	if (FlashDetect.installed) {
		document.write('<OBJECT  class="homeFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="910" height="430" id="flash" ALIGN="">');
		document.write('<PARAM NAME="movie" VALUE="/content/flash/'+nameFlash+'"/>');
		document.write('<PARAM NAME="quality" VALUE="high"/>');
		document.write('<PARAM NAME="bgcolor" VALUE="#ffffff"/>');
		document.write('<PARAM NAME="wmode" VALUE="transparent"/>');
		document.write('<PARAM NAME="menu" VALUE="false"/>');
		document.write('<PARAM NAME="loop" VALUE="true"/>');
		document.write('<EMBED class="homeFlash" src="/content/flash/'+nameFlash+'" wmode="transparent" quality="high" bgcolor="#ffffff" width="910" height="430" NAME="flash" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
		document.write('</OBJECT>');
	} 
	else {
		document.write('<img class="homeFlash" src="/content/img/home-no-flash.jpg" alt="Úvodní animace"  />');
	}
}


function FlashReference2(nameFlash) {
	if (FlashDetect.installed) {
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="850" height="500" id="flash" ALIGN="">');
		document.write('<PARAM NAME="movie" VALUE="/content/flash/'+nameFlash+'"/>');
		document.write('<PARAM NAME="quality" VALUE="high"/>');
		document.write('<PARAM NAME="bgcolor" VALUE="#ffffff"/>');
		document.write('<PARAM NAME="wmode" VALUE="transparent"/>');
		document.write('<PARAM NAME="menu" VALUE="false"/>');
		document.write('<PARAM NAME="loop" VALUE="true"/>');
		document.write('<EMBED style="margin-left: 40px;" src="/content/flash/'+nameFlash+'" wmode="transparent" quality="high" bgcolor="#ffffff" width="850" height="500" NAME="flash" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
		document.write('</OBJECT>');
	}
	else {
		document.write('<img src="/content/img/no-script-reference-main.jpg" alt="Reference" style="margin: 4px 0px 0px 0px" />');
	}
}


function FlashONas() {
	if (FlashDetect.installed) {
		document.getElementById('vimeo').innerHTML = '<object width="860" height="494"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5334860&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=59a5d1&amp;fullscreen=1&autoplay=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5334860&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=59a5d1&amp;fullscreen=1&autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="860" height="494"></embed></object>';
	}
	else {
		window.open('http://vimeo.com/5334860', '_blank')
	}
}
