// JavaScript Document


function showPanel(panel, show){
var obj = null;
	obj=document.getElementById(panel);
	if(harden){
		obj.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(Opacity=1.0)";
		obj.style.opacity ="1.0";
	}else{
		obj.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(Opacity=0.87)";
		obj.style.opacity ="0.87";
	}
}

function showHelp(){
	fetchData('http://www.selfhelprecordings.com/information/instructions.asp', 0, 'infoBoxContent');
	objPopUp = document.getElementById('infoBoxContent');
	objPopUp.innerHTML = '<strong>Loading...</strong>';
}

function filterData(pageRequest, objectID){
	if(pageRequest.readyState == 4 && (pageRequest.status == 200 || window.location.href.indexOf("http") == -1)) document.getElementById(objectID).innerHTML=pageRequest.responseText;
}

function fetchData(url, dataToSend, objectID){
	var pageRequest = false;
	if(window.XMLHttpRequest) pageRequest= new XMLHttpRequest();
	else if(window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
	else return false;
	pageRequest.onreadystatechange = function(){
			filterData(pageRequest, objectID);
	}
	if(dataToSend){
			var sendData = 'sendData=' + dataToSend;
			pageRequest.open('POST', url, true);
			pageRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			pageRequest.send(sendData);
	}
	else{
		pageRequest.open('GET', url, true);
		pageRequest.send(null);
	}
}

function SubNav(catOver){
	var cat1Height = 0;
	var catObj = null;
	var coverObj = null;
	catObj = document.getElementById('cat1');
	coverObj = document.getElementById('productCover');
	catObj.style.top = (catOver * 23)+ 210+"px";
	catObj.style.display = "block";
	var fillText= "";
	var catCount = 0;
	for(i = 0; i < mainCats.length; i++){
		if(mainCats[i] == catOver){
			fillText += "<div class='midCatLink'><a href='javascript:void();' onmouseover='viewLinks(" + i + "," + catCount + ")'>" + viewCats[i] + "</a></div>";
			cat1Height += 23;
			catCount += 1;
		}
	}
	if( cat1Height > 275){
		fillText += "<div id='productCover' style='top:" + (23 * catOver) + "px'>" + catsArray[catOver] + "</div>";
	}else
	{
		fillText += "<div id='productCover'>" + catsArray[catOver] + "</div>";
	}
	fillText += "<div id='productList' ><a href='javascript:void();'>product</a><div id='midLinkCover'>ssssssssssssssss</div></div>"
	catObj.innerHTML = fillText;
	if( cat1Height > 275){
		catObj.style.top = 210+"px";
	}
}

function viewLinks(category, catCount){
	ProductCategory = dbCats[category];
	var objProductList = null;
	var objProductCover = null;
	var numberListed = 0;
	objProductList = document.getElementById("productList");
	
	var fillText = "";
	if(category != 37){
		objProductList.style.width = '450px'
		for(i = 0; i < Navproducts.length; i++){
			if(NavproductCategories[i] == ProductCategory.substring(0, ProductCategory.indexOf('/'))){
			fillText += "<div class='productItem'> <a href='" + NavproductURL[i] + "' style='font-weight:normal; text-decoration:underline;'>"+Navproducts[i] + " By " + NavAuthor[i] + "</a></div>";
			numberListed ++;
			}
		}
		objProductList.style.top =  (catCount * 26)+"px";
		fillText += "<div id='midLinkCover'>" +  viewCats[category] + "</div>"
	}
	else{
			objProductList.style.width = '540px';
			for(i = 0; i < Navproducts.length; i++){
			if(NavproductCategories[i] == ProductCategory.substring(0, ProductCategory.indexOf('/'))){
			fillText += "<div class='productItem' style='width: 250px; float: left'> <a href='" + NavproductURL[i] + "' style='font-weight:normal; text-decoration:underline;'>"+Navproducts[i] + "</a></div>";
			numberListed ++;
			}
		}
		objProductList.style.top =  "-1px";
		fillText += "<div id='midLinkCover' style='top: 52px;'>" +  viewCats[category] + "</div>"
	}

	objProductList.style.display = "block";
	objProductList.innerHTML = fillText;
}


function closeAll(){
	document.getElementById("productList").style.display = "none";
	document.getElementById("cat1").style.display = "none";
}
function sortOutPhobias(){
			
}

for (var i = 0; i < Navproducts.length; i++){
	
}


var catsArray = new Array("Addictions/Compulsions", "Anxiety &amp; Fear", "Depression", "Family", "Food &amp; Body Image", "Physical Problems", "Relationships", "Self Improvement", "Sexuality", "Sleep Issues");