// JavaScript Document
//mshareif areea----------------------------------------------------------------------------------------------------------------------------------------------
var globalFactor='0.11';

var pathG='http://www.caderco.com/new_portal/user/';
//var pathG='http://localhost/new_portal/user/';
//create ajax http request
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
//general varible
var http = createObject();
//-------

function editFormalLetter(letterNum)
{
	window.open('?typeRequested=1&letterNum='+letterNum,"Nominate","width=1000,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}

function openFullWindow()
{
	window.open(window.location.href+'&z=1',"fs","fullscreen=yes","scrollbars=yes")
}
function openFullWindow2()
{
	window.location.href+'&z=2';
}
///---------------ajax serching mail
////filter the hotmaillist as user selected 
function filterListOfUSers()
{
		//var array=Array('a','b')
		//document.getElementById('hotmailUserList').scrollTop = 100;

}
//----sending this value to php server side to filter the data 
function serchMailResult(value,sentBox)
{
	if(sentBox!='')
		sentPage='1';
	else
		sentPage='0';
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=filterEmail&sentPage='+sentPage+'&value='+value+'&nocache='+nocache,true);
	http.onreadystatechange = fillFilteringData;
	http.send('');
}
function fillFilteringData()
{
	if(http.readyState == 4){	
	
	var response = http.responseText;
	var value=document.getElementById('mailSearchKey').value;
	document.getElementById("resultSerach").style.border="1px solid #ffffff";
	var content='<table border=0 align=center width=90%>';
	content+='<tr><td class=normal_text colspan=2>'+response+'</td></tr>';
	content+='<tr><td class=normal_text>From:</td><td>'+value+'</td></tr>';
	content+='<tr><td class=normal_text>to:</td><td>'+value+'</td></tr>';
	content+='</table>';
	
	if(value!='')
	{
		document.getElementById('resultSerach').innerHTML='<div class=hotmailUserList style="width:250px;position:absolute;z-index:1;height=200px;" id=divOnTheFly>'+content+'</div>';
	}
	else
	document.getElementById('resultSerach').innerHTML='';
	}
}
function viweLoadingImageInDiv()
{
	document.getElementById('divOnTheFly').innerHTML='<img src=../images/loading_aqua.gif width=300 height=290 />';
}
//------------------
//-----------------------next and prev mail
function nextEmail(id)
{
	var data="";
	data+="<table border=0 align=center cellpadding=0 cellspascing=0 bgcolor=#ffffff><tr><td ><img src=../images/loading_aqua.gif width=300 height=290 /></td>";
	data+="</table>";
	document.getElementById("image_div").innerHTML=data;
	document.getElementById('image_div').style.padding='200 100 400 400 px';
	document.getElementById('image_div').style.visibility='visible';
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=nextPage&detailsEmail='+id+'&nocache='+nocache,true);
	http.onreadystatechange = showNextMail;
	http.send('');
}
function showNextMail()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	emptyCells();
	}
}
//--------------
////----------send email to draft 
function addingEmailToDraft()
{
	var data="";
	data+="<table border=0 align=center cellpadding=0 cellspascing=0 bgcolor=#ffffff><tr><td ><img src=../images/loading_aqua.gif width=300 height=290 /></td>";
	data+="</table>";
	document.getElementById("image_div").innerHTML=data;
	document.getElementById('image_div').style.padding='200 100 400 400 px';
	document.getElementById('image_div').style.visibility='visible';
	document.getElementById("forDraftVersion").value=1;
	
	document.getElementById('sendMail').submit();
	/*var nocache = Math.random();
	http.open('GET','index.php?typeRequested=savingDraftVersion&title='+title+'&description='+desc+'&nocache='+nocache,true);
	http.onreadystatechange = savingDraftResult;
	http.send('');*/
}

//print all vacation report
function printAllVacLeavYear(year)
{
	window.open('?typeRequested=1&yearSelected='+year,"Nominate","width=1000,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
//print all vacation report
function printAllVacLeavYearSummery(year)
{
	window.open('?typeRequested=1&yearSelectedSummery='+year,"Nominate","width=1000,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
//get nominate details
function getNominationDetails(id)
{
	window.open('?typeRequested=1&id='+id,"Nominate","width=500,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
////go to necxt page for the EOM
function nextPageEOM()
{
	window.location='?req=nextPage';
	/*var data="";
	data+="<table border=0 align=center cellpadding=0 cellspascing=0 bgcolor=#ffffff><tr><td ><img src=../images/loading_aqua.gif width=300 height=290 /></td>";
	data+="</table>";
	document.getElementById("image_div").innerHTML=data;
	document.getElementById('image_div').style.padding='1200 100 400 400 px';
	document.getElementById('image_div').style.visibility='visible';
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=nextPage2&req=nextPage&nocache='+nocache,true);
	http.onreadystatechange = nextPageResult;
	http.send('');*/
}
function nextPageResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	emptyCells();
	}
}
//fill id for master trainer for get assesment marks
function fillMtIdAsses()
{
	document.getElementById('selectedMtId1').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId2').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId3').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId4').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId5').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId6').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId7').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId8').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId9').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId10').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId11').value=document.getElementById('mtListNotMultiple').value;
	document.getElementById('selectedMtId12').value=document.getElementById('mtListNotMultiple').value;
	
}
//-----if its require view data here 
function viewRequFiled(onSite,campus)
{
	//alert(campus);
	if(document.getElementById('school_name').value==0 || document.getElementById('school_name').value==5)
	{
		document.getElementById('student_name').value='';
		document.getElementById('student_name_title').style.color='#FF0000';
		document.getElementById('lecture_title').innerHTML='';
		document.getElementById('lecture_list').innerHTML='';
	}
	else
	if(document.getElementById('school_name').value==2 )
	{
		document.getElementById('student_name').value='----';
		document.getElementById('student_name_title').style.color='#000000';
		document.getElementById('lecture_title').innerHTML='onSite Lecture';
		document.getElementById('lecture_list').innerHTML=onSite;
	}
	else
	if( document.getElementById('school_name').value==3)
	{
		document.getElementById('student_name').value='----';
		document.getElementById('student_name_title').style.color='#000000';
		document.getElementById('lecture_title').innerHTML='Campus Lecture';
		document.getElementById('lecture_list').innerHTML=campus;
	}
	else
	{
		document.getElementById('student_name').value='------';
		document.getElementById('student_name_title').style.color='#000000';
		document.getElementById('lecture_title').innerHTML='';
		document.getElementById('lecture_list').innerHTML='';
	}
}
function sendEmailPopup(userId,targetId)
{
	//alert('?sendEmailPopup=1&typeRequested=1&sender='+userId+'&rec='+targetId);
	//alert(targetId);
	window.open(pathG+'?sendEmailPopup=1&typeRequested=1&sender='+userId+'&rec='+targetId,"SendEmail","width=500,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
function hiditNoew()
{
	alert(1);
}
//view sds in students marks list
function viewSds(id,data)
{
		if(document.getElementById('viewSds_'+id).innerHTML=='')
			document.getElementById('viewSds_'+id).innerHTML=data ;
		else
			document.getElementById('viewSds_'+id).innerHTML='' ;
}
//fill fileds for editing the transp
function fillUpdateTransFileds(fromDate,toDate,ny,fmonth,tomonth,y)
{
		document.getElementById('fromDate').value=fromDate ;
		document.getElementById('toDate').value=toDate ;
		document.getElementById('ny').value=ny ;
		document.getElementById('fmonth').value=fmonth ;
		document.getElementById('tmonth').value=tomonth ;
		document.getElementById('y').value=y ;
		document.getElementById('viewReports').submit();

}
//add transportation form using js
function fillTranFormJs(data,id)
{
	document.getElementById('tranFormJs_'+id).innerHTML=data;
}
//view on line user in the user home page
function getOnlineUser(data,e)
{
		var height='90';
		//document.getElementById("sendingToData").innerHTML=list2;
		//document.getElementById("sendingToData").innerHTML='';
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			//alert(screen.height-event.screenY);
			if(screen.height-event.screenY>380)
			{
				var x_pos=event.screenX+document.body.scrollLeft;
				var y_pos=event.screenY+document.body.scrollTop;
			}
			else
			{
				var x_pos=event.screenX+document.body.scrollLeft;
				var y_pos=event.screenY+document.body.scrollTop;
			}
		}
		else
		{
			//alert((screen.height-e.clientY));
			if((screen.height-e.clientY)>410)
			{
				var x_pos=e.clientX+document.body.scrollLeft;
				var y_pos=e.clientY+document.body.scrollTop-20;
			}
			else
			{
				var x_pos='1000';
				var y_pos=e.clientY+document.body.scrollTop-320;
			}
		}
		image_div.style.left=x_pos-140;
		image_div.style.top=height;
		image_div.style.visibility='visible';
		image_div.innerHTML=data;
}
//reply msgs
function openReplyEmail(senderId,type,typeOfReply)
{
	if(document.getElementById('replyArea').innerHTML=='')
	{
		var content='';
		//alert(type);
		//alert(document.getElementById('listOfIds').value);
		content='<form name=replyEmail id=replyEmail method=post action=? enctype=multipart/form-data >';
		content+='<table border=0 align=center cellpadding=0 cellspascing=0>';
		if(typeOfReply==2)
			content+='<input type=hidden name=replyAllIds id=replyAllIds value="'+document.getElementById('listOfIds').value+'" />';
		else
			content+='<input type=hidden name=replyAllIds id=replyAllIds  value="'+senderId+'" />';
		content+='<input type=hidden name=sendMail id=sendMail value=1 />';
		content+='<input type=hidden name=typeUser id=typeUser value='+type+' />';
		content+='<input type=hidden name=senderId id=senderId value='+senderId+' />';
		content+='<input type=hidden name=replyNow id=replyNow value=1 />';
		content+='<tr><td class=normal_text>Title:</td><td><input type=text name=title id=title size=20 /></td></tr>';
		content+='<tr><td class=normal_text>File:</td><td><input type=file name=image id=image size=30 /></td></tr>';
		content+='<tr><td class=normal_text>Description:</td><td><textarea name=description id=description rows=25 cols=80 ></textarea></td></tr>';
		content+='<tr><td colspan=2><input type=submit name=send id=send value=send /></td></tr>';
		content+='</table >';
		content+='</form>';
		//alert(content);
		document.getElementById('replyArea').innerHTML=content;
		document.getElementById('replyWord').innerHTML='<a href=# onclick=openReplyEmail('+senderId+')>Close</a>';	

	}
	else
	{
		document.getElementById('replyArea').innerHTML='';
		document.getElementById('replyWord').innerHTML='<a href=# onclick=openReplyEmail('+senderId+')><img src=../images/replyCopy.png width=70  height=38 border=0 /></a>';

	}
}
function openPage(path)
{
	window.open("?"+path+"&typeRequested=1&apperance=1","Reports","width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}

//return day fro the date
function setTheFees(id,mt_id)
{
	
	if(mt_id==143)
	{
		globalFactor='0.13';
		
	}
	var value2=document.getElementById(id+'_distance').value;
	var v=(value2*globalFactor);
	document.getElementById(id+'_fees').value=v;
	
}
function openTransPage(data)
{
	window.open("index.php?printTrans=1&typeRequested=1&"+data,"Reports","width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
function printTransReport(data)
{
		//alert(data);
		window.open("index.php?printTrans=2&typeRequested=1&"+data,"Reports2","width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
function fillFees()
{
	document.getElementById('fees').value=document.getElementById('distance').value*0.11;
}
//open report page
function openReportPage(studId,userId)
{
	studId=studId*220;
	userId=userId*120;
	window.open("../student/?userViewReports=1&missingId="+studId+"&unmissingId="+userId,"Reports","width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
//creat user name sessions using js
function creatrNames(name1,name2)
{
	alert(name1);
	alert(name2);
	/*var nocache = Math.random();
	http.open('GET','index.php?page=groupUser&request=buildSessions&name1='+name1+'&name2='+name2+'&nocache='+nocache,true);
	http.onreadystatechange = updateDataResultSessions;
	http.send(null);*/
}
function updateDataResultSessions()
{
}

//convertind td to input text for acc editing
function convertTdToText(tdId,valueAmount,columnType,valueRed)
{
	document.getElementById(tdId).innerHTML='<input type=text name=updatingOnAcc id=updatingOnAcc value='+valueAmount+' size=6 /><a href=# onclick=ajaxRefresingFor('+tdId+','+columnType+','+valueRed+')>Ref</a>';
}

//updating value in db
function ajaxRefresingFor(id,columnType,valueRed)
{
	var newValue=document.getElementById('updatingOnAcc').value;
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=updatingAccValue&id='+id+'&newValue='+newValue+'&columnType='+columnType+'&nocache='+nocache,true);
	http.onreadystatechange = updateAccNewValue;
	http.send('');
}
function updateAccNewValue()
{
	window.location.reload();	/*var id=document.getElementById('studIdFoPayment').value;
	alert(' If The Change Not Take Effect Directly , just press F5	');
	window.location='index.php?xyzwfvd='+id;
	*/
}
//ajax serach for payment list
function getResultData(serachKy)
{
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=account_search&keyWords='+serachKy+'&nocache='+nocache,true);
	http.onreadystatechange = getResultDataFor;
	http.send('');
}
function getResultDataFor()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	
	}
}
//reports from list
function ajaxReportFromList()
{
	var nocache = Math.random();
	var mtId=document.getElementById("erspUserId").value;
	var reportFrom=document.getElementById("reportFrom").value;
	var reportTo=document.getElementById("reportTo").value;
	if(reportFrom!='' && reportTo!='' && mtId!='')
		http.open('GET','../user/index.php?typeRequested=1&erspUserId='+mtId+'&reportFrom='+reportFrom+'&reportTo='+reportTo+'&nocache='+nocache,true);
	else
	if(reportFrom!='' && reportTo!='')
		http.open('GET','../user/index.php?typeRequested=1&reportFrom='+reportFrom+'&reportTo='+reportTo+'&nocache='+nocache,true);
	else
	if(reportFrom!='' && mtId!='')
		http.open('GET','../user/index.php?typeRequested=1&erspUserId='+mtId+'&reportFrom='+reportFrom+'&nocache='+nocache,true);
	else
	if(reportFrom!='')
		http.open('GET','../user/index.php?typeRequested=1&reportFrom='+reportFrom+'&nocache='+nocache,true);
	else
	if(reportTo!='' && mtId!='')
		http.open('GET','../user/index.php?typeRequested=1&erspUserId='+mtId+'&reportTo='+reportTo+'&nocache='+nocache,true);
	else
	if(reportTo!='')
		http.open('GET','../user/index.php?typeRequested=1&reportTo='+reportTo+'&nocache='+nocache,true);
	else
	if(mtId!='')
		http.open('GET','../user/index.php?typeRequested=1&erspUserId='+mtId+'&nocache='+nocache,true);

	http.onreadystatechange = getReportForm;
	http.send('');
}
function getReportForm()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	
	}
}
//getting location list
function getLocationListforMt()
{
	var nocache = Math.random();
	var mtId=document.getElementById("report_for").value;
	http.open('GET','../user/index.php?typeRequested=1&locationForMtErsp=1&masterTrainerId='+mtId+'&nocache='+nocache,true);
	http.onreadystatechange = getReportFor;
	http.send('');
}
function getReportFor()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('locationList').innerHTML =response;
	
	}
}
//validate reprot
function validateReport()
{
	if(document.getElementById("report_for").value=='')
	{
		document.getElementById("report_for_validation").innerHTML='Please Select Your Master Trainer';
		document.getElementById("report_for").focus();
		return false;
	}
	if(document.getElementById("task_num").value=='')
	{
		document.getElementById("task_num_validation").innerHTML='Please Enter Your Task Number';
		document.getElementById("task_num").focus();
		return false;
	}
	if(document.getElementById("task_date").value=='')
	{
		document.getElementById("task_date_validation").innerHTML='Please Enter Your Date';
		document.getElementById("task_date").focus();
		document.getElementById("task_num_validation").innerHTML='';
		return false;
	}
	if(document.getElementById("start_hours").value=='-1')
	{
		document.getElementById("start_hours_validation").innerHTML='Please Enter Your Start Time';
		document.getElementById("start_hours").focus();
		return false;
	}
	if(document.getElementById("end_hours").value=='-1')
	{
		document.getElementById("end_hours_validation").innerHTML='Please Enter Your End Time';
		document.getElementById("end_hours").focus();
		return false;
	}
	
	/*if(document.getElementById("start_hours").value<=13 && document.getElementById("end_hours").value>13)
	{
		alert('Please Seperate Your Intries to Include Break Hours');
		return false;
	}*/
	//if(document.getElementById("end_hours").value>=14)
	//{
		if((document.getElementById("end_hours").value-document.getElementById("start_hours").value)>8 || (document.getElementById("end_hours").value-document.getElementById("start_hours").value)<0 )
		{
			alert('You Cant Enter More Than 8 Hours of Work / day , Please check Your Entry Very well');
			return false;
		}
	//}
	
	if(document.getElementById("end_hours").value==document.getElementById("start_hours").value)
	{
		alert('You Start And End At the same Time !!!!!!!!!!!!!');
		return false;
	}
	
	
	
}
//function for ersp user menu
function fillErspHiddenData(data)
{
	document.getElementById("erspHidden").innerHTML=data;
}
//print list of dlayed and withdraw students
function openPrintPage(type)
{
	if(type=="dlayed")
	window.open("index.php?type=26","StudentList","400,200,100,100","no","no");
	else
	window.open("index.php?type=27","StudentList","400,200,100,100","no","no");
}
//get the recipent list for users
function showRecipientMail()
{
	if(document.getElementById("showMailForWhome").innerHTML=="")
	{
		var listOfNames=document.getElementById("listOfNames").value;
		document.getElementById("showMailForWhome").innerHTML=listOfNames;
	}
	else
	{
		document.getElementById("showMailForWhome").innerHTML="";
	}
	
}
//verfication image for registration
function checkImageVer()
{
	if(document.getElementById("imageVr").value!=document.getElementById("imageVrCode").value)
	{
			alert("Image Code Dosen't Match Your Input");
			document.getElementById("imageVr").value='';
			document.getElementById("imageVr").focus();
			return false;
	}
}
//validate sending mail form 
function validateSendingMail()
{
	if(document.getElementById("selectTo").value=='')
	{
		document.getElementById("selectTo_validation").innerHTML="Please Select the recipient";
		document.getElementById("title_validation").innerHTML="";
		return false;
	}
	if(document.getElementById("title").value=='')
	{
		document.getElementById("title_validation").innerHTML="Please Insert Title";
		document.getElementById("selectTo_validation").innerHTML="";

		return false;
	}
	
}
//viwing description for jobs in hidden td
function strrepl(form)
{
	var data=form.reply_description.value;
	 data=data.replace("\"","\\\"") ;
	 alert(data);
	return false;
}
function viewJsHobDetails(countNumber,descData,postDate)
{
	document.getElementById("viewDesc"+countNumber).innerHTML='<table border=0>'+descData+'</table>';
	document.getElementById("viewPostDate"+countNumber).innerHTML='<table border=0>'+postDate+'</table>';
}
function checkAllList(id)
{
	var ob=document.getElementById("mtList");
	var countList=0;
	while (ob.length>countList)
  	 {
		ob.options[countList].selected = true;
		countList++;
   	}
}
function unCheckAllList(id)
{
	var ob=document.getElementById("mtList");
	var countList=0;
	while (ob.length>countList)
  	 {
		ob.options[countList].selected = false;
		countList++;
   	}
}
function enableDisableAllowPass()
{
	if(document.getElementById("changePass").checked==true)
	{
		document.getElementById("old_password").disabled=false;	
		document.getElementById("new_password").disabled=false;	
	}
	else
	{
		document.getElementById("old_password").disabled=true;	
		document.getElementById("new_password").disabled=true;	
		document.getElementById("old_password").value='';	
		document.getElementById("new_password").value='';	
	}
}
//check change password
function checkChangePassword(password)
{
	//alert(password);
	if(document.getElementById("old_password").value!=password)
	{
		alert('In Correct Old Password');
		document.getElementById("old_password").value='';	
		document.getElementById("new_password").value='';
		document.getElementById("old_password").focus();	
	}
}
function colorPick(inputValue)
{
		window.open('../colorPic.php?inputValue='+inputValue,"ColorPicker","width=100,height=260,top=100,left=250,scrollbars=yes,resizable=no");
}

function checkBlog()
{
	var name=document.getElementById("blog").value;
	
	if(name.indexOf(' ') > -1)
	{
		alert("No Space Allowd");
		document.getElementById("blog").value='';
		return false;
	}
	if(name.indexOf('?') > -1 || name.indexOf('/') > -1 || name.indexOf('"') > -1 || name.indexOf('\\') > -1 || name.indexOf("'") > -1)
	{
		alert("No Special Cahracters  Allowd");
		document.getElementById("blog").value='';
		return false;
	}
	
}

function setFontColor(inputValue,selectedValue)
{
	document.getElementById(inputValue).value='#'+selectedValue;
}
//validate adding from stud to articels books 
function validateGeneralForm(titleMsg,descMsg)
{
	if(document.getElementById("title").value=="")
	{
		document.getElementById("titleMsg").innerHTML=titleMsg;
		document.getElementById("title").focus();
		return false;
	}
	
	
}
//open menu links
function testing()
{
	//alert(1);
}
function openLink(links)
{
	//var secureIdValue=document.getElementById('randomValueToCheckURL').value;
	//alert(secureIdValue);
	window.location=links;
}
function overlink(id)
{
	var obj=document.getElementById(id);
	obj.style.background="d5d5d5";
}
function removestyle(id)
{
	var obj=document.getElementById(id);
	obj.style.background="fff59c";
}
//write status on db
function writeStatusOnDB(studentId)
{
	var nocache = Math.random();
	var statusValue=document.getElementById("statusList_"+studentId).value;
	http.open('GET','../user/index.php?typeRequested=1&statusValue='+statusValue+'&studentId='+studentId+'&updateStudentStatus=1&nocache='+nocache,true);
	http.onreadystatechange = updateStudStatus;
	http.send('');
	document.getElementById("msg_"+studentId).innerHTML='Updated';
}
function updateStudStatus()
{
}
function buildLoadingImage()
{
	var data="";
	data+="<table border=0 align=center cellpadding=0 cellspascing=0 bgcolor=#ffffff><tr><td ><img src=../images/loading_aqua.gif width=300 height=290 /></td>";
	data+="</table>";
	document.getElementById("image_div").innerHTML=data;
	document.getElementById('image_div').style.padding='300 100 400 400 px';
	document.getElementById('image_div').style.visibility='visible';
}
//build student list in the section 
function getStudentListonSection(courseIdView,listName)
{
	buildLoadingImage();
	if(listName==2)
	classTypeId=document.getElementById("classListMt0").value=-1;
	else
	if(listName==0)
	classTypeId=document.getElementById("classListMt2").value=-1;
	
	
	var classTypeId=document.getElementById("classListMt"+listName).value;
	var myId=courseIdView.split('_');
	var myIdValue=myId[0];
	var nocache = Math.random();
	http.open('GET','../evaluation/index.php?typeRequested=1&classTypeId='+classTypeId+'&courseIdView='+courseIdView+'&listName='+listName+'&nocache='+nocache,true);
	http.onreadystatechange = showStudentList;
	http.send('');
	//document.getElementById('allMarks').innerHTML ='<td class=normal_text id=section_mark_id><input type=submit name=section_mark id=section_mark value=Marks onclick=sectionMark(2) ></td>';
}

function showStudentList()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('studentList').innerHTML =response;
	emptyCells();
	}
}
function updateUniId(id,count)
{
	nocache = Math.random();
	var uniId=document.getElementById("uni_id"+count).value;
	http.open('GET','../user/index.php?typeRequested=1&uniId='+uniId+'&id='+id+'&updateUniId=1&nocache='+nocache,true);
	http.onreadystatechange = updateUniIds;
	http.send('');
}
function updateUniIds()
{
	
}

function destroySession()
{
	//logout after 1 mint
	//setTimeout("ajaxDestroySession()",1000);
	//setTimeout("ajaxDestroySession()",600000);
}
function destroySessionNow()
{
	//logout after 1 mint
		//setTimeout("ajaxDestroySession()",600000);
	//setTimeout("ajaxDestroySession()",6000);
	/*if (isBrowserClosed())
	{
		// browser closed
		// do your thing...
		window.opener=self;
		window.close();
	}*/

}
function ajaxDestroySession()
{	
	nocache = Math.random();
	http.open('GET','../index.php?typeRequested=1&logout=user&nocache='+nocache,true);
	http.onreadystatechange = logout;
	http.send('');
}
function logout()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML ='<div align=center>Sorry, You Need To reLogin to the System , Timeout!</div>';
	}
}
//changing the style testing
function changFontStyle(type)
{
	nocache = Math.random();
	if(type=="1")
	http.open('GET','index.php?typeRequested=1&Font=1&largeFont=1&nocache='+nocache,true);
	else
	if(type=="2")
	http.open('GET','index.php?typeRequested=1&Font=1&largeFont=-1&nocache='+nocache,true);
	else
	if(type=="3")
	http.open('GET','index.php?typeRequested=1&Font=2&largeFont=1&nocache='+nocache,true);
	else
	http.open('GET','index.php?typeRequested=1&Font=2&largeFont=-1&nocache='+nocache,true);
	http.onreadystatechange = changeCssData;
	http.send('');
}
function changeCssData()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('dummyData').innerHTML =response;

}
}
//ajax export excel files

function exportExcelFile(type)
{
	if(type=="1")
	var id=document.getElementById('campusClassId').value;
	else
	if(type=="2")
	var id=document.getElementById('onsiteClassId').value;

	id=22*id;
	window.location='?type=18&showPass=1&id='+id+'&style='+type;
}
//ajax return back
function returnBack(folderName,paramName,value,paramName2,value2,paramName3,value3,paramName4,value4)
{
	//alert(document.getElementById("pending_list").value);
	var path="../"+folderName+"/";
	nocache = Math.random();
	//alert(path+'index.php?typeRequested=1&'+paramName+'='+value);
	http.open('GET',path+'index.php?typeRequested=1&'+paramName+'='+value+'&'+paramName2+'='+value2+'&'+paramName3+'='+value3+'&'+paramName4+'='+value4+'&nocache='+nocache,true);
	http.onreadystatechange = returnBackResult;
	http.send('');
	//document.getElementById("main_data").innerHTML=document.getElementById("keyWords").value;
}
function returnBackResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
}
}
//opening help page
function openHelpPage()
{
	window.open("../help/help.php","Help","width=1003,height=1000,top=100,left=250,scrollbars=yes,resizable=no");
}
function chLang(type)
{
	var nocache = Math.random();
	http.open('GET','../index.php?chLang='+type+'&nocache='+nocache,true);
	http.onreadystatechange = chLangNumber;
	http.send('');
	window.location.reload();
}
function chLangNumber()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	//document.getElementById("main_data").innerHTML =response;
	
	}
}
function test(themeNumber)
{
	var nocache = Math.random();
	http.open('GET','../index.php?themeNumber='+themeNumber+'&nocache='+nocache,true);
	http.onreadystatechange = themeNumberSelected;
	http.send('');
	window.location.reload();
}
function themeNumberSelected()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	//document.getElementById("main_data").innerHTML =response;
	
	}
}
//check all checkbioxes in internal email
function checkAll(counter)
{
	if(document.getElementById("selectAllCheck").checked==true)
	{
		for(var i=0;i<counter;i++)
		{
			document.getElementById("checkMail_"+i).checked=true;
		}
	}
	else
	{
		for(var i=0;i<counter;i++)
		{
			document.getElementById("checkMail_"+i).checked=false;
		}
	}
}
//enable or disable one of the mt or mts
function enableDisableCheckBoxes()
{
	if(document.getElementById("mt").checked==true)
	{
		document.getElementById("mts").checked=false;
	}
	else
	if(document.getElementById("mts").checked==true)
	{
		document.getElementById("mt").checked=false;
	}
	
}
//buld send to list if to one or to more
function sendToList(list,list2,studList,emptyField,e)
{
	
	 
if(document.getElementById("selectTo").value=="1")
	{
		if(emptyField==1)
			document.getElementById("sendingToData").innerHTML='';
		var height='200';
		//document.getElementById("sendingToData").innerHTML=list2;
		//document.getElementById("sendingToData").innerHTML='';
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			//alert(screen.height-event.screenY);
			if(screen.height-event.screenY>380)
			{
				var x_pos=event.screenX+document.body.scrollLeft;
				var y_pos=event.screenY+document.body.scrollTop+200;
			}
			else
			{
				var x_pos=event.screenX+document.body.scrollLeft;
				var y_pos=event.screenY+document.body.scrollTop-100;
			}
		}
		else
		{
			if((screen.height-e.clientY)>410)
			{
				var x_pos=e.clientX+document.body.scrollLeft+300;
				var y_pos=e.clientY+document.body.scrollTop-20;
			}
			else
			{
				var x_pos='700';
				var y_pos=e.clientY+document.body.scrollTop-320;
			}
		}
		image_div.style.left=x_pos-40;
		image_div.style.top=height;
		image_div.style.visibility='visible';
		image_div.innerHTML=list2;
		document.getElementById("viewLink").style.visibility='visible';
		if(document.getElementById("mtIdsM").value!='')
		{
			var selectedIds=document.getElementById("mtIdsM").value.split(',');
			for(var i=0;i<selectedIds.length;i++)
			{
				if(selectedIds[i]!='')
				document.getElementById('user_'+selectedIds[i]).checked=true;
			}
		}
	}
	else
	if(document.getElementById("selectTo").value=="2")
	{
		
		document.getElementById("sendingToData").innerHTML=list;
		document.getElementById("viewLink").style.visibility='hidden';
		document.getElementById("image_div").style.visibility='hidden';
		document.getElementById("mtIdsM").value='';
	}
	else
	if(document.getElementById("selectTo").value=="3")
	{
		/*document.getElementById("sendingToData").innerHTML=studList;
		document.getElementById("viewLink").style.visibility='hidden';
		document.getElementById("image_div").style.visibility='hidden';*/
		document.getElementById("mtIdsM").value='';
		document.getElementById("sendingToData").innerHTML='';
		var height='300px';
		////document.getElementById("sendingToData").innerHTML=list2;
		document.getElementById("sendingToData").innerHTML='';
		document.getElementById("mtIdsM").value='';
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			//alert(screen.height-event.screenY);
			if(screen.height-event.screenY>380)
			{
				var x_pos=event.screenX+document.body.scrollLeft;
				var y_pos=event.screenY+document.body.scrollTop+200;
			}
			else
			{
				var x_pos=event.screenX+document.body.scrollLeft;
				var y_pos=event.screenY+document.body.scrollTop-100;
			}
		}
		else
		{
			if((screen.height-e.clientY)>410)
			{
				var x_pos=e.clientX+document.body.scrollLeft+300;
				var y_pos=e.clientY+document.body.scrollTop-20;
			}
			else
			{
				var x_pos='700';
				var y_pos=e.clientY+document.body.scrollTop-320;
			}
		}
		image_div.style.left=x_pos-40;
		image_div.style.top=height;
		image_div.style.visibility='visible';
		image_div.innerHTML=studList;
		document.getElementById("viewLink").style.visibility='visible';
		if(document.getElementById("mtIdsM").value!='')
		{
			var selectedIds=document.getElementById("mtIdsM").value.split(',');
			for(var i=0;i<selectedIds.length;i++)
			{
				if(selectedIds[i]!='')
				document.getElementById('student_'+selectedIds[i]).checked=true;
			}
		}

	}
}
//buld send to list if to one or to more
function sendToListStudent(list,list2,studList)
{
	if(document.getElementById("selectTo").value=="1")
	{
		document.getElementById("sendingToData").innerHTML=list2;
	}
	else
	if(document.getElementById("selectTo").value=="2")
	{
		document.getElementById("sendingToData").innerHTML=list;
	}
	else
	if(document.getElementById("selectTo").value=="3")
	{
		document.getElementById("sendingToData").innerHTML=studList;
	}

}

////select all hotmail list 
function selectAllHotmailList(id,names)
{
	if(document.getElementById('selectAllHotmailList').checked==true)
	{
		document.getElementById('changeSelectWord').innerHTML='<input type=checkbox name=selectAllHotmailList id=selectAllHotmailList onclick="unSelectAllHotmailList()">Select NON';
		var ids=id.split(',');
		var names=names.split(',');
		document.getElementById('mtIdsM').value=id;
		document.getElementById('sendingToData').innerHTML='';
		for(var i=0;i<(ids.length)-1;i++)
		{
			document.getElementById('user_'+ids[i]).checked=true;
			addToListHotMail(names[i],ids[i]);
		}
	}
}
function unSelectAllHotmailList()
{
	var id2=document.getElementById('mtIdsM').value;
	var id=document.getElementById('mtIdsM').value;
		document.getElementById('sendingToData').innerHTML='';
	var ids=id.split(',');
	document.getElementById('mtIdsM').value='';
	for(var i=0;i<(ids.length)-1;i++)
	{
		document.getElementById('user_'+ids[i]).checked=false;
		document.getElementById(ids[i]+'_span').innerHTML='';
	}
		//document.getElementById('selectAllHotmailList').checked=false;
		document.getElementById('image_div').innerHTML='';
}

//viwing hotmail list
var counter=1;
function addToListHotMail(addedName,userId)
{
	if(document.getElementById('mtIdsM').value!='')
	{
		var listedId=document.getElementById('mtIdsM').value;
		var values=listedId.split(',');
		var ar=Array();
		//alert(listedId);
		if(document.getElementById('user_'+userId).checked==true)
		{
			document.getElementById('mtIdsM').value+=userId+',';
			if((counter%8)==0)
			document.getElementById('sendingToData').innerHTML+='<br/><span id='+userId+'_span class=userListed width=10px>'+addedName+'</span>';
			else
			document.getElementById('sendingToData').innerHTML+='<span id='+userId+'_span class=userListed width=10px>'+addedName+'</span>';
			counter++;
		}
		else
		if(document.getElementById('user_'+userId).checked==false)
		{
			var selectedIds=document.getElementById("mtIdsM").value.split(',');
			document.getElementById('mtIdsM').value='';
			for(var i=0;i<selectedIds.length;i++)
			{
				if(selectedIds[i]!=userId)
				{
					document.getElementById('mtIdsM').value+=selectedIds[i]+',';
					//alert(selectedIds[i]);
				}
				else
				{
					document.getElementById(userId+'_span').style.visibility='hidden';
					document.getElementById(userId+'_span').style.hight='0px';
				}
			}
			counter--;
		}
		
	}
	else
	{
		document.getElementById('mtIdsM').value+=userId+',';
		document.getElementById('sendingToData').innerHTML+='<span id='+userId+'_span  class=userListed>'+addedName+'</span>';
	}
}
//viwing hotmail list
var counter=1;
function addToSingleListHotMail(addedName,userId)
{
	if(document.getElementById('mtIdsM').value!='')
	{
		var listedId=document.getElementById('mtIdsM').value;
		var values=listedId.split(',');
		var ar=Array();
		//alert(listedId);
		if(document.getElementById('user_'+userId).checked==true)
		{
			document.getElementById('mtIdsM').value+=userId+',';
			if((counter%8)==0)
			document.getElementById('sendingToData').innerHTML+='<br/><span id='+userId+'_span class=userListed width=10px>'+addedName+'</span>';
			else
			document.getElementById('sendingToData').innerHTML+='<span id='+userId+'_span class=userListed width=10px>'+addedName+'</span>';
			counter++;
		}
		else
		if(document.getElementById('user_'+userId).checked==false)
		{
			var selectedIds=document.getElementById("mtIdsM").value.split(',');
			document.getElementById('mtIdsM').value='';
			for(var i=0;i<selectedIds.length;i++)
			{
				if(selectedIds[i]!=userId)
				{
					document.getElementById('mtIdsM').value+=selectedIds[i]+',';
					//alert(selectedIds[i]);
				}
				else
				{
					document.getElementById(userId+'_span').style.visibility='hidden';
					document.getElementById(userId+'_span').style.hight='0px';
				}
			}
			counter--;
		}
		
	}
	else
	{
		document.getElementById('mtIdsM').value+=userId+',';
		document.getElementById('sendingToData').innerHTML+='<span id='+userId+'_span  class=userListed>'+addedName+'</span>';
	}
}

function show_image(e,object_id,image_name,width,height)
{
if (navigator.appName == "Microsoft Internet Explorer")
{
	if(screen.height-event.screenY>380)
	{
		var x_pos=event.screenX+document.body.scrollLeft;
		var y_pos=event.screenY+document.body.scrollTop-120;
	}
	else
	{
		var x_pos=event.screenX+document.body.scrollLeft;
		var y_pos=event.screenY+document.body.scrollTop-450;
	}
}
else
{
	//alert((screen.height-e.clientY));
	if((screen.height-e.clientY)>410)
	{
		var x_pos=e.clientX+document.body.scrollLeft;
		var y_pos=e.clientY+document.body.scrollTop-20;
	}
	else
	{
		var x_pos=e.clientX+document.body.scrollLeft;
		var y_pos=e.clientY+document.body.scrollTop-320;
	}
}
image_div.style.left=x_pos+10;
image_div.style.top=y_pos+10-height;
image_div.style.visibility='visible';
var data="";
data+="<table border=0 align=center cellpadding=0 width=387 cellspascing=0><tr height=9><td width=19  valign=bootom height=9><img src='../images/arr.png' width=19 height=9  /></td></tr></table>";
data+="<table border=0 align=center cellpadding=0 width=412 cellspascing=0 class=imageDiv><tr><td valign=top>&nbsp;</td></tr><tr height=20><td width=110  valign=top height=130 align=center><img src='"+image_name+"' width=100 height=125  /></td>";
data+="<td valign=top width=1 height=250  />&nbsp;</td><td valign=top  height=125>"+object_id+"</td></tr></table>";
image_div.innerHTML=data
}
function hide_image()
{
	if(image_div.innerHTML!='')
	{
		image_div.style.visibility='hidden';
		image_div.innerHTML="";
	}
}


function openMTImageandDescription(id,description)
{
	alert(id);
	alert(description);
}
function printPage()
{
	window.print();
	document.getElementById("payments").submit();
}
function printPageOnly()
{
	window.print();
}
function validatePayment()
{
	if(document.getElementById("program_value").value=='-1')
	{
		alert("Please Select Program");
		document.getElementById("program_value").focus();
		return false;
	}
	else
	if(document.getElementById("year_value").value=='-1')
	{
		alert("Please Select year");
		document.getElementById("year_value").focus();
		return false;
	}
	else
	if(document.getElementById("semester_value").value=='-1' || document.getElementById("semester_value").value=='')
	{
		alert("Please Select Semester");
		document.getElementById("semester_value").focus();
		return false;
	}
	else
	if(document.getElementById("amount").value=='')
	{
		alert("Is Not Nnmber");
		document.getElementById("amount").focus();
		return false;
	}
	else
	{
	paymentForm(document.getElementById("program_value").value,document.getElementById("semester_value").value,document.getElementById("amount").value,document.getElementById("studentId").value);

	}
	
}
function checkAmountField()
{
	if(isNaN(document.getElementById("amount").value))
	{
		alert("Is Not Nnmber");
		document.getElementById("amount").focus();
		return false;
	}
	
}
function paymentForm(programId,semesterId,amount,studentId)
{
window.open("../paymentForm.php?programId="+programId+"&semesterId="+semesterId+"&amount="+amount+"&studentId="+studentId,"details","width=400,height=1000,top=100,left=250,scrollbars=no,resizable=no");
return false;
}
function disableWindow(event)
{
	//var choice = window.event.keyCode-48;
	//alert(choice);
	if (event.shiftKey==1)
	{
	alert("The shift key was pressed!")
	}
	else
	{
	alert("The shift key was NOT pressed!")
	}
}
function openHiddenOldFeedBack(index,desc,mark,markLang,descLang,type,idFeedBack,numberOfTds,studTitle,studDesc,titlLang,descLang,hwID,fileName,mtId,path,pysicalPath)
{
	
	var data='';
	var downLoadPath='../downloadfiles.php/';
	for(var i=0;i<numberOfTds;i++)
	{
		document.getElementById("viwFeedBackData"+i).innerHTML='';
	}
	data='<form name=feedBackHw id=feedBackHw method=post action=?getFeedBack=1 enctype=multipart/form-data>';
	data+='<table border=0 align=center width=80% cellpadding=2 cellspascing=1>';
	data+='<input type=hidden name=viwe_homeWorksFeedBack_hidden id=viwe_homeWorksFeedBack_hidden value='+hwID+' />';
	data+='<input type=hidden name='+type+' id='+type+' />';
	data+='<tr><td class=normal_text align=right>'+titlLang+':</td><td>"'+studTitle+'"</td></tr>';
	data+='<tr><td class=normal_text align=right>'+descLang+':</td><td>"'+studDesc+'"</td></tr>';
	data+='<tr><td class=normal_text align=right>'+markLang+':</td><td><input type=text name=mark id=mark value='+mark+' size=3 /></td></tr>';
	if(fileName!='')
	{
		var path1=mtId*220;
		data+='<tr><td class=normal_text align=left colspan=2 style=padding-left:35px>Check For Deletion:<input type=checkbox name=deleteMtFile id=deleteMtFile value=1 ></td></tr>';
		data+='<tr><td class=normal_text align=right>File:</td><td><a href='+downLoadPath+'?folder1=3&path1='+path1+'&path='+path+'&fileName='+pysicalPath+'>'+fileName+'</td></tr>';
		data+='<tr><td class=normal_text align=center colspan=2><em><b>Uploading New File Will Replace The old One</b></em>,</td></tr>';
	}
	data+='<tr><td class=normal_text align=right>File:</td><td><input type=file name=uploadedFile id=uploadedFile size=30 ></td></tr>';
	data+='<tr><td class=normal_text align=right>'+descLang+':</td><td><textarea rows=15 cols=80 name="mtFeedback" id="mtFeedback" >'+desc+'</textarea></td></tr>';
	
	data+='<tr><td colspan=2 align=center><input type=button name=send value=send onclick="submitFormsWithId(\'feedBackHw\',\''+idFeedBack+'\',\''+type+'\');" /></td></tr>';
	
	data+='</table>';
	data+='</form>';
	document.getElementById("viwFeedBackData"+index).innerHTML=data;
}

function viewListOfFeatures(countNum)
{
		alert(document.getElementById("viewProgramClasses"+countNum).value);
}
//view campus and on site classes
function viewProgramClasses(countNum,data)
{
	document.getElementById("viewProgramClasses"+countNum).innerHTML=data;
}
//mt menu
function mtMenu(data)
{
	document.getElementById("mtMenu").innerHTML=data;
	document.getElementById("mtSuperGroups").innerHTML='';
}
//mt super groups list
function mtSuperGroups(data,id)
{
		//document.getElementById("mtPublicGroups").innerHTML=data;
		document.getElementById("mtSuperGroups").innerHTML=data;
	  	document.getElementById("mtMenu").innerHTML='';
}
//mt public groups list
function mtPublicGroups(data)
{
		document.getElementById("mtPublicGroups").innerHTML=data;
}
//function for serching using ajax
function ajaxSearch(folderName,table_name,typeRequested,anotherValues)
{
	//alert(keywo);
	//alert(document.getElementById("pending_list").value);
	var path="../"+folderName+"/";
	var table=table_name;
	var keyWord=document.getElementById('keyWords').value;
	nocache = Math.random();
	http.open('GET',path+'index.php?typeRequested='+typeRequested+'&keyWords='+keyWord+'&table_name='+table+'&anotherValues='+anotherValues+'&nocache='+nocache,true);
	http.onreadystatechange = serachResult;
	http.send('');
	//document.getElementById("main_data").innerHTML=document.getElementById("keyWords").value;
}
function serachResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
}
}
/*
//create dynamic ajax pages list
function ajaxPages(folderName,table_name,typeRequested,anotherValues,i,listOfView,type)
{
	if(anotherValues=='')
	anotherValues=document.getElementById('filtering_param').value;
	if(anotherValues=='1')
	anotherValues='';
	//alert(document.getElementById("pending_list").value);
	var path="../"+folderName+"/";
	var table=table_name;
	var keyWord=document.getElementById('keyWords').value;
	nocache = Math.random();
	http.open('GET',path+'index.php?typeRequested='+typeRequested+'&keyWords='+keyWord+'&table_name='+table+'&anotherValues='+anotherValues+'&listOfView='+listOfView+'&i='+i+'&type='+type+'&nocache='+nocache,true);
	http.onreadystatechange = pageingResult;
	http.send('');
	//document.getElementById("main_data").innerHTML=document.getElementById("keyWords").value;
}*/
//create dynamic ajax pages list
function ajaxPages(folderName,table_name,typeRequested,anotherValues,i,listOfView,type,otherValues)
{
	//alert(typeRequested);
	var data="";
	data+="<table border=0 align=center cellpadding=0 cellspascing=0 bgcolor=#ffffff><tr><td ><img src=../images/loading_aqua.gif width=300 height=290 /></td>";
	data+="</table>";
	document.getElementById("image_div").innerHTML=data;
	document.getElementById('image_div').style.padding='300 100 400 400 px';
	document.getElementById('image_div').style.visibility='visible';
	if(anotherValues=='')
	anotherValues=document.getElementById('filtering_param').value;
	if(anotherValues=='1')
	anotherValues='';
	//alert(document.getElementById("pending_list").value);
	var path="../"+folderName+"/";
	var table=table_name;
	var keyWord=document.getElementById('keyWords').value;
	nocache = Math.random();
	http.open('GET',path+'index.php?typeRequested='+typeRequested+'&keyWords='+keyWord+'&table_name='+table+'&anotherValues='+anotherValues+'&listOfView='+listOfView+'&i='+i+'&type='+type+'&otherValue='+otherValues+'&nocache='+nocache,true);

	http.onreadystatechange = pageingResult;
	http.send('');
	//document.getElementById("main_data").innerHTML=document.getElementById("keyWords").value;
}
function pageingResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	emptyCells();
}
}
//ajax downloading files
function downLoadFiles(UserId,folderName,fileName)
{
	var nocache = Math.random();
	http.open('GET','../downloadfiles.php?UserId='+UserId+'&folderName='+folderName+'&fileName='+fileName+'&nocache='+nocache,true);
	http.onreadystatechange = downloadingResult;
	http.send('');
}
function downloadingResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
}
}
//function for submit forms
function submitForms(name)
{
	document.getElementById(name).submit();
}
//function to check duplicate users
function checkDuplictaeUser(userNames,name)
{
	var users=userNames.split(",");
	for(var i=0;i<=(users.length)-1;i++)
	{
		if(document.getElementById(name).username.value==users[i])
		{
		 	document.getElementById("vaildation_user_name").innerHTML="Duplicated User Name";
			document.getElementById("username").value="";
			document.getElementById("username").focus();
			
		}
		else
		{
		 	document.getElementById("vaildation_user_name").innerHTML="";
		}
	}
}
//check editing on user name
function checkDuplictaeUserEdit(userNames,name)
{
	
	var users=userNames.split(",");
	for(var i=0;i<=(users.length)-1;i++)
	{
		if(document.getElementById(name).username.value==users[i])
		{
		 	document.getElementById("vaildation_user_name").innerHTML="Duplicated User Name";
			document.getElementById("username").value="";
			document.getElementById("username").focus();
			
		}
		else
		{
		 	document.getElementById("vaildation_user_name").innerHTML="";
		}
	}
}
//sorting by
function sortingBy(pageNumber)
{
	pageNumber=pageNumber;
	window.location='?&sort='+document.getElementById("sortBy").value+'&indexValue='+pageNumber;
}
//submiting form with hidden id
function submitFormsWithId(name,id,input_name)
{
	
		
	document.getElementById(input_name).value=id;
	document.getElementById(name).submit();
}

function submitFormsWithId2(n,sem_id,name)
{
	
		
	document.getElementById(name).value=sem_id;
	document.getElementById(n).submit();
}
//submiting form with hidden id
function submitDeleteFormsWithId(name,id,input_name)
{
	$msg=confirm("Are you sure ? .. ");
	if($msg==true)
	{
		document.getElementById(input_name).value=id;
		document.getElementById(name).submit();
	}
}
//empty field when focus on it
function emptyField(fieldName)
{
	document.getElementById(fieldName).value="";
}
//return check box values if its checked or not
function getCheckBoxValue(formName,checkBoxName,hiddenCheckBoxName)
{
	
	if(document.getElementById(checkBoxName).checked==true)
	{
		document.getElementById(hiddenCheckBoxName).value="1";
	}
	else
	if(document.getElementById(checkBoxName).checked==false)
	{
		document.getElementById(hiddenCheckBoxName).value="0";
	}
}
function buildCourseList(getType)
{
	var semester_id=document.getElementById("semester_value").value;
	var nocache = Math.random();
	http.open('GET','../general_system/index.php?semester_id_js='+semester_id+'&type='+getType+'&nocache='+nocache,true);
	http.onreadystatechange = courseSemester;
	http.send('');
}
//dispaly yaers for selected prograsm
function courseSemester()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("course_value_id").innerHTML =response;
	}
}
//get multiple dayes selection
function getMultipleDayesSelection()
{
	var ob=document.getElementById("dayList");
	var count=0;
	document.getElementById("daysIds").value='';
	while(ob.length>count)
	{
		if(ob.options[count].selected==true)
		{
			document.getElementById("daysIds").value+=ob.options[count].value+",";	
		}
		count++;
	}



}
//get selected Maseter trainer form multiple selection list
function masterTrainerMultipleSelection()
{
	var ob=document.getElementById("mtList");
	var countList=0;
	document.getElementById("masterTrainerIds").value='';
	while (ob.length>countList)
  	 {
		if(ob.options[countList].selected == true)
	   {
			document.getElementById("masterTrainerIds").value+=ob.options[countList].value+",";
	   }
		countList++;
   	}
//
}
//send email to
function sendEmailToMultipleSelection()
{
	var ob=document.getElementById("mt_id");
	var countList=0;
	document.getElementById("mtIdsM").value='';
	while (ob.length>countList)
  	 {
		if(ob.options[countList].selected == true)
	   {
			document.getElementById("mtIdsM").value+=ob.options[countList].value+",";
	   }
		countList++;
   	}
}
//build the list of selected master triner wehn editing on it
function editMasterTrainerList(calling)
{
	var id_value='';
	var id_value_split='';
	var id_value=document.getElementById("masterTrainerIds").value;
	var id_value_split=id_value.split(",");
	var option_value=document.getElementById("mtList");
	document.getElementById("masterTrainerIds").value='';
	var i;
	for(i=0;i<(option_value.length);i++)
	{
		for(j=0;j<id_value_split.length;j++)
		{
			if(document.getElementById("mtList").options[i].value==id_value_split[j])
			{
				document.getElementById("mtList").options[i].selected=true;
				document.getElementById("masterTrainerIds").value+=document.getElementById("mtList").options[i].value+",";
			}
		}
	}
	if(calling!='1')
	editDayList();

}
function editDayList()
{
	var id_value='';
	var id_value_split='';
	var id_value=document.getElementById("daysIds").value;
	var id_value_split=id_value.split(",");
	var option_value=document.getElementById("dayList");
	document.getElementById("daysIds").value='';
	var i;
	for(i=0;i<(option_value.length);i++)
	{
		for(j=0;j<id_value_split.length;j++)
		{
			if(document.getElementById("dayList").options[i].value==id_value_split[j])
			{
				document.getElementById("dayList").options[i].selected=true;
				document.getElementById("daysIds").value+=document.getElementById("dayList").options[i].value+",";
			}
		}
	}
}
//end mshareif areea----------------------------------------------------------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//ibrash Functons 


function bulidmarks()
{
	
	
	var sem_id=document.getElementById("mt_semester_value").value;
	
	var mt_id=document.getElementById("mt_value").value;
 
	var theme_id=document.getElementById("mt_theme_value").value;
	
	var year_id=document.getElementById("year_theme").value;
	//mshareif
	//var get_type=document.getElementById("typeFromUrl").value;
    nocache = Math.random();

//url='../studentInfo/index.php?sem2_id_js='+sem_id+'&mt2_id_js_semester='+mt_id+'&theme_id_js_semester='+theme_id+'&year_id_js_semester='+year_id+''
http.open('POST','../studentInfo/index.php?mohad=1&sem2_id_js='+sem_id+'&mt2_id_js_semester='+mt_id+'&theme_id_js_semester='+theme_id+'&year_id_js_semester='+year_id+'&nocache='+nocache);
	

	
}


function getMT(getSemester)
{
	var mt_id=document.getElementById("mt_value").value;
	nocache = Math.random();
	if(getSemester==5)
	{
		
		http.open('GET','../general_system/index.php?mt_id_js='+mt_id+'&buildSemester=5&nocache='+nocache,true);
		document.getElementById("year_value_id").innerHTML='--';
	}
	else
	{
		
		http.open('GET','../general_system/index.php?mt_id_js='+mt_id+'&nocache='+nocache,true);
		
	}
	http.onreadystatechange = mt_semester;
	http.send('');
}

function mt_semester()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("year_value_id").innerHTML =response;
	}
}
	function bulidListSemeser()
{
	var sem_id=document.getElementById("mt_semester_value").value;
	var mt_id=document.getElementById("mt_value").value;
	//mshareif
	var get_type=document.getElementById("typeFromUrl").value;
	nocache = Math.random();
	http.open('GET','../general_system/index.php?sem_id_js='+sem_id+'&mt_id_js_semester='+mt_id+'&type='+get_type+'&nocache='+nocache,true);
	
	http.onreadystatechange = selecttheme;
	http.send('');
}

function selecttheme()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("semester_value_id").innerHTML =response;
	}
}
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
/////////////////////
// msaeddd area-----------------------------------------------------------------------------------------------------------------------------------------------------
//jax function to get the program list
function getProgramYear(getSemester)
{
	var program_id=document.getElementById("program_value").value;
	nocache = Math.random();
	if(getSemester==1)
	{
		http.open('GET','../general_system/index.php?program_id_js='+program_id+'&buildSemester=1&nocache='+nocache,true);
		document.getElementById("semester_value_id").innerHTML='--';
	}
	else
	{
		
		http.open('GET','../general_system/index.php?program_id_js='+program_id+'&nocache='+nocache,true);
		
	}
	http.onreadystatechange = selectYear;
	http.send('');
}
//dispaly yaers for selected prograsm
function selectYear()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("year_value_id").innerHTML =response;
	}
}
//ajax calling for build semesters for year
function bulidSemesetList()
{
	var year_id=document.getElementById("year_value").value;
	var prog_id=document.getElementById("program_value").value;
	//mshareif
	var get_type=document.getElementById("typeFromUrl").value;
	nocache = Math.random();
	http.open('GET','../general_system/index.php?year_id_js='+year_id+'&program_id_js_semester='+prog_id+'&type='+get_type+'&nocache='+nocache,true);
	
	http.onreadystatechange = selectSemester;
	http.send('');
}
//ajax calling for build semesters for year
function selectSemester()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("semester_value_id").innerHTML =response;
	}
}
function noDeleteFunction(module,related)
{
	
	alert("Cant Delete This "+module+" Because Releated Other "+related+" ... ");
	return false;
}
function buildCampusList()
{
	
	var course_id=document.getElementById("course_value").value;
	
	var nocache = Math.random();
	http.open('GET','../general_system/index.php?course_id_js='+course_id+'&typeRequested=1&nocache='+nocache,true);
	http.onreadystatechange = viewSection;
	http.send('');
}

function viewSection()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("campus_value_id").innerHTML =response;
	buildOnsiteList();
}
}
function buildOnsiteList()
{
	var course_id=document.getElementById("course_value").value;
	var nocache = Math.random();
	http.open('GET','../general_system/index.php?course_id_js2='+course_id+'&nocache='+nocache,true);
	http.onreadystatechange = viewOnsite;
	http.send('');
	
}
function viewOnsite()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("onsite_value_id").innerHTML =response;
	}
}
function getSemesterYearValue(typeValue)
{
	var idSemester=document.getElementById("semester_value").value;
    var nocache = Math.random();
	http.open('GET','../general_system/index.php?SemesterID='+idSemester+'&type='+typeValue+'&nocache='+nocache,true);
	http.onreadystatechange = vieSemesterdate;
	http.send('');
}
function vieSemesterdate()
{
	
	if(http.readyState == 4){	
	var response = http.responseText;
	//document.getElementById("view_semester_year").value='';
	document.getElementById("view_semester_year").value =response.substr(280,40);
	
	}
}

// end msaeddd area------------------------------------------------------------------------------------------------------------------------------------------------------

//test areae\
function getProgramYearTo(getSemester)
{
	var program_id=document.getElementById("program_value").value;
	nocache = Math.random();
	if(getSemester==1)
	{
		http.open('GET','../general_system/index.php?program_id_js='+program_id+'&buildSemester=2&nocache='+nocache,true);
		document.getElementById("semester_value_id_to").innerHTML='--';
	}
	else
	{
		
		http.open('GET','../general_system/index.php?program_id_js='+program_id+'&nocache='+nocache,true);
		
	}
	http.onreadystatechange = selectYearTo;
	http.send('');
}
//dispaly yaers for selected prograsm
function selectYearTo()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("year_value_id_to").innerHTML =response;
	}
}
function bulidSemesetListTo()
{
	
	var year_id=document.getElementById("year_value").value;
	var prog_id=document.getElementById("program_value").value;
	//mshareif
	var get_type=document.getElementById("typeFromUrl").value;
	nocache = Math.random();
	http.open('GET','../general_system/index.php?year_id_js_to='+year_id+'&program_id_js_semester='+prog_id+'&type='+get_type+'&nocache='+nocache,true);
	
	http.onreadystatechange = selectSemesterTo;
	http.send('');
}
//ajax calling for build semesters for year
function selectSemesterTo()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("semester_value_id_to").innerHTML =response;
	}
}
function buildCourseListTo(getType)
{
	var semester_id=document.getElementById("semester_value_to").value;
	var nocache = Math.random();
	http.open('GET','../general_system/index.php?semester_id_js_to='+semester_id+'&type='+getType+'&nocache='+nocache,true);
	http.onreadystatechange = courseSemesterTo;
	http.send('');
}
//dispaly yaers for selected prograsm
function courseSemesterTo()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("course_value_id_to").innerHTML =response;
	}
}
function buildSectionList(getType)
{
	var section_id=document.getElementById("course_value_to").value;
	var nocache = Math.random();
	http.open('GET','../general_system/index.php?section_id_js_to='+section_id+'&type='+getType+'&nocache='+nocache,true);
	http.onreadystatechange = courseSectionTo;
	http.send('');
}
function courseSectionTo()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("section_value_id_to").innerHTML =response;
	}
}
function buildSectionListvalue(getType)
{
	var section_id=document.getElementById("course_value").value;
	var nocache = Math.random();
	http.open('GET','../general_system/index.php?section_id_js='+section_id+'&type='+getType+'&nocache='+nocache,true);
	http.onreadystatechange = courseSectionListvalueTo;
	http.send('');
}
function courseSectionListvalueTo()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(document.getElementById("year_value").value);
	document.getElementById("section_value_id").innerHTML =response;
	}
}
// view form on the syestem
function viewForum(countNum,data)
{
	var count=0;
	while(count<countNum)
	{
		document.getElementById("viewForum"+countNum).innerHTML=data;
		count++;
	}
}
// open forum page
function submitForumFormsWithId(id)
{
	var id_value="cader_"+id*2222222;	
    window.open("../forum/?id_value="+id_value);

}
// view form on the syestem
function viewForum2(countNum,data)
{
	
	var count=0;
	while(count<countNum)
	{
		document.getElementById("viewForum2"+countNum).innerHTML=data;
		count++;
	}
}
function openStaticMenu(data)
{
	document.getElementById("reportData").innerHTML=data;
}
function getCategoriesId()
{
	var ob=document.getElementById("categories_value");
	var countList=0;
	document.getElementById("CategoriesId").value='';
	while (ob.length>countList)
  	 {
		if(ob.options[countList].selected == true)
	   {
			document.getElementById("CategoriesId").value+=ob.options[countList].value+",";
	   }
		countList++;
   	}
}
///shareif
var counter=1;
function addStudentListHotMail(addedName,userId)
{
	if(document.getElementById('mtIdsM').value!='')
	{
		var listedId=document.getElementById('mtIdsM').value;
		var values=listedId.split(',');
		var ar=Array();
		if(document.getElementById('student_'+userId).checked==true)
		{
			document.getElementById('mtIdsM').value+=userId+',';
			if((counter%4)==0)
			document.getElementById('sendingToData').innerHTML+='<br/><span id='+userId+'_span class=userListed width=10px>'+addedName+'</span>';
			else
			document.getElementById('sendingToData').innerHTML+='<span id='+userId+'_span class=userListed width=10px>'+addedName+'</span>';
			counter++;
		}
		else
		if(document.getElementById('student_'+userId).checked==false)
		{
			var selectedIds=document.getElementById("mtIdsM").value.split(',');
			document.getElementById('mtIdsM').value='';
			for(var i=0;i<selectedIds.length;i++)
			{
				if(selectedIds[i]!=userId)
				{
					document.getElementById('mtIdsM').value+=selectedIds[i]+',';
				}
				else
				document.getElementById(userId+'_span').innerHTML='';
			}
			counter--;
		}
		
	}
	else
	{
		document.getElementById('mtIdsM').value+=userId+',';
		document.getElementById('sendingToData').innerHTML+='<span id='+userId+'_span  class=userListed>'+addedName+'</span>';
	}
}
//---------- mohammad alsayyed ---------------------
function viewSystemReport()
{
	document.getElementById("viewResultReportStudentValue").innerHTML ="";
	var nocache = Math.random();
	if(document.getElementById("mtListNotMultiple").value!=0 )
	{
	document.getElementById("stedentName").value="";
	var MT_id=document.getElementById("mtListNotMultiple").value;
	document.getElementById("mtId").value=MT_id;
	http.open('GET','../user/index.php?type=34&resultSystemReport=yes&typeRequested=1&id='+MT_id+'&nocache='+nocache,true);
	http.onreadystatechange = systemReportViewResult;
	http.send('');
	}
	else
	if(document.getElementById("mtListNotMultiple").value==0 && document.getElementById("stedentName").value!=null)
	{
	
	var studentName=document.getElementById("stedentName").value;
	http.open('GET','../user/index.php?type=34&resultSystemReport=yesStudent&typeRequested=1&studentNameValue='+studentName+'&nocache='+nocache,true);
	http.onreadystatechange = systemReportViewResult;
	http.send('');
	}
}
function systemReportViewResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(response);
	document.getElementById("viewResultReport").innerHTML =response;
	}
}
function getResultStudent(id)
{
	//alert(id);
	document.getElementById("viewResultReport").innerHTML="";
	var nocache = Math.random();
	
	http.open('GET','../user/index.php?type=35&resultSystemReport=yesStudent&typeRequested=1&id='+id+'&nocache='+nocache,true);
	http.onreadystatechange = systemReportViewResultStudent;
	http.send('');
}
function systemReportViewResultStudent()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(response);
	document.getElementById("viewResultReportStudentValue").innerHTML =response;
	}
}
function addFileViewForm(fileLang)
{
	
	num=document.getElementById("numFile").value;
	
	if(num>4)
	{
			document.getElementById("dateID").innerHTML='';
			document.getElementById("titleID").innerHTML='';
			document.getElementById("areaID").innerHTML='';
			document.getElementById("descriptionID").innerHTML='';
			document.getElementById("fileID").innerHTML='Max Upload File is 4';
			document.getElementById("fileViewID").innerHTML='';
	}
	else
	if(num=="")
	{
			document.getElementById("dateID").innerHTML='';
			document.getElementById("titleID").innerHTML='';
			document.getElementById("areaID").innerHTML='';
			document.getElementById("descriptionID").innerHTML='';
			document.getElementById("fileID").innerHTML='Please Enter Num File';
			document.getElementById("fileViewID").innerHTML='';
	}
	else
	{
		
		var fileForm='<table border=0>';
		for(i=0;i<num;i++)
		{
		countFile=i+1;
		fileForm+='<tr><td class=title_text>'+fileLang+'('+countFile+')<input type=text name=fileName'+i+' id=fileName'+i+'> </td>';
		fileForm+='<td><input type=file name=fileValue'+i+' id=fileValue'+i+'> </td></tr>';
		}
		fileForm+='</table>';
		document.getElementById("fileViewID").innerHTML=fileForm;
	}
	
}
// HED Leaders
function studentInHEDLeaders(studentId,td)
{

	if(document.getElementById("hedLeaderStudent").checked==true)
	{
	hedLeaderStudentValue='2';
	}
	else
	{
	hedLeaderStudentValue='0';
	}
	buildLoadingImageTdNew(td);
	var nocache = Math.random();
	
	http.open('GET','../general_system/index.php?type=11&typeRequested=1&updateStudentStatus=1&hedLeaderStudent='+hedLeaderStudentValue+'&studentId='+studentId+'&nocache='+nocache,true);
	
	http.onreadystatechange = studentInHEDLeadersView;
	http.send('');
}
function studentInHEDLeadersView()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	
	//alert(response);
	document.getElementById("okHEDLeader").innerHTML =response;
	}
}
function buildLoadingImageTdNew(td)
{
	var data="";
	data+="<img src=../images/littleloaderiw6.gif width=16 height=16 />";
	document.getElementById(td).innerHTML=data;
	document.getElementById(td).style.padding='0 px';
	document.getElementById(td).style.visibility='visible';
}
// ebd HED Leader 
// check user evaluation
var secureIDPassValueDem='';
function checkEvalutionData(secureIDPassValue)
{
   var nocache = Math.random();
   secureIDPassValueDem=secureIDPassValue;
   if(secureIDPassValue=='')
   alert(1111);
   
   	http.open('GET','../evaluation/checkUserEvaluation.php?secureIDPassValue='+secureIDPassValue+'&nocache='+nocache,true);
	
	http.onreadystatechange = checkEvalutionDataRun;
	http.send('');

	
}

function checkEvalutionDataRun()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	if(response=='allowAccess')
	window.location='../evaluation/?secureIDPassValue='+secureIDPassValueDem;
	else
	alert(response);
	
	//document.getElementById("okHEDLeader").innerHTML =response;
	}
}


//---------- end mohammad alsayyed -----------------

function mt_avg_mark_leader(theme,asd)
{
	/*alert (smax);
	alert (smin);
	alert (savg);
	alert (maxid);
	alert (minid);*/


	window.open('../chart_leader/index.php?typeRequested=2&themeid='+theme+'&sem='+asd,'Window',"width=800,height=600,top=10,left=250,scrollbars=yes,resizable=no");
	
}

function mt_avg_mark(themeval,userids)
{
	/*alert (smax);
	alert (smin);
	alert (savg);
	alert (maxid);
	alert (minid);*/


	window.open('../chart/index.php?typeRequested=2&themeid='+themeval+'&sem='+userids,'Window',"width=800,height=600,top=10,left=250,scrollbars=yes,resizable=no");
	
}
