﻿// JScript File
var winWidth = screen.width;
var winHeight = screen.height;
var ie6=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;
String.prototype.lTrim = function() { return this.replace(/^\s*/, ""); }
String.prototype.rTrim = function() { return this.replace(/\s*$/, ""); }
String.prototype.trim = function() { return this.lTrim().rTrim(); }
String.prototype.isEmail = function()
{
	var e = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i ;
	return e.test(this.trim());
}
String.prototype.isPosInteger = function() {
    var e = /^0*[1-9]+[0-9]*$/i ;
	return e.test(this.trim());
}
String.prototype.isEmpty = function (){return this.trim() == "" ? true : false;}
String.prototype.isUrl = function(){var r = /((ftp|http|https):\/\/)?(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return r.test(this.trim());}
Date.prototype.upSecond = function (){
    var h = this.getHours();
    var m = this.getMinutes();
    var s = this.getSeconds();
    s++;
    if(s == 60){ s=0; m++;}
    if(m == 60){ m=0; h++;}
    this.setHours(h);
    this.setMinutes(m);
    this.setSeconds(s);
}
function $(id){	return document.getElementById(id);	}

//window.onload = OnLoad;
function OnLoad()
{
    if(!ie5)
    {
        var divSessionLeft = document.getElementById("divSessionLeft");
        var divSessionContent = document.getElementById("divSessionContent"); 
        var newWidth = winWidth - 200 - 25;
        divSessionContent.style.width = newWidth + 'px';
    }
}
function extractHTML(html)
{
    var patternStart = '<div id="_ajaxdata">';
    var patternEnd = '</div></form>';
    var posStart = html.indexOf(patternStart);
    var len = html.length;
    var retVal = html.substring(posStart + patternStart.length, len - patternEnd.length);
    return retVal;
}
function OnDeleteWarning()
{
    return window.confirm('Bạn có chắc là muốn xóa phần tử đã chọn ?');
}
function OnVerifyWarning()
{
    return window.confirm('Bạn có chắc là đã duyệt phần tử đã chọn ?');
}

function resizeFullHeightFrame(f){
    f.style.height = f.contentWindow.document.body.scrollHeight + 20 + 'px';
}

function OnPrintPreviewNews(newsid){
    var url = 'Print.aspx?newsid=' + newsid.toString();
    showWindow(url);
}
function showWindow(url)
{	
	var winDef = "titlebar=no,scrollbars=yes,menubar=no,resizable=yes,status=no,fullscreen=no";
//	winDef = winDef.concat('top=').concat((screen.height)/2).concat(',');
//	winDef = winDef.concat('left=').concat((screen.width)/2);
	return window.open(url,"H1",winDef);
}
function OnEnter(evt, buttonId){
    evt = (evt) ? evt : ((event) ? event : null);
    if (evt) {
        var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
        if (charCode == 13){
            var btSearch=document.getElementById(buttonId); 
            if(btSearch){
                btSearch.focus();
                btSearch.click();
            }
        }
    }
}