var msgAlert = 0;

function loadImage(){
	var searchKeyword=document.search.keyword.value;
	if(document.search.source.value=='0')
	{
		alert('Please select the source.');
		document.search.source.focus();
		return false;
	}

	var quote= new Array(5)
	quote[0]='Find a book by title, author, or ISBN...';
	quote[1]='Find a magazine article by title...';
	quote[2]='Find a newspaper article by title...';
	quote[3]='Find a scholarly journal article by title...';
	quote[4]='Find a film by title, director, or actor...';
	var x=0;
	for (x=0; x<5; x++)
	{
		if(quote[x]==searchKeyword){
			alert('Please enter search keyword.');
			document.search.keyword.focus();
			return false;
			break;
		}
	}
	
	if (document.search.keyword.value=='')
	{
		alert('Please enter any keyword');
		document.search.keyword.focus();
		return false;
	}
	else
	{
		document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
		AjaxLoadData();
	}
}

function loadImage2(e){
	if (e.keyCode=="13")
	{
		if(document.search.source.value=='0')
		{
			alert('Please select the source.');
			document.search.source.focus();
			return false;
		}
		else
		{
			document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
			AjaxLoadData();
		}
	}
}

function advSearchBox(e,frm)
	{
		if (e.keyCode=="13")
		{
			AdvSearchLoader(frm);
		}
	}
function AdvSearchLoader(form){	
	var strReturn='';
	var cnt=0;
	var keyword=form.keyword.value;
	var format=form.format.value;
	if(keyword==''){
		alert('Please enter search keyword.');
		return false;
	}
	if(form.book.checked == true || form.journal.checked == true || form.newspaper.checked == true || form.magazine.checked == true || form.film.checked == true)
	{
		cnt++;
	}
	
	if(cnt==0)
	{
		alert('Please select at least one source.');
		return false;
	}

	pst = 'keyword='+keyword;
	var book='<div id="book"><div class="common_item_expand" style="float:left;"><div class="item_heading">Book</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var journal = '<div id="journal"><div class="common_item_expand" style="float:left;"><div class="item_heading">Journal</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var newspaper = '<div id="newspaper"><div class="common_item_expand" style="float:left;"><div class="item_heading">Newspaper</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var magazine = '<div id="magazine"><div class="common_item_expand" style="float:left;"><div class="item_heading">Magazines</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var film = '<div id="film"><div class="common_item_expand" style="float:left;"><div class="item_heading">Film</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	if(form.book.checked){
		strReturn=strReturn+book;
		//pst = pst+'&book=book'+'&format='+format;
		pst = pst+'&book=book';
	}
	if(form.journal.checked){
		strReturn=strReturn+journal;
		//pst = pst+'&journal=journal'+'&format='+format;
		pst = pst+'&journal=journal';
	}

	if(form.newspaper.checked){
		strReturn=strReturn+newspaper;
		//pst = pst+'&newspaper=newspaper'+'&format='+format;
		pst = pst+'&newspaper=newspaper';
	}

	if(form.magazine.checked){
		strReturn=strReturn+magazine;
		//pst = pst+'&magazine=magazine'+'&format='+format;
		pst = pst+'&magazine=magazine';
	}
	if(form.film.checked){
		strReturn=strReturn+film;
		//pst = pst+'&film=film'+'&format='+format;
		pst = pst+'&film=film';
	}
	    document.getElementById('searchResults').innerHTML=strReturn;

		pst = pst+'&format='+format;
		AjaxLoadSearchData(pst);

	//if(form.book.checked)
/*
	if(form.journal.checked)
		AdvSearchJournal(pst);

	if(form.newspaper.checked)
		AdvSearchNewspaper(pst);

	if(form.magazine.checked)
		AdvSearchMagazine(pst);

	if(form.film.checked)
		AdvSearchFilm(pst);*/
}
function EditAdvSearchLoader(keyword,format,source1,source2,source3,source4,source5){	
	var strReturn='';
	var cnt=0;
	var keyword=keyword;
	var format=format;
	if(keyword==''){
		alert('Please enter search keyword.');
		return false;
	}
	if(source1 !='')
	{
		cnt++;
	}
	
	if(cnt==0)
	{
		alert('Please select at least one source.');
		return false;
	}

	pst = 'keyword='+keyword;
	var book='<div id="book"><div class="common_item_expand" style="float:left;"><div class="item_heading">Book</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var journal = '<div id="journal"><div class="common_item_expand" style="float:left;"><div class="item_heading">Journal</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var newspaper = '<div id="newspaper"><div class="common_item_expand" style="float:left;"><div class="item_heading">Newspaper</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var magazine = '<div id="magazine"><div class="common_item_expand" style="float:left;"><div class="item_heading">Magazines</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	var film = '<div id="film"><div class="common_item_expand" style="float:left;"><div class="item_heading">Film</div><div class="showing_numbers">Loading....</div></div><div class="blue_strip_ne clear"></div><div style="padding-left:30px;margin-top:10px;"><img src="images/ajax-loader.gif"></div></div>';

	if(source1=='book'){
		strReturn=strReturn+book;
		//pst = pst+'&book=book'+'&format='+format;
		pst = pst+'&book=book';
	}
	
	if(source2=='journal'){
		strReturn=strReturn+journal;
		//pst = pst+'&journal=journal'+'&format='+format;
		pst = pst+'&journal=journal';
	}

	if(source3=='newspaper'){
		strReturn=strReturn+newspaper;
		//pst = pst+'&newspaper=newspaper'+'&format='+format;
		pst = pst+'&newspaper=newspaper';
	}

	if(source4=='magazine'){
		strReturn=strReturn+magazine;
		//pst = pst+'&magazine=magazine'+'&format='+format;
		pst = pst+'&magazine=magazine';
	}
	if(source5=='film'){
		strReturn=strReturn+film;
		//pst = pst+'&film=film'+'&format='+format;
		pst = pst+'&film=film';
	}

	    document.getElementById('searchResults').innerHTML=strReturn;

		pst = pst+'&format='+format;
		
		AjaxLoadSearchData(pst);

}
function expandDiv(div1,div2){
	document.getElementById(div1).style.display="";
	document.getElementById(div2).style.display="";
	var divNumberId="";
	if (div1=="smallbook")
		divNumberId="divNumberShowBook";
	else if (div1=="smalljournal")
		divNumberId="divNumberShowJournal";
	else if (div1=="smallnewspaper")
		divNumberId="divNumberShowNewspaper";
	else if (div1=="smallmagazine")
		divNumberId="divNumberShowMagazine";
	else if (div1=="smallfilm")
		divNumberId="divNumberShowFilm";
	document.getElementById(divNumberId).innerHTML="1-10";
}
function collapseDiv(div1,div2){
	document.getElementById(div1).style.display="";
	document.getElementById(div2).style.display="none";
	var divNumberId="";
	if (div1=="smallbook")
		divNumberId="divNumberShowBook";
	else if (div1=="smalljournal")
		divNumberId="divNumberShowJournal";
	else if (div1=="smallnewspaper")
		divNumberId="divNumberShowNewspaper";
	else if (div1=="smallmagazine")
		divNumberId="divNumberShowMagazine";
	else if (div1=="smallfilm")
		divNumberId="divNumberShowFilm";
	document.getElementById(divNumberId).innerHTML="1-2";
}
function SearchResults(){	
		document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
		AjaxLoadSearchData();
}
function switchAutoMode(){
	val = document.search.source.value;
	if(val !='Book' && val !='Magazine' && val!='Newspaper' && val!='Journal' && val!='Film'){
		document.search.source.selectedIndex = 0;
	}
	 document.getElementById('tabs').innerHTML = '<a href="#" onClick="javascript:setDefaultText();"><img src="images/white_autocite_tab.gif" border="0" /></a>&nbsp;<a href="javascript:;" onclick="manualEntry()"><img src="images/green_maual_entry_tab.gif" width="134" height="26" border="0" /></a>&nbsp;<a href="advance_search.php"><img src="images/green_search_tab.gif" width="134" height="26" border="0" /></a>';
	 document.getElementById('findbook').style.display ="";
	 document.getElementById('searchResults').innerHTML ='';
}

function setDefaultText(val){
	if(document.getElementById('findbook').style.display =="none"){
		manualEntry();
	}
	if(val !='Book' && val !='Magazine' && val!='Newspaper' && val!='Journal' && val!='Film'){
		manualEntry();
	
	}
	
	if(val=='')
		val = document.search.source.value;
	switch(val){
		case 'Book':
			document.search.keyword.value='Find a book by title, author, or ISBN...';
		break;
		case 'Magazine':
			document.search.keyword.value='Find a magazine article by title...';
		break;
		case 'Newspaper':
			document.search.keyword.value='Find a newspaper article by title...';
		break;
		case 'Journal':
			document.search.keyword.value='Find a scholarly journal article by title...';
		break;
		case 'Film':
			document.search.keyword.value='Find a film by title, director, or actor...';
		break;		
		default:
			document.search.keyword.value='';
	}
}

function setDefaultTextAdvSearch(val){
	if(val !='Book' && val !='Magazine' && val!='Newspaper' && val!='Journal' && val!='Film'){
		manualEntry();
	}
	else if(val =='Book' || val =='Magazine' || val=='Newspaper' || val=='Journal' || val=='Film'){
		self.location='search.php';
	}
	
	if(val=='')
		val = document.search.source.value;

	switch(val){
		case 'Book':
			document.search.keyword.value='Find a book by title, author, or ISBN...';
		break;
		case 'Magazine':
			document.search.keyword.value='Find a magazine article by title...';
		break;
		case 'Newspaper':
			document.search.keyword.value='Find a newspaper article by title...';
		break;
		case 'Journal':
			document.search.keyword.value='Find a scholarly journal article by title...';
		break;
		case 'Film':
			document.search.keyword.value='Find a film by title, director, or actor...';
		break;		
		default:
			document.search.keyword.value='';
	}
}

function editDetail(name,author,publisher,city,date,fname,mi,lname,type,annotation,selectedformat){
	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	pst = 'name='+name+'&fname='+fname+'&mi='+mi+'&lname='+lname+'&publisher='+publisher+'&city='+city+'&date='+date+'&type='+type+'&annotation='+annotation+'&selectedformat='+selectedformat;
	//alert(pst);
	AjaxAutofill(pst);
}

function editDetailMagazine(name,date,type,annotation,selectedformat,link){
	var arrName=new Array();
	var arrlen=0;
	if(name !=''){
		var arrName = name.split("-");
		var arrlen = arrName.length;
	}

	var MagazineName='';
	var title='';

	if(arrlen > 1){
		MagazineName = arrName[0];
		title = '';
		var i;
		for(i=1;i< arrlen;i++){
			title += arrName[i]+' ';
		}
	}else{
		MagazineName = arrName[0];
		title = '';
	}
	if(document.getElementById('searchsource')){
		document.getElementById('searchsource').value='Magazine';
	}
	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	pst = 'name='+MagazineName+'&title='+title+'&date='+date+'&type='+type+'&annotation='+annotation+'&selectedformat='+selectedformat+'&link='+link;
	AjaxAutofill(pst);
}

function editDetailNews(name,date,type,annotation,selectedformat,link){
	var arrName=new Array();
	var arrlen=0;
	if(name !=''){
		var arrName = name.split("-");
		var arrlen = arrName.length;
	}
	var NewspaperName='';
	var title='';
	if(arrlen > 1){
		NewspaperName = arrName[0];
		title = '';
		var i;
		for(i=1;i< arrlen;i++){
			title += arrName[i]+' ';
		}
	}else{
		NewspaperName = arrName[0];
		title = '';
	}
	if(document.getElementById('searchsource')){
		document.getElementById('searchsource').value='Magazine';
	}
	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	title=trim(title);
	pst = 'name='+NewspaperName+'&title='+title+'&date='+date+'&type='+type+'&annotation='+annotation+'&selectedformat='+selectedformat+'&link='+link;

	AjaxAutofill(pst);
}


function editDetailJournal(jname,atitle,pdate,volume,issue,pagenum,from,to,fname,mi,lname,type,annotation,selectedformat,link){

	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	//pst = 'name='+JournalName+'&title='+title+'&date='+date+'&type='+type+'&annotation='+annotation+'&link='+link;
	pst = 'name='+jname+'&title='+atitle+'&date='+pdate+'&volume='+volume+'&issue='+issue+'&pagenum='+pagenum+'&from='+from+'&to='+to+'&fname='+fname+'&mi='+mi+'&lname='+lname+'&type='+type+'&annotation='+annotation+'&selectedformat='+selectedformat+'&link='+link;
	//alert(pst);
	AjaxAutofill(pst);
}


function editDetailFilm(name,catalog,distributor,actor,director,date,type,annotation,selectedformat){
	var arrName=new Array();
	var arrlen=0;
	if(director !=''){
		var arrName = director.split(" ");
		var arrlen = arrName.length;
		var lastElement	= arrlen-1;	
	}
	var fname='';
	var lname='';

	if(arrlen > 1){
		lname = arrName[arrlen -1];
		var i;
		var fname='';
		for(i=0;i<lastElement;i++){
			fname += arrName[i]+' ';
		}
	}else{
		fname = director;
		lname = '';
	}

	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	pst = 'name='+name+'&fname='+fname+'&lname='+lname+'&catalog='+catalog+'&distributor='+distributor+'&actor='+actor+'&director='+director+'&date='+date+'&type='+type+'&annotation='+annotation+'&selectedformat='+selectedformat;
	AjaxAutofill(pst);
}


function AddToSession(){
	AjaxAddToSession();
}

function OpenInPopUp(url,mwidth,mheight)
	{
	var url = url;
		objSubWin2=window.open(url,"","width="+mwidth+"px,height="+mheight+"px,resizable=0,scrollbars=1");
		if(!objSubWin2) 
		{
			alert("Please disable Popup Blocker.");
		}
		else objSubWin2.focus(); 
	}

function addElement() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);

  newdiv.innerHTML = '<label>First Name </label><input type="text" style="margin-right:10px;" name="fname[]"/><label class="general_label">Middle Initial</label><input type="text" class="midInt" name="minitial[]"/><label>Last Name </label><input type="text" name="lname[]"/><a href=\'#\' onclick=\'removeElement("'+divIdName+'")\'><img src="images/delete_author_btn.gif" border="0"></a><div class="clear"></div>';
  ni.appendChild(newdiv);
}

function removeElement(divNum) {
document.getElementById(divNum).style.display="none";
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}

function removeDirectAuthors(divNum) {
document.getElementById(divNum).style.display="none";
var d = document.getElementById('loadNames');
var olddiv = document.getElementById(divNum);
	 d.removeChild(olddiv);
}

function addElement_APA() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);

  newdiv.innerHTML = '<label style="margin-left:60px;">First Initial </label><input type="text" style="margin-right:10px;" name="fname[]" class="midInt"/><label>Middle Initial</label><input type="text" class="midInt" name="minitial[]"/><label>Last Name </label><input type="text" name="lname[]"/><a href=\'#\' onclick=\'removeElement_APA("'+divIdName+'")\'><img src="images/delete_author_btn.gif" border="0"></a><div class="clear"></div>';
  ni.appendChild(newdiv);
}

function removeElement_APA(divNum) {
document.getElementById(divNum).style.display="none";
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}

function showhide(divId){
	if(divId=='authorinfo'){
		document.getElementById('authorinfo').style.display='';
		document.getElementById('newsservice').style.display='none';
	}else if(divId=='newsservice'){
		document.getElementById('newsservice').style.display='';
		document.getElementById('authorinfo').style.display='none';	
	}else if(divId=='noauthor'){
		document.getElementById('newsservice').style.display='none';
		document.getElementById('authorinfo').style.display='none';	
	}
}

function manualEntry(){
	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	var sourceType;
	if(document.getElementById('source')){
		sourceType=document.getElementById('source').value;
	}
	var annotation;
	if(document.getElementById('annotation').checked==true)
	{
		annotation='yes';
	}
	else
	{
		annotation='no';
	}
	var pst;
	formatSelectd=document.getElementById('format').value;
	
	if(formatSelectd=='MLA')
	{
		switch(sourceType){
			case 'Book':
				pst='pagename=manual_book.tpl&annotation='+annotation;
			break;
			case 'BookEdited':
				pst='pagename=manual_book_edited.tpl&annotation='+annotation;
			break;
			case 'Magazine':
				pst='pagename=manual_magazine.tpl&annotation='+annotation;
			break;
			case 'Newspaper':
				pst='pagename=manual_newspaper.tpl&annotation='+annotation;
			break;
			case 'Journal':
				pst='pagename=manual_journal.tpl&annotation='+annotation;
			break;
			case 'Film':
				pst='pagename=manual_film.tpl&annotation='+annotation;
			break;
			case 'Interview':
				pst='pagename=other_interview.tpl&annotation='+annotation;
			break;
			case 'Entertainment':
				pst='pagename=other_radio.tpl&annotation='+annotation;
			break;
			case 'Encyclopedia':
				pst='pagename=other_encyclopedia.tpl&annotation='+annotation;
			break;
			case 'Anthology':
				pst='pagename=other_anthology.tpl&annotation='+annotation;
			break;
			case 'Brochure':
				pst='pagename=other_broucher.tpl&annotation='+annotation;
				break;
			case 'Cartoon':
				pst='pagename=other_cartoon.tpl&annotation='+annotation;
				break;
			case 'ComputerProgram':
				pst='pagename=other_computer_program.tpl&annotation='+annotation;
				break;
			case 'Dissertation':
				pst='pagename=other_dissertation.tpl&annotation='+annotation;
				break;
			case 'EMail':
				pst='pagename=other_email.tpl&annotation='+annotation;
				break;
			case 'Advertisement':
				pst='pagename=other_advertisement.tpl&annotation='+annotation;
				break;
			case 'ChapterBook':
				pst='pagename=other_chapterbook.tpl&annotation='+annotation;
				break;
			case 'DissertionAbstract':
				pst='pagename=other_dissertion_abstract.tpl&annotation='+annotation;
				break;
				break;
			case 'Mud':
				pst='pagename=other_mud.tpl&annotation='+annotation;
				break;
				break;
			case 'Map':
				pst='pagename=other_map.tpl&annotation='+annotation;
				break;
			case 'Goverment':
				pst='pagename=other_goverment.tpl&annotation='+annotation;
				break;
			case 'Lecture':
				pst='pagename=other_lecture.tpl&annotation='+annotation;
				break;
			case 'LetterToEditor':
				pst='pagename=other_lettertoeditor.tpl&annotation='+annotation;
				break;
			case 'Film':
				pst='pagename=manual_film.tpl&annotation='+annotation;
				break;		
			case 'Painting':
				pst='pagename=other_painting.tpl&annotation='+annotation;
				break;		
			case 'MusicalComposition':
				pst='pagename=other_musicalcomposition.tpl&annotation='+annotation;
				break;		
			case 'InternetDatabase':
				pst='pagename=other_internetdatabase.tpl&annotation='+annotation;
				break;		
			case 'PrivateOrganization':
				pst='pagename=other_privateorganization.tpl&annotation='+annotation;
				break;		
			case 'OnlinePeriodical':
				pst='pagename=other_onlineperiodical.tpl&annotation='+annotation;
				break;		
			case 'WebDocument':
				pst='pagename=other_webdocument_new.tpl&annotation='+annotation;
				break;	
			case 'DatabaseArticle':
				pst='pagename=other_database_article.tpl&annotation='+annotation;
				break;	
			case 'Review':
				pst='pagename=other_review.tpl&annotation='+annotation;
				break;
			default:
				pst='pagename=manual_book.tpl&annotation='+annotation;
		}
	}
	else if(formatSelectd=='APA')
	{
		switch(sourceType){
			case 'Advertisement':
				pst='pagename=other_advertisement.tpl&annotation='+annotation;
				break;
			case 'Anthology':
				pst='pagename=other_anthology_apa.tpl&annotation='+annotation;
			break;
			case 'Book':
				pst='pagename=manual_book_apa.tpl&annotation='+annotation;
			break;
			case 'BookEdited':
				pst='pagename=manual_book_edited.tpl&annotation='+annotation;
			break;
			case 'Brochure':
				pst='pagename=other_broucher.tpl&annotation='+annotation;
				break;
			case 'Cartoon':
				pst='pagename=other_cartoon.tpl&annotation='+annotation;
				break;
			case 'ChapterBook':
				pst='pagename=other_chapterbook_apa.tpl&annotation='+annotation;
				break;
			case 'ComputerProgram':
				pst='pagename=other_computer_program.tpl&annotation='+annotation;
				break;
			case 'Dissertation':
				pst='pagename=other_dissertation.tpl&annotation='+annotation;
				break;
			case 'DissertionAbstract':
				pst='pagename=other_dissertion_abstract.tpl&annotation='+annotation;
				break;
			case 'EMail':
				pst='pagename=other_email.tpl&annotation='+annotation;
				break;
			case 'Encyclopedia':
				pst='pagename=other_encyclopedia.tpl&annotation='+annotation;
				break;
			case 'Entertainment':
				pst='pagename=other_radio_apa.tpl&annotation='+annotation;
				break;
			case 'Film':
				pst='pagename=manual_film_apa.tpl&annotation='+annotation;
				break;
			case 'Interview':
				pst='pagename=other_interview.tpl&annotation='+annotation;
				break;
			case 'Journal':
				pst='pagename=manual_journal_apa.tpl&annotation='+annotation;
				break;
			case 'Magazine':
				pst='pagename=manual_magazine_apa.tpl&annotation='+annotation;
				break;
			case 'Newspaper':
				pst='pagename=manual_newspaper_apa.tpl&annotation='+annotation;
				break;			
			case 'Map':
				pst='pagename=other_map.tpl&annotation='+annotation;
				break;
			case 'Mud':
				pst='pagename=other_mud.tpl&annotation='+annotation;
				break;
			case 'Goverment':
				pst='pagename=other_goverment.tpl&annotation='+annotation;
				break;
			case 'Lecture':
				pst='pagename=other_lecture.tpl&annotation='+annotation;
				break;
			case 'LetterToEditor':
				pst='pagename=other_lettertoeditor_apa.tpl&annotation='+annotation;
				break;
			case 'Painting':
				pst='pagename=other_painting.tpl&annotation='+annotation;
				break;		
			case 'MusicalComposition':
				pst='pagename=other_musicalcomposition.tpl&annotation='+annotation;
				break;		
			case 'InternetDatabase':
				pst='pagename=other_internetdatabase.tpl&annotation='+annotation;
				break;		
			case 'PrivateOrganization':
				pst='pagename=other_privateorganization.tpl&annotation='+annotation;
				break;		
			case 'OnlinePeriodical':
				pst='pagename=other_onlineperiodical.tpl&annotation='+annotation;
				break;		
			case 'WebDocument':
				pst='pagename=other_webdocument.tpl&annotation='+annotation;
				break;	
			case 'DatabaseArticle':
				pst='pagename=other_database_article_apa.tpl&annotation='+annotation;
				break;	
			case 'Review':
				pst='pagename=other_review_apa.tpl&annotation='+annotation;
				break;
			default:
				pst='pagename=manual_book_apa.tpl&annotation='+annotation;
		}
	}
	else if(formatSelectd=='Chicago')
	{
		switch(sourceType)
		{
			case 'Anthology':
				pst='pagename=other_anthology_chicago.tpl&annotation='+annotation;
			break;
			case 'Book':
				pst='pagename=manual_book_chicago.tpl&annotation='+annotation;
			break;
			case 'ChapterBook':
				pst='pagename=other_chapterbook.tpl&annotation='+annotation;
				break;
			case 'DatabaseArticle':
				pst='pagename=other_database_article_chicago.tpl&annotation='+annotation;
			break;
			case 'EMail':
				pst='pagename=other_email_chicago.tpl&annotation='+annotation;
				break;
			case 'Film':
				pst='pagename=manual_film_chicago.tpl&annotation='+annotation;
				break;
			case 'Goverment':
				pst='pagename=other_goverment_chicago.tpl&annotation='+annotation;
				break;
			case 'Magazine':
				pst='pagename=manual_magazine_chicago.tpl&annotation='+annotation;
			break;
			case 'Newspaper':
				pst='pagename=manual_newspaper_chicago.tpl&annotation='+annotation;
			break;
			case 'Interview':
				pst='pagename=other_interview_chicago.tpl&annotation='+annotation;
			break;
			case 'Journal':
				pst='pagename=manual_journal_chicago.tpl&annotation='+annotation;
			break;
			case 'Sound':
				pst='pagename=other_sound.tpl&annotation='+annotation;
				break;
			case 'Encyclopedia':
				pst='pagename=other_encyclopedia.tpl&annotation='+annotation;
			break;
			case 'WebDocument':
				pst='pagename=other_webdocument_chicago.tpl&annotation='+annotation;
				break;
			default:
				pst='pagename=manual_book_chicago.tpl&annotation='+annotation;
		}
	}
		
	ManualPageLoad(pst);
	
		
	//ChangingAPA();
}

function validateRegistrationForm(form){
	//var regEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;	
	var regEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;	

	if (checkempty(form.existuser.value)==false)
	{
		alert("Please choose unique user");
		form.email.focus();
		return false;

	}
	if (checkempty(form.email.value)==true){
		alert('Please enter a valid email address.');
		form.email.focus();
		return false;
	//}else if (checkemail(form.email.value)==false){
    }else if (!regEmail.test(form.email.value)){
		alert('Please enter a valid email address.');
		form.email.focus();
		return false;
	}else if(checkempty(form.password.value)==true){
		alert('Please enter Password.');
		form.password.focus();
		return false;
	}else if(checkempty(form.confpassword.value)==true){
		alert('Please enter Confirm Password.');
		form.confpassword.focus();
		return false;
	}else if(form.confpassword.value!=form.password.value){
		alert('Password Mismatch.');
		form.confpassword.focus();
		return false;
	}else if(checkempty(form.fname.value)==true){
		alert('Please enter first name.');
		form.fname.focus();
		return false;
	}else if(checkempty(form.lname.value)==true){
		alert('Please enter last name.');
		form.lname.focus();
		return false;
	}
	return true;
}

function validateProjects(form){

	if (checkempty(form.pname.value)==true){
		alert('Please enter a Project Name.');
		form.pname.focus();
		return false;
	}
	return true;
}

function validateLoginForm(form){
	//var regEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;	
	var regEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;	
	 if ((!regEmail.test(form.email.value)) || (form.email.value=='')){
		alert('Please enter a valid email address.');
		form.email.focus();
		return false;	
	}else if(form.password.value ==''){
		alert('Password field is blank');
		form.password.focus();
		return false;
	}

	return true;
}

function validatePass(form){	
	if(form.oldpassword.value==''){
		alert('Old password field is blank');
		form.oldpassword.focus();
		return false;
	}else if(form.newpassword.value==''){
		alert('New password field is blank');
		form.newpassword.focus();
		return false;

	}else if(form.newpassword.value !== form.confpassword.value ){
		alert('Password Mismatch');
		form.confpassword.focus();
		return false;

	}
	return true;
}

function forgotPass(form){	
	//var regEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;	
	var regEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;	
	 if ((!regEmail.test(form.email.value)) || (form.email.value=='')){
		alert('Invalid email address.');
		form.email.focus();
		return false;
	}
	return true;
}

function validateAdminLoginForm(form){
	 //if (form.email.value==''){
		 
	 if (checkempty(form.email.value)==true){
		alert('Please enter a valid Username.');
		form.email.focus();
		return false;	
	}else if(checkempty(form.password.value)==true){
		alert('Please enter your Password.');
		form.password.focus();
		return false;
	}

	return true;
}


function loadOtherPage(){
	var page=document.search.source.value;
	//alert(page);
	document.getElementById('searchResults').innerHTML = '<img src="images/wait.gif" style="margin-left:270px; margin-top:60px;">';
	var annotation;
	if(document.getElementById('annotation').checked==true)
	{
		annotation='yes';
	}
	else
	{
		annotation='no';
	}
	var pst;
	switch(page){
		case 'Interview':
			pst='pagename=other_interview.tpl&annotation='+annotation;
		break;
		case 'Entertainment':
			pst='pagename=other_radio.tpl&annotation='+annotation;
		break;
		case 'Encyclopedia':
			pst='pagename=other_encyclopedia.tpl&annotation='+annotation;
		break;
		case 'otherSource':
			pst='pagename=other_source.tpl&annotation='+annotation;
		break;
		case 'Anthology':
			pst='pagename=other_anthology.tpl&annotation='+annotation;
		break;
		case 'Broucher':
			pst='pagename=other_broucher.tpl&annotation='+annotation;
			break;
		case 'Cartoon':
			pst='pagename=other_cartoon.tpl&annotation='+annotation;
			break;
		case 'ComputerProgram':
			pst='pagename=other_computer_program.tpl&annotation='+annotation;
			break;
		case 'Dissertation':
			pst='pagename=other_dissertation.tpl&annotation='+annotation;
			break;
		case 'EMail':
			pst='pagename=other_email.tpl&annotation='+annotation;
			break;
		case 'Advertisement':
			pst='pagename=other_advertisement.tpl&annotation='+annotation;
			break;
		case 'ChapterBook':
			pst='pagename=other_chapterbook.tpl&annotation='+annotation;
			break;
		case 'DissertionAbstract':
			pst='pagename=other_dissertion_abstract.tpl&annotation='+annotation;
			break;
			break;
		case 'Mud':
			pst='pagename=other_mud.tpl&annotation='+annotation;
			break;
			break;
		case 'Map':
			pst='pagename=other_map.tpl&annotation='+annotation;
			break;
		case 'Goverment':
			pst='pagename=other_goverment.tpl&annotation='+annotation;
			break;
		case 'Lecture':
			pst='pagename=other_lecture.tpl&annotation='+annotation;
			break;
		case 'LetterToEditor':
			pst='pagename=other_lettertoeditor.tpl&annotation='+annotation;
			break;
		case 'Film':
			pst='pagename=manual_film.tpl&annotation='+annotation;
			break;		
		case 'Painting':
			pst='pagename=other_painting.tpl&annotation='+annotation;
			break;		
		case 'MusicalComposition':
			pst='pagename=other_musicalcomposition.tpl&annotation='+annotation;
			break;		
		case 'InternetDatabase':
			pst='pagename=other_internetdatabase.tpl&annotation='+annotation;
			break;		
		case 'PrivateOrganization':
			pst='pagename=other_privateorganization.tpl&annotation='+annotation;
			break;		
		case 'OnlinePeriodical':
			pst='pagename=other_onlineperiodical.tpl&annotation='+annotation;
			break;		
		case 'WebDocument':
			pst='pagename=other_webdocument.tpl&annotation='+annotation;
			break;	
		case 'DatabaseArticle':
			pst='pagename=other_database_article.tpl&annotation='+annotation;
			break;	
	}
	OtherPageLoad(pst);
}


function LoadEditPage(source,elementId){
	if(source==''){
		return false;
	}
	annotation='yes';	
	var pst;

	formatSelectd=document.getElementById('format').value;
	if (formatSelectd=="MLA")
	{
		switch(source){
			case 'Book':
				pst='pagename=manual_book.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'BookEdited':
				pst='pagename=manual_book_edited.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Magazine':
				pst='pagename=manual_magazine.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Newspaper':
				pst='pagename=manual_newspaper.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Journal':
				pst='pagename=manual_journal.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Film':
				pst='pagename=manual_film.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'Interview':
				pst='pagename=other_interview.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Entertainment':
				pst='pagename=other_radio.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Encyclopedia':
				pst='pagename=other_encyclopedia.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'otherSource':
				pst='pagename=other_source.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Anthology':
				pst='pagename=other_anthology.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Broucher':
			case 'Brochure':
				pst='pagename=other_broucher.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Cartoon':
				pst='pagename=other_cartoon.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'ComputerProgram':
				pst='pagename=other_computer_program.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Dissertation':
				pst='pagename=other_dissertation.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'EMail':
				pst='pagename=other_email.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Advertisement':
				pst='pagename=other_advertisement.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'ChapterBook':
				pst='pagename=other_chapterbook.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'DissertionAbstract':
				pst='pagename=other_dissertion_abstract.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;	
				break;
			case 'Mud':
				pst='pagename=other_mud.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Map':
				pst='pagename=other_map.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Goverment':
				pst='pagename=other_goverment.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Lecture':
				pst='pagename=other_lecture.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'LetterToEditor':
				pst='pagename=other_lettertoeditor.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Film':
				pst='pagename=manual_film.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'Painting':
				pst='pagename=other_painting.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'MusicalComposition':
				pst='pagename=other_musicalcomposition.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'InternetDatabase':
				pst='pagename=other_internetdatabase.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'PrivateOrganization':
				pst='pagename=other_privateorganization.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'OnlinePeriodical':
				pst='pagename=other_onlineperiodical.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'DatabaseArticle':
				pst='pagename=other_database_article.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;	
			case 'WebDocument':
				pst='pagename=other_webdocument_new.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;	
			case 'Review':
				pst='pagename=other_review.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;	
			case 'Sound':
				pst='pagename=other_sound.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;	

		}
	}
	else if (formatSelectd=="APA")
	{
		
		switch(source){

			case 'Anthology':
				pst='pagename=other_anthology_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'Book':
				pst='pagename=manual_book_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			
			case 'Brochure':
			case 'Broucher':
				pst='pagename=other_broucher.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'ChapterBook':
				pst='pagename=other_chapterbook_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'ComputerProgram':
				pst='pagename=other_computer_program.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'DissertionAbstract':
				pst='pagename=other_dissertion_abstract.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Film':
				pst='pagename=manual_film_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Journal':
				pst='pagename=manual_journal_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Magazine':
				pst='pagename=manual_magazine_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Newspaper':
				pst='pagename=manual_newspaper_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;			
			case 'LetterToEditor':
				pst='pagename=other_lettertoeditor_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'PrivateOrganization':
				pst='pagename=other_privateorganization.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'OnlinePeriodical':
				pst='pagename=other_onlineperiodical.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;		
			case 'WebDocument':
				pst='pagename=other_webdocument.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;	
			case 'DatabaseArticle':
				pst='pagename=other_database_article_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;	
			case 'Review':
				pst='pagename=other_review_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Entertainment':
				pst='pagename=other_radio_apa.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;

		}
	}
	else if (formatSelectd=="Chicago")
	{
		switch(source){

			case 'Anthology':
				pst='pagename=other_anthology_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'Book':
				pst='pagename=manual_book_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'ChapterBook':
				pst='pagename=other_chapterbook.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'DatabaseArticle':
				pst='pagename=other_database_article_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'EMail':
				pst='pagename=other_email_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Film':
				pst='pagename=manual_film_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Goverment':
				pst='pagename=other_goverment_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Magazine':
				pst='pagename=manual_magazine_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'Newspaper':
				pst='pagename=manual_newspaper_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'Interview':
				pst='pagename=other_interview_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'Journal':
				pst='pagename=manual_journal_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'Sound':
				pst='pagename=other_sound.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;
			case 'Encyclopedia':
				pst='pagename=other_encyclopedia.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
			break;
			case 'WebDocument':
				pst='pagename=other_webdocument_chicago.tpl&annotation=yes&mode=edit&source='+source+'&elementId='+elementId;
				break;

		}
	}
	
	OtherPageLoad(pst);
	
	if (source=="LetterToEditor")
		var value="Letter";
	else if (source=="Entertainment")
		var value="Radio/TV";
	else if (source=="BookEdited")
		var value="Book With Editor";
	else if (source=="Goverment")
		var value="Goverment Publication";
	else if (source=="MusicalComposition")
		var value="Musical Composition";
	else if (source=="InternetDatabase")
		var value="Online Database";
	else if (source=="ChapterBook")
		var value="Chapter Book";
	else if (source=="ComputerProgram")
		var value="Computer Program";
	else if (source=="DissertionAbstract")
		var value="Dissertion Abstract";
	else if (source=="OnlinePeriodical")
		var value="Online Periodical";
	else if (source=="PrivateOrganization")
		var value="Private Organization";
	else if (source=="WebDocument")
		var value="Web Document";
	else if (source=="Sound")
		var value="Sound Recording";
	else if (source=="DatabaseArticle" && formatSelectd=="APA")
		var value="Database Article";
	else if (source=="DatabaseArticle" && formatSelectd=="Chicago")
		var value="Database Document";
	else if (source=="Film" && formatSelectd=="Chicago")
		var value="Film / Videotape";
	else if (source=="EMail")
		var value="E-Mail";
	else
		var value=source;

	document.getElementById('selectsource').innerHTML = '<select name="source" class="select_use_bib_builder" onChange="setDefaultText(this.value)" id="source"><option value="'+source+'" selected >'+value+'</option>'
	document.getElementById('tabs').style.display= 'none'; 
	document.getElementById('findbook').style.display= 'none'; 
	//document.getElementById('selectSourceDiv').style.display= 'none'; 
	//document.getElementById('sourceDiv').style.display= 'none'; 
	//document.getElementById('citation').style.marginTop= "0"; 
}

function myAccountBib(form,url,action)
	{
	var url = url;
	var url_new = url;
	var action = action;
	
	var count=0;
	if(!isNaN(form.selectProject.length))
		{
			for (i=0; i<form.selectProject.length; i++)
			{
				if(form.selectProject[i].checked)
				{
					url=url+"&PrjId="+form.selectProject[i].value;
					if(action=='download')
					{
						//OpenInPopUp(url,1,1);
						window.location=url;
					}
					if(action=='newwindow')
					{
						OpenInPopUp(url,600,500);
					}
					if(action=='mail')
					{
						OpenInPopUp(url,400,200);
					}
					if(action=='delete')
					{
						if (confirm("Do you want to delete ?"))
						{
							url=url_new+"?PrjId="+form.selectProject[i].value;
							window.location=url;
						}
					}
					if(action=='edit')
					{
						url=url_new+"?PrjId="+form.selectProject[i].value;
						window.location=url;
					}
					if(action=='myBib')
					{
						url=url_new+"?PrjId="+form.selectProject[i].value;
						window.location=url;
					}
				count++;
				}
			}
			if(count==0)
			{
				alert("Please select Project");
			}
		}
		else
		{
			if(form.selectProject.checked)
			{
					//url=url_new+"?PrjId="+form.selectProject.value;
					//window.location=url;
					url=url+"&PrjId="+form.selectProject.value;
					if(action=='download')
					{
						//OpenInPopUp(url,1,1);
						window.location=url;
					}
					if(action=='newwindow')
					{
						OpenInPopUp(url,600,500);
					}
					if(action=='mail')
					{
						OpenInPopUp(url,400,150);
					}
					if(action=='delete')
					{
						if (confirm("Do you want to delete ?"))
						{
							url=url_new+"?PrjId="+form.selectProject.value;
							window.location=url;
						}
					}
					if(action=='edit')
					{
						url=url_new+"?PrjId="+form.selectProject.value;
						window.location=url;
					}
					if(action=='myBib')
					{
						url=url_new+"?PrjId="+form.selectProject.value;
						window.location=url;
					}
			}
			else
			{
				alert("Please select Workscited.");
			}
		}
	}



function redirectionPage(val){
	if(val!='Other'){
		self.location='search.php';
	}
}


function changeFormating(form)
	{
		form.submit();
	}


function checkemail(val)
{
	  for(i=0;i<val.length;i++)
	  {
		if(val.charAt(i)!=" " ) break;
	  }
	  start=i;
	   
	  for(i=val.length-1;i>=0;i--)
	  {
		if(val.charAt(i)!=" " ) break;
	  }
	  stop=i+1-start;
	  val=val.substr(start,stop);
	  if(checkalpha(val.charAt(0))==false) return false;
	  var list="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@."
	  for(var i=0;i<val.length;i++)
	  {
	   if(list.indexOf(val.charAt(i))==-1)
	   {
		 return (false);
	   }
	  }
	  if(val.indexOf("@")==-1) return false;
	  if(val.indexOf("@")!=val.lastIndexOf("@")) return false;
	  if(val.indexOf(".")==-1) return false;
	  return (true);
}

function checkempty(val)
{
//	alert(val);
   nval="";
   for(i=0;i<val.length;i++)
  {
    if(val.charAt(i)!=" ") nval=nval+val.charAt(i);
  }
  if(nval=="")return true;
  else return false;
}


function checkalpha(val)
{
 var list="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ . "
 for(var i=0;i<val.length;i++)
 {
   if(list.indexOf(val.charAt(i))==-1)
   {
     return false;
   }
 }
return true; 
}


function ParentheticalCitation(form,url)
	{
	var url = url;
	var fieldName;
	var citationName;
		if(!isNaN(form.radCitation.length))
		{
			var count=0;
			for(i=0; i<form.radCitation.length; i++)
			{
				
				if(form.radCitation[i].checked)
				{
					fieldName=form.radCitation[i].value+'_pc';
					
					citationName=document.getElementById(fieldName).value;
					
					url=url+"?"+citationName;

					OpenInPopUp(url,500,350);

				count++;
				}
			}
			if(count==0)
			{
				alert("Please select Workscited.");
			}
		}
		else
		{
			if(form.radCitation.checked)
			{
					fieldName=form.radCitation.value+'_pc';
					citationName=document.getElementById(fieldName).value;
					url=url+"?"+citationName;
					//alert(url);
					OpenInPopUp(url,500,300);
			}
			else
			{
				alert("Please select Workscited.");
			}
		}

	}


function CreateBookmarkLink() 
{

 bookmarktitle = "Workscited4u.com"; 

 bookmarkurl = "http://workcited4u.mysqlphpexperts.com/";
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
else if (window.sidebar) // firefox
window.sidebar.addPanel(bookmarktitle, bookmarkurl, "");


/*
	if (window.sidebar) 
	{ // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if( window.external ) 
	{ // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if(window.opera && window.print)
	{ // Opera Hotlist
		return true; 
	}*/
 }

 function Endnotes(form,url,width,height)
	{
	var url = url;

		if(!isNaN(form.radCitation.length))
		{
			var count=0;
			for(i=0; i<form.radCitation.length; i++)
			{
				
				if(form.radCitation[i].checked)
				{
					//alert(form.radCitation[i].value);
					//if(action=='Endnotes')
					//{
						url=url+"&sourceid="+form.radCitation[i].value;
						//alert(url);
						OpenInPopUp(url,width,height)
						
						
					//}
					//document.getElementById(form.radCitation[i].value).style.display='';
				count++;
				break;
				}
			}
			if(count==0)
			{
				alert("Please select Workscited.");
			}
		}
		else
		{
			if(form.radCitation.checked)
			{
					//url=url+"?"+form.radCitation.value;
					//document.getElementById(form.radCitation.value).style.display='';
					//OpenInPopUp(url,500,300);
					url=url+"&sourceid="+form.radCitation.value;
					OpenInPopUp(url,width,height)
			}
			else
			{
				alert("Please select Workscited.");
			}
		}

	}

//	function hideEndnodes()
//	{
//	//alert("sgfsdff");
//		var theForm = document.forms['add'];
//		
//		for(var i=0;i < theForm.length;i++){
//			if(theForm[i].getAttribute('type') == "radio")
//				{	
//				
//					if(!isNaN(theForm[i].name.length))
//					{
//						var count=0;
//						for(j=0; j<theForm[i].name.length; j++)
//						{
//							//alert(document.add.radCitation.length);
//							if(!isNaN(document.add.radCitation.length))
//							{
//								//alert(document.add.radCitation[j].value);
//								document.getElementById(document.add.radCitation[j].value).style.display='none';
//							}
//							
//							count++;
//						}
//					}
//
//				}
//				break;
//		}
//	}


function hideEndnodes()
	{
	//alert("sgfsdff");
	try
		{
		var theForm = document.forms['add'];
		
		for(var i=0;i < theForm.length;i++){
			if(theForm[i].getAttribute('type') == "radio")
				{	
				
					if(!isNaN(document.add.radCitation.length))
					{
						if(!isNaN(theForm[i].name.length))
						{
							var count=0;
							for(j=0; j<document.add.radCitation.length; j++)
							{					
								if(!isNaN(document.add.radCitation.length))
								{
									document.getElementById(document.add.radCitation[j].value).style.display='none';
								}
								
								count++;
							}
						}
					}

				}
				break;
		}
		}
		catch(e)
		{
		}
	}
		
/*function hideEndnodes()
	{
	//alert("sgfsdff");
		var theForm = document.forms['addForm'];
		
		for(var i=0;i < theForm.length;i++){
			if(theForm[i].getAttribute('type') == "radio")
				{	
				
					if(!isNaN(theForm.radCitation.length))
					{
						if(!isNaN(theForm[i].name.length))
						{
							var count=0;
							for(j=0; j<theForm.radCitation.length; j++)
							{					
								if(!isNaN(theForm.radCitation.length))
								{
									document.getElementById(theForm.radCitation[j].value).style.display='none';
								}
								
								count++;
							}
						}
					}

				}
				break;
		}
	}*/

 function checkValue()
 {
	 var v=document.getElementById('select').value;
	 if (v!="")
	 {
		 window.location="search.php?format="+v;
	 }
 }

 function createSourceOption(formatType){
	 // create dropdown according to format
	var format;
  if(formatType=='')
	format=document.getElementById('format').value;
  else 
	 format=formatType;

	if(format=='APA'){	
		document.getElementById('selectsource').innerHTML='<select name="source" class="select_use_bib_builder" onChange="setDefaultText(this.value)" id="source"><option value="0">-----------Select Source-----------</option><option value="Anthology">Anthology</option><option value="Book">Book</option><option value="Brochure">Brochure</option><option value="ChapterBook">Chapter from a Book</option><option value="ComputerProgram">Computer Program</option><option value="DatabaseArticle">Database Article</option><option value="DissertionAbstract">Dissertion Abstract</option><option value="Film">Film</option><option value="Journal">Journal</option><option value="LetterToEditor">Letter</option><option value="Magazine">Magazine</option><option value="Newspaper">Newspaper</option><option value="OnlinePeriodical">Online Periodical</option><option value="PrivateOrganization">Private Organization</option><option value="Entertainment">Radio/TV</option><option value="Review">Review</option><option value="WebDocument">Web Document</option></select>';
	}
	else if(format=='MLA'){
		document.getElementById('selectsource').innerHTML='<select name="source" class="select_use_bib_builder" onChange="setDefaultText(this.value)" id="source"><option value="0">-----------Select Source-----------</option><option value="Advertisement">Advertisement</option><option value="Anthology">Anthology</option><option value="Book">Book</option><option value="BookEdited">Book with Editor</option><option value="Cartoon">Cartoon</option><option value="Dissertation">Dissertation</option><option value="EMail">E-Mail</option><option value="Encyclopedia">Encyclopedia</option><option value="Film">Film</option><option value="Goverment">Government Publication</option><option value="Interview">Interview</option><option value="Journal">Journal</option><option value="Lecture">Lecture</option><option value="LetterToEditor">Letter</option><option value="Map">Map</option><option value="Magazine">Magazine</option><option value="Mud">MUD</option><option value="MusicalComposition">Musical Composition</option><option value="Newspaper">Newspaper</option><option value="InternetDatabase">Online Database</option><option value="Painting">Painting</option><option value="Entertainment">Radio/TV</option><option value="Review">Review</option><option value="WebDocument">Website</option></select>';
	}else if(format=='Chicago'){
		document.getElementById('selectsource').innerHTML='<select name="source" class="select_use_bib_builder" onChange="setDefaultText(this.value)" id="source"><option value="0">-----------Select Source-----------</option><option value="Anthology">Anthology</option><option value="Book">Book</option><option value="ChapterBook">Chapter in a Book</option><option value="DatabaseArticle">Database Document</option><option value="EMail">Email</option><option value="Encyclopedia">Encyclopedia</option><option value="Film">Film / Videotape</option><option value="Goverment">Government Publication</option><option value="Interview">Interview</option><option value="Journal">Journal</option><option value="Magazine">Magazine</option><option value="Newspaper">Newspaper</option><option value="Sound">Sound Recording</option><option value="WebDocument">Web Document</option></select>';
	}

// create dropdown according to format
 }

function validateSendMail(form){
	var regEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;	

	if (checkempty(form.email.value)==true){
		alert('Please enter a valid email address.');
		form.email.focus();
		return false;
    }else if (!regEmail.test(form.email.value)){
		alert('Please enter a valid email address.');
		form.email.focus();
		return false;
	}
	return true;
}


function validateProjectForm(form)
{
	if(checkempty(form.projName.value) == true)
	{
		alert("Please enter the Bibliography name");
		form.projName.focus();
		return false;
	}
	return true;
}


function forLogin()
{
	alert('Please login to your account or create a free acount now to access your bibliography.');
	self.location="register.php?bib=ftime";
}


 function selectedFormat()
 {
	 var v=document.getElementById('select').value;
	 if (v!="")
	 {
		 window.location="addProject.php?format="+v;
	 }
 }

 function verifyMail(frm)
 {
	 if(checkempty(frm.subject.value) == true)
	 {
		alert("Please enter Subject.");
		frm.subject.focus();
		return false;
	 }
	 else if(checkempty(frm.message.value) == true)
	 {
		alert("Please enter Message.");
		frm.message.focus();
		return false;
	 }
	 return true;
 }


 // For Foot Nodes and endnodes function starts

function trim(s) {
  while (s.substring(0,1) == ' ') {
	s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
	s = s.substring(0,s.length-1);
  }
  return s;
}

function removeChar(s) {
  r = "";
  for (i=0; i < s.length; i++) {
	if (s.charAt(i) != '\\') {
	  r += s.charAt(i);
	}
  }
  return r;
}

function dispParens(frm) {

	page = frm.page.value;
	
	updParens();

}

function updParens() {
	elements = new Array();
	
	if(page.length > 0) elements.push(page);

	detstr = trim(elements.join(' '));

	if(detstr.length > 0) pstr = detstr;
	else pstr = ''

	if(window.document.getElementById('showCitation'))	{
		var piece = window.document.getElementById('showCitation');
		piece.innerHTML = "<p color:#000000; style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;margin-left:.30in;text-indent:-.35in;'><SUP>"+pstr+"</SUP>"+document.getElementById('hidCitation').value+"</p>";
	}
	else window.document.pcite.style.innerHTML = pstr;
}

 // For Foot Nodes and endnodes function Ends


function advacnSearch()
{
	formatSelectd=document.getElementById('format').value;	
	window.location="advance_search.php?format="+formatSelectd;
}
function test()
{
	alert("test");
 document.getElementById('tabs').innerHTML = '<a href="#" onClick="javascript:setDefaultText();"><img src="images/white_autocite_tab.gif" border="0" /></a>&nbsp;<a href="javascript:;" onclick="manualEntry()"><img src="images/green_maual_entry_tab.gif" width="134" height="26" border="0" /></a>&nbsp;<a href="advance_search.php"><img src="images/green_search_tab.gif" width="134" height="26" border="0" /></a>';
	 document.getElementById('findbook').style.display ="";
	 document.getElementById('searchResults').innerHTML ='';
}