var SoundPlayingTableName = "";
var SoundPlayingID = "";

function GetIconExt(TableName)
{
	if(TableName=="Products")
		return("jpg");
	else
		return("gif");
}

function PlayEmbed(TableName,ID,Ext)
{
	var iconExt = GetIconExt(TableName);
	
	document.getElementById("SoundButton_"+TableName+ID).src="img/SoundOn."+iconExt ;
	document.getElementById("SoundButton_"+TableName+ID).alt="השתק";
	document.getElementById("SoundLink_"+TableName+ID).title="השתק";
	var DivID,str;
	if(Ext==".wav")
		DivID = "waveDiv";
	else if(Ext==".mp3")
		DivID = "mp3Div";			
	str = document.getElementById(DivID).innerHTML;
	str = replaceAll(str,"_TableName_",TableName);
	str = replaceAll(str,"_ID_",ID);
	str = replaceAll(str,"_SoundFileExt_",Ext);
	document.getElementById("Sound_"+TableName+ID).innerHTML=str;
	SoundPlayingTableName = TableName;
	SoundPlayingID = ID;
}
function RemoveEmbed(TableName,ID)
{
	var iconExt = GetIconExt(TableName);
	
	document.getElementById("SoundButton_"+TableName+ID).src="img/SoundTurnOff."+iconExt;
	document.getElementById("SoundButton_"+TableName+ID).alt="הפעל";
	document.getElementById("SoundLink_"+TableName+ID).title="הפעל";
	document.getElementById("Sound_"+TableName+ID).innerHTML="";
	SoundPlayingTableName = "";
	SoundPlayingID = "";
}
function SoundClick(TableName,ID,Ext)
{
	var temp_TableName,temp_ID;
	if(isNumeric(SoundPlayingID))
	{
		temp_TableName = SoundPlayingTableName;
		temp_ID = SoundPlayingID;
		RemoveEmbed(SoundPlayingTableName,SoundPlayingID);
		if((TableName!=temp_TableName)||(ID!=temp_ID))
			PlayEmbed(TableName,ID,Ext);
	}
	else
		PlayEmbed(TableName,ID,Ext);
}