	//<!--web login start-->//
	function webLogIn(){
		myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			
			if(html_entity_decode(decodeURIComponent(myAjax.result.content.response.title))=="Error"){
				alert('Could not login - please check your username and/or password.');
			}else{
				document.getElementById('login').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
				if(returnDocument()=='archive-comment.php' ||returnDocument()=='keane-view-release.php' || returnDocument()=='keane-biography.php' || returnDocument()=='keane-view-track.php' || returnDocument()=='keane-live-view.php' || returnDocument()=='keane-live-photo.php' || returnDocument()=='video.php' ){
					location.reload(true);
				}
			}
			//alert(html_entity_decode(decodeURIComponent(myAjax.result.content.response.title)))
			//document.getElementById('login').innerHTML='aa';
			//location.reload(true);
			
		}
		params=[{varName:"action",value:'logIn'},{varName:"username",value:document.getElementById('form-login-username').value},
				{varName:"password",value:document.getElementById('form-login-password').value}];
		
		myAjax.makeRequest('ajax_login.php',params);
	}
	function logOut(){
		myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			//document.getElementById('loginPanel').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			
			if(returnDocument()=='register.php'){
				window.location = "register.php";
			}else{
				location.reload(true);
			}
		}
		params=[{varName:"action",value:'logOut'}];
		//document.getElementById('searchForm').innerHTML='';
		//document.getElementById('searchResult').innerHTML='';
		myAjax.makeRequest('ajax_login.php',params);
	}
	
	function LogIn(username,password){
		myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('loginPanel').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
		}
		params=[{varName:"action",value:'logIn'},{varName:"username",value:username},{varName:"password",value:password}];
		myAjax.makeRequest('ajax_login.php',params);
	}
	//<!--web login end-->//
	
	//<!--search login start-->//
	function Search(section_name){
		myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('column-1').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			document.getElementById('content').className='content';
		}
		params=[{varName:"search_str",value:document.getElementById('keyword').value},
				{varName:"action",value:'search'},{varName:"rnd",value:section_name}];
		document.getElementById('column-1').innerHTML='<div style="width; 100%; text-align: center;"><strong>Searching...</strong></div>';
		myAjax.makeRequest('ajax_search.php',params);
	
	}
	function advancedSearch(){
		myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('searchResult').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			alert(document.getElementById('searchResult').innerHTML);
		}
		params=[{varName:"action",value:'advancedSearch'},{varName:"account_number",value:document.getElementById('account_number').value},
			{varName:"name",value:document.getElementById('name').value},{varName:"address",value:document.getElementById('address').value}];
		document.getElementById('searchResult').innerHTML='<div style="width; 100%; text-align: center;"><strong>Searching...</strong></div>';
		myAjax.makeRequest('ajax_search.php',params);
	}
	
	function searchAgain(){
			document.getElementById('rightForm1').innerHTML="<div id=\"form-controls\"><div id=\"rightForm1\" class=\"form-panel\"><form id=\"simpleSearch\" action=\"\"><h3 class=\"top\">Simple Search</h3><ul class=\"list-fields\"><li><label for=\"keyword\"><em>keyword</em></label><input name=\"keyword\" id=\"keyword\" type=\"text\" class=\"text\" /></li><li class=\"last\"><input type=\"image\" src=\"assets/images/btns/search.png\" class=\"submit\" alt=\"Search\" onclick=\"Search();return false;\" /></li></ul></form><form id=\"advancedSearch\" action=\"\"><h3>Advanced Search</h3><ul class=\"list-fields\"><li><label for=\"author\"><em>author</em></label><input name=\"author\" id=\"search_author\" type=\"text\" class=\"text\" /></li><li><label for=\"title\"><em>title</em></label><input name=\"title\" id=\"search_title\" type=\"text\" class=\"text\" /></li><li><label for=\"category\"><em>category</em></label><select name=\"category\" id=\"search_category\"><option value=\"\">All Subjects</option><option value=\"Non-fiction\">Non-fiction</option><option value=\"Fiction\">Fiction</option><option value=\"Sport\">Sport</option><option value=\"Biography\">Biography</option><option value=\"Business\">Business</option><option value=\"Lifestyle\">Lifestyle</option><option value=\"Humour\">Humour</option></select></li><li><label for=\"isbn\"><em>ISBN</em></label><input name=\"isbn\" id=\"search_isbn\" type=\"text\" class=\"text\" /></li><li class=\"last\"><input type=\"image\" src=\"assets/images/btns/search.png\" class=\"submit\" alt=\"Advanced Search\" onclick=\"advancedSearch();return false;\" /></li></ul></form></div>"
		
		}
	
	function next(offset){
		
		myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('column-1').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
		}
		params=[{varName:"action",value:'next'},{varName:"offset",value:offset}];
		document.getElementById('column-1').innerHTML='<div style="width; 100%; text-align: center;"><strong>Searching...</strong></div>';
		myAjax.makeRequest('ajax_search.php',params);
	}
	
	
	//<!--comment  start-->//
	function submitComment(data_id){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			//document.getElementById('usercomments').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			//document.getElementById('comment_num').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.content));
			//document.getElementById('btn-submit-comment').innerHTML="<a href=\"#\" class=\"link-button\" onClick=\"submitComment('"+data_id+"');return false;\">Add Comment</a>";
			location.reload(true);
		}
		var comment=document.getElementById('comment').value;
		if(comment==''){
			document.getElementById('notice').innerHTML="Comment cannot be empty, please enter some text and try again.";
		}else{
			document.getElementById('notice').innerHTML="";
			var params=[{varName:"action",value:'saveComment'},{varName:"comment",value:comment},
						{varName:"rnd",value:data_id}];
			document.getElementById('btn-submit-comment').innerHTML="<a href=\"#\" class=\"link-button\" onClick=\"return false;\">Submitting...</a>";
			
			myAjax.makeRequest('ajax_comment.php',params);
			document.getElementById('comment').value='';
		}
	}
	function getComments(data_id){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('user-comments').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			//document.getElementById('comment_num').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.content));
		}
		var comment=document.getElementById('comment').value;
		var params=[{varName:"action",value:'getComments'},{varName:"rnd",value:data_id}];
		//document.getElementById('rightForm1').innerHTML='Loading...';
		myAjax.makeRequest('ajax_comment.php',params);
	}
	
	function deleteComment(comment_id){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			//document.getElementById('usercomments').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			//document.getElementById('comment_num').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.content));
			//document.getElementById('notice').innerHTML='';
			location.reload(true);
		}	
		var comment=document.getElementById('comment').value;
		var params=[{varName:"action",value:'deleteComment'},{varName:"rnd",value:comment_id}];
		//document.getElementById('rightForm1').innerHTML='Loading...';
		myAjax.makeRequest('ajax_comment.php',params);
		document.getElementById('notice').innerHTML='Deleting...';
	}
	
	function activeComment(comment_id){
		
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('userComments').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			//document.getElementById('comment_num').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.content));
			document.getElementById('notice').innerHTML='';
		}
		var comment=document.getElementById('comment').value;
		var params=[{varName:"action",value:'activeComment'},{varName:"rnd",value:comment_id}];
		//document.getElementById('rightForm1').innerHTML='Loading...';
		myAjax.makeRequest('ajax_comment.php',params);
		document.getElementById('notice').innerHTML='Activating...';
		
	}
	function deactivateComment(comment_id){
		
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('userComments').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			//document.getElementById('comment_num').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.content));
			document.getElementById('notice').innerHTML='';
		}
		var comment=document.getElementById('comment').value;
		var params=[{varName:"action",value:'deactivateComment'},{varName:"rnd",value:comment_id}];
		//document.getElementById('rightForm1').innerHTML='Loading...';
		myAjax.makeRequest('ajax_comment.php',params);
		document.getElementById('notice').innerHTML='Deactivating...';
		
	}
	
	//<!--comment  end-->//
	
	//<!--rateing  start-->//
	function rate(data_id,current_rate){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			
			document.getElementById('btn-rate-the-book').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			//alert(html_entity_decode(decodeURIComponent(myAjax.result.content.news[0].title)));
		}
		var params=[{varName:"rnd",value:data_id},{varName:"current_rate",value:current_rate}];
		//document.getElementById('rightForm1').innerHTML='Loading...';
		myAjax.makeRequest('ajax_rate.php',params);
			
	}
	//<!--rateing  end-->//	
	
	
	//get category//
	
	function getCategory(category){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('column-1').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
			document.getElementById('content').className='content';
			
		}
		document.getElementById('column-1').innerHTML='<div style="width; 100%; text-align: center;"><strong>Searching...</strong></div>';
		var params=[{varName:"category",value:category}];
		myAjax.makeRequest('ajax_category.php',params);
			
	}
	
	//
	function AddToBasket(product){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			document.getElementById('totalNumber').innerHTML=html_entity_decode(decodeURIComponent(myAjax.result.content.response.title));
		}
		var params=[{varName:"action",value:'AddToBasket'},{varName:"rnd",value:product}];
		myAjax.makeRequest('ajax_shoppingcart.php',params);
		
	}
	function removeProduct(product){
		var myAjax= new Ajax.Obj();
		myAjax.debug=false;
		myAjax.callBack=function(){
			location.reload(true);	
		}
		var params=[{varName:"action",value:'removeProduct'},{varName:"rnd",value:product}];
		myAjax.makeRequest('ajax_shoppingcart.php',params);
	}
		
    function html_entity_decode(str) {
		toReturn=str.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,"\"");
		
		 return toReturn
   } 
   
   function returnDocument() {
		var file_name = document.location.href;
		var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
		return file_name.substring(file_name.lastIndexOf("/")+1, end);
	}
	function enterKey(event,e,parameter) {
		var keyCode = (window.Event) ? event.which : event.keyCode;
		if(keyCode ==13){
			eval(e)(parameter);
		
		}
	}
