﻿// JScript File

function doSidebarSearchBox(obj, evt) {
	if (evt.keyCode!=13) return true;
	doSidebarSearch(obj.value);
	return false;
}

function doSidebarSearchButton(obj, tb) {
	var textbox = document.getElementById(tb);
	doSidebarSearch(textbox.value);
}

function doSidebarSearch(txt) {
	if (txt.length < 2) {
		alert('Vui lòng nhập chuỗi tìm kiếm.');
	} else {
		document.location = "/Search.aspx?Text=" + encodeURIComponent(txt);
	}
}

function OpenPopup(surl, sname, iwidth, iheight, itop, ileft, scrollbars) {
    var f = 'width=' + iwidth + ',height='+iheight;
    var x = (itop!=0)?(itop):((screen.width-iwidth)/2);
    var y = (ileft!=0)?(itop):((screen.height-iheight)/2);
    f += ',top=' + y + ',left=' + x;
    f += ',scrollbars=' + ((scrollbars)?('yes'):('no'));
    return window.open(surl, sname, f);
}

function AjaxBeginRequest() {
    var pimg = document.getElementById('AjaxProgressingImage');
    if (pimg) pimg.style.display = '';
}

function AjaxEndRequest() {
    var pimg = document.getElementById('AjaxProgressingImage');
    if (pimg) pimg.style.display = 'none';
}

function PrintNews(obj) {
	var win = OpenPopup(obj.toString(), 'printnews', 550, 550, 0, 0, true);
	win.focus();
}

function SendNews(obj) {
	var win = OpenPopup(obj.toString(), 'sendnews', 420, 450, 0, 0, false);
	win.focus();
}

function FeedbackNews(obj) {
	var win = OpenPopup(obj.toString(), 'fbnews', 420, 450, 0, 0, false);
	win.focus();
}

function jsAdPopup(w, h, url) {
		var opts = "width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=0,top=25,left=25";
		window.open(url,"_blank",opts);
	}