/****
 * JS for Public Vision
 * Author: Mario Diaz @ mario-diaz.com
 * Created: 2010-04-08
 ****/

//
var bLangSelectShown = false;
var bJScrollerActive = false;

var iScrollWidth = 8;

var bMsie = (document.all) ? true : false;
var bIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;


// startup actions
$(document).ready(function() {

	checkJqueryScrollerInit ();
	
	// magazines: if set then display first:
	if (iIdShowMag > 0) {
		showMag(iIdShowMag);
	}
	
	// slideshow?
	if (document.getElementById('slideshow')) {
		$('#slideshow').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}
	
	// vodcasts: First?
	if (iVodcast > 0) {
		loadVideo(iVodcast, false);
	}
	/*
	if (bIE6) {
		if (document.getElementById('overlay')) {
			document.getElementById('container').style.marginTop = '120px';
		}
	}*/
	
	// news on video site shows news of media. Problem: If news at top is clicked on video site then we should stay there
	// so this little helper
	sTmp = document.URL;
	if (sTmp.indexOf('shownews') != -1) {
		iPos = sTmp.indexOf('shownews');
		sTmp = sTmp.substr(iPos);
		aTmp = sTmp.split('=');
		iUid = parseInt(aTmp[1]);
		//alert(iUid);
		showNewsItem(iUid, '');
	}
});


/**
 * checks if jquery scroller must be initialized
 * @return void
 */
function checkJqueryScrollerInit () {
	if (document.getElementById('text_short')) {
		if (bJScrollerActive) {
			$('#text_short').jScrollPaneRemove();
			oLayer.style.height = 'auto';
		}
		oLayer = document.getElementById('text_short');
		if (oLayer.offsetHeight > 112) {
			$(function() {
				oLayer.style.height = '112px';
				$('#text_short').jScrollPane({showArrows:false,scrollbarWidth:iScrollWidth});
				bJScrollerActive = true;
			});
		}
		//oLayer.style.outline = '0';
	} else if (document.getElementById('just_cotent')) {
		oLayer = document.getElementById('just_cotent');
		if (oLayer.offsetHeight > 267) {
			$(function() {
				oLayer.style.height = '267px';
				$('#just_cotent').jScrollPane({showArrows:false,scrollbarWidth:iScrollWidth});
				bJScrollerActive = true;
			});
		}
	} else if (document.getElementById('text_standard')) {
		oLayer = document.getElementById('text_standard');
		if (oLayer.offsetHeight > 224) {
			$(function() {
				oLayer.style.height = '224px';
				$('#text_standard').jScrollPane({showArrows:false,scrollbarWidth:iScrollWidth});
				bJScrollerActive = true;
			});
		}
	}
}


/**
 * positions the lang select layer and changes its display. It bottom then position it above caller button 
 * @return void
 */
function changeDisplayLangSelect () {
	if (document.getElementById('lang_select_layer')) {
		bLangSelectShown = !bLangSelectShown;
		if (bLangSelectShown) {
			oLayer = document.getElementById('lang_select_layer');
			oCaller = document.getElementById('lang_select_caller');
			aTmp = findPos(oCaller);
			oLayer.style.left = (aTmp[0] + 6) + 'px';
			oLayer.style.top = (aTmp[1] + oCaller.offsetHeight + 2) + 'px';
			oLayer.style.visibility = 'visible';
		} else {
			oLayer.style.visibility = 'hidden';
		}
	}
}


/**
 * finds position of element
 * @param object obj
 * @return int array
 */
function findPos (obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft, curtop];
}


/**
 * shows content in overlay layer (news, sitemap etc)
 * @param string sHtmlId (which content to show)
 * @return void
 */
function showContentInOverlay (sHtmlId) {
	document.getElementById('overlay').style.display = 'inline';
	oContent = document.getElementById('content_overlay');
	oContainer = document.getElementById('container');
	oContent.style.display = 'inline';
	aTmp = findPos(oContainer);
	oContent.style.left = (aTmp[0] + (oContainer.offsetWidth - oContent.offsetWidth) / 2) + 'px';
	oContent.style.top = (aTmp[1] + (oContainer.offsetHeight - oContent.offsetHeight) / 2) + 'px';
	// close button:
	oContent.innerHTML = '<div id="overlay_close"><a href="#" onclick="hideOverlay(); return false;"><img src="fileadmin/Layouts/images/close_button.png" alt="" /></a></div>';
	if (sHtmlId == 'sitemap' && bIE6) {
		document.getElementById('overlay_close').style.right = '27px';
	}
	oContent.innerHTML += document.getElementById(sHtmlId).innerHTML;
}


/**
 * hides overlay layers
 * @return void
 */
function hideOverlay () {
	document.getElementById('content_overlay').style.display = 'none';
	document.getElementById('overlay').style.display = 'none';
	if (document.getElementById('news_row_0')) {
		document.getElementById('news_row_0').className = 'news_row';
	}
}


// *** news vars and functions ***********************************************************************************************
var aNewsItems = new Array();
var iNewsItemActive = -1;


/**
 * shows news item in main content
 * @param int iId
 * @param string sArea
 * @return void
 */
function showNewsItem (iId, sArea, iNum) {
	if (aNewsItems[iId]) {
		iNewsItemActive = iId;
		if (aNewsItems[iId][3] == '') aNewsItems[iId][3] = '&nbsp;';
		if (sArea == '') {
			document.getElementById('headline').innerHTML = '<h1>' + aNewsItems[iId][2] + '</h1>';
			document.getElementById('subheadline').innerHTML = '<h2>' + aNewsItems[iId][3] + '</h2>';
			document.getElementById('text_short').innerHTML = aNewsItems[iId][4];
			checkJqueryScrollerInit();
			
			for (iUid in aNewsItems) {
				if (document.getElementById('news_row_' + iUid)) {
					document.getElementById('news_row_' + iUid).className = (iId != iUid) ? 'news_row' : 'news_row bold_9';
				}
			}
			document.getElementById('news_row_0').className = 'news_row';
		} else {
			document.getElementById(sArea + '_headline').innerHTML = '<h1>' + aNewsItems[iId][2] + '</h1>';
			document.getElementById(sArea + '_subheadline').innerHTML = '<h2>' + aNewsItems[iId][3] + '</h2>';
			document.getElementById(sArea + '_text').innerHTML = aNewsItems[iId][4];
			checkJqueryScroller('news_large_right_text', 340);
			
			iCounter = 0;
			while (document.getElementById('news_large_' + iCounter)) {
				if (iCounter == iNum) {
					document.getElementById('news_large_' + iCounter).className = 'news_row bold_9';
				} else {
					sTmp = document.getElementById('news_large_' + iCounter).className;
					sNew = sTmp.indexOf('dn') != -1 ? 'news_row dn' : 'news_row';
					document.getElementById('news_large_' + iCounter).className = sNew;
				}
				iCounter++;
			}
		}
	} 
}


/**
 * shows further news
 * @return void
 */
function showFurtherNews () {
	iNewsItemActive = 0;
	showContentInOverlay('news_large_content');
	
	for (iUid in aNewsItems) {
		if (document.getElementById('news_row_' + iUid)) 
			document.getElementById('news_row_' + iUid).className = 'news_row';
	}
	document.getElementById('news_row_0').className = 'news_row bold_9';
}


/**
 * paging news large layer (by 21 items)
 * @param int iStartAt
 * @return void
 */
function pagingNewsLarge (iStartAt) {
	if (document.getElementById('news_large_' + iStartAt)) {
		iDiff = 21;
		iCounter = 0;
		while (document.getElementById('news_large_' + iCounter)) {
			if (iCounter < iStartAt || iCounter >= iStartAt + iDiff) {
				document.getElementById('news_large_' + iCounter).style.display = 'none';
			} else {
				document.getElementById('news_large_' + iCounter).style.display = 'block';
			}
			iCounter++;
		}
		iPagingCurrent = iStartAt;
		checkPagingActive();
	}
}


var iPagingCurrent = 0;


/**
 * pages news by iDiff items
 * @param int iDiff
 * @return void
 */
function pagingNews (iDiff) {
	iPagingCurrent += iDiff;
	if (iPagingCurrent < 0) iPagingCurrent = 0;
	pagingNewsLarge (iPagingCurrent);
}


/**
 * colors paging items 
 * @return void
 */
function checkPagingActive () {
	iDiff = 21;
	iCounter = 0;
	while (document.getElementById('paging_' + (iCounter * iDiff))) {
		if (iPagingCurrent == iCounter * iDiff) {
			document.getElementById('paging_' + (iCounter * iDiff)).style.color = '#666';
		} else {
			document.getElementById('paging_' + (iCounter * iDiff)).style.color = '#b1b3b4';
		}
		iCounter++;
	}
}


var bJScrollerActiveLarge = false;


/**
 * checks if jquery scroller must be initialized
 * @return void
 */
function checkJqueryScroller (sHtmlId, iHeight) {
	if (document.getElementById(sHtmlId)) {
		if (bJScrollerActiveLarge) {
			$('#' + sHtmlId).jScrollPaneRemove();
			oLayer.style.height = 'auto';
		}
		oLayer = document.getElementById(sHtmlId);
		iHeight -= 11;
		if (oLayer.offsetHeight > iHeight) {
			$(function() {
				oLayer.style.height = iHeight + 'px';
				$('#' + sHtmlId).jScrollPane({showArrows:false,scrollbarWidth:iScrollWidth});
				bJScrollerActiveLarge = true;
			});
		}
	}
}


/* *** team members **************************************************+***** */
var aTeamMembers = new Array();


/**
 * shows team member in main content. Mark active bold
 * @param int iId
 * @return void
 */
function showTeamMember (iId) {
	if (aTeamMembers[iId]) {
		document.getElementById('headline').innerHTML = '<h1>' + aTeamMembers[iId][0] + '</h1>';
		document.getElementById('subheadline').innerHTML = '<h2>' + aTeamMembers[iId][1] + '</h2>';
		document.getElementById('text_short').innerHTML = aTeamMembers[iId][2];
		checkJqueryScrollerInit();
		// mark bold
		for (iUid in aTeamMembers) {
			//document.getElementById('tm_caller_' + iUid).style.fontWeight = (iId != iUid) ? 'normal' : 'bold';
			document.getElementById('tm_caller_' + iUid).className = (iId != iUid) ? 'arrow_grey' : 'arrow_grey bold';
		}
		//iTeamMemberActive = iId;
		document.getElementById('left_content').innerHTML = "<img src='" + aTeamMembers[iId][3] + "' alt='' />";
	}
}


/* *** magazines ********************************************************* */
var aMags = new Array();
var iIdShowMag = -1;


/**
 * shows magazine img in img field (left bottom). Mark active bold
 * @param int iId
 * @return void
 */
function showMag (iId) {
	if (aMags[iId]) {
		// mark bold
		document.getElementById('left_content').innerHTML = "<img src='" + aMags[iId] + "' alt='' />";
		for (iUid in aMags) {
			document.getElementById('mag_caller_' + iUid).className = (iId != iUid) ? 'arrow_grey' : 'arrow_grey bold';
		}
	}
}


/* *** google maps ******************************************************************** */
/**
 * shows google maps address
 * @param string address
 * @param string info
 * @return void
 */
function showAddress (address, info) {
	geocoder.getLatLng(address,
						function (point) {
							if (!point) {
								alert("Could not find postcode " + address);
							} else {
								oMap.setCenter(point, 13);
								var marker = new GMarker(point);
								oMap.addOverlay(marker);
								marker.openInfoWindowHtml(info);
							}
						}
	);
}



/* *** statements ************************************************************************** */
var aStatements = new Array();


/**
 * shows news item in main content
 * @param int iId
 * @param string sArea
 * @return void
 */
function showStatement (iId) {
	if (aStatements[iId]) {
		if (aStatements[iId][3] == '') aStatements[iId][3] = '&nbsp;';
		document.getElementById('headline').innerHTML = '<h1>' + aStatements[iId][2] + '</h1>';
		document.getElementById('subheadline').innerHTML = '<h2>' + aStatements[iId][3] + '</h2>';
		document.getElementById('text_short').innerHTML = aStatements[iId][4];
		checkJqueryScrollerInit();
		for (iUid in aStatements) {
			document.getElementById('statement_caller_' + iUid).className = (iId != iUid) ? 'arrow_grey' : 'arrow_grey bold';
		}
		if (aStatements[iId][5] != '') {
			document.getElementById('left_content').innerHTML = "<img src='" + aStatements[iId][5] + "' alt='' />";
		}
	}
}


/* *** video or swf or image show ************************************************************ */
/* multi array for data:
 * Items with:
 * string sType
 * string sUrl
 * string sText
 * string sImages
 */
var aVideos = new Array();


// vodcasts: First should be displayed directly -> see startup actions above
var iVodcast = -1;

// if iphone then show mp4 file if selected:
var sMp4 = '';


/**
 * gets absolute url for flash (flash needs it for loading flvs)
 * @return string
 */
function getBaseHref () {
	sTmp = document.URL;
	return sTmp.indexOf('relaunch_2010') != -1 ? 'http://www.public-vision.de/relaunch_2010/' : 'http://www.public-vision.de/';
}


/**
 * calls actions for loading video (flv), swf or image show
 * use swfobjects
 * flash handles whatever it gets
 * @param int iId
 * @param bool bStartDirectly
 * @return bool
 */
function loadVideo (iId, bStartDirectly) {
	/* test
	if (aVideos[iId]) {	
		if (aVideos[iId][5] != '') {
			alert(aVideos[iId][5]);
			checkForIphone(aVideos[iId][5]);
			return false;
		}
	}*/
	
	if (!FlashDetect.versionAtLeast(10)) {
		if (aVideos[iId]) {
			checkForIphone(aVideos[iId][5]);
		}
		return false;
	}
	if (aVideos[iId]) {
		oLayer = document.getElementById('left_content');
		
		if (aVideos[iId][0] == 'single_img') {
			oLayer.innerHTML = '<img src="' + aVideos[iId][3] + '" alt="" />';
			return true;
		}
		
		sBaseHref = getBaseHref();
		sSwf = 'fileadmin/flash_video_player/flash_video_player.swf';
		sFlashVars = 'sType=' + aVideos[iId][0] + '&sUrl=' + sBaseHref + aVideos[iId][1] + '&sText=' + aVideos[iId][2] + '&sImages=' + aVideos[iId][3] + '&sBaseHref=' + sBaseHref + '&bStartDirectly=' + (bStartDirectly ? 1 : 0);
		//alert(sFlashVars);
		sContent = '<object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" width="473" height="267" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=10,0,0,0">';
		sContent += '<param name="movie" value="' + sSwf + '">';
		sContent += '<param name="quality" value="high">';
		sContent += '<param name="scale" value="exactfit">';
		sContent += '<param name="menu" value="false">';
		sContent += '<param name="bgcolor" value="#ffffff">';
		sContent += '<param name="allowFullscreen" value="true">';
		sContent += '<param name="FlashVars" value="' + sFlashVars + '">';
		sContent += '<param name="wmode" value="transparent">';
		sContent += '<embed src="' + sSwf + '" quality="high" scale="exactfit" menu="false" ';
		sContent += 'bgcolor="#ffffff" width="473" height="267" swLiveConnect="false" FlashVars="' + sFlashVars + '" ';
		sContent += 'type="application/x-shockwave-flash" allowFullscreen="true" wmode="transparent" ';
		sContent += 'pluginspage="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">';
		sContent += '</embed>';
		sContent += '</object>';
		oLayer.innerHTML = sContent;
		return true;
	}
	return false;
}


/**
 * loads video directly by string parameters
 * @param string sType
 * @param string sUrl
 * @param string sText
 * @param string sImages
 * @param bool bStartDirectly
 * @param bool bLarge
 * @return bool
 */
function loadVideoDirectly (sType, sUrl, sText, sImages, bStartDirectly, bLarge) {
	
	if (!FlashDetect.versionAtLeast(10)) {
		checkForIphone (sMp4);
		return false;
	}
	/*
	sMp4 = 'fileadmin/Medien/test_iphone.mp4';
	if (sMp4 != '') {
		checkForIphone (sMp4);
		return false;
	}*/
	
	//if (bLarge) alert('large');
	oLayer = bLarge ? document.getElementById('doorpage_img') : document.getElementById('left_content');
	
	iWidth = bLarge ? 938 : 473;
	iHeight = bLarge ? 249 : 267;
	sWmode = bLarge ? '' : '<param name="wmode" value="transparent">';
	sWmodeEmbed = bLarge ? '' : ' wmode="transparent"';
	sBaseHref = getBaseHref();
	sSwf = 'fileadmin/flash_video_player/flash_video_player.swf';
	sFlashVars = 'sType=' + sType + '&sUrl=' + sBaseHref + sUrl + '&sText=' + sText + '&sImages=' + sImages + '&sBaseHref=' + sBaseHref + '&bStartDirectly=' + (bStartDirectly ? 1 : 0);
	//alert(sFlashVars);
	sContent = '<object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + iWidth + '" height="' + iHeight + '" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=10,0,0,0">';
	sContent += '<param name="movie" value="' + sSwf + '">';
	sContent += '<param name="quality" value="high">';
	sContent += '<param name="scale" value="exactfit">';
	sContent += '<param name="menu" value="false">';
	sContent += '<param name="bgcolor" value="#ffffff">';
	sContent += '<param name="allowFullscreen" value="true">' + sWmode;
	sContent += '<param name="FlashVars" value="' + sFlashVars + '">';
	sContent += '<embed src="' + sSwf + '" quality="high" scale="exactfit" menu="false" ';
	sContent += 'bgcolor="#ffffff" width="' + iWidth + '" height="' + iHeight + '" swLiveConnect="false" FlashVars="' + sFlashVars + '" ';
	sContent += 'type="application/x-shockwave-flash" allowFullscreen="true"' + sWmodeEmbed + ' ';
	sContent += 'pluginspage="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">';
	sContent += '</embed>';
	sContent += '</object>';
	oLayer.innerHTML = sContent;
	return true;
}


/**
 * checks if iphone and mp4 file selected. If so then display it
 * @param string sVideo
 * @return bool
 */
function checkForIphone (sVideo) {
	var sUserAgent = navigator.userAgent;
	if (sUserAgent.indexOf("iPhone") > 0) {	
		sVideo = getBaseHref() + sVideo;
		//alert(sVideo);
		//document.getElementById('left_content').innerHTML = '';
		
		sContent = '<video id="movie" width="320" height="240" autoplay="autoplay" preload="none" controls="controls">';
		sContent += '<source src="' + sVideo + '" type="video/mp4" />';
		sContent += '</video>';
		
		/*
		sContent = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
		sContent += 'CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" WIDTH="473" HEIGHT="267" >';
		sContent += '<PARAM NAME="src" VALUE="' + sVideo + '" >';
		sContent += '<PARAM NAME="autoplay" VALUE="true" >';
		sContent += '<PARAM name="CONTROLLER" VALUE="true">';
		sContent += '<EMBED SRC="' + sVideo + '" TYPE="image/x-macpaint" ';
		sContent += 'PLUGINSPAGE="http://www.apple.com/quicktime/download" WIDTH="473" HEIGHT="267" AUTOPLAY="true" CONTROLLER="true"></EMBED>';
		sContent += '</OBJECT>';
		*/
		
		
		document.getElementById('left_content').innerHTML = sContent;
		return true;
		
	}
	return false;
}


/* *** contacts stuff *** */
/**
 * @param string sHeadline
 * @param string sSubheadline
 * @param string sText
 * @return void
 */
function showContentMain (sHeadline, sSubheadline, sText) {
	document.getElementById('headline').innerHTML = '<h1>' + sHeadline + '</h1>';
	document.getElementById('subheadline').innerHTML = '<h2>' + sSubheadline + '</h2>';
	document.getElementById('text_short').innerHTML = sText;
	checkJqueryScrollerInit();
}


/* *** flash detection ******************************************************************************************** */
/*
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.4
*/
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);
            }
        }
    ];
    /**
     * Extract the ActiveX version of the plugin.
     * 
     * @param {Object} The flash ActiveX object.
     * @type String
     */
    var getActiveXVersion = function(activeXObj){
        var version = -1;
        try {
            version = activeXObj.GetVariable("$version");
        } catch (err) {}
        return version;
    };
    /**
     * Try and retrieve an ActiveX object having a specified name.
     * 
     * @param {String} name The ActiveX object name lookup.
     * @return One of ActiveX object or a simple object having an attribute of activeXError with a value of true.
     * @type Object
     */
    var getActiveXObject = function(name){
        var obj = -1;
        try{
            obj = new ActiveXObject(name);
        }catch(err){
            obj = {activeXError:true};
        }
        return obj;
    };
    /**
     * Parse an ActiveX $version string into an object.
     * 
     * @param {String} str The ActiveX Object GetVariable($version) return value. 
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    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]
        };
    };
    /**
     * Parse a standard enabledPlugin.description into an object.
     * 
     * @param {String} str The enabledPlugin.description value.
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    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)
        };
    };
    /**
     * Parse the plugin revision string into an integer.
     * 
     * @param {String} The revision in string format.
     * @type Number
     */
    var parseRevisionStrToInt = function (str) {
        return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
    };
    /**
     * Is the major version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required major version.
     * @type Boolean
     */
    self.majorAtLeast = function (version) {
        return self.major >= version;
    };
    /**
     * Is the minor version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required minor version.
     * @type Boolean
     */
    self.minorAtLeast = function (version) {
        return self.minor >= version;
    };
    /**
     * Is the revision version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required revision version.
     * @type Boolean
     */
    self.revisionAtLeast = function (version) {
        return self.revision >= version;
    };
    /**
     * Is the version greater than or equal to a specified major, minor and revision.
     * 
     * @param {Number} major The minimum required major version.
     * @param {Number} (Optional) minor The minimum required minor version.
     * @param {Number} (Optional) revision The minimum required revision version.
     * @type Boolean
     */
    self.versionAtLeast = function(major){
        var properties = [self.major, self.minor, self.revision];
        var len = Math.min(properties.length, arguments.length);
        for (i = 0; i < len; i++) {
            if (properties[i] >= arguments[i]) {
                if (i + 1 < len && properties[i] == arguments[i]) {
                    continue;
                } else {
                    return true;
                }
            } else {
                return false;
            }
        }
    };
    /**
     * Constructor, sets raw, major, minor, revisionStr, revision and installed public properties.
     */
    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(!obj.activeXError){
                    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.JS_RELEASE = "1.0.4";


