function goLocation(loc)
{
	document.frm_main.page.value=loc;
	document.frm_main.submit();
}


function goPopLocation(loc)
{
	url_str='/cgi-bin/seerinquiry/'+loc+'&'+document.frm_main.yearid.value+'&'+document.frm_main.questionid.value;
	popup = window.open(url_str,'SINQ','width=700,height=500,left=1,top=1,toolbar=yes,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
}

function goPopPrint(loc)
{
	url_str='/cgi-bin/seerinquiry/'+loc+'&'+document.frm_main.yearid.value+'&'+document.frm_main.questionid.value+'&'+document.frm_main.showdiscussion.value+'&'+document.frm_main.showhistory.value+'&'+document.frm_main.showcomment.value+'&'+document.frm_main.showreview.value;
	popup = window.open(url_str,'SINQ_PRINT','width=700,height=500,left=1,top=1,toolbar=yes,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
}


function goPopHelp(loc)
{
	url_str='/cgi-bin/seerinquiry/'+loc;
	popup = window.open(url_str,'SINQ_HELP','width=630,height=470,left=35,top=35,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
}


function goPopReview(loc)
{
	url_str='/cgi-bin/seerinquiry/'+loc+'&'+document.frm_main.yearid.value+'&'+document.frm_main.questionid.value+'&';
	url_str=url_str+document.frm_main.searchquestion.value+'&';
	url_str=url_str+document.frm_main.searchyear.value+'&';
	url_str=url_str+document.frm_main.searchstatus.value+'&';
	url_str=url_str+document.frm_main.searchowner.value+'&';
	url_str=url_str+document.frm_main.searchkeyword.value+'&';
	url_str=url_str+document.frm_main.searchtext.value+'&';
	url_str=url_str+document.frm_main.searchupdate.value+'&';
	url_str=url_str+document.frm_main.currquestion.value+'&';
	url_str=url_str+document.frm_main.totalquestion.value+'&';
	url_str=url_str+document.frm_main.showhistory.value+'&';
	url_str=url_str+document.frm_main.showreview.value+'&';
	url_str=url_str+document.frm_main.showcomment.value+'&';
	url_str=url_str+document.frm_main.showdiscussion.value+'&';
	url_str=url_str+document.frm_main.showinfo.value+'&';
	url_str=url_str+document.frm_main.marked.value+'&';
	popup = window.open(url_str,'SINQ_REVIEW','width=630,height=470,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
}


function goPopListing(loc)
{
	url_str='/cgi-bin/seerinquiry/'+loc;

	url_str=url_str+document.frm_main.searchquestion.value+'&';
	url_str=url_str+document.frm_main.searchyear.value+'&';
	url_str=url_str+document.frm_main.searchstatus.value+'&';
	url_str=url_str+document.frm_main.searchowner.value+'&';
	url_str=url_str+document.frm_main.searchkeyword.value+'&';
	url_str=url_str+document.frm_main.searchtext.value+'&';
	url_str=url_str+document.frm_main.searchupdate.value+'&';
	url_str=url_str+document.frm_main.totalquestion.value+'&';
	url_str=url_str+document.frm_main.showhistory.value+'&';
	url_str=url_str+document.frm_main.showreview.value+'&';
	url_str=url_str+document.frm_main.showcomment.value+'&';
	url_str=url_str+document.frm_main.showdiscussion.value+'&';
	url_str=url_str+document.frm_main.showinfo.value+'&';
	url_str=url_str+document.frm_main.marked.value+'&';

	popup = window.open(url_str,'SINQ_LIST','width=700,height=500,left=1,top=1,toolbar=yes,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
}


function goPopSave2(loc) {
	//I added this function in named 2 since this is not my project and I do not want to permanetley delete a function from it.
	//However this function is designed to work with Seerinquiry in a Form POST submission environment
	// - Marty K.
			
   var formObj 	= document.frm_main;
   var origTarget = formObj.target;
   var origAction = formObj.action;
   baccept=window.confirm('Are you sure ?'); 
   accept=(baccept)?1:0; 
   if (accept) 
   { 
   	
  url_str='/cgi-bin/seerinquiry/'+loc+"&";
  
  
  
	if (document.frm_main.outsidereview.checked)
	     {url_str=url_str+'1&'; } 
	else {url_str=url_str+'0&'; }
	if (document.frm_main.outsidequality.checked)
	     {url_str=url_str+'1&'; } 
	else {url_str=url_str+'0&'; }
   	
  	var popup = window.open(url_str,'SINQ_SAVE','width=630,height=470,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
	formObj.target='SINQ_SAVE';
   formObj.action = url_str;
	formObj.submit();
	formObj.target = origTarget;
	formObj.action = origAction;
	}// accept
}

function goPopSave(loc)
{
   baccept=window.confirm('Are you sure ?'); 
   accept=(baccept)?1:0; 
   if (accept) 
   { 

	
	var sl='&';	var cat1='&';  var cat2='&'; cat3='&';
	var url_str="";
	for (var i = document.frm_main.statusList.length-1; i >= 0; i--)
       	{  if (document.frm_main.statusList.options[i].selected)
               	{ 
       			sl=document.frm_main.statusList.options[i].value+'&';
		}
	}

	for (var i = document.frm_main.keywordList1.length-1; i >= 0; i--)
       	{  if (document.frm_main.keywordList1.options[i].selected)
               	{ 
       			cat1=document.frm_main.keywordList1.options[i].value+'&';
		}
	}

	for (var i = document.frm_main.keywordList2.length-1; i >= 0; i--)
       	{  if (document.frm_main.keywordList2.options[i].selected)
               	{ 
       			cat2=document.frm_main.keywordList2.options[i].value+'&';
		}
	}

	for (var i = document.frm_main.keywordList3.length-1; i >= 0; i--)
       	{  if (document.frm_main.keywordList3.options[i].selected)
               	{ 
       			cat3=document.frm_main.keywordList3.options[i].value+'&';
		}
	}

	url_str=url_str+document.frm_main.keywordList1.value+'&';
	url_str=url_str+document.frm_main.keywordList2.value+'&';
	url_str=url_str+document.frm_main.keywordList3.value+'&';
	url_str='/cgi-bin/seerinquiry/'+loc+'&'+document.frm_main.yearid.value+'&'+document.frm_main.questionid.value+'&';
	url_str=url_str+document.frm_main.listField.value+'&';

	url_str=url_str+sl;
	url_str=url_str+cat1;
	url_str=url_str+cat2;
	url_str=url_str+cat3;

	url_str=url_str+escape(document.frm_main.editReference1.value)+'&';
	url_str=url_str+escape(document.frm_main.editPage1.value)+'&';
	url_str=url_str+escape(document.frm_main.editNote1.value)+'&';
	url_str=url_str+escape(document.frm_main.editReference2.value)+'&';
	url_str=url_str+escape(document.frm_main.editPage2.value)+'&';
	url_str=url_str+escape(document.frm_main.editNote2.value)+'&';
	url_str=url_str+escape(document.frm_main.editBrief.value)+'&';
	url_str=url_str+escape(document.frm_main.editQuestion.value)+'&';
	url_str=url_str+escape(document.frm_main.editDiscussion.value)+'&';
	url_str=url_str+escape(document.frm_main.editAnswer.value)+'&';
	url_str=url_str+escape(document.frm_main.editHistory.value)+'&';
	url_str=url_str+escape(document.frm_main.editReferredto.value)+'&';
	if (document.frm_main.outsidereview.checked)
	     {url_str=url_str+'1&'; } 
	else {url_str=url_str+'0&'; }
	if (document.frm_main.outsidequality.checked)
	     {url_str=url_str+'1&'; } 
	else {url_str=url_str+'0&'; }
	popup = window.open(url_str,'SINQ_SAVE','width=630,height=470,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
   }
}


function goPopDelete(loc)
{
   baccept=window.confirm('Are you sure you want to permanantly remove this question from the Database? \nIf you want to keep the Question in the Databse, you can set the Status to deleted.'); 
   accept=(baccept)?1:0; 
   if (accept) 
   { 

	
	var sl='&';	var cat1='&';  var cat2='&'; cat3='&';
	var url_str="";
	for (var i = document.frm_main.statusList.length-1; i >= 0; i--)
       	{  if (document.frm_main.statusList.options[i].selected)
               	{ 
       			sl=document.frm_main.statusList.options[i].value+'&';
		}
	}

	for (var i = document.frm_main.keywordList1.length-1; i >= 0; i--)
       	{  if (document.frm_main.keywordList1.options[i].selected)
               	{ 
       			cat1=document.frm_main.keywordList1.options[i].value+'&';
		}
	}

	for (var i = document.frm_main.keywordList2.length-1; i >= 0; i--)
       	{  if (document.frm_main.keywordList2.options[i].selected)
               	{ 
       			cat2=document.frm_main.keywordList2.options[i].value+'&';
		}
	}

	for (var i = document.frm_main.keywordList3.length-1; i >= 0; i--)
       	{  if (document.frm_main.keywordList3.options[i].selected)
               	{ 
       			cat3=document.frm_main.keywordList3.options[i].value+'&';
		}
	}

	url_str=url_str+document.frm_main.keywordList1.value+'&';
	url_str=url_str+document.frm_main.keywordList2.value+'&';
	url_str=url_str+document.frm_main.keywordList3.value+'&';
	url_str='/cgi-bin/seerinquiry/'+loc+'&'+document.frm_main.yearid.value+'&'+document.frm_main.questionid.value+'&';
	url_str=url_str+document.frm_main.listField.value+'&';

	url_str=url_str+sl;
	url_str=url_str+cat1;
	url_str=url_str+cat2;
	url_str=url_str+cat3;

	url_str=url_str+escape(document.frm_main.editReference1.value)+'&';
	url_str=url_str+escape(document.frm_main.editPage1.value)+'&';
	url_str=url_str+escape(document.frm_main.editNote1.value)+'&';
	url_str=url_str+escape(document.frm_main.editReference2.value)+'&';
	url_str=url_str+escape(document.frm_main.editPage2.value)+'&';
	url_str=url_str+escape(document.frm_main.editNote2.value)+'&';
	url_str=url_str+escape(document.frm_main.editBrief.value)+'&';
	url_str=url_str+escape(document.frm_main.editQuestion.value)+'&';
	url_str=url_str+escape(document.frm_main.editDiscussion.value)+'&';
	url_str=url_str+escape(document.frm_main.editAnswer.value)+'&';
	url_str=url_str+escape(document.frm_main.editHistory.value)+'&';
	url_str=url_str+escape(document.frm_main.editReferredto.value)+'&';
	popup = window.open(url_str,'SINQ_SAVE','width=630,height=470,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
document.frm_main.submit();
   }
}

function goPopDelete2(loc)
{
	//I added this function in named 2 since this is not my project and I do not want to permanetley delete a function from it.
	//However this function is designed to work with Seerinquiry in a Form POST submission environment
	// - Marty K.

   var formObj 	= document.frm_main;
   var origTarget = formObj.target;
   var origAction = formObj.action;
   var url_str    = "";
   baccept=window.confirm('Are you sure you want to permanantly remove this question from the Database? \nIf you want to keep the Question in the Databse, you can set the Status to deleted.'); 
   accept=(baccept)?1:0; 
   if (accept) 
   	{ 
   	url_str='/cgi-bin/seerinquiry/'+loc+"&";
		
  		var popup = window.open(url_str,'SINQ_REMOVE','width=630,height=470,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
		popup.focus();
		formObj.target ='SINQ_REMOVE';
   	formObj.action = url_str;
		formObj.submit();
		formObj.target = origTarget;
		formObj.action = origAction;
		}// accept
}

function goReport(level)
{
	str=document.frm_main.marked.value;
	str=str.substring(1,str.length);
	url_str='/cgi-bin/seerinquiry/Report.pl?'+level+'&'+document.frm_main.yearid.value+'&'+document.frm_main.questionid.value+'&'+str+'&';
	
	url_str=url_str+document.frm_main.searchstatus.value+'&';
	url_str=url_str+document.frm_main.searchquestion.value+'&';
	url_str=url_str+document.frm_main.searchowner.value+'&';
	url_str=url_str+document.frm_main.searchkeyword.value+'&';
	url_str=url_str+document.frm_main.searchtext.value+'&';
	url_str=url_str+document.frm_main.searchupdate.value+'&';
	if (document.frm_main.record[0].checked) {url_str=url_str+'0&';}
	else if (document.frm_main.record[1].checked) {url_str=url_str+'1&';}
	else if (document.frm_main.record[2].checked) {url_str=url_str+'2&';}
	if (document.frm_main.format[0].checked) {url_str=url_str+'0&';}
	else if (document.frm_main.format[1].checked) {url_str=url_str+'1&';}
	if (document.frm_main.field[0].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	if (document.frm_main.field[1].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	if (document.frm_main.field[2].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	if (document.frm_main.field[3].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	if (document.frm_main.field[4].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	if (document.frm_main.field[5].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	if (document.frm_main.field[6].checked) {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
	
	if (level == 'sys' )
	{
		if (document.frm_main.field[7].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
		if (document.frm_main.field[8].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
		if (document.frm_main.field[9].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
                url_str=url_str+'1&';
	}

	if (level == '2sys' )
	{
		if (document.frm_main.field[7].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
		if (document.frm_main.field[8].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
		if (document.frm_main.field[9].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
                url_str=url_str+'0&';
	}
	if (level == 'adreg' )
	{
		url_str=url_str+'0&';
		if (document.frm_main.field[7].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
		url_str=url_str+'0&';
                url_str=url_str+'1&';
	}
	if (level == '2adreg' )
	{
		url_str=url_str+'0&';
		if (document.frm_main.field[7].checked)  {url_str=url_str+'1&';} else {url_str=url_str+'0&';}
		url_str=url_str+'0&';
                url_str=url_str+'0&';
	}


	if (level == 'pub' )
	{
		url_str=url_str+'0&';
		url_str=url_str+'0&';
		url_str=url_str+'0&';
                url_str=url_str+'1&';
	}
	if (level == '2pub' )
	{
		url_str=url_str+'0&';
		url_str=url_str+'0&';
		url_str=url_str+'0&';
                url_str=url_str+'0&';
	}

	popup = window.open(url_str,'SINQ_REPORT','width=700,height=500,left=1,top=1,toolbar=yes,scrollbars=yes,status=1,menubar=1,resizable=1');
	popup.focus();
}


function on_search_click()
{                                
	var id=document.frm_main.searchid.value;
	var dateid=document.frm_main.searchupdate.value;
	document.frm_main.searchyear.value=id.substr(0,4);
	document.frm_main.searchquestion.value=id.substr(4,id.length);

       // test for valid date format
  	var testDate = new String(document.frm_main.searchupdate.value);
   	for (var j=0; j<9; j++)
    	   {   for (var i=0; i<10; i++)
        	  {  testDate = testDate.replace(i,""); }      
           }
    	testDate = testDate.replace("/",""); 
    	testDate = testDate.replace("/",""); 
	
  
       // test for an 8 digits only long string or nothing
       var testID = new String(document.frm_main.searchid.value);
   	for (var j=0; j<9; j++)
    	   {   for (var i=0; i<10; i++)
        	  {  testID = testID.replace(i,""); }      
           }

	if ((dateid.length != 0) && (dateid.length != 10)) {alert('error: Date must be in this format mm/dd/yyyy'); }
	else if ((dateid.length != 0) && (testDate.length != 0)) {alert('error: Date must be in this format mm/dd/yyyy'); }
	else if ((id.length != 0) && (id.length != 8)) {alert('error: id must be 8 didgits long'); }
	else if ((id.length != 0) && (testID.length != 0)) {alert('error: id must contain digits only'); }
	else {	document.frm_main.page.value='';document.frm_main.submit(); }
}



function on_reset_page_click()
{                                
	//var id=document.frm_main.searchid.value;
	//var dateid=document.frm_main.searchupdate.value;
	//document.frm_main.searchyear.value=id.substr(0,4);
	//document.frm_main.searchquestion.value=id.substr(4,id.length);

       // test for valid date format
  	//var testDate = new String(document.frm_main.searchupdate.value);
   	//for (var j=0; j<9; j++)
    	//   {   for (var i=0; i<10; i++)
        //	  {  testDate = testDate.replace(i,""); }      
        //   }
    	//testDate = testDate.replace("/",""); 
    	//testDate = testDate.replace("/",""); 
	
  
       // test for an 8 digits only long string or nothing
       //var testID = new String(document.frm_main.searchid.value);
   	//for (var j=0; j<9; j++)
    	//   {   for (var i=0; i<10; i++)
        //	  {  testID = testID.replace(i,""); }      
        //   }
//
//	if ((dateid.length != 0) && (dateid.length != 10)) {alert('error: Date must be in this format mm/dd/yyyy'); }
//	else if ((dateid.length != 0) && (testDate.length != 0)) {alert('error: Date must be in this format mm/dd/yyyy'); }
//	else if ((id.length != 0) && (id.length != 8)) {alert('error: id must be 8 didgits long'); }
//	else if ((id.length != 0) && (testID.length != 0)) {alert('error: id must contain digits only'); }
//	else {	document.frm_main.page.value='';document.frm_main.submit(); }

 	document.frm_main.searchstatus.value='';
 	document.frm_main.searchquestion.value='';
 	document.frm_main.searchyear.value='';
 	document.frm_main.searchkeyword.value='';
 	document.frm_main.searchowner.value='';
 	document.frm_main.searchtext.value='';
	document.frm_main.searchupdate.value='';
	document.frm_main.currquestion.value='';
        document.frm_main.page.value='';
        document.frm_main.submit();
}

function on_stats_click()
{                                
	for (var i = document.frm_main.year_list.length-1; i >= 0; i--)
             	{  if (document.frm_main.year_list.options[i].selected)
                	{ 
        			document.frm_main.yearselected.value=document.frm_main.year_list.options[i].value;
			}
		}
	document.frm_main.page.value='statistics';
	document.frm_main.submit();
}



// ***   CHANGE THE STATUS   ***
function on_status_change()
{  
 	for (var i = document.frm_main.status_list.length-1; i >= 0; i--)
             	{  if (document.frm_main.status_list.options[i].selected)
                	{ 
        			document.frm_main.searchstatus.value=document.frm_main.status_list.options[i].value;
				document.frm_main.searchid.value="";
				document.frm_main.searchquestion.value="";
				document.frm_main.searchyear.value="";
   			}
   		}
}


// ***   CHANGE KEYWORD   ***
function on_keyword_change()
{  
 	for (var i = document.frm_main.keyword_list.length-1; i >= 0; i--)
             	{  if (document.frm_main.keyword_list.options[i].selected)
                	{ 
        			document.frm_main.searchkeyword.value=document.frm_main.keyword_list.options[i].value;
				document.frm_main.searchid.value="";
				document.frm_main.searchquestion.value="";
				document.frm_main.searchyear.value="";

   			}
   		}
}

// ***   CHANGE THE AUTHOR   ***
function on_author_change()
{  
 	for (var i = document.frm_main.author_list.length-1; i >= 0; i--)
             	{  if (document.frm_main.author_list.options[i].selected)
                	{ 
        			document.frm_main.searchowner.value=document.frm_main.author_list.options[i].value;
				document.frm_main.searchid.value="";
				document.frm_main.searchquestion.value="";
				document.frm_main.searchyear.value="";
   			}
   		}
}


// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function pop_up(url_str)
   {  url_str='/cgi-bin/seerinquiry/'+url_str;
      popup = window.open(url_str,'SINQ','height=500,width=500,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
      popup.focus();
   }

function pop_up2(url_str)
   {  url_str='/cgi-bin/seerinquiry/'+url_str;
      popup = window.open(url_str,'SINQ2','height=500,width=500,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
      popup.focus();
   }


function pop_up_large(url_str)
   {  url_str='/cgi-bin/seerinquiry/'+url_str;
      popup = window.open(url_str,'SINQ','height=600,width=800,left=5,top=5,toolbar=no,scrollbars=yes,status=1,menubar=1,resizable=1');
      popup.focus();
   }


// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function show_hist()
   { 
	if (document.frm_main.showHistory.checked) toc="1";
	else toc="0";
	document.frm_main.showhistory.value=toc;
	document.frm_main.submit();
   }

// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function show_rev()
   { 
	if (document.frm_main.showReview.checked) toc="1";
	else toc="0";
	document.frm_main.showreview.value=toc;
	document.frm_main.submit();
   }


// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function show_com()
   { 
	if (document.frm_main.showComment.checked) toc="1";
	else toc="0";
	document.frm_main.showcomment.value=toc;
	document.frm_main.submit();
   }


// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function show_discus()
   { 
	if (document.frm_main.showDiscussion.checked) toc="1";
	else toc="0";
	document.frm_main.showdiscussion.value=toc;
	document.frm_main.submit();
   
   }


// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function show_info()
   { 
	if (document.frm_main.showInfo.checked) toc="1";
	else toc="0";
	document.frm_main.showinfo.value=toc;
	document.frm_main.submit();
   
   }


// *******************************************
// ***   CREATE LINK TO ASK NEW QUESTION   ***
// *******************************************
function mark_rep()
   { 
	if (document.frm_main.markReport.checked)
	{ 
		document.frm_main.marked.value=document.frm_main.marked.value+";"+document.frm_main.yearid.value+','+document.frm_main.questionid.value; 
	}
	else
	{
		base=document.frm_main.marked.value;
		base2=document.frm_main.yearid.value+','+document.frm_main.questionid.value;
		str="&"+document.frm_main.yearid.value+','+document.frm_main.questionid.value;
		pos1=document.frm_main.marked.value.search(str);
		strstart=document.frm_main.marked.value.substr(0,pos1);
		strend=document.frm_main.marked.value.substr(pos1+1,base.length);
		strend=strend.substring(base2.length,base.length);
		document.frm_main.marked.value=strstart+strend;
	}
//alert(document.frm_main.marked.value);
   }

// ********************************
// ***   GO TO FIRST QUESTION   ***
// ***   Current                ***
// ********************************
function OnFirst_Click()
{  
	recno = 1;
	document.frm_main.currquestion.value=recno;
	document.frm_main.submit();
}


// *******************************
// ***   GO TO LAST QUESTION   ***
// ***   Current                ***
// *******************************
function OnLast_Click()
{
   	var totalrec = parseInt(document.frm_main.totalquestion.value);	
	recno = totalrec;
	document.frm_main.currquestion.value=recno;
	document.frm_main.submit();
}



// ***********************************
// ***   GO TO PREVIOUS QUESTION   ***
// ***   Current                   ***
// ***********************************
function OnPrev_Click()
{
	var recno = parseInt(document.frm_main.currquestion.value);
	recno=Math.max(recno-1,1);
	document.frm_main.currquestion.value=recno;
	document.frm_main.submit();
}



// *******************************
// ***   GO TO NEXT QUESTION   ***
// ***   Current               ***
// *******************************
function OnNext_Click()
{	var totalrec = parseInt(document.frm_main.totalquestion.value);	
      	var recno = parseInt(document.frm_main.currquestion.value);
	recno=Math.min(recno+1,totalrec);
	document.frm_main.currquestion.value=recno;
	document.frm_main.submit();
}


// *******************************
// ***   GO TO NEXT QUESTION   ***
// ***   Current               ***
// *******************************
function OnJump_Click()
{
        var go_to = parseInt(document.frm_main.jump.value);
	var totalrec = parseInt(document.frm_main.totalquestion.value);	
        if ((go_to >= 1) && (go_to <= totalrec))
      	   { recno=go_to;
	     document.frm_main.currquestion.value=recno;
	     document.frm_main.jump.value='';
	     document.frm_main.submit();
	   }

      	else
           {alert('value must be between 1 and '+totalrec);}
}


function Reset(loc)
{
//	alert(loc.value);
	loc.value="";
}





var request = null;
function createRequest() {
	try {
		request = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				request = null;
			}
		}
	}
	if (request == null)
		alert("Error creating request object!");
}

function addToReport(id) {
	createRequest();
	var url = "/seerinquiry/addToReport.php?id=" + id;
	request.open("GET", url, true);
	request.send(null);
}

function removeFromReport(id) {
	createRequest();
	var url = "/seerinquiry/addToReport.php?remove=" + id;
	request.open("GET", url, true);
	request.send(null);
}

function toggleVisibility(e_id, a_id, saveOption) {
	obj = document.getElementById(e_id);
	anchor = document.getElementById(a_id);
	if (obj.style.display != 'none') {
		display_val = 'none';
		is_displayed = 0;
		obj.style.display = 'none';
		anchor.firstChild.data = 'show';
	}
	else {
		display_val = '';
		is_displayed = 1;
		obj.style.display = '';
		anchor.firstChild.data = 'hide';
	}
	
	if (saveOption) {
		createRequest();
		var url = "/seerinquiry/modifySearchOptions.php?" + e_id + "=" + is_displayed;
		request.open("GET", url, true);
		request.send(null);
	}
}


function clearField(field_id) {
	obj = document.getElementById(field_id);
	obj.value = '';
}


function finalizeQuestion() {
	status = document.getElementById('Question_0'); //status
	status.value = 4; //Final
}


function clearForm(form_id) {
	oForm = document.getElementById(form_id);
	var frm_elements = oForm.elements; 
	
	for (i=0; i<frm_elements.length; i++) {
		field_type = frm_elements[i].type.toLowerCase();
		
		switch(field_type) {
		
			case "text":
			case "password":
			case "textarea":
	       //  case "hidden":
		
			frm_elements[i].value = "";
			break;
		
			//	case "radio":
			//	case "checkbox":
			//	if (elements[i].checked) {
			//	elements[i].checked = false;
			//  }
			//	break;
		
			case "select-one":
			case "select-multi":
		
			frm_elements[i].selectedIndex = -1;
			break;
		
			default:
			break;

		}
	} 

}


function toggleSinqIdsDisplay(fieldIdToDisplay, checkedFieldId, shouldDisplay) {
	checkedField = document.getElementById(checkedFieldId);
	displayField = document.getElementById(fieldIdToDisplay);
	testValue = false;
	//alert(shouldDisplay);
	//alert(testValue);
	if (shouldDisplay == true) {
		displayField.style.display = 'inline';
	}
	else {
		displayField.style.display = 'none';
	}
}



function splitValuesAndSubmit(form_id, field_id) {
	form = document.getElementById(form_id);
	field = document.getElementById(field_id);
	asc = document.getElementById('asc');
	order = document.getElementById('order');
		
	var val = field.options[field.selectedIndex].value;
	var values = val.split(',');
		
	order.value = values[0];
	asc.value = values[1];
	form.submit();
	
}



function modifyDisplayOptions(e_id, display_val, addOption) {
	createRequest();
	var url = "/seerinquiry/modifySearchOptions.php?" + e_id + "=" + display_val;
	
	if (addOption) {
		url = url + "&add=1";
	}
	else {
		url = url + "&remove=1";
	}
	
	request.open("GET", url, true);
	request.send(null);
}


function selectAll(form_id, is_checked) {
	form = document.getElementById(form_id);
	var form_elements = form.elements;
	
	for (i=0; i<form_elements.length; i++) {
		field_type = form_elements[i].type.toLowerCase();
		
		if  (field_type == "checkbox") {
			form.elements[i].checked = is_checked;
		}
	}
}

function selectAllGroup(form_id, is_checked, grp) {
	form = document.getElementById(form_id);
	var form_elements = form.elements;
	var re = new RegExp( grp, "i");
	
	for (i=0; i<form_elements.length; i++) {
		field_type = form_elements[i].type.toLowerCase();
		var element_id = form_elements[i].id;
		
		if  (field_type == "checkbox" && re.test(element_id)) {
			form_elements[i].checked = is_checked;
		}
	}
}


function contentChanged(element_id) {
	row_checkbox = document.getElementById(element_id);
	row_checkbox.checked = true;
	
	modifyMassEditChanged(element_id, true);
}



function modifyMassEditChanged(id, is_checked) {
	createRequest();
	var url = "/seerinquiry/modifyMassEditChanged.php?id=" + id + "&add=" + is_checked;
	
	request.open("GET", url, true);
	request.send(null);
}

// from http://www.htmlcodetutorial.com/linking/linking_famsupp_73.html
function popupform(myform, windowname) {
	if (!window.focus) return true;
	window.open('', windowname, 'height=400,width=500,scrollbars=yes');
	myform.target = windowname;
	return true;
}


// PopUp Link JavaScript Code Provided By: http://www.DesignerWiz.com - Development Resource & JavaScript Public Archive Center -->
function popUp(page,PWidth,PHeight,id) {
	eval("designerwiz"+id+"=window.open('"+page+"','designerwiz1','toolbar=0,scrollbars=1,location=1,status=0,menubar=1,resizable=1,width="+PWidth+",height="+PHeight+"')")
	eval;("wiz"+id+".window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2))")
}



