/*------------------------------------------*/

function ebankingPop(url){
var url;
window.open (url,'mywindow','menubar=1,scrollbars=1,resizable=0,width=820,height=615'); 
}


/* change lang */
function langEn() {

var url=document.URL;
url =(url).replace('#1','');
countstr=url.length;
data=url.substr(countstr-1);

if(data=='/'){
url=url+'index.php';
}

sp_url=url.split("."); 
pointtype=(sp_url.length)-1;

type=sp_url[pointtype];
newurl =url.replace('.'+type,'-en.'+type);
window.location=newurl;
//alert(newurl);
}
function langTh() {
		var url=document.URL;
			url =(url).replace('#1','');
			newurl =(url).replace('-en','');
			window.location=newurl;
}


function strRootPath(){
	var strCfgRoot = "";
	var strCfgMainUrl = "";
	if("icweb.dyndns.info"==document.domain){ // webserver
		strCfgRoot = "/tmbbank";
		strCfgMainUrl = "http://" + document.domain + strCfgRoot ;
	}else if("192.168.1.9"==document.domain){ // webserver
		strCfgRoot = "/tmbbank";
		strCfgMainUrl = "http://" + document.domain + strCfgRoot ;
	}else{ // Server
		strCfgMainUrl = "http://" + document.domain + strCfgRoot ;
	}
	return strCfgMainUrl;
}


var numEnewsletter = 0;
function showEnewsletter(){
	if(this.numEnewsletter==0){
		$("#FormEnews").slideDown("slow");
		this.numEnewsletter = 1;
	} else {
		$("#FormEnews").slideUp("slow");
		this.numEnewsletter = 0;
	}
}


function getdata() {
	var str1 = document.getElementById("eEmail").value;
	var str2 = (document.getElementById("ePersonal").checked==true)? "1": "0";
	var str3 = (document.getElementById("eCorporate").checked==true)? "1": "0";
	var str4 = (document.getElementById("eSME").checked==true)? "1": "0";
	
	queryStr="Email="+str1+"&Personal=" + str2 +"&Corporate="+ str3 + "&SME=" + str4;
	
	$.ajax({
		type: "POST",
		url: "../../lib/enewletter.php",
		cache: false,
		data: queryStr,
			success: function(response){
			  alert("ขอบคุณที่สมัคร Enewletter กับเรา");	
			}
	});
}



function VF_frm_Search(){ //v2.0
	var theForm = document.frm_Search;
	var errMsg = "";
	var setfocus = "";

	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	else theForm.submit();
}//-->



function switchtopHeadMenu(){
  var strURL = document.URL;
  
  if(strURL.match("/personal/")){  
    //$("#NavCat1").css("display",""); 
	$("#NavCat1").fadeIn("slow");
  } else if(strURL.match("/business/")){  
    //$("#NavCat2").css("display",""); 
	$("#NavCat2").fadeIn("slow");
  } else {  
  	//$("#NavCat3").css("display",""); 
	$("#NavCat3").fadeIn("slow");
  }
}


/*
function ShowNavLinkTop(){
	$("#strNavLinkTop").slideDown("slow");
}
function HideNavLinkTop(){
	$("#strNavLinkTop").fadeOut("slow");
}
*/
function HideAllNavLinkTop(){
  $("#strNavLinkTop").hide();
}


function switchTab(num){
	/* EX. By Cartoon
      <script>
		jQuery().ready(function(){
			$(".aTab").css("display","none");
			$("#Tab1").css("display","");
		});
      </script>
      <div id="Tab1" class="aTab">
	  	Tab1
		<a href="javascript: switchTab('2');">Tab2</a>
		<a href="javascript: switchTab('3');">Tab3</a>
	  </div>
      <div id="Tab2" class="aTab">
	  	<a href="javascript: switchTab('1');">Tab1</a>
		Tab2
		<a href="javascript: switchTab('3');">Tab3</a>
	  </div>
      <div id="Tab3" class="aTab">
		<a href="javascript: switchTab('1');">Tab1</a>
		<a href="javascript: switchTab('2');">Tab2</a>
		Tab3
	  </div>
	*/

			
	if(num!="") {
		$(".aTab").css("display","none");
		
		$("#Tab"+num).css("display","");
	}
}

function imgSwap(oImg)
{
   var strOver  = "_on"    // image to be used with mouse over
   var strOff = "_off"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}

function imgSwapId(oImg)
{
   var strOver  = "_on"    // image to be used with mouse over
   var strOff = "_off"     // normal image
   var strImg = document.getElementById(oImg).src
   if (strImg.indexOf(strOver) != -1)
      document.getElementById(oImg).src = strImg.replace(strOver,strOff)
   else
      document.getElementById(oImg).src = strImg.replace(strOff,strOver)
}
 
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*------------------------------------------*/

function fnPrintAnalytic(){
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var content_A= document.getElementById("AnalyticsDetail").innerHTML;
  //alert(content_A)
  var strCfgMainUrl = strRootPath();

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="../css/tmbTH.css" rel="stylesheet" type="text/css" /><link href="../css/tmbAnalytics.css" rel="stylesheet" type="text/css" /><link href="../css/tmbAnalytics-print.css" rel="stylesheet" type="text/css" /></head><body onLoad="self.print();" style="margin-left:20px;margin-top:20px;">');
   docprint.document.write('<div style="padding-bottom:10px;"><img src="../common/img/logoTMB.png" alt="TMB" border="0" /></div>');
   docprint.document.write('<div id="Analytics"><div id="Wrapper"><div id="Body">');
   docprint.document.write(content_A);
   docprint.document.write('</div></div></div>');
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
function promotionPrint(){
  var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var content_A= document.getElementById("Promotion").innerHTML;
  //var divHide="'Functions'";
  //var show="'none'";document.getElementById('+divHide+').style.display='+show+';
  var strCfgMainUrl = strRootPath();

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="../css/tmbTH.css" rel="stylesheet" type="text/css" /><link href="../css/tmbPromotion.css" rel="stylesheet" type="text/css" /></head><body onLoad="self.print();" style="margin-left:20px;margin-top:20px;">');
   docprint.document.write('<div style="padding-bottom:10px;"><img src="../common/img/logoTMB.png" alt="TMB" border="0" /></div>');
   docprint.document.write('<div id="Content"><div class="TwoColumnC"><div id="Promotion">');
   docprint.document.write(content_A);
   docprint.document.write('</div></div></div>');
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 

}
function newsPrint(){
  var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var obj=document.getElementById("NewsRoom");
  
  var content_A = obj.getElementsByTagName("div")[0].innerHTML;
  var content_B = obj.getElementsByTagName("div")[2].innerHTML;
  var divHide="'Functions'";
  var show="'none'";
  
  var strCfgMainUrl = strRootPath();

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="../css/tmbTH.css" rel="stylesheet" type="text/css" /><link href="../css/tmbPrint.css" rel="stylesheet" type="text/css" /></head><body onLoad="document.getElementById('+divHide+').style.display='+show+';self.print();" style="margin-left:20px;margin-top:20px;">');
   docprint.document.write('<div style="padding-bottom:10px;"><img src="../common/img/logoTMB.png" alt="TMB" border="0" /></div>');
   docprint.document.write('<div id="NewsRoom">');
   docprint.document.write('<div class="Header">'+content_A+'</div>');
   docprint.document.write('<div class="Display">'+content_B+'</div>');
   docprint.document.write('</div>');
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus();
}

function irPrint(){
	
  var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var obj=document.getElementById("Content");
  
  var content_A = obj.getElementsByTagName("div")[1].innerHTML;
  var divHide="'Functions'";
  var show="'none'";
  var strCfgMainUrl =strRootPath();

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="'+strCfgMainUrl+'/css/tmbTH.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbIR.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbIR.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbPrint.css" rel="stylesheet" type="text/css" /><body onLoad="document.getElementById('+divHide+').style.display='+show+';self.print();" style="margin-left:20px;margin-top:20px;">');
   docprint.document.write('<div style="padding-bottom:10px;"><img src="'+strCfgMainUrl+'/common/img/logoTMB.png" alt="TMB" border="0" /></div>');
   docprint.document.write('<div id="Content">');
   docprint.document.write('<div class="TwoColumnC">'+content_A+'</div>');
   docprint.document.write('</div>');
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus();
}
function ratesPrint(){
		
  var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var obj=document.getElementById("Content");
  
  var content_A = obj.getElementsByTagName("div")[1].innerHTML;
  
  //var content_A=content_A.replace("line-height: 18px;", "line-height: 10px;");
 
  
  var divHide="'Functions'";
  var divHideFoot="'footComment'";
  var show="'none'";
  var strCfgMainUrl =strRootPath();
  
  //document.getElementById('footComment').style.display='none';

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="'+strCfgMainUrl+'/css/tmbRatesPrint.css" rel="stylesheet" type="text/css" /><body onLoad="document.getElementById('+divHide+').style.display='+show+';self.print();" style="margin-left:20px;margin-top:1px;">');
   //docprint.document.write('<div style="padding-bottom:1px;"><img src="'+strCfgMainUrl+'/common/img/logoTMB.png" alt="TMB" border="0" /></div>');
  
   docprint.document.write(content_A);
   
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>');
   
   docprint.document.close(); 
   docprint.focus();
}
function productPrint(){
  self.print();
  /*var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var obj=document.getElementById("Content");
  var strCfgMainUrl =strRootPath();
  var divHide="'Functions'";
  var show="'none'";
  
  var content_A = obj.getElementsByTagName("div")[1].innerHTML;
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="'+strCfgMainUrl+'/css/tmbTH.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbProductPrint.css" rel="stylesheet" type="text/css" /><body onLoad="document.getElementById('+divHide+').style.display='+show+';self.print();" style="margin-left:20px;margin-top:20px;">');
   docprint.document.write('<div style="padding-bottom:10px;"><img src="'+strCfgMainUrl+'/common/img/logoTMB.png" alt="TMB" border="0" /></div>');
   docprint.document.write('<div id="Content">');
   docprint.document.write('<div class="MainC">'+content_A+'</div>');
   docprint.document.write('</div>');
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus();*/
	
}
function careerPrint(){
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
      disp_setting+="scrollbars=yes,width=767, height=800, left=100, top=25"; 
  var obj=document.getElementById("Content");
  
  var content_A = obj.getElementsByTagName("div")[1].innerHTML;
  var divHide="'Functions'";
  var show="'none'";
  var strCfgMainUrl =strRootPath();

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>TMB Bank Public Company Limited</title>'); 
   docprint.document.write('<link href="'+strCfgMainUrl+'/css/tmbTH.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbCareer.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbIR.css" rel="stylesheet" type="text/css" /><link href="'+strCfgMainUrl+'/css/tmbPrint.css" rel="stylesheet" type="text/css" /><body onLoad="document.getElementById('+divHide+').style.display='+show+';self.print();" style="margin-left:20px;margin-top:20px;">');
   docprint.document.write('<div style="padding-bottom:10px;"><img src="'+strCfgMainUrl+'/common/img/logoTMB.png" alt="TMB" border="0" /></div>');
   docprint.document.write('<div id="Content">');
   docprint.document.write('<div class="TwoColumnC">'+content_A+'</div>');
   docprint.document.write('</div>');
   docprint.document.write('<div style="font-size:0.7em;">© สงวนลิขสิทธิ์ 2553 ธนาคารทหารไทย จำกัด (มหาชน)</div>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus();
}
function fnEnews(){
	lroot=strRootPath();
	tb_show('', lroot+'/lib/enewletter.php?height=300&width=500', '') ;
}
function fnCareer(id){
	lroot=strRootPath();
	tb_show('', lroot+'/career/confirm.php?height=300&width=500&id='+id, '') ;
}
function fnSend2friend(){
	lroot=strRootPath();
	tb_show('', lroot+'/lib/sendtofriend.php?height=400&width=510', '') ;
}
function fnFeedback(){
	lroot=strRootPath();
	tb_show('', lroot+'/ssi/feedback.php?height=465&width=360', '') ;
}
function fnRegis(){
	lroot=strRootPath();
	tb_show('', lroot+'/popup/registration.php?height=585&width=430', '') ;
}
function fnPrivacy(){
	lroot=strRootPath();
	window.open (lroot+"/personal/e-banking/popup/policy.html","mywindow","'toolbar=0,location=0,resizeable=0,directories=0,menubar=0,scrollbars=0,status=0,width=820,height=610");
}
function fnPrivacyEn(){
	lroot=strRootPath();
	window.open (lroot+"/personal/e-banking/popup/policy-en.html","mywindow","'toolbar=0,location=0,resizeable=0,directories=0,menubar=0,scrollbars=0,status=0,width=820,height=610");
}

function fnHiglightS(img,id){
	$('.Menu li').css("background", "#EBEBEB");
	$('.Menu li').css("color", "#006cb7");
	//$('.Menu li').css("border", "1px solid #EBEBEB");
	Cufon.replace('span.navMenu', { 
		color: '#006cb7'
	});
	$('#menu0'+id).css("background", "#57A1CE");
	$('#menu0'+id).css("color", "#FFF");
	//$('#menu0'+id).css("border", "1px solid #57A1CE");
	Cufon.replace('#menu0'+id+' span.navMenu', { 
		color: '#FFF'
	});
	$('#boxHighlight').hide();
	//$('#boxHighlight').fadeOut(200);
	
	fadeImg(img,id)
	
	//setTimeout("fadeImg('"+img+"','"+id+"')",100);
	
}
function fnHiglightH(img,id){
	$('#menu0'+id).css("background", "#57A1CE");
	$('#menu0'+id).css("color", "#FFF");
	Cufon.replace('#menu0'+id+' span.navMenu', { 
		color: '#006cb7'
	});
	//$('#menu0'+id).css("border", "1px solid #57A1CE");
}

function fadeImg(img,id){
	//alert(img)
	document.getElementById('jpgHighlight').src="img/H-"+img+".jpg";
	//$('#boxHighlight').fadeIn(300);
	$('#boxHighlight').show();
	Cufon.replace('span.navMenu', { 
		color: '#006cb7'
	});
	Cufon.replace('#menu0'+id+' span.navMenu', { 
		color: '#FFF'
	});
}