﻿URLSite = '';
URL = ''
function Process_txtDioNewsId(Obj, Action)
{
    if(Action)
        Obj.value = "";
    else
    {
        if(Obj.value == "")
        Obj.value = "Nhập mã số tài sản";
    }
}
function Search_DioNews()
{
    Obj = document.getElementById("txtDioNewsId");
    if(Obj.value=="Nhập mã số tài sản")
    {
        url = URLSite +'/sieuthi/';
        //alert(url)            ;
        window.location.href =url;
    }
    else
    {
        if(IsNumeric(Obj.value)) 
        {
            url = URLSite +'/sieuthi/chitiet/';
            url = url + document.getElementById("txtDioNewsId").value +"/";        
            window.location.href =url;                
        }
        else
        {
            alert("Mã số tài sản phải là số nguyên");
            Obj.focus();        
        }
    }
}

//Scroll news for default
$(document).ready(function(){
    var newsoption1 = {
      firstname: "mynews",
      secondname: "showhere",
      //thirdname:"news_display",
      fourthname:"news_button",
      mouseover: false,
      imagedir: URL +'/images/',

       newsspeed:'8000'
    }
    $.init_news(newsoption1);


    var myoffset=$('#news_button').offset();

    var mytop=myoffset.top-1;

    $('#news_button').css({top:mytop});

});

//Script for block Search
function Home_DioNews_Count()
{        
    Controls_ucHome_DioNews_Search.TotalRecord(document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucHome_DioNews_Search_cboCity").value, document.getElementById("txtTuKhoa").value,document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucHome_DioNews_Search_cboDioNewsType").value,document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucHome_DioNews_Search_cboDoo_DioNews_Type").value, "0", document.getElementById("cboMaxPrice").value,Home_DioNews_CallBack);
}
function Home_DioNews_CallBack(response)
{   
    document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucHome_DioNews_Search_cmdSubmit").value = response.value;
    //document.getElementById("tbButton").innerHTML = '<input name="button" type="button" class="buttonHome" value="Xem 9888 tài sản"/>';
}
function Bind_cboDistrict(id)
{    
    Controls_ucHome_DioNews_Search.Bind_DropDownDistrict(id, Bind_cboDistrict_CallBack);
}
//function Bind_cboDistrict_CallBack(response)
//{
//    var ds = response.value;
//    var obj=document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucHome_DioNews_Search_cboDistrict");
//    obj.options.length = 0;        
//    
//    if(ds != null && typeof(ds) == "object" && ds.Tables != null)
//    {            
//        obj.options[0]=new Option("Tất cả","0");            
//        for(var i=0;i<ds.Tables[0].Rows.length;i++)
//        {                
//            obj.options[i+1]=new Option(ds.Tables[0].Rows[i].DisplayName, ds.Tables[0].Rows[i].DistrictId);                
//        }
//    }        
//}

//Script for block Email NewsLetter
function Validate_Form()
{
    var Email = document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucNewsLetter_txtEmail").value;
    if(Email == "")
    {
        alert("Bạn vui lòng nhập địa chỉ email");
        document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucNewsLetter_txtEmail").focus();
        return false;
    }
    else
    {
        if(checkEmail(Email)==false)
        {
            alert("Email không đúng định dạng, vui lòng kiểm tra lại");
            document.getElementById("ctl00_ctl00_cphMainContent_cphMainContent_ucNewsLetter_txtEmail").focus();
            return false;
        }
    }
    return true;
}
function Clear_Text(Obj, Action)
{
    if(Action)
        Obj.value = "";
    else
    {
        if(Obj.value == "")
        Obj.value = "Vui lòng nhập email của bạn";
    }
}
function Clear_KeywordText(Obj, Action, Text)
{
    if(Action)
        Obj.value = "";
    else
    {
        if(Obj.value == "")
        Obj.value = Text;
    }
}

