﻿ 
 /*Implementing Modal popups to login box, forget password box and password confirmation box*/
 /*...........Start..................*/
 
$(document).ready(function(){
	 $('#login_box').jqm({modal: true,trigger: 'area.jqModal_login'});
	 
	 $('#forget_password').jqm({modal:true,trigger:'a.jqModal_forget_password'});
	  $('#password_confirmation').jqm({modal:true,trigger:'a.jqModal_password_confirmation'});
	  
	  
	
 });
 
  /*...........End..................*/
 
 /*Forget Forget Password Confirmation Box Close scripts */
 /*...........Start..................*/
 
 function close_all()
 {
 $('#password_confirmation').jqmHide(); 
 $('#forget_password').jqmHide(); 
 $('#login_box').jqmHide(); 
 
 }
 
  /*...........End..................*/
 
 
 
 /*Forget Password Login Box scripts */
 /*...........Start..................*/
 
function forgetpassword()
{

var studentid = $("input#txtforgetpass_userid").val();

if(studentid == ""|| studentid == " " || studentid == null)
{
alert("Please enter valid email address");
return false;


}


var url = "ForgotYourPassword.aspx?emailid="+studentid;

AjaxRequest.get(

  {
  	'url':url
    ,'onLoading':function() {$("div#forgetpassword_message").html("<img src='images/loader.gif' />&nbsp;Please Wait..."); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		
	var response = req.responseText;
	 var stat = response.split(",");
	 	
	if(stat[0] == "ok")
	{
	
	$("div#forgetpassword_message").html(" ");
	 $('#password_confirmation').jqmShow(); 
	 $("div#pass_userid").html("Dear "+stat[1]+",");
	
	}
	else
	
	{
	$("div#forgetpassword_message").html(req.responseText); 
	}
	
	
    }
	,'onError':function(req){
	$("div#forgetpassword_message").html(req.responseText); 

	}
  }
);


}
 /*...........End..................*/
 
 
 
 /*Forget  Login Box scripts */
 /*...........Start..................*/

function verifylogin()
{
var userid = $("input#txtuserid").val();
var pass = $("input#txtpassword").val();

if(userid == "" || userid == " " || userid == null)
{
alert('Please enter e-mail id ');
return false;
}

if(pass == "" || pass == " " || pass == null)
{
alert('Please enter your password ');
return false;
}


var url = "verifystudentlogin.aspx?userid="+userid+"&pass="+pass+"&remember="+document.getElementById('chkrememberpass').checked;

AjaxRequest.get(

  {
  	'url':url
    ,'onLoading':function() {$("div#verify_login_message").html("<img src='images/loader.gif' />&nbsp;Please Wait..."); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
	
	//$("div#forgetpassword_message").html(req.responseText); 
		
	var response = req.responseText;
	 var stat = response.split(",");
	 	
	if(stat[0] == "ok")
	{
	    if(stat[1] == "student")
	    {
    	//$('#login_box').jqmHide(); 
         location.href="ecampus/";
	    }
	    else
	    {
	  //  $('#login_box').jqmHide(); 
         location.href="teacher/";
	    
	    }
	    
	    
	    
	    
	
	}
	else
	
	{
	$("div#verify_login_message").html(req.responseText); 
	
	}
	
	
	
		 	
//	if(response == "ok")
//	{
//	
//	 $('#login_box').jqmHide(); 

//	location.href="ecampus/";
//	
//	
//	}
//	else
//	
//	{
//	$("div#verify_login_message").html(req.responseText); 
//	}
	
	
    }
	,'onError':function(req){
	$("div#verify_login_message").html(req.responseText); 

	}
  }
);



}

 /*...........End..................*/
 
 function slide_button(id,cls)
 {
         for(var x=1;x<=4;x++)
         {
                     if(x == id)
                     {
                     document.getElementById(x).className = cls+"_selected";
                     
                     
                     
                     }
                 else
                 {
                 
                 if(x == 1){document.getElementById(x).className = 'intro';}
                  if(x == 2){document.getElementById(x).className = 'events';}
                   if(x == 3){document.getElementById(x).className = 'philosophy';}
                    if(x == 4){document.getElementById(x).className = 'testimonials';}
                 
                 }
         
         }
  
 }
 
			
function tab2_selection(catid,x){
    for(var i=1;i<=6;i++){
    if(catid+'_'+x==catid+'_'+i){
    $('div#'+catid+'_'+i).find('a').css('color','#000')
    $('div#'+catid+'_'+i).find('a').addClass('tab2_selected')}
    else{
    $('div#'+catid+'_'+i).find('a').css('color','#fff')
    $('div#'+catid+'_'+i).find('a').removeClass('tab2_selected')}}
   
     if(x == "1")
    {
  
    req("loadcoursedetailsmain.aspx?catid="+catid, catid+"_category_details");
   return;
    }
   

    if(x == "2")
    {
    req("loadcoursedetails.aspx?catid="+catid+"&param=Aim", catid+"_category_details");return;
    }
    
     if(x == "3")
    {
    req("loadcoursedetails.aspx?catid="+catid+"&param=Overview",catid+"_category_details");return;
    }
    
      if(x == "4")
    {
    req("loadcoursedetails.aspx?catid="+catid+"&param=SampleLession",catid+"_category_details");return;
    }
    
       if(x == "5")
    {
    req("loadcoursedetails.aspx?catid="+catid+"&param=StudentSay",catid+"_category_details");return;
    }
    
       if(x == "6")
    {
    req("loadcoursedetails.aspx?catid="+catid+"&param=Requirements",catid+"_category_details");return;
    }
    
    

}





function req(url1,target)
{

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='images/loader.gif' />&nbsp;Please Wait..."); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	$("div#"+target).html(req.responseText);     }
	,'onError':function(req){
	$("div#"+target).html(req.responseText);    }
  }
);


}

function getlessontime(coursecode,timezoneindex,catid)
{
req("loadlessontime.aspx?coursecode="+coursecode+"&timezoneindex="+timezoneindex,catid+"_lbllessons");


}

function openiframe(catid)
{
$('div#iframe_div').html("");
$('div#loading').show();


var x  = '<iframe id="iframeregistration" onload="hide_loader()" src="registration.aspx?catid='+catid+'"  allowtransparency="true"   frameborder="0" width="597px" height="642px" scrolling="no" ></iframe>';

setTimeout(function() {$('div#iframe_div').html(x);}, 3000);
window.scroll(0,0);
}


function openiframe_freetrial()
{
$('div#iframe_div').html("");
$('div#loading').show();


var x  = '<iframe id="iframeregistration" onload="hide_loader()" src="registration.php"  allowtransparency="true"   frameborder="0" width="597px" height="642px"scrolling="no" ></iframe>';

setTimeout(function() {$('div#iframe_div').html(x);}, 3000);
window.scroll(0,0);
}


function openiframe_freetrial_ecampus()
{
$('div#iframe_div').html("");
$('div#loading').show();


var x  = '<iframe id="iframeregistration" onload="hide_loader()" src="../registration.php"  allowtransparency="true"   frameborder="0" width="597px" height="642px" scrolling="no" ></iframe>';

setTimeout(function() {$('div#iframe_div').html(x);}, 3000);
window.scroll(0,0);
}




function hide_loader()
{
$('div#loading').hide();

}


 function hidetopbar()
{
   // var x  = '<iframe id="iframesecure" src="'+url+'"  allowtransparency="true"   frameborder="0" width="99%" height="500px" scrolling="no" ></iframe>';
    //   $('div#iframe_div_1').html(x);
    
    $('#close_bar').hide(); 
}

function showtopbar()
{

$('#close_bar').show();

}

function paynow(url)
{
 //var hidScroll = document.getElementById('close_bar');
// document.getElementById(what).scrollTop = hidScroll.value;

//hidScroll.focus();
 //$('#registration_page').jqmShow(); 
$('div#iframe_div').html("");
$('div#loading').show();



var x  = '<iframe id="iframeregistration" onload="hide_loader()" src="'+url+'"  allowtransparency="true"   frameborder="0" width="99%" height="570px" scrolling="no" ></iframe>';

setTimeout(function() {$('div#iframe_div').html(x);}, 3000);
window.scroll(0,0);


}



function reqattend(url1,target)
{

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	$("div#"+target).html(req.responseText);     }
	,'onError':function(req){
	$("div#"+target).html(req.responseText);    }
  }
);


}

function attendlesson(aid,uniqueid)
{

for(i=1;i<=5;i++)
{

        if(aid == "a_"+i+"_"+uniqueid)
        {

        $('a#'+aid).addClass('button_style_black');

        }
        else

        {
        $('a#a_'+i+'_'+uniqueid).removeClass('button_style_black');

        }

}

}

function submithomework(url,target,uniquecode,lessoncode,regno,coursecode,studentid)
{
reqsubmithomework(url,target,uniquecode,lessoncode,regno,coursecode,studentid);
display_homework(coursecode,lessoncode,regno,studentid);
}

function submithomework_teacher(url,target,uniquecode,lessoncode,coursecode)
{
reqsubmithomework_teacher(url,target,uniquecode,lessoncode,coursecode);
display_homework_teacher(coursecode,lessoncode);
}


function submitmarkedhomework_teacher(url,target,uniquecode,lessoncode,coursecode)
{
reqsubmitmarkedhomework_teacher(url,target,uniquecode,lessoncode,coursecode);
display_markedhomework_teacher(coursecode,lessoncode);
}






function reqsubmithomework(url1,target,uniquecode,lessoncode,regno,coursecode,studentid)
{

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	$("div#"+target).html(req.responseText);  
	
	
	
	
		runfile(uniquecode,lessoncode,regno,coursecode,studentid);
		


	
	
	
	   }
	,'onError':function(req){
	$("div#"+target).html(req.responseText); 
	
	
	   }
  }
);


}


function reqsubmithomework_teacher(url1,target,uniquecode,lessoncode,coursecode)
{

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	$("div#"+target).html(req.responseText);  
	
	
	
	
		runfile_teacher(uniquecode,lessoncode,coursecode);
		


	
	
	
	   }
	,'onError':function(req){
	$("div#"+target).html(req.responseText); 
	
	
	   }
  }
);


}


function reqsubmitmarkedhomework_teacher(url1,target,uniquecode,lessoncode,coursecode)
{

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	$("div#"+target).html(req.responseText);  
	
	
	
	
		runfile_marked_teacher(uniquecode,lessoncode,coursecode);
		


	
	
	
	   }
	,'onError':function(req){
	$("div#"+target).html(req.responseText); 
	
	
	   }
  }
);


}



function runfile(uniquecode,lessoncode,regno,coursecode,studentid)
{
var btnUpload=$('#upload_'+uniquecode);
		var status=$('#status_'+uniquecode);
		
		new AjaxUpload(btnUpload, {
			action: 'upload-file.php',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(doc|pdf|docx|txt|jpg|gif|png|bmp)$/.test(ext))){ 
                    // extension is not allowed 
					//status.text('Only word, pdf or txt files are allowed');
					alert('Only word, pdf , txt and image files are allowed'); 
					return false;
				}
				
				if($('input#filename_'+uniquecode).val() == "" || $('input#filename_'+uniquecode).val()== "")
				{
				
				alert('Enter Title Name');
				return false;
				}
				
				
				
				status.html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle' style='color:#ff0000'>Uploading...</span>");
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.html('');
				//Add uploaded file to list
				if(response==="success")
				{
					//$('<li></li>').appendTo('#files').html('<img src="./uploads/'+file+'" alt="" /><br />'+file).addClass('success');
					title = $('input#filename_'+uniquecode).val();
					//display_homework(coursecode,lessoncode,regno,studentid);
					target = "uploaddetail_"+lessoncode+regno+coursecode;
					inserthomework(coursecode,regno,studentid,lessoncode,title,file,target);
					
				}
				
				else{
					//$('<li></li>').appendTo('#files').text(file).addClass('error');
				}
			}
		});
		
		
}



function runfile_teacher(uniquecode,lessoncode,coursecode)
{
var btnUpload=$('#upload_'+uniquecode);
		var status=$('#status_'+uniquecode);
		
		new AjaxUpload(btnUpload, {
			action: 'upload-file.php',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(doc|pdf|docx|txt|jpg|gif|png|bmp)$/.test(ext))){ 
                    // extension is not allowed 
					//status.text('Only word, pdf or txt files are allowed');
					alert('Only word, pdf , txt and image files are allowed'); 
					return false;
				}
				
				if($('input#filename_'+uniquecode).val() == "" || $('input#filename_'+uniquecode).val()== "")
				{
				
				alert('Enter Title Name');
				return false;
				}
				
				
				
				status.html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle' style='color:#ff0000'>Uploading...</span>");
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.html('');
				//Add uploaded file to list
				if(response==="success")
				{
					//$('<li></li>').appendTo('#files').html('<img src="./uploads/'+file+'" alt="" /><br />'+file).addClass('success');
					title = $('input#filename_'+uniquecode).val();
					//display_homework(coursecode,lessoncode,regno,studentid);
					target = "uploaddetail_"+lessoncode+coursecode;
					inserthomework_teacher(coursecode,lessoncode,title,file,target);
					
				}
				
				else{
					//$('<li></li>').appendTo('#files').text(file).addClass('error');
				}
			}
		});
		
		
}

function runfile_marked_teacher(uniquecode,lessoncode,coursecode)
{
var btnUpload=$('#upload_'+uniquecode);
		var status=$('#status_'+uniquecode);
		
		new AjaxUpload(btnUpload, {
			action: 'upload-file.php',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(doc|pdf|docx|txt|jpg|gif|png|bmp)$/.test(ext))){ 
                    // extension is not allowed 
					//status.text('Only word, pdf or txt files are allowed');
					alert('Only word, pdf , txt and image files are allowed'); 
					return false;
				}
				
				if($('input#filename_'+uniquecode).val() == "" || $('input#filename_'+uniquecode).val()== "")
				{
				
				alert('Enter Title Name');
				return false;
				}
				
				if( document.getElementById('student'+lessoncode+coursecode).value == "")
				{
			alert('Choose Student Name');
				return false;
				}
				
				
				
				status.html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle' style='color:#ff0000'>Uploading...</span>");
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.html('');
				//Add uploaded file to list
				if(response==="success")
				{
					//$('<li></li>').appendTo('#files').html('<img src="./uploads/'+file+'" alt="" /><br />'+file).addClass('success');
					title = $('input#filename_'+uniquecode).val();
					//display_homework(coursecode,lessoncode,regno,studentid);
					target = "uploaddetail_"+lessoncode+coursecode;
					studentid = document.getElementById('student'+lessoncode+coursecode).value;
					insertmarkedhomework_teacher(coursecode,lessoncode,title,file,target,studentid);
					
				}
				
				else{
					//$('<li></li>').appendTo('#files').text(file).addClass('error');
				}
			}
		});
		
		
}



function display_homework(coursecode,lessoncode,regno,studentid)
{

target = "uploaddetail_"+lessoncode+regno+coursecode;
reqattend("uploadedhomework.aspx?lessoncode="+lessoncode+"&coursecode="+coursecode+"&regno="+regno+"&studentid="+studentid,target);


}


function display_homework_teacher(coursecode,lessoncode)
{

target = "uploaddetail_"+lessoncode+coursecode;
reqattend("uploadedhomework_teacher.aspx?lessoncode="+lessoncode+"&coursecode="+coursecode,target);


}



function display_markedhomework_teacher(coursecode,lessoncode)
{

target = "uploaddetail_"+lessoncode+coursecode;
reqattend("uploadedhomework_markedteacher.aspx?lessoncode="+lessoncode+"&coursecode="+coursecode,target);


}




function inserthomework(coursecode,regno,studentid,lessoncode,title,file,target)
{
url1 = "inserthomework.aspx?lessoncode="+lessoncode+"&coursecode="+coursecode+"&regno="+regno+"&studentid="+studentid+"&title="+title+"&filename="+file;

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	//$("div#"+target).html(req.responseText);  
	
	 display_homework(coursecode,lessoncode,regno,studentid);
	
	   }
	,'onError':function(req){
	$("div#"+target).html(req.responseText);   
	
	 }
  }
);


}




function inserthomework_teacher(coursecode,lessoncode,title,file,target)
{
url1 = "inserthomework_teacher.aspx?lessoncode="+lessoncode+"&coursecode="+coursecode+"&title="+title+"&filename="+file;

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	//$("div#"+target).html(req.responseText);  
	
	 display_homework_teacher(coursecode,lessoncode);
	
	   }
	,'onError':function(req){
	$("div#"+target).html(req.responseText);   
	
	 }
  }
);


}



function insertmarkedhomework_teacher(coursecode,lessoncode,title,file,target,studentid)
{
url1 = "insertmarkedhomework_teacher.aspx?lessoncode="+lessoncode+"&coursecode="+coursecode+"&title="+title+"&filename="+file+"&studentid="+studentid;

AjaxRequest.get(

  {
  	'url':url1
    ,'onLoading':function() {$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>"); }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	//$("div#"+target).html(req.responseText);  
	
	 display_markedhomework_teacher(coursecode,lessoncode);
	
	   }
	,'onError':function(req){
	$("div#"+target).html(req.responseText);   
	
	 }
  }
);


}





function delete_homework(sno,lessoncode,regno,coursecode,studentid)
{


if( confirm('Are you sure to Delete ?') == true)

{
url1 = "deletehomework.aspx?sno="+sno;
AjaxRequest.get(


  {
  	'url':url1
    ,'onLoading':function() {
    //$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>");
     }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	//$("div#"+target).html(req.responseText);  
	
	display_homework(coursecode,lessoncode,regno,studentid)
	
	
	
	
	
	
	   }
	,'onError':function(req){
	//$("div#"+target).html(req.responseText); 
	//alert("Error while Deleting Homework");
	
	alert(req.responseText);
	
	   }
  }
);

}
else

{




}
}



function delete_homework_teacher(sno,lessoncode,coursecode)
{


if( confirm('Are you sure to Delete ?') == true)

{
url1 = "deletehomework_teacher.aspx?sno="+sno;
AjaxRequest.get(


  {
  	'url':url1
    ,'onLoading':function() {
    //$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>");
     }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	//$("div#"+target).html(req.responseText);  
	
	display_homework_teacher(coursecode,lessoncode)
	
	
	
	
	
	
	   }
	,'onError':function(req){
	//$("div#"+target).html(req.responseText); 
	//alert("Error while Deleting Homework");
	
	alert(req.responseText);
	
	   }
  }
);

}
else

{




}
}




function delete_markedhomework_teacher(sno,lessoncode,coursecode)
{


if( confirm('Are you sure to Delete ?') == true)

{
url1 = "deletemarkedhomework_teacher.aspx?sno="+sno;
AjaxRequest.get(


  {
  	'url':url1
    ,'onLoading':function() {
    //$("div#"+target).html("<img src='../images/loader.gif' />&nbsp;<span class='textstyle'>Please Wait...</span>");
     }
    ,'onLoaded':function() {  }
    ,'onInteractive':function() {  }
    ,'onComplete':function() {  }
    ,'onSuccess':function(req) {
		

	//$("div#"+target).html(req.responseText);  
	
	display_markedhomework_teacher(coursecode,lessoncode)
	
	
	
	
	
	
	   }
	,'onError':function(req){
	//$("div#"+target).html(req.responseText); 
	//alert("Error while Deleting Homework");
	
	alert(req.responseText);
	
	   }
  }
);

}
else

{




}
}










function toplink(id)
{
for(i=1;i<=4;i++)
{
    if(id == i)
    {
    $('a#'+id).removeClass("redlink");
    $('a#'+id).addClass("blacklink");
    }
    else

    {
      $('a#'+i).removeClass("blacklink");
      $('a#'+i).addClass("redlink");
    }


}

}

function closepopup()
{

$('#registration_page').jqmHide();

}

function openforgetpassword()
{

 $('#forget_password').jqmShow(); 


}




// JScript File
function open_big(tmp)
{
var w = 480, h = 340;

if (document.all) {
   /* the following is only available after onLoad */
   w = document.body.clientWidth;
   h = document.body.clientHeight;
}
else if (document.layers) {
   w = window.innerWidth;
   h = window.innerHeight;
}

var popW = 670, popH = 475;

var leftPos = (w-popW)/2, topPos = (h-popH)/2;

var x = window.open(tmp,'popup','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos+',scrollbars=1');
//var x = window.open(tmp,'','titlebar= 1, menubar=1, scrollbars=1');

x.focus();
}



