//Ham chi cho nhap so vao textbox
function numberOnly(evt) {
	evt = (evt) ? evt : ((window.event) ? event : null);
	if (evt) {
	   var elem = (evt.target) ? evt.target : 
		  ((evt.srcElement) ? evt.srcElement : null);
	   if (elem) {
		   var charCode = (evt.charCode) ? evt.charCode : 
			   ((evt.which) ? evt.which : evt.keyCode);
		   if ((charCode < 32 ) || 
			   (charCode > 44 && charCode < 47) || 
			   (charCode > 47 && charCode < 58)) {
			   return true;
		   } else {
			   return false;
		   }
	   }
	}
}

//Chon tat ca cac checkbox
function checka(){
		form=document.adminForm;
		for (var i = 0; i < form.elements.length; i++) {
			if ( form.all.checked==true ){
				form.elements[i].checked = true;
			}
			else{
				form.elements[i].checked = false;
			}
		}
}

//An - Hien 1 doi tuong
function hide_show_item(item_name){	
	var obj = document.getElementById(item_name).style;
	if(obj.display=="none"){
		obj.display="block";
	}else{
		obj.display="none";
	}
}

function lockMenu(){
	$('menu').style.display="none";
}

function unlockMenu(){	
	$('menu').style.display="inline";
}

function ajaxSubmit(div,link,pressbutton,form) {
	
	//alert(link);
	link=link.replace(/\//g,'-');

	switch(pressbutton){
		case 'deleteone':
			if(confirm('Are you sure to delete this?')){
				Nav.go(div,link,form);	
			}
			break;
		case 'resetpass':
			if(confirm('Are you sure to reset password this user?')){
				Nav.go(div,link,form);	
			}
			break;
		case 'delete':
			
			for (var i = 0; i < document.adminForm.elements.length; i++) {
				if ( document.adminForm.elements[i].checked == true && document.adminForm.elements[i].id=='cb'){
					break;
				}
			}
			if(i==document.adminForm.elements.length){
				alert('No selected data !');
				break;
			}
			if(confirm('Are you sure to delete?')){
				Nav.go(div,link,form);	
			}
			break;
		case 'move':
			
			for (var i = 0; i < document.adminForm.elements.length; i++) {
				if ( document.adminForm.elements[i].checked == true && document.adminForm.elements[i].id=='cb'){
					break;
				}
			}
			if(i==document.adminForm.elements.length){
				alert('No selected data !');
				break;
			}
			if(confirm('Bạn có muốn chuyển giao các yêu cầu đã chọn cho Qnc?')){
				Nav.go(div,link,form);	
			}
			break;
		case 'published':
			
			for (var i = 0; i < document.adminForm.elements.length; i++) {
				if ( document.adminForm.elements[i].checked == true && document.adminForm.elements[i].id=='cb'){
					break;
				}
			}
			if(i==document.adminForm.elements.length){
				alert('No selected data !');
				break;
			}
			Nav.go(div,link,form);	
			break;
		default:
			
			Nav.go(div,link,form);
		;
	}
	
	return false;	
}

function ajax(container,action,form){

	$('loading').style.display='inline';
	width='50%';
		
	height='50%'//screen.height;

	//$('cover').style.width=width;
	//$('cover').style.height=height;
	//$('cover').style.marginTop="100px";
	//$('cover').style.marginLeft="25%";
	//$('cover').style.zIndex=199;
	//$('cover').style.background="#74B842";
	//$('cover').style.filter='alpha(opacity=40)';
	//$('cover').style.opacity='0.4';
	$('imgcover').style.zIndex=200;
	$('imgcover').style.marginLeft="42%";
	$('imgcover').style.marginTop=200;

	if(form){
		form=$(form);
		form.action=action;
			
		form.send({update: $(container),
				evalScripts:true,
				onComplete: function() {
					$('loading').style.display='none';
				}
		});
	}
	else{
		
		new Ajax(action, {method:'post',update: $(container), asynchronous:true, evalScripts:true,
					onComplete: function(){
							$('loading').style.display='none';
						}							  
												  }).request();
	
	}
	
	/*cover=document.getElementById('cover');
	$('loading').style.width='100%';
	$('loading').style.height='100%';
	$('loading').style.position='absolute';
	$('loading').style.zIndex=100;
	
	$('loading').style.filter='alpha(opacity=40)';
	$('loading').style.opacity='0.4';
	*/

}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function empty(str){
		var temp="";
		var len=0;
		temp=str;
		while(len!=temp.length){
			len=temp.length;
			temp=temp.replace(" ","");
			temp=temp.replace("\r","");
			temp=temp.replace("\n","");
		}
		if(temp=="")return true;
		return false;
	}

function translateWord(strreplace){
	var str =new String(strreplace);
	
	//---------------------------------

	return str;


}
