function musicPlay(intSong) {
	musicReset();
	strFlash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="1" width="1">';
	strFlash += '<param name="movie" value="/flash/player.swf?id='+intSong+'" />';
	strFlash += '<param name="quality" value="high" />';
	strFlash += '<param name="wmode" value="transparent" />';
	strFlash += '<embed src="/flash/player.swf?id='+intSong+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="1" width="1" />';
	strFlash += '</object>';
	divPlayer = document.getElementById('player_'+intSong);
	divPlayer.innerHTML = strFlash;
	divStop = document.getElementById('listen_'+intSong);
	divStop.innerHTML = '<a href="#" onclick="musicReset();return false;" class="stop"><span>Stop</span></a>';
}


function musicReset() {
	arrTracks = getElementsByClass("col_listen");
	for (i = 0; i < arrTracks.length; i++) {
		intSong = arrTracks[i].id;
		intSong = intSong.replace(/listen_/,"");
		if(arrTracks[i].className.match('noplay')) {
			arrTracks[i].innerHTML = '<div class="play"></div>';
		} else {
			arrTracks[i].innerHTML = '<a href="#" onclick="musicPlay('+intSong+');return false;" class="play">Listen</a>';
		}
	}
	arrTracks = getElementsByClass("col_player");
	for (i = 0; i < arrTracks.length; i++) {
		arrTracks[i].innerHTML = '';
	}
}


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


function showLayer(layerId,show) {
	if (document.getElementById && document.getElementById(layerId)) { objLayer = document.getElementById(layerId); } else if (document.all && document.all[layerId]) { objLayer = document.all[layerId]; } else if (document.layers && document.layers[layerId]) { objLayer = document.layers[layerId]; } else { objLayer = null; }
	if (objLayer !== null) { objLayer.style.display = (show == 1) ? 'block' : 'none'; }
}


function zoom(id,intWidth,intHeight) {
	var winl = (screen.width - intWidth) / 2;
	var wint = (screen.height - intHeight) / 2;
	window.open('/medias/products/?id='+id, 'preview','width='+intWidth+',height='+intHeight+',top='+wint+',left='+winl+',scrollbars=yes,resizable')
}

function price(mxdValue) {
	mxdValue = mxdValue.replace(/,/,'.');
	mxdValue = parseFloat(mxdValue);
	if (isNaN(mxdValue)||mxdValue=='') mxdValue = 0;
	return mxdValue.toFixed(2);
}

function checkall(strForm,strName,boolChecked) {
	for (var i = 0; i < strForm.elements.length; i++) {
		while (strForm.elements[i].name != strName+"[]") {
			i++;
			if (!strForm.elements[i]) {
				return;
			}
		}
		strForm.elements[i].checked = boolChecked;
	}
}
