﻿// JScript File

		
	    var xmlHttp;  
		var _requestURL = '';
		var is_ie =   (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
		var is_ie5 =   (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
		var is_opera =  ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
		var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
		var divresult_="_divcontent";
		 
		
		
		function show_data(_divcontent,_requestquery)
		{ 
		 //	divresult_ = _divcontent.id;
		 	divresult_ = _divcontent;
		 	if (_requestquery.length > 0)
		 	{
		 		var url = _requestURL + _requestquery;
		 	 	xmlHttp = GetXmlHttpObject(stateChangeHandler);
		 		xmlHttp_Get(xmlHttp, url);
		 	}
		 	else 
		 	{ 
		 	   eval("document.getElementById('"+divresult_+"')").innerHTML ='Not found'; 		     		 	    
		 	}
		}
		
		function post_data(_requestquery)
		{ 
		 //	divresult_ = _divcontent.id;
		 
		 	if (_requestquery.length > 0)
		 	{
		 		var url = _requestURL + _requestquery;
		 	 	xmlHttp = GetXmlHttpObject(stateChangeHandler_post);
		 		xmlHttp_Get(xmlHttp, url);
		 	}
		 	
		}
		function stateChangeHandler_post()
		{
		//readyState of 4 or 'complete' represents that data has been returned  
		
		     if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		     {
		                 
		          var str = xmlHttp.responseText; 
		          alert(str);	
		        
		     }
		    
		}
		//stateChangeHandler
		function stateChangeHandler()
		{
		//readyState of 4 or 'complete' represents that data has been returned  
		
		     if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		     {
		                 
		           var str = xmlHttp.responseText; 
		          // document.getElementById('result').innerHTML = str; 
		           
		          eval("document.getElementById('"+divresult_+"')").innerHTML =str;	
		           
		     }
		     else
		     {
		      eval("document.getElementById('"+divresult_+"')").innerHTML ='Đang tải dữ liệu ...'; 
		         
		     	
		     }
		}
		
		
		 // XMLHttp send GET request 
		 function xmlHttp_Get(xmlhttp, url) 
		 { 
		       xmlhttp.open('GET', url, true);
		       xmlhttp.send(null); 
		 } 
		 
		 //GetXmlHttpObject
		 function GetXmlHttpObject(handler) 
		 { 
		 
		 	var objXmlHttp = null; 
		 	if (is_ie)
		 	{
		 	    var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
		 	    try
		 	    { 
		 	    
		 	        objXmlHttp = new ActiveXObject(strObjName);
		 	        objXmlHttp.onreadystatechange = handler;
		 	    }
		 	    catch(e)
		 	    {
		 	       alert('You must sure that activeX controls are enabled on your web brower');
		 	        return;
			    }
		 	    
		 	 }
		 	 
		 	 else if (is_opera)
		 	 {
		 	 		alert('Opera detected.  The page may not behave as expected.'); 
		 	 		return; 
		 	 }
		 	 else
		 	 {
		 	 		objXmlHttp = new XMLHttpRequest();
		 	 		objXmlHttp.onload = handler; 
			        objXmlHttp.onerror = handler;
			         
		 	 
		 	 }
		 	 return objXmlHttp; 
		 }
	function webdialog_1(url, width_, height_){
	//var cSearchValue=showModalDialog(url,0,"dialogWidth:width_;dialogHeight:height_;dialogleft:0px;dialogTop:700px","resizable: yes; status: yes");
	var win;
	win = window.open(url, 'dialog', "scrollbars=yes, resizable=yes,top=180, left=0, width=" + width_ + ", height=" + height_);
	win.focus();
}
		function OpenWinCenter(zzzurl)
		{
			    w = 550;
h=300;
var win = null;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable'
window.open(zzzurl,'Notes',settings);	
   
		}
		function OpenWinCenter1(zzzurl,w,h)
		{
			   
var win = null;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable'
window.open(zzzurl,'Notes',settings);	
   
		}
