﻿// JScript File
var Control = 1;
function Flash()
{
    if (Control==1)
    {
        window.status = "->http://www.nts.edu.vn";
        Control = 0;
    }
    else
    {
        window.status = "-> Trường Trung Cấp Du Lịch Nha Trang!";
        Control = 1;
    }
    setTimeout("Flash();", 1000);
}
    
//Dung de xoa Session khi browser close
function PageUnload()
{ 
    var url = "../Session.aspx";
    
    if (event.altKey==true && event.keyCode==0 ){ //capturing ALT + F4
        document.location.href=url;
    }
    var Xwidth=document.body.offsetWidth-event.clientX
    var YHeight=event.clientY
    if(Xwidth<=30 && YHeight<0){ //capturing close button
        document.location.href=url;
    }
}

function getKey(el) 
    {
        if(event.which || event.keyCode){
            if ((event.which == 13) || (event.keyCode == 13)) {
                el.click();
            }
        }
    }

function features(isStatus, isResizeable, isScrollbars, isToolbar, isLocation, 
isFullscreen, isTitlebar, isCentered, width, height, top, left){
    if (isCentered)
	{
		top = (screen.height - height) / 2;
		left = (screen.width - width) / 2;
	}
    return 'status=' + (isStatus ? 'yes' : 'no') + ','
	+ 'resizable=' + (isResizeable ? 'yes' : 'no') + ','
	+ 'scrollbars=' + (isScrollbars ? 'yes' : 'no') + ','
	+ 'toolbar=' + (isToolbar ? 'yes' : 'no') + ','
	+ 'location=' + (isLocation ? 'yes' : 'no') + ','
	+ 'fullscreen=' + (isFullscreen ? 'yes' : 'no') + ','
	+ 'titlebar=' + (isTitlebar ? 'yes' : 'no') + ','
	+ 'height=' + height + ',' + 'width=' + width + ','
	+ 'top=' + top + ',' + 'left=' + left;
}

function showWindow(url, isStatus, isResizeable, isScrollbars, isToolbar, isLocation, 
isFullscreen, isTitlebar, isCentered, width, height, top, left)
{
	if (isCentered)
	{
		top = (screen.height - height) / 2;
		left = (screen.width - width) / 2;
	}
	
	return open(url, '_blank', 
	    features(false, false, false, false, false, false, true, true, width, height, 0, 0));
}

function showDialog(url, width, height)
{
	showWindow(url, false, false, true, false, false, false, true, true, width, height, 0, 0);
}

function OpenDialog(urlPath){
    var frm = window.showModalDialog(urlPath);   
    return false;
}   

function DoiTuong(name)
    {
        var x = "";
        for(var i=0; i<aspnetForm.elements.length; i++)
        {
            x = aspnetForm.elements[i].id;
            if(x.indexOf(name) > -1){
                return aspnetForm.elements[i];
            }
        }
        return null;
    }
    
function NewWin(el, rdbname)
    {
        var rdb = DoiTuong(rdbname);
        if (rdb != null) {
            var sitesearch = '';
            if(rdb.checked) sitesearch = 'www.nts.edu.vn';
            var url = 'http://www.google.com.vn/custom?domains=' + sitesearch + '&q=' + el.value + '&sitesearch=' + sitesearch;
            window.open(url);   
        }
    }
    
    


