
//ham JavaScript dung cho Ajax DDL Parent/Child 
	var obj, IdDiv;
	function ChangeCat(Url, IdDiv1)
	{			
	    IdDiv = IdDiv1;
		var xRequest=null;
		if(window.XMLHttpRequest)
		{
			xRequest = new XMLHttpRequest();			
		}
		else if(typeof xRequest != "undenfined")
		{
			xRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		obj = xRequest;
		if(obj != null)
		{
			obj.onreadystatechange = processResponse;	
			// doi duong dan den webform tao moi de goi (duong dan goc tinh tu webform goi Control nay)
			obj.open("GET",Url,true);  //"frm/StreetList.aspx?cid="+ParentID
			obj.send(null);
		}
	}
    // Process the HTTP Response when it is complete
	function processResponse()
	{
		if (obj.readyState == 4)
		{
			if (obj.status == 200)
			{
				var retval=obj.responseText;
				// ID phai giong ID the Div bao DDL child
				if (document.getElementById(IdDiv)!=null)    //"subCat"
				{
					document.getElementById(IdDiv).innerHTML = retval;
				}
				else
				{
					alert("Error retrieving data!");
				}
			}
		}
	}	
	//----------
	var obj4, IdDiv4;
	function ChangeCat4(Url, IdDiv1)
	{			
	    IdDiv4 = IdDiv1;
		var xRequest=null;
		if(window.XMLHttpRequest)
		{
			xRequest = new XMLHttpRequest();			
		}
		else if(typeof xRequest != "undenfined")
		{
			xRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		obj4 = xRequest;
		if(obj4 != null)
		{
			obj4.onreadystatechange = processResponse4;	
			// doi duong dan den webform tao moi de goi (duong dan goc tinh tu webform goi Control nay)
			obj4.open("GET",Url,true);  //"frm/StreetList.aspx?cid="+ParentID
			obj4.send(null);
		}
	}
    // Process the HTTP Response when it is complete
	function processResponse4()
	{
		if (obj4.readyState == 4)
		{
			if (obj4.status == 200)
			{
				var retval=obj4.responseText;
				// ID phai giong ID the Div bao DDL child
				if (document.getElementById(IdDiv4)!=null)  
				{
					document.getElementById(IdDiv4).innerHTML = retval;
				}
				else
				{
					alert("Error retrieving data!");
				}
			}
		}
	}	
//het ham JavaScript dung cho Ajax DDL Parent/Child 
	
	// Dung cho khung view anh Ajax --------------
	var objImage, IdDivImage;
	function ChangeCatImage(Url, IdDiv1) 
	{		
	    IdDivImage = IdDiv1;
		var xRequest=null;
		if(window.XMLHttpRequest)
		{
			xRequest = new XMLHttpRequest();			
		}
		else if(typeof xRequest != "undenfined")
		{
			xRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		objImage = xRequest;
		if(objImage != null)
		{
			objImage.onreadystatechange = processResponseImage;	
			// doi duong dan den webform tao moi de goi (duong dan goc tinh tu webform goi Control nay)
			objImage.open("GET",Url,true);   
			objImage.send(null);
		}
	}
    // Process the HTTP Response when it is complete
	function processResponseImage()
	{
		if (objImage.readyState == 4)
		{
			if (objImage.status == 200)
			{
				var retval=objImage.responseText;
				// ID phai giong ID the Div bao DDL child
				if (document.getElementById(IdDivImage)!=null)
				{
					document.getElementById(IdDivImage).innerHTML = retval;
				}
				else
				{
					alert("Error retrieving data!");
				}
			}
		}
	}	

// Ham check xem 1 chuoi co o cuoi cung cua chuoi khac ko
function endWith(strCheck, strEnd)
{
    var flag = false;
    var index = strCheck.toLowerCase().lastIndexOf(strEnd.toLowerCase());
    if(index > -1)
    {
    	if(strEnd.length + index == strCheck.length)
    	{
    		flag = true;
    	}		    	
    }
    return flag;
}

// Dung cho chuyen Tab --------------
//dua vao chuoi co trong ten validate control trong tung tab tuong ung theo dung thu tu tab
//Chu y : chuoi con nay phai nam sau cung ten validate control
var arrstr = new Array ("Sell", "Rent", "NeedStock"); 

function enableAllValidatorsOfTab(index)
{
    var id;
    for(i=0;i< Page_Validators.length;i++) 
    { 
        id = Page_Validators[i].id;         
        if(endWith(id,arrstr[index]) == true)
        {                
            ValidatorEnable(Page_Validators[i], true) 
        }                
        else
        {
            ValidatorEnable(Page_Validators[i], false) 
        }
        //alert(id + ' ~ ' + Page_Validators[i].isvalid); 
    }    
}
///------------- luc dau chi enable cac validate cua tab dau tien
function disableAllValidatorsOnload()
{
    var id;
    for(i=0;i< Page_Validators.length;i++) 
    { 
        id = Page_Validators[i].id;  
        for(j=1; j< arrstr.length; j++) 
        {
            if(endWith(id,arrstr[j]) == true)
            {
                ValidatorEnable(Page_Validators[i], false) 
                break;
            }
        }
    }   
}
document.write('<\/script>');
document.write('<\/script>');




