// home, property, financing, service, decor_garden,lifestyle
var dn=document.domain;
var server=GetServer(document.location);
var adtxt;
// vote
var vote;

function GetServer(str)
{
	if (dn!='www.homeandi.com' && dn!='localhost' )
	{
		return 'http://www.homeandi.com';
	}
	else
	{
		var pos=0;
		var server=new String(str);
		for (i=1;i<=3 ;i++ )
			pos = server.indexOf('/',pos+1);
		server = server.slice(0,pos);
		return server;
	}
}
/*
//Aniversary
function setVariables() {
imgwidth=235;
imgheight=19;
if (navigator.appName == "Netscape") {
horz=".left";
vert=".top";
docStyle="document.";
styleDoc="";
innerW="window.innerWidth";
innerH="window.innerHeight";
offsetX="window.pageXOffset";
offsetY="window.pageYOffset";
}
else {
horz=".pixelLeft";
vert=".pixelTop";
docStyle="";
styleDoc=".style";
innerW="document.body.clientWidth";
innerH="document.body.clientHeight";
offsetX="document.body.scrollLeft";
offsetY="document.body.scrollTop";
   }
}
function checkLocation() {
objectXY="branding";
var availableX=eval(innerW);
var availableY=eval(innerH);
var currentX=eval(offsetX);
var currentY=eval(offsetY);
x=availableX-(imgwidth+350)+currentX;
y=availableY-(imgheight+81)+currentY;
evalMove();
setTimeout("checkLocation()",10);
}
function evalMove() {
eval(docStyle + objectXY + styleDoc + horz + "=" + x);
eval(docStyle + objectXY + styleDoc + vert + "=" + y);
}*/

//popup for button link  -- benefit
function popup_filebox(){
	window.open('/promotion/filebox/','filebox','width=550 height=400, scrollbars=0');
}

//scroll my file box
function showtip2(current,e,text){
  if (document.all&&document.readyState=="complete"){
    document.all.tooltip2.innerHTML='<marquee style="border:1px solid #959000;"><font face="MS Sans Serif, thonburi" size="2">'+text+'</font></marquee>';
    document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10;
    document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10;
    document.all.tooltip2.style.visibility="visible";
	}
  else if (document.layers){
    document.tooltip2.document.nstip.document.write('<b>'+text+'</b>');
    document.tooltip2.document.nstip.document.close();
    document.tooltip2.document.nstip.left=0;
    currentscroll=setInterval("scrolltip()",100);
    document.tooltip2.left=e.pageX+10;
    document.tooltip2.top=e.pageY+10;
    document.tooltip2.visibility="show";
	}
}
function hidetip2(){
  if (document.all)
    document.all.tooltip2.style.visibility="hidden";
  else if (document.layers){
    clearInterval(currentscroll);
    document.tooltip2.visibility="hidden";
	}
}
//LOGIN BOX
function LoginBox(default_url)
{	
	var userid=getCookie("un");		
	if(default_url == null || default_url=='') default_url='/my/filebox.asp';
	if(userid=='' || userid==null){
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="3">');	
		document.write('<form id=frmLogin name=frmLogin method="post" action="/signin.asp">');
		document.write('<tr><td width="20%"><font face="ms Sans Serif, thonburi" size="2" color="#4D692C"><b>My ID</b></font></td></tr>');
		document.write('<tr><td width="20%"><input type="text" name="uid" id="uid" size=12 class="flat_box"></td></tr>');
		document.write('<tr><td width="20%"><font face="ms Sans Serif, thonburi" size="2" color="#4D692C"><b>Password</b></font></td></tr>');
		document.write('<tr><td width="20%"><input type="password" name="pwd" id="pwd" size=12 class="flat_box"></td></tr>');
		document.write('<tr><td><input type="image" src="http://www.homeandi.com/images/ic_login.gif" width="69" height="23" border="0" id=image1 name=image1><input type="hidden" name="done" value="'+ default_url+ '"></td></tr> ');
		document.write('</form>');
		document.write('<tr><td align="center" width="135"><a href="/register/?src=home&done='+ default_url+ '"><img src="http://www.homeandi.com/images/ic_register.gif" width="115" height="23" border=0></a></td></tr>');
		document.write('</table>');
		//button link -- benefit
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="3">');
		document.write('<tr><td align="center" width="135"><a href="javascript:popup_filebox();"><img src="/promotion/filebox/ic_how2myfilebox.gif" width="120" height="42" border="0"></a><img src="/images/blank.gif" width="120" height="5"></td></tr></table>');
	}else{
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.write('<tr><td align=center><br><font class="value">สวัสดีค่ะ<br> ');
		document.write('คุณ ' +userid);
		document.write('</font></td></tr>');
		document.write('<tr><td>');
		document.write('<a href="/my/filebox.asp"><img src="http://www.homeandi.com/images/ic_tomyfilebox2.gif" border=0></a>');
		document.write('</td></tr>');
		document.write('<tr><td>');
		document.write('<a href="/signout.asp"><img src="http://www.homeandi.com/images/ic_signout2.gif" border=0></a>');
		document.write('</td></tr>');
		document.write('</table><br>');
	}	
	document.write('<table width="100%"border="0"><tr><td align="center" width="135"><a href="http://www.homeandi.com/content/c1191.html"><img src="/images/ic_onmobile.gif" width="120" height="42" border="0"></a><img src="/images/blank.gif" width="120" height="5"><br><br></td></tr></table>');
	//document.write('<table width="100%"border="0"><tr><td align="center" width="135"><a href="http://www.homeandi.com/activity/AFC2007/announce.html" target="_blank"><img src="/activity/AFC2007/bn_announce.gif" width="120" height="80" border="0"></a><img src="/images/blank.gif" width="120" height="5"><br><br></td></tr></table>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function Header(site,adv)
{
	if (site=='' || site==null) site='home';
	if (adv=='' || adv==null) adv='homeandi.index.home';

	//Wristband();
	MainMenu(site,adv);
	SubMenu(site);
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function Wristband() {
	document.write('<table width="740" border="0" cellpadding="0" cellspacing="0">');
	document.write('<tr><td height="37" style="background: #343b3d url('+server+'/download/kk_band.gif) no-repeat center ">&nbsp;</td></tr>');
	document.write('<tr><td height="15"></td></tr>');
	document.write('</table>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function MainMenu(site,adv)
{
	// Display Logo, Ad Banner ,and Main Menu
	document.write('<table width="740" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr>');
	// Logo
	document.write('<td width="125" valign="top" align="center"><a href="'+server+'/home.html" target="_parent"><img src="http://www.homeandi.com/images/homeandi_logo.gif" border=0></a></td>');
	document.write('<td valign="bottom">');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	// Banner
	document.write('<tr align="center" valign="top"><td height="70" align="center">');
	
	//Banner Adv
	document.write('<IFRAME  WIDTH="468" HEIGHT="60"  MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" SRC="http://www.homeandi.com/adnow2/redirect/adrun.asp?location='+adv+'&position=top"></iframe>');
	document.write('</td></tr>');
	document.write('<tr>');
	document.write('<td width="20%">');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr align="center"> ');	
	
	TabMenu(site)

	// End Main Menu
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function TabMenu(site)
{
	// Main Menu
	document.write('<td width="103"><a href="'+server+'/home.html" target="_parent"><img src="http://www.homeandi.com/images/ic_home' + ((site=='home')?'2':'1') +'.gif" width="98" height="24" border="0"></a></td>');
	document.write('<td width="103"><a href="'+server+'/property/" target="_parent"><img src="http://www.homeandi.com/images/ic_property' + ((site=='property')?'2':'1') +'.gif" width="98" height="24" border="0"></a></td>');
		document.write('<td width="103"><a href="'+server+'/finance/" target="_parent"><img src="http://www.homeandi.com/images/ic_financing' + ((site=='financing')?'2':'1') +'.gif" width="98" height="24" border="0"></a></td>');
	document.write('<td width="103"><a href="'+server+'/service/" target="_parent"><img src="http://www.homeandi.com/images/ic_h-service' + ((site=='service')?'2':'1') +'.gif" width="97" height="24" border="0"></a></td>');
	document.write('<td width="103"><a href="'+server+'/decor_garden/" target="_parent"><img src="http://www.homeandi.com/images/ic_garden-decor' + ((site=='decor_garden')?'2':'1') +'.gif" width="116" height="24" border="0"></a></td>');
	document.write('<td width="103"><a href="'+server+'/lifestyle/" target="_parent"><img src="http://www.homeandi.com/images/ic_lifestyle' + ((site=='lifestyle')?'2':'1') +'.gif" width="98" height="24" border="0"></a></td>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function SubMenu(site)
{
	// Display Text My File Box and Sub Menu
	document.write('<table width="740" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr>');
	document.write('<td width="125" valign="top" bgcolor="#CEE6AC" height="16">');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#6FAD2E">');
	document.write('<tr>');
	document.write('<td width="16"><img src="http://www.homeandi.com/images/p001.gif" width="16" height="16"></td>');
	// Text
	if(dn=='www.homeandi.com' || dn=='localhost')
	{
		document.write('<div id="tooltip2" style="position:absolute;visibility:hidden;clip:rect(0 250 50 0);width:150px;background-color:#f2f8e0;z-index:10"></div>');
		//My File Box text
		document.write('<td bgcolor="#6FAD2E" align="center"><a href="'+server+'/my/filebox.asp" target="_parent" class="myfilebox"onMouseover="showtip2(this,event,\'ระบบผู้ช่วยบันทึกข้อมูลและความต้องการส่วนตัวในเรื่องบ้านเพื่อคุณ \');" onMouseout="hidetip2();" STYLE="cursor: hand">My File Box</a></td>');
	}
	else 
	{
		document.write('<td bgcolor="#6FAD2E" align="center"><a href="'+server+'/my/filebox.asp" target="_parent" style="FONT-SIZE: xx-small; COLOR: #ffffff; FONT-FAMILY: ms sans serif; TEXT-DECORATION: none">My File Box</a></td>');
	}

	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('<td valign="top" bgcolor="#CEE6AC">');
	//Case of Sub Menu
	MenuDetail(site);
	
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function MenuDetail(site)
{
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr align="center">'); 	
	document.write('<td>'); 	
	switch (site)
	{
	case 'home':
			vote = 'home';
			document.write('<font size="1" face="ms Sans Serif, thonburi"><img src="/images/blank.gif" width="5" height="5"></font>');
			break;
	case 'property':
			vote = 'property';
			document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
			document.write('<tr align="center">'); 
			document.write('<td width="25%"><a href="/property/advance_search.asp" class="link_black" target="_parent">หาบ้านถูกใจ</a></td>');
			document.write('<td width="25%"><a href="/property/selling/postform.asp" class="link_black" target="_parent">แขวนป้ายขายเช่า</a></td>');
			//document.write('<td width="20%"><a href="/property/agent_list.asp" class="link_black">ผู้ช่วยซื้อขายบ้าน</a></td>');
			//document.write('<td width="25%"><a href="/property/cool_place" class="link_black">ท้องที่เด็ดทำเลดี</a></td>');
			document.write('<td width="25%"><a href="/content/c624.html" class="link_black" target="_parent">สัญญามาตรฐาน (download)</a></td>');
			document.write('<td width="25%"><a href="/property/choose" class="link_black" target="_parent">คู่มือซื้อขายบ้าน</a></td>');
			document.write('</tr>');
			document.write('</table>');
			break;
	case 'financing':
			vote = 'financing';
			document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
			document.write('<tr align="center">');
			document.write('<td width="25%"><a href="http://www.silkspan.com/silkspan_ssl/auction_mg/auction1.asp?partner=homeandi" class="link_black" target="_parent">Instant Mortgage</a></td>');
			document.write('<td width="25%"><a href="http://www.silkspan.com/silkspan1/insurance/joinfire/fas_insurance.asp?partner=homeandi" class="link_black" target="_parent">ประกันภัยบ้าน</a></td>');
			document.write('<td width="25%"><a href="http://www.silkspan.com/silkspan_ssl/joincredit/pl.asp?partner=homeandi#pl" class="link_black" target="_parent">สินเชื่อบุคคล</a></td>');
			document.write('<td width="25%"><a href="'+server+'/finance/calculator/" class="link_black" target="_parent">ผู้ช่วยคำนวณสินเชื่อ</a></td>');
			//document.write('<td width="20%"><a href="'+server+'/finance/handbook/" class="link_black" target="_parent">คู่มือการเงิน</a></td>');
			document.write('</tr>');
			document.write('</table>');
			break;
	case 'service':
			vote = 'service';
			document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
			document.write('<tr align="center">');
			document.write('<td width="20%"><a href="/service/search.asp?type=professional" class="link_black" target="_parent">ค้นหามืออาชีพ</a></td>');
			document.write('<td width="20%"><a href="/service/search.asp?type=handyman" class="link_black" target="_parent">สารพัดช่าง</a></td>');
			document.write('<td width="20%"><a href="/service/search.asp?type=supplier" class="link_black" target="_parent">วัสดุอุปกรณ์-เฟอร์นิเจอร์</a></td>');
			document.write('<td width="20%"><a href="/service/diy" class="link_black" target="_parent">DIY เรื่องบ้านงานง่ายๆ</a></td>');
			document.write('<td width="20%"><a href="/service/build_fix" class="link_black" target="_parent">คู่มือสร้าง-ซ่อมบ้าน</a></td>');
			document.write('</tr>');
			document.write('</table>');
			break;
	case 'decor_garden':	
			vote = 'decor_garden';
			document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
			document.write('<tr align="center"> ');
			document.write('<td width="25%"><a href="/decor_garden/design" class="link_black" target="_parent">เรียนรู้เรื่องดีไซน์</a></td>');
			document.write('<td width="25%"><a href="/decor_garden/your_style" class="link_black" target="_parent">สไตล์บ้าน..สไตล์คุณ</a></td>');
			document.write('<td width="25%"><a href="/decor_garden/garden_field" class="link_black" target="_parent">สวนงาม-สนามสวย</a></td>');
			document.write('<td width="25%"><a href="/decor_garden/creative" class="link_black" target="_parent">เพิ่มพลังสร้างสรรค์</a></td>');
			document.write('</tr>');
			document.write('</table>');
			break;
	case 'lifestyle':	
			vote = 'lifestyle';
			document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
			document.write('<tr align="center">'); 
			document.write('<td width="25%"><a href="/lifestyle/men" class="link_black" target="_parent">สบายสไตล์หนุ่ม</a></td>');
			document.write('<td width="25%"><a href="/lifestyle/women" class="link_black" target="_parent">สบายสไตล์สาว</a></td>');
			document.write('<td width="25%"><a href="/lifestyle/health" class="link_black" target="_parent">ครอบครัวสุขภาพดี</a></td>');
			document.write('<td width="25%"><a href="/lifestyle/freestyle" class="link_black" target="_parent">มุมนี้...ฟรีสไตล์</a></td>');
			//document.write('<td width="20%"><a href="/lifestyle/calendar" class="link_black" target="_parent">ปฏิทินกิจกรรม</a></td>');
			document.write('</tr>');
			document.write('</table>');
	}
	document.write('</td>');
	//document.write('<td align=center width=40 ><font face="arial" size=2>| <a href="http://eng.homeandi.com" class="language" target="_parent">Eng</a></font></td>');
	document.write('</tr>');
	document.write('</table>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function Footer(pagename)
{
	if(pagename==null || pagename=='') pagename='Unfiled'
		document.write('<hr width="740" align=left>');
		document.write('<table width="740" border="0" cellspacing="0" cellpadding="0">');
		document.write('<tr> ');
		document.write('<td align=center><font face="ms sans serif,thonburi" size=2>');
		document.write('<a href="'+server+'/home.html" class="link_sub_menu" target="_parent">Home</a> | ');
		document.write('<a href="'+server+'/property/" class="link_sub_menu" target="_parent">Property</a> | ');
		document.write('<a href="'+server+'/finance/" class="link_sub_menu" target="_parent">Financing</a> | ');
		document.write('<a href="'+server+'/service/" class="link_sub_menu" target="_parent">Home Services</a> | ');
		document.write('<a href="'+server+'/decor_garden/" class="link_sub_menu" target="_parent">D&eacute;cor&amp;Garden</a> | ');
		document.write('<a href="'+server+'/lifestyle/" class="link_sub_menu" target="_parent">Lifestyles</a> | ');
		document.write('<a href="'+server+'/market/" class="link_sub_menu" target="_parent">Market</a>');
		document.write('<br>');
		document.write('<a href="'+server+'/about/termofservice.html" class="link_sub_menu" target="_parent">Terms of Use</a> | ');
		//document.write('<a href="#" class="link_sub_menu">Privacy Policy</a> | ');
		document.write('<a href="'+server+'/about/aboutus.html" class="link_sub_menu" target="_parent">About US</a> | ');
		//document.write('<a href="#" onclick="window.open(\''+server+'/mail/contactus.asp?to=webmaster@homeandi.com\',\'mail\',\'width=475 height=400 scrollbars=1\');" class="link_sub_menu">Contact US</a> ');
		document.write('<a href="'+server+'/mail/contactus.asp?to=webmaster@homeandi.com" class="link_sub_menu" target="_blank">Contact US | </a> ');
		document.write('<a href="'+server+'/service/advertising/" class="link_sub_menu" target="_parent">Advertising</a> ');
		document.write('<br>');
		document.write('<font face="ms sans serif,thonburi" size=2>ติดต่อลงโฆษณาได้ที่ <a href="mailto:csinfo@homeandi.com" class="link_menu">csinfo@homeandi.com</a></font><br>');
		document.write('&copy;2000.All rights reserved <img src="http://www.homeandi.com/images/small_logo.jpg" width="43" height="34" align="absmiddle"> ');
		document.write('</font></td>');
		document.write('</tr>');
		document.write('</table>');			
	Counter(pagename);
	googleAdword();
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function Counter(pagename){
		document.write('<script language="javascript" src="/js/homeandi_tag.js"></script>');
		//document.write('<p align="center"><A HREF="http://rd1.hitbox.com/rd?acct=WQ5106133JVZ52UN0&p=s">');
		//document.write('<IMG SRC="http://hg1.hitbox.com/HG?hc=wf132&l=y&hb=WQ5106133JVZ52UN0&cd=1&n='+pagename+'" height=1 width=1 ALT="Click Here!" border=0></A></p>');			
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function googleAdword(){
		document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>');
		document.write('<script language="javascript" src="/js/adword.js"></script>');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function RightBarAdv(adv)
{
	if (adv=='' || adv==null) adv='homeandi.index.home';
	document.write('<br>');
	document.write('<IFRAME  WIDTH="120" HEIGHT="320"  MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" SRC="http://www.homeandi.com/adnow2/redirect/adrun.asp?location='+adv+'&position=right1"></iframe>');
	document.write('<IFRAME  WIDTH="120" HEIGHT="320"  MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" SRC="http://www.homeandi.com/adnow2/redirect/adrun.asp?location='+adv+'&position=right2"></iframe>');

}
