function alreadyOptions(obj){
	if(obj!=null && obj.options!=null){return true;}return false;
}

function selectedOptionsCopy(from,to, ele){
	var options = new Object();
	if(alreadyOptions(to)){
		for(var i=0;i<to.options.length;i++){
			options[to.options[i].value] = to.options[i].text;
		}
	}
	if(!alreadyOptions(from)){
		return;
	}
	eleid = document.getElementById(ele);
	for(var i=0;i<from.options.length;i++){
		var o = from.options[i];
		if(o.selected){
			if(options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text){
				if(!alreadyOptions(to)){
					var index = 0;
				}else{
					var index=to.options.length;
				}
				to.options[index] = new Option( o.text, o.value, false, false);
				eleid.value = to.options[index].value + ";"+ eleid.value;
			}
		}
	}

	if((arguments.length<3) ||(arguments[2]==true)){
		sortSelect(to);
	}
	from.selectedIndex = -1;to.selectedIndex = -1;
}

function removeSelectedOptions(from, ele){
	if(!alreadyOptions(from)){
		return;
	}
	eleid = document.getElementById(ele);
	eleid.value = '';
	if(from.type=="select-one"){
		from.options[from.selectedIndex] = null;
	}else{
		for(var i=(from.options.length-1);i>=0;i--){
			var o=from.options[i];
			if(o.selected){
				from.options[i] = null;
			}else{
				eleid.value = from.options[i].value + ";"+ eleid.value;
			}
		}
	}
	from.selectedIndex = -1;
}

function author_validation(){
	if(document.author_create.username.value.toLowerCase() == "") {
		alert("Author pen name should not be empty");
		document.author_create.username.select();
		document.author_create.username.focus();
		return false;
	}

	if(document.author_create.username.value != '') {
		if(document.author_create.username.value.toLowerCase() == document.author_create.user_name_chk.value) {
			alert("User name already exist.");
			document.author_create.username.select();
			document.author_create.username.focus();
			return false;
		}
	}

	if(document.author_create.password.value == ""){
		alert("Password should not be empty");
		document.author_create.password.select();
		document.author_create.password.focus();
		return false;
	}

	if(document.author_create.password.value != document.author_create.repassword.value){
		alert("Confirm password should not be match");
		document.author_create.repassword.select();
		document.author_create.repassword.focus();
		return false;
	}
	
	if(document.author_create.first_name.value.toLowerCase() == "") {
		alert("Customer name should not be empty");
		document.author_create.first_name.select();
		document.author_create.first_name.focus();
		return false;
	}

	if(document.author_create.email_address.value == ""){
		alert(" Please enter your email address");
		document.author_create.email_address.select();
		document.author_create.email_address.focus();
		return false;
	}

	if(document.author_create.email_address.value != ""){
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.author_create.email_address.value))){
			alert("Invalid E-mail Address! Please re-enter");
			document.author_create.email_address.select();
			document.author_create.email_address.focus();
			return false;
		}
	}

	if(document.author_create.country.value.toLowerCase() == "") {
		alert("Country should not be empty");
		document.author_create.country.focus();
		return false;
	}
}

function validation(){

	if(document.user_registration.username.value.toLowerCase() == "") {
		alert("Customer pen name should not be empty");
		document.user_registration.username.focus();
		return false;
	}

	if(document.user_registration.username.value != '') {
		if(document.user_registration.username.value.toLowerCase() == document.user_registration.user_name_chk.value) {
			alert("User name already exist.");
			document.user_registration.username.select();
			document.user_registration.username.focus();
			return false;
		}
	}

	if(document.user_registration.password.value == ""){
		alert("Password should not be empty");
		document.user_registration.password.select();
		document.user_registration.password.focus();
		return false;
	}

	if(document.user_registration.password.value != document.user_registration.repassword.value){
		alert("Confirm password should not be match");
		document.user_registration.repassword.select();
		document.user_registration.repassword.focus();
		return false;
	}
	
	if(document.user_registration.first_name.value.toLowerCase() == "") {
		alert("Customer name should not be empty");
		document.user_registration.first_name.select();
		document.user_registration.first_name.focus();
		return false;
	}

	if(document.user_registration.email_address.value == ""){
		alert(" Please enter your email address");
		document.user_registration.email_address.select();
		document.user_registration.email_address.focus();
		return false;
	}

	if(document.user_registration.email_address.value != ""){
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.user_registration.email_address.value))){
			alert("Invalid E-mail Address! Please re-enter");
			document.user_registration.email_address.select();
			document.user_registration.email_address.focus();
			return false;
		}
	}
	
	/*if(document.user_registration.postcode.value == "") {
		alert("Postcode should not be empty");
		document.user_registration.postcode.select();
		document.user_registration.postcode.focus();
		return false;
	}

	if(document.user_registration.state.value == "") {
		alert("State should not be empty");
		document.user_registration.state.select();
		document.user_registration.state.focus();
		return false;
	}*/

	if(document.user_registration.country.value.toLowerCase() == "") {
		alert("Country should not be empty");
		document.user_registration.country.focus();
		return false;
	}

	/*if(document.user_registration.bookGrinder_club_name.value == '') {
		alert("BookGrinder club name should not be empty.");
		document.user_registration.bookGrinder_club_name.select();
		document.user_registration.bookGrinder_club_name.focus();
		return false;
	}*/
	if(document.user_registration.bookGrinder_club_name.value != '') {
		if(document.user_registration.bookGrinder_club_name.value.toLowerCase() == document.user_registration.bk_nm_chk.value) {
			alert("BookGrinder club name already exist.");
			document.user_registration.bookGrinder_club_name.select();
			document.user_registration.bookGrinder_club_name.focus();
			return false;
		}
	}

	if(document.user_registration.secret_question.value.toLowerCase() == ''){
		alert("Secret question should not be empty");
		document.user_registration.secret_question.select();
		document.user_registration.secret_question.focus();
		return false;
	}

	if(document.user_registration.secret_answer.value == ''){
		alert("Secret answer should not be empty");
		document.user_registration.secret_answer.select();
		document.user_registration.secret_answer.focus();
		return false;
	}

	if(document.user_registration.secret_answer.value != document.user_registration.confirm_secret_answer.value){
		alert("Confirm secret answer should not be match");
		document.user_registration.confirm_secret_answer.select();
		document.user_registration.confirm_secret_answer.focus();
		return false;
	}
	if(document.user_registration.user_type.value == 'author'){
		adbk = document.getElementById('add_books');
		yopub = document.getElementById('your_publisher');
		adpub = document.getElementById('add_publishers');
		if(adbk.value == ''){
			alert("Please enter your book name");
			adbk.focus();
			return false;
		}
		if(adpub.value == ''){
			error = false;
			for (i=0; i < yopub.options.length; i++){
				if (yopub.options[i].selected){
					error = true;
					return true;
				}
			}
			if(error == false){
				alert("Please select publishers");
				yopub.focus();
				return false;
			}
		}
	}

}

function setType(val){
	document.user_registration.user_type.value = val;
}


var http;
var did;
function default_value(){
	document.user_registration.bookname.value = 0;
	document.user_registration.publishername.value = 0;
	document.user_registration.authorname.value = 0;
	document.user_registration.favbookname.value = 0;
	document.user_registration.favgenresname.value = 0;
	document.user_registration.bookclubname.value = 0;
}
//auto_book_filed
function auto_book_filed(){
	val = document.user_registration.bookname.value = parseInt(document.user_registration.bookname.value) + 1;
	check_data('book_field', val, 'bookadd');
}
//auto_publisher_filed
function auto_publisher_filed(){
	val = document.user_registration.publishername.value = parseInt(document.user_registration.publishername.value) + 1;
	check_data('publisher_field', val, 'publisheradd');
}
//auto_author_filed
function auto_author_filed(){
	val = document.user_registration.authorname.value = parseInt(document.user_registration.authorname.value) + 1;
	check_data('author_field', val, 'authoradd');
}
//auto_fav_book_filed
function auto_fav_book_filed(){
	val = document.user_registration.favbookname.value = parseInt(document.user_registration.favbookname.value) + 1;
	check_data('fav_book_field', val, 'favbookadd');
}
//auto_fav_genres_filed
function auto_fav_genres_filed(){
	val = document.user_registration.favgenresname.value = parseInt(document.user_registration.favgenresname.value) + 1;
	check_data('fav_genres_field', val, 'favgenresadd');
}
//auto_books_club_filed
function auto_books_club_filed(){
	val = document.user_registration.bookclubname.value = parseInt(document.user_registration.bookclubname.value) + 1;
	check_data('books_club_field', val, 'booksclubadd');
}
function check_data(filed, val, type) {
   var url = 'check_names.php?val='+val+'&type='+type;
	did = filed+val;
   // Internet Explorer
   try { http = new ActiveXObject("Msxml2.XMLHTTP"); }
   catch(e) {
      try { http = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(oc) { http = null; }
   }

   // Mozailla/Safari
   if (!http && typeof XMLHttpRequest != "undefined") { http = new XMLHttpRequest(); }

   // Call the processChange() function when the page has loaded
   if (http != null) {
      http.onreadystatechange = processChangeData;
      http.open("GET", url, true);
      http.send(null);
   }
}

function processChangeData() {
   // The page has loaded and the HTTP status code is 200 OK
   if (http.readyState == 4 && http.status == 200) {
      // Write the contents of this URL to the searchResult layer
      getObjectData(did).innerHTML = http.responseText;
   }
}

function getObjectData(name) {
   var ns4 = (document.layers) ? true : false;
   var w3c = (document.getElementById) ? true : false;
   var ie4 = (document.all) ? true : false;

   if (ns4) return eval('document.' + name);
   if (w3c) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   return false;
}

function check_names(name, userid) {
	if(userid){
		id = '&id='+userid;
	}else{
		id = '';
	}
   var url = 'check_names.php?name='+name+id;
   // Internet Explorer
   try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
   catch(e) {
      try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(oc) { req = null; }
   }

   // Mozailla/Safari
   if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }

   // Call the processChange() function when the page has loaded
   if (req != null) {
      req.onreadystatechange = processChange;
      req.open("GET", url, true);
      req.send(null);
   }
}

function processChange() {
   // The page has loaded and the HTTP status code is 200 OK
   if (req.readyState == 4 && req.status == 200) {
      // Write the contents of this URL to the searchResult layer
      getObject("chk_name").innerHTML = req.responseText;
   }
}

function getObject(name) {
   var ns4 = (document.layers) ? true : false;
   var w3c = (document.getElementById) ? true : false;
   var ie4 = (document.all) ? true : false;

   if (ns4) return eval('document.' + name);
   if (w3c) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   return false;
}

function del(id, url){
	conf = confirm("Are you sure to delete record");
	if(conf == true){
		window.location.href = '/accounts/'+url+'/delid/'+id;
	}
}

function validation_login(){
	if(document.user_login.username.value == "") {
		alert("Customer pen name should not be empty");
		document.user_login.username.select();
		document.user_login.username.focus();
		return false;
	}
	if(document.user_login.forgetval.value != 'forgetpass'){
		if(document.user_login.password.value == "") {
			alert("Password should not be empty");
			document.user_login.password.select();
			document.user_login.password.focus();
			return false;
		}
	}
	if(document.user_login.forgetval.value == 'forgetpass'){
		if(document.user_login.secret_answer.value == "") {
			alert("Secret password should not be empty");
			document.user_login.secret_answer.select();
			document.user_login.secret_answer.focus();
			return false;
		}
	}
}

function hideshow(){
	var login = document.getElementById('login');
	var forgot = document.getElementById('forgot');
	if(forgot.style.display == 'none'){
		login.style.display = 'none';
		forgot.style.display = '';
		document.user_login.forgetval.value = 'forgetpass';
	}else{
		login.style.display = '';
		forgot.style.display = 'none';
		document.user_login.forgetval.value = '';
	}
}

function showhide(){
	var eclub = document.getElementById('edit_club');
	var jclub = document.getElementById('join_club');
	if(eclub.style.display == 'none'){
		jclub.style.display = 'none';
		eclub.style.display = '';
	}else{
		jclub.style.display = '';
		eclub.style.display = 'none';
	}
}

function club_edit(){
	if(document.edit_bookclub.bcname.value.toLowerCase() == ''){
		alert("Please enter book club name");
		document.edit_bookclub.bcname.select();
		document.edit_bookclub.bcname.focus();
		return false;
	}
}

function grinder_valid(){
	var today = new Date();
	var month = today.getMonth()+1;
	var day = today.getDate();
	if(day<10) day = "0" + day;
	if(month<10) month= "0" + month;

	if(document.grinder.tempid.value == '1'){
		if(document.grinder.bbcname.value == ''){
			alert("Please enter bookgrinder club name");
			document.grinder.bbcname.select();
			document.grinder.bbcname.focus();
			return false;
		}
	}else if(document.grinder.tempid.value == '0'){
		if(document.grinder.bookGrinder_club_name.value == ''){
			alert("Please enter bookgrinder club name");
			document.grinder.bookGrinder_club_name.select();
			document.grinder.bookGrinder_club_name.focus();
			return false;
		}
	}
	
	if(document.grinder.tempid.value == '1'){
		if(document.grinder.bbcname.value != '') {
			if(document.grinder.bbcname.value.toLowerCase() == document.grinder.bk_nm_chk.value) {
				alert("BookGrinder club name already exist.");
				document.grinder.bbcname.select();
				document.grinder.bbcname.focus();
				return false;
			}
		}
	}else if(document.grinder.tempid.value == '0'){
		//if(document.grinder.bookGrinder_club_name.value != '') {
			if(document.grinder.bookGrinder_club_name.value.toLowerCase() == document.grinder.bk_nm_chk.value) {
				alert("BookGrinder club name already exist.");
				document.grinder.bookGrinder_club_name.select();
				document.grinder.bookGrinder_club_name.focus();
				return false;
			}
		//}
	}
	
	/*if(document.grinder.bbcentvenus.value != ''){
		if(document.grinder.evtdate.value == ''){
			alert("Please select date");
			document.grinder.evtdate.focus();
			return false;
		}else{
			if(document.grinder.evtmonth.value < month){
				if(document.grinder.evtdate.value < day){
					//alert("Please select future date and month");
					//document.grinder.evtdate.focus();
					//return false;
				}
			}
			if(document.grinder.evtmonth.value < month){
				//alert("Please select future date and month");
				//document.grinder.evtmonth.focus();
				//return false;
			}
		}
		if(document.grinder.evtyear.value == ''){
				//alert("Please select Year");
				//document.grinder.evtyear.focus();
				//return false;
		}
	}*/
}

function book_validation(){
	if(document.book.book_name.value == ''){
		alert("Please enter book name");
		document.book.book_name.select();
		document.book.book_name.focus();
		return false;
	}

	if(document.book.user_type.value == 'author'){
		if(document.book.previous_sign_image.value == ''){
			if(document.book.signature_book.value == ''){
				alert("Please upload signature book");
				document.book.signature_book.select();
				document.book.signature_book.focus();
				return false;
			}
		}
	}

	if(document.book.user_type.value == 'author'){
		adbk = document.getElementById('add_auth');
		if(document.book.book_author_text.value == ''){
			if(adbk.value == ''){
				alert("Please select book author");
				adbk.focus();
				return false;
			}
		}
	}

}



function item_validate(){

   if(document.items.item_title.value == ''){
		alert(" Book Name should not be empty");
		document.items.item_title.select();
		document.items.item_title.focus();
		return false;
	}
	
	if(document.items.item_category.value == '0'){
		alert("Category should not be empty");
		//document.items.item_category.select();
		document.items.item_category.focus();
		return false;
	}
	
	
	if(document.items.publisher.value == '0' && document.items.book_pub_text.value == ''){
		alert("Books Publisher should not be empty");
		//document.items.publisher.select();
		document.items.publisher.focus();
		return false;
	}
	
	
/* 	if(document.items.image_upload[0].value == ''){
		alert("Image Upload (thumbnail) should not be empty");
		//document.items.publisher.select();
		document.items.image_upload[0].focus();
		return false;
	}
	
	
	if(document.items.image_upload[1].value == ''){
		alert("Image Upload should not be empty");
		//document.user_registration.image_upload[1].select();
		document.user_registration.image_upload[1].focus();
		return false;
	}
	
*/

}


function chg_pass_validation(){

	if(document.form1.password.value == ""){
		alert("Password should not be empty");
		document.form1.password.select();
		document.form1.password.focus();
		return false;
	}

	if(document.form1.new_password.value == ""){
		alert("New Password should not be empty");
		document.form1.new_password.select();
		document.form1.new_password.focus();
		return false;
	}

	if(document.form1.new_password.value != document.form1.password_confirm.value){
		alert("Confirm password should not be match");
		document.form1.password_confirm.select();
		document.form1.password_confirm.focus();
		return false;
	}
}

var req = createReqObj(); 

function createReqObj(){
	var request_ads; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		request_ads = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_ads = new XMLHttpRequest();
	}
	return request_ads; //return the object
}

function showAds(ads_id){
	req.open('get', '/pages/page_news_banner/'+ads_id);
	req.onreadystatechange =  banners; 
	req.send(null);
}

function banners(){
	if(req.readyState == 4){ 
	   var response = req.responseText;
 	   document.getElementById('bann').innerHTML = response;
	}
}

function show_subcategoies(cats_id, sub_id){
	if(sub_id){
		sub_id = sub_id;
	}else{
		sub_id = '';
	}
	req.open('get', '/accounts/sub_categories/'+cats_id+'/'+sub_id);
	req.onreadystatechange =  subcate; 
	req.send(null);
}

function subcate(){
	if(req.readyState == 4){ 
	   var response = req.responseText;
 	   document.getElementById('subcategories_details').innerHTML = response;
	}
}

function chk_categories(){
	if(document.categories.categories_name.value == ''){
		alert("Please enter categories name");
		document.categories.categories_name.focus();
		document.categories.categories_name.select();
		return false;
	}
}

function chk_sub_categories(){
	if(document.subcategories.categories_id.value == ''){
		alert("Please enter categories name");
		document.subcategories.categories_id.focus();
		return false;
	}
	if(document.subcategories.sub_categories_name.value == ''){
		alert("Please enter sub-categories name");
		document.subcategories.sub_categories_name.focus();
		document.subcategories.sub_categories_name.select();
		return false;
	}
}


// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function chk_users_categories(){
	if(document.user_category.user_first_name.value == ''){
		alert("Please enter first name");
		document.user_category.user_first_name.focus();
		return false;
	}
	if(document.user_category.user_last_name.value == ''){
		alert("Please enter last name");
		document.user_category.user_last_name.focus();
		return false;
	}

	if(document.user_category.users_emailid.value == ""){
		alert(" Please enter your email address");
		document.user_category.users_emailid.select();
		document.user_category.users_emailid.focus();
		return false;
	}

	if(document.user_category.users_emailid.value != ""){
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.user_category.users_emailid.value))){
			alert("Invalid E-mail Address! Please re-enter");
			document.user_category.users_emailid.select();
			document.user_category.users_emailid.focus();
			return false;
		}
	}

	if(document.user_category.users_listing.value == ""){
		alert(" Please enter your listing title");
		document.user_category.users_listing.select();
		document.user_category.users_listing.focus();
		return false;
	}

	if(document.user_category.users_emailid.value != ""){
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.user_category.users_emailid.value))){
			alert("Invalid E-mail Address! Please re-enter");
			document.user_category.users_emailid.select();
			document.user_category.users_emailid.focus();
			return false;
		}
	}

	if(document.user_category.user_address.value == ''){
		alert("Please enter address");
		document.user_category.user_address.focus();
		return false;
	}
	if(document.user_category.user_phone.value == ''){
		alert("Please enter phone/mobile number");
		document.user_category.user_phone.focus();
		return false;
	}

	if (checkInternationalPhone(document.user_category.user_phone.value)==false){
		alert("Please enter a valid phone number");
		document.user_category.user_phone.focus();
		return false;
	}

	if(document.user_category.user_city.value == ''){
		alert("Please enter city");
		document.user_category.user_city.focus();
		return false;
	}
	if(document.user_category.user_state.value == ''){
		alert("Please enter state");
		document.user_category.user_state.focus();
		return false;
	}
	if(document.user_category.country.value == ''){
		alert("Please select country");
		document.user_category.country.focus();
		return false;
	}
	if(document.user_category.user_zip.value == ''){
		alert("Please enter zip code");
		document.user_category.user_zip.focus();
		return false;
	}
	if(document.user_category.users_organization.value == ''){
		alert("Please enter organization name");
		document.user_category.users_organization.focus();
		return false;
	}
	if(document.user_category.website.value == ''){
		alert("Please enter website url");
		document.user_category.website.focus();
		return false;
	}
	if(document.user_category.main_categories.value == ''){
		alert("Please select category");
		document.user_category.main_categories.focus();
		return false;
	}
	if(document.user_category.users_description.value == ''){
		alert("Please enter description");
		document.user_category.users_description.focus();
		return false;
	}
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
	var bracket=3
	strPhone=trim(strPhone)
	if(strPhone.indexOf("+")>1) return false
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
	var brchr=strPhone.indexOf("(")
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function advnce_opt(){
	var adv = document.getElementById('advopt');
	if(adv.style.display == 'none'){
		adv.style.display = '';
	}else{
		adv.style.display = 'none';
	}
}

function reqpopup(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=550,height=190,screenX=150,screenY=150,top=150,left=150')
}

function search_keyword(){
	if(document.search_keywords.keyword.value == ''){
		alert("Please enter keyword");
		document.search_keywords.keyword.focus();
		return false;
	}
	if(document.search_keywords.link.value == ''){
		alert("Please enter link");
		document.search_keywords.link.focus();
		return false;
	}
}

function book_validate(){
	 if(document.book.item_title.value == ''){
		alert(" Book Name should not be empty");
		document.book.item_title.select();
		document.book.item_title.focus();
		return false;
	}
	
	if(document.book.item_category.value == '0'){
		alert("Category should not be empty");
		document.book.item_category.focus();
		return false;
	}
}

var http = createRequestObject();
function search(clk, keyword){
	http.open('get', 'search/sea/'+clk+'/'+keyword+'/');
	http.onreadystatechange =  search_list; 
	http.send(null);
}

function search_list(){
	if(http.readyState == 4){ 
	   var response = http.responseText;
 	   document.getElementById('search_show').innerHTML = response;
	}
}

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}