// JavaScript Document
function setInText(textName,divName,other){
	fromat = getSectionName();
	$('#wrapintext').css('display','block');
	pageAlias = "";
	
	if(fromat == 'apa'){
		strAPA1 = "(%%A%%, %%Y%%, %%PN%%)";
		strAPA2 = "%%A%% (%%Y%%, %%PN%%)";
		pageAlias = "p.";
		auLim = 7;
	}
	else if(fromat == 'harvard'){
		//For harvard there is no comma after Author and only a comma after year. Also, there is no "p." or "pp" before page numbers. 
		strAPA1 = "(%%A%% %%Y%%, %%PN%%)";
		strAPA2 = "%%A%% (%%Y%%, %%PN%%)";
		auLim = 5;
	}
	else if(fromat == 'mla'){
		//For MLA - no year or "p" or "pp" - before page number9s) appear. There is also no commas. Egs. Author (Page) or (Author Page)
		strAPA1 = "(%%A%%  %%PN%%)";
		strAPA2 = "%%A%% (%%PN%%)";
		auLim = 5;
	}
	
	/*cFocus = '';
	$(":input").focus(function () {
		cFocus  = this.id;
	});*/


	//start alert logic
	if(!document.ignoreA){
			document.ignoreA = 0;
	}
	for(AL=2;AL<auLim;AL++){
		IAF = 'ignoreA'+AL;
		if(!eval("document." + IAF)){
			eval("document." + IAF+" = 0;");
			//alert(eval("document." + IAF+""));
		}
	}
	
	if(!document.ignoreE){
			document.ignoreE = 0;
	}
	for(EL=2;EL<10;EL++){
		IEF = 'ignoreE'+EL;
		if(!eval("document." + IEF)){
			eval("document." + IEF+" = 0;");
		}
	}
	
	if(!document.ignoreT){
			document.ignoreT = 0;
	}
	for(TL=2;TL<10;TL++){
		ITF = 'ignoreT'+TL;
		if(!eval("document." + ITF)){
			eval("document." + ITF+" = 0;");
		}
	}
	
	if(!document.ignoreP){
			document.ignoreP = 0;
	}
	for(PL=2;PL<10;PL++){
		IPF = 'ignoreP'+PL;
		if(!eval("document." + IPF)){
			eval("document." + IPF+" = 0;");
		}
	}
	//end alert logic
	
	strAuthor = '';
	Authors = new Array();
	strAuthorArr = '';
	strYear = '';
	strPage = '';
	boolAuthor = true;
	j=0;
	theForm = $('#publicationtype').html();
	defaultArr = new Array('author','editor','trans','producer','publisher');
	newDefArr = new Array();
	/*keys  = new Array();
	for(k=0;k<defaultArr.length;k++){
		eee = theForm.search(new RegExp(defaultArr[k], "i"));
		if(eee != -1){
			newDefArr[eee] = defaultArr[k];
		}
	}
	
	newDefArr.sort(function (a,b){return (a>b - b<a)});
	cnt = 0;
	for(m=0;m<newDefArr.length;m++){
		if(newDefArr[m]){
			keys[cnt++] = newDefArr[m];
		}
	}

	for(n=0;n<keys.length;n++){
		if(keys[n] == "author"){
			if(document.getElementById("author")){
				if($('#author').val() != ''){
					boolAuthor = false;
				}else{
					if(document.getElementById('author2') && $('#author2').val() != ''){
						boolAuthor = false;
					}
				}
				
				if(boolAuthor == false){
					strAuthor = $('#CiteAuthor').html();
					strAuthor = Authorfilter(strAuthor);
					htmls = $('#VirCiteAuthor').html();
					
					for(au=2;au<auLim;au++){
						if(document.getElementById('CiteAuthor'+au)){
							tmphtml = $('#CiteAuthor'+au).html();
							tmpstrAuthor = Authorfilter(tmphtml);
							htmls = htmls.replace(tmphtml,tmpstrAuthor);
						}
					}
					
					strAuthor = strAuthor+htmls.replace(/<[\/]{0,1}(span|Span|SPAN)[^><]*>/g,"");
					
				}
			}
		}
		
		if(keys[n] == "editor"){
			if(boolAuthor && document.getElementById("editor")){
				if($('#editor').val() != ''){
					boolAuthor = false;
				}else{
					if(document.getElementById('editor2') && $('#editor2').val() != ''){
						boolAuthor = false;
					}
				}
				
				if(boolAuthor == false){
					strAuthor = $('#CiteEditor').html();
					strAuthor = Authorfilter(strAuthor);
					htmls = $('#VirCiteEditor').html();
					
					for(au=2;au<auLim;au++){
						if(document.getElementById('CiteEditor'+au)){
							tmphtml = $('#CiteEditor'+au).html();
							tmpstrAuthor = Authorfilter(tmphtml);
							htmls = htmls.replace(tmphtml,tmpstrAuthor);
						}
					}
					
					strAuthor = strAuthor+htmls.replace(/<[\/]{0,1}(span|Span|SPAN)[^><]*>/g,"");
				}
			}
		}
		
		if(keys[n] == "trans"){
			if(boolAuthor && document.getElementById("trans")){
				if($('#trans').val() != ''){
					boolAuthor = false;
				}else{
					if(document.getElementById('trans2') && $('#trans2').val() != ''){
						boolAuthor = false;
					}
				}
				
				if(boolAuthor == false){
					strAuthor = $('#CiteTrans').html() + $('#CiteTra').html();//CiteTra
					strAuthor = Authorfilter(strAuthor);
					htmls = $('#VirCiteTrans').html();
					
					for(au=2;au<auLim;au++){
						if(document.getElementById('CiteTrans'+au)){
							tmphtml = $('#CiteTrans'+au).html();
							tmpstrAuthor = Authorfilter(tmphtml);
							htmls = htmls.replace(tmphtml,tmpstrAuthor);
						}
					}
					
					//alert(htmls);
					strAuthor = strAuthor+htmls.replace(/<[\/]{0,1}(span|Span|SPAN)[^><]*>/g,"");
					//alert(strAuthor);
				}
			}
		}
		
		if(keys[n] == "producer"){
			if(boolAuthor && document.getElementById("producer")){
				if($('#producer').val() != ''){
					boolAuthor = false;
				}else{
					if(document.getElementById('producer2') && $('#producer2').val() != ''){
						boolAuthor = false;
					}
				}
				
				if(boolAuthor == false){
					strAuthor = $('#CiteProducer').html();
					strAuthor = Authorfilter(strAuthor);
					htmls = $('#VirCiteProducer').html();
					
					for(au=2;au<auLim;au++){
						if(document.getElementById('CiteProducer'+au)){
							tmphtml = $('#CiteProducer'+au).html();
							tmpstrAuthor = Authorfilter(tmphtml);
							htmls = htmls.replace(tmphtml,tmpstrAuthor);
						}
					}
					
					strAuthor = strAuthor+htmls.replace(/<[\/]{0,1}(span|Span|SPAN)[^><]*>/g,"");
				}
			}
		}
		
		if(keys[n] == "publisher"){
			if(boolAuthor && document.getElementById("publisher")){
				strAuthor = $('#CitePublisher').html();
				boolAuthor = false;
			}
		}
	}*/
	
			if((document.getElementById('author') && $('#author').val() != '') || (document.getElementById('author2') && $('#author2').val() != '')){
				strAuthor = $('#author').val();
				if(other == true || document.ignoreA==1){
					strAuthor = Authorfilter(strAuthor);
				}else{
					strAuthor = AuthorAlert(strAuthor,textName,'','A');
				}
			
				for(au=2;au<auLim;au++){
					if(document.getElementById('author'+au) && document.getElementById('author'+au).value != ''){
						if(au > 2){
							strAuthor = strAuthor.replace(' &',',');
						}
						iaf = 'ignoreA'+au;		
						if(other == true || eval("document." + iaf)==1){
							strAuthor = strAuthor +' & '+Authorfilter(document.getElementById('author'+au).value);
						}else{
							strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('author'+au).value,textName,au,'A');
						}
					
						if(au == auLim-1){
							strAuthor = strAuthor + ' et al.';
						}
					}
				}
				//boolAuthor = false;
			}
			else if((document.getElementById('editor') && $('#editor').val() != '') || (document.getElementById('editor2') && $('#editor2').val() != '')){
				strAuthor = $('#editor').val();
				if(other == true || document.ignoreE==1){
					strAuthor = Authorfilter(strAuthor);
				}else{
					strAuthor = AuthorAlert(strAuthor,textName,'','E');
				}
				for(au=2;au<auLim;au++){
					if(document.getElementById('editor'+au) && document.getElementById('editor'+au).value != ''){
						if(au > 2){
							strAuthor = strAuthor.replace(' &',',');
						}
						iaf = 'ignoreE'+au;		
						if(other == true || eval("document." + iaf)==1){
							strAuthor = strAuthor +' & '+Authorfilter(document.getElementById('editor'+au).value);
						}else{
							strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('editor'+au).value,textName,au,'E');
						}
						//strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('editor'+au).value);
					}
				}
				//boolAuthor = false;
			}
			else if((document.getElementById('trans') && $('#trans').val() != '') || (document.getElementById('trans2') && $('#trans2').val() != '')){
				strAuthor = $('#trans').val();
				if(other == true || document.ignoreT==1){
					strAuthor = Authorfilter(strAuthor);
				}else{
					strAuthor = AuthorAlert(strAuthor,textName,'','T');
				}
				for(au=2;au<auLim;au++){
					if(document.getElementById('trans'+au) && document.getElementById('trans'+au).value != ''){
						if(au > 2){
							strAuthor = strAuthor.replace(' &',',');
						}
						iaf = 'ignoreT'+au;		
						if(other == true  || eval("document." + iaf)==1){
							strAuthor = strAuthor +' & '+Authorfilter(document.getElementById('trans'+au).value);
						}else{
							strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('trans'+au).value,textName,au,'T');
						}
						//strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('trans'+au).value);
					}
				}
				//boolAuthor = false;
			}
			else if((document.getElementById('producer') && $('#producer').val() != '') || (document.getElementById('producer2') && $('#producer2').val() != '')){
				strAuthor = $('#producer').val();
				if(other == true  || document.ignoreP==1){
					strAuthor = Authorfilter(strAuthor);
				}else{
					strAuthor = AuthorAlert(strAuthor,textName,'','P');
				}
				for(au=2;au<auLim;au++){
					if(document.getElementById('producer'+au) && document.getElementById('producer'+au).value != ''){
						if(au > 2){
							strAuthor = strAuthor.replace(' &',',');
						}
						iaf = 'ignoreP'+au;		
						if(other == true  || eval("document." + iaf)==1){
							strAuthor = strAuthor +' & '+Authorfilter(document.getElementById('producer'+au).value);
						}else{
							strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('producer'+au).value,textName,au,'P');
						}
						//strAuthor = strAuthor +' & '+AuthorAlert(document.getElementById('producer'+au).value);
					}
				}
				//boolAuthor = false;
			}
			else if(document.getElementById('title') && $('#title').val() != ''){
				strAuthor = $('#title').val();
			}
			else if(document.getElementById('chapter') && $('#chapter').val() != ''){
				strAuthor = $('#chapter').val();
			}
			/*else if(document.getElementById('subject') && $('#subject').val() != ''){
				strAuthor = $('#subject').val();
				strAuthor = Authorfilter(strAuthor);
			}*/
			else if(document.getElementById('publisher') && $('#publisher').val() != ''){
				strAuthor = $('#publisher').val();
				strAuthor = Authorfilter(strAuthor);
			}
	
	
	
	if(document.getElementById("year")){
		strYear = $('#year').val();
	}
	if(document.getElementById("pageBook")){
		strPage = $('#pageBook').val();
	}
	else if(document.getElementById("page")){
		if($('#page').val() != 'afterlogin1.php'){
			strPage = $('#page').val();
		}
	}
	
	//strAuthor = AuthorfilterComma(strAuthor);
	
	if(strAuthor == '.' || strAuthor == '' || !strAuthor){
		//strAuthor = strAuthor.replace(/([A-Z])/g, '#$1');
		strAPA1 = strAPA1.replace('%%A%%' , '');
		strAPA2 = strAPA2.replace('%%A%%' , '');
		strAPA2 = strAPA2.trim();
	}else{
		strAuthor = strAuthor.replace('&nbsp;' , '');
		strAPA1 = strAPA1.replace('%%A%%' , strAuthor);
		strAPA2 = strAPA2.replace('%%A%%' , strAuthor);
		//strAPA2 = strAPA2.replace('&nbsp;' , ''); //RD Add line 16 Jan
		strAPA2 = strAPA2.trim();
	}
	
	//alert(strAPA2);
	if(strYear == ''){
		strAPA1 = strAPA1.replace('%%Y%%' , 'n.d.');	
		strAPA2 = strAPA2.replace('%%Y%%' , 'n.d.');	
	}else{
		strAPA1 = strAPA1.replace('%%Y%%' , strYear);	
		strAPA2 = strAPA2.replace('%%Y%%' , strYear);	
	}
	
	//alert(strPage);
	if(strPage == ''){
		//alert('kkk');
		if(fromat == 'apa'){
			strAPA1 = strAPA1.replace(', %%PN%%' , '');
			strAPA2 = strAPA2.replace(', %%PN%%' , '');
		}else if(fromat == 'harvard'){
			strAPA1 = strAPA1.replace(', %%PN%%' , '');
			strAPA2 = strAPA2.replace(', %%PN%%' , '');
		}else if(fromat == 'mla'){
			strAPA1 = strAPA1.replace('%%PN%%' , '');
			strAPA2 = strAPA2.replace('%%PN%%' , '');
		}
	}else{
		strAPA1 = strAPA1.replace('%%PN%%' , strPage); //pageAlias+
		strAPA2 = strAPA2.replace('%%PN%%' , pageAlias+strPage);
	}
	
	$('#in_radio1').html('<input type="checkbox" name="radio1" id="radio1" checked="checked" />&nbsp;<span id="txt1">'+strAPA1+'</span>');
	$('#in_radio2').html('<input type="checkbox" name="radio2" id="radio2" checked="checked"/>&nbsp;<span id="txt2">'+strAPA2+'</span>');	
	if((strAuthor == '' && strYear == '' && strPage=='')){
		$('#in_radio1').html('');
		$('#in_radio2').html('');
	}
}


function AuthorAlert(str,field,au,who){
	//alert(document.ignoreA2);
	format = getSectionName();
	msg = 'APA formats personal authors as Last Name, First Name';
	//replace(/<[\/]{0,1}(span|Span|SPAN)[^><]*>/g,"");

	str1 = str.replace(' ','_');
	str1 = str1.replace('.','_');
	var re1 = new RegExp('^[A-z]_');
	var re2 = new RegExp('^[A-z | 0-9]+,');
	//var re = new RegExp(',','g');
	var m1 = re1.exec(str1);
	var m2 = re2.exec(str);

	  if (m1 == null && m2 == null) {
			return Authorfilter(str);
			return false;
	  }else {
		   jConfirmMod(msg, 'Alert' ,'&nbsp;OK&nbsp;', function(c1) {
    		if(c1)
    		{
				setInText('','',true);
				IaFF = 'ignore'+who;
				eval("document." + IaFF+" = 1;");
				IaF = 'ignore'+who+au;
				eval("document." + IaF+" = 1;");
				document.IaF=1;
				return false;
			}	
			else{
				
				$('#'+field).val('');
				setInText('','',true);
				//document.ignoreA=1;
				return false;
			}
			});
	  }
}
function Authorfilter(str){
	format = getSectionName();
	if(str != ''){
		word = new Array();
		word=str.split(" ");//Ra, T
		
		if(word.length>1){
			//alert(word[word.length-1].length);
			//alert(word[word.length-1]);	
			if(word[0].length == 1 && word[1].length == 1){
				narray2 = new Array();
					for(i=0;i<word.length;i++){
						if(word[i].length ==1){
							narray2[i] = word[i]+'.';
						}else{
							narray2[i] = word[i];
						}
					}
					return BeCapital(narray2.join(' ').replace(',',''));
				//return BeCapital(str.replace(',','').trim());
			}
			else if(word[word.length-1].length == 1 || word[word.length-2].length == 1){
				if(word[word.length-1].length == 1){
					narray1 = new Array();
					for(k=0;k<word.length;k++){
						if(word[k].length >1){
							narray1[k] = word[k];
						}
					}
					return BeCapital(narray1.join(' ').replace(',',''));
				}else{
					narray = new Array();
					for(j=0;j<word.length;j++){
						if(word[j].length ==1){
							narray[j] = word[j]+'.';
						}else{
							narray[j] = word[j];
						}
					}
					return BeCapital(narray.join(' ').replace(',',''));
					//return BeCapital(str);
					//return BeCapital(word[0].replace(',','').trim());
				}
			}
			else{
				return BeCapital(str.replace(',','').trim());
			}
		}else{
			return BeCapital(str.replace(',','').trim());
		}
	}else{
		return '';
	}
}

function setintext_session(val){
	html = $('#txt'+val).html();
	html=html.replace(/&/g , "##");
	$.ajax({ 
			type: "POST",   
			url: base_url+"ajax.php",   
			data: "type=setintextsession&val="+html,
			success: function(data){
				//alert(data);
			}
		});
}
function saveIntextpreview(srcPnlID , destPnlID, log){
	
	if(log==true){
		if(document.getElementById('radio1') && document.getElementById('radio1').checked){
			setintext_session(1);
		}
		if(document.getElementById('radio2') && document.getElementById('radio2').checked){
			setintext_session(2);
		}
		$('#in_radio1').html('');
		$('#in_radio2').html('');
		$('#wrapintext').css('display','none');
		
		$.ajax({ 
				type: "POST",   
				url: base_url+"ajax.php",   
				data: "type=getintextsession",
				success: function(data){
				
					//if(data != ''){ $('#navid').removeClass('inline30');}
					
					$('#intext_content').html(data);
					GetIntext();
				}
			});
	}	
	
	
	/*$(".citation")
	.spellchecker({
			lang: "en",
			engine: "google"
	})
	.spellchecker("check");*/
}
function DeleteSelectedintext()
{
	var n = $('.chkIntext:checked').length;
    if(n>0){
		dataArr = new Array();
		cnt = 0;
		$('.chkIntext:checked').each(function(index){
			dataArr[cnt++] = $(this).val();
		});
		$.ajax({ 
			type: "POST",   
			url: base_url+"ajax.php",   
			data: "type=deleteintext&datastr="+dataArr,
			success: function(data){
				GetIntext();
			}
		});		
		
	}
	else {
		if(!$('#intext_content').html()){
			jAlertMod("Click save at foot of form before clicking Delete.","Alert","&nbsp;OK&nbsp;",null);
		}else{
			jAlertMod("Click the checkbox alongside in-text before Delete","Alert","&nbsp;OK&nbsp;",null);
		}
	}
return false;
}
function GetIntext(){
	$.ajax({ 
			type: "POST",   
			url: base_url+"ajax.php",   
			data: "type=getintextsession",
			success: function(data){
				if(data == ''){
					//$('#navid').addClass('inline30');
				}else{
					//$('#navid').removeClass('inline30');
				}
				$('#intext_content').html(data);
			}
		});				
}
function copy_intext() {
	var n = $('.chkIntext:checked').length;
    if(n>0){
	clip5 = new ZeroClipboard.Client();
	clip5.setHandCursor( true );
	clip5.addEventListener('mouseOver', function (client) {
										   
	$("#clip_div").parent().addClass("active");
	var content="";
	if($.trim($("#intext_content").text())!="")
	{
		/*$('#intext_content .intexts').each(function(index)
		{
			content=content+$.trim($(this).text())+"\r\n \r\n";
		});*/
		
		$('.chkIntext:checked').parent().each(function(index){
			content=content+$.trim($(this).text())+"\r\n \r\n";
		})
	
	}
	else{
			
		clip5.addEventListener('Complete', function () {
				if($.trim($("#intext_content").text())==""){
						jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);
						return false;
				}
		});
	}
	//alert(content);
	clip5.setText(content);

	});
	clip5.addEventListener('mouseOut', function (client) {
		$("#clip_div").parent().removeClass("active");
	});
	
	//Complete //load
	clip5.addEventListener('load', function () {
		if($.trim($("#intext_content").text())==""){
				jAlertMod("No citation found. Save your citation(s) first.","Alert","&nbsp;OK&nbsp;",null);
				return false;
		}
	});
	
	clip5.glue('clip_button','clip_div');
	}else {
		if(!$('#intext_content').html()){
			jAlertMod("Click save at foot of form before clicking Copy.","Alert","&nbsp;OK&nbsp;",null);
		}else{
			jAlertMod("Click the checkbox alongside in-text before clicking Copy","Alert","&nbsp;OK&nbsp;",null);
		}
	}
}
function BeCapital(str){
	s = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
			return letter.toUpperCase();//+'.'
		});
	return s;
}
function ACAlert(){
	var n = $('.chkIntext:checked').length;
    if(n == 1){
		dataArr = new Array();
		cnt = 0;
		$('.chkIntext:checked').each(function(index){
			dataArr[cnt++] = $(this).val();
		});
		$.ajax({ 
			type: "POST",   
			url: base_url+"ajax.php",   
			data: "type=setAddNoteStr&datastr="+dataArr,
			success: function(data){
				jAlertMod1("Enter your CiteNote in the lower right hand panel","Alert","&nbsp;Proceed&nbsp;",null);
				fireAjaxRequest("students/scripts/addNote.php","","fileId=0&current=panel","c8Content","","CN");
				//alert(data);
				var int=self.setInterval("$('#tagname').val('"+data+"')",1000);
				var int2=self.setInterval("clearInterval('"+int+"')",1200);
			}
		});		
		
	}
	else {
		if(!$('#intext_content').html()){
			jAlertMod("Click save at foot of form before clicking add CiteNote.","Alert","&nbsp;OK&nbsp;",null);
		}else{
			if(n<=0){
				jAlertMod("Click the checkbox alongside in-text before adding CiteNote","Alert","&nbsp;OK&nbsp;",null);
			}else{
				jAlertMod("Click only one checkbox for adding CiteNote.","Alert","&nbsp;OK&nbsp;",null);
			}
		}
		
	}
	return false;
}
function getACButton(){
	$.ajax({ 
			type: "POST",   
			url: base_url+"ajax.php",   
			data: "type=suffelAddbutton",
			success: function(data){
				$('#intext_addcite').html(data);
			}
		});		
}
function clearIntext(){
	$(".cssform input").spellchecker("remove");
	
	$('#in_radio1').html('');
	$('#in_radio2').html('');
}
function email_intext(){
  var section=getSectionName();
  var content="";
  $('.chkIntext: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: 600px; height: auto; text-indent: -30px; white-space: normal;'>"+content1+"</div><br />"; 
		content=content+content1;
		//content=content.replace("&nbsp;",""); 


	});
	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 emailAddr1 = document.getElementById('mail_id').value;
	if(echeck(emailAddr1)){
        var lngth = txtToEmail.length;
        document.getElementById('emailedData5').value = txtToEmail;
		$.ajax({
               type: 'POST',
			   async:false,
			   url: base_url+ 'students/scripts/phpMailer.php',
               data: "html="+txtToEmail+"&emailAddr1="+emailAddr1+"&set=email1&format="+section+"&time="+new Date().toString().substring(4,28),
		  	 success: function(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 references have been e-mailed.' ){
				  jAlertMod("Your WriteCite references have been e-mailed. ","Success","&nbsp;OK&nbsp;",null);					 
				}
				$('#fade , .popup_block').fadeOut(function() {
						$('#fade, a.close').remove();  //fade them both out
					});
			}					
	      });
	}
return false;		
}

$(document).ready(function(){
	GetIntext();	
	getACButton();
});



//am = "To copy and paste you will need to use keyboard commands.\nOn a PC Ctrl+C or Ctrl+P\nOn a Mac Command+C or Command+P";
am = "To copy text into fields use the following keyboard commands\nOn a PC type <b>Ctrl P</b> and on a Mac type <b>Command P</b>.";
// do not edit below this line
// ===========================
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"

function nrc(e) {
	//alert(e)
	//alert(e.which)
   if (bNS && e.which > 1){
     jAlertMod1(am,"Alert","&nbsp;OK&nbsp;",null);
      return false
   } else if (bIE && (event.button >1)) {
     jAlertMod1(am,"Alert","&nbsp;OK&nbsp;",null);
     return false;
   }
}
document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;

//Authorfilter2 is use for preview filter
function Authorfilter2(str){
	words = new Array();
	words=str.split(" ");
	if(words.length>1){
		if(words[words.length-1].length < 5){
			words[words.length-1] = words[words.length-1];
			tstr = words.join(" ");//RD .replace(',','')
			return tstr;
		}else{
			words[words.length-1] = words[words.length-1].replace('.','');
			tstr = words.join(" ");//.replace(',','')
			return tstr;
		}
	}else{
		str =  str.replace('.','');
		return str; //.replace(',','')
	}
}

function AuthorfilterComma(str){
	words = new Array();
	words=str.split(",");
	if(words.length>1){
		return words[0];
	}
	return str;
}
