var NORMAL_STATE = 4; var requestUrlForAction = "https://www.workscited4u.com/ajax/"; function _newXMLHttpRequest() { var retVal; if (window.XMLHttpRequest){ retVal = new XMLHttpRequest(); }else if (window.ActiveXObject){ try{ retVal = new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ try{ retVal = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e){} } } return retVal; } function makeheaderRequest(pst, URL){ var reqP = _newXMLHttpRequest(); reqP.open('POST', URL, true); reqP.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqP.setRequestHeader("Content-length", pst.length); reqP.setRequestHeader("Connection", "close"); reqP.send(pst); return reqP; } function formPost(formName,callthis,action){ var prms = getParams(formName); var reqP = _newXMLHttpRequest(); reqP.onreadystatechange = postBack; reqP.open('POST', requestUrlForAction+action, true); reqP.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqP.setRequestHeader("Content-length", prms.length); reqP.setRequestHeader("Connection", "close"); reqP.send(prms); function postBack(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; eval(callthis+"()"); } } } } function getParams(formName){ var pst = ""; var theForm = document.forms[formName]; for(var i=0;i < theForm.length;i++){ if(theForm[i].tagName=="SELECT"){ pst += "&" + theForm[i].name + "="; pst += theForm[i][theForm[i].selectedIndex].value; }else{ if((theForm[i].getAttribute('type') == "checkbox") || (theForm[i].getAttribute('type') == "radio")){ if(theForm[i].checked){ pst += "&" + theForm[i].name + "="; pst += encodeURIComponent(theForm[i].value); } }else{ pst += "&" + theForm[i].name + "="; pst += encodeURIComponent(theForm[i].value); } } } return pst.substr(1); } function checkState() { if(reqP.readyState == 4) { return true; } else return false; } function AjaxLoadData(){ var pst = ''; pst = getParams('search'); reqP = makeheaderRequest(pst, requestUrlForAction+'dynamic.php'); reqP.onreadystatechange = showloadsuccess; var testCount=0; function showloadsuccess(){ if (reqP.readyState == 3){ if(setTimeout("checkState();", 4000) == false) { document.getElementById('searchResults').innerHTML="Result Not Found."; testCount++; } } if(testCount==0) { if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('searchResults').innerHTML =jsonRetVal; } } } } } return false; } function AjaxLoadSearchData(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'advance_search.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ document.getElementById('searchResults').innerHTML =jsonRetVal; } } } } return false; } function AjaxAutofill(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'manual_entry.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('searchResults').innerHTML=jsonRetVal; } } } } return false; } function ManualPageLoad(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'manual_entry_page.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); //document.getElementById('tabs').innerHTML = ''; document.getElementById('findbook').style.display ="none"; document.getElementById('searchResults').innerHTML =jsonRetVal; } } } } return false; } function OtherPageLoad(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'manual_entry_page.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ document.getElementById('searchResults').innerHTML =jsonRetVal; } } } } return false; } function AjaxAddToSession(){ var pst = ''; pst = getParams('search'); document.getElementById('searchResults').innerHTML = ''; reqP = makeheaderRequest(pst, requestUrlForAction+'addtosession.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //document.getElementById('searchResults').innerHTML =jsonRetVal; //alert(jsonRetVal); self.location='editBibliography.php?add=1'; } } } } return false; } function AjaxLoadProjects(objFrm){ var pst = ''; //pst="projname="+objFrm.projName.value+"&descr="+objFrm.descr.value; if (objFrm.projName.value=="") { alert("Please enter project name"); objFrm.projName.focus(); return false; } pst="projname="+objFrm.projName.value+"&projformat="+objFrm.projformat.value; reqP = makeheaderRequest(pst, requestUrlForAction+'processajax.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('selectproject').innerHTML =jsonRetVal; var para=document.getElementById("addnewproj"); para.style.display="none"; } } } } return false; } function showAddProject() { var para=document.getElementById("addnewproj"); para.style.display="inline"; //var para2=document.getElementById("projectLabel"); //alert(para2); //var value=para2.innerHTML; //alert(value); } function hideAddProject() { var para=document.getElementById("addnewproj"); para.style.display="none"; } function tfdValue(value) { //alert(value); document.getElementById("selectedproject").value=value; } function checkProjectId() { var obj=document.getElementById("project"); var value=obj.value; if (value=="") { alert("Please Select Project"); return false; } document.forms['frmProject'].submit(); //window.location="editBibliography.php?project="+value; //return true; } function AjaxTest(name,value){ var pst = ''; pst="val="+value+"&name="+name; reqP = makeheaderRequest(pst, requestUrlForAction+'processajaxtest.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); if (name=="c1") document.getElementById('t1').innerHTML =jsonRetVal; if (name=="c2") document.getElementById('t2').innerHTML =jsonRetVal; if (name=="c3") document.getElementById('t3').innerHTML =jsonRetVal; } } } } return false; } function checkUser(value){ var pst = ''; pst="val="+value+"&name=uniqueUser"; reqP = makeheaderRequest(pst, requestUrlForAction+'uniqueuser.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('uniqueUser').innerHTML =jsonRetVal; //document.getElementByName('password').focus(); if (document.getElementById('existuser').value!="") { //alert("User Name already exist!!"); //document.getElementById('email').focus(); } else { document.getElementById('password').focus(); } } } } } return false; } function AdvSearchBook(pst){ var success = 'success'; reqP = makeheaderRequest(pst, requestUrlForAction+'advance_search_book.php'); reqP.onreadystatechange = showloadsuccess(); function showloadsuccess() { if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ document.getElementById('book').innerHTML =jsonRetVal; } } } } return success; } function AdvSearchMagazine(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'advance_search_magazine.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ document.getElementById('magazine').innerHTML =jsonRetVal; } } } } return false; } function AdvSearchNewspaper(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'advance_search_newspaper.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('newspaper').innerHTML =jsonRetVal; } } } } return false; } function AdvSearchJournal(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'advance_search_journal.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('journal').innerHTML =jsonRetVal; } } } } return false; } function AdvSearchFilm(pst){ reqP = makeheaderRequest(pst, requestUrlForAction+'advance_search_film.php'); reqP.onreadystatechange = showloadsuccess; function showloadsuccess(){ if (reqP.readyState == 4){ if (reqP.status == 200){ jsonRetVal = reqP.responseText; if(jsonRetVal){ //alert(jsonRetVal); document.getElementById('film').innerHTML =jsonRetVal; } } } } return false; } function ChangingAPA() { if(document.getElementById('format').value=='APA') { document.getElementById('common_APA').style.display=''; } }