// for music comment and sound editor


//soundEditPage = pagepath + '/_py/soundupload//' + Math.random()
soundEditPage = pagepath + '//edit/soundupload/' + Math.random()
soundCommentPage = pagepath + '/comments';
//soundEditPage = pagepath + '/_manage/edit';
soundEditComPage = pagepath + '/_manage/comments';

currentId = false;
function comment(id) {
	commentIFrame(id);
	}
iCFObj = false;
function closeComment(id) {
	document.location='/music///id-'+id;
	}

function commentIFrame(id) {
	commentContentObj = document.getElementById('commentdiv');
	iCFW = '360px';
	soundCommentPageUrl = soundCommentPage;
	if (id) soundCommentPageUrl = soundCommentPageUrl + '//id-' + id;
	if (iCFObj) {
		commentContentObj.removeChild(iCFObj);
		iCFObj = false;
		}
	else {
		iCFObj = document.createElement('iframe');
		commentContentObj.appendChild(iCFObj);
		iCFObj.setAttribute('src',soundCommentPageUrl);
		iCFObj.setAttribute('scrolling','no');
		iCFObj.setAttribute('width',iCFW);
		iCFObj.setAttribute('height','340px');
		iCFObj.frameBorder='0';
		iCFObj.scrolling='no';
		}
	}
function editSoundiFrame(w,id,h,version,subversion) {
	if (w) iFW = w+'px';
	else iFW = '250px';
	if (h) iFH = h+'px';
	else iFH = '200px';
	soundContentObj = document.getElementById('soundContent');
	soundEditPageUrl = soundEditPage;
	var re=new RegExp('/',"g");
	if (id) soundEditPageUrl += ('//id-' + id.replace(re,"%2F"));
	soundEditPageUrl += ('//version-' + ((!version)?0:version));
	soundEditPageUrl += ('//subversion-' + ((!subversion)?0:subversion));
	alert(soundEditPageUrl)
	if (iCFObj&&currentId==id) {
		soundContentObj.removeChild(iCFObj);
		iCFObj = false;
		}
	else {
		removeSoundiFrame();
		iCFObj = document.createElement('iframe');
		soundContentObj.appendChild(iCFObj);
		iCFObj.setAttribute('scrolling','no');
		iCFObj.setAttribute('width',iFW);
		iCFObj.setAttribute('height',iFH);
		iCFObj.frameBorder='0';
		iCFObj.scrolling='no';
		iCFObj.src = soundEditPageUrl;
		}
	currentId = id;
	}
function removeSoundiFrame() {
	soundContentObj = document.getElementById('soundContent');
	if (iCFObj) soundContentObj.removeChild(iCFObj);
	iCFObj = false;
	}
function soundDurationFinish(t,p) {
	//alert('hey')
	lengthfield = findobject(uploadSoundFormLengthField);
	pathfield = findobject(uploadSoundFormPathField);
	lengthfield.value = t;
	pathfield.value = p;
	}
function getFormElementValue(f,name){
	for (i in f.elements) {
		element = f.elements[i]
		if (element.name==name) {
			if (element.type=='checkbox') return element.checked;
			if (element.type=='text') return element.value;
			}
		}
	return false;
	}
function viewCommentsFrame(w,id,h) {
	if (w) iFW = w+'px';
	else iFW = '250px';
	if (h) iFH = h+'px';
	else iFH = '200px';
	soundContentObj = document.getElementById('soundContent');
	soundEditComUrl = soundEditComPage;
	if (id) soundEditComUrl = soundEditComUrl + '//id-' + id;
	if (iCFObj&&currentId==id) {
		soundContentObj.removeChild(iCFObj);
		iCFObj = false;
		}
	else {
		removeSoundiFrame();
		iCFObj = document.createElement('iframe');
		soundContentObj.appendChild(iCFObj);
		iCFObj.setAttribute('src',soundEditComUrl);
		iCFObj.setAttribute('scrolling','no');
		iCFObj.setAttribute('width',iFW);
		iCFObj.setAttribute('height',iFH);
		iCFObj.frameBorder='0';
		iCFObj.scrolling='no';
		}
	currentId = id;
	}

