function tabMenu(value){

	// set the tab highlight
	for (x=1; x<4; x++){
		if (x == value){
			document.getElementById("li"+x).setAttribute("class", "selected");
			document.getElementById("li"+x).setAttribute("className", "selected");// for IE		
		}else{
			document.getElementById("li"+x).setAttribute("class", "");
			document.getElementById("li"+x).setAttribute("className", "");
		}
	}
	
	// tab function
	if (value==3)
		window.location = 'highlight.php';	
	else if (value==2)
		new Ajax.Updater('bookadddiv', 'book_public.php', {evalScripts:true});		
	else if (value==1)
		new Ajax.Updater('bookadddiv', 'book_personal.php', {evalScripts:true});				
	else if (value==4){
		new Ajax.Updater('fb_logindiv', 'logout.php', {evalScripts:true});				
	}	
}

function ajaxReplyEnquiry (enquiryID){
	var postBodyStr = 'enquiryID=' + enquiryID;
	new Ajax.Updater('enquiryhiddendiv', 'enquiry_reply.php', {evalScripts:true, postBody:postBodyStr});		
}

function ajaxEditEnquiry (enquiryID){
		var postBodyStr = 'enquiryID=' + enquiryID;
		new Ajax.Updater('enquiryhiddendiv', 'enquiry_edit.php', {evalScripts:true, postBody:postBodyStr});		
		//new Ajax.Request('enquiry_edit.php', {evalJS: true, postBody:postBodyStr});		
}

function ajaxPostEnquiry(enquiryProduct){	
	// the encodeURCompoenent is require to preserve & character in note	
	var postBodyStr = 'enquiryNote=' + 
		encodeURIComponent($('enquiryNote_'+enquiryProduct).value) +
		'&enquiryProduct=' + enquiryProduct ;
	//alert(postBodyStr);	
	new Ajax.Updater('enquirydisplaydiv_'+enquiryProduct, 'enquiry_add.php', 
		{evalScripts:true, postBody:postBodyStr});	 	
}

function focusClear(){
	//alert("hi");
	document.getElementById("bookText").value = "";
	document.getElementById("bookText").onfocus=function(){ nothing(); }; 
}

function nothing(){
// do nothing
}


function processData(data) {
	document.getElementById("bookadddiv").innerHTML = data;
}

function book_edit(bookID){
	postBodyStr = 
		'bookID=' + bookID;
	new Ajax.Updater('bookeditdiv', 'book_edit.php', {evalScripts:true, postBody:postBodyStr});	 		
}

function book_collect(bookID){
	postBodyStr = 'bookID=' + bookID;
	new Ajax.Updater('bookLine'+bookID, 'book_collect.php', {evalScripts:true, postBody:postBodyStr});	 		
}

function book_remove(bookID){
	postBodyStr = 'bookID=' + bookID;
	new Ajax.Updater('bookLine'+bookID, 'book_remove.php', {evalScripts:true, postBody:postBodyStr});	 		
}


function book_update(bookID){
	var postBodyStr = 'bookText=' + 
		encodeURIComponent($('bookText').value) +
		'&bookID=' + bookID; 	// the encodeURCompoenent is require to preserve & character in note	
	new Ajax.Updater('bookeditdiv', 'book_update.php', {evalScripts:true, postBody:postBodyStr});	 		
}

function book_add()
{	

	if (document.getElementById("bookText").value.length > 1000000){
		//document.getElementById("waitdiv").toggle();//$('waitdiv').toggle();
		alert("Please limit to only 1MB of text. Please email ljcollections@gmail.com if you need more.");
		$("submit").disabled=false;
		$("enquirywaitdiv").toggle();
		return;
	}
	
	/*
	if (document.getElementById("bookTitle").value == "" || document.getElementById("bookTitle").value == "Enter Book Title"){
		//document.getElementById("waitdiv").toggle();//$('waitdiv').toggle();
		alert("Please enter a title");
		$("submit").disabled=false;
		$("enquirywaitdiv").toggle();
		$('bookTitle').focus();
		return;
		
	}else 
	*/
	if (document.getElementById("bookText").value == "" || document.getElementById("bookText").value.substring(0,3)=="How"){
		//document.getElementById("waitdiv").toggle();//$('waitdiv').toggle();
		alert("Please paste the content");
		$("submit").disabled=false;
		$("enquirywaitdiv").toggle();
		$('bookText').focus();
		return;
	}
	
	//alert(document.getElementById("bookText").value.substring(0,3));
	postBodyStr = 
		'bookTitle='+ encodeURIComponent( document.getElementById("bookTitle").value ) + 
		'&bookText=' + encodeURIComponent( document.getElementById("bookText").value );		
	new Ajax.Updater('bookpublishdiv', 'book_add.php', {evalScripts:true, postBody:postBodyStr});	 	
}		

function ajaxUpdateVisit (bookID){
	var postBodyStr = 'bookID=' + bookID;
	new Ajax.Request('book_visit.php', {postBody:postBodyStr});
	
	//new Ajax.Updater('descriptiondiv' , 'blog_visit.php', 
	//	{asynchronous:true, method:'post', postBody:postBodyStr});	
}
	