// JavaScript Document
function show_subjects(course_id)
{
	if(course_id>0)
	{
		document.getElementById("course_id").value=course_id;
		document.frm.method="post";
		document.frm.action="subjectmain.php";
		document.frm.submit();
	}
}
function show_modules(subject_id)
{
	if(subject_id>0)
	{
		document.getElementById("subject_id").value=subject_id;
		document.frm.method="post";
		document.frm.action="modules.php";
		document.frm.submit();
	}
}

function show_module_details(module_id)
{
	if(module_id>0)
	{
		document.getElementById("module_id").value=module_id;
		document.frm.method="post";
		document.frm.action="modules_name.php";
		document.frm.submit();
	}
}
function show_notes()
{
		document.frm.method="post";
		document.frm.action="notes.php";
		document.frm.submit();
}
function filter_blog_categories()
{
	var search_keyword=document.frm.search_keyword.value;	
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{			
			document.getElementById("category_list").innerHTML=xmlhttp.responseText;			
		}
	}
	xmlhttp.open("get","blog_category_search_ajax.php?search_keyword="+search_keyword,true);
	xmlhttp.send(null);	
}

function blog_post_vote(gid,pid)
{
var mail=document.getElementById("email").value;
var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			//alert(xmlhttp.responseText);
			if(xmlhttp.responseText>0)
			{
			alert("you already voted");
			window.parent.Shadowbox.close()		
			
			}
			else
			{
			//window.parent.Shadowbox.close()	
			vote_blog_new(pid,mail);
			}
			//document.getElementById("category_list").innerHTML=xmlhttp.responseText;			
		}
	}  
	xmlhttp.open("get","blog_vote_ajax_new.php?pid="+pid+"&mail="+mail,true);
	xmlhttp.send(null);	


}
function vote_blog(blog_post_id)
{

//window.open("bm_blog_comment_add.php");
vote_blog_new(blog_post_id);

}
function vote_blog_new(blog_post_id,mail)
{	


	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			window.parent.Shadowbox.close()	
			//alert(xmlhttp.responseText);
			//document.getElementById("vote_count"+blog_post_id).innerHTML=xmlhttp.responseText;			
		}
	}
	//xmlhttp.open("get","blog_vote_ajax_new.php?pid="+pid+"&mail="+mail,true);
	xmlhttp.open("get","blog_vote_ajax.php?blog_post_id="+blog_post_id+"&mail="+mail,true);
	xmlhttp.send(null);	
}
function login()
{	
	if(document.frm.username.value=="")
	{
		alert("Please enter username");
		document.frm.username.focus();		
	}
	else if(document.frm.password.value=="")
	{
		alert("Please enter password");
		document.frm.password.focus();
		return false;
	}
	else
	{
		document.frm.method="post";
		document.frm.action="login_controller.php?action=login";
		document.frm.submit();
	}
}
function call_login(e)
{
	var keynum;
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		if(window.event) // IE
		{	
			keynum = e.keyCode;				
		}
	}
	if(navigator.appName=="Netscape")
	{	
		if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}
	}
	if(keynum==13)
	{
		login();
		return false;
	}
}
function show_notes_full(none_div,block_div)
{	
	document.getElementById(none_div).style.display="none";
	document.getElementById(block_div).style.display="block";	
}

function get_polls_index(id,result)
{
	
	var length=document.frm.ans.length;
	var k=0;
	for (var i=0; i<length; i++)
	{
		
	if (document.frm.ans[i].checked == true)
	{
		
		result=document.frm.ans[i].value;
		k=1;
	//alert(result);
	}
	
	}
	if(k==0)
	{
	alert("Please select at least one");
	}
	else
	{
	get_polls_ajax(id,result);	
	}
}
function get_polls_ajax(id,result)
{
//document.getElementById('content').innerHTML="<img align='center' src='images/loading_wh.gif'  alt=''/>";
var xmlhttp;

try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{	
		//get_view_poll1(id);
			document.getElementById("polls").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("get","polls.php?id="+id+"&result="+result,true);
	xmlhttp.send(null);	
	
}
function get_course_ajax(id)
{
	//document.getElementById('content').innerHTML="<img align='center' src='images/loading_wh.gif'  alt=''/>";
var accountsearch=document.getElementById('accountsearch').value;
var xmlhttp;
try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{	
		document.getElementById("account").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("get","accounts_item.php?course_id="+id+"&account="+accountsearch,true);
	xmlhttp.send(null);	
	
}
function get_view_index(id)
{
//document.getElementById('content').innerHTML="<img align='center' src='images/loading_wh.gif'  alt=''/>";
var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			
			temp=document.getElementById('polls').innerHTML;
			
			document.getElementById('polls').innerHTML=xmlhttp.responseText;
			//document.getElementById('c').style.display="none";
		}
	}
	xmlhttp.open("get","view_result.php?id="+id,true);
	xmlhttp.send(null);	
}

function show_ind(id)
{
	document.getElementById('polls').innerHTML=temp;
	
}
function add_project()
{
	if(document.frm.subject_id.value=="0")
	{
		alert("Please select Subject");
		document.frm.subject_id.focus();
		return false;
	}
	else if(document.frm.module_id.value=="0")
	{
		alert("Please select Module");
		document.frm.module_id.focus();
		return false;
	}
	else if(document.frm.name.value=="")
	{
		alert("Please enter project name");
		document.frm.name.focus();
		return false;
	}	
	else if(document.frm.due_date.value=="")
	{
		alert("Please enter due date");
		document.frm.due_date.focus();
		return false;
	}				
	else
	{
		var mcount=document.frm.member_count.value;
		var mids="";
		for(var i=1;i<=mcount;i++)
		{
			if(document.getElementById("member"+i).checked)
			{
				mids+=(mids!="")?",":"";
				mids+=document.getElementById("member"+i).value;
			}
		}	
		document.frm.method="post";
		document.frm.action="project_admin.php?action=add"+"&mids="+mids;
		document.frm.submit();
	}
}
function list_project_modules_ajax(campus_id,department_id,course_id)
{
	var campus_id=campus_id;
	var department_id=department_id;	
	var course_id=course_id;
	var subject_id=document.frm.subject_id.value;	
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{			
			document.getElementById("module_list").innerHTML=xmlhttp.responseText;					
		}
	}
	xmlhttp.open("get","admin/templates/mm_module_list_ajax.php?campus_id="+campus_id+"&department_id="+department_id+"&course_id="+course_id+"&subject_id="+subject_id,true);
	xmlhttp.send(null);	
}
function blog_post_add(pid)
{	
	
   if(document.frm.name.value=="")
	{
		alert("Please enter your Name.");
		document.frm.name.focus();
		return false;
	}	
	else if(document.frm.email.value=="")
	{
		alert("Please type your email address.");
		document.frm.email.focus();
		return false;
	}	
	else if(document.frm.title.value=="")
	{
		alert("Please type your title.");
		document.frm.title.focus();
		return false;
	}	
	//else if(document.frm.message.value=="")
//	{
//		alert("Please type your message.");
//		document.frm.message.focus();
//		return false;
//	}	
	else
	{
		document.frm.method="post";
		document.frm.action="admin/controller/bm_blog_post_controller.php?action=front_add&id"+pid;
		document.frm.submit();		
	}
}
function blog_abuse_add(group_id,post_id)
{	
   
	if(document.frm.offensive_type.value=="0")
	{
			alert("Please select offensive type.");
			document.frm.offensive_type.focus();
			return false;
	}
	else if(document.frm.email.value=="")
	{
		alert("Please type your email address.");
		document.frm.email.focus();
		return false;
	}	
	else
	{
		    document.frm.method="post";
			document.frm.action="admin/controller/bm_blog_abuse_controller.php?action=front_add&group_id="+group_id+"&post_id="+post_id;
			document.frm.submit();		
	}
	
}
function blog_comment_add(group_id,post_id)
{   
     if(document.frm.name.value=="")
	{
			alert("Please enter your Name.");
			document.frm.name.focus();
			return false;
	}	
   else if(document.frm.email.value=="")
	{
			alert("Please type your email address.");
			document.frm.email.focus();
			return false;
	}	
	/*else if(document.frm.message.value=="")
	{
			alert("Please type your comments.");
			document.frm.message.focus();
			return false;
	}*/	
	else
	{
		   document.frm.method="post";
		   document.frm.action="admin/controller/bm_blog_comment_controller.php?action=front_add&group_id="+group_id+"&post_id="+post_id;
		  document.frm.submit();		
	}
}

function get_event(month,year)
{
	

	
	
//get_leftmenu(76);
//document.getElementById('content').innerHTML="<img align='center' src='images/loading_wh.gif'  alt=''/>";
str=month+","+year;
var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			//document.getElementById('rightmenu').style.display="block";
			document.getElementById('content').innerHTML=xmlhttp.responseText;						
		}
	}
	xmlhttp.open("get","eventcalendar.php?str="+str,true);
	xmlhttp.send(null);	
}

function callprev(m,y)
{
  document.frm1.method="Post";
  document.frm1.action="calender.php?month="+m+"&amp;year="+y;
  document.frm1.submit();
}
function event_disp()
{
document.getElementById('txtevent').style.display="Block";
}
function callfun(mon,curr_year)
{	
	get_event(mon,curr_year);    
}
function call_today(id)
{
	document.frm1.method="Post";
	document.frm1.action="calender.php?today="+id;
	document.frm1.submit();
}
function showevt(a)
{
showcalender(a);
}
function callnext(yr)
{
document.frm1.method="Post";
document.frm1.action="calender.php?next="+yr;
document.frm1.submit();
}
function curr_mon(mon,y)
{
document.frm1.method="Post";
document.frm1.action="calender.php?month="+mon+"&amp;year="+y;
document.frm1.submit();
}
function get_calendar(cid)
{
document.frm1.method="Post";
document.frm1.action="news_event.php?str="+cid;
document.frm1.submit();
}
function callover(ebutton)
{
	ebutton.style.background='#D5D3C7';
}

function callout(ebutton)
{
	ebutton.style.background='#FFFFFF';
}

function searchpage()
{
	var text=document.getElementById('s_txt').value;
	if(document.searchForm.s_txt.value=="Search")
	{
		alert("Please enter your search keyword");
		document.searchForm.s_txt.focus();
	}
	else if(document.searchForm.s_txt.value=="")
	{
		alert("Please enter your search keyword");
		document.searchForm.s_txt.focus();
	}
	else{
		
	document.searchForm.method="post";
	document.searchForm.action="search.php?s_txt="+text;
	document.searchForm.submit();
		
	}
}

function edit_profile()
{
  if(document.frm.firstname.value=="")
  {
	alert("Please enter first name");
	document.frm.firstname.focus();
	return false;
 }
 else if(document.frm.password.value=="")
{
alert("Please enter password");
						document.frm.password.focus();
						return false;
				}
				else if(document.frm.password.value!=document.frm.cpassword.value)
				{
					alert("Password and confirm password are mismatch");
					document.frm.cpassword.value="";
					document.frm.cpassword.focus();
					return false;					
				}
				else
				{
					document.frm.method="post";
					document.frm.action="admin/controller/um_user_controller.php?action=front_edit";
					document.frm.submit();		
				}
}



function call_login(e)
{
	var keynum;
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		if(window.event) // IE
		{	
			keynum = e.keyCode;				
		}
	}
	if(navigator.appName=="Netscape")
	{	
		if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}
	}
	if(keynum==13)
	{
		searchpage();
		return false;
	}
}
function printDiv(dname)
{  
  var divToPrint=document.getElementById(dname);
  var newWin=window.open('','Print-Window','width=500,height=500');
  newWin.document.open();
  newWin.document.write('<html><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
  newWin.document.close();
  setTimeout(function(){newWin.close();},10);
}
function filter_member_by_alphabet(course_id,project_id,search_char)
{	
	document.getElementById("student_list").innerHTML="Loading...";
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{			
			document.getElementById("student_list").innerHTML=xmlhttp.responseText;			
		}
	}
	xmlhttp.open("get","admin/templates/member_filter_ajax.php?course_id="+course_id+"&project_id="+project_id+"&search_char="+search_char,true);
	xmlhttp.send(null);	
}
function get_faq_ajax(id)
{
	//document.getElementById('content').innerHTML="<img align='center' src='images/loading_wh.gif'  alt=''/>";
var faqsearch=document.getElementById('faqsearch').value;
var xmlhttp;
try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{	
		document.getElementById("faq").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("get","display_faq_question.php?faq_cat="+id+"&faqsearch="+faqsearch,true);
	xmlhttp.send(null);	
	
}
function assignment_submission()
{	
	if(document.frm.assignment_file.value=="")
	{
		alert("Please select assignment submitted file");
		document.frm.assignment_file.focus();
		return false;
	}					
	else
	{
		document.frm.method="post";
		document.frm.action="admin/controller/am_assignment_answer_controller.php?action=submit_by_student";
		document.frm.submit();		
	}	
}
function project_comment_manipulation(operation,project_id)
{ 
  switch(operation)
  {
		case 'front_add':
			if(document.frm.title.value=="")
			{
				alert("Please enter title.");
				document.frm.title.focus();
				return false;
			}	
			else if(document.frm.comment.value=="")
			{
				alert("Please enter comment.");
				document.frm.comment.focus();
				return false;
			}	
			else
			{
				document.frm.method="post";
				document.frm.action="admin/controller/pm_project_comments_controller.php?action="+operation+"&project_id="+project_id;
				document.frm.submit();		
			}	
			break;
  }
}
function filter_campus_staff()
{
	var search_keyword=document.frm.search_keyword.value;	
	//alert("search_keyword==>>"+search_keyword);
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{			
			document.getElementById("staff_list").innerHTML=xmlhttp.responseText;			
		}
	}
	xmlhttp.open("get","campus_staff_search_ajax.php?search_keyword="+search_keyword,true);
	xmlhttp.send(null);	
}
function filter_campus_mates()
{
	var search_keyword=document.frm.search_keyword.value;	
	//alert("search_keyword==>>"+search_keyword);
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{			
			document.getElementById("mates_list").innerHTML=xmlhttp.responseText;			
		}
	}
	xmlhttp.open("get","campus_mates_search_ajax.php?search_keyword="+search_keyword,true);
	xmlhttp.send(null);	
}



function current_time_display()
{
	
	//alert("okkkkk");
	//var search_keyword=document.frm.search_keyword.value;	
	//alert("search_keyword==>>"+search_keyword);
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{	
		   // alert(xmlhttp.responseText);
			//document.getElementById("contentArea").innerHTML=xmlhttp.responseText;			
		}
	}
	xmlhttp.open("get","time.php");
	xmlhttp.send(null);	
	setTimeout('current_time_display()', 1000);
}





function filter_campus_alumini()
{
	var search_keyword=document.frm.search_keyword.value;	
	//alert("search_keyword==>>"+search_keyword);
	var xmlhttp;
	try
	{
		//Firebox,Opera,safari
		xmlhttp= new XMLHttpRequest();
	}
	catch(e)
	{
		//IE
		try
		{
		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your Browser Does Not Support Ajax");
				return false;			
			}
		}
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{			
			document.getElementById("alumini_list").innerHTML=xmlhttp.responseText;			
		}
	}
	xmlhttp.open("get","campus_alumini_search_ajax.php?search_keyword="+search_keyword,true);
	xmlhttp.send(null);	
}
