var maxnum=301
var curnum=1
var newstart=290
var randomnum=0
var autovar=0
var tmout
var ctr=0
var baseURL="http://lalitkumar.in/muktak/";

function findrec()
{

var findnum=0
findnum=prompt("Please enter Number of the Muktak that you want to see:\n(Number should be between 1 and "+maxnum+")","")

if(findnum==null)
return;

///////  check for valid numeric strings	

   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

var strString=findnum

   if (strString.length == 0)
{
alert("Please enter a number between 1 and " +maxnum)
//document.all.pagename.focus()
return false
}

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
alert("Please enter numbers only between 1 and "+maxnum);
return;
         }
      }

//////// numeric check over


if (findnum>maxnum||findnum<=0)
{alert("Please enter a number between 1 and " + maxnum);
return;}

if(findnum!="")
{
parent.main_frame.location.href=baseURL + findnum;
curnum=parseInt(findnum)
displaypagename();
}
}




function gonext()
{
curnum=curnum+1
parent.main_frame.location.href=baseURL+curnum;
document.all.pagename.value=curnum;
displaypagename();
changestate();
}

function goprev()
{
curnum=curnum-1
parent.main_frame.location.href=baseURL+curnum;
document.all.pagename.value=curnum
displaypagename();
changestate();
}



function changestate()
{
document.all.nextbt.disabled=false;
document.all.prevbt.disabled=false;
if (curnum==maxnum||curnum>maxnum)
{
document.all.nextbt.disabled=true;
document.all.prevbt.disabled=false;
return;
}
if (curnum==0||curnum==1)
{
document.all.nextbt.disabled=false;
document.all.prevbt.disabled=true;
return;
}
document.all.nextbt.disabled=false;
document.all.prevbt.disabled=false;
}



function IsNumeric()
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

strString=document.all.pagename.value

   if (strString.length == 0)
{
alert("Please enter a number between 1 and " +maxnum)
document.all.pagename.focus()
return false
}

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
alert("Please enter numbers only between 1 and "+maxnum);
document.all.pagename.focus()
return;
         }
      }
findrec()
}


function displaypagename()
{
document.all.mnumber.value=curnum + " / " + maxnum
document.all.pagename.value=curnum
}


function seerandom()
{

//here multiplication with maxnum dictates that the random number should fall between 0 and maxnum.

for(var ctr=0;ctr=200;ctr=ctr+1)
{
var randomnumber=Math.floor(Math.random()*maxnum+1)
if(randomnumber!=randomnum && randomnumber!=0)
{
randomnum=randomnumber;
parent.main_frame.location.href=baseURL + randomnumber;
document.all.pagename.value=randomnumber;
curnum=parseInt(document.all.pagename.value)
displaypagename();
changestate();
break;
}
}

if(autovar==1)
{
tmout=setTimeout("seerandom()",document.all.showtime.value)	
document.all.showmsg.value="स्वत: बदल जारी है"
document.all.startbt.disabled=true
document.all.stopbt.disabled=false
document.all.stopbt.style.classname="stopbton"
document.all.showtime.disabled=true
document.all.new_list.disabled=true
document.all.randombt.disabled=true
document.all.khojbt.disabled=true
document.all.findbt.disabled=true
document.all.nextbt.disabled=true
document.all.prevbt.disabled=true
document.all.findbt.disabled=true
document.all.lekhakind.disabled=true
document.all.showpic.src="showon.gif"
}

}



function startshow()
{
autovar=1
alert("PLEASE NOTE: Auto change is going to start now.\n\nTo view other pages in Muktak Saagar, you will have to STOP Auto change.");
}


function stopshow()
{
clearTimeout(tmout);
autovar=0;
document.all.showmsg.value="स्वत: बदल रुका हुआ है"
document.all.startbt.disabled=false
document.all.stopbt.disabled=true
document.all.showtime.disabled=false
document.all.new_list.disabled=false
document.all.randombt.disabled=false
document.all.khojbt.disabled=false
changestate()
document.all.findbt.disabled=false
document.all.lekhakind.disabled=false
document.all.showpic.src="spacer.gif"
}

function init_controls()
{
document.all.stopbt.disabled=true
document.all.showmsg.disabled=true
document.all.showmsg.value="स्वत: बदल रुका हुआ है"
}


function x()
{
document.all.pagename.focus()
}


function gotonew()
{
var findnum=0
findnum=document.all.new_list.value
if (findnum>maxnum)
{alert("Please enter a number between 1 and " + maxnum);
document.all.pagename.focus();
return;}

if(findnum!="")
{
parent.main_frame.location.href=baseURL+findnum;
document.all.pagename.value=findnum;
curnum=parseInt(findnum)
displaypagename();
changestate()
}
}


function new_start()
{
var strg;

strg="<select name=new_list style='font-size: 12px' onchange='gotonew()'><option value='' unselectable>--</option>"
for(x=newstart;x<=maxnum;x++)
{
strg=strg+"<option value="+x+">"+x+"</option>"
}
strg=strg+"</select>"

//strg="<input type=button name=newst value='New Muktaks ("+newstart+"-"+maxnum+")' onclick=gotonew("+newstart+")>"
//strg="<a href='"+newstart+".htm' class=footerlnk target='main_frame'>New Muktaks ("+newstart+"-"+maxnum+")</a>"
document.write(strg);
}


function NewMuktakList()
{
var strg;

strg=""
for(x=newstart;x<=maxnum;x++)
{
strg=strg+"<a href="+x+".htm target=main_frame>"+x+"</a><br><br>"
}

document.write(strg);
}


function OpenNewMuktakFrame()
{
parent.innerset.cols="50,*"
parent.left_frame.location.href="new_muktak.htm"
document.all.pagename.value=""
document.all.mnumber.value=""
stopshow()
}

function OpenLeftFrame()
{
parent.innerset.cols="200,*"
parent.left_frame.location.href="lekhak_ind.htm"
document.all.pagename.value=""
document.all.mnumber.value=""
stopshow()
}

function OpenSearchPage()
{
parent.main_frame.location.href="sitesearch.htm"
document.all.pagename.value=""
document.all.mnumber.value=""
stopshow()
}



function muktakRef(writer,comment,sender){

var ref='<table class="dettable" width="900" style="border-collapse: collapse" bordercolor="#111111" cellpadding="2" cellspacing="0"><tr><td width="166" class="headcell" align="right">लेखक/लेखिका :</td><td width="694" class="writer">अमीर खुसरो </td></tr><tr><td width="166" class="headcell" align="right">टिप्पणी / संदर्भ :</td><td width="694" class="comments">&nbsp;</td></tr><tr><td width="166" class="headcell" align="right">प्रेषक :</td><td width="694" class="submitter"><span lang="en-us">ललित कुमार</span></td></tr></table>'

document.write(ref);
}

