function setPointer(theRow, thePointerColor){
	if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
		return false;
	}
	if (typeof(document.getElementsByTagName) != 'undefined') {
		var theCells = theRow.getElementsByTagName('td');

	} else if (typeof(theRow.cells) != 'undefined') {
		var theCells = theRow.cells;

	} else {
		return false;
	}

	var rowCellsCnt  = theCells.length;
	for (var c = 0; c < rowCellsCnt; c++) {
		theCells[c].style.backgroundColor = thePointerColor;
	}
	return true;
} // end of the 'setPointer()' function
/********************************************************************************************/
function setcolor(theRow){
	var asd=document.forms[0].checked;
	var i;

	for (i=0; i<asd.length; i++){
		alert (" values is "+ asd[i].value);
	}

}
/********************************************************************************************/
function countuser(the_form){
	var elts      = document.forms[the_form].elements['CandidateSelect[]'];
	var elts_cnt  = elts.length;
	alert(elts_cnt);
	/*
	for (var i = 0; i < elts_cnt; i++) {
		elts[i].checked = do_check;
	} // end for*/
	//return true;
} // end 

function checkcount(the_form, ind){
	var elts      = document.forms[the_form].elements['CandidateSelect[]'];

	alert (elts[ind].status);
	if (elts[ind].value.checked==true){
		alert ("Checked");
	} else{
		alert(" Not Checked");
	}
}
/*****************************************************************************************/
function results(form){
	var index1=form.CandidateType.selectedIndex;
	var url='./index.php?m=admin&a=index&mode=report&CandidateType='+form.CandidateType.options[index1].value
			+'&check=1'
	location.replace(url);
}

/*************************************************************************************/
/***	Checks/unchecks all tables
*		@param   string   the form name
*		@param   boolean  whether to check or to uncheck the element
*		@return  boolean  always true
***/
function setCheckboxes(the_form, do_check){
	var elts      = document.forms[the_form].elements['selected_row[]'];
	var elts_cnt  = elts.length;
	for (var i = 0; i < elts_cnt; i++) {
		elts[i].checked = do_check;
	} // end for
	return true;
} // end of the 'setCheckboxes()' function
/*************************************************************************************/
function confirmLink(theLink)
{
    // Confirmation is not required in the configuration file
//    if (confirmMsg == '') {
//      return true;
//    }

    var is_confirmed = confirm('Do You Really want to DELETE this record?\n\nThis will permanently delete the Record!');
    if (is_confirmed) {
        theLink.href += '';
    }
    return is_confirmed;
} // end of the 'confirmLink()' function
/*************************************************************************************/
function selectcheque(the_form, do_check){

	var elts      = document.forms[the_form].elements['selected_row[]'];
	var elts2	  = document.forms[the_form].elements['amountcr[]'];
	var elts_cnt  = elts.length;
	for (var i = 0; i < elts_cnt; i++) {
		elts[i].checked = false;
	} // end for
	for (var i = 0; i < elts_cnt; i++) {
		if(elts2[i].value>=500){
			elts[i].checked = do_check;
		}
	} // end for
	return true;
	//alert("hello");
}
/*************************************************************************************/
function selectbf(the_form, do_check){

	var elts      = document.forms[the_form].elements['selected_row[]'];
	var elts2	  = document.forms[the_form].elements['amountcr[]'];
	var elts_cnt  = elts.length;
	for (var i = 0; i < elts_cnt; i++) {
		elts[i].checked = false;
	} // end for
	for (var i = 0; i < elts_cnt; i++) {
		if(elts2[i].value>0 && elts2[i].value<500){
			elts[i].checked = do_check;
		}
	} // end for
	return true;
	//alert("hello");
}
/********************************************************************************************/
function popups(the_form, the_link, width, height){
	var as; //,ap,ln;
	as=window.location;
	//alert(""+as+"");
	ap=as.toString();
	ln=ap.length - 1;
	ap1=ap.substring(0,ln);
	//window.opener.location.href=ap1;

	window.open(the_link, 'popup', 'WIDTH='+width+', HEIGHT='+height+',toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=1,resizeable=no,left=40,top=20');
}

/********************************************************************************************/

function student(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var url='./index.php?m=admin&a=student&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function subject(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var url='./index.php?m=admin&a=subject&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function notes(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.SubjectId.selectedIndex;
	var index4=form.TeacherId.selectedIndex;
	var url='./index.php?m=admin&a=notes&mode=add&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&subs='+form.SubjectId.options[index3].value
			+'&teach='+form.TeacherId.options[index4].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function studentnotes(form){
	var index3=form.SubjectId.selectedIndex;
	var index4=form.TeacherId.selectedIndex;
	var url='./index.php?m=student&a=notes&mode=add'
			+'&subs='+form.SubjectId.options[index3].value
			+'&teach='+form.TeacherId.options[index4].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function adminnotes(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.SubjectId.selectedIndex;
	var index4=form.TeacherId.selectedIndex;
	var url='./index.php?m=admin&a=notes&mode=list'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&subs='+form.SubjectId.options[index3].value
			+'&teach='+form.TeacherId.options[index4].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function teachernotes(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.SubjectId.selectedIndex;
	var index4=form.TeacherId.selectedIndex;
	var url='./index.php?m=faculty&a=notes&mode=list'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&subs='+form.SubjectId.options[index3].value
			+'&teach='+form.TeacherId.options[index4].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function studentquery(form){
	var index3=form.SubjectId.selectedIndex;
	var index4=form.TeacherId.selectedIndex;
	var url='./index.php?m=student&a=query'
			+'&subs='+form.SubjectId.options[index3].value
			+'&teach='+form.TeacherId.options[index4].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function adminquery(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.SubjectId.selectedIndex;
	var index4=form.TeacherId.selectedIndex;
	var url='./index.php?m=admin&a=query'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&subs='+form.SubjectId.options[index3].value
			+'&teach='+form.TeacherId.options[index4].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function acc(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.MonthId.selectedIndex;
	var url='./index.php?m=account&a=index'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&month='+form.MonthId.options[index3].value
			+'&year='+form.YearId.value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function edu(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.SubjectId.selectedIndex;
	var index4=form.YearId.selectedIndex;
	var index5=form.ExamId.selectedIndex;
	var url='./index.php?m=education&a=index'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&subs='+form.SubjectId.options[index3].value
			+'&year='+form.YearId.options[index4].value
			+'&exam='+form.ExamId.options[index5].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function studentacc(form){
	//var index3=form.MonthId.selectedIndex;
	var url='./index.php?m=student&a=account'
	//		+'&month='+form.MonthId.options[index3].value
			+'&year='+form.YearId.value
			+'&check=1'
	location.replace(url);
}
/********************************************************************************************/
function studentattend(form){
	//var index3=form.MonthId.selectedIndex;
	var url='./index.php?m=student&a=attend'
	//		+'&month='+form.MonthId.options[index3].value
			+'&year='+form.YearId.value
			+'&check=1'
	location.replace(url);
}
/********************************************************************************************/
function studentedu(form){
	//var index3=form.SubjectId.selectedIndex;
	var index4=form.YearId.selectedIndex;
	var index5=form.ExamId.selectedIndex;
	var url='./index.php?m=student&a=education'
//			+'&subs='+form.SubjectId.options[index3].value
			+'&year='+form.YearId.options[index4].value
			+'&exam='+form.ExamId.options[index5].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function notice(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.StudentId.selectedIndex;
	var url='./index.php?m=admin&a=notice'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&user='+form.StudentId.options[index3].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/
function noticeform(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.StudentId.selectedIndex;
	var url='./index.php?m=admin&a=notice&mode=add'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&user='+form.StudentId.options[index3].value
			+'&check=1'
	location.replace(url);
}

/********************************************************************************************/

function win_open(the_link){
	window.open(''+the_link+'&print=1', 'popup', 'height=500,width=600,left=115,top=15,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizeable=no');
	//window.popup.focus();
}
/********************************************************************************************/
function attend(form){
	var index1=form.FacultyId.selectedIndex;
	var index2=form.ClassId.selectedIndex;
	var index3=form.MonthId.selectedIndex;
	var url='./index.php?m=admin&a=attend'
			+'&faculty='+form.FacultyId.options[index1].value
			+'&class='+form.ClassId.options[index2].value
			+'&month='+form.MonthId.options[index3].value
			+'&year='+form.YearId.value
			+'&check=1'
	location.replace(url);
}
/********************************************************************************************/
function printfunc(the_link){
	var ur, ap;
	ur=the_link.href;
	ap=ur.substring(0, ur.length-1);
	location.replace(ap+"&print=1");
}
/********************************************************************************************/
function wordfunc(the_link){
	var ur, ap;
	ur=the_link.href;
	ap=ur.substring(0, ur.length-1);
	location.replace(ap+"&print=1&send_to_excel=1");
}
/********************************************************************************************/

function addUser(the_form) {
	var form = document.cat;
	//alert("sdf1");
	var fl = form.resources.length -1;
	//alert("sdf2");
	var au = form.assigned.length -1;
	var users = "x";
	//alert("sdf3");
	//build array of assiged users
	for (au; au > -1; au--) {
		users = users + "," + form.assigned.options[au].value + ","
	}

	//Pull selected resources and add them to list
	for (fl; fl > -1; fl--) {
		if (form.resources.options[fl].selected && users.indexOf( "," + form.resources.options[fl].value + "," ) == -1) {
			t = form.assigned.length
			opt = new Option( form.resources.options[fl].text, form.resources.options[fl].value );
			form.assigned.options[t] = opt
		}
	}
}
/********************************************************************************************/
function removeUser(the_form) {
	var form = document.cat;
	fl = form.assigned.length -1;
	for (fl; fl > -1; fl--) {
		if (form.assigned.options[fl].selected) {
			form.assigned.options[fl] = null;
		}
	}
}
/********************************************************************************************/

function popCalendar(x, docm, y, m, d){
	//var form = document.cat;
//alert(docm);
	mm = m;
	dd = d;
	yy = y;

dar = eval("document."+docm+"." + x + ".value.split('/')");
if(eval("document."+docm+"." + x + ".value.length") > 9) {
if(dar.length == 3)
  {
  yy = parseInt(dar[2], 10);
  mm = parseInt(dar[1], 10);
  dd = parseInt(dar[0], 10);
  }
}
	newwin = window.open( './calendar.php?form='+docm+'&page=tasks&field=' + x + '&thisYear=' + yy + '&thisMonth=' + mm + '&thisDay=' + dd, 'calwin', 'width=250, height=220, scollbars=false, status=false' );
}

/******************************************************************************************************************/
function DataTableCheckBox_Click1()
			{
				var oTR = this.parentNode.parentNode;

				if(this.checked)
				{
					if(this.IsNewMessage) oTR.className += ' selected';
					else oTR.className = 'selected';
					g_oDataTable.CheckBoxes.NumberChecked++;
				}
				else
				{
					if(this.IsNewMessage) oTR.className = 'msgnew';
					else oTR.className = 'msgold';
					g_oDataTable.CheckBoxes.NumberChecked--;
				}

				g_oDataTable.SelectAllRows.checked = (g_oDataTable.CheckBoxes.NumberChecked == g_oDataTable.CheckBoxes.length) ? true : false;
			}

/******************************************************************************************************************/

function hL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="H";
}

function dL(E,S){
while (E.tagName!="TR")
{E=E.parentElement;}
if (typeof(S)!="undefined")
E.className=S;
else
E.className="";
}

function CCA(CB,noHL){
if (!noHL)
	{
	if (CB.checked)
	hL(CB);
	else
	dL(CB);
	}
}

function NCCA(CB,noHL){
if (!noHL)
	{
	if (CB.checked)
	dL(CB);
	else
	hL(CB);
	}
}

// Open new window
var newWindow
	function openNewWindow(theURL) {
		newWindow = window.open(theURL,"","width=640,height=400 resizable=0,scrollbars=1,toolbar=0,menubar=0,location=0,directories=0,status=0,copyhistory=0")
	}




