//------------------ Detect language --------------------
var nowURL = document.URL;
var thURL = nowURL.replace('/en/','/th/');
var enURL = nowURL.replace('/th/','/en/');

//------------------ Init Text Size--------------------
// setDefaults arguments: size unit, default size, minimum, maximum
// optional array of elements or selectors to apply these defaults to
dw_fontSizerDX.setDefaults("px", 13, 9, 26, ['td.text'] );
//dw_fontSizerDX.setDefaults( "px", 13, 9, 26, ['body', 'td', 'div', 'p', 'font'] );
dw_Event.add( window, 'load', dw_fontSizerDX.init );

//------------------Contents for menu_unit------------------
var menu_unit=new Array()
menu_unit[0]='<a href="x55.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'imgX55\',\'\',\'images/m_x55.gif\',1)"><img src="images/m_x55.gif" alt="X 5.5" name="imgX55" width="135" height="20" border="0" id="imgX55" /></a>'
menu_unit[1]='<a href="x5.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'imgX5\',\'\',\'images/m_x5.gif\',1)"><img src="images/m_x5.gif" alt="X 5" name="imgX5" width="135" height="20" border="0" id="imgX5" /></a>'
menu_unit[2]='<a href="x5corner.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'imgX5corner\',\'\',\'images/m_x5corner.gif\',1)"><img src="images/m_x5corner.gif" alt="X 5 Corner" name="imgX5corner" width="135" height="20" border="0" id="imgX5corner" /></a>'

var menuwidth='122px' //default menu width
//var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

//------------------Page Elements---------------------
function header(section) {
	document.write('<table width="952" border="0" align="center" cellpadding="0" cellspacing="0" id="Header"><tr><td>');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr><td height="12"></td></tr>');
	writeTitle(); // Logo and options
	document.write('<tr><td height="12"></td></tr></table>');
	document.write('<table width="952" border="0" cellpadding="0" cellspacing="0" class="bg_mainpic"><tr><td align="right">');
	document.write('<table width="940" border="0" cellpadding="0" cellspacing="0" class="bg_mainpic_in">');
	writeMainImage(section); // Main image of page
	document.write('<tr><td height="4"></td></tr>');
	writeMenu(section); // Main menu
	document.write('</table>');
	document.write('</td></tr></table>');
	document.write('</table>');
}

function writeTitle() {
	document.write('<tr><td>');
	
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="bottom">');
	document.write('<td width="12"></td>');
	document.write('<td width="190"><a href="index.html"><img src="images/logo_project.gif" alt="Town+ X Ladprao" width="166" height="76" border="0" /></a></td>');
	document.write('<td><img src="images/title_project.gif" alt="Town+ X Ladprao" width="335" height="76" border="0" /></td>');
	// Options
	document.write('<td align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr valign="top"><td align="right"><a href="http://www.sansiri.com/" target="_blank"><img src="images/ic_sansiri.gif" alt="Sansiri PCL. Call.1685" width="132" height="19" border="0" /></a></td></tr>'); // Sansiri Logo
	document.write('<tr><td height="40" align="right"><table width="100" border="0" cellspacing="0" cellpadding="0"><tr>');
	document.write('<td><img src="images/txt_showth.gif" width="90" height="14" /> </td>');
	document.write('<td><a href="' + thURL + '"><img src="images/ic_th.gif" alt="Change to English" width="24" height="12" border="0" /></a></td>');
	document.write('</tr></table></td></tr>');

	document.write('<tr><td align="right">');
	document.write('<div id="sizer"><table border="0" cellspacing="0" cellpadding="0"><tr>');
	document.write('<td align="right" class="changesize">Text size</td>');
	document.write('<td width="37" align="right"><a class="decrease" href="#"><img src="images/ic_fontdec.gif" alt="Decrease text size" width="31" height="13" border="0" /></a></td>');
	document.write('<td width="37" align="right"><a class="increase" href="#"><img src="images/ic_fontinc.gif" alt="Increase text size" width="31" height="13" border="0" /></a></td>');
	document.write('</tr></table></div>');
	document.write('</td></tr>');
	document.write('</table></td>');
	// ------
	document.write('</tr></table>');
	
	document.write('</td></tr>');
}

function writeMainImage(section) {
	document.write('<tr><td align="center">');
	switch(section) {
		case "info" :
			document.write('<img src="images/txl.jpg" width="679" height="338" />')
			document.write('<img src="images/txl_promotion_en.gif" width="261" height="338" />')
			break;
		case "unit" :
		case "x5" :
		case "x5.5" :
		case "x5corner" :
		case "ready" :
		case "act" :
			document.write('<img src="images/txl.jpg" width="679" height="338" />')
			document.write('<img src="images/txl_promotion_en.gif" width="261" height="338" />')
			break;
		case "contact" :
			document.write('<img src="images/txl.jpg" width="679" height="338" />')
			document.write('<img src="images/txl_promotion_en.gif" width="261" height="338" />')
			//writeFlash('mainflash-contact.swf',940,338);
			break;
	}
	document.write('</td></tr>');
}

function writeMenu(section) {
	switch(section) {
		case "x5" :
		case "x5.5" :
		case "x5corner" :
			section ="unit";
			break;
	}

	document.write('<tr><td><table width="940" border="0" align="center" cellpadding="0" cellspacing="0" class="bg_menu"><tr>');
	document.write('<td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"><tr>');
	document.write('<td><a href="index.html"><img src="images/m_info'+ ((section=='info')?'2':'1')+'.gif" alt="Project Info" width="184" height="35" border="0" /></a></td>');
	writeBar();
	document.write('<td><a href="unit.html"><img src="images/m_unit'+ ((section=='unit')?'2':'1')+'.gif" alt="House Type" width="171" height="35" border="0" onMouseover="dropdownmenu(this, event, menu_unit, \'150px\')" onMouseout="delayhidemenu()" /></a></td>');
	writeBar();
	//document.write('<td><a href="ready.html"><img src="images/m_ready'+ ((section=='ready')?'2':'1')+'.gif" alt="Ready to Move In" width="223" height="35" border="0" /></a></td>');
	//writeBar();
	//document.write('<td><a href="activity.html"><img src="images/m_activity'+ ((section=='act')?'2':'1')+'.gif" alt="Activities" width="170 height="35" border="0" /></a></td>');
	//writeBar();
	document.write('<td><a href="contact.html"><img src="images/m_contact'+ ((section=='contact')?'2':'1')+'.gif" alt="Contact Us" width="180" height="35" border="0" /></a></td>');
	document.write(' </tr></table></td>');
	document.write(' </tr></table></td></tr>');
}

function writeBar() {
	document.write('<td><img src="images/m_bar.gif" width="3" height="35" border="0" /></td>');
}

function footer(section) {
	document.write('<table width="952" border="0" align="center" cellpadding="0" cellspacing="0" id="Footer">');
	if ((section!='')&&(section!=null)) {
		document.write('<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.write('<tr><td height="26"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>');
		// remark for simulated graphic
		document.write('<tr><td align="center" class="copyright" colspan="2">Featured photography on website  consists of photography on location, photography on location with simulated atmosphere and simulated graphic. Should you have any questions regarding any photography, please contact our customer service staffs or visit our projects\' site. Call 1685.</td></tr>');
		document.write('<tr><td colspan="2" height="15"></td></tr>');
		// end remark for simulated graphic
		document.write('<td width="120"></td>');
		document.write('<td class="copyright">Copyright&copy; Sansiri Public Co., Ltd. All right reserved. <b>One of quality projects of</b> <img src="images/logo_townplusx.gif" width="55" height="21" align="absmiddle" />');
		counter();
		document.write('</td></tr></table></td>');
		document.write('<td width="269" class="bg_right"></td></tr>');
		document.write('</table></td></tr>');
	} else {
		// remark for simulated graphic
		document.write('<tr><td align="center" class="copyright">Featured photography on website  consists of photography on location, photography on location with simulated atmosphere and simulated graphic. <br>Should you have any questions regarding any photography, please contact our customer service staffs or visit our projects\' site. Call 1685.</td></tr>');
		// end remark for simulated graphic
		document.write('<tr><td height="15"></td></tr>');
		document.write('<tr><td align="center" class="copyright">Copyright&copy; Sansiri Public Co., Ltd. All right reserved. <b>One of quality project of</b> <img src="images/logo_townplusx.gif" width="55" height="21" align="absmiddle" />');
		counter();
		document.write('</td></tr>');
	}
	document.write('<tr><td height="3" bgcolor="#fda707"></td></tr>');
	document.write('<tr><td height="16"></td></tr>');
	document.write('</table>');
}
  
function counter()
{	document.write('<script language="javascript" src="/scripts/googleAnalytics.js"></script>');
        document.write('<script language="javascript" src="/scripts/adword.js"></script>');
	/*document.write('<script language="javascript" src="/scripts/sansiri_tag.js"></script>');*/
	/*document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>');*/
	/*document.write('<script language="javascript" src="/scripts/adword.js"></script>');*/
}

