/**
 *
 * Extra functions designed to work together with SWFObject v1.4.4 and Webtrends
 *
 */
 
 //This function checks for extra flash variables in url.
 function writeFlash(swfObject) {
	try {
		FlashVarArray=getFlashVars(swfObject.getAttribute('id'));
		for (i in FlashVarArray) {
			thisFlashVar=FlashVarArray[i].split("=");
			swfObject.addVariable(thisFlashVar[0], thisFlashVar[1]);
		}
	} catch (e) {
	}
	try {
        var installedVersion = deconcept.SWFObjectUtil.getPlayerVersion();  // Get installed version
        var swfObjectVersion = swfObject.getAttribute('version');   // Get version from flash obj
        var flashBar = $('flashBar');   // The div containing the flash error msg
        //alert('installed= ' + installedVersion.major + ' obj= ' + swfObjectVersion.major);
        if(installedVersion.major >= swfObjectVersion.major){
    		swfObject.write("flashcontent");
        }else{
            flashBar.show();    // Show the flashbar
            $('flashcontent').hide();   // Hide (collapse) the flash area
        }
        //then rename the flash container to be able to take care of the next one (if more than one exists on the page)  (IE bug)
        $('flashcontent').id='flashcontent_used';
    } catch (e) {
        // Fallback to old solution since new one does not work...due to missing code/files...
        try {
            swfObject.write("flashcontent");
    		//rename the container  (iebug)
    		document.getElementById('flashcontent').id='flashcontent_used';
        } catch (err) {
        }
	}
 }
 
 //Function that returns an array with Flash variables
 // The flash_id is used to identify the flash_vars. We need to add a '_' to the id since that is used in the querystring.
 // The id + '_' is then removed before pushed to the flashVar-array.
function getFlashVars(flash_id ) {
	flash_id = flash_id + '_';
	currentFlashVar = 'flash_' + flash_id ;

	thisArray=new Array();
	try {
		href=document.location.href;
		startPath='none';
		urlArray=new Array();
		urlArray=href.split('?');
		if (urlArray.length==2) {
			querystringArray=new Array();
			querystringArray=urlArray[1].split('&');
			for (i in querystringArray) {
				thisQueryVar=querystringArray[i].split("=");
				
				// If the id contains a space ' ' we have to replace '%20' from the url to ' '
				cleanedQuerystring = querystringArray[i].replace("%20"," ");
				//document.write(cleanedQuerystring);
				if (cleanedQuerystring.substring(0,(6 + flash_id.length))==currentFlashVar) {
					thisArray.push(cleanedQuerystring.substring(0,6) + cleanedQuerystring.substring((6 + flash_id.length),cleanedQuerystring.length));
				}
			}
		}
	} catch (e) {
	}
	return thisArray;
}

//function for for stat generation with exception handling
function IRWdcsMultiTrack() {
	try {
		if (window.gDomain===undefined) {
			WTdom_Load=false;
		} else {
			WTdom_Load=true;
		}
		if (window.WTmain_Load === true && window.WTdom_Load === true) {
			dcsMultiTrack.apply(this,arguments);
		}
	} catch (e) {}	
}