// JavaScript Document

google.setOnLoadCallback(function(){	
	
	//insert custom product/author info in page
	$("#moreInfo").each(function(){
	prodID = $(this).attr("class");
	var infoURL = "http://" + location.host + "/xml/moreProductInfo.asp #" + prodID +" .leadership";
	//alert (infoURL);
	$(this).load(infoURL);							 
								 
								 });
	
	
	$(".authorThm").each(function(){
		authorImage = $(this).text();
		findImg(authorImage,$(this));
		
								  })
	
	//main menu operation
	/*$("#list a").click(function(){
			
			$("#details>div").hide();
			var prodID = $(this).attr("class");
			showInfo(prodID);
			$("#"+prodID).fadeIn("slow");
									 
									 
									 }) */
	

// get params from url
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function findImg(aName,domNode){
	var xmlResult;
	var xmlURL = "http://" + location.host + "/img/authorImages.asp?a=" + aName;
	//alert(xmlURL);
	 $.ajax({
			type: "GET",
			url: xmlURL,
			dataType: "xml",
			success: function(xml){
				//alert("XML successfully loaded");
				$(xml).find("image").each(function(){	
					imageDescription = $(this).find("desc").text();
					imageLink = $(this).find("location").text();
					if (imageDescription == "Author Thumbnail"){
					xmlResult = '<img src="' + imageLink + '" border="0" alt="' + aName.replace("_"," ") + '"/>';
					$(domNode).html(xmlResult).show();
					}
					
				})
			}
		
		});
	
	
	
}

// load enhanced buy button
$("#buybtn").buynow();

//end jQuery
});


function showHide(obj) {
	 	 if (document.getElementById(obj).style["display"] == "none") {
	 	document.getElementById(obj).style["display"] = "";
			}
		else
			{document.getElementById(obj).style["display"] = "none";}
		}
		
function dualTabs(obj1,obj2) {
	 	 if (document.getElementById(obj1).style["display"] == "none") {
	 	document.getElementById(obj2).style["display"] = "none";
		document.getElementById(obj1).style["display"] = "";
			}
		//else {
		//document.getElementById(obj1).style["display"] = "none";
		//document.getElementById(obj2).style["display"] = "";
		//	}
			
		}
		
		
		
		
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function redir(isbn13){
                 window.location='books.asp?p=' + isbn13;
                    
                    }



function switchtabs(tabID){ 

// Detail Tabs Array
var tabMenu = document.getElementById("detailsmenu");
var tabList = tabMenu.getElementsByTagName("li");

// Detail Content Array
var tabContentDiv = document.getElementById("detailcontent");
var tabContent1 = tabContentDiv.getElementsByTagName("div");

// get only Tab class
var tabContent = new Array()
var classname="tab"
var inc=0
for (i=0; i<tabContent1.length; i++){
	//alert(tabContent1[i].className)
		if (tabContent1[i].className==classname){
		//alert(tabContent1[i].id);
		tabContent.push(tabContent1[i]);
		
		}
}
//cycle through tabs, show only selected, hide all others, highlight current menu tab
for(i=0; i<tabContent.length; i++){
	//alert(tabContent[i].id);
	if(tabContent[i].id != tabID){
		tabContent[i].style["display"]="none";
		tabList[i].setAttribute("class","");
		tabList[i].setAttribute("className","");	
		//alert(tabID + " != " + tabContent[i].id);
	}
	
	else{ 
		tabContent[i].style["display"]="block";
		tabList[i].setAttribute("class","current");
		tabList[i].setAttribute("className","current");
		//alert(tabID + " = " + tabContent[i].id);
	}
  }

}