// JavaScript Document
var myDomain='http://'+document.domain + '/';
$(document).ready(function(){
jQuery.fn.extend({
	  scrollTo : function(speed, easing) {
	    return this.each(function() {
	      var targetOffset = $(this).offset().top;
	      $('html,body').animate({scrollTop: targetOffset}, speed, easing);
	    });
	  }
	});
	$('#theTop').click(function(){
		$('#theBottom').scrollTo(5000,"linear");
		return false;
	});
	$('#theBottom').click(function(){
		$('body').scrollTo(800,"linear");
		return false;
	});
	$('#sidebar h3').nextAll().hide();
	$('#advert').css({'background-image':'none','cursor':'default'}).nextAll().show();
	$('#sidebar h3').not('#advert').click(function(){
		var me=$(this);
		$(this).next().slideToggle('normal',function(){
							if($(this).is(":visible")){
								me.css({'background':'url('+myDomain+'images/arrow-down.gif) top right no-repeat'});
							}else{
								me.css({'background':'url('+myDomain+'images/arrow-up.gif) top right no-repeat'});
							}
							
		 });
	});
	
	$('#bangkokbank').append('<iframe src="http://www.tmd.go.th/en/daily_forecast_forweb.php?strProvinceID=2-37-61-75-72-76-3" width="185" height="260" scrolling="no" frameborder="0" ></iframe><br /><br /><iframe src="http://www.bangkokbank.com/fxbanner/banner1.htm" frameborder="0" scrolling="no" width="178" id="bkkBank" style="padding-left:8px;"></iframe>');
	
	var inBoxText="Your E-mail";
	$('#sscText').val(inBoxText).blur(function(){
											   		$(this).css({'border-color':'#EBEBEB'});
													if(this.value==""){
														this.value=inBoxText;
													}
													}).focus(function(){
																	$(this).css({'border-color':'#09B1FC'});
																	if(this.value==inBoxText){
																		this.value="";
																		}
																});
$('#subForm').submit(function (){
	  		var validMail=this.sscText.value;
			var returnBool=true;
		if(this.sscText.value==''){
				returnBool= notNull(this.sscText,'Your E-mail, Please...');
		}else if((validMail.indexOf('@') < 0) || ((validMail.charAt(validMail.length-4) != '.') && (validMail.charAt(validMail.length-3) != '.'))){
				returnBool= notNull(this.sscText,'Invalid E-mail ...');
		} //endif
			return returnBool;
		});




	});

	function notNull(obj,txt){alert(txt);obj.focus();return false;} //
	
