// Include tooltip JS
	document.write("<script language='JavaScript' src='http://www.nyc.gov/html/dcp/extern/alttxt.js'></script>");
	
// Checks the GeoQuery form for valid fields
function checkGQForm(){

	// Verify form
	if(document.GQForm.sn.value == ""){
		alert("Please Enter Street or Place Name");
		return;
	}
	if(document.GQForm.bo.selectedIndex == 0){
		alert("Please Select a Borough");
		return;
	}

	// If address translator
	if(document.GQForm.qt[0].checked == true){
		location.href = ("http://gis.nyc.gov/dcp/pa/Map?hseNumber=" + escape(document.GQForm.hn.value) + "&address=" + escape(document.GQForm.sn.value) + "&borough=" + escape(document.GQForm.bo[document.GQForm.bo.selectedIndex].value) + "&event=PROCESS_TRACT");
	}

	// If Census App
	else if(document.GQForm.qt[1].checked == true){
		location.href = ("http://gis.nyc.gov/dcp/at/f1.jsp?submit=true&house_nbr=" + escape(document.GQForm.hn.value) + "&street_name=" + escape(document.GQForm.sn.value) + "&boro=" + escape(document.GQForm.bo[document.GQForm.bo.selectedIndex].value));
	}

	/* If CITI App
	else if(document.GQForm.qt[2].checked == true){
		var tempSTR = "http://www.oasisnyc.net/OASISCiti.asp?name=OASIS+Citi&tool=&Action=identify&btnAction=&tab=search&sLot=&sCB=&sCty=&sLeg=&ADDRESS="
		tempSTR = tempSTR + escape(document.GQForm.hn.value)
		tempSTR = tempSTR + "+"
		tempSTR = tempSTR + escape(document.GQForm.sn.value)
		tempSTR = tempSTR + "&AddrBoro="
		tempSTR = tempSTR + escape(document.GQForm.bo[document.GQForm.bo.selectedIndex].value)
		tempSTR = tempSTR + "&BLOCK=&LOT=&Boro=Select+Borough&CD=Select&NYCCB=on&NYC_ST_LABELS=on&STREETS_CITI=on&TRN_CITI=on&LOT_LABELS=&LOTS=on&RESIDENTIAL=&RESIDENTIAL2=&MIXED=&COMMERCIAL=&INSTITUTIONS=&TRANSPORTATION=&INDUSTRIAL=&VACANT=&BUILDINGS_CITI=&NYCHA_CITI_LABELS=&NYCHA_CITI=&PARKS_CITI=on&CEMETERIES_CITI=on&go.x=0&go.y=0"
		location.href = (tempSTR);
	}
	*/
	
	/* If NYC.gov Map Portal App
	else if(document.GQForm.qt[2].checked == true){
		location.href = ("http://gis.nyc.gov/doitt/mp/Address.do?hseNumber=" + escape(document.GQForm.hn.value) + "&strName=" + escape(document.GQForm.sn.value) + "&boro=" + escape(document.GQForm.bo[document.GQForm.bo.selectedIndex].value));
	}
	*/

	// If NYC.gov CityMap App
	else if(document.GQForm.qt[2].checked == true){
		location.href = ("http://gis.nyc.gov/doitt/cm/index.jsp?a=" + escape(document.GQForm.hn.value) + " " + escape(document.GQForm.sn.value) + "&b=" + escape(document.GQForm.bo[document.GQForm.bo.selectedIndex].text));
	}

}

// Selects Radio Button based on input (enables links)
function selectRB(index){
	document.GQForm.qt[index].checked = true;
}


// Prints out Form HTML
function writeGQ(){
	if(! document.layers){
		document.write("<form method='get' name='GQForm' id='GQForm' style='margin-bottom:0;'>");
		document.write("                <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' >      ");
		//document.write("                  <tr align='center'>      ");
		//document.write("                    <td class='Text_black_11_Bold'>");
					   //<table width='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='#003366'>      
//		document.write("                        <tr>      ");	
		//document.write("                          <td width='11%' background='gif/interface/bg_header.gif' class='Text_White_12_Bold'><img src='gif/interface/motif.gif' border='0' alt=''></td>      ");
//		document.write("                          <td height='30' align='center' background='gif/interface/test/bck2.jpg' class='Text_Blue_10_Bold'>OR Search by Address:</td>      ");
//		document.write("                        </tr>      ");
		//document.write("                      </table>      ");
		//document.write("                    </td>      ");
		//document.write("                  </tr>      ");
		document.write("                  <tr align='center'>      ");
		document.write("                    <td class='Text_black_11_Bold'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>      ");
		document.write("                        <tr>      ");
		document.write("                          <td align='center' bgcolor='336699' class='Text_White_10'><table border='0' cellspacing='0' cellpadding='0'>      ");
		document.write("                              <tr>      ");
		document.write("                                <br><td class='Text_gray_11'>Addr#</td>      ");
		document.write("                                <td>&nbsp;</td>      ");
		document.write("                                <td class='Text_gray_11'>Street Name</td>      ");
		document.write("                              </tr>      ");
		document.write("                              <tr>      ");
		document.write("                                <td><input name='hn' type='text' class='search-box2' id='hn' size='5'>      ");
		document.write("                                </td>      ");
		document.write("                                <td>&nbsp;</td>      ");
		document.write("                                <td><input name='sn' type='text' class='search-box2' id='sn' size='10'>      ");
		document.write("                                </td>      ");
		document.write("                              </tr>      ");
		document.write("                            </table>      ");
		document.write("                          </td>      ");
		document.write("                        </tr>      ");
		document.write("                        <tr bgcolor='#F4F4F4'>      ");
		document.write("                          <td height='20' align='center' bgcolor='336699' class='Text_White_11'>Borough: </td>      ");
		document.write("                        </tr>      ");
		document.write("                        <tr bgcolor='#F4F4F4'>      ");
		document.write("                          <td align='center' bgcolor='336699' class='Text_gray_11'><select name='bo' class='search-box2' id='select3'>      ");
		document.write("                              <option value='0' selected>Select Borough:</option>      ");
		document.write("                              <option value='2'>Bronx</option>      ");
		document.write("                              <option value='3'>Brooklyn</option>      ");
		document.write("                              <option value='1'>Manhattan</option>      ");
		document.write("                              <option value='4'>Queens</option>      ");
		document.write("                              <option value='5'>Staten Island</option>      ");
		document.write("                            </select>      ");
		document.write("                          </td>      ");
		document.write("                        </tr>      ");
		document.write("                        <tr bgcolor='#F4F4F4'>      ");
		document.write("                          <td height='20' align='center' valign='middle' bgcolor='336699' class='Text-White-11'>      ");
		document.write("                           </td>      ");
		document.write("                        </tr>      ");
		document.write("                        <tr bgcolor='#F4F4F4'><td bgcolor='336699'><img src='gif/neigh_info/choose_text.gif' border='0' alt=''></td></tr>      ");
document.write("                        <tr bgcolor='#F4F4F4'>      ");
		document.write("                          <td align='center' bgcolor='336699' class='Text-White-10'><table width='100%' border='0' cellpadding='0' cellspacing='0' class='Table-Border-Gray'>      ");
		document.write("                              <tr>      ");
		document.write("                                <td valign='middle' height='80'>    ");

		// Option for Census FactFinder
		document.write("								  <table width='100%' cellpadding='0' cellspacing='0'>      ");
		document.write("                                    <tr>      ");
		document.write("                                      <td valign='middle' class='Text-White-10'><input name='qt' type='radio' value='pa' checked>      ");
		document.write("                                      </td>      ");
		document.write("                                      <td height='20' valign='middle' class='Text_gray_11'><a href='javascript:selectRB(0);' class='link-gray-11' onmouseover='callwritetxt(0)' onmouseout='writetxt(0)'> Census      ");
		document.write("                                          FactFinder</a>      ");
		document.write("                                      </td>      ");
		document.write("                                    </tr>      ");
		document.write("                                  </table>      ");
		
		// Option for Address Translator
		document.write("                                    <table width='100%' cellpadding='0' cellspacing='0'>      ");
		document.write("                                      <tr>      ");
		document.write("                                        <td valign='middle' class='Text-White-10'><input type='radio' name='qt' value='at'>      ");
		document.write("                                        </td>      ");
		document.write("                                        <td height='20' valign='middle' class='Text_gray_11'><a href='javascript:selectRB(1);' class='link-gray-11' onmouseover='callwritetxt(1)' onmouseout='writetxt(0)'> Address      ");
		document.write("                                            Translator</a>      ");
		document.write("                                        </td>      ");
		document.write("                                      </tr>      ");
		document.write("                                    </table>      ");
		
		// Option for CITI Property Information
		// document.write("                                    <table width='100%' cellpadding='0' cellspacing='0'>      ");
		// document.write("                                      <tr>      ");
		// document.write("                                        <td valign='middle' class='Text-White-10'><input type='radio' name='qt' value='ci'>      ");
		// document.write("                                        </td>      ");
		// document.write("                                        <td height='20' valign='middle' class='Text-White-10'><a href='javascript:selectRB(2);' class='link_white_12' onmouseover='callwritetxt(2)' onmouseout='writetxt(0)'> CITI       ");
		// document.write("                                            Property Info</a>      ");
		// document.write("                                        </td>      ");
		// document.write("                                      </tr>      ");
		// document.write("                                    </table>      ");

		// Option for NYC Map Portal
		document.write("                                    <table width='100%' cellpadding='0' cellspacing='0'>      ");
		document.write("                                      <tr>      ");
		document.write("                                        <td valign='middle' class='Text-White-10'><input type='radio' name='qt' value='mp'>      ");
		document.write("                                        </td>      ");
		document.write("                                        <td height='20' valign='middle' class='Text_gray_11'><a href='javascript:selectRB(2);' class='link-gray-11' onmouseover='callwritetxt(2)' onmouseout='writetxt(0)'>");
		document.write("                                            NYC.gov CityMap</a>      ");
		document.write("                                        </td>      ");
		document.write("                                      </tr>      ");
		document.write("                                    </table>      ");
		
		document.write("                                </td>      ");
		document.write("                              </tr>      ");
		document.write("                            </table>      ");
		document.write("                          </td>      ");
		document.write("                        </tr>      ");
		document.write("                        <tr bgcolor='#F4F4F4'>      ");
		document.write("                          <td align='center' bgcolor='336699' class='Text-White-10'><p>      ");
		document.write("                              <input type='hidden' name='submit' value='true'>      ");
		document.write("                              <br>      ");
		document.write("                              <a href='javascript:checkGQForm();'><img src='gif/interface/go.gif' alt='Click Once to Submit Query' border='0'></a><br>      ");
		document.write("                              <br>      ");
		document.write("                          </td>      ");
		document.write("                        </tr>      ");
		document.write("                      </table>      ");
		document.write("                    </td>      ");
		document.write("                  </tr>      ");
		document.write("                </table>      ");
		document.write("              </form>      ");
		
		// Div for tooltip
		document.write("<div id='navtxt' style='position:absolute; top:-100px; left:0px; visibility:hidden; width:300px; font-size:11px; layer-background-color:#C6CFDE; background-color:#FFFFCC; color:#000000; font-family: Verdana, Arial, Helvetica, sans-serif; border: 1px darkgray outset'></div>		");
	}
}

// Support for writeGQ()
// IMPORTANT: THIS FUNCTION REQUIRES FOR THE INCLUSION OF alttxt.js AND navtxt DIV.
function callwritetxt(option){
	if(option == 0){
		writetxt("View a profile of the population in your census tract based on the 2000 census.");
	}
	else if(option == 1){
		writetxt("Geographic information such as Administrative and Political Districts, Zip Code, Block &amp; Lot Number, Police Precinct, Cross Streets and more...");
	}
	//else if(option == 2){
	//	writetxt("<img src='http://www.nyc.gov/html/dcp/gif/app_geoquery/citi_home.gif' align='left' hspace='5'> Maps of properties & information on land use, zoning, ownership and more. Citi is a project of the Municipal Art Society and is not associated with NYC.gov.");
	//}
	else if(option == 2){
		writetxt("Other NYC Data including building, property, community information and neighborhood statistics.");
	}
}