window.onscroll = Float
function encode(data)
{
	return encodeURIComponent(data);
}


function LoadXmlDoc(url,element_id)
{
element=element_id
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function LoadXmlDocPost(url,data,element_id)
{
data=data+'&ndacheck=1';
element=element_id
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("POST", url , true)
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(data)
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
try{document.getElementById(element).innerHTML=xmlHttp.responseXML.getElementsByTagName('data')[0].firstChild.data;
}catch(e)
{
}

try{
	eval(xmlHttp.responseXML.getElementsByTagName('java')[0].firstChild.data)
}
catch(e)
{	
}

}
}


function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
	objXmlHttp=new XMLHttpRequest()
	objXmlHttp.onload=handler
	objXmlHttp.onerror=handler 
	return objXmlHttp
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
}


function create_get_element_array(array)
{
	var command="data='button="+array[0]+"';";
	var text_array='';
	var logic_array='';
	var select_one_array='';
	var textarea_array='';
	var frame_array='';
	var select_multiple='';
	var select_multiple_innerHTML='';
	var select_multiple_selected='';
	var select_multiple_selected_value='';
	var type;
	var i=0;
	var k=0;
	for (a in array)
	{
		i++;
		if(i>1 & i<=array.length)
		{
			type=document.getElementById(array[a]).type;
			if(type=='text' || type=='hidden' || type=='password')
			{
				command=command+"data=data+'&"+array[a]+"='+encode(document.getElementById('"+array[a]+"').value);";
				text_array=text_array+' '+array[a];
			}
			if(type=='checkbox')
			{
				command=command+"data=data+'&"+array[a]+"='+logic_to_01(document.getElementById('"+array[a]+"').checked);";
				logic_array=logic_array+' '+array[a];
			}
			if(type=='textarea')
			{
				command=command+"data=data+'&"+array[a]+"='+encode(document.getElementById('"+array[a]+"').value);";
				textarea_array=textarea_array+' '+array[a];
			}
			if(!type)
			{
				command=command+"data=data+'&"+array[a]+"='+encode(document.getElementById('"+array[a]+"').contentWindow.document.body.innerHTML);";
				frame_array=frame_array+' '+array[a];
			}
			
			if(type=='select-one')
			{
				command=command+"data=data+'&"+array[a]+"='+document.getElementById('"+array[a]+"').value;";
				select_one_array=select_one_array+' '+array[a];
			}
			if(type=='select-multiple')
			{
				command=command+"data=data+'&"+array[a]+"='+encode(document.getElementById('"+array[a]+"').value);";
				select_multiple=select_multiple+' '+array[a];
				command=command+"data=data+'&"+array[a]+"innerHTML='+encode(document.getElementById('"+array[a]+"').innerHTML);";
				select_multiple_innerHTML=select_multiple_innerHTML+' '+array[a];
				
				select_multiple_selected_value='';
				for (k=0; k<document.getElementById(array[a]).options.length; k++)
				{
						//alert(k);
					if (document.getElementById(array[a]).options[k].selected) {
					select_multiple_selected_value=select_multiple_selected_value+','+document.getElementById(array[a]).options[k].value;
					}
				}
				abc=select_multiple_selected_value;
				select_multiple_selected=select_multiple_selected+' '+array[a];
				command=command+"data=data+'&"+array[a]+"selected='+encode(abc);";
			}

		}
		
	}

	command=command+"data=data+'&text_array='+'"+text_array+"';";
	command=command+"data=data+'&logic_array='+'"+logic_array+"';";
	command=command+"data=data+'&select_one_array='+'"+select_one_array+"';";
	command=command+"data=data+'&textarea_array='+'"+textarea_array+"';";
	command=command+"data=data+'&frame_array='+'"+frame_array+"';";
	command=command+"data=data+'&select_multiple='+'"+select_multiple+"';";
	command=command+"data=data+'&select_multiple_innerHTML='+'"+select_multiple_innerHTML+"';";
	command=command+"data=data+'&select_multiple_selected='+'"+select_multiple_selected+"';";
	return command;

}
function logic_to_01(value)
{
	if(value==true)
	{	
		return 1;
	}else
	{
		return 0;	
	}
}


function submit_form(echo_id,button_id,xml_file,array)
{
	try{document.getElementById(button_id).disabled=true;}
	catch(e){}

	ele_array=array.split(",");
	
	new_ele_array=new Array();
	new_ele_array[0]=button_id;
	i=0;
	
	if(ele_array.length>0)
	{
		for (a in ele_array)
		{
			i++;
			if(i<ele_array.length+1)
			{
				new_ele_array[i]=ele_array[a];
			}
		}

	}else
	{
		data='';	
	}
	eval(create_get_element_array(new_ele_array));
	LoadXmlDocPost(xml_file,data,echo_id);
}

function submit_form2(echo_id,button_id,xml_file,divbao)
{
	var arr = new Array();
	var elestring='';
	var elems = document.getElementById(divbao).getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  var type = elem.type;
	
	  if(type=='text' || type=='hidden' || type=='password')elestring=elestring+','+id;
	  if(type=='select-one')elestring=elestring+','+id;
	  if(type=='textarea')elestring=elestring+','+id;
	  if(type=='checkbox')elestring=elestring+','+id;
	  if(type=='select-multiple')elestring=elestring+','+id;
	  
	}
	elestring=elestring.substr(1)
	
	submit_form(echo_id,button_id,xml_file,elestring)
}



function test()
{
	$("#common_echo").dialog()
	setTimeout('$("#common_echo").dialog("close")',3000);
}

function showecho(ele,timeout,loi)
{
	test()
	return;
	if(loi!=1)
	{
		document.getElementById(ele).style.background='#0099cc';
	}else
	{
		document.getElementById(ele).style.background='red';
	}
	
	document.getElementById(ele).style.display='none';
	setTimeout("document.getElementById('"+ele+"').style.display='block';",200)
	setTimeout("document.getElementById('"+ele+"').style.display='none';",timeout)
} 
function error_note(ele,echo)
{
	document.getElementById(ele).style.display="inline";
	document.getElementById(ele).innerHTML='( '+echo+' )';
} 

function blink_now(ele)
{
	if(document.getElementById(ele).style.display=="inline")
	{
		document.getElementById(ele).style.display="none";
	}else
	{
		document.getElementById(ele).style.display="inline";
	}
}
function blink_text(ele)
{
	
	try{clearInterval(blink_event)}catch(e){}
	blink_event=setInterval ( "blink_now('"+ele+"')", 700 );
}
function hidden_element(ele)
{
	document.getElementById(ele).style.display="none";
} 
function lay_cookies_menu()
{
	menu_cookie=getCookie('last_click_left_menu');
	if(menu_cookie!='')
	{
		document.getElementById('div_cap2_id_'+menu_cookie).style.display="block";
	}
}





function sua_seo(id)
{
	ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'modules/gianhang_sanpham/seo_danhmuc_pop.php?id='+id, 'Tối ưu mã nguồn tìm kiếm', 'width=500px,height=200px,resize=1,scrolling=1,center=1');

}

function gokhoidonhang(id,gh)
{
	LoadXmlDoc('xml/gianhang_gokhoidonhang.php?id='+id+'&gh='+gh,'','');	
}
function remove_dot(value)
{
	value=value.replace(".", "");
	value=value.replace(".", "");
	value=value.replace(".", "");
	value=value.replace(".", "");
	value=value.replace(".", "");
	value=value.replace(".", "");
	value=value.replace(".", "");
	return value
}
function doi_gia_tri_mac_dinh_style(ele)
{
	ele_id=ele.id;
	document.getElementById('check_'+ele_id).checked=false;
}
 
function luu_bookmarks(loai,id)
{
	data='loai='+encode(loai);
	data=data+'&id='+encode(id);
	LoadXmlDocPost('xml/web_bookmarks/them.php',data,'common_echo')
}
function choncosan(kieu)
{
	if(kieu==1)
	{
		document.getElementById('chontumau').value=1
		document.getElementById("thongtintimkiem").innerHTML=""
	}else
	{
		document.getElementById('chontumau').value=0
		document.getElementById("chongdongsanpham").innerHTML="";
		document.getElementById("chonhang").innerHTML="";	
		
	}
}

function logout(id)
{
	LoadXmlDoc('xml/web_taikhoan/logout.php','');	
}

function timkiem_web()
{
	value=document.getElementById('box_timkiem').value;
	type=document.getElementById('select_timkiem').value;
	
	data='value='+encode(value)+'&type='+type;
	LoadXmlDocPost('xml/web_timkiem/timkiem.php',data,'common_echo')
}



function doingaythang()
{
	thang=(document.getElementById('create_date_Month_ID').value);
	ngay=(document.getElementById('create_date_Day_ID').value);
	nam=(document.getElementById('create_date_Year_ID').value);
	
	window.location='tin_danhsach.php?ngay='+nam+'-'+(parseInt(thang)+1)+'-'+ngay

}


function save_pass(id,pass)
{
	LoadXmlDoc('xml/web_taikhoan/admin_doimatkhau.php?id='+id+'&pass='+pass,'common_echo');	
}

function save_email(id,email)
{
	LoadXmlDoc('xml/web_taikhoan/save_email.php?id='+id+'&email='+email,'common_echo');	
}

function save_diem(id,diem)
{
	LoadXmlDoc('xml/web_taikhoan/save_diem.php?id='+id+'&diem='+diem,'common_echo');	
}




function save_date_pub(id,date_pub)
{
	LoadXmlDoc('xml/web_tin/save_date_pub.php?id='+id+'&date_pub='+date_pub,'common_echo');	
}



function web_xoa_anh_tin(id)
{
	LoadXmlDoc('xml/web_tin/xoa_anh_tin.php?id='+id,'common_echo');	
}







function xoa_anh_logo(id)
{
	LoadXmlDoc('xml/xoa_anh_logo.php?id='+id,'common_echo');	
}



function xoa_bookmark(id)
{
	LoadXmlDoc('xml/web_bookmarks/xoa.php?id='+id,'common_echo');	
}


function thuhepmorong()
{
	if(document.getElementById('tim_kiem_hidden').style.display=="block")
	{
		document.getElementById('tim_kiem_hidden').style.display="none";
		document.getElementById('thuhepmorong').className="morong";
	}else
	{
		document.getElementById('tim_kiem_hidden').style.display="block";
		document.getElementById('thuhepmorong').className="thuhep";
	}
}

function check_all(className,thisele)
{
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ 
		var cls = elem.getAttribute("className");
		if(cls==null)var cls = elem.getAttribute("class");
		}
		else
		
		{ var cls = elem.getAttribute("class");	}
	  if(cls == className)
	  {
	  	elem.checked=thisele.checked;
	  }
	}
	
}







function hover_tab(ele,hover_class,current_class,back_class)
{
	if(ele.className==back_class)
	{
		ele.className=hover_class;
	}
}


function out_tab(ele,hover_class,current_class,back_class)
{
	if(ele.className==hover_class)
	{
		ele.className=back_class;
	}
}





function open_asset(folder,editor_name,type,class_name,select_content)
{
	if(!folder)folder='';
	if(!editor_name)editor_name='';
	if(!class_name)class_name='';
	var curent_file='';

	if(select_content!='')
	{
		var myArray = select_content.split('src="'); 
		if(myArray[1]!='')
		{
			myArray=myArray[1].split('"');
			curent_file=myArray[0];
		}
	}

	window.open('asset_manager.php?folder='+folder+'&editor_name='+editor_name+'&type='+type+'&class='+class_name+'&curent_file='+curent_file,'mywindow','width=800,height=550');
}


function open_asset_select_folder(folder)
{
	window.open('asset_manager.php?folder='+folder+'&sele_folder=1&type=image','mywindow','width=800,height=550');
}


function insert_img(path,file,ele,class_name)
{
	if(file=='')
	{
		alert('Bạn vui lòng chọn file ở khung bên phải');
	}else
	{
		if(class_name!='')
		{
			tinyMCE.get(ele).selection.setContent('<span class="'+class_name+'"><img src="'+path+file+'" /></span>');
		}else
		{
			tinyMCE.get(ele).selection.setContent('<img src="'+path+file+'" />');
		}
	}
}

function insert_file(path,file,ele)
{
	if(file=='')
	{
		alert('Bạn vui lòng chọn file ở khung bên phải');
	}else
	{
		tinyMCE.get(ele).selection.setContent('<a href="'+path+file+'">'+file+'</a>');
	}
}



function insert_flash(path,file,ele,width,height)
{
	if(file=='')
	{
		alert('Bạn vui lòng chọn file ở khung bên phải');
	}else
	{
		html= '<object class="flash_preview" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+path+file+'" /><param name="quality" value="high" />  <embed src="'+path+file+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>';
		tinyMCE.get(ele).selection.setContent(html);
	}
}



function gui_phan_hoi(id)
{
	try{value=tinyMCE.get('detail').getContent();}catch(e){alert('Bạn vui lòng nhập nội dung phản hồi !');}
	
	
	data='detail='+encode(value);
	data=data+'&captcha='+document.getElementById('captcha').value;
	data=data+'&rating='+document.getElementById('danhgia_hidden').value;

LoadXmlDocPost('xml/web_tin/guiphanhoi.php?id='+id,data,'nut_ket_qua_tin_nhan')
}











function suachitiet_phankhac(id)
{
	detail=encode(tinyMCE.get('detail').getContent());

	data='detail='+detail;
	data=data+'&name='+encode(document.getElementById('name').value);
	
	LoadXmlDocPost('xml/suachitiet_phankhac.php?id='+id,data,'common_echo')
}

function dang_ky()
{
	data='tel='+encode(document.getElementById('tel').value);
	data=data+'&register_user='+encode(document.getElementById('register_user').value);
	data=data+'&register_password='+encode(document.getElementById('register_password').value);
	data=data+'&register_passwordagain='+encode(document.getElementById('register_passwordagain').value);
	data=data+'&full_name='+encode(document.getElementById('full_name').value);
	data=data+'&address='+encode(document.getElementById('address').value);
	data=data+'&email='+encode(document.getElementById('email').value);
	data=data+'&gioitinh='+encode(document.getElementById('gioitinh').value);
	data=data+'&nghenghiep='+encode(document.getElementById('nghenghiep').value);
	data=data+'&nghenghiepkhac='+encode(document.getElementById('nghenghiepkhac').value);



	data=data+'&dieukhoan='+logic_to_01(document.getElementById('dieukhoan').checked);
	
	data=data+'&sinhnhat='+encode(document.getElementById('sinhnhat_Year_ID').value)+'-'+encode(parseInt(document.getElementById('sinhnhat_Month_ID').value)+1)+'-'+encode(document.getElementById('sinhnhat_Day_ID').value);

	LoadXmlDocPost('xml/web_taikhoan/dangky.php',data,'common_echo')
}

function sua_canhan()
{
	des=encode(tinyMCE.get('des').getContent());

	data='sign='+des;
	data=data+'&tel='+encode(document.getElementById('tel').value);
	data=data+'&full_name='+encode(document.getElementById('full_name').value);
	data=data+'&address='+encode(document.getElementById('address').value);
	data=data+'&email='+encode(document.getElementById('email').value);
	data=data+'&gioitinh='+encode(document.getElementById('gioitinh').value);
	data=data+'&nghenghiep='+encode(document.getElementById('nghenghiep').value);
	data=data+'&nghenghiepkhac='+encode(document.getElementById('nghenghiepkhac').value);
	data=data+'&sinhnhat='+encode(document.getElementById('sinhnhat_Year_ID').value)+'-'+encode(parseInt(document.getElementById('sinhnhat_Month_ID').value)+1)+'-'+encode(document.getElementById('sinhnhat_Day_ID').value);

	LoadXmlDocPost('xml/web_taikhoan/doithongtin.php',data,'common_echo')
}



function sua_tin_web(id)
{
	des=encode(tinyMCE.get('des').getContent());
	detail=encode(tinyMCE.get('detail').getContent());
	data='des='+des;
	data=data+'&detail='+detail;
	data=data+'&name='+encode(document.getElementById('tieudetin').value);
	data=data+'&tag='+encode(document.getElementById('tag').value);
	data=data+'&date_event='+encode(document.getElementById('date_event').value);
	data=data+'&date_create='+encode(document.getElementById('date_create').value);
	
	
	data=data+'&danhmuc='+document.getElementById('danhmuc').value;

LoadXmlDocPost('xml/web_tin/suatinchitiet.php?id='+id,data,'common_echo')
}


function sua_tin_comment(id)
{
	detail=encode(tinyMCE.get('detail').getContent());
	data='detail='+detail;
	data=data+'&date_create='+encode(document.getElementById('date_create').value);
	LoadXmlDocPost('xml/web_tin/suacommentchitiet.php?id='+id,data,'common_echo')
}

function suadanhmucchitiet(id)
{
	detail=encode(tinyMCE.get('detail').getContent());
	data='data='+detail;
	data=data+'&detail='+detail;
	
	data=data+'&dm_name='+encode(document.getElementById('dm_name').value);
	data=data+'&dm_order='+encode(document.getElementById('dm_order').value);

LoadXmlDocPost('xml/web_tin/suatin_danhmuc.php?id='+id,data,'common_echo')
}




function sua_pop_up(id)
{
	des=encode(tinyMCE.get('des').getContent());
	data='des='+des;
	data=data+'&title='+encode(document.getElementById('title').value);
	data=data+'&rong='+encode(document.getElementById('rong').value);
	data=data+'&cao='+encode(document.getElementById('cao').value);
	data=data+'&giay='+encode(document.getElementById('giay').value);

LoadXmlDocPost('xml/suapopup.php?id='+id,data,'common_echo')
}




function them_baiviet(sid)
{
	document.getElementById('nut').value="Đang hoạt động, bạn vui lòng đợi";
	detail=encode(tinyMCE.get('detail').getContent());
	
	data='detail='+detail;
	data=data+'&name='+encode(document.getElementById('name').value);
	data=data+'&danhmuc='+encode(document.getElementById('danhmuc').value);
	data=data+'&suatomtat='+encode(document.getElementById('suatomtat').value);
	data=data+'&tags='+encode(document.getElementById('tags').value);
	LoadXmlDocPost('xml/web_tin/tin_them.php?sid='+sid+'&captcha='+document.getElementById('captcha').value,data,'common_echo')
}




function web_them_dichvu(sid)
{
	detail=encode(tinyMCE.get('detail').getContent());
	submit_form2('common_echo','nut','xml/web_dichvu/dichvu_them.php?sid='+sid+'&detail='+detail,'div_dang_tin');
}


function gianhang_sua_chitiet_sanpham(id_sanpham)
{
	detail=getText();
	data='detail='+encode(detail);
	LoadXmlDocPost('xml/gianhang_sanpham/suachitiet.php?id_sanpham='+id_sanpham,data,'common_echo')
}


function getText(){
	
	//tinymce
    var content = "", body = tinyMCE.activeEditor.getDoc().body;
	/*
    if (body.textContent) {
        // Mozilla (Gecko)
    }
    if (body.innerText) {
        // Internet Explorer
        content = body.innerText;    }
    if (content == "") {
        // other browsers
        content = tinyMCE.activeEditor.getContent();
    }*/
 	 //  content = content.replace(/<\/?[^>]+>/g, "");
        
	content = body.innerHTML;
    return content;
}


function gianhang_chon_danh_muc_ok(id,menu_sua_id)
{
	value=document.getElementById('danhmucid').value;
	if(value==""){alert('Bạn vui lòng chọn cấp danh mục cuối cùng');return}
	
	LoadXmlDoc('xml/gianhang_suamenu/gianhang_suamenu_capnhat_danhmuc_sanpham.php?id='+id+'&menu_sua_id='+menu_sua_id+'&value='+value,'common_echo');	

	ajaxwin.close(); return false;
}


function web_quangcao_html(id)
{
	detail=getText();
	data='detail='+encode(detail);
	LoadXmlDocPost('xml/web_quangcao/capnhat_html.php?id='+id,data,'common_echo')
}



function chon_ss_ok(id,menu_sua_id)
{
	value=document.getElementById('danhmucid').value;
	if(value==""){alert('Bạn vui lòng chọn cấp cuối cùng');return}
	
	LoadXmlDoc('xml/gianhang_suamenu_capnhat_ss_sanpham.php?id='+id+'&menu_sua_id='+menu_sua_id+'&value='+value,'common_echo');	

	ajaxwin.close(); return false;
}


function chon_danh_muc_cap2_ok(dm_id,id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_capnhat_danhmuc_con.php?id='+id+'&dm_id='+dm_id+'&menu_sua_id='+menu_sua_id,'common_echo');	
	ajaxwin.close();
}

function doi_vi_tri_danh_muc(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_doivitri_danhmuc_tuhienthi.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}

function gianhang_mo_rong(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_mo_rong.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}

function uathich(id)
{
	LoadXmlDoc('xml/web_tin/uathich.php?id='+id,'common_echo');	
}

function thank_comment(id,comment_id)
{
	LoadXmlDoc('xml/web_taikhoan/thank_comment.php?id='+id+'&comment_id='+comment_id,'common_echo');	
}

function thank_tin(id,tin_id)
{
	LoadXmlDoc('xml/web_taikhoan/thank_tin.php?id='+id+'&tin_id='+tin_id,'common_echo');	
}


function noidungxau(id)
{
	LoadXmlDoc('xml/web_tin/noidungxau.php?id='+id,'common_echo');	
}


function noidungxaucomment(id)
{
	LoadXmlDoc('xml/web_tin/noidungxaucomment.php?id='+id,'common_echo');	
}



function trangchutab(id)
{
	LoadXmlDoc('xml/web_tin/trangchu_danhmuc.php?id='+id,'common_echo');	
}


function active_user(id)
{
	LoadXmlDoc('xml/web_taikhoan/active_user.php?id='+id,'common_echo');	
}
function bientap_user(id)
{
	LoadXmlDoc('xml/web_taikhoan/bientap_user.php?id='+id,'common_echo');	
}




function explode (delimiter, string, limit) {
    // http://kevin.vanzonneveld.net
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||
        typeof arguments[1] == 'undefined' ) {
        return null;
    }
 
    if ( delimiter === '' ||
        delimiter === false ||
        delimiter === null ) {
        return false;
    }
 
    if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' ) {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function chontoanbo_xuatban(string,value)
{
	array=explode(',',string);	
	for (ivar=0;ivar<=array.length-2;ivar=ivar+1)
	{
		xuatban_tin(array[ivar],value);
	}

}

function chontoanbo_xuatban_comment(string,value)
{
	array=explode(',',string);	
	for (ivar=0;ivar<=array.length-2;ivar=ivar+1)
	{
		xuatban_phanhoi(array[ivar],0,value);
	}

}

function xuatban_tin(id,value)
{
	LoadXmlDoc('xml/web_tin/xuatban_tin.php?id='+id+'&value='+value,'common_echo');	
}
function chontoanbo_toprate(string,value)
{
	array=explode(',',string);	
	for (ivar=0;ivar<=array.length-2;ivar=ivar+1)
	{
		toprate_tin(array[ivar],value);
	}

}

function toprate_tin(id,value)
{
	LoadXmlDoc('xml/web_tin/toprate_tin.php?id='+id+'&value='+value,'common_echo');	
}



function chontoanbo_xoa(string)
{
	var answer = confirm('Bạn đã chắc chắn xóa toàn bộ tin trong trang này ?')
	if (answer){
		
		array=explode(',',string);	
		for (ivar=0;ivar<=array.length-2;ivar=ivar+1)
		{
			LoadXmlDoc('xml/web_tin/xoa.php?id='+array[ivar],'common_echo');	
		}

		
	}
}

function chontoanbo_xoa_comment(string)
{
	var answer = confirm('Bạn đã chắc chắn xóa toàn bộ comment trong trang này ?')
	if (answer){
		
		array=explode(',',string);	
		for (ivar=0;ivar<=array.length-2;ivar=ivar+1)
		{
			LoadXmlDoc('xml/web_tin/xoa_comment.php?id='+array[ivar],'common_echo');	
		}

		
	}
}



function xuatban_phanhoi(id,isreload,value)
{
	LoadXmlDoc('xml/web_tin/xuatban_phanhoi.php?id='+id+'&isreload='+isreload+'&value='+value,'common_echo');	
}

function xuatban_votes(id)
{
	LoadXmlDoc('xml/admin/xuatban_votes.php?id='+id,'common_echo');	
}

function xuatban_danhmuctin(id)
{
	LoadXmlDoc('xml/web_tin/xuatban_danhmuctin.php?id='+id,'common_echo');	
}

function slide_danhmuctin(id)
{
	LoadXmlDoc('xml/web_tin/slide_danhmuctin.php?id='+id,'common_echo');	
}


function html_danhmuctin(id)
{
	LoadXmlDoc('xml/web_tin/html_danhmuctin.php?id='+id,'common_echo');	
}

function lock_danhmuctin(id)
{
	LoadXmlDoc('xml/web_tin/lock_danhmuctin.php?id='+id,'common_echo');	
}




function gianhang_sua_logic(id,logic_id)
{
	LoadXmlDoc('xml/gianhang_sanpham/gianhang_sua_logic.php?id='+id+'&logic_id='+logic_id,'common_echo');	
}

function doi_kieu_menu_trai(value)
{
	LoadXmlDoc('xml/gianhang_suamenu/doi_kieu_menu_trai.php?value='+value,'common_echo');	
}



function gianhang_sua_logic_tin(id,logic_id)
{
	LoadXmlDoc('xml/gianhang_tin/gianhang_sua_logic.php?id='+id+'&logic_id='+logic_id,'common_echo');	
}


function gianhang_sua_tin_logic(id,logic_id)
{
	LoadXmlDoc('xml/gianhang_sua_tin_logic.php?id='+id+'&logic_id='+logic_id,'common_echo');	
}

function them_banner(value)
{
	submit_form('','','xml/banner/them.php?vitri='+value,'title' );
}


function xoa_banner(value)
{
	var answer = confirm('Bạn đã chắc chắn xóa quảng cáo này ?')
	if (answer){
		
		LoadXmlDoc('xml/banner/xoa.php?id='+value,'common_echo');	
		
	}


}

function gianhang_chon_loai_banner(value)
{
	LoadXmlDoc('xml/gianhang_banner/chon_loai_banner.php?value='+value,'common_echo');	
}

function gianhang_chon_hieu_ung_flash(value)
{
	LoadXmlDoc('xml/gianhang_banner/chon_hieu_ung_flash.php?value='+value,'common_echo');	
}





function doi_hien_thi(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_doihienthi.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}


function doi_hien_thi_danhmuc(id)
{
	LoadXmlDoc('xml/gianhang_sanpham/danhmuc_doihienthi.php?id='+id,'common_echo');	
}




function doi_hien_thi_capcon(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_doihienthicapcon.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}




function gianhang_target(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_target.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}

function xoa_danh_muc_tu_dong(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_xoa_danhmuc_tuhienthi.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}

function xoa_ket_noi_danh_muc(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_xoa_danhmuc_ketnoi.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}

function xoa_ket_noi_ss(id,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_xoa_ss_ketnoi.php?id='+id+'&menu_sua_id='+menu_sua_id,'common_echo');	
}
function doikieu(id,value,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu_doikieu.php?id='+id+'&value='+value+'&menu_sua_id='+menu_sua_id,'common_echo');	
}
function doi_nick_loai(id,value)
{
	LoadXmlDoc('xml/gianhang_suanick_loai.php?id='+id+'&value='+value,'common_echo');	
}
function doi_quangcao_loai(id,value)
{
	LoadXmlDoc('xml/web_quangcao/doiloai.php?id='+id+'&value='+value,'common_echo');	
}

function doi_quangcao_vitri(id,value)
{
	LoadXmlDoc('xml/web_quangcao/doi_vitri.php?id='+id+'&value='+value,'common_echo');	
}

function doi_danhmuc_qc(id,value)
{
	LoadXmlDoc('xml/web_quangcao/doi_danhmuc.php?id='+id+'&value='+value,'common_echo');	
}



function doi_id_trang(id,value)
{
	LoadXmlDoc('xml/gianhang_doi_id_trang.php?id='+id+'&value='+value,'common_echo');	
}

function gianhang_doi_danh_muc_tin(id,id_dm,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu/doi_danhmuctin.php?id='+id+'&id_dm='+id_dm+'&menu_sua_id='+menu_sua_id,'common_echo');	
}

function gianhang_menu_doi_danhmuc(id,id_dm,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu/gianhang_menu_doi_danhmuc.php?id='+id+'&id_dm='+id_dm+'&menu_sua_id='+menu_sua_id,'common_echo');	
}


function gianhang_doi_danh_muc_dichvu(id,id_dm,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu/gianhang_suamenu_danhmucdichvu.php?id='+id+'&id_dm='+id_dm+'&menu_sua_id='+menu_sua_id,'common_echo');	
}


function gianhang_doi_dichvu(id,id_dm,menu_sua_id)
{
	LoadXmlDoc('xml/gianhang_suamenu/gianhang_suamenu_dichvu.php?id='+id+'&id_dm='+id_dm+'&menu_sua_id='+menu_sua_id,'common_echo');	
}


function xoa_nick(id)
{
	LoadXmlDoc('xml/gianhang_nick/xoa_nick.php?id='+id,'common_echo');	
	
}


function xoa_tin_danhmuc(id)
{
	var answer = confirm('Nếu danh mục này chứa các bài viết,các bài viết sẽ không có danh mục mẹ, bạn cần chọn lại danh mục mẹ cho các bài viết, bạn đã chắc chắn xóa danh mục này ?')
	if (answer){
		LoadXmlDoc('xml/web_tin/xoa_tin_danhmuc.php?id='+id,'common_echo');	
	}
	
}


function xoa_votes(id)
{
	var answer = confirm('Xóa thăm dò này ?')
	if (answer){
		LoadXmlDoc('xml/admin/xoa_vote.php?id='+id,'common_echo');	
	}
	
}



function xoa_menu_ngang(id)
{
	var answer = confirm('Bạn đã chắc chắn xóa menu này ?')
	if (answer){
		LoadXmlDoc('xml/admin/menu_ngang_xoa.php?id='+id,'common_echo');	
	}
	
}

function xoa_danhmuc(id)
{
	var answer = confirm('Bạn đã chắc chắn xóa danh mục này ?')
	if (answer){
		LoadXmlDoc('xml/gianhang_sanpham/xoa_danhmuc.php?id='+id,'common_echo');	
	}
	
}


function sapxep_sanpham_khach(id,order_mask)
{
	order=document.getElementById('suasapxep_khach_'+id+order_mask).value;
	LoadXmlDoc('xml/sapxep_sanpham_khach.php?id='+id+'&order='+order,'common_echo');	
}

function gianhang_sua_loai_noi_dung(id)
{
	loai_noi_dung=document.getElementById('loai_noi_dung').value;
	LoadXmlDoc('xml/gianhang_sanpham/sua_loai_noi_dung.php?id='+id+'&value='+loai_noi_dung,'common_echo');	
}

function luu_gia_sanpham(id,tygia)
{
	price=document.getElementById('price').value;
	
	LoadXmlDoc('xml/gianhang_sanpham/luu_gia_sanpham.php?id='+id+'&price='+price,'common_echo');	
}


function luu_vat_sanpham_khach(id)
{
	vat=document.getElementById('vat').value;
	LoadXmlDoc('xml/gianhang_sua_vat_sanpham_khach.php?id='+id+'&vat='+vat,'common_echo');	
}


function gianhang_luu_baohanh(id)
{
	baohanh=encode(document.getElementById('baohanh').value);
	data='baohanh='+baohanh;
	LoadXmlDocPost('xml/gianhang_sanpham/sua_baohanh.php?id='+id,data,'common_echo')
}

function gianhang_luu_khuyenmai(id)
{
	khuyenmai=encode(document.getElementById('khuyenmai').value);
	data='khuyenmai='+khuyenmai;
	LoadXmlDocPost('xml/gianhang_sanpham/sua_khuyenmai.php?id='+id,data,'common_echo')
}

function sua_kieu_chitiet_khach(id)
{
	detail_type=document.getElementById('detail_type').value;
	LoadXmlDoc('xml/gianhang_sua_kieu_chitiet_khach.php?id='+id+'&value='+detail_type,'common_echo');	
}

function sua_kieu_anh_khach(id)
{
	pic_type=document.getElementById('pic_type').value;
	LoadXmlDoc('xml/gianhang_sua_kieu_anh_khach.php?id='+id+'&value='+pic_type,'common_echo');	
}


function xoa_tin(id)
{
	var answer = confirm('Bạn đã chắc chắn xóa tin này ?')
	if (answer){
		LoadXmlDoc('xml/web_tin/xoa.php?id='+id,'common_echo');	
	}
}

function xoa_comment(id)
{
	var answer = confirm('Bạn đã chắc chắn xóa comment này ?')
	if (answer){
		LoadXmlDoc('xml/web_tin/xoa_comment.php?id='+id,'common_echo');	
	}
}

function ngung_xuat_ban_tin(id)
{
	LoadXmlDoc('xml/web_tin/ngung_xuat_ban_tin.php?id='+id,'common_echo');	
}



function gianhang_dichvu_xoa(id)
{
	LoadXmlDoc('xml/gianhang_dichvu/xoa.php?id='+id,'common_echo');	
}



function sapxep_tin_khach(id,order_mask)
{
	order=document.getElementById('suasapxeptin_khach_'+id+order_mask).value;
	LoadXmlDoc('xml/gianhang_tin/sapxep.php?id='+id+'&order='+order,'common_echo');	
}


function gianhang_dichvu_sapxep(id,order_mask)
{
	order=document.getElementById('suasapxepdichvu_khach_'+id+order_mask).value;
	LoadXmlDoc('xml/gianhang_dichvu/sapxep.php?id='+id+'&order='+order,'common_echo');	
}



function gianhang_tin_moi(id)
{
	LoadXmlDoc('xml/gianhang_tin_moi.php?id='+id,'common_echo');	
}
function gianhang_tin_xuatban(id)
{
	LoadXmlDoc('xml/gianhang_tin_xuatban.php?id='+id,'common_echo');	
}

function gianhang_sanpham_xuatban(id)
{
		
	LoadXmlDoc('xml/gianhang_sanpham/xuatban.php?id='+id,'common_echo');	
}

function gianhang_danhmuc_xuatban(id)
{
	LoadXmlDoc('xml/gianhang_sanpham/danhmuc_xuatban.php?id='+id,'common_echo');	
}

function get_product_folder(id)
{
	id=String(id);
	len=id.length;
	folder=id.substr(0,(len-3));
	return folder+'000';
}

function doi_anh_chi_tiet_san_pham(ele,id,pic,gh)
{
	
	document.getElementById('anh_chitiet_sanpham').src="userfiles/cuahang/"+gh+"/sanpham/"+id+'/'+pic;
	
	
	
	className='anh_sanpham_chitiet_chon';
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == className)
	  {
		arr[arr.length] = id;
		
		 elem.className="anh_sanpham_chitiet";
	  }
	}
	
	ele.className='anh_sanpham_chitiet_chon';

	
}

function doi_dang_ky(value)
{
	className='dang_ky_gian_hang';
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == className)
	  {
		  	if(value==0)
			{
			 elem.style.display="none";
			}else
			{
			 elem.style.display="block";
			}
	  }
	}
	

	
}
function chon_tat_tin(string)
{
	var a = string.split("|");
	for (i=0;i<=a.length;i++)
	{
		eleid='newsletter'+(a[i])
		document.getElementById(eleid).checked=true
	}
}

function chon_tat_tin_comment(string)
{
	
	var a = string.split("|");
	for (i=0;i<=a.length;i++)
	{
		eleid='newsletter_comment'+(a[i])
		document.getElementById(eleid).checked=true;
		
	}
}


function bo_chon_tat_tin(string)
{
	var a = string.split("|");
	for (i=0;i<=a.length;i++)
	{
		eleid='newsletter'+(a[i])
		document.getElementById(eleid).checked=false
	}
}

function bo_chon_tat_tin_comment(string)
{
	
	var a = string.split("|");
	for (i=0;i<=a.length;i++)
	{
		eleid='newsletter_comment'+(a[i])
		document.getElementById(eleid).checked=false;
		
	}
}



function doi_anh_chi_tiet(ele,id,pic)
{
	document.getElementById('anh_chitiet_sanpham').src="userfiles/sanpham/"+get_product_folder(id)+"/"+id+"/"+pic;
	
	
}

function add_dot(self)
{
	oldvalue=self.value;
	oldvalue=oldvalue.replace('.','');
	oldvalue=oldvalue.replace('.','');
	oldvalue=oldvalue.replace('.','');
	oldvalue=oldvalue.replace('.','');
	oldvalue=oldvalue.replace('.','');
	
	len=oldvalue.length;
	var returnvalue;
	var part1='';
	var part2='';
	var part3='';
	var part4='';
	
	if(len<=3){part1=oldvalue}
	if(len>3 & len<=6)
		{
			part1=oldvalue.substr(0,len-3);
			part2='.'+oldvalue.substr(len-3,3);
		}
	
	if(len>6 & len<=9)
		{
			part1=oldvalue.substr(0,len-6);
			part2='.'+oldvalue.substr(len-6,3);
			part3='.'+oldvalue.substr(len-3,3);
		}
	
	if(len>9 & len<=11)
		{
			part1=oldvalue.substr(0,len-9);
			part2='.'+oldvalue.substr(len-9,3);
			part3='.'+oldvalue.substr(len-6,3);
			part4='.'+oldvalue.substr(len-3,3);
		}
	
	if(len>11)
		{
			part1=''
		}
	returnvalue=part1+part2+part3+part4;
	
	self.value=returnvalue;
}
function add_dot_price(self)
{
	add_dot(self)
}

function gianhang_dathang(id,gh,soluong)
{
	
	LoadXmlDoc('xml/gianhang_dathang.php?id='+id+'&gh='+gh+'&soluong='+soluong,'common_echo');	
}
function doi_anh_nen(id,template_id)
{
	document.getElementById('anh_nen_hien_tai').value=id;
	submit_form2('common_echo','banner_dongy','xml/gianhang_banner1.php?template_id='+template_id,'suabanner_div' );
				
	
}




function doi_kieu_quang_cao(value,id)
{
	LoadXmlDoc('xml/web_quangcao/doi_kieu_quang_cao.php?id='+id+'&value='+value,'common_echo');
}
	
	





function xoa_user(id)
{
	var answer = confirm('Xác user này ?')
	if (answer){
		LoadXmlDoc('xml/web_taikhoan/xoa.php?id='+id,'common_echo');
	}

}


function gianhang_xoa_lienhe(id)
{
	var answer = confirm('Xác nhận thư liên hệ này ?')
	if (answer){
		LoadXmlDoc('xml/gianhang_phanhoi/xoa_lienhe.php?id='+id,'common_echo');	
	}
}



function dangnhap()
{
	ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'modules/web_taikhoan/login_pop.php', 'Đăng nhập', 'width=400px,height=180px,resize=0,scrolling=0,center=1'); 
}






function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	  }
	return "";
}

function danhgia(value)
{
	document.getElementById('danhgia_hidden').value=value;
	for(var i = 1; i < 6; i++)
	{
		document.getElementById('dangia'+i).className='danhgia_off';
	}

	for(j = 1; j <= value; j++)
	{
		document.getElementById('dangia'+j).className='danhgia_on';
	}

}


function get_select_default(element,value)
{
	ele=document.getElementById(element);
	len = ele.length
	i = 0
	for (i = 0; i < len; i++) 
	{
		if (ele[i].value==value)ele.selectedIndex=i;
	}

	
}
function web_hien_thuoc_tinh_an(id)
{
	if(document.getElementById('bangan_'+id).style.display=="block")
	{
		document.getElementById('bangan_'+id).style.display="none";
		document.getElementById('nut_xem_them_'+id).innerHTML="Thêm";
	}else
	{
		document.getElementById('bangan_'+id).style.display="block";
		document.getElementById('nut_xem_them_'+id).innerHTML="Ẩn";
	}
}

function resize_thumb(ele)
{
	var width = ele.naturalWidth;
	var height = ele.naturalHeight;
	if(width>height)
	{
		ele.style.width="40px";	
		ele.style.height="auto";	
	}else
	{
		ele.style.height="auto";	
	}
}
	
	





function nhacnen()
{
	if(document.getElementById('stop_nhacnen').innerHTML=="Tắt nhạc nền")
	{
		soundManager.stop('helloWorld');
		document.getElementById('stop_nhacnen').innerHTML="Bật nhạc nền";
		url='xml/stopnhacnen.php';
		LoadXmlDoc(url,'');
	}
	else
	{
		soundManager.play('helloWorld');
		document.getElementById('stop_nhacnen').innerHTML="Tắt nhạc nền";
		url='xml/playnhacnen.php';
		LoadXmlDoc(url,'');
	}
	
}

function stop_popup()
{

	if(document.getElementById('stop_popup').innerHTML=="Bật lời nhắc")
	{
		document.getElementById('stop_popup').innerHTML="Tắt lời nhắc";
		url='xml/bat_popup.php';
		LoadXmlDoc(url,'');
	}
	else
	{
		document.getElementById('stop_popup').innerHTML="Bật lời nhắc";
		url='xml/stop_popup.php';
		LoadXmlDoc(url,'');
	}
	
}
function mo_rong_tom_tat(id)
{
	if(document.getElementById('nut_morong_'+id).innerHTML=="Thu hẹp")
	{
		document.getElementById('tomtat_'+id).style.height="55px";	
		document.getElementById('nut_morong_'+id).innerHTML="Mở rộng";
		document.getElementById('nut_morong_'+id).style.backgroundImage="url(templates/images/mo_rong_nho.gif)";
	}else
	{
		document.getElementById('tomtat_'+id).style.height="auto";	
		document.getElementById('nut_morong_'+id).innerHTML="Thu hẹp"	;
		document.getElementById('nut_morong_'+id).style.backgroundImage="url(templates/images/thu_hep_nho.gif)";
	}
	
}





function view_vote(id,path)
{
	url='xml/thamdo_xemketqua.php?id='+id;
	var LeftPosition;
	var TopPosition;
	LeftPosition = (screen.width)/2-200;
	TopPosition = (screen.height)/2-200;
	newwindow=window.open(url,'name','height=300,width=500,top='+TopPosition+',left='+LeftPosition);
	if (window.focus) {newwindow.focus()}
	return false;
}






function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
var winW = 630, winH = 460;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}
//left=winW/2-250;

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 10);
}

// ***** at_click *****








function quote(id)
{
	noidung='<div class="quote">'+document.getElementById('noidung_comment_'+id).innerHTML+'</div> <br /><br />';
	tinyMCE.get('detail').setContent(noidung);
}
function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}



function yourfunction(date)
{
	vartam='date'+date
	//varname=document.getElementById('name'+date).innerHTML;
	
	TagToTip(vartam, WIDTH,300,TITLE, 'Sự kiện', PADDING, 8, BORDERCOLOR,'#8fb939',CENTERMOUSE, true, OFFSETX, 0,OFFSETY,10);
}




