function setPage() {
	var pageName=getPage();
	var loc=getLoc();
	
	top.mainpage.location.href='http://' + top.window.location.host + '/' + pageName + loc;
}

function getPage()
{
  var url = top.document.URL;
  var arrQS = url.split('?');

  //if the querystring is passed
  if (arrQS.length==2) {
    var index=arrQS[1].indexOf('loadpage');
    var constLength=index+9;  //Puts the index to the begining of the page name
    var lastIndex=arrQS[1].indexOf('&',constLength);

    if (lastIndex!=-1) {
    	return arrQS[1].substr(constLength,lastIndex-constLength);
    }
    else {
        return arrQS[1].substr(constLength);
    }
  }
  else {
     //return the main page if nothing is passed
     return 'main_page.shtml';
    
  }
}// end getPage()

function getLoc()
{
   var url = top.document.URL;
   var arrQS = url.split('?');

   //if the querystring is passed
   if (arrQS.length==2) {
      var index=arrQS[1].indexOf('pic');
      //if the pic string is not found then return
      if (index==-1) {
	 return '';
      }
      var constLength=index+4;  //Puts the index to the begining of the page name
      var lastIndex=arrQS[1].indexOf('&',constLength);

      if (lastIndex!=-1) {
    	  return '#' + arrQS[1].substr(constLength,lastIndex-constLength);
      }
      else {
          return '#' + arrQS[1].substr(constLength);
      }

   }
   else {
      return '';
   }
}