// JavaScript Document

$(document).ready(function(){
	 $('img.tab-home').hover(function(){ $(this).attr('src','images/tab-home-hover.gif');  },function(){ $(this).attr('src','images/tab-home.gif');  });
	 $('img.tab-aboutsiaf').hover(function(){ $(this).attr('src','images/tab-aboutsiaf-hover.gif');  },function(){ $(this).attr('src','images/tab-aboutsiaf.gif');  });
	 $('img.tab-conferenceinfo').hover(function(){ $(this).attr('src','images/tab-conferenceinfo-hover.gif');  },function(){ $(this).attr('src','images/tab-conferenceinfo.gif');  });
	 $('img.tab-registration').hover(function(){ $(this).attr('src','images/tab-registration-hover.gif');  },function(){ $(this).attr('src','images/tab-registration.gif');  });
	 $('img.tab-sponsorspartners').hover(function(){ $(this).attr('src','images/tab-sponsorspartners-hover.gif');  },function(){ $(this).attr('src','images/tab-sponsorspartners.gif');  });
	 $('img.tab-pressrelease').hover(function(){ $(this).attr('src','images/tab-pressrelease-hover.gif');  },function(){ $(this).attr('src','images/tab-pressrelease.gif');  });
	 $('img.tab-contactus').hover(function(){ $(this).attr('src','images/tab-contactus-hover.gif');  },function(){ $(this).attr('src','images/tab-contactus.gif');  });

     $('ul.left-menu-sub').hide();
	 $('li.left-menu-with-sub').hover(function(){ $('ul.left-menu-sub').hide();$('ul',this).show();   },function(){ $('ul',this).hover(function(){ },function(){$(this).hide();  });  });
	 $('li.left-menu-with-no-sub').hover(function(){ $('ul.left-menu-sub').hide();   },function(){  });
	 
	 
        $('div.salutation-select-drop').hover(
			function() { $('div.salutation-select-drop-container').show();},function() {
			    $('div.salutation-select-drop-container').hover(function() { }, function() { $('div.salutation-select-drop-container').hide(); });
			});

        $('ul.salutation-select-drop li').hover(function() { $(this).addClass('nover'); }, function() { $(this).removeClass('nover'); });
        $('div.salutation-select-drop-container').hide();
        $('ul.salutation-select-drop li').click(function() {
            $('div.salutation-select-drop').html($(this).html());$('input#salutation').val($(this).html());
            $('div.salutation-select-drop-container').hide();
        });	 
		

 
		
		
		var myDate=new Date();
		myDate.setFullYear(2009,11,30);
		var today = new Date();
		
		var amtpay=0;
		 if (myDate>today){
			// alert('S$850');
			amtpay = 850 + (850*0.07);
			amtpay = amtpay.toFixed(2);
			$('span.amt_payable').html(amtpay);
	    }else{
			// alert('S$1000');*/
		    amtpay = 1000 + (1000*0.07);
			amtpay = amtpay.toFixed(2);
			$('span.amt_payable').html(amtpay);
	   }
		
		
         $('input.is-numberonly').keypress(function(e){
				var code = (e.keyCode ? e.keyCode : e.which);
				if(code < 48 ||  code > 58){
					if(code==13 || code==8){
					   return true;
					}
			        return false;
				}return true;
         });
		 
         $('input#required_meal_no').keypress(function(e){
				$('#required_meal').attr('checked',true);
		 });
		 
});

function _regSubmit(){
	var no_error = 0;
	var is_checked = 0;
   $("input.is-required").each(function(){
        if($(this).val()==''){ $(this).addClass('error_msg');no_error++; }
   });
  
   $("input.is-email").each(function(){
									 
        if($(this).val()!=""){
			  var foo = $(this).val();
			  var objc = $(this).attr('name');
			  if(foo.indexOf("@")==-1){
			    $('.span-' + objc).show();
				no_error++; 
			  }else{
		       $('.span-' + objc).hide();
 			  }
		     
		}
   });


   
    $("input.is-required-check").each(function(){
	    var tfield = $(this).attr('field');
		if($('input#' + tfield).is(':checked')){
			if($(this).val()==''){ $(this).addClass('error_msg');no_error++; }
	    }
   });
	
   
    $("textarea.is-required").each(function(){
		 if($(this).val()==''){  $(this).addClass('error_msg');no_error++;  }									
   });


    if($('input#salutation').val()==''){  $('span.salutation_error').show();no_error++;  }
    if(no_error>0){ $('tr.error_msg').show();SetFocus('page-top');return false; }
    
	var dt = new Date();
	var tday = (dt.getDate()>9)?dt.getDate():'0'+dt.getDate();
	var tmth = ((dt.getMonth()+1)>9)?(dt.getMonth()+1):'0'+(dt.getMonth()+1);
    //$('form').attr('action','app/app.php?_cmd=register&SIAF' + dt.getFullYear() + tmth + tday + 'CWPJT=Y');
	
	return true;	

}

function SetFocus(element){
window.scrollTo(0,document.body.scrollHeight);
document.getElementById(element).focus();
return true;
}

		
		
        function __calcPay(cty){
		        var myDate=new Date();
				myDate.setFullYear(2009,11,30);
				var today = new Date();
				// cty = 
				var amtpa2y=0;
				if (myDate>today){
					// alert('S$850');
					if(cty=='Singapore'){
						amtpa2y = 850 + (850*0.07);
						amtpa2y = amtpa2y.toFixed(2);
						$('span.amt_payable').html(amtpa2y);
					}else{
						amtpa2y = 850;
						amtpa2y = amtpa2y.toFixed(2);
						$('span.amt_payable').html(amtpa2y);
					}
				}else{
					// alert('S$1000');
				    if(cty=='Singapore'){
						amtpa2y = 1000 + (1000*0.07);
						amtpa2y = amtpa2y.toFixed(2);
						$('span.amt_payable').html(amtpa2y);
					}else{
						amtpa2y = 1000;
						amtpa2y = amtpa2y.toFixed(2);
						$('span.amt_payable').html(amtpa2y);
					}
				}
	   }
