/*
 * Copyright (C) 1995-2011 by 4system Polska Sp. z o.o.
 * All Rights Reserved.
 */
 
componentBlanksInTextAudio = function(name)
{
	this.componentBlanksInText = componentBlanksInText;
	this.componentBlanksInText(name);
	
	this.correctValues = new Array(new Array(), new Array());
	this.complete = false;
	this.addInactive = false;
	
	this.compAudio = null;	
	this.buttons = new Array();		
	this.iTimerID == null;
	
	this.interactions = true;
	this.interactionsType = "fill-in";		
};

componentBlanksInTextAudio.prototype = new componentBlanksInText;
componentBlanksInTextAudio.prototype.type = "componentBlanksInTextAudio";

componentBlanksInTextAudio.prototype.componentBlanksInTextAudioBaseOnCreate = componentBlanksInTextAudio.prototype.onCreate;
componentBlanksInTextAudio.prototype.onCreate = function(obj)
{
	if (PageInterface.GetValue("state") != psDesigning &&  lms && this.disableOnlineOfflineMix != false ) 
	{
		this.resourcesStatus 	= lms.resourcesStatus();
		this.resourcesURL 		= lms.resourcesURL();
	} else this.resourcesURL = resourcesURL;
	
	if (PageInterface.GetValue("state") != psDesigning) {
		this.text = this.setButtonsActions(this.text);
		this.getCorrectValues(this.inputsCorrectValues);
	}

	var btnHTML = "";
	btnHTML += '<div style="margin:0px; margin-bottom:10px;">';
	btnHTML += '<img src="'+ this.resourcesURL + this.audioPlay + '" style="cursor:pointer;" onclick="pc.'+this.id+'.onMouseClickImagePlay()"/>&nbsp;';

	if (this.enableFlashPlayer) {
		var e = new componentFlashAudioPlayer;
		e.myParent = this;
		e.id = this.id + 'dropAudioComp';
		e.step = -1;
		e.src = this.flashAudioPlayerSrc;
		e.x = 0;
		e.y = 0;
		e.w = 1;
		e.h = 1;
		e.loop = false;
		e.flashVars = "";
		this.compAudio = page.addChild(e);
	} else {
		var newDiv = document.createElement("DIV"); //pg2
		newDiv.setAttribute("id", this.id + 'dropAudioComp_contentObj');
		newDiv.setAttribute("style", "visibility: visible;");
		document.body.appendChild(newDiv);
		
		var audioElement = new componentAudio;
		audioElement.myParent = this;
		audioElement.id = this.id + 'dropAudioComp'; 
		audioElement.src = this.src;
		audioElement.pvWMP64 = false;
		audioElement.pvWMP7up = false;
		audioElement.step = -1;
		audioElement.editorPaint = this.editorPaint;
		this.compAudio = page.addChild(audioElement);
		audioElement.allowNextStep = true;
		
		btnHTML += '<img src="'+ this.resourcesURL + this.audioPause + '" style="cursor:pointer;" onclick="pc.'+this.id+'.onMouseClickImagePause()"/>&nbsp;';
	}

	btnHTML += '<img src="'+this.resourcesURL + this.audioStop + '" style="cursor:pointer;" onclick="pc.'+this.id+'.onMouseClickImageStop()"/>&nbsp;';
	btnHTML += '</div>';

	this.text = btnHTML + this.text;
};

componentBlanksInTextAudio.prototype.editorPaint = function()
{
	return '';
}

componentBlanksInTextAudio.prototype.onMouseClickImagePlay = function()
{	
	if (this.enableFlashPlayer) {
		this.compAudio.flashVars = "playIdx=0&autoStart=true&playOnce=true";
		this.compAudio.show();
	} else {
		this.compAudio.actionMediaPlay();
	};
};

componentBlanksInTextAudio.prototype.onMouseClickImagePause = function()
{
	if (this.enableFlashPlayer) {
		this.compAudio.flashVars = "";
		this.compAudio.hide();
	} else {
		this.compAudio.actionMediaPause();
	};
};

componentBlanksInTextAudio.prototype.onMouseClickImageStop = function()
{
	if (this.enableFlashPlayer) {
		this.compAudio.flashVars = "";
		this.compAudio.hide();
	} else {
		this.compAudio.actionMediaStop();
	};
};

componentBlanksInTextAudio.prototype.onShow = function() {
	for (var i=0; i < this.buttons.length; i++) {
		var obj = this.buttons[i]; //pg2
		if (obj) {
			obj.style.visibility = 'visible';
			obj.show();
		}
	}
}
