// JavaScript Document

	var click = 0
	function showInstructions(divID){
	
	var instructionsDiv = document.getElementById(divID)
	
	var subLinkText = document.getElementById(divID+'Link')
		if (instructionsDiv.style.display == 'none' || click == 0){
		subLinkText.innerHTML = "Hide mailing list form"
		instructionsDiv.style.display = 'block'
		click = 1
		}else{
		instructionsDiv.style.display = 'none'
		subLinkText.innerHTML = "Subscribe to our mailing list"
		click = 0
		}

	}

function hideDiv(divID) {
	var divToHide= document.getElementById(divID)

	var subLinkText = document.getElementById(divID+'Link')
		if (divToHide.style.display == 'none' || click == 0){
		subLinkText.innerHTML = "Hide mailing list form"
		divToHide.style.display = 'block'
		click = 1
		}else{
		divToHide.style.display = 'none'
		subLinkText.innerHTML = "Subscribe to our mailing list"
		click = 0
		}

}
	
	

var activateLinks = false;

function activateLink(linkId){
//alert(linkId)
var baseFilePath = "http:\/\/www.dontinsley.com\/dont\/dl\/"
	if (Boolean(linkId) == true) {
	
	activeLink = document.getElementById('link'+linkId);
	activeCheckBox = document.getElementById(linkId);
	linkId = linkId.split("varified")
	//alert(fileUrl[linkId[1]] + " - "+ linkId[1])
	linkId = fileUrl[linkId[1]]
	activeLink.href = baseFilePath+linkId + '.mp3'
	activeLink.onclick = ''
	activeCheckBox.disabled = true;

	//setTimeout("alert(\"you may now download the file\")", 5000);
	}
}

var fileList = '';
//alert(entryLength)
function getFileList() {

var firstEntry = document.getElementById('fileListDiv_0') 
		if (firstEntry){
		//alert(entryLength)
		
		for (i=0; i<entryLength; i++){
		 fileList += document.getElementById('fileListDiv_'+i).innerHTML +","
		//alert(fileList +" - " + i)
		}
	}
	//alert("fileList" + fileList)
 
 
		
		if (fileList) {
			//var fileList = document.getElementById('fileListDiv').innerHTML
			var fileListContainer = document.getElementById('fileListContainerDiv')
			
			fileUrl = fileList.split(",")
			var fileName = new Array()
			var fileCaption = new Array()
			//alert(fileUrl.length)
			for (x=0; x<fileUrl.length; x++) {
			fileCaption[x] = fileUrl[x].split("-")[2]
			fileName[x] = fileUrl[x].split("-")[1]
			fileUrl[x] = fileUrl[x].split("-")[0]
			
			}

			
			html = '';
			var n = fileUrl.length-1
			for (i=0; i<fileUrl.length-1; i++) {
			//alert(fileUrl[i] + "-" + fileName[i] )
			html += '<strong>Catalog # [00'+ n-- +'] </strong>| <a href="#" id="linkvarified'+i+'"';
			html +=	'	onclick="showLicense(\'varified'+i+'\'); return false;" title="'+fileName[i]+'"';
			html += ' target="_blank">'+fileName[i]+'</a>';
			html +=	' <input onFocus="activateLink(this.id)" type="checkbox" disabled id="varified'+i+'" /> <br/>';
			
		
			if (fileCaption[i].length < 0){
			}else{
			html += '<div class="ccm_caption">';
			html +=	fileCaption[i]; 
			html += '</div><br />';
			}
			fileListContainer.innerHTML = html; 
			
			}
		
		}
}

function showLicense(id) {
  sLicense = window.open('ccLicense.html?'+id, 'license', 'width=652,height=570,location=1,toolbar=1,scrollbars=1,screenX=200,screenY=100,left=200,top=100');
}

function remLink() {
  if (window.sLicense && window.sLicense.open && !window.sLicense.closed){
    window.sLicense.opener = null;
	}
}
// -->
/*
var activateLinks = false;

function activateLink(linkId){
//alert(linkId)
var baseFilePath = "http:\/\/www.dontinsley.com\/dont\/dl\/"
	if (Boolean(linkId) == true) {
	
	activeLink = document.getElementById('link'+linkId);
	activeCheckBox = document.getElementById(linkId);
	linkId = linkId.split("varified")
	//alert(fileUrl[linkId[1]] + " - "+ linkId[1])
	linkId = fileUrl[linkId[1]]
	activeLink.href = baseFilePath+linkId + '.mp3'
	activeLink.onclick = ''
	activeCheckBox.disabled = true;

	//setTimeout("alert(\"you may now download the file\")", 5000);
	}
}



var fileList = document.getElementById('fileListDiv').innerHTML
var fileListContainer = document.getElementById('fileListContainerDiv')

fileUrl = fileList.split(",")
var fileName = new Array()
//alert(fileUrl.length)
for (x=0; x<fileUrl.length; x++) {
fileName[x] = fileUrl[x].split("-")[1]
fileUrl[x] = fileUrl[x].split("-")[0]
}

function showLicense(id) {
  sLicense = window.open('/clientDev/domains/openaudio/ccLicense.html?'+id, 'license', 'width=652,height=570,location=0,toolbar=0,scrollbars=1,screenX=200,screenY=100,left=200,top=100');
}

function remLink() {
  if (window.sLicense && window.sLicense.open && !window.sLicense.closed)
    window.sLicense.opener = null;
}
html = '';
for (i=0; i<fileUrl.length; i++) {
//alert(fileUrl[i] + "-" + fileName[i] )
html += '<a href="#" id="linkvarified'+i+'"';
html +=	'	onclick="showLicense(\'varified'+i+'\'); return false;" title="'+fileName[i]+'"';
html += ' target="_blank">'+fileName[i]+'</a>';
html +=	' <input onFocus="activateLink(this.id)" type="checkbox" disabled id="varified'+i+'" /> <br/><br/>';
fileListContainer.innerHTML = html; 
}
*/