<!--

function change_fact(the_list, the_url, the_div){
	var fact_id	= the_list.options[the_list.selectedIndex].value;
	if ( fact_id > 0 ){
		ajaxLoadURL(the_url +'&id='+ fact_id , the_div);
	}
}

function change_model(the_list, the_url){
	var id	= the_list.options[the_list.selectedIndex].value;
	if ( id > 0 ){
		window.location	= the_url +'?id='+ id;
	}
}

function search_all_modules(the_form){
	var module_url	= the_form.smodule.options[the_form.smodule.selectedIndex].value;
	if ( module_url != ""){
		the_form.action	= module_url;
		return true;
	}
	alert("Vui lòng chọn trang cần tìm !");
	return false;
}

//Open normal popup
function open_popup(the_url, the_width, the_height, the_menu) {
	if ( the_width == 0 ){
		the_width	= screen.width;
	}
	if ( the_height == 0 ){
		the_height	= screen.height;
	}

	left_val	= (the_width > 0) ? (screen.width - the_width)/2 : 0;
	top_val		= (the_height > 0) ? (screen.height - the_height)/2 - 30 : 0;
	if (top_val < 0){ top_val	= 0; }
	if (the_menu == ""){ the_menu	= "no";	}

	window.open(the_url, "", "menubar="+ the_menu +", toolbar="+ the_menu +", scrollbars=yes, resizable=yes, width="+ the_width +", height="+ the_height +", top="+ top_val +", left="+ left_val);
}

//Open popup when users submit form
function open_popup_form(the_url, targetName, the_width, the_height){
	left_val	= (the_width > 0) ? (screen.width - the_width)/2 : 0;
	top_val		= (the_height > 0) ? (screen.height - the_height)/2 - 30 : 0;
	if (top_val < 0){ top_val	= 0; }

	window.open(the_url, targetName, "menubar=no, toolbar=no, scrollbars=yes, resizable=yes, width="+ the_width +", height="+ the_height +", top="+ top_val +", left="+ left_val);
}

//Check and open popup when use chose web links
function weblink_openURL(the_url){
	if ( the_url != "" ){
		window.open(the_url);
	}
}

function select_list(the_value, the_list){
	var option_count = the_list.options.length;	
	for (i=0; i<option_count; i++){
		if (the_value == the_list.options[i].value){
			the_list.options[i].selected	= true;
			break;
		}
	}
}

function radio_list(the_value,the_list){
	var name_count = the_list.length;	
	for (i=0; i<name_count; i++){
		if (the_value == the_list[i].value){
			the_list[i].checked	= true;
			break;
		}
	}
}


function cart_update(){
	window.document.CARTFORM.submit();
}
function cart_check_login_form(the_form) {
	if ( (the_form.email.value == "") || (the_form.password.value == "") ){
		alert("Xin quý khách vui lòng nhập email và mật khẩu.")
		return false;
	}
	return true;
}
function cart_check_reg_form(the_form) {
	if ( (the_form.fullname.value == "") || (the_form.address.value == "") || (the_form.phone.value == "") || (the_form.email.value == "") ){
		alert("Xin quý khách vui lòng nhập đầy đủ thông tin yêu cầu.\n\nChú ý: các thông tin có dấu \"*\" là bắt buột.")
		return false;
	}
	return true;
}
function cart_edit_order(the_url){
	var the_form	= window.document.VERIFYFORM;
	the_form.action	= the_url;
	the_form.submit();
}
function cart_copy_shipping_info(the_form){
	if ( the_form.shipping_copy.checked ){
		the_form.shipping_fullname.value	= the_form.fullname.value;
		the_form.shipping_company.value		= the_form.company.value;
		the_form.shipping_address.value		= the_form.address.value;
		the_form.shipping_phone.value		= the_form.phone.value;

		the_form.shipping_fullname.disabled	= true;
		the_form.shipping_company.disabled	= true;
		the_form.shipping_address.disabled	= true;
		the_form.shipping_phone.disabled	= true;
	}
	else{
		the_form.shipping_fullname.disabled	= false;
		the_form.shipping_company.disabled	= false;
		the_form.shipping_address.disabled	= false;
		the_form.shipping_phone.disabled	= false;
	}
}

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function show_tip(obj, event){
	var ie	= document.all;
	var ns6	= (document.getElementById && !document.all) ? 1 : 0;
	if (ie || ns6) {
		var tipobj	= document.all ? document.all[obj] : (document.getElementById ? document.getElementById(obj) : "");
		var curX	= (ns6) ? event.pageX : event.x + ietruebody().scrollLeft;
		var curY	= (ns6) ? event.pageY : event.y + ietruebody().scrollTop;
		var rightedge	= (ie && !window.opera) ? ietruebody().clientWidth-event.clientX : window.innerWidth - event.clientX - 16;
		var bottomedge	= (ie && !window.opera) ? ietruebody().clientHeight-event.clientY : window.innerHeight - event.clientY;
		var leftedge	= -1000;

		if ( rightedge < tipobj.offsetWidth ){
			tipobj.style.left	= ie ? ietruebody().scrollLeft + event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset + event.clientX-tipobj.offsetWidth + "px";
		}
		else if (curX<leftedge){
			tipobj.style.left	= "5px";
		}
		else tipobj.style.left	= curX + "px";

		if ( bottomedge < tipobj.offsetHeight ){
			tipobj.style.top	= ie ? ietruebody().scrollTop + event.clientY-tipobj.offsetHeight+16+"px" : window.pageYOffset + event.clientY-tipobj.offsetHeight-16 + "px";
		}
		else{
			tipobj.style.top	= curY + 18 + "px";
			tipobj.style.visibility	= "visible"
			document.body.style.cursor	= "help";
		}
	}
}

function hide_tip(obj){
	var ie	= document.all;
	var ns6	= (document.getElementById && !document.all) ? 1 : 0;
	if (ie || ns6) {
		var tipobj	= document.all ? document.all[obj] : (document.getElementById ? document.getElementById(obj) : "");
		tipobj.style.visibility	= "hidden";
		tipobj.style.left		= "-1000px";
		document.body.style.cursor	= "auto";
	}
}

-->	
