function print_menu() {
	document.write('' +
'                        <table summary="" align="right" border="0" cellspacing="0" cellpadding="3" width=100%>' +
'                        <tr width=100% align="right">' +
'                            <td width=100%>&nbsp;' + 
'								</td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu0" class="inactive_menu">' + 
'							 <a class="menu_link" href="/index.html" onmouseover="document.getElementById(\'menu0\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu0\').className=\'inactive_menu\'">Home</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu1" class="inactive_menu">' + 
'                            <a class="menu_link" href="/search/" onmouseover="document.getElementById(\'menu1\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu1\').className=\'inactive_menu\'">Property Search</a> </td>' +
'							 <!--<a class="menu_link" href="#" onmouseover="document.getElementById(\'menu1\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu1\').className=\'inactive_menu\'" onclick="window.open(\'http://remax.realtor.com/FindHome/SearchOptions.asp?frm=bymap&mls=xmls&typ=1&typ=2&typ=3&typ=4&typ=5&typ=6&lnksrc=&js=on&gate=remax&poe=realtor&ct=&st=&zp=&mnbed=0&mnbath=0&mnprice=0&mxprice=99999999\',\'searchResult\', \'scrollbars=yes,location=no,toolbar=no,menubar=no\')">Property Search</a> </td>-->' +
'                        </tr>' +
'                        <!--<tr width=100% align="right">' +
'                            <td width=100% id="menu2" class="inactive_menu">' +
'                            <a class="menu_link" href="/feature/" onmouseover="document.getElementById(\'menu2\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu2\').className=\'inactive_menu\'">Featured Homes</a> </td>' +
'                        </tr>-->' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu3" class="inactive_menu">' +
'                            <a class="menu_link" href="/interest/" onmouseover="document.getElementById(\'menu3\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu3\').className=\'inactive_menu\'">Interest Rate</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu4" class="inactive_menu">' +
'                            <a class="menu_link" href="/mortgage/" onmouseover="document.getElementById(\'menu4\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu4\').className=\'inactive_menu\'">Mortgage Calculator</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu4a" class="inactive_menu">' +
'                            <a class="menu_link" href="/news/" onmouseover="document.getElementById(\'menu4a\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu4a\').className=\'inactive_menu\'">Syndicated News</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu5" class="inactive_menu">' +
'                            <a class="menu_link" href="/newsletter/" onmouseover="document.getElementById(\'menu5\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu5\').className=\'inactive_menu\'">Printed Newsletter</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu6" class="inactive_menu">' +
'                            <a class="menu_link" href="/enewsletter/" onmouseover="document.getElementById(\'menu6\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu6\').className=\'inactive_menu\'">eNewsletter</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="right">' +
'                            <td width=100% id="menu7" class="inactive_menu">' +
'                            <a class="menu_link" href="/blog/" onmouseover="document.getElementById(\'menu7\').className=\'active_menu\'" onmouseout="document.getElementById(\'menu7\').className=\'inactive_menu\'">REM Blog</a> </td>' +
'                        </tr>' +
'                        <tr width=100% align="center">' +
'                            <td>' +
'                            <br><a href="/newsletter/"><img src="/images/newsletterp1.gif" alt="Real Estate Dynamics Newsletter" border="0" width="80"/></a><br>' +
'                            <font style="font-size:8pt"><a class="footer_link" href="/cgi-bin/sub_news.pl">Subscribe my Newsletter</a></font>' +
'                            </td>' +
'                        </tr>' +
'                        <tr width=100% align="center">' +
'                            <td>' +
'                            <br><a href="http://www.remax-ca.com/" target="_blank"><img src="/images/remax_leaders.jpg" alt="RE/MAX Accord" border="0" width="150"/></a>' +
'                            </td>' +
'                        </tr>' +
'                        </table>' 
	);
}

function print_contact_box() {
	document.write('' +
'                   <table summary="" width=100% style="color:#FFFFFF;font-size:10pt;margin-left:6px">' +
'                       <tr width=100%>' +
'                         <td>' +
'                           <font style="font-size:16pt">www.QiRealty.com</font><br>' +
'                           <font style="font-weight:bold">Hong Qi, Ph.D.</font><br>' +
'                           RE/MAX Accord<br>' +
'                           313 Sycamore Valley Rd W <br>' +
'                           Danville,  CA  94526 <br>' +
'                         </td>' +
'                         <td align="right">' +
'                           <font style="font-weight:bold">Direct:</font> 925.914.0868 <br>' +
'                           <!--<font style="font-weight:bold">Mobile:</font> 925.914.0868 <br>-->' +
'                           <font style="font-weight:bold">Email:</font> <a class="footer_link" href="mailto:&#072;&#111;&#110;&#103;&#064;&#081;&#105;&#082;&#101;&#097;&#108;&#116;&#121;&#046;&#099;&#111;&#109;">&#072;&#111;&#110;&#103;&#064;&#081;&#105;&#082;&#101;&#097;&#108;&#116;&#121;&#046;&#099;&#111;&#109;</a><br><br>' +

'                           <font style="font-weight:bold;color:#d6993f">|&nbsp; <a class="header_link" href="/about.html">about me</a> &nbsp;|&nbsp; <a class="header_link" href="/contact.html">contact me</a> &nbsp;|&nbsp; <a class="header_link" href="testimonial.html">testimonials</a> &nbsp;|</font>' +
'                         </td>' +
'                         <td width="6">' +
'                           &nbsp;' +
'                         </td>' +
'                       </tr>' +
'                    </table>' 
	);
}

function header() {
	document.write('' +
'<table summary="" width=100% border="0" cellspacing="0" cellpadding="0" bgcolor="#367298">' +
'   <tr width=100%>' +
'	<td width=170 valign="top">' +
'       <!-- left panel start -->' +
'	    <table summary="" width=100% border="0" cellspacing="0" cellpadding="0">' +
'           <tr width=100%>' +
'                <td width=100% valign=middle align=center>' +
'		         <!-- photo start -->' +
'                <br><img alt="Hong Qi" src="/images/hong_qi.jpg" border="0" width=120>' +
'                <!-- photo end -->' +
'                </td>' +
'		    </tr>' +
'		    <tr>' +
'                <td>' +
'                <!-- menu start -->');
	print_menu();
	document.write('' +
'                <!-- menu end -->' +
'                </td>' +
'		    </tr>' +
'	    </table>' +
'	    <!-- left panel end -->' +
'	</td>' +
'	<td valign="top" bgcolor="#FFFFFF">' +
'	    <table summary="" width=100% border="0" cellspacing="0" cellpadding="0">' +
'           <tr width=100% >' +
'               <td width=100% bgcolor="#367298">'+
'               <!-- contact box start -->');
	print_contact_box();
	document.write('' +
'               <!-- contact box end -->' +
'               </td>' +
'           </tr>' +
'           <tr width=100% >' +
'               <td width=100%>' +
'               <!-- start body content -->'
	);
}

function footer() {
	document.write('                        ' +
'               <!-- end body content -->' +
'               </td>' +
'           </tr>' +
'       </table>' +
'   </td>' +
'	<!-- right panel end-->' +
'   <td width=10>&nbsp;</td>' +
'   </tr>' +
'</table>' +
'<br>' +
'<center><font style="color:#FFFFFF;font-size:8pt">Copyright &#169; 2004 Qi Realty. All Rights Reserved&#160;|<a class="footer_link" href="/contact.html">&#160;Contact Us&#160;</a>|&#160;Privacy Policy</font></center>'
);

}

function today() {
    var tStamp = new Date();
    var monthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    document.write((monthName[tStamp.getMonth()]) +" "+tStamp.getDate()+ ", "+tStamp.getFullYear());
}

function before_n_days(n) {
    var date = new Date();
    date.setTime(date.getTime() - 24*60*60*1000*n);
    var d  = date.getDate();
    var dd = (d < 10) ? '0' + d : d;
    var m = date.getMonth() + 1;
    var mm = (m < 10) ? '0' + m : m;
    var yy = date.getYear();
    var yyyy = (yy < 1000) ? yy + 1900 : yy;
    var formated = mm + "/" + dd + "/" + yyyy;
    
    return formated;
}

function validate_enews() {
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid


	if (!reg1.test(document.sub_enews.Email.value) && reg2.test(document.sub_enews.Email.value)) {
		return true;
	} else {
		alert("Please enter email in the right format"); 
		document.sub_enews.Email.focus();
		document.sub_enews.Email.select();
		return false;
	}
}		

function write_sub_enewsletter() {
	document.write('' +
'							<table cellspacing="0" cellpadding="3" width="100%">' +
'							<tr bgcolor="#E4E8DD">' +
'							<td style="font-weight:bold;font-size:8pt;color:#336699">Sign Up for The eNewsletter!</td>' +
'							</tr>' +
'							<tr>' +
'							<td style="border-left:solid 1px #E4E8DD; border-bottom:solid 1px #E4E8DD; border-right:solid 1px #E4E8DD;" align="center"><a id="enews_a" name="enews_a" href="mailto:hong@QiRealty.com?subject=subsribe Realty Science - Home Owner\'s Guide&body="></a>' +
'								<form name="sub_enews" action="/cgi-bin/sub_enews.pl" onSubmit="return validate_enews();">' +
'								<font style="font-size:8pt">Email: </font><input type="text" name="Email" id ="Email" size="18" maxlength="40" ><br>' +
'								<input type="submit" value="Subscribe!">' +
'								</form>' +
'							</td>' +
'							</tr>' +
'							</table>'
	);
}

function validate_news() {
	if(document.sub_news.Name.value == "") {
		alert("Please enter your name.");
		document.sub_news.Name.focus();
		return false;
	}

	if (document.sub_news.Email) {
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

		if (document.sub_news.Email.value == "") {
			alert("Please enter your email to receive the PDF version of the newsletter.");
			document.sub_news.Email.focus();
			return false;
		} 
		
		if (!(!reg1.test(document.sub_news.Email.value) && reg2.test(document.sub_news.Email.value))) {
			alert("Please double check your email address format and submit again.");
			document.sub_news.Email.focus();
			document.sub_news.Email.select();
			return false;
		}
	}

	if (document.sub_news.Address.value == "") {
		alert("Please enter your address so we can send you the newsletter.");
		document.sub_news.Address.focus();
		return false;
	}

	if (document.sub_news.City.value == "") {
		alert("Please enter your city.");
		document.sub_news.City.focus();
		return false;
	}

	if (document.sub_news.Zip.value == "") {
		alert("Please enter your zip code.");
		document.sub_news.Zip.focus();
		return false;
	}

	// now submit
	return true;
}
							
function write_sub_newsletter() {
	document.write('' +
'							<table cellspacing="0" cellpadding="3" width="100%">' +
'							<tr bgcolor="#d6993f">' +
'							<td style="font-weight:bold;font-size:8pt;color:#FFFFFF">Get the Real Estate Dynamic Monthly Newsletter (Local Market Analysis)!</td>' +
'							</tr>' +
'							<tr>' +
'							<td style="border-left:solid 1px #d6993f; border-bottom:solid 1px #d6993f; border-right:solid 1px #d6993f;" align="right">' +
'								<form name="sub_news" action="/cgi-bin/sub_news.pl" onSubmit="return validate_news();">' +
'								<font style="font-size:8pt">Name: <input type="text" name="Name" size="15"><br>' +
'								Email: <input type="text" name="Email" size="15"><br>' +
'								Address: <input type="text" name="Address" size="15"><br>' +
'								City: <input type="text" name="City" size="15"><br> ' +
'								Zip: <input type="text" name="Zip" size="6">&nbsp;' +
'								<input type="submit" value="Go!"></font>' +
'								</form>' +
'							</td>' +
'							</tr>' +
'							</table>' 
	);
}

function sub_justlisted() {
	window.open("http://californiamoves.com/homedelivery/user/home.aspx?abrand=7445", "justlisted_alert", "scrollbars=yes,location=no,toolbar=no,menubar=no");     
}

function sub_openhomes() {
	window.open("http://californiamoves.com/homedelivery/user/home.aspx?abrand=7445", "openhomes_alert", "scrollbars=yes,location=no,toolbar=no,menubar=no");     
}

function do_alert() {
	if (document.sub_alert.alert_type[0].checked) {
		sub_justlisted();
	} else if (document.sub_alert.alert_type[1].checked) {
		sub_openhomes();
	}
	  return true; 
}

function write_sub_alert() {
	document.write('' +
'							<table cellspacing="0" cellpadding="3" width="100%">' +
'							<tr bgcolor="#98A2C1">' +
'							<td style="font-weight:bold;font-size:8pt;color:#FFFFFF">Get E-Mail Alerts on</td>' +
'							</tr>' +
'							<tr>' +
'							<td style="border-left:solid 1px #98A2C1; border-bottom:solid 1px #98A2C1; border-right:solid 1px #98A2C1;" align="left">' +
'								<form name="sub_alert">' +
'								<font style="font-size:8pt"><input type="radio" name="alert_type" value="justlisted" checked> Just Listed Homes<br>' +
'								<input type="radio" name="alert_type" value="openhomes"> Open Houses' +
'								<input type="button" value="Submit!" onClick="do_alert();"><br>' +
'								<center><font style="font-size:8pt"> (by californiamoves.com) </font></center>' +
'								</form>' +
'							</td>' +
'							</tr>' +
'							</table>' 
	);
}

function write_lendingtree() {
	document.write('' + 
'							<table cellspacing="0" cellpadding="3" width="100%">' +
'							<tr>' +
'								<td align="center">' +
'								<IMG SRC="http://service.bfast.com/bfast/serve?bfmid=115759&sourceid=40590463&categoryid=mortgage_v1_03" BORDER="0" WIDTH="1" HEIGHT="1" NOSAVE >' +
'								<A HREF="http://service.bfast.com/bfast/click?bfmid=115759&sourceid=40590463&categoryid=mortgage_v1_03" TARGET="_top">' +
'								<IMG SRC="http://www.lendingtree.com/common/bp/affiliates/sb/mtg125x125scour2.gif" BORDER="0" WIDTH="125" HEIGHT="125" ALT=""></A>' +
'								</td>' + 
'							</tr>' +
'							</table>'
	);

}


function write_baycal() {
	document.write('' + 
'							<table cellspacing="0" cellpadding="3" width="100%">' +
'							<tr>' +
'								<td align="center">' +
'								<A HREF="http://www.baycaloan.com" TARGET="_top">' +
'								<IMG SRC="/images/baycal_logo.gif" BORDER="0" WIDTH="180" ALT="BayCal Financial"></A><br>' +
'								<IMG SRC="/images/equal.gif" BORDER="0" ALT="Equal Housing"><IMG SRC="/images/fdic.gif" BORDER="0" ALT="FDIC">' +
'								</td>' + 
'							</tr>' +
'							</table>'
	);

}


function write_google() {
	document.write('' + 
'							<table cellspacing="0" cellpadding="3" width="100%">' +
'							<tr>' +
'								<td align="center">' +
'<script type="text/javascript"><!--' +
'google_ad_client = "pub-2590168480434608";'+
'google_ad_width = 180;' +
'google_ad_height = 150;' +
'google_ad_format = "180x150_as";' +
'google_ad_channel ="";' +
'google_color_border = "CCCCCC";' +
'google_color_bg = "FFFFFF";' +
'google_color_link = "000000";'+
'google_color_url = "666666";' +
'google_color_text = "333333";' +
'//--></script>' +
'<script type="text/javascript"' +
'  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">' +
'</script>' +
'								</td>' + 
'							</tr>' +
'							</table>'
	);

}


function write_google_search() {
    document.write('' +
'							<td bgcolor="#f7f7f7">' +
'								<!-- SiteSearch Google -->' +
'								<form method="get" action="http://www.google.com/custom" target="_top">' +
'								<table border="0" bgcolor="#cccccc">' +
'								<tr><td nowrap="nowrap" valign="top" align="left" height="32">' +
'								<a href="http://www.google.com/">' +
'								<img src="http://www.google.com/logos/Logo_25gry.gif"' +
'								border="0" alt="Google"></img></a>' +
'								<br/>' +
'								<input type="hidden" name="domains" value="QiRealty.com"></input>' +
'								<input type="text" name="q" size="25" maxlength="255" value=""></input>' +
'								</td></tr>' +
'								<tr>' +
'								<td nowrap="nowrap">' +
'								<table>' +
'								<tr>' +
'								<td>' +
'								<input type="radio" name="sitesearch" value=""></input>' +
'								<font size="-1" color="#000000">Web</font>' +
'								</td>' +
'								<td>' +
'								<input type="radio" name="sitesearch" value="QiRealty.com" checked="checked"></input>' +
'								<font size="-1" color="#000000">QiRealty.com</font>' +
'								</td>' +
'								</tr>' +
'								</table>' +
'								<input type="submit" name="sa" value="Search"></input>' +
'								<input type="hidden" name="client" value="pub-2590168480434608"></input>' +
'								<input type="hidden" name="forid" value="1"></input>' +
'								<input type="hidden" name="ie" value="ISO-8859-1"></input>' +
'								<input type="hidden" name="oe" value="ISO-8859-1"></input>' +
'								<input type="hidden" name="safe" value="active"></input>' +
'								<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;"></input>' +
'								<input type="hidden" name="hl" value="en"></input>' +
'' +
'								</td></tr></table>' +
'								</form>' +
'								<!-- SiteSearch Google -->' +
'							</td>'
	);
}



