﻿///////////////
// Call Form //
///////////////
var loadstatustext="<img src='images/gif/loading.gif' /> Đang tải dữ liệu..."
function get_module(link, id, param)
{
    document.getElementById(id).innerHTML=loadstatustext
    $.ajax
    ({
	    type: "GET",
	    url: "modules/" + link + ".aspx",
	    data: "p=" + param,
	    success: function(dt)
	    {
		    $("#" + id).html(dt);
	    }
    });
}
function get_var(param)
{
    $.ajax
    ({
	    type: "GET",
	    url: "modules/get_var.aspx",
	    data: "v=" + param,
	    success: function(dt)
	    {
		    return true;
	    }
    });
}
function get_content(link, id, param)
{
    document.getElementById(id).innerHTML=loadstatustext
    $.ajax
    ({
	    type: "GET",
	    url: link + ".aspx",
	    data: "p=" + param,
	    success: function(dt)
	    {
		    $("#" + id).html(dt);
	    }
    });
}
function get_content_focus(link, id, param, control)
{
    document.getElementById(id).innerHTML=loadstatustext
    $.ajax
    ({
	    type: "GET",
	    url: link + ".aspx",
	    data: "p=" + param,
	    success: function(dt)
	    {
		    $("#" + id).html(dt);
		    if(dt!="")
		        $('#' + control).focus();
	    }
    });
}
function get_content_reload(link, id, param, reload, note)
{
    document.getElementById(id).innerHTML=loadstatustext
    $.ajax
    ({
	    type: "GET",
	    url: link + ".aspx",
	    data: "p=" + param,
	    success: function(dt)
	    {
		    $("#" + id).html(dt);
		    if(dt=="")
		    {
		        if(note != "")
                    alert(note);
		        window.location = reload;
		    }
	    }
    });
}
function get_content_confirm(link, id, param, note, status)
{
    if (status == 1)
    {
        status = confirm(note);
        if (status == false)
            return;
    }
    get_content("modules/" + link, id, param);
    if (status == 2)
        alert(note);
}
function get_content_search(link, param)
{
    $.ajax
    ({
	    type: "GET",
	    url: link + ".aspx",
	    data: "p=" + param + "&url=" + window.location.href + "&site=" + $('#rdoAllSongs:checked').val(),
	    success: function(dt)
	    {
	        window.location = dt;
	    }
    });
} 
function get_multi_content(link1, id1, param, link2, id2)
{
    $.ajax
    ({
	    type: "GET",
	    url: link1 + ".aspx",
	    data: "p=" + param,
	    success: function(dt)
	    {
		    $("#" + id1).html(dt);
		    $("#" + id2).load(link2 + ".aspx");
	    }
    });
}

function jqueryHash(){
	var hash = window.location.hash;
	hash  = hash.replace('#','');
	if( hash == '' ){
		return 1;
	}else{
		return hash;
	}
}
function updating1()
{
    alert("Phim này đang cập nhật.\nXin quý khách vui lòng chọn xem phim khác!\nXin chân thành cảm ơn quý khách!");
}
function comming_son()
{
    alert("Chức năng này đang được hoàn thiện.\nXin quý khách vui lòng quay lại sau!\nXin chân thành cảm ơn quý khách!");
}
$(document).ready(function () {
    setTimeout(function() {$("#header").load("ads/header.aspx");}, 500);
    setTimeout(function() {$("#footer").load("ads/footer.aspx");}, 2000);
    //$('#schedule').click(function () {get_content('modules/lichphatsong', 'schedule', '');});
    $("#right_banner_1").load("ads/quang_cao_online_vinatro.aspx?p=10&sp=0&po=4&t=1");
    $("#right_banner_2").load("ads/quang_cao_online_vinatro.aspx?p=10&sp=0&po=4&t=2");
    $("#right_banner_3").load("ads/quang_cao_online_vinatro.aspx?p=10&sp=0&po=4&t=3");
//    $("#left_banner").load("ads/left_banner.aspx");
	$('#love_film').click(function () {love_film();});
	$('#comment_film').click(function () {alert('Comming soon!');});
    $('#share_film').click(function () {alert('Comming soon!');});
    $('#broken_film').click(function () {broken_film();});
	$('#mistake_film').click(function () {mistake_film();});
	$('#broken_link_film').click(function () {broken_link_film();});
	$('#deleted_film').click(function () {deleted_film();});
    //Seach
	$('#txtSearch').focus(function () {
	    var s = "Từ khóa tìm kiếm...";
	    var str = trim($('#txtSearch').val());
	    fnFocus(str, s, "txtSearch");
	});
	$('#txtSearch').blur(function () {
	    var s = "Từ khóa tìm kiếm...";
	    var str = trim($('#txtSearch').val());
	    fnBlur(str, s, "txtSearch");
	});
	$('#txtSearch').keydown(function (e) {
	    var code = (e.keyCode ? e.keyCode : e.which);
         if(code == 13) { $("#btnSearch").click();}
	});
	$('#txtSearch_bottom').focus(function () {
	    var s = "Từ khóa tìm kiếm...";
	    var str = trim($('#txtSearch_bottom').val());
	    fnFocus(str, s, "txtSearch_bottom");
	});
	$('#txtSearch_bottom').blur(function () {
	    var s = "Từ khóa tìm kiếm...";
	    var str = trim($('#txtSearch_bottom').val());
	    fnBlur(str, s, "txtSearch_bottom");
	});
	$('#txtSearch_bottom').keydown(function (e) {
	    var code = (e.keyCode ? e.keyCode : e.which);
         if(code == 13) { $("#btnSearch_bottom").click();}
	});
	$('#btnSearch').click(function () {
	    var str = trim($('#txtSearch').val());
	    if(str.length < 2 || str == "Từ khóa tìm kiếm...")
	    {
	        alert("Xin vui lòng nhập từ khóa cần tìm nhiều hơn một ký tự!");
	        return;
	    }
	    document.getElementById("txtSearch_bottom").value = str;
	    get_search_list();
	});
	$('#btnSearch_bottom').click(function () {
	    var str = trim($('#txtSearch_bottom').val());
	    if(str.length < 2 || str == "Từ khóa tìm kiếm...")
	    {
	        alert("Xin vui lòng nhập từ khóa cần tìm nhiều hơn một ký tự!");
	        return;
	    }
	    document.getElementById("txtSearch").value = str;
	    get_search_list();
	});
	$('#btnReset').click(function () {
	    document.getElementById("txtSearch").value = "";
	    document.getElementById("txtSearch").focus();
	});
	$('#btnReset_bottom').click(function () {
	    document.getElementById("txtSearch_bottom").value = "";
	    document.getElementById("txtSearch_bottom").focus();
	});
});
