	var base_url=window.location;

	//alert(base_url);

	if(base_url.toString().startsWith('http://writecite.com/'))

		base_url="http://writecite.com/";

	else if(base_url.toString().startsWith('http://www.writecite.com/'))

		base_url="http://www.writecite.com/";

	else if(base_url.toString().startsWith('http://118.139.163.124/'))

		base_url="http://118.139.163.124/";

	else if(base_url.toString().startsWith('http://67.23.237.8/'))

		base_url="http://67.23.237.8/~visitor/";

	else if(base_url.toString().startsWith('http://mi1'))

		base_url="http://mi1/WW/Writecite/WCLivejan12/";

	else if(base_url.toString().startsWith('http://192.168.1.202/WC/'))

		base_url="http://192.168.1.202/WC/";

	else if(base_url.toString().startsWith('http://localhost/WC/'))

		base_url="http://localhost/WC/";



//window.open('http://www.google.com','google');

    

$(document).ready(function()

{



    $(document).bind("contextmenu",function(e){

        return false;

    });



    $('#mswordexport').click(function() {

        OpenMSWordExport();

    });

		

    $.get(base_url+'students/scripts/getsession.php', function(data)

    {//alert(data);

       $('#svPnl').html(data); 

			

    });

	

    $(document).keypress(function(e) {

       // alert(e.which);

        if (e.which == 13) {// && !$(e.target).is("textarea")

			jAlertMod("Enter key is disabled!\r\nPlease use Tab key or the available buttons.","Alert","&nbsp;OK&nbsp;",null);

           		return false;

        }

	});

	



});







function TransportingCitation2(obj){

	//publication

	var cnt =0;

	var cbool = false;

	var $inputs = $('.cssform :input');

    var values = {};

    $inputs.each(function() {

        values[this.name] = $(this).val();

		//alert(this.type+" "+this.value);

		if(this.type == 'text' && this.value !=''){

				jConfirmMod("Transporting citations between styles is not possible!\r\nYou will loose your citations! Are you sure you want to continue?", 'Page Change' ,'&nbsp;Proceed&nbsp;', function(c1) {

			if(c1)

    		{	

				  $.ajax({

				  type: 'POST',

				  url: base_url+ 'students/scripts/savesession.php',

				  context: document.body,

				  data: "html=@@@@@",

				  success: function(data){

					  

					window.location=obj.href;	

			      }

				  

			});

				try{$(".cssform input").spellchecker("remove");}

				catch(e){}

				return false;

    		}

			else{cbool = true; return false;}

		});	

			return false;	

		}

		else if(this.type == 'text' && this.value ==''){

			cnt = cnt +1;

		}

    });



	if(cnt>0 && cbool == false){

		  $.ajax({

		  type: 'POST',

		  url: base_url+ 'students/scripts/savesession.php',

		  context: document.body,

		  data: "html=@@@@@",

		  success: function(data){

			//window.location=obj.href;	

		  }

	});

	}

	 return false;

}





function TransportingCitation(obj){

	//alert($.trim($("#bookPanel").text()));

	//alert($.trim($("#svPnl").text()));

	if($.trim($("#bookPanel").text()) != '' || $.trim($("#svPnl").text()) !=''){

		jConfirmMod("Transporting citations between styles is not possible!\r\nYou will loose your citations! Are you sure you want to continue?", 'Page Change' ,'&nbsp;Proceed&nbsp;',function(c1) {

			if(c1){

			  $.ajax({

			  type: 'POST',

			  url: base_url+ 'students/scripts/savesession.php',

			  context: document.body,

			  data: "html=@@@@@",

			  success: function(data){

				window.location=obj.href;	

			  }

				  

			});

			

			

			$.ajax({

			  type: 'POST',

			  url: base_url+ 'ajax.php',

			  context: document.body,

			  data: "type=setintextsession&val2=@@@@@",

			  success: function(data){

				window.location=obj.href;	

			  }

				  

			});

			

				try{$(".cssform input").spellchecker("remove");}

				catch(e){}

				return false;

    		}

			else{return false;}

		});

	}else{

		window.location=obj.href;	

	}

   

 return false;

}





function OpenPDFExport()

{

    if($.trim($("#svPnl").text())=="")

	{

	jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);

	return false;

	}

    else

    {

		var section=getSectionName();

	

		url = base_url+ "students/scripts/exportPDF.php?time="+new Date().toString().substring(4,28)+"&section="+section;	

		//alert(url);

		window.open(url,'mywindow','');

		//window.location = url

		return false;

    }

}



function OpenMSWordExport()

{

    if($.trim($("#svPnl").text())=="")

	{

	jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);

	return false;

	}

    else

    {

		var section=getSectionName();

		url = base_url+ "students/scripts/export.php?time="+new Date().toString().substring(4,28)+"&section="+section;	

		//alert(url);

		window.location = url

		return false;

    }

}



function PDFCopy(){

	var section=getSectionName();

	var n = $('.deletecitationbody:checked').length;

	if(n>0) {

	  var content="";

        $('.deletecitationbody:checked').parent().each(function(index)

        {

			var inpt = $(this).html();

			var par = $(this);

			$(par).children('input').remove();

			content1 = $(par).html();

			$(par).html(inpt);

			

			//content1="<div style='width: 347px; height: auto; text-indent: -30px; padding-left: 20px; word-wrap: break-word; text-align: left; white-space: normal;' class='citation'>"+content1+"</div><br />"; 

			content=content+content1+"|";

			content=content.replace("&nbsp;",""); 

        });

			content=content.replace(/&/g , "##");

			

			$.ajax({

               type: 'POST',

		   	   async:false,

		   	   url: base_url+ 'students/scripts/savesession1.php',

               data: "html_db="+content

		   

	      });

			murl =base_url+'students/scripts/exportPDF.php?fromDB=yes&time='+new Date().toString().substring(4,28)+'&section='+section;

		window.open(murl,'mywindow','');

    		 return false;

		}

	else {

	jAlertMod("Click the checkbox alongside citations before using PDF.","Alert","&nbsp;OK&nbsp;",null);

	}

}



function OpenMSWordExport1()

{

      var section=getSectionName();

	var n = $('.deletecitationbody:checked').length;

	if(n>0) {

	  var content="";

        $('.deletecitationbody:checked').parent().each(function(index)

        {

			var inpt = $(this).html();

			var par = $(this);

			$(par).children('input').remove();

			content1 = $(par).html();

			$(par).html(inpt);

			//content1="<div style='width: 347px; height: auto; text-indent: -30px; padding-left: 20px; word-wrap: break-word; text-align: left; white-space: normal;' class='citation'>"+content1+"</div><br />"; 

			content=content+content1+"|";

			content=content.replace("&nbsp;",""); 

        });

			content=content.replace(/&/g , "##");

			

			$.ajax({

               type: 'POST',

		   async:false,

		   url: base_url+ 'students/scripts/savesession1.php',

               data: "html_db="+content

		   

	      });



		 window.location = base_url+ "students/scripts/export.php?fromDB=yes&time="+new Date().toString().substring(4,28)+"&section="+section;

    		 return false;

		}

		else {

		jAlertMod("Click the checkbox alongside citations before using MS Word.","Alert","&nbsp;OK&nbsp;",null);

		}

		

}



function getSectionName(secNo) {

if(secNo==1) {

	return 'mla';

}

else if(secNo==2) {

	return 'apa';

}

else if(secNo==3) {

	return 'harvard';

}

else {

return 'none'

}

}



function getSectionName() {

	var pathname = window.location.pathname;

	if(pathname.indexOf('mla')>0){

		return 'mla';

	} 

	else if (pathname.indexOf('apa')>0){

		return 'apa';

	}

	else if (pathname.indexOf('harvard')>0){

		return 'harvard';

	}

	else{

		return 'apa';

	}

}



function getSectionName4css() {

	var pathname = opener.window.location.pathname;

	if(pathname.indexOf('mla')>0){

		return 'mla';

	} 

	else if (pathname.indexOf('apa')>0){

		return 'apa';

	}

	else if (pathname.indexOf('harvard')>0){

		return 'harvard';

	}

	else{

		return 'apa';

	}

}





function getSectionNameFromSec(secNo) {

if(secNo==1) {

	return 'mla';

}

else if(secNo==2) {

	return 'apa';

}

else if(secNo==3) {

	return 'harvard';

}

else {

return 'none'

}

}

function showHarvard(secNo){



	$('#savedPanel').html('');

	//section = getSectionName(secNo);

	section = getSectionNameFromSec(secNo);

	

		$.ajax({type: 'GET', 

							url: base_url+'students/scripts/showSavedPanel1.php', 

							cache: false,

							async:false,

							data: "format=harvard&formatHL="+section,

							success: function(data){

								//alert(data);

		    	    		$('#savedPanel').html(data);

			     			}

			     		});

		return false;	

}



function showMLA(secNo){



	$('#savedPanel').html('');

	//section = getSectionName(secNo);

	section = getSectionNameFromSec(secNo);

	

		$.ajax({type: 'GET', 

							url: base_url+ 'students/scripts/showSavedPanel1.php', 

							cache: false,

							async:false,

							data: "format=mla&formatHL="+section,

							success: function(data){

		    	    		$('#savedPanel').html(data);

			     			}

			     		});

		return false;

}



function showAPA(secNo){

	//section = getSectionName(secNo);

	section = getSectionNameFromSec(secNo);

	//alert(section);

	$.ajax({type: 'GET', 

		url: base_url+ 'students/scripts/showSavedPanel1.php', 

		cache: false,

		async:false,

		data: "format=apa&formatHL="+section,

		success: function(data){

			//alert(data);

			$('#savedPanel').html(data);

		}

	});

	return false;		

}



function showAPA2(secNo){

		//alert("dd"+secNo);

		$.ajax({type: 'GET', 

							url: base_url+ 'students/scripts/showSavedPanel.php', 

							cache: false,

							async:false,

							data: "format=apa&formatHL=apa",

							success: function(data){

		    	    		$('#savedPanel').html(data);

			     			}

			     		});

}



function DetectSection(){

	

	var section = getSectionName();

	if(section=='mla') {

		showMLA(1)

	}

	else if (section=='apa'){

		showAPA(2);

	}

	else if (section=='harvard'){

		showHarvard(3);

	}

	else{

		showAPA2(2);

	}

}





function DetectSection1(){

$('a').click(function(e) {

	e.preventDefault();

	window.location.href= e.target;

});

}



function DetectSection2(link1){

	

$(".stop").click(function(e){

	e.preventDefault();

	Reset();

	jConfirmMod("Transporting citations between styles is not possible!\r\nYou will loose your citations! Are you sure you want to continue?", 'Page Change' ,'&nbsp;Proceed&nbsp;', function(c1) {

    		if(c1)

    		{

				window.location=e.target+"?html="+link1;

				$.ajax({

						type: 'POST',

						url: base_url+ 'students/scripts/savesession.php',

						data: "html="

					});

				

    		}

	 });

});

}



function ask4Save()

{	//alert('qqqq');

	$("ul.stop1").click(function(e){

	e.preventDefault();

	

    if($.trim($('#bookPanel').text()) != "")

    {

		jConfirmMod('Do you want to save your current citation?', 'Save Citation','&nbsp;Proceed&nbsp;', function(r7) {

			if(r7) {	

					savePrevPanl1('bookPanel' , 'svPnl',true);

					jAlert("Your info has been saved","Alert",function(){

					window.location.href=e.target});



				}

				else {

		            clearPanel('bookPanel');

					window.location.href=e.target;



				}

			});

    }



	if($.trim($('#bookPanel').text()) == "")

    {

		window.location.href=e.target;

    }

});

}



function ask4Save1()

{	

	$("ul").click(function(e){

	e.preventDefault();

	

    if($.trim($('#bookPanel').text()) != "")

    {

		jConfirmMod('Do you want to save your current citation?', 'Save Citation','&nbsp;Proceed&nbsp;', function(r7) {

			if(r7) {	

					RegisterAlert();



				}

				else {

		            clearPanel('bookPanel');

					window.location.href=e.target;



				}

			});

    }



	if($.trim($('#bookPanel').text()) == "")

    {

	window.location.href=e.target;

    }

});

}









function saveNotestoDB(val)

{

var theForm = document.forms['quicknote'];

var url = theForm.url.value;

var text = theForm.text.value;

var fileId = theForm.fileId.value;



var filenameText = theForm.filename.value;

var tagnameText = theForm.tagname.value;



//var filenameSelect = theForm.filenm.value;

//alert(filenameText);



	if(filenameText==""){

			if(tagnameText.length <= 40){

			filenameText = tagnameText;

		}

		else if(tagnameText.length > 40)

			{

			jAlertMod("Enter max 40 character in the Note Name Field.","Alert","&nbsp;OK&nbsp;",null);			

			return false;

			}

		}

		text=text.replace(/&/g , "@@@");

		text=text.replace(/\n/g , "");

		url=url.replace(/&/g , "@@@");

	

if(tagnameText!=""){

	

			$.ajax({

				type: 'GET',

				url: base_url+ 'students/scripts/saveNotesDatabase.php',

				data: "url="+url+"&text="+text+"&filename="+filenameText+"&tagname="+tagnameText+"&fileId="+fileId,

				

				success: function(data){

					

					if(val == 'panel' || val == 'WINDOW'){

					fireAjaxRequest('students/scripts/viewGroupNote.php','','formatHL=apa&fileId='+filenameText+'&window='+val,'c8Content','','CN');

					

					opener.fireAjaxRequest('students/scripts/showAllNotes.php','','formatHL=apa','c8Content','','CN');

					

					}else{

		    	    opener.fireAjaxRequest('students/scripts/showAllNotes.php','','formatHL=apa','c8Content','','CN');	

					}

			     			}

							

			});



			//$('#addnote').dialogr('close');

			//$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected'));

}else

	{

		jAlertMod("Enter Mandaory Field Note Name.","Alert","&nbsp;OK&nbsp;",null);

	}



}





function openWindow(fileId,editflag) {



			var dialogErr = '#addnote';



			var btns = {};

			var file="";

			if(fileId && fileId !="" && editflag && editflag=='true'){

				

				file =	base_url+"students/scripts/addNote.php";

				btns['Save'] = function(){ saveNotestoDB(); };

				btns['Cancel'] = function(){ 

					var theForm = document.forms['quicknote'];

					var fileId = theForm.fileId.value;

					$(dialogErr).dialogr('close');

					openWindow(fileId,'false');

				};



			}

			else if(fileId && fileId !="" && editflag && editflag=='false'){

				file =	base_url+"students/scripts/viewNote.php";

				btns['Edit'] = function(){ 

					var theForm = document.forms['quicknote1'];

					//var fileId = theForm.fileId.value;

					$(dialogErr).dialogr('close');

					openWindow(fileId,'true');

				};

				}

			

			else {

				file =	base_url+"students/scripts/addNote.php";

				btns['Save'] = function(){ saveNotestoDB(); };



			}

			btns['Close'] = function(){ $(dialogErr).dialogr('close'); };





	$(dialogErr).dialogr({

			autoOpen: true,

			bgiframe: true,

			resizable: false,

			minHeight: 300, 

			minWidth: 390,

			height:400,

			width:390,

			minimize:true,

			maximized:false,

			modal: false,

			title: 'Add Note',

			open: function() { 

				var xhr = $.ajax({ 

					type: 'POST',

					url: file, 

					data: "fileId="+fileId,

					cache: false,

					async: false,

					success: function(data){

    	    		$(dialogErr).html(data);

	     			}

	     		});

	     		xhr=null;

			},

			buttons: btns

		});



		$('#addnote').removeAttr("style");	

	

		$('#ui-dialog-title-addnote').css({

						color:'#FFF'

					});

		$('#ui-dialog-title-addnote').parent().css({

						background:'url("../images/red-gradient.png") repeat scroll 0 0 transparent'

					});



		$(dialogErr).dialogr('open');



}









function unk(){//v1.0







var windowProperties=''; 



if(nav==false) windowProperties+='toolbar=no,';



else



windowProperties+='toolbar=yes,'; 







if(loc==false)



windowProperties+='location=no,'; 



else windowProperties+='location=yes,'; 







if(sts==false)



windowProperties+='status=no,';



else windowProperties+='status=yes,'; 







if(menu==false)



windowProperties+='menubar=no,';



else windowProperties+='menubar=yes,'; 







if(scroll==false)



windowProperties+='scrollbars=no,';



else windowProperties+='scrollbars=yes,'; 







if(resize==false)



windowProperties+='resizable=no,';



else windowProperties+='resizable=yes,'; 







if(w!="")



windowProperties+='width='+w+',';







if(h!="") windowProperties+='height='+h; 







if(windowProperties!="") { 



if( windowProperties.charAt(windowProperties.length-1)==',') 



windowProperties=windowProperties.substring(0,windowProperties.length-1);



}



window1 = window.open(url,name,windowProperties);



window1.moveTo(705,200);



if (window1)



{



window1.focus();



}



}



function showFileNameSelection(content1,section) {

   

   jPrompt1('Enter a filename. If filename exists then citations will be appended to existing file.', 'Default_Citations', 'Save as', function(r1) {

																																			

				if( r1 ) {

					notes=r1;

					//alert(r1);

					$.ajax({

						type: 'POST',

						url: base_url+ 'students/scripts/savedatabase.php?formatHL='+section,

						data: "html="+content1+"&notes="+notes+"&save=append",

						success: function(data){

				//alert(data);

						if(data == 'cannot save more citations')

							{

							jAlertMod("Storage Full. Please delete unwanted citations before saving Or save to a new list.","Failure","&nbsp;OK&nbsp;",null);

							}

							else 

							if(data == '1')

							{//do nothing

							//alert(section);

							fireAjaxRequest('students/scripts/showAlldatabase.php','','formatHL='+section+'&format='+section,'c8Content','','SF');

                        			}

							else 

							if(data == 'cannot save more files')

							{

							jAlertMod("You have exceed your storage capacity. Please delete unwanted files.","Failure","&nbsp;OK&nbsp;",null);

                        			}									

									}



					});

				

				//$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected'));

				}

				

			});

  // 

}



function showFileNameSelection2(content1,section,filenm1) {

        //alert(content1+filenm1);

   jPrompt2('Enter a filename. If filename exists then citations will be appended to existing file.', 'Default_Citations', 'Save as', function(r1) {

				if( r1 ) {

					notes=r1;

					if(notes==filenm1)

					{

					jAlertMod("Cannot save Duplicate Citation to the same Filename.<br>Save to a New File or Existing File.","Failure","&nbsp;OK&nbsp;",null);

					}

					else

					{

						//alert(filenm1);

					$.ajax({

						type: 'POST',

						url: base_url+ 'students/scripts/savedatabase.php?formatHL='+section,

						data: "html="+content1+"&notes="+notes+"&save=append&fileid="+filenm1,

						success: function(data){

							//alert(data);

							if(data == 'cannot save more citations'){

								jAlertMod("Storage Full. Please delete unwanted citations before saving Or save to a new list.","Failure","&nbsp;OK&nbsp;",null);

							}else if(data == '1' || data == '11'){

								jAlertMod("Citations save successfully.","Failure","&nbsp;OK&nbsp;",null);

							}else if(data == 'cannot save more files'){

								jAlertMod("You have exceed your storage capacity. Please delete unwanted files.","Failure","&nbsp;OK&nbsp;",null);

							}									

						}



					});

				

				$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected'));

				}

				}

				

			},filenm1);

}







function saveCitationstoDB2()

{

	if(document.log==true){

		$.get(base_url+'students/scripts/getformat.php', function(data){

		

		var section = getSectionName();

		//alert(section);

		//return false;

      	 //if(data!=section){

			jConfirmMod('Your citations will be saved in '+section.toUpperCase()+' format', 'Save Confirmation','&nbsp;Proceed&nbsp;', function(r5) {

			if(r5) {

				saveCitationstoDB(section);

				}

			});

		//}

		/*else {

				//alert('jjj');

				saveCitationstoDB(section);

				

		}*/

	  });

	}else{

		RegisterAlert();

	}

}



function saveCitationstoDB(section){



    var content="";

    var n = $('.deletecitation').length;

	if(n==1) {

		$('.deletecitation').attr('checked',true);

	}

	$('.deletecitation:checked').each(function(index)

    {

		var inpt = $(this).parent().html();

		var par = $(this).parent();

		$(par).children('input').remove();



			//content1 = $.trim($(par).html());

			//alert($.trim($(par).html()));

			$(par).html().replace("<i>", "^i^");

			$(par).html().replace("</i>", "^ii^");

			content1 = $(par).html();

			//alert(content1);

			content1=content1.replace("^i^", "<i>");

            content1=content1.replace("^ii^", "</i>");

			



		$(par).html(inpt);

		$(par).children('input').attr('checked',true);



       content=content+content1+"|";

	   

    });

	

	content=$.trim(removeNewLine(content));

	content=content.replace(/&nbsp;/g," ");

	content=content.replace(/&amp;/g,"##");



	if(content!=""){

		showFileNameSelection(content,section);

	}else {

		jAlertMod("Click the checkbox alongside citations before saving","Alert","&nbsp;OK&nbsp;",null);

	}



}



function RegisterAlert(){

jAlertMod1("This function is available for registered users only.<br>Register or Login using the links at the top of the page.","Login Required","&nbsp;OK&nbsp;",null);



jAlertMod1("This function is available for registered users only.<br>Register or Login using the links at the top of the page.","Login Required","&nbsp;OK&nbsp;",function(afteruserRes){

			if(afteruserRes){

				if(opener){

                    opener.rigtTabContent('b9');

				}else{

					//LoginHandler();

					rigtTabContent('b9');

				}

			}

		});

		return false;

		

}



function callbackfrmdiv(){



	if(!document.getElementById('radio1') && !$('.intexts').html()){

	//$('#formPreDiv').css('display','none');

	jAlertMod1("Your in-text citation will appear as you enter the source details into the form.","Required","&nbsp;OK&nbsp;",null);

	$('#formPreDiv').toggle();

	}else{

		$('#formPreDiv').toggle();

	}

	

	return false;

}





function DeleteSelected()

{

	var n = $('.deletecitation:checked').length;

    if(n>0) {

		

		$('.deletecitation:checked').each(function(index)

		{

			$(this).parent().remove();

		});

	

		if($.trim($("#svPnl").text())!="")

		{

	

			var content="";

			$('.citation').each(function(index)

			{

				content=content+$.trim($(this).text())+"|";

			});

	//alert(content);

			$.ajax({

				type: 'POST',

				url: base_url+ 'students/scripts/savesession.php',

				data: "html="+content

			});

			//$(".cssform input").spellchecker("remove");

			try{

				$(".cssform input").spellchecker("remove");

			}

			catch(e){

			}

		}

		if($.trim($("#svPnl").text())=="")

		  {

		clearSvPanel();

		}

	}

	else {

		jAlertMod("Click the checkbox alongside citations before Delete","Alert","&nbsp;OK&nbsp;",null);

	}

}



function ShowButtons()

{

//alert('ppppp');

/*$('#bottomfooter').html("<div id='submit1'><input type='button' value='Open' onclick='OpenCitations();'/><input type='button' value='Add Note' onclick='AddNoteFromCitationFile();'/><input type='button' value='# Delete' onclick='DeleteSelectedfromDBFile();' /><input type='button' value='Logout' onclick='LogoutHandler()' /></div>");*/

//AddNoteFromCitationFile();return false



$('#showBelowPanel').html('<div class="content-bottom" style="padding-left:135px; width:265px" id="bottomfooter"><ul class="buttnav"><li class="active"><a href="#" onclick="OpenCitations();return false;"><span>Open</span></a></li><li><a href="#" onclick="return fireAjaxRequest(\'students/scripts/addNote.php\',\'\',\'fileId=0&current=panel\',\'c8Content\',\'\',\'CN\');"><span>AddNote</span></a></li><li><a><span onclick="duplicateCitation2();">Save As</span></a></li><li><a href="#" onclick="DeleteSelectedfromDBFile();return false"><span>Delete</span></a></li><li><a><span onclick="makePrint(\'saved-panel\');">Print</span></a></li><li><a href="#" onclick="LogoutHandler();" return false;><span>Logout</span></a></li></ul></div>');

makeULCenter();

}



function ShowButtons2()

{

$('#showbuttons2').html("<form class='cssform' method='post' id='preview1' name='preview1' ><div id='submit1'><div id='d_clip_container1'><input type='button' id='d_clip_button1' value='Copy All' /></div><input type='button' value='Add Note' onclick='AddNoteFromCitations();'/><input type='button' value='# Delete' onclick='DeleteSelectedfromDB();' /><input type='button'value='MS Word' onclick='OpenMSWordExport1();' /><input type='button' value='E-mail' onclick='showEmailDiv2();' /><input type='button' value='Logout' onclick='LogoutHandler()' /><input type='button' value='Duplicate' onclick='duplicateCitation();' /><br /><div id='emailSec1' style='display: none'><span id='emailTxt' style='color: black; line-height: 150%'>Enter your e-mail address in the field below:</span><br /><input type='text' name='emailAddr1' id='emailAddr1' /><input type='submit' value='Send' onclick='return email1();'  /> </div></div id='submit'></form>");

init2();

}



function ShowButtons3()

{



$('#showbuttons3').html("<div id='submit1' style='padding-top:5px;'><input type='button' value='View' onclick='OpenNotes();'/><input type='button' value='Edit' onclick='EditNotes();'/><input type='button' value='# Delete' onclick='DeleteSelectedNotesfromDB();' /><input type='button' value='Logout' onclick='LogoutHandler()'/></div>");

}



function ShowButtons4(fileId)

{

$('#showbuttons4').html("<div id='submit1' style='padding-top:5px'><input type='button' value='Close' onclick='OpenNotesback();'/><input type='button' value='Edit' onclick='EditNotes("+fileId+");'/><input type='button' value='Expand' onclick='expandView("+fileId+");'/></div>");

}



function expandView(fileId,arg)

{

openWindows(fileId,'false');

}



function ShowButtonsPanel() {

//alert('111');

$('#savePanelUITabs').bind('tabsselect', function(event, ui) {

	selectedTab = ui.index;

	 if(selectedTab=='1')

	{

		var fileid ='';

    		$('.opencitationbody:checked').each(function(index)

    		{		

		fileid = $(this).attr('name');

		});

		if(fileid!="") {

    		 var newUrl = base_url + 'students/scripts/showAlldatabase2.php?fileid=' + fileid; 

    		 $("#savePanelUITabs").tabs("url", 1, newUrl);

      	//$("#savePanelUITabs").tabs("select", 1);

		}

	}

	else {

	}

});

}





function OpenCitations()

{	

    var n = $('.opencitationbody:checked').length;

    if(n>0) {

    var fileid ='';

    $('.opencitationbody:checked').each(function(index)

    {		

		fileid = $(this).attr('name');

		filenm1 = $(this).attr('id');

    });

	if(fileid!="") {

		//alert(fileid+" "+filenm1);

    // var newUrl = base_url + 'students/scripts/showAlldatabase2.php?fileid=' + fileid; 

     // $("#savePanelUITabs").tabs("url", 1, newUrl);

     // $("#savePanelUITabs").tabs("select", 1);

	  

	  fireAjaxRequest("students/scripts/showAlldatabase2.php","","fileid="+fileid,"c8Content","")

	//showbuttons2

	//$('#bottomfooter').html("<form class='cssform' method='post' id='preview1' name='preview1' ><div id='submit1'><div id='d_clip_container1'><input type='button' id='d_clip_button1' value='Copy All'/></div><input type='button' value='Add Note' onclick='AddNoteFromCitations();'/><input type='button' value='# Delete' onclick='DeleteSelectedfromDB();' /><input type='button' id='mswordexport1' onclick='OpenMSWordExport1();' value='MS Word' /><input type='button' value='E-mail' onclick='showEmailDiv2();' /><input type='button' value='Logout' onclick='LogoutHandler()' /><input type='button' value='Duplicate' onclick='duplicateCitation(filenm1);' /><br /><div id='emailSec1' style='display: none'><span id='emailTxt' style='color: black; line-height: 150%'>Enter your e-mail address in the field below:</span><br /><input type='text' name='emailAddr1' id='emailAddr1' /><input type='submit' value='Send' onclick='return email1();' /> </div></div id='submit'></form>");

	//setTimeout(function() {init2();},1000);

	}

	}

	else {

		jAlertMod("No saved citations or Citations file was not selected","Alert","&nbsp;OK&nbsp;",null);

		}



}



function AddNoteFromCitationFile()

{

	var fileid ='';

	var filename ='';

    $('.opencitationbody:checked').each(function(index)

    {		

		fileid = $(this).attr('name');

		filename = $(this).parent().attr('name');

     });



	if(fileid!="") {

		

     openWindows();

	 var theForm = document.forms['quicknote'];

	 theForm.filename.value = filename;

	}

	else {

		jAlertMod("No saved Citation file was selected","Alert","&nbsp;OK&nbsp;",null);

	}



}



function AddNoteFromCitations()

{

	var fileid ='';

	var filename ='';

    $('.deletecitationbody:checked').each(function(index)

    {		

		fileid = $(this).attr('id');

		filename = $(this).parent().parent().attr('name');

     });



	if(fileid!="") {

     openWindows();

	 //var theForm = document.forms['quicknote'];

	// theForm.filename.value = filename;

	}

	else {

		jAlertMod("No saved Citation was selected","Alert","&nbsp;OK&nbsp;",null);

	}

	return false;



}





function EditNotes(fileId,val)

{

	var fileid ='';

	if(fileId && fileId != "")

	{	

	fileid=fileId;

	}

	else

	{

	    $('.opennotesbody:checked').each(function(index)

	{		

		fileid = $(this).attr('name');

     });

	

	}

	if(fileid!="") {

			if(val == 'panel' || val == 'WINDOW'){

					fireAjaxRequest("students/scripts/addNote.php","","fileId="+fileid+"&current="+val,"c8Content","","CN");

			}else{

		     	openWindows(fileid,'true');

			}

	}

	else {

		jAlertMod("Click the checkbox alongside citenotes before Edit","Alert","&nbsp;OK&nbsp;",null);

	}

    	

}



function OpenGroup(val){

	//alert(val);

	var fileid ='';

    $('.opennotesbody:checked').each(function(index)

    {		

		fileid = $(this).attr('name');

		filenm = $(this).attr('id');

    });

	if(fileid!="") {

		var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

		var is_safari= navigator.userAgent.toLowerCase().indexOf('Safari')> -1;

		

		

		if(val == 'WINDOW'){

			url = base_url+ 'students/scripts/viewPage.php?method=group&fileId='+filenm;

			if(is_chrome || is_safari)

			{

				FP_openNewWindow(490,500,false,false,false,false,true,true,'AddNote',url);

			}

			else

			{

				FP_openNewWindow(470,410,false,false,false,false,true,true,'AddNote',url);

			}

		}else if(val == 'WINDOW2'){

			url = base_url+ 'students/scripts/viewPage.php?method=view&fileId='+fileid;

			if(is_chrome || is_safari)

			{

				FP_openNewWindow(490,500,false,false,false,false,true,true,'AddNote',url);

			}

			else

			{

				FP_openNewWindow(470,410,false,false,false,false,true,true,'AddNote',url);

			}

		}else if(val == 'WIND'){

		 $.ajax({

				type: 'GET',

				async:false,

				url:base_url+'students/scripts/viewGroupNote.php',

				data: "show=yes&method=group&window=WINDOW&fileId="+filenm,

				success: function(data){

						$('#filewrapper').html(data);

					}

			});

	

		}

		else{

		 $.ajax({

				type: 'GET',

				async:false,

				url:base_url+'students/scripts/viewGroupNote.php',

				data: "show=yes&fileId="+fileid,

				success: function(data){

						$('#filewrapper').html(data);

					}

			});

	

		}

	}

	else {

		if(val == 'panel' || val == 'WIND'){

			jAlertMod("No saved Notes file was selected","Alert","&nbsp;OK&nbsp;",null);

		}else{

			filenm = '';

			url = base_url+ 'students/scripts/viewPage.php?method=group&fileId='+filenm;

			FP_openNewWindow(470,410,false,false,false,false,true,true,'AddNote',url);

		}

		

	}

}



function OpenNotes(val,val2)

{

      var fileid ='';

    $('.opennotesbody:checked').each(function(index)

    {		

		fileid = $(this).attr('name');

    });

	if(fileid!="") {

		if(val2 == 'yes'){

			url=base_url+ 'students/scripts/viewPage.php?method=view&fileId='+fileid,

			FP_openNewWindow(470,400,false,false,false,false,true,true,'AddNote',url);	

		}else{

     $.ajax({

            type: 'GET',

			async:false,

            url: base_url+ 'students/scripts/viewNote.php',

            data: "show=yes&fileId="+fileid+"&window="+val,

			success: function(data){

				$('#filewrapper').html(data);

	     	}

        });

		}



	}

	else {

		if(val2 == 'yes'){

			jAlertMod("Click the checkbox alongside citenotes before Expand","Alert","&nbsp;OK&nbsp;",null);

		}else{

			jAlertMod("Click the checkbox alongside citenotes before View","Alert","&nbsp;OK&nbsp;",null);

		}

	}

}



function OpenNotesback()

{

$.ajax({

            type: 'POST',

            url: base_url+ 'students/scripts/showAllNotes.php',

            data: "html=",

		success: function(data){

				$('#filewrapper').html(data);

	     			}

        });



}



function addslashes( str ) {   

  

    return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");   

} 



function DeleteSelectedfromDB()

{



	var n = $('.deletecitationbody:checked').length;

	if(n>0) {

		jConfirm('Are you sure that you want to delete the selected citation', 'Delete Citation', function(r9) {

			if(r9) {

					$('.deletecitationbody:checked').each(function(index)

					{

						$(this).parent().remove();

					});



						var content='{"filenames":[';



					$('span.fileNameOpen').each(function(index)

						{

						content=content+'{"filename":"'+$(this).attr("id")+'"';

						content=content+',"value":"';

						//$(this).parent('div').children('.citationbody').each(function(index)

						$('#c8Content .citation').each(function(index)

						{

							//alert('hhh');

							content=content+addslashes($.trim($(this).text()))+'|';

						});

						content=content+'"},';



				   });

					content = content.substring(0, content.length-1); 

					content=content+']}';

					content=content.replace(/&/g , "##");



						$.ajax({

							type: 'POST',

							async:false,

							url: base_url+ 'students/scripts/deldatabase.php',

							data: "html="+content,

							

							success: function(data){

							//alert(data);

		    	   			//fireAjaxRequest('students/scripts/showAllNotes.php','','formatHL=apa&act=CN','c8Content','');	

							}

						});



					//$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected')); 



			}

	}); 

	}

	else {

		jAlertMod("Click the checkbox alongside citations before Deleting","Alert","&nbsp;OK&nbsp;",null);

	}

}



function DeleteGroup(val)

{

    var fileid ='';

    $('.opennotesbody:checked').each(function(index)

    {

		fileid = $(this).attr('name');

		filenm = $(this).attr('id');

        

    });







if(fileid!="") {

	jConfirm('Are you sure you want to delete <b>'+filenm+'</b>', 'Delete Confirmation', function(r4) {

			if(r4) {

				$.ajax({

				type: 'GET',

				async:false,

				url: base_url+ 'students/scripts/delgroupnotesbyfileid.php?fileid='+filenm,

				success: function(data){

					

		    	   fireAjaxRequest('students/scripts/showAllNotes.php','','formatHL=apa&act=CN&window='+val,'c8Content','');	

				   if(val == 'WINDOW'){

					   	opener.fireAjaxRequest('students/scripts/showAllNotes.php','','formatHL=apa&act=CN','c8Content','');

				   }

			     }

			});



		//$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected')); 



	}

	});  

} else{

		jAlertMod("Click the checkbox alongside citenotes before Deleting","Alert","&nbsp;OK&nbsp;",null);

	}

}





function DeleteSelectedNotesfromDB(fileid,val,val1)

{//alert(fileid);

	filenm = '';

    if(fileid ==''){

		$('.opennotesbody:checked').each(function(index)

		{

			fileid = $(this).attr('name');

			filenm = $(this).attr('id');

			

		});

	}

//alert(fileid);

if(fileid!="") {

	

	jConfirm('Are you sure you want to delete <b>'+filenm+'</b>', 'Delete Confirmation', function(r4) {

			if(r4) {

				$.ajax({

				type: 'GET',

				async:false,

				url: base_url+ 'students/scripts/delnotesbyfileid.php?fileid='+fileid,

				success: function(data){

					if(val =='view'){

						 fireAjaxRequest("students/scripts/showAllNotes.php","","formatHL=apa&window="+val1,"c8Content","","CN");

						

					}else{

		    	  		 fireAjaxRequest('students/scripts/viewGroupNote.php','','formatHL=apa&act=CN&fileId='+filenm+'&window='+val1,'c8Content','');	

					}

					

					if(val1 == 'WINDOW'){

							opener.fireAjaxRequest("students/scripts/showAllNotes.php","","formatHL=apa&window="+val1,"c8Content","","CN");

					}

			     }

			});



		//$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected')); 



	}

	});  

} else{

		jAlertMod("Click the checkbox alongside citenotes before Deleting","Alert","&nbsp;OK&nbsp;",null);

	}

}





function DeleteSelectedfromDBFile()

{

    var fileid ='';

    $('.opencitationbody:checked').each(function(index)

    {

		fileid = $(this).attr('name');

		filenm = $(this).attr('id');

        

    });



section = getSectionName();



if(fileid!="") {

	jConfirm('Are you sure you want to delete <b>'+filenm+'</b>', 'Delete Confirmation', function(r4) {

			if(r4) {

				$.ajax({

				type: 'GET',

				async:false,

				url: base_url+ 'students/scripts/deldatabasebyfileid.php?fileid='+fileid

			});



		fireAjaxRequest('students/scripts/showAlldatabase.php','','formatHL='+section+'&format='+section,'c8Content','');

		//$("#savePanelUITabs").tabs('load', $("#savePanelUITabs").tabs('option', 'selected')); 



	}

	});  

} else{

		jAlertMod("Click the checkbox alongside citations before Deleting","Alert","&nbsp;OK&nbsp;",null);



}



}





function clearSvPanel()

{



    $("#svPnl").html("");

    $.ajax({

        type: 'POST',

        url: base_url+ 'students/scripts/savesession.php',

        data: "html="

    });

	$.ajax({

		type: 'POST',

		url: base_url+ 'students/scripts/deldatabase.php'

	});

	//$(".cssform input").spellchecker("remove");

	try{

				$(".cssform input").spellchecker("remove");

			}

			catch(e){

			}

}



function getInnerText(element1)

{

    return $("#"+element1).text();

}

function setInnerText(element1,str)

{

	//alert(str);

    if(document.getElementById(element1)!=null)

    {

        if(isIE())

        {

            document.getElementById(element1).innerText=str;

        }

        else

        {

            document.getElementById(element1).textContent=str;

        }

    }

}



function setFocus(element)

{

    document.getElementById(element).focus();

    document.getElementById(element).value = "";

}

function isIE()

{

    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))

        return true;

    else

        return false;



}



function onPgClose()

{

    

}



function CheckAll()

{

$('.deletecitationbody').attr('checked', true);

}



function UncheckAll()

{

$('.deletecitationbody').attr('checked', false);

}



Array.prototype.multiSort = function(index)

{

    // Written By: WillyDuitt@hotmail.com | 03-10-2005 \\;

    for(var i=0; i<this.length; i++)

    {

		$(this[i]);

        var temp = this[i].splice(index,1);

        this[i].unshift(temp);

    }

    return this.sort();

}



function clearClipBoard()

{

$(".stop2").click(function(e){

e.preventDefault();

	targetIE =e.target

	if(navigator.appName=="Microsoft Internet Explorer")

	{

	clearClipBoardfun(targetIE);

	}	

	else

	{

	window.location.href=e.target;

	}

});

}



function clearClipBoardfun(targetIE)

{

jConfirmMod('Do you want to clear the Clipboard?', 'Clear ClipBoard','&nbsp;Proceed&nbsp;', function(r7) {

			if(r7) {	

			window.clipboardData.clearData();

			window.location.href=targetIE;

			}

			else {

	            	window.location.href=targetIE;

				}

	});

}



function duplicateCitation2(){

var section=getSectionName();

//var filenm = filenm1;



var n = $('.opencitationbody:checked').length;

	  if(n>0){

		 filenm1 = $('.opencitationbody:checked').attr('name');

	  var content="GROUP";

	showFileNameSelection2(content,section,filenm1);

	}	

	else

	{jAlertMod("Click the checkbox alongside citations before using Save As functionality.","Alert","&nbsp;OK&nbsp;",null);}

}



function duplicateCitation3(filenm){

var section=getSectionName();

filenm1 = $('.opencitationbody:checked').attr('name');

var content1=$('#databaseE').val();

content = content1+"|";

showFileNameSelection2(content,section,filenm1);

	

}



function duplicateCitation(filenm1){



var section=getSectionName();

var filenm = filenm1;

var n = $('.deletecitationbody:checked').length;

	  if(n>0)

	{

	  var content="";

	  $('.deletecitationbody:checked').parent().each(function(index)

        {

			var inpt = $(this).html();

			var par = $(this);

			$(par).children('input').remove();

			content1 = $(par).html();

			$(par).html(inpt);

			content=content+content1+"|";

	    });

		content=content.replace(/&nbsp;/g , " ");

		content=content.replace(/&/g , "##");

		//alert(content);

		showFileNameSelection2(content,section,filenm1);

	}	

	else

	{jAlertMod("Click the checkbox alongside citations before using Save As functionality.","Alert","&nbsp;OK&nbsp;",null);}

}



function detectPubtype(){

var section = getSectionName();

$('.modernbricksmenu2 a').click(function(e)

{

var link1 = $('.modernbricksmenu2 a.selected').attr('href');

var link = link1.substring(0, link1.length-4);

var link=section+"/"+link; 

link = CapitalizeAfter(link,"/");

$('#linkDetect').html(link);

DetectSection2(link1);

});

}



function getFormData(frmID){

	// TODO add script to handle select / textarea in future development

	

	// get all the inputs into an array.

	var $inputs = $('#'+frmID+' :input');

	// not sure if you wanted this, but I thought I'd add it.

	// get an associative array of just the values.

	var values = {};

	$inputs.each(function() {

		if(this.type == 'checkbox'){

			if(this.checked==true){

				values[this.name] = $(this).val();

			}

		}else{

			values[this.name] = $(this).val();

		}

		//alert(this.type+"===="+this.name+"==="+$(this).val());

	});	

	return values;

}



function fireAjaxRequest(url,frmName,strData,divName,afterSuccessJS,ActiveTab){

	//alert(url);

	

	formData = '';

	if(frmName!=""){

		formData = getFormData(frmName);

	}else if(strData!=""){

		formData = strData;

	}

	//alert(formData);

	if(ActiveTab=='CN'){

		$('#t1').removeClass('active');

   		$('#t2').addClass('active');

		$('#t3').removeClass('active');

		$('#t4').removeClass('active');

		$('#t6').removeClass('active');

	}

	if(ActiveTab=='SF'){

		$('#t1').addClass('active');

		$('#t2').removeClass('active');

		$('#t3').removeClass('active');

		$('#t4').removeClass('active');

		$('#t6').removeClass('active');

	}

	if(ActiveTab=='CM'){

		$('#t1').removeClass('active');

		$('#t2').removeClass('active');

		$('#t3').addClass('active');

		$('#t4').removeClass('active');

		$('#t6').removeClass('active');

	}

	if(ActiveTab=='TW'){

		$('#t1').removeClass('active');

		$('#t2').removeClass('active');

		$('#t3').removeClass('active');

		$('#t4').addClass('active');

		$('#t6').removeClass('active');

	}

	

	

	$.ajax({

		type: "GET",

		url: base_url+url,

		data: formData,

		success: function(data){

			//alert(data);

			if(afterSuccessJS!=""){

				if(afterSuccessJS=='divnull'){

					//$('.content-bottom').html('');

					$("#"+divName).html(data);

				}else{

					//alert(afterSuccessJS + "('" + data + "');");

					eval(afterSuccessJS + "('" + data + "');");

				}

			}else{

				//alert(data);

				$("#"+divName).html(data);

				

			}

		}

	});

	return false;

}



function EditDatabase(id){

	var n = $('.deletecitationbody:checked').length;

	if(n==1){

	var arrID = $('.deletecitationbody:checked').attr('name');

		fireAjaxRequest("students/scripts/editdatabase.php","","fileid="+id+"&arrID="+arrID+"&edit=select","c8Content","")

	}else{

		jAlertMod("Click the checkbox alongside citations before using Edit.","Alert","&nbsp;OK&nbsp;",null);

	}



}

function SaveDatabase(id,arrID){

	section = getSectionName();

	dataval = $("#databaseE").val();

	

	dataval=dataval.replace(/&nbsp;/g , " ");

	dataval=dataval.replace(/&/g , "@@@");

	

	//alert(dataval);

	$.ajax({ type: "GET",   

		url: base_url+"students/scripts/editdatabase.php",   

		data: "fileid="+id+"&arrID="+arrID+"&dataval="+dataval+"&edit=edit",

		success : function(data){

			//alert(data);

			fireAjaxRequest("students/scripts/showAlldatabase.php","","formatHL="+section+"&format="+section+"","c8Content","","SF");

		}

	});	

}

function DatabaseEditButton(id,arrID){

	section = getSectionName();



$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:56px; width:465px' id='bottomfooter'><ul class='buttnav'><li><a><span onclick='SaveDatabase("+id+","+arrID+");'>Save</span></a></li><li><a><span onclick='duplicateCitation3("+id+");'>Save As</span></a></li><li class='active'><a><span onclick='return fireAjaxRequest(\"students/scripts/showAlldatabase.php\",\"\",\"formatHL="+section+"&format="+section+"\",\"c8Content\",\"\",\"SF\");'>MyList</span></a></li><!--<li><a><span onclick='DeleteSelectedfromDB();'>Delete</span></a></li><li><a><span onclick='LogoutHandler();'>Logout</span></a></li>--></ul></div>");

makeULCenter();

//init2();



}



function ShowButtons22(id){

	section = getSectionName();



$('#showBelowPanel').html(" <div class='content-bottom' style='padding-left:56px; width:465px' id='bottomfooter'><ul class='buttnav'><!--<li><a><span onclick='AddNoteFromCitations();return false;'>AddNote</span></a></li>--><li id='copyLi'><a onmouseover='CopyToClipBoard(2,\"Over\");' onmouseout='CopyToClipBoard(2,\"Out\");'><span>Copy</span></a></li><li><a><span onclick='EditDatabase("+id+");'>Edit</span></a></li><li><a href='#?w=310' rel='emailSec1' class='poplight'><span>E-Mail</span></a></li><li><a><span onclick='OpenMSWordExport1();'>MS Word</span></a></li><li><a><span onclick='PDFCopy();return false;'>PDF</span></a></li><!--<li><a><span onclick='makePrint(\"saved-panel\");'>Print</span></a></li>--><li><a><span onclick='duplicateCitation();'>Save As</span></a></li><li class='active'><a><span onclick='return fireAjaxRequest(\"students/scripts/showAlldatabase.php\",\"\",\"formatHL="+section+"&format="+section+"\",\"c8Content\",\"\",\"SF\");'>MyList</span></a></li><li><a><span onclick='DeleteSelectedfromDB();'>Delete</span></a></li><!--<li><a><span onclick='LogoutHandler();'>Logout</span></a></li>--></ul></div>");

makeULCenter();

//init2();



}



function ShowButtons33(val){

	//alert('33'+val);

	if(val == 'WINDOW'){

		OnExpand = '';

		OnClose = "<li><a><span onclick='window.close();return opener.fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa\",\"c8Content\",\"\",\"CN\");'>Close</span></a></li>";

		//OnLog = "opener.LogoutHandler();window.close();";

		OnLog = '<li><a><span onclick="opener.LogoutHandler();window.close();">Logout</span></a></li>';

		val2 = 'WIND';

		OnBook = "<li><a><span onclick='Bookmark2();'>BookMark</span></a></li>";

	}else{

		OnExpand = '<li><a><span onclick="OpenGroup(\'WINDOW\');">Expand</span></a></li>';

		OnClose = '';

		val = 'panel';

		val2 = 'panel';

		//OnLog = "LogoutHandler();";

		OnLog ="";

		OnBook = "";

	}

	

$('#showBelowPanel').html("<div class='content-bottom' width:421px;'><ul class='buttnav'><li class='active'><a><span onclick='return fireAjaxRequest(\"students/scripts/addNote.php\",\"\",\"fileId=0&current="+val+"\",\"c8Content\",\"\",\"CN\");'>AddNote</span></a></li><li><a><span onclick='OpenGroup(\""+val2+"\");'>Open</span></a></li>"+OnExpand+"<li><a><span onclick='makePrint(\"saved-panel\");'>Print</span></a></li><li><a><span onclick='DeleteGroup(\""+val+"\");'>Delete</span></a></li>"+OnBook+" "+OnClose+" "+OnLog+"</ul></div>");

makeULCenter();



}



function ShowButtons333(val){

	//alert('333'+val);

	if(val == 'WINDOW'){

		OnExpand = '';

		OnClose = "<li><a><span onclick='window.close();return opener.fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa\",\"c8Content\",\"\",\"CN\");'>Close</span></a></li>";

		OnLog = "opener.LogoutHandler();window.close();";

	}else{

		//OnExpand = "<li><a><span onclick='OpenGroup(\"WINDOW2\");'>Expand</span></a></li>";

		OnExpand = "<li><a><span onclick='OpenNotes(\"WINDOW\",\"yes\");'>Expand</span></a></li>";

		OnClose = '';

		val ='panel';

		OnLog = "LogoutHandler();";

	}

//openWindows

//EditNotes

$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:10px; width:400px;'><ul class='buttnav'><li class='active1'><a><span onclick='fireAjaxRequest(\"students/scripts/addNote.php\",\"\",\"fileId=0&current="+val+"\",\"c8Content\",\"\",\"CN\");'>AddNote</span></a></li><li class='active'><a><span onclick='OpenNotes(\""+val+"\");'>View</span></a></li><li><a><span onclick='EditNotes(\"\",\""+val+"\");'>Edit</span></a></li>"+OnExpand+"<li><a><span onclick='makePrint(\"saved-panel\");'>Print</span></a></li><li><a><span onclick='DeleteSelectedNotesfromDB(\"\",\"\",\""+val+"\");'>Delete</span></a></li><!--<li><a><span onclick='Bookmark2();'>BookMark</span></a></li>--><li><a><span onclick='return fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa&window="+val+"\",\"c8Content\",\"\",\"CN\");'>MyList</span></a></li><li><a><span onclick='"+OnLog+"'>Logout</span></a></li>"+OnClose+"</ul></div>");

makeULCenter();

}



function ShowButtons133(fid,val){

	//alert('133'+val);

	//var fid = $(this).attr('name');

	//val = 'update'

	//if(val == 'update'){

	//	fid = document.getElementById('filename').value;

	//}

	ExpandVar = "";

	OnClose ="";

	if(fid == 0){

		if(val == 'WINDOW'){

			ExpandVar = "";

			OnClose = "<li><a><span onclick='window.close();return opener.fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa\",\"c8Content\",\"\",\"CN\");'>Close</span></a></li>";

		}else{

			ExpandVar = "<li><a><span onclick='openWindows();'>Expand</span></a></li>";

			OnClose ="";

			val ="panel";

		}

		 fid = document.getElementById('filename').value;

	}else{

		if(val == 'WINDOW'){

			ExpandVar = "";

			OnClose = "<li><a><span onclick='window.close();return opener.fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa\",\"c8Content\",\"\",\"CN\");'>Close</span></a></li>";

		}else{

				val ="panel";

		}

	}

	OnReset ="";

	//OnReset ="<li><a><span onclick='return resetPanel(1);'>Reset</span></a></li>";

	

	

$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:78px; width:321px;'><ul class='buttnav'><li><a  id='aCheckSpell'><span>Spelling</span></a></li><li class='active'><a><span onclick='saveNotestoDB(\""+val+"\");'>Save</span></a></li><li><a><span onclick='resetPanel();'>Reset</span></a></li>"+ExpandVar+"<li><a><span onclick='return fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa&window="+val+"\",\"c8Content\",\"\",\"CN\");'>MyList</span></a></li>"+OnReset+" "+OnClose+"</ul></div>");

makeULCenter();

$("#aCheckSpell").click(function(e){

	callCheckSpell(e,1);

});



}

function resetPanel(val){

	if(val==1){

		$.ajax({ type: "POST",   

		url: base_url+"ajax.php",   

		data: "type=resetNoteSession"

		});		

	}

	theForm=document.forms['quicknote']; //quicknotes

	theForm.filename.value='';

	theForm.tagname.value='';

	theForm.url.value='';

	theForm.text.value='';

	$(".cssform input").spellchecker("remove");

	$(".cssform textarea").spellchecker("remove");

	return false;

}



function ShowButtons123(){

	$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:75px; width:445px;'><ul class='buttnav'><li class='active'><a><span onclick='RegisterAlert();'>Save</span></a></li><li><a><span onclick='openWindows();'>OpenNote</span></a></li><li><a><span onclick='RegisterAlert();'>Ms Word</span></a></li><li><a><span onclick='RegisterAlert();'>PDF</span></a></li><li><a><span onclick='RegisterAlert();'>Email</span></a></li><li><a><span onclick='Bookmark2();'>BookMark</span></a></li></ul></div>");

	makeULCenter();

}



function ShowButtons44(fileId,val){

	//alert('44'+val);

	if(val == 'WINDOW'){

		OnExpand = '';

		OnClose = "<li><a><span onclick='window.close();return opener.fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa\",\"c8Content\",\"\",\"CN\");'>Close</span></a></li>";

		OnPDF = "";

		onLogOut = "<li><a><span onclick='opener.LogoutHandler();window.close();'>Logout</span></a></li>";

	}else{

		OnExpand = "<li><a><span onclick='expandView("+fileId+",\"no\");'>Expand</span></a></li>";

		OnClose = '';

		val = 'panel';

		OnPDF = "";

		onLogOut = "";

	}

	$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:35px;width:370px;'><ul class='buttnav'><li><a><span onclick='EditNotes("+fileId+",\""+val+"\");'>Edit</span></a></li>"+OnExpand+"<li><a class='poplight' rel='emailSec2' href='#?w=310'><span onclick='showEmailDiv3();'>E-Mail</span></a></li><li><a><span onclick='OpenMSWordExportNotes();'>MS Word</span></a></li><li><a><span onclick='return OpenPDF();'>PDF</span></a></li><li><a><span onclick='makePrint(\"saved-panel\");'>Print</span></a></li><li class='active'><a><span onclick='return fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa&window="+val+"\",\"c8Content\",\"\",\"CN\");'>MyList</span></a></li><li><a><span onclick='DeleteSelectedNotesfromDB("+fileId+",\"view\",\""+val+"\");'>Delete</span></a></li>"+OnClose+onLogOut+"</ul></div><!--<li class='active1'><a><span onclick='OpenNotesback();'>Close</span></a></li>--><!--<li><a><span onclick='Bookmark2()'>BookMark</span></a></li>-->");

	makeULCenter();

}





function ShowButtons55(Log){

	//alert(Log);

	if(Log=='LOGIN'){

		$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:35px; width:370px;'><ul class='buttnav'><li><a href='#b8' onclick='LogoutHandler();'><span>Logout</span></a></li></ul></div>");

	}else{

		$('#showBelowPanel').html("<div class='content-bottom' style='padding-left:35px; width:370px;'><ul class='buttnav'><li><a href='#b8' onclick='return rigtTabContent(\"b8\");'><span>Login</span></a></li><li><a href='#b9' onclick='return rigtTabContent(\"b9\");'><span>Register</span></a></li></ul></div>");

	}

	

	   // $('#t1').removeClass('active');

		//$('#t2').removeClass('active');

		//$('#t3').removeClass('active');

		//$('#t4').removeClass('active');

		//$('#t6').addClass('active');

		

makeULCenter();

}



function openWindows(fileId,editflag){





//alert('oooo');

			var file="";



			if(fileId && fileId !="" && editflag && editflag=='true'){



				file =	base_url+"students/scripts/viewPage.php?fileId="+fileId+"&method=edit";



			}



			else if(fileId && fileId !="" && editflag && editflag=='false'){



				file =	base_url+"students/scripts/viewPage.php?fileId="+fileId+"&method=view";



				}



			else {



				file =	base_url+"students/scripts/viewPage.php?method=add";







			}



var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

var is_safari= navigator.userAgent.toLowerCase().indexOf('Safari')> -1;





if(is_chrome || is_safari)

{

	FP_openNewWindow(490,500,false,false,false,false,true,true,'AddNote',file);

}

else

{

	FP_openNewWindow(470,410,false,false,false,false,true,true,'AddNote',file);

}





}



var window1=null;



function FP_openNewWindow(w,h,nav,loc,sts,menu,scroll,resize,name,url){//v1.0



scroll = false;

var windowProperties=''; 



if(nav==false) windowProperties+='toolbar=no,';



else



windowProperties+='toolbar=yes,'; 







if(loc==false)



windowProperties+='location=no,'; 



else windowProperties+='location=yes,'; 







if(sts==false)



windowProperties+='status=no,';



else windowProperties+='status=yes,'; 







if(menu==false)



windowProperties+='menubar=no,';



else windowProperties+='menubar=yes,'; 







if(scroll==false)



windowProperties+='scrollbars=no,';



else windowProperties+='scrollbars=yes,'; 







if(resize==false)



windowProperties+='resizable=no,';



else windowProperties+='resizable=yes,'; 







if(w!="")



windowProperties+='width='+w+',';







if(h!="") windowProperties+='height='+h; 







if(windowProperties!="") { 



if( windowProperties.charAt(windowProperties.length-1)==',') 



windowProperties=windowProperties.substring(0,windowProperties.length-1);



}



window1 = window.open(url,name,windowProperties);



window1.moveTo(705,200);



if (window1)



{



window1.focus();



}



}





function setButton(arrButton,editID,EmailCallBackFn,leftPad){

	strHTML = '';

	if(arrButton.length>0){

		for(i=0;i<arrButton.length;i++){

			if(arrButton[i]=="btnEdit"){

				strHTML = strHTML + "<li><a><span onclick='openEditpanel("+editID+");'>Edit</span></a></li>";

			}else if(arrButton[i]=="btnClose"){

				strHTML = strHTML + "<li><a><span onclick='window.close();return opener.fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa\",\"c8Content\",\"\",\"CN\");'>Close</span></a></li>";

			}else if(arrButton[i]=="btnClose2"){

				strHTML = strHTML + "<li><a><span onclick='window.close();'>Close</span></a></li>";

			}else if(arrButton[i]=="btnEmail"){

				strHTML = strHTML + "<li><a><span onclick='"+EmailCallBackFn+"();'>E-Mail</span></a></li>";

			}else if(arrButton[i]=="btnEmailR"){

				strHTML = strHTML + "<li><a><span onclick='RegisterAlert();'>E-Mail</span></a></li>";

			}else if(arrButton[i]=="btnWord"){

				strHTML = strHTML + "<li><a><span onclick='OpenMSWordExportNotes();'>MS Word</span></a></li>";

			}else if(arrButton[i]=="btnWordR"){

				strHTML = strHTML + "<li><a><span onclick='RegisterAlert();'>MS Word</span></a></li>";

			}else if(arrButton[i]=="btnBookmark"){

				strHTML = strHTML + "<li><a><span onclick='Bookmark2()'>BookMark</span></a></li>";

			}else if(arrButton[i]=="btnPrint"){

				strHTML = strHTML + "<li><a><span onclick='makePrint(\"saved-panel\");'>Print</span></a></li>";

			}else if(arrButton[i]=="btnSave"){

				strHTML = strHTML + "<li><a><span onclick='saveNotestoDB("+editID+");'>Save</span></a></li>";

			}else if(arrButton[i]=="btnSaveR"){

				strHTML = strHTML + "<li><a><span onclick='RegisterAlert();'>Save</span></a></li>";

			}else if(arrButton[i]=="btnAddB"){

				strHTML = strHTML + "<li><a><span onclick='openWindow_Bookmark();'>AddNote</span></a></li>";

			}else if(arrButton[i]=="btnViewB"){

				strHTML = strHTML + "<li><a><span onclick='openViewfromBookmark();'>View</span></a></li>";

			}else if(arrButton[i]=="btnEditB"){

				strHTML = strHTML + "<li><a><span onclick='openEditfromBookmark();'>Edit</span></a></li>";

			}else if(arrButton[i]=="btnDeleteB"){

				strHTML = strHTML + "<li><a><span onclick='DeleteSelectedNotesfromDB();'>Delete</span></a></li>";

			}else if(arrButton[i]=="btnLogout"){

				strHTML = strHTML + "<li><a><span onclick='opener.LogoutHandler();window.close();'>Logout</span></a></li>";

			}else if(arrButton[i]=="btnMyList"){

				strHTML = strHTML + "<li class='active'><a ><span onclick='return fireAjaxRequest(\"students/scripts/showAllNotes.php\",\"\",\"formatHL=apa&window=WINDOW\",\"c8Content\",\"\",\"CN\");'>MyList</span></a></li>";

			}else if(arrButton[i]=="btnPDF"){

				strHTML = strHTML + "<li><a><span onclick='return OpenPDF(\"WINDOW\");'>PDF</span></a></li>";

			}else if(arrButton[i]=="btnPDFR"){

				strHTML = strHTML + "<li><a><span onclick='return RegisterAlert();'>PDF</span></a></li>";

			}

			else if(arrButton[i]=="btnSPL"){

				strHTML = strHTML + "<li><a id='aCheckSpell'><span>Spelling</span></a></li>";

				

			}

			else if(arrButton[i]=="btnReset"){

				strHTML = strHTML + "<li><a onclick='return resetPanel(1);'><span>Reset</span></a></li>";

				

			}

			

			

		}

		

		

		

		$(".buttnav").html(strHTML).css("padding-left",leftPad+"px");

		$(".buttnav li:first").addClass("active1");

	}

}



function Bookmark2(){



//var url = base_url+'students/apa/notes1.php';

var url = base_url;



var title = "WriteCite";



if (window.sidebar) { // firefox



             window.sidebar.addPanel(title, url,"");



		} else if( document.all ) { //MSIE



                window.external.AddFavorite( url, title);



        } else {



               alert("Sorry, your browser doesn't support this");



        }



}



function stayonTop(){



	if(window1){



	window1.focus();



	setTimeout("stayonTop()", 3000);



	}



}



function showEmailDiv3(){

	secID = 'emailSec2';

    document.getElementById(secID).style.display=(document.getElementById(secID).style.display!="block")? "block" : "none";



    document.getElementById('emailAddr2').value = "";



}



function OpenPDF(val){

	var content = "";



	$('#filediv2 form p').each(function(index){

		content= content+"<br/>"+$(this).html();			

	});

	content=content.replace(/&nbsp;/g , " ");

	content=content.replace(/&/g , "##");

	$.ajax({

		   type: 'POST',



		   async:false,



		   cache:false,



		   url: base_url+ 'students/scripts/savesessionNote.php',



           data: "html_notes="+content



	      });





		if(val=='WINDOW'){

			murl = base_url+'students/scripts/export_notePDF.php?time='+new Date().toString().substring(4,28);



			opener.window.open(murl,'mywindow','');

		}else{

			murl =base_url+'students/scripts/export_notePDF.php?time='+new Date().toString().substring(4,28);

		 	window.open(murl,'mywindow','');

		}



    		 return false;

}



function OpenMSWordExportNotes(){



			var content = "";



			



			$('#filediv2 form p').each(function(index)



		    {



			content= content+"<br/>"+$(this).html();			



			});











			content=content.replace(/&nbsp;/g , " ");



			content=content.replace(/&/g , "##");



			



			$.ajax({



               type: 'POST',



		   async:false,



		   cache:false,



		   url: base_url+ 'students/scripts/savesessionNote.php',



               data: "html_notes="+content



		   



	      });







		 window.location = base_url+ "students/scripts/exportNotes.php?time="+new Date().toString().substring(4,28);



    		 return false;



		



}



function emailNotes(){



	  var section=getSectionName();

	  var content = $('#filediv2').html();			



	  content="<div style='width: 600px; height: auto; text-indent: 30px; white-space: normal;'>"+content+"</div><br />"; 



		content=content.replace(/&nbsp;/g , " ");



		content=content.replace(/&/g , "##");



	var txtToEmail = "<div style='width:650px;padding-left:30px; margin-left:30px'>"+content+"</div>";



	txtToEmail = removeNewLine(txtToEmail);



	var emailAddr2 = document.getElementById('emailAddr2').value;



		var website = document.getElementById('website').value;



	

	if(echeck(emailAddr2))



	{

        var lngth = txtToEmail.length;



        document.getElementById('emailedData5').value = txtToEmail;

	

	$.ajax({

               type: 'POST',



		   async:false,



		   url: base_url+ 'students/scripts/phpMailerNotes.php',



               data: "html="+txtToEmail+"&emailAddr1="+emailAddr2+"&set=email2&format="+section+"&website="+website+"&time="+new Date().toString().substring(4,28),



		   success: function(data){

				//alert(data);

   				if(data =='An error has occured.' )



					{



                     jAlertMod("An error has occured, please report this to the website administrator.","Failure","&nbsp;OK&nbsp;",null);



					}



					else



				if(data =='Your WriteCite notes have been e-mailed.' )

				{

					  

					  $("img.btn_close").parent("a").trigger("click");

					 jAlertMod("Your WriteCite notes have been e-mailed. ","Success","&nbsp;OK&nbsp;",null);					

					  $('#fade , .popup_block').fadeOut(function() {

							$('#fade, a.close').remove();  //fade them both out

					  });



					}



			}					





	      });



	}



return false;		



}



function callCheckSpell(e,whichButton){

	e.preventDefault();

	$(".loading").show();

	if(whichButton==1){

		whatToCheck = '.textSpelling';

	}else if(whichButton==2){

		whatToCheck = '.cssform input';

	}

	$(whatToCheck)

	.spellchecker({

		url: base_url+'checkspelling.php',

		lang: "en",

		engine: "google",

		suggestBoxPosition: "above"

	})

	.spellchecker("check", function(result){

		$(".loading").hide();

	});

}





function makePrint(val){

	//alert(val);

	if(val == 'svPnl'){

		if($.trim($("#svPnl").text())=="")

		{

			jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);

			return false;

		}

	

		$('#svPnl').removeClass('noprint');

		$('#savedPanel').addClass('noprint');

		$('#b4').css('border','none');

		

	}else if(val == 'saved-panel'){

		

			$('#savedPanel').removeClass('noprint');

			$('#svPnl').addClass('noprint');

		

			//jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);

			

		

	}

	

	window.print();

}









function calcActualWidth(objUL){

	var sum = 0;

	$(objUL).children("li").each(function(i,e){

		sum += $(e).outerWidth(true);

	});

	return sum;

}



function makeULCenter(){

	var args = makeULCenter.arguments;

	if(args.length==1){

		mainDiv = args[0];

		//alert(mainDiv);

	}else{

		mainDiv = 'showBelowPanel';

	}

	widthDivP = $("#"+mainDiv).outerWidth();

	widthDiv = $("#"+mainDiv+" .content-bottom").outerWidth();

	//alert(widthDivP + "==" + widthDiv);

	if(widthDivP<widthDiv){

		widthDiv = widthDivP;

	}

	$("#"+mainDiv+" .content-bottom").css("width",widthDiv+"px");

	objUL = $("#"+mainDiv+" .content-bottom ul.buttnav");

	widthUL = calcActualWidth(objUL);

	//alert(widthDiv + "==" + widthUL);

	$("#"+mainDiv+" .content-bottom").css("padding-left","0px");

	$("#"+mainDiv+" .content-bottom ul.buttnav").css("padding-left","0px");

	$("#"+mainDiv+" .content-bottom ul.buttnav").css("padding-left",((widthDiv-widthUL)/2)+"px");

}



function FaceBookWallHandler(Log){

	dataL='';

	if(Log=='LOGIN'){

			dataL = 'LOG=LOGIN';

	}

	$.ajax({ type: "GET",   

		url: base_url+"students/scripts/showFBmassage.php",   

		data: dataL,

		async: true,

		cache: false,

		success : function(data1)

		{

			$('#c8Content').html(data1);

			$('ul#tabs2 li a').removeClass("active");

			$('ul#tabs2 li a#t6').addClass("active");

		}

	});

	return false;

}



//Copied from apa_functions.js & commented both functions from mla_functions.js & harvard_functions.js

/*function init() {

		

	clip11 = new ZeroClipboard.Client();

	

	clip11.setHandCursor( true );

	//alert(clip11);

	clip11.addEventListener('mouseOver', function (client) {//Complete

		// update the text on mouse over

		

		$("#d_clip_container").parent().addClass("active");

        var content="";

		if($.trim($("#svPnl").text())!="")

		{

			$('#svPnl .citation').each(function(index)

			{

				content=content+$.trim($(this).text())+"\r\n \r\n";

			});

		}

		else{

				//jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);

			//return false;

		}

		//alert(content);

		clip11.setText(content);



	});

	clip11.addEventListener('mouseOut', function (client) {

		$("#d_clip_container").parent().removeClass("active");

	});

	

	

	clip11.addEventListener('Complete', function () {

		if($.trim($("#svPnl").text())==""){

				jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);

				return false;

		}

	});

	

	clip11.glue('d_clip_button','d_clip_container');

}



function init2() {

	alert("dfff1");

	clip22 = new ZeroClipboard.Client();

	alert("dfff2");

	clip22.setHandCursor( true );

	clip22.addEventListener('mouseOver', function (client) {

		alert("dddddddd");

		// update the text on mouse over

		$("#d_clip_container1").parent().addClass("active");

        var content="";

        $('.citationbody').each(function(index)

        {

            content=content+$.trim($(this).text())+"\r\n \r\n";

        });

		alert(content);

		clip22.setText(content);

	});

	clip22.addEventListener('mouseOut', function (client) {

		$("#d_clip_container1").parent().removeClass("active");

	});

	clip22.glue( 'd_clip_button1', 'd_clip_container1' );

}

*/

function removeNewLine(str)

{

    str=str.replace(new RegExp( "\\n", "g" ),"").replace(new RegExp( "\\r", "g" ),"");

    return str;

}

function CountLeft(field, count, max) {

// if the length of the string in the input field is greater than the max value, trim it



field.value=field.value.replace(/\n/g , "");



	if (field.value.length > max)

	field.value = field.value.substring(0, max);

	else

	// calculate the remaining characters

	count = max - field.value.length;

	$('#left').html(count);

	

}



function AddEmail(){

	if(document.getElementById('temail1').value != "" && echeck(document.getElementById('temail1').value)){

		boolOpen2 = $("#rFp2").is(":visible");

		$("#rFp2").css({'display':'block'});

		$(".aReferAdd").hide();

		$("#rFp2 .aReferAdd").show();

		if(document.getElementById('temail2').value != "" && echeck(document.getElementById('temail2').value)){

			boolOpen3 = $("#rFp3").is(":visible");

			$("#rFp3").css({'display':'block'});

			$(".aReferAdd").hide();

			$("#rFp3 .aReferAdd").show();

			if(document.getElementById('temail3').value != "" && echeck(document.getElementById('temail3').value)){

				boolOpen4 = $("#rFp4").is(":visible");

				$("#rFp4").css({'display':'block'});

				$(".aReferAdd").hide();

				$("#rFp4 .aReferAdd").show();

				if(document.getElementById('temail4').value != "" && echeck(document.getElementById('temail4').value)){

					boolOpen5 = $("#rFp5").is(":visible");

					$("#rFp5").css({'display':'block'});

					$(".aReferAdd").hide();

					$("#rFp5 .aReferAdd").show();

					if(document.getElementById('temail5').value != "" && echeck(document.getElementById('temail5').value)){

						

						jAlertMod("You Can Use Maximum 5 Email ID.","Alert","&nbsp;OK&nbsp;",null);

					}

					else if(boolOpen5 && document.getElementById('temail5').value == ""){

						jAlertMod("Please Enter Email Address.","Alert","&nbsp;OK&nbsp;",null);

						$("#rFp5 .aReferAdd").show();

					}

				}

				else if(boolOpen4 && document.getElementById('temail4').value == ""){

					jAlertMod("Please Enter Email Address.","Alert","&nbsp;OK&nbsp;",null);

					$("#rFp4 .aReferAdd").show();

				}

			}

			else if(boolOpen3 && document.getElementById('temail3').value == ""){

				jAlertMod("Please Enter Email Address.","Alert","&nbsp;OK&nbsp;",null);

				$("#rFp3 .aReferAdd").show();

			}

		}

		else if(boolOpen2 && document.getElementById('temail2').value == ""){

			$("#rFp2 .aReferAdd").show();		

			jAlertMod("Please Enter Email Address.","Alert","&nbsp;OK&nbsp;",null);

		}

	}else if(document.getElementById('temail1').value == ""){

		$("#rFp1 .aReferAdd").show();

		jAlertMod("Please Enter Email Address.","Alert","&nbsp;OK&nbsp;",null);

	}		

	return false;

}


