/////////////////////////////////  page numbering code
function addPaginationLinks() {
  var cursor = gSearch.cursor;
  var curPage = cursor.currentPageIndex;
  var pagesList = document.createElement('ul');
  pagesList.innerHTML = "<li class='active' style='padding:5px 10px;'>Page:</li>";
  pagesList.className = 'nav';
  pagesList.style.marginLeft = '7px';
  for (var i = 0; i < cursor.pages.length; i++) {
    var page = cursor.pages[i];
    var linkPage = document.createElement('li');
    linkPage.innerHTML = '<img src="icons/zoom.png"><a href="javascript:gSearch.gotoPage('+i+');">'+page.label+'</a>';
	if (curPage == i){ 
	   linkPage.className = "active";
	}
    pagesList.appendChild(linkPage);
    
  }
  var contentDiv = document.getElementById('content');
  contentDiv.appendChild(pagesList);
}
/////////////////////////////////////// search

//window.location.hash



function google_search(){
	//alert("checking hash");
	if (currenthash != window.location.hash)
	{
		currenthash = window.location.hash;
		//alert("searching");
		if (searchtype=='2'){
			//MP3
			gSearch.execute('-inurl:(htm|html|asp|php) intitle:"index of"  "last modified"  "parent directory"  description  size  (mp3|wma|wav) "'+currenthash.replace(/#/gi, "")+'"');			
		} else if(searchtype=='3'){
			//torrent
			gSearch.execute('filetype:torrent '+currenthash.replace(/#/gi, ""));
		} else {
			//no sterm manipulation
			gSearch.execute(currenthash.replace(/#/gi, ""));
		}
		setCookie('sterm',currenthash.replace(/#/gi, ""),1);
	}
	//not good document.getElementById('s').value = currenthash.replace(/#/gi, "");
}

function timedSearch()
{
//alert("timed search");
t=setInterval("google_search()",800);
}

///////////////////////////////////////////////// cookie
function setCookie(s_term,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=s_term+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(s_term)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(s_term + "=");
  if (c_start!=-1)
    {
    c_start=c_start + s_term.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

//////////////////////////////////////////////// querystring
function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}