// invoked by towncntr.htm
var buttonSpacing = 2;
var buttonOnColor = "3975CE";
var buttonOffColor = "EFF3FF";
var button_leftblueSrc = "http://www.ziptowns.com/images/button_leftblue.gif";
var button_rightblueSrc = "http://www.ziptowns.com/images/button_rightblue.gif";
var img_signin = "http://www.ziptowns.com/images/icn_login.gif";
var img_signou = "http://www.ziptowns.com/images/icn_logout.gif";
var img_login  = "http://www.ziptowns.com/images/signin_key.gif";
var img_signup = "http://www.ziptowns.com/images/signup_arrow.gif";
var img_gray   = "http://www.ziptowns.com/images/gray_gradient.jpg";
var img_tline  = "http://www.ziptowns.com/images/tag_line.gif";
var img_logo   = "http://www.ziptowns.com/images/zt_logo.gif";
//var img_topbg  = "http://www.ziptowns.com/images/stripe_bg.jpg";
var img_topbg  = "http://www.ziptowns.com/images/top_tag.gif";
var img_home   = "http://www.ziptowns.com/images/icon_home.gif";
var img_acc    = "http://www.ziptowns.com/images/icon_acc.gif";
var img_add    = "http://www.ziptowns.com/images/icon_add.gif";
var img_ptrr   = "http://www.ziptowns.com/images/arrow_brwn_right10.jpg";
var img_usps   = "http://www.ziptowns.com/images/icon_usps.gif";
var img_item   = "http://www.ziptowns.com/images/icon_item.jpg";
var img_hdr_itm= "http://www.ziptowns.com/images/icn_stuff.jpg";
var url_top = "http://www.ziptowns.com/gt_upld.pl?clicType=gt_new&zipcode="+thisZip+"&uAlias="+uAlias+"";
var url_zip = "http://www.ziptowns.com/cgi-bin/gt_zip.pl?clicType=gt_zip&zipcode="+thisZip;
var url_login  = "http://www.ziptowns.com/cgi-bin/login.pl";
var url_accmg  = "http://www.ziptowns.com/cgi-bin/accmgr.pl";
var url_signup = "http://www.ziptowns.com/gt_signup.htm";
var url_index  = "http://www.ziptowns.com/cgi-bin/gt_zip.pl";
var url_zip    = "http://www.ziptowns.com/cgi-bin/gt_zip.pl?clicType=gt_zip&zipcode="+thisZip;
var url_logout = "http://www.ziptowns.com/cgi-bin/logout.pl";
var url_gtzip  = "http://www.ziptowns.com/cgi-bin/gt_zip.pl";
var url_help   = "http://www.ziptowns.com/index.htm";
// to match the definition in subctglist.js
var topc_link=["","Services Directory", "Jobs Nearby", "For Sale", "Community Center"];
//------------ random number controller -----------
function randomByTime(range) {
// generate a random based the time in seconds when it is called
var now = new Date();
// note: getTime() return the number of milliseconds since 1/1/1970
var thisSec = parseInt(now.getSeconds());
thisSec = thisSec % range;
return thisSec;
}
function randomByMath(range) {
// generate a random number if Math.random function available
if (Math.random) {
return Math.round(Math.random() * (range-1));
} else { // just in case the Math function is not available
var thisSec = randomByTime(range);
return thisSec;
// note: getTime() return the number of milliseconds since 1/1/1970
}
}
// Usage:
// var myArr = new Array();
//     myArr[0]= "...";
//     myArr[1]= "...";
// var theChoice = randomByTime(myArr.length);
//------------ END random number controller -----------
function accmg() {
if (uAlias == "Guest") {
alert("Member only. Please sign in.");
} else {
var theForm = document.accmgForm;
theForm.clicType.value = "acct";
theForm.submit();
}
}
function login() {
var theForm = document.loginForm;
theForm.submit();
return false;
}
function logout() {
// clear the cookie
var ePtrObject = new Object;
ePtrObject.value = "00";
writeCookie("ePtr", ePtrObject);
var theForm = document.logoutForm;
theForm.submit();
return false;
}
function hoverTD(whichTD, idx, whichStyle, mouseOutColor) {
// whichTD = TD name, such as "HDR", etc
// idx = detailed ID, to be joined with whichTD to form a unique ID
// whichStyle = over/out (users mouse is hovering over or moving out)
var myTd = document.getElementById(whichTD+idx);
if (whichStyle == "over") {
myTd.style.backgroundColor = "6699cc"; // green - 27eafb; gold - E8E000
} else { // whichStyle = "out"
myTd.style.backgroundColor = mouseOutColor;
}
var myFontTd = document.getElementById(whichTD+"_FONT"+idx);
if (whichStyle == "over") {
myFontTd.style.color = "ffffff"; // green - 27eafb; gold - E8E000
} else { // whichStyle = "out"
myFontTd.style.color = "6699cc";
}
}
function focusButton(buttonStatus, statusText, buttonIdx) {
if (buttonSelectedIdx != buttonIdx) {
switch (buttonStatus) {
case "over":
window.status = statusText;
if (buttonIdx != buttonSelectedIdx) {
var theButton = document.getElementById("button"+buttonIdx);
theButton.style.backgroundColor=buttonOnColor;
var theText = document.getElementById("text"+buttonIdx);
theText.style.color = "#ffffff";
}
break;
case "out":
window.status = "";
if (buttonIdx != buttonSelectedIdx) {
var theButton = document.getElementById("button"+buttonIdx);
theButton.style.backgroundColor=buttonOffColor;
var theText = document.getElementById("text"+buttonIdx);
theText.style.color = "#3161A5";
}
break;
default:
break;
}
}
}
function clickKW(kword) {
formFiller("kw_select", kword);
uploadToServer();
return false;
}
function changePage(catg_ptr) {
var theForm = document.headerForm;
theForm.clicType.value = "gt_new";
theForm.topc_select.value = catg_ptr; // implied 0 to Comm
theForm.catg_select.value = '0';
theForm.subc_select.value = '0';
theForm.submit();
//return false;
}
function setRadius(rad_op) {
var theForm = document.headerForm;
theForm.clicType.value = "gt_new";
theForm.radius.value = rad_op;
theForm.topc_select.value = "100"; // force to towncenter
theForm.catg_select.value = '0';
theForm.subc_select.value = '0';
theForm.submit();
}
function setZipCode() {
// this code operate across two forms
// first is the headerform
// check if the zipcode is valid
var hdrForm = document.headerForm;
var errorMsg = "";
var errorFlag = "no";
var errorBgColor = "#ff8888";
hdrForm.zipcode.style.backgroundColor = "#ffffff";
var enteredZip = hdrForm.zipcode.value;
if (!validZip(enteredZip)) {
errorMsg += "\nPlease enter a valid zipcode.";
hdrForm.zipcode.style.backgroundColor = errorBgColor;
errorFlag = "yes";
document.headerForm.zipcode.select();
}
if (errorFlag == "yes") {
alert(errorMsg);
} else {
// save the zip code in client cookie (for javacript only)
var zipObject = new Object;
zipObject.value = enteredZip;
writeCookie("zipcode", zipObject);
// save the zipcode to the form to be submitted
var sbmForm = document.myZipForm;
if (uAlias == "Guest") {
alert("Please sign in first.");
} else {
sbmForm.zipcode.value= enteredZip;
sbmForm.submit();
}
}
} // function setZipCode(cType)
function chgZipCode(cType) {
var theForm = document.headerForm;
var errorMsg = "";
var errorFlag = "no";
var errorBgColor = "#ff8888";
theForm.zipcode.style.backgroundColor = "#ffffff";
var enteredZip = theForm.zipcode.value;
if (!validZip(enteredZip)) {
errorMsg += "\nPlease enter a valid zipcode.";
theForm.zipcode.style.backgroundColor = errorBgColor;
errorFlag = "yes";
document.headerForm.zipcode.select();
}
if (errorFlag == "yes") {
alert(errorMsg);
return false;
}
theForm.clicType.value = cType;
// save the zip code in client cookie (for javacript only)
var zipObject = new Object;
zipObject.value = enteredZip;
writeCookie("zipcode", zipObject);
theForm.submit();
return false;
}
//------------- Header body -------------
document.write("<Table border=0 cellspacing=0 cellpadding=0 background=\""+img_topbg+"\" width=760>");
document.write("<tr>");
document.write("<\/tr>");
document.write("<tr>");
document.write("<td width=5><\/td>");
document.write("<td width=190 valign=top><a href=\""+url_index+"\"><img src=\""+img_logo+"\" border=0><\/a><\/td>");
document.write("<td width= 5><\/td>");
document.write("<td width=560 valign=top align=right>");
document.write("<Table border=0 cellspacing=0 cellpadding=0 width=100%>");
document.write("<tr><td width=230>");
document.write("<\/td>");
document.write("<td width=10><\/td>");
document.write("<td width=340 align=right>");
// city name and ZIP change
document.write("<Table border=0 cellspacing=0 cellpadding=0>");
document.write("<form name=\"accmgForm\" action=\""+url_accmg+"\" method=\"post\">");
document.write("<input type=\"hidden\" name=\"topc_select\" value=\""+topc_idx+"\">");
document.write("<input type=\"hidden\" name=\"catg_select\" value=\""+catg_idx+"\">");
document.write("<input type=\"hidden\" name=\"subc_select\" value=\""+subc_idx+"\">");
document.write("<input type=\"hidden\" name=\"clicType\" value=\"init\">");
document.write("<input type=\"hidden\" name=\"uAlias\" value=\""+uAlias+"\">");
document.write("<input type=\"hidden\" name=\"ePtr\" value=\""+ePtr+"\">");
document.write("<input type=\"hidden\" name=\"zipcode\" value=\""+thisZip+"\">");
document.write("<\/form>");
document.write("<form name=\"loginForm\" action=\""+url_login+"\" method=\"post\">");
document.write("<input type=\"hidden\" name=\"topc_select\" value=\""+topc_idx+"\">");
document.write("<input type=\"hidden\" name=\"catg_select\" value=\""+catg_idx+"\">");
document.write("<input type=\"hidden\" name=\"subc_select\" value=\""+subc_idx+"\">");
document.write("<input type=\"hidden\" name=\"thisPage\" value=\""+thisPage+"\">");
document.write("<input type=\"hidden\" name=\"itemPtr\" value=\""+itemPtr+"\">");
document.write("<input type=\"hidden\" name=\"zipcode\" value=\""+thisZip+"\">");
document.write("<\/form>");
document.write("<form name=\"logoutForm\" action=\""+url_logout+"\" method=\"post\">");
document.write("<input type=\"hidden\" name=\"zipcode\" value=\""+thisZip+"\">");
document.write("<input type=\"hidden\" name=\"topc_select\" value=\""+topc_idx+"\">");
document.write("<input type=\"hidden\" name=\"catg_select\" value=\""+catg_idx+"\">");
document.write("<input type=\"hidden\" name=\"subc_select\" value=\""+subc_idx+"\">");
document.write("<\/form>");
document.write("<form name=\"myZipForm\" action=\""+url_gtzip+"\" method=\"post\">");
document.write("<input type=\"hidden\" name=\"clicType\" value=\"gt_addzip\">");
document.write("<input type=\"hidden\" name=\"topc_select\" value=\""+topc_idx+"\">");
document.write("<input type=\"hidden\" name=\"catg_select\" value=\""+catg_idx+"\">");
document.write("<input type=\"hidden\" name=\"subc_select\" value=\""+subc_idx+"\">");
document.write("<input type=\"hidden\" name=\"uAlias\" value=\""+uAlias+"\">");
document.write("<input type=\"hidden\" name=\"ePtr\" value=\""+ePtr+"\">");
document.write("<input type=\"hidden\" name=\"zipcode\" value=\""+thisZip+"\">");
document.write("<\/form>");
document.write("<form name=\"headerForm\" action=\""+url_gtzip+"\" method=\"post\" onSubmit=\"return chgZipCode('gt_new');\">");
document.write("<input type=\"hidden\" name=\"radius\" value=\""+thisRadius+"\">");
document.write("<input type=\"hidden\" name=\"clicType\" value=\"gt_new\">");
document.write("<input type=\"hidden\" name=\"topc_select\" value=\""+topc_idx+"\">");
document.write("<input type=\"hidden\" name=\"catg_select\" value=\""+catg_idx+"\">");
document.write("<input type=\"hidden\" name=\"subc_select\" value=\""+subc_idx+"\">");
document.write("<input type=\"hidden\" name=\"uAlias\" value=\""+uAlias+"\">");
document.write("<input type=\"hidden\" name=\"ePtr\" value=\""+ePtr+"\">");
document.write("<tr><td height=5><\/td><\/tr>"); // 340
document.write("<tr><td>");
document.write("<font style=\"color: #C47D65; font-size: 13px; font-family: verdana; font-weight: bold;\">"+thisTown+"<\/font>");
document.write("<\/td><\/tr>");
document.write("<tr><td height=5><\/td><\/tr>");
document.write("<tr><td align=right>");
document.write("<input type=\"text\" name=\"zipcode\" size=6 maxlength=5 value=\""+thisZip+"\" style=\"font-size: 12px; font-family: verdana; color:c47d65; font-weight: bold;\"> <input type=\"submit\" value=\"Change\" style=\"font-size: 11px; font-family: verdana;\"> &nbsp; <\/font>");
document.write("<a href=\"javascript:setZipCode();\" style=\"font-family: verdana; font-size: 11px; color:6699cc; text-decoration: underline; \">Add to My Zip<\/a><\/td><\/tr>");
document.write("<\/form>");
document.write("<\/table>");
document.write("<\/td><\/tr>");
document.write("<tr><td colspan=3 align=right>");
// url links    width=560
document.write("<Table border=0 cellspacing=0 cellpadding=0 width=560>");
document.write("<tr><td height=5><\/td><\/tr>");
document.write("<tr>");
document.write("<td width=218 align=center><font style=\"color: #aa4411; font-size: 11px; font-family: verdana;\"><b>Hello "+uAlias+" ! <\/b><\/font><\/td>");
document.write("<td width=12><\/td>");
document.write("<td align=right> &nbsp;");
document.write("<a href=\"javascript:accmg();\" style=\"font-family: verdana; font-size: 11px; color:6699cc; text-decoration: none;\" >Account<\/a>");
document.write("<font style=\"color: acacac; font-size: 11px; font-family: arial;\"> &nbsp; | &nbsp; <\/font>");
document.write("<a href=\""+url_zip+"\" style=\"font-family: verdana; font-size: 11px; color:6699cc; text-decoration: none;\" >ZIPcodes Nearby<\/a>");
document.write("<font style=\"color: acacac; font-size: 11px; font-family: arial;\"> &nbsp; | &nbsp; <\/font>");
if (uAlias == "Guest") {
document.write("<a href=\"javascript:login()\" style=\"font-family: verdana; font-size: 11px; color:6699cc; text-decoration: none;\"><b>Join/Sign In<\/b> <\/a>");
} else {
document.write("<a href=\"javascript:logout();\" style=\"font-family: verdana; font-size: 11px; color:6699cc; text-decoration: none;\">Sign out <\/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("<\/Table>");
document.write("<Table border=0 cellspacing=0 cellpadding=0 width=760>");
//    document.write("<tr><td height=10><\/td><\/tr>");
document.write("<tr><td height=1 bgcolor=C8D1F2><\/td><\/tr>"); //90581b
document.write("<tr><td height=2 bgcolor=efF3fF><\/td><\/tr>");
document.write("<\/table>");
//------------- END Header body -------------
