﻿function GetControlByName(id)
{
    var prefix = document.getElementById("hidPrefix").value;
    return document.getElementById(prefix + id);
}
/*Danh cho header-Tim kiem*/
function HideTextSearch(textSearch)
{       
    textSearch.value = "";
}
function ShowTextSearch(control)
{
    if (control) control.value = control.value.trim();
    if (control != null && control.value.length == 0)
    {
        control.value = "...điền từ khóa cần tìm";
    }
}
function DoSearch(txt)
{        
    var keySearch=document.getElementById(txt).value;
    if (document.all)
        window.location = "/home/resultsearch.html?keySearch=" + keySearch;
    else
        document.location = "/home/resultsearch.html?keySearch=" + keySearch;
}
function doClickTimTin(buttonName,event,strKey)
{
    var keySearch=strKey.value;
    var key;
    var url="/home/resultsearch.html?keySearch="+keySearch;
    if(window.event)
    {
        key = window.event.keyCode;     //IE
        if (key == 13)
        {
            if(strKey!="")
            {   
                document.location.href = url;
                //event.keyCode = 0;                        
                return false;
            }
            else
            {
                alert("Bạn chưa nhập từ khóa tìm kiếm !");
                return false;
            }
        }    
    }
    else
    {
        key =event.which; ;   //firefox
        if (key == 13)
        {
            if(strKey!="")
            {
                document.location.href = url;
                //event.keyCode = 0;
                return false;
            }
            else
            {
                alert("Bạn chưa nhập từ khóa tìm kiếm !");
                return false;
            }
        }    
    }
    
}

/*Danh cho Bao giay*/
function ShowAll(id,divID)
{
    var url = "/Ajax/Manazine/Show_Details.aspx?iCatID=" + id;
    new Ajax.Request(url,
	    {
		    method:'get',
		    evalScripts: true,			   		   
		    onSuccess: function(transport)
		    {
		        var response = transport.responseText;	
		        divID.innerHTML = response;			      
		    },
		    onFailure: function(){ alert('Có lỗi xảy ra..'); }			  
	    });
    return true;
}
function LoadAjaxContent(iCat_ParentID)
{	       
    document.getElementById("divYear").innerHTML = "<img src='/Images/loading.gif'/>Đang tải dữ liệu ...";
    var url = '/Ajax/Manazine/List_By_Year.aspx?iCat_ParentID='+ iCat_ParentID;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("divYear").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
/*Danh cho Menu Focus*/
function LoadFocus()
{
    var divMenu = document.getElementById("neo-nav");
    var listA = divMenu.getElementsByTagName("A");
    var hidCat=document.getElementById('hidCatID');
    if (hidCat)
    {
        var objLink = document.getElementById("id" +hidCat.value );
        if (objLink) {objLink.className =  "current";}
    }
}
/* Mo cua so PopUp*/
function openPopup(url) 
{
    var LeftPos=(screen.width)?(screen.width-600)/2:100;
    var TopPos=(screen.height)?(screen.height-500)/2:100;
    window.open(url,null,'height=500,width=600,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,Left= '+LeftPos+',top='+TopPos);
}
function openPopupCustome(url) 
{
    window.open(url, "popup_id", "scrollbars,resizable");
}
/*Danh cho Rating*/
function GetStarMark()
{
    var objStar=document.getElementById('divStar');
    if (objStar.style.display=='none')
    {
        objStar.style.display='block';
    }
    else
    {
        objStar.style.display="none";
    }
}
/*Nguoi tim viec*/
function LoadTimViec(id)
{	       
    document.getElementById("divNguoiTimViec").innerHTML = "<img src='/Images/loading.gif'/>Đang tải dữ liệu ...";
    var url = '/Ajax/Tuyen_Dung/Tim_Viec.aspx?PageIndex='+ id ;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("divNguoiTimViec").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
/*Tuyen Dung*/
function LoadTuyenDung(id)
{	       
    document.getElementById("divTuyenDung").innerHTML = "<img src='/Images/loading.gif'/>Đang tải dữ liệu ...";
    var url = '/Ajax/Tuyen_Dung/Tuyen_Dung.aspx?PageIndex='+ id ;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("divTuyenDung").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
/*Danh sach tin*/
function LoadDataDanhSachTin(PageIndex,catID,Date)
{	       
    document.getElementById("divList").innerHTML = "<img src='/Images/loading.gif'/>Đang tải dữ liệu ...";
    var url = '/Ajax/News/danhsachtin.aspx?CatID=' + catID + '&PageIndex='+ PageIndex + '&Date='+Date;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("divList").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
function LoadDataNext(PageIndex,catID)
{	       
    var url = '/Ajax/News/News_More_Next.aspx?CatID=' + catID + '&PageIndex='+ PageIndex ;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("NextList").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
/*Danh cho trang Picture*/
function LoadDataPicture(PageIndex)
{	       
    document.getElementById("divList").innerHTML = "<img src='/Images/loading.gif'/>Đang tải dữ liệu ...";
    var url = '/Ajax/Photo/ListPhoto.aspx?PageIndex='+ PageIndex ;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("divList").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
function LoadDataNextPiture(PageIndex)
{	       
    var url = '/Ajax/Photo/PhotoNext.aspx?PageIndex='+ PageIndex ;
    new Ajax.Request(
        url,
        {
              method: 'get',
              evalScripts: true,
              onSuccess: function(transport)
	            {
		             var response = transport.responseText;
		             document.getElementById("NextList").innerHTML = response;					          
	            },
              onFailure: function(){ alert('Có lỗi xảy ra...'); }	
        }
    );
}
