	function get_chapter(url, id){
		//1. create request object
		createRequest();
		if ( request == null ) {
			alert("Could not create XMLHttpRequest Object");
			return;  //end the function
		}
		url = get_validate_url(url)
		get_loading_msg(id)
		
		request.onreadystatechange = function get_infos(){
			if( request.readyState == 4 ) {
				document.getElementById(id).innerHTML = request.responseText;
				change_font_style()
			}
		}
		request.open("GET",url,true);
		request.send(null);
	}
	
/************************************/	
/************************************/

	function get_results(url, id){
		//1. create request object
		createRequest();
		if ( request == null ) {
			alert("Could not create XMLHttpRequest Object");
			return;  //end the function
		}
		
		url = get_validate_url(url)
		get_loading_msg(id)
		request.onreadystatechange = function get_infos(){
			if( request.readyState == 4 ) {
				document.getElementById(id).innerHTML = request.responseText;
			}
		}
		request.open("GET",url,true);
		request.send(null);
	}	
/************************************/	
/************************************/
	function get_loading_msg(id){
		var cood = ""
		if ( id == "content_detail" ) {
			cood = "margin-left:290px;margin-top:20px;"
		} else if ( id == "chapter_content" ) {
			cood = "margin-left:50px;margin-top:50px;"
		} else {
			cood = ""
		}
		var loader	 = "<center><img src=\"images/ajax-loader.gif\" style=\"" + cood + "height:20px;width:20px;\" /></center>" 
		document.getElementById(id).innerHTML = loader
	}
/************************************/	
/************************************/
	function get_story(url, id){
		//1. create request object
		createRequest();
		if ( request == null ) {
			alert("Could not create XMLHttpRequest Object");
			return;  //end the function
		}
		
		url = get_validate_url(url)
		
		request.onreadystatechange = function get_infos(){
			if( request.readyState == 4 ) {
				document.getElementById(id).innerHTML = request.responseText;
				change_font_style()
			}
		}
		request.open("GET",url,true);
		request.send(null);
	}
/************************************/	
/************************************/	
	function get_search_story(url, id){
		//1. create request object
		createRequest();
		if ( request == null ) {
			alert("Could not create XMLHttpRequest Object");
			return;  //end the function
		}
		
		var opt = get_dropdown_value("option")
		var key = get_input_textbox( "story_keyword" )
		url += "?timkiem=" + key
		url += "&option=" + opt

		url = get_validate_url(url)
		get_loading_msg(id)
		request.onreadystatechange = function get_infos(){
			if( request.readyState == 4 ) {
				document.getElementById(id).innerHTML = request.responseText;
			}
		}
		
		request.open("GET",url,true);
		request.send(null);
	}
/************************************/	
/************************************/	
	function get_validate_url(url) {
		//var vn = get_input_textbox( "vntrungtam" )
		var vn = get_md5()
		var myRegExp 	= /\?/;
		var matchPos1 	= url.search(myRegExp);
		if ( matchPos1 != -1 ) {
			url += "&vnsite=" + vn ;
		} else {
			url += "?vnsite=" + vn ;
		}
		return url
	}
/************************************/	
/************************************/		
	function get_input_textbox( id ) {
		var input = document.getElementById(id).value ;
		return input ;
	}	
/************************************/	
/************************************/	
	function get_dropdown_value(id) {
		var droplist = document.getElementById(id) ;
		var fValue = droplist.options[droplist.selectedIndex].value ;
		return fValue ;
	}	
/************************************/	
/************************************/	
	function get_change_active_color(id, total) {
		get_change_link_color(total)
		document.getElementById(id).style.background = "#fff" ;
	}
/************************************/	
/************************************/	
	function get_change_link_color(total) {
		var total_chapter = document.getElementById(total).value
		for ( var i = 0; i<total_chapter; i++ ) {
			document.getElementById("chapter_" + i).style.background = "#E2EEFC" ;
		}
	}
/************************************/	
/************************************/		
	function preview(url,id,objFind, objShow, pLeft, pTop){
		showMe(objFind, objShow, pLeft, pTop)
		get_story(url,id)
	}	
/************************************/	
/************************************/		
/*********** Paging Control ***********/	
	var strPath = "../truyen/get_read_chapter.php?reply_id="
/************************************/	
/************************************/	
	function set_all_nav_enable(){
		var strNav 
		strNav = '<a class="nvFirst" onclick="set_first_page()"></a>'
		strNav += '<a class="nvPrev" onclick="set_prev_page()"></a>'
		strNav += '<a class="nvNext" onclick="set_next_page()"></a>'
		strNav += '<a class="nvLast" onclick="set_last_page()"></a>'
		return strNav
	}
/************************************/	
/************************************/	
	function do_get_story(js_reply_id){
		var reply_id = document.getElementById(js_reply_id).value
		url = strPath + reply_id
		get_chapter(url, 'chapter_content')
	}	
/************************************/	
/************************************/	
	function set_menu_current_page(index_reply_id){
		if ( index_reply_id == 0 ) {
			set_first_page()	
			return false
		} else if ( index_reply_id == ((document.getElementById("count_chapter").value) - 1) ) {
			set_last_page()	
			return false
		} else {
			do_get_story("js_reply_id_" + index_reply_id)
			var strNav = set_all_nav_enable()
			set_new_current_page(strNav, index_reply_id)
			get_change_active_color('chapter_' + index_reply_id, 'count_chapter')
		}
	}
/************************************/	
/************************************/	
	function set_first_page(){
		do_get_story("js_reply_id_0")
		var strNav 
		strNav = '<a class="nvFirstDisable"></a>'
		strNav += '<a class="nvPrevDisable"></a>'
		strNav += '<a class="nvNext" onclick="set_next_page()"></a>'
		strNav += '<a class="nvLast" onclick="set_last_page()"></a>'
		set_new_current_page(strNav, 0)
		get_change_active_color('chapter_0', 'count_chapter')
	}
/************************************/	
/************************************/	
	function set_prev_page(){
		if ( document.getElementById("current_chapter").value == 1 ) {
			set_first_page()	
			return false
		} else {
			var iPrev = (document.getElementById("current_chapter").value) -1
			do_get_story("js_reply_id_" + iPrev)
			var strNav = set_all_nav_enable()
			set_new_current_page(strNav, iPrev)
			get_change_active_color('chapter_' + iPrev, 'count_chapter')
		}
	}
/************************************/	
/************************************/	
	function set_next_page(){
		//alert(document.getElementById("count_chapter").value)
		if ( document.getElementById("current_chapter").value == ((document.getElementById("count_chapter").value)-2) ) {
			set_last_page()	
			return false
		} else {
			var iNext = (document.getElementById("current_chapter").value) 
			iNext = parseInt(iNext) + 1
			do_get_story("js_reply_id_" + iNext)
			var strNav = set_all_nav_enable()
			set_new_current_page(strNav, iNext)
			get_change_active_color('chapter_' + iNext, 'count_chapter')
		}
	}
/************************************/	
/************************************/	
	function set_last_page(){
		var iLast = (document.getElementById("count_chapter").value) -1
		do_get_story("js_reply_id_" + iLast)
		var strNav 
		strNav = '<a class="nvFirst" onclick="set_first_page()"></a>'
		strNav += '<a class="nvPrev" onclick="set_prev_page()"></a>'
		strNav += '<a class="nvNextDisable"></a>'
		strNav += '<a class="nvLastDisable" ></a>'
		set_new_current_page(strNav, iLast)
		get_change_active_color('chapter_' + iLast, 'count_chapter')
	}
/************************************/	
/************************************/		
	function set_new_current_page(strNav, iNewCurrentPage){
		document.getElementById("nav_box_top").innerHTML 	= strNav
		document.getElementById("nav_box_bottom").innerHTML = strNav
		document.getElementById("current_chapter").value 	= iNewCurrentPage
	}	
/***********End Paging Control ***********/	
/******************************************************************************************/
/*********** Paging Control 2***********/	
	function get_story_query_string(chapter_id){
		var story_id 	= document.getElementById("js_story_id").value
		var strPath2 	= "../truyen/get_read_chapter.php?story_id=" + story_id + "&chapter_id=" + chapter_id
		return strPath2
	}
/************************************/	
/************************************/
	function set_next_page2(){
		if ( document.getElementById("current_chapter").value == ((document.getElementById("count_chapter").value)-2) ) {
			set_last_page2()	
			return false
		} else {
			var iNext 	= (document.getElementById("current_chapter").value) 
			iNext 		= parseInt(iNext) + 1
			var url 	= get_story_query_string(iNext)
			get_chapter(url, 'chapter_content')
			var strNav = set_all_nav_enable2()
			set_new_current_page(strNav, iNext)
			get_change_active_color('chapter_' + iNext, 'count_chapter')
		}
	}
	
/************************************/	
/************************************/
	function set_last_page2(){
		var iLast	= (document.getElementById("count_chapter").value) -1
		var url		= get_story_query_string(iLast)
		get_chapter(url, 'chapter_content')
		var strNav 
		strNav = '<a class="nvFirst" onclick="set_first_page2()"></a>'
		strNav += '<a class="nvPrev" onclick="set_prev_page2()"></a>'
		strNav += '<a class="nvNextDisable"></a>'
		strNav += '<a class="nvLastDisable" ></a>'
		set_new_current_page(strNav, iLast)
		get_change_active_color('chapter_' + iLast, 'count_chapter')
	}
/************************************/	
/************************************/	
	function set_prev_page2(){
		if ( document.getElementById("current_chapter").value == 1 ) {
			set_first_page2()	
			return false
		} else {
			var iPrev 	= (document.getElementById("current_chapter").value) -1
			var url 	= get_story_query_string(iPrev)
			get_chapter(url, 'chapter_content')
			var strNav = set_all_nav_enable2()
			set_new_current_page(strNav, iPrev)
			get_change_active_color('chapter_' + iPrev, 'count_chapter')
		}
	}	
/************************************/	
/************************************/	
	function set_first_page2(){
		var url = get_story_query_string(0)
		get_chapter(url, 'chapter_content')
		var strNav 
		strNav = '<a class="nvFirstDisable"></a>'
		strNav += '<a class="nvPrevDisable"></a>'
		strNav += '<a class="nvNext" onclick="set_next_page2()"></a>'
		strNav += '<a class="nvLast" onclick="set_last_page2()"></a>'
		set_new_current_page(strNav, 0)
		get_change_active_color('chapter_0', 'count_chapter')
	}
/************************************/	
/************************************/	
	function set_menu_current_page2(index_reply_id){
		if ( index_reply_id == 0 ) {
			set_first_page2()	
			return false
		} else if ( index_reply_id == ((document.getElementById("count_chapter").value) - 1) ) {
			set_last_page2()	
			return false
		} else {
			var url = get_story_query_string(index_reply_id)
			get_chapter(url, 'chapter_content')
			var strNav = set_all_nav_enable2()
			set_new_current_page(strNav, index_reply_id)
			get_change_active_color('chapter_' + index_reply_id, 'count_chapter')
		}
	}
/************************************/	
/************************************/	
	function set_all_nav_enable2(){
		var strNav 
		strNav = '<a class="nvFirst" onclick="set_first_page2()"></a>'
		strNav += '<a class="nvPrev" onclick="set_prev_page2()"></a>'
		strNav += '<a class="nvNext" onclick="set_next_page2()"></a>'
		strNav += '<a class="nvLast" onclick="set_last_page2()"></a>'
		return strNav
	}
/***********End Paging Control 2***********/	

/***********************************/
/***********Font Control ***********/
/***********************************/
	function get_update_story_font_style(){
		createRequest();
		if ( request == null ) {
			alert("Could not create XMLHttpRequest Object");
			return;  //end the function
		}
		var url 	= "../truyen/get_set_font.php"
		var vSize 	= get_dropdown_value("font_size")
		var vColor 	= get_dropdown_value("font_color")
		var vName 	= get_dropdown_value("font_name")
		url += "?size=" + vSize + "&color=" + vColor + "&name=" + vName
		request.open("GET",url,true);
		request.send(null);
	}
	
	function change_font_style(){
		change_font_size()
		change_font_color()
		change_font_name()
	}
	/***********Font Size ***********/
	function change_font_size(){
		var vSize = get_dropdown_value("font_size")
		document.getElementById("reply_msg").style.fontSize = vSize + "px"
	}
	
	function set_font_size(){
		get_update_story_font_style()
		change_font_size()
	}
	
	/***********Font Color ***********/
	function change_font_color(){
		var vColor = get_dropdown_value("font_color")
		document.getElementById("reply_msg").style.color = vColor 
	}
	
	function set_font_color(){
		get_update_story_font_style()
		change_font_color()
	}
	/***********Font Size ***********/
	function change_font_name(){
		var vName = get_dropdown_value("font_name")
		document.getElementById("reply_msg").style.fontFamily = vName
	}
	
	function set_font_name(){
		get_update_story_font_style()
		change_font_name()
	}

/***********************************/
/***********End Font Control ***********/
/***********************************/	
	function show_tb_writer(){
		//if (document.getElementById("preview").style.display = "none") {
			//document.getElementById("preview").style.display = "block"
		//}
		document.getElementById("preview").style.height = "300px"
	}
	
	function hide_tb_writer(){
		//if (document.getElementById("preview").style.display = "none") {
			//document.getElementById("preview").style.display = "block"
		//}
		document.getElementById("preview").style.height = "0px"
	}
	
	function set_theloailink_to_action(fActive){
		for ( var i=0; i<14; i++ ) {
			document.getElementById("theloai_link_" + i).style.background = "#ffffff"
		}
		document.getElementById(fActive).style.background = "#E2EEFC"
	}

