// COOKIES
function setCookie(name, value, expirationDayCount, path, domain, secure ) {
	var expirationDate = new Date();
	expirationDate.setDate(expirationDate.getDate() + expirationDayCount);
	
	document.cookie = name + "=" +escape( value ) +
	( ( expirationDayCount ) ? ";expires=" + expirationDate.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function getCookie(cookieName) {
	if (document.cookie.length>0) {
		var startIndex = document.cookie.indexOf(cookieName + "=");
		if (startIndex!=-1) { 
	    	startIndex = startIndex + cookieName.length + 1; 
	    	var endIndex = document.cookie.indexOf(";", startIndex);
	    	if (endIndex==-1) {
	    		endIndex = document.cookie.length;
	    	}	
	    	return unescape(document.cookie.substring(startIndex, endIndex));
		} 
	}
	return "";
}

// VIEW PORT 
function getAvailableHeight() {
	var h = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;
	return h;
}
function getAvailableWidth() {
	var w = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
	return w;
}

// NAVIGATION
function openPage(url, target) {
	var pageReference = window.open(url, target);
	if (!pageReference) { 
		alert('Please deactivate you anti-popup system in order to open this page in a new window');
		document.location = url;
	} else {
		pageReference.focus();
	}
}
function openPopUp(url, height, width) {
	var options = 'resizable,status=no,top=0,left=0,height=' + height + ',width=' + width;
	var popUpReference = window.open(url, "popUp", options);
	if (!popUpReference) { 
		alert('Please deactivate you anti-popup system in order to open this page in a new window');
		document.location = url;
	} else {
		popUpReference.focus();
	}
}
function goToPage(url) {
	location.href = url;
}	
function reloadPage() { // called from Flex applications
	window.location.reload();
}

// WINDOWS
function centerWindow(name) { // called from Flex applications
	var window = ColdFusion.Window.getWindowObject(name);
	window.center();
}
function hideWindow(name) { // called from Flex applications
	ColdFusion.Window.hide(name);
}
function resizeWindow(name, height, width) { // called from Flex applications
	var window = ColdFusion.Window.getWindowObject(name);
	window.setSize(width, height);
	window.center();
}
function showWindow(name, optionalUrl) { // called from Flex applications
	if (optionalUrl != undefined && optionalUrl != "") {
		ColdFusion.navigate(optionalUrl, name);
	}
	ColdFusion.Window.show(name);
}


// SHARE
function shareOnFacebook(title, url) {
	var popUpReference = window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title),'facebookSharePopUp','toolbar=0,status=0,width=626,height=436'); 
	if (popUpReference) {
		popUpReference.focus();
	}
	return false;
}

function shareOnMyspace(title, url) {
	var popUpReference = window.open('http://www.myspace.com/index.cfm?fuseaction=postto&t=' + encodeURIComponent(title) + '&c=&u=' + encodeURIComponent(url) + '&l=1','myspaceShareWindow'); 
	if (popUpReference) {
		popUpReference.focus();
	}
	return false;
}
				
// UTIL
function setElementDisplay(elementId, value) {
	var element = document.getElementById(elementId);
	if (element != null) {
		element.style.display = value;
	}
}
function getQueryVariable(variable) { 
	var query = window.location.search.substring(1); 
	var vars = query.split("&"); 
	for (var i=0;i<vars.length;i++) { 
		var pair = vars[i].split("="); 
		if (pair[0] == variable) { 
			return decodeURI(pair[1]); 
		} 
	} 
}

function writeDateAgo(unixTime, locale) {
    var pluralize = function(amt) {
        return (amt >= 1 && amt < 2) ? "" : "s";
    }

    if (typeof unixTime === "Date") {
        unixTime = unixTime.getTime();
    } else if (typeof unixTime === "string") {
        unixTime = Date.parse(unixTime);
    }

	var ms = new Date().getTime() - unixTime;
	
	if(locale == "fr_FR"){
		secs = ms / 1000;
	    if ((mins = secs / 60) < 1) {
	        amount = "il y a " + Math.floor(secs) + " seconde" + pluralize(secs);
	    } else if ((hours = mins / 60) < 1) {
	        amount = "il y a " + Math.floor(mins) + " minute" + pluralize(mins);
	    } else if ((days = hours / 24) < 1) {
	        amount = "il y a " + Math.floor(hours) + " heure" + pluralize(hours);
	    } else if ((weeks = days / 7) < 1) {
	        amount = "il y a " + Math.floor(days) + " jour" + pluralize(days);
	    } else if ((months = days / 30) < 1) {
	        amount = "il y a " + Math.floor(weeks) + " semaine" + pluralize(weeks);
	    } else if ((years = days / 365) < 1) {
	        amount = "il y a " + Math.floor(months) + " mois";
	    } else {
	        amount = "il y a " + Math.floor(years) + " an" + pluralize(years);
	    }
	    document.write(amount);
	} else {
		/*if ((secs = ms / 1000) < 1) {
	        amount = ms + " ms";
	    }*/
		secs = ms / 1000;
	    if ((mins = secs / 60) < 1) {
	        amount = Math.floor(secs) + " sec" + pluralize(secs);
	    } else if ((hours = mins / 60) < 1) {
	        amount = Math.floor(mins) + " min" + pluralize(mins);
	    } else if ((days = hours / 24) < 1) {
	        amount = Math.floor(hours) + " hour" + pluralize(hours);
	    } else if ((weeks = days / 7) < 1) {
	        amount = Math.floor(days) + " day" + pluralize(days);
	    } else if ((months = days / 30) < 1) {
	        amount = Math.floor(weeks) + " week" + pluralize(weeks);
	    } else if ((years = days / 365) < 1) {
	        amount = Math.floor(months) + " month" + pluralize(months);
	    } else {
	        amount = Math.floor(years) + " year" + pluralize(years);
	    }
	    document.write(amount + " ago");
	}
}

function writeLocaleDate(utcDate, formatString) {
	if(utcDate instanceof Date) {
		var today = new Date();
		var localeTimeDate = new Date(utcDate.getTime() - (today.getTimezoneOffset()*60000))
		var yyyy = localeTimeDate.getFullYear();
		var yy = yyyy.toString().substring(2);
		var m = localeTimeDate.getMonth() + 1;
		var mm = m < 10 ? "0" + m : m;
		var d = localeTimeDate.getDate();
		var dd = d < 10 ? "0" + d : d;
		
		var h = localeTimeDate.getHours();
		var hh = h < 10 ? "0" + h : h;
		var n = localeTimeDate.getMinutes();
		var nn = n < 10 ? "0" + n : n;
		var s = localeTimeDate.getSeconds();
		var ss = s < 10 ? "0" + s : s;

		formatString = formatString.replace(/yyyy/i, yyyy);
		formatString = formatString.replace(/yy/i, yy);
		formatString = formatString.replace(/mm/i, mm);
		formatString = formatString.replace(/m/i, m);
		formatString = formatString.replace(/dd/i, dd);
		formatString = formatString.replace(/d/i, d);
		formatString = formatString.replace(/hh/i, hh);
		formatString = formatString.replace(/h/i, h);
		formatString = formatString.replace(/nn/i, nn);
		formatString = formatString.replace(/n/i, n);
		formatString = formatString.replace(/ss/i, ss);
		formatString = formatString.replace(/s/i, s);
		
		document.write(formatString);
	} else {
		document.write("");
	}
}

/**********************************
* QUESTIONS/ANSWERS
**********************************/
var _cf_CommentWebService = ColdFusion.AjaxProxy.init('/affinitiz/services/comment/CommentWebService.cfc','CommentWebService');
_cf_CommentWebService.prototype.setCommentHighlighted=function(commentUid, contentUid) { return ColdFusion.AjaxProxy.invoke(this, "setCommentHighlighted", {commentUid:commentUid, contentUid:contentUid});};


function setCommentHighlighted(commentUid, contentUid){
    var commentWebService = new CommentWebService();
    commentWebService.setHTTPMethod("POST");
    
    var onCommentWebServiceFault = function(statusCode,statusMessage) {
        alert(statusCode + ': ' + statusMessage);
    };
    commentWebService.setErrorHandler(onCommentWebServiceFault);
    
    var onCommentWebServiceResult = function(response) {
		window.location.reload();
    };
    commentWebService.setCallbackHandler(onCommentWebServiceResult);
    
    commentWebService.setCommentHighlighted(commentUid, contentUid);
}

/**********************************
* FAVORITES
**********************************/
var _cf_FavoriteWebService = ColdFusion.AjaxProxy.init('/affinitiz/services/favorite/FavoriteWebService.cfc','FavoriteWebService');
_cf_FavoriteWebService.prototype.deleteFavorite=function(contentUid) { return ColdFusion.AjaxProxy.invoke(this, "deleteFavorite", {contentUid:contentUid});};
_cf_FavoriteWebService.prototype.getFavorite=function(contentUid) { return ColdFusion.AjaxProxy.invoke(this, "getFavorite", {contentUid:contentUid});};
_cf_FavoriteWebService.prototype.saveFavorite=function(contentUid, spaceName, spaceUid) { return ColdFusion.AjaxProxy.invoke(this, "saveFavorite", {contentUid:contentUid, spaceName:spaceName, spaceUid:spaceUid});};

function deleteFavorite(contentUid, deletedLabel){
    var favoriteWebService = new FavoriteWebService();
    favoriteWebService.setHTTPMethod("POST");
    
    var onFavoriteWebServiceFault = function(statusCode,statusMessage) {
        alert(statusCode + ': ' + statusMessage);
    };
    favoriteWebService.setErrorHandler(onFavoriteWebServiceFault);
    
    var onFavoriteWebServiceResult = function(response) {
		document.getElementById('deleteFavorite').style.display = 'none';
        document.getElementById('saveFavoriteButton').enabled = true;
		document.getElementById('saveFavorite').style.display = 'inline';
		alert(deletedLabel);
    };
    favoriteWebService.setCallbackHandler(onFavoriteWebServiceResult);
    
	document.getElementById('deleteFavoriteButton').enabled = false;
    favoriteWebService.deleteFavorite(contentUid);
}

function saveFavorite(contentUid, spaceName, spaceUid, savedLabel){
    var favoriteWebService = new FavoriteWebService();
    favoriteWebService.setHTTPMethod("POST");
    
    var onFavoriteWebServiceFault = function(statusCode,statusMessage) {
        alert(statusCode + ': ' + statusMessage);
    };
    favoriteWebService.setErrorHandler(onFavoriteWebServiceFault);
    
    var onFavoriteWebServiceResult = function(response) {
        document.getElementById('saveFavorite').style.display = 'none';
        document.getElementById('deleteFavoriteButton').enabled = true;
		document.getElementById('deleteFavorite').style.display = 'inline';
		alert(savedLabel);
    };
    favoriteWebService.setCallbackHandler(onFavoriteWebServiceResult);
    
	document.getElementById('saveFavoriteButton').enabled = false;
    favoriteWebService.saveFavorite(contentUid, spaceName, spaceUid);
}

/**********************************
* RATING
**********************************/
var _cf_ContentWebService = ColdFusion.AjaxProxy.init('/affinitiz/services/content/ContentWebService.cfc','ContentWebService');
_cf_ContentWebService.prototype.saveContentRatingStatusId=function(contentRatingStatusId,contentUid) { return ColdFusion.AjaxProxy.invoke(this, "saveContentRatingStatusId", {contentRatingStatusId:contentRatingStatusId,contentUid:contentUid});};
_cf_ContentWebService.prototype.getContentRatingAverage=function(contentUid,trackerEnabled) { return ColdFusion.AjaxProxy.invoke(this, "getContentRatingAverage", {contentUid:contentUid,trackerEnabled:trackerEnabled});};
_cf_ContentWebService.prototype.saveContentRating=function(contentRating,contentUid) { return ColdFusion.AjaxProxy.invoke(this, "saveContentRating", {contentRating:contentRating,contentUid:contentUid});};
_cf_ContentWebService.prototype.getContentRatingAverages=function(contentUids,trackerEnabled) { return ColdFusion.AjaxProxy.invoke(this, "getContentRatingAverages", {contentUids:contentUids,trackerEnabled:trackerEnabled});};
_cf_ContentWebService.prototype.setContentPublicEnabled=function(contentUid, publicEnabled, spaceUid) { return ColdFusion.AjaxProxy.invoke(this, "setContentPublicEnabled", {contentUid:contentUid,publicEnabled:publicEnabled,spaceUid:spaceUid});};

function getContentRatingAverages(contentUids) {
	var contentWebService = new ContentWebService();
	contentWebService.setHTTPMethod("POST");

    var onContentWebServiceFault = function(statusCode, statusMessage) {
    	alert(statusCode + ': ' + statusMessage);
    };
	contentWebService.setErrorHandler(onContentWebServiceFault);

    var onContentWebServiceResult = function(response) {
    	for (var i = 0; i < response.length; i++) {
    		if (response[i].contentRatingAverage > 0) {
	            document.getElementById('contentRatingVoteButton_' + response[i].contentUid).style.display = 'none';
				document.getElementById('contentRatingVoteText_' + response[i].contentUid).style.display = 'inline';
	        }
    	}
	};
	contentWebService.setCallbackHandler(onContentWebServiceResult);
	
	contentWebService.getContentRatingAverages(contentUids, true);
}

/*function getContentRatingAverage(contentUid) {
    var contentWebService = new ContentWebService();
    contentWebService.setHTTPMethod("POST");

    var onContentWebServiceFault = function(statusCode, statusMessage) {
        alert(statusCode + ': ' + statusMessage);
    };
    contentWebService.setErrorHandler(onContentWebServiceFault);

    var onContentWebServiceResult = function(response) {
        lastSavedRatingContentUid = response.contentUid;
        lastSavedRating = response.contentRatingAverage;
        if (response.contentRatingAverage > 0) {
            onContentRatingStarMouseOver(response.contentRatingAverage, response.contentUid);
        }
    };
    contentWebService.setCallbackHandler(onContentWebServiceResult);
    
    contentWebService.getContentRatingAverage(contentUid, true);
}*/

function onContentRatingStarMouseOver(contentRating, contentUid){
    var i = 1;
    for (i=1; i<=5; i++){
        if (i <= contentRating){
            document.getElementById('contentRatingStar_' + contentUid + '_' + i).style.backgroundPosition = "center left";
        } else {
            document.getElementById('contentRatingStar_' + contentUid + '_' + i).style.backgroundPosition = "bottom left";
        }
    }
}
function onContentRatingStarMouseOut(contentRating, contentUid){
    var i = 1;
    if (lastSavedRatingContentUid == contentUid){
        for (i=1; i<=5; i++){
            if (i <= lastSavedRating){
                document.getElementById('contentRatingStar_' + contentUid + '_' + i).style.backgroundPosition = "center left";
            } else {
                document.getElementById('contentRatingStar_' + contentUid + '_' + i).style.backgroundPosition = "bottom left";
            }
        }
    } else {
        for (i=1; i<=5; i++){
            if (i <= contentRating){
                document.getElementById('contentRatingStar_' + contentUid + '_' + i).style.backgroundPositionY = "top left";
            } else {
                document.getElementById('contentRatingStar_' + contentUid + '_' + i).style.backgroundPosition = "bottom left";
            }
        }
    }
}

function saveContentStarRating(contentRating, contentUid){
    var contentWebService = new ContentWebService();
    contentWebService.setHTTPMethod("POST");
    
    var onContentWebServiceFault = function(statusCode,statusMessage) {
        alert(statusCode + ': ' + statusMessage);
    };
    contentWebService.setErrorHandler(onContentWebServiceFault);
    
    var onContentWebServiceResult = function(response) {
        lastSavedRatingContentUid = response.contentUid;
        lastSavedRating = response.contentRating;
        
        if (response.contentRatingAverage.toString().indexOf('.') == -1) {
        	response.contentRatingAverage = response.contentRatingAverage + '.0';
       	}
        
        document.getElementById('contentRatingAverage_' + response.contentUid).innerHTML = response.contentRatingAverage;
        document.getElementById('contentRatingCount_' + response.contentUid).innerHTML = response.contentRatingCount;
        onContentRatingStarMouseOver(response.contentRating, response.contentUid);
    };
    contentWebService.setCallbackHandler(onContentWebServiceResult);
    
    contentWebService.saveContentRating(contentRating, contentUid);
}

function saveContentVoteRating(contentRating, contentUid){
	var contentWebService = new ContentWebService();
	contentWebService.setHTTPMethod("POST");
	
	var onContentWebServiceFault = function(statusCode,statusMessage) {
		alert(statusCode + ': ' + statusMessage);
	};
	contentWebService.setErrorHandler(onContentWebServiceFault);
	
	var onContentWebServiceResult = function(response) {
		document.getElementById('contentRatingVoteCount_' + response.contentUid).innerHTML = response.contentRatingCount;
        if (response.contentRatingCount > 0) {
			document.getElementById('contentRatingVoteButton_' + response.contentUid).style.display = 'none';
            document.getElementById('contentRatingVoteText_' + response.contentUid).style.display = 'inline';
        }
	};
	contentWebService.setCallbackHandler(onContentWebServiceResult);
	
	contentWebService.saveContentRating(contentRating, contentUid);
}

function saveContentRatingStatusId(contentRatingStatusId, contentUid) {
	var contentWebService = new ContentWebService();
	contentWebService.setHTTPMethod("POST");
	
	var onContentWebServiceFault = function(statusCode,statusMessage) {
		alert(statusCode + ': ' + statusMessage);
	};
	contentWebService.setErrorHandler(onContentWebServiceFault);
	
	var onContentWebServiceResult = function(response) {
		switch(response.contentRatingStatusId) {
			case 0: 
				document.getElementById('contentRatingStatusRefusedLabel_' + response.contentUid).style.display = 'inline';
				document.getElementById('contentRatingVoteButton_' + response.contentUid).style.display = 'none';
            	document.getElementById('contentRatingVoteText_' + response.contentUid).style.display = 'none';
            	document.getElementById('contentRatingStatusApprovedLabel_' + response.contentUid).style.display = 'none';
				break;
			case 1: 
				document.getElementById('contentRatingStatusRefusedLabel_' + response.contentUid).style.display = 'none';
            	document.getElementById('contentRatingVoteButton_' + response.contentUid).style.display = 'block';
            	document.getElementById('contentRatingStatusApprovedLabel_' + response.contentUid).style.display = 'none';
				break;
			case 2: 
				document.getElementById('contentRatingStatusRefusedLabel_' + response.contentUid).style.display = 'none';
            	document.getElementById('contentRatingVoteButton_' + response.contentUid).style.display = 'none';
            	document.getElementById('contentRatingVoteText_' + response.contentUid).style.display = 'none';
            	document.getElementById('contentRatingStatusApprovedLabel_' + response.contentUid).style.display = 'inline';
				break;
		}
	};
	contentWebService.setCallbackHandler(onContentWebServiceResult);
	
	contentWebService.saveContentRatingStatusId(contentRatingStatusId, contentUid);
}

function setContentPublicEnabled(contentUid, publicEnabled, spaceUid){
	var contentWebService = new ContentWebService();
	contentWebService.setHTTPMethod("POST");
	
	var onContentWebServiceFault = function(statusCode,statusMessage) {
		alert(statusCode + ': ' + statusMessage);
	};
	contentWebService.setErrorHandler(onContentWebServiceFault);
	
	var onContentWebServiceResult = function(response) {
		window.location.reload();
	};
	contentWebService.setCallbackHandler(onContentWebServiceResult);
	
	contentWebService.setContentPublicEnabled(contentUid, publicEnabled, spaceUid);
}

/**********************************
* Flash Player Version Detection - Rev 1.5
* Detect Client Browser type
* Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
**********************************/
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}