/* function to set the value of the specifed cookie*/ function setCookie(name, value, expires, path, domain, secure) { var expString = ((expires == '') ? ' ' : ('; expires=' + expires.toGMTString())); var pathString = ((path == '') ? ('; path=/') : ('; path=' + path)); var domainString = ((domain == '') ? ' ' : ('; domain=' + domain)); var secureString = ((secure == true) ? '; secure' : ''); document.cookie = name + '=' + value + expString + pathString + domainString + secureString; } /* function to extract the current cookie from the cookie arr*/ function getCookie(name) { var start = document.cookie.indexOf(name+"="); var len = start+name.length+1; if ((!start) && (name != document.cookie.substring(0,name.length))) return null; if (start == -1) return null; var end = document.cookie.indexOf(";",len); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(len,end)); } /* Delete a cookie */ function deleteCookie(cookiename) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cookieVal = getCookie(cookiename); if (cookieVal != null) document.cookie = name + "=" + cookieVal + "; expires=" + exp.toGMTString(); return; } /*------------Added by Satish on 14 Aug 02 for Previous/Next Functionality ------------------*/ /* function to extract the current cookie from the cookie arr*/ function getCurrentCookie( cookieName ) { cookieArr = document.cookie.split( ";" ); for ( i = 0; i < cookieArr.length ; i++ ) { if ( cookieArr[ i ].indexOf( cookieName ) != -1 ) CurrCk = cookieArr[ i ]; } return CurrCk; } /* To extract the location from the cookie string */ function getLocfromCookie( CurrCookie, index ) { beginstr = cookieName+"="; countbegin = CurrCookie.indexOf( beginstr ) + beginstr.length; countend = CurrCookie.indexOf( ";", index + 1 ); if ( countend == -1 ) countend = CurrCookie.length; return String( CurrCookie.substring( countbegin,countend ) ); } /* Function to return location without the start and count parameters */ function getLocWithoutParams( loc ) { endstr = "&START="; countend = loc.indexOf( endstr ); return loc.substring( 0,countend ); } /* Function to return the value of the start or count parameter from the location*/ /* if beginstr is blank then the user wants the value at the beginning of the string ie set countbegin to 0. if endstr is blank then the user wants the value at the end of the string ie set countend to length of the string.*/ function getParameterValue( loc, beginstr, endstr ) { if ( beginstr != "" ) countbegin = loc.indexOf( beginstr ) + beginstr.length; else countbegin = 0; if ( endstr != "" ) countend = loc.indexOf( endstr ); else countend = loc.length; return loc.substring( countbegin,countend ); } /* function for 'Next' */ /* get the current cookie from the cookie array, cookieName & cookieArr are global variables */ function DoAction( Action , cookieName ) { CurrCookie = getCurrentCookie( cookieName ); index = CurrCookie.indexOf( cookieName ); /* extract the Location string from the cookie ie from 'location=http://... extract only http://www...'*/ loc = getLocfromCookie( CurrCookie, index ); /* Do all manipulations on uppercase of the location string to avoid any case errors */ loc = loc.toUpperCase(); /* extract the Location value till '&START=' ( only dbpath/newsflowstory?openview&name=usr.. ) from the cookie */ currloc = getLocWithoutParams( loc ); /* extract the start parameter from the cookie */ startval = getParameterValue( loc, "&START=" , "&COUNT=" ); /* extract the count parameter from the cookie */ countval =getParameterValue( loc, "&COUNT=" , "" ); startval = parseInt(startval); countval = parseInt( countval ); proceed = true; if ( Action == "Next" ) startval = startval + countval - 1; else { if ( startval != 1 ) startval = startval - countval + 1; else proceed = false; } NextDisabled = false; if ( Action == "Next" && document.all("ViewContents").innerHTML.indexOf( "