$(document).ready(function() {
  $(".late").removeClass("hide");
  
  $(".sAll").click(function(){
    $(".ss").removeClass("Active")
	$(this).addClass("Active");
	$(".years").removeClass("hide");
  });

  $(".sy2009").click(function(){
    $(".ss").removeClass("Active")
	$(this).addClass("Active");
	$(".years").addClass("hide");
	$(".y2009").removeClass("hide");
  });

  $(".sy2008").click(function(){
    $(".ss").removeClass("Active")
	$(this).addClass("Active");
	$(".years").addClass("hide");
	$(".y2008").removeClass("hide");	
  });

  $(".sy2007").click(function(){
    $(".ss").removeClass("Active")
	$(this).addClass("Active");
	$(".years").addClass("hide");
	$(".y2007").removeClass("hide");	
  });

  $(".report").click(function(){
    reportId = $(this).parent().parent().attr('id').substring(2);
	
    if ($('#reporting_'+reportId).text() == '') {
      $(this).parent().parent().after('<div class="reporting" id="reporting_'+reportId+'">'+
        '<a href="javascript:;" id="bookId_1" class="reportus">Broken Link?</a>&nbsp;&nbsp;'+
		'<a href="javascript:;" id="bookId_2" class="reportus">Invalid Year?</a>&nbsp;&nbsp;'+
		'<a href="javascript:;" id="bookId_3" class="reportus">Spam?</a>'+
        '</div>')
		callreport();
      $('#reporting_'+reportId).hide()
    }
    $('#reporting_'+reportId).slideToggle(100);
    return false;
  });

function callreport(){
  $(".reportus").each(function(){
    $(this).click(function(){
      reportid = $(this).parent().attr('id').substring(10);
	  reportsubject = $(this).attr('id').substring(7);
      $(this).parent().fadeOut(100).load("ignou/assignment/a-report.php",{reportofid:reportid, reportofid1:reportsubject}).fadeIn(500);
    });
  });
  }

  $(".download").each(function(){
    $(this).click(function(){
	 $(this).text('loading...');
     aId = $(this).parent().parent().attr('id').substring(2);
     $.post("ignou/assignment/download.php", { assignment:aId},
	   function(data){
		 if(data==0) {alert('Please login for download the assignment!');}
		 else if(data==2) {alert('Server problem! Please try again later!');}
		 else { var browserName=navigator.appName; 
    if (browserName=="Microsoft Internet Explorer"){
     location.href='../../main/'+data; downloadmsg();	tb_remove();
    }else {		 
		 location.href='main/'+data; downloadmsg(); tb_remove();
	}
	 }
	   });
    });
  });

function downloadmsg(){
  $(".download").text('Download');
}  

 $(".HS-ans").each(function(){
    $(this).click(function(){
	getClass=$(this).parent().parent().next().attr('class');
	if(getClass=='code' || getClass=='code show') {
	  $(this).parent().parent().next().addClass('hide');
	  $(this).parent().parent().next().removeClass('show');
	  $(this).text('[+]');
	}else {
	  $(this).parent().parent().next().addClass('show');
	  $(this).parent().parent().next().removeClass('hide');
	  $(this).text('[-]');	
	}
    });
  });
  

});

function showQuick(dropdown){
    var browserName=navigator.appName; 
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    if (browserName=="Microsoft Internet Explorer"){
      var baseURL  = '';	
    }else {
      var baseURL  = 'ignou/assignment/';
	}
    top.location.href = baseURL+SelValue+'.html';
    return true;
}

function checkA(){
Aid= document.getElementById('Anscomment').value;
 // if(Aid=="") { alert ('Please say something'); return false;}
   if(document.getElementById('Anscomment').value.length <= 10 ){alert('Please Enter minmum 1 line'); return false;}
   else   return true;
}

function isBlank(field) {
  return (field.value.length > 0) ? true : false;
}

