﻿//var site_url = "http://chrt-test-svr2:8888/yb";
var site_url = "http://10.0.0.10";


function Search(url)
{
	window.location = url + "?k=" + aspnetForm.idSearchString.value + "&u=" + site_url;
}

function MySearchKeyDown(event, strUrl)
{

	if (event.keyCode == 13)
	{
		//alert(url + "?k=" + aspnetForm.idSearchString.value + "&u=" + site_url);
		window.location = strUrl + "?k=" + aspnetForm.idSearchString.value + "&u=" + site_url;
		return false;
	}
	return true;
}



function UpdateTuan(ChonNam, tuan)
{




    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var ChonTuan = ChonNam.form.elements["tuan"];
    while (ChonTuan.options.length) {
        ChonTuan.remove(0);
    }
    
    var nam = ChonNam.options[ChonNam.selectedIndex].value;
    
    var daunam =   new Date(nam,0,1) ;
     
    var ngaylech = ((new Date(nam,0,1) - new Date(2006,0,2))/86400000) % 7;

    if (ngaylech != 0)
    {
        daunam.setDate(daunam.getDate() + 7 - ngaylech);
    }
    
    var i = 1;
    if (nam != "") {
        while (parseInt(daunam.getFullYear()) < parseInt(nam) + 1) {
            var newElem = document.createElement("option");
            newElem.text = "Tuan " + i + " (" + daunam.getDate() + "/" +  (parseInt( daunam.getMonth()) + 1) + "/" + daunam.getFullYear() + " -> ";
            daunam.setTime( parseInt(daunam.getTime())+ 6*86400000);
            newElem.text = newElem.text + daunam.getDate() + "/" + (parseInt( daunam.getMonth()) + 1) + "/" + daunam.getFullYear() + ")";
            newElem.value = i;
            daunam.setTime(parseInt(daunam.getTime())+ 86400000);
            i = i + 1;
            ChonTuan.add(newElem, where);
        }
    }
    ChonTuan.selectedIndex = tuan -1;    
}




function DangNhap()
{
//alert("ok");
	document.cookie="loginAsDifferentAttemptCount=0";
	var url= site_url + "/_layouts\u002fAccessDenied.aspx?loginasanotheruser=true&Source="+escapeProperly(window.location.href);
	//alert(url);
	STSNavigate(url);

}


function DuyetLich(ListID, ItemID, Source )
{

	window.location = site_url + "/_layouts/approve.aspx?List=" + escapeProperly(ListID) + "&ID=" + ItemID + "&Source=" + escapeProperly(site_url + "/" + Source );
   
}

function GoToDetail(Page, ID, Source)
{
	window.location = site_url +  "/" + Page + "?ID=" + ID + "&Source=" + escapeProperly(site_url + "/" + Source); 


}

function ContinueAddNew(Source)
{
	
	if (aspnetForm.action.indexOf("Source") == -1)
	{
		if (aspnetForm.action.indexOf("?") == -1)
			{
			aspnetForm.action += "?Source=" + escapeProperly(site_url + "/" + Source); 
			}
		else
			{
			aspnetForm.action += "&Source=" + escapeProperly(site_url + "/" + Source); 

			}
	}

}
