var arrIWPlayers = new Array();

function IW_activate(p_strWrapper, p_objElement){
	var objWrapper = document.getElementById(p_strWrapper);
	
	if(objWrapper && p_objElement){
		var arrElements = objWrapper.getElementsByTagName(p_objElement.tagName);
		for(var i = 0; i < arrElements.length; i++){
			var objElement = arrElements[i];
			objElement.className = '';
			
		}
		p_objElement.className = 'active';
	}
}

function IW_player_id(){
	return 'InteliwiseMediaPlayer'+arrIWPlayers.length;
}

function IW_player_code(p_strFile, p_iWidth, p_iHeight, p_bAutoPlay){
	var iRev = 11;
	
	var strPlayerId = IW_player_id();
	var strParams = 'playerId='+strPlayerId+'&rev='+iRev+'&filePath='+p_strFile;
	
	if(p_iWidth)
		strParams = strParams+"&videoWidth="+p_iWidth;
		
	if(p_iHeight)
		strParams = strParams+"&videoHeight="+p_iHeight;
        
    if(p_bAutoPlay)
        strParams = strParams+"&autoPlay=true";

	if (AC_FL_RunContent == 0) {
		return "";
	} else {
		return AC_FL_RunContent_Str(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0',
			'width', p_iWidth?p_iWidth+10:'330',
			'height', p_iHeight?p_iHeight+33:'273',
			'src', '/en/_ext/InteliwiseMediaPlayer.swf?v=3',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'noscale',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', strPlayerId,
			'bgcolor', '#ffffff',
			'name', strPlayerId,
			'menu', 'true',
			'allowFullScreen', 'true',
			'allowScriptAccess','always',
			'movie', '/en/_ext/InteliwiseMediaPlayer.swf?v=3',
			'salign', 'lt',
			'FlashVars', strParams
			); //end AC code
		
	}
}


function IW_insert_player(p_strWrapperId, p_strFile, p_iWidth, p_iHeight, p_bAutoPlay){
	var strPlayerId = IW_player_id();
	
	var objWrapper = document.getElementById(p_strWrapperId);
	
	if(objWrapper){
		objWrapper.innerHTML = IW_player_code(p_strFile, p_iWidth, p_iHeight, p_bAutoPlay);
		if (navigator.appName.indexOf("Microsoft") != -1) {
			arrIWPlayers.push(document.getElementById(strPlayerId));
			//this.m_objCharacter =  window[p_strInstanceName];
		} else {
			arrIWPlayers.push(document[strPlayerId]);
		}
	}
}

function IW_player(p_strFile, p_iWidth, p_iHeight, p_bAutoPlay){
	
	document.write(IW_player_code(p_strFile, p_iWidth, p_iHeight, p_bAutoPlay));
	
	var strPlayerId = IW_player_id();
	
	if (navigator.appName.indexOf("Microsoft") != -1) {
		arrIWPlayers.push(document.getElementById(strPlayerId));
		//this.m_objCharacter =  window[p_strInstanceName];
	} else {
		arrIWPlayers.push(document[strPlayerId]);
	}
	
	
}

function IW_stop_all_players(p_strExcludeId){
	for(var i=0; i<arrIWPlayers.length; i++){
		if(arrIWPlayers[i].stopPlaying && p_strExcludeId != 'InteliwiseMediaPlayer'+i)
			arrIWPlayers[i].stopPlaying();
	}
	if(window.IW_stop_avatar){
		IW_stop_avatar();
	}
}

