/*---------------------------------------------------------------------------*/
function getDateClient(para) {
	var d = new Date();
	var y = parseInt(d.getYear());
	y %= 100;
	if (y < 10) y = "0" + y;
	if (para == "en") {
		var weekday 	= ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
		var monthday 	= ['January','February','March','April','May','June','July','August','September','October','November','December'];
		document.getElementById("spnDate").innerHTML = "<b>" + weekday[d.getDay()] + "</b>,&nbsp;" + monthday[d.getMonth()] + "&nbsp;" + d.getDate() + ",&nbsp;" + "20" + y;
	} else {
		var weekday 	= ['Ch&#7911; nh&#7853;t','Th&#7913; hai','Th&#7913; ba','Th&#7913; t&#432;','Th&#7913; n&#259;m','Th&#7913; s&aacute;u','Th&#7913; b&#7843;y'];
		var monthday 	= ['01','02','03','04','05','06','07','08','09','10','11','12'];
		document.getElementById("spnDate").innerHTML = "<b>" + weekday[d.getDay()] + "</b>,&nbsp;ng&agrave;y&nbsp;" + d.getDate() + "/"  + monthday[d.getMonth()] + "/" + "20" + y;
	}
}

function showImage(url) {
	var img = new Image();
	img.src = url;
	w = img.width;
	h = img.height;
	t=(screen.availHeight - h)/2;
	l=(screen.availWidth - w)/2;
	window.open(url,"","width=" + (w + 20)+ "px,height=" + (h + 20)+ ",top=" + t +"px,left=" + l + "px,resizable=0,status=0,scrollbars=yes");
}

// tim control
function $$(id) {
	return document.getElementById(id);
}
function trimSpace(s) {
	for (i=0;i<s.length;i++)
		s = s.replace("&nbsp;"," ");
	while(s.charCodeAt(0)==32 && s.length>1) {
		s=s.substr(1,s.length)
	}
	
	//-------------------------
	if(s.charCodeAt(0)==32 && s.length==1)
		return "";
	else
		return s;
}
function isEmail(email) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(email);
}

function Trim(s) {
	return trimSpace(s);
}

function download(id,tbl){
	window.open("download.php?id="+id+"&tbl="+tbl);
}
function isNumber(textNum)
{
	var re = /^[0-9]{1,5}$/;	
	sNum = document.getElementById(textNum).value;
	if (!re.test(sNum) ){
		alert("Vui long nhap vao kieu so !");		
		$("#"+textNum).focus();
		return false;
	}
}
function isNummeric(text){
	var re = /^[0-9]{1,4}$/;	
	return re.test(text);
}
function CompDateE(strDate1,strDate2){
		var m1, d1, y1;
		var m2, d2, y2;
		var s, pos1, pos2;
		var s = strDate1, s1 = strDate2;
		if (s.length == 0 || s1.length == 0) return true;

		pos1 = s.indexOf("/",0);
		pos2 = s.indexOf("/",pos1+1);
		d1 = parseInt(s.substr(0,pos1),10);
		m1 = parseInt(s.substr(pos1+1,pos2-pos1-1),10);
		y1 = parseInt(s.substr(pos2+1,s.length-pos2),10);
		
		pos1 = s1.indexOf("/",0);
		pos2 = s1.indexOf("/",pos1+1);
		d2 = parseInt(s1.substr(0,pos1),10);
		m2 = parseInt(s1.substr(pos1+1,pos2-pos1-1),10);
		y2 = parseInt(s1.substr(pos2+1,s1.length-pos2),10);
		
		var d1 = new Date(y1,d1,m1);
		var d2 = new Date(y2,d2,m2);
		if (d1 > d2 || d1 == d2) 
			return true;
		else
			return false;
	}
function CompDate(strDate1,strDate2){
	var m1, d1, y1;
	var m2, d2, y2;
	var s, pos1, pos2;
	var s = strDate1, s1 = strDate2;
	if (s.length == 0 || s1.length == 0) return true;

	pos1 = s.indexOf("/",0);
	pos2 = s.indexOf("/",pos1+1);
	d1 = parseInt(s.substr(0,pos1),10);
	m1 = parseInt(s.substr(pos1+1,pos2-pos1-1),10);
	y1 = parseInt(s.substr(pos2+1,s.length-pos2),10);
	
	pos1 = s1.indexOf("/",0);
	pos2 = s1.indexOf("/",pos1+1);
	d2 = parseInt(s1.substr(0,pos1),10);
	m2 = parseInt(s1.substr(pos1+1,pos2-pos1-1),10);
	y2 = parseInt(s1.substr(pos2+1,s1.length-pos2),10);
	
	var d1 = new Date(y1,m1,d1);
	var d2 = new Date(y2,m2,d2);
	if (d1 > d2 || d1 == d2) 
		return true;
	else
		return false;
}

function requestCheck(){
	var $checked=false;
	$('input[id=chkid]').each(function(){
		if(this.checked)
			$checked=true;
	});
	return $checked;
}
function valueArr(){
	$_hiden_value="";
	$('input[id=chkid]').each(function(){		
		if(this.checked){
			$_hiden_value += this.value + "$";
		}
	});
	return $_hiden_value;
}
function getTextFCK(FCKname)
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance(FCKname) ;
		// Get the editor contents in XHTML.
	return oEditor.GetXHTML(true);// "true" means you want it formatted.
}
function showHide(id)
{
	ctrl = document.getElementById(id);
	if (ctrl.style.display == "none"){
		ctrl.style.display = "";		
	}else{
		ctrl.style.display = "none";
	}
}
function changeMenu(id){		
	 $("div[id*='menu_']").each(function(){
		$(this).hide('normal'); 	 
	})

	$("#menu_" + id).show('normal');//.css("display", "");
	temp = ($('#divcontent-left').height() >  $('#divcontent-right').height())?($('#divcontent-left').height()):($('#divcontent-right').height());
	$('#divcontent-left').height(temp+10);
	$('#divcontent-right').height(temp);
}

function CompDateOrder(strDate1,strDate2){
    var m1, d1, y1;
    var m2, d2, y2;
    var s, pos1, pos2;
    var s = strDate1, s1 = strDate2;
    if (s.length == 0 || s1.length == 0) return true;

    pos1 = s.indexOf("/",0);
    pos2 = s.indexOf("/",pos1+1);
    d1 = parseInt(s.substr(0,pos1),10);
    m1 = parseInt(s.substr(pos1+1,pos2-pos1-1),10);
    y1 = parseInt(s.substr(pos2+1,s.length-pos2),10);

    pos1 = s1.indexOf("/",0);
    pos2 = s1.indexOf("/",pos1+1);
    d2 = parseInt(s1.substr(0,pos1),10);
    m2 = parseInt(s1.substr(pos1+1,pos2-pos1-1),10);
    y2 = parseInt(s1.substr(pos2+1,s1.length-pos2),10);

    var d1 = new Date(y1,m1,d1);
    var d2 = new Date(y2,m2,d2);
    if (d1 < d2 || d1 == d2)
        return true;
    else
        return false;
}

function addToCart(id){		
		return confirm("Ban co muon chuyen qua website ban hang truc tuyen cua chung toi hay khong?");
	}


