// JavaScript Document

 function updateTips( t, tips ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 2000 );
 }
		
 function checkLength( o, n, min, max , tips) {
			if ( o.val().length > max || o.val().length < min ) {
				o.addClass( "ui-state-error" );
				updateTips( "Length of " + n + " must be between " +
					min + " and " + max + "." ,tips );
				return false;
			} else {
				return true;
			}
 }
 
 function checkRequired( o, n, tips) {
			if ( o.val() == '' || o.val() == 'select one') {
				o.addClass( "ui-state-error" );
				updateTips( n + " field is required. " ,tips );
				return false;
			} else {
				return true;
			}
 }
 
  function show_msg( msg, tips) {

				updateTips( msg ,tips );
	
  }

 function checkRegexp( o, regexp, n , tips) {
			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass( "ui-state-error" );
				updateTips( 'Wrong '+n , tips);
				return false;
			} else {
				return true;
			}
 }
 
 function check_integer(o, n, tips, bl){
	       var reg = /^\+?[0-9]*$/;	
		     
			 if(bl){			 
				    if(checkRequired(o, n, tips)){		 	     
				       return checkRegexp(o, reg, 'number only valid.', tips);		 
					} 
					else{
						  return false;		 
					}
			 }
			 else{
				  return checkRegexp(o, reg, n, tips);
			 }
			
 }
 
 function check_decimal(o, n, tips){
			 if(checkRequired(o, n, tips)){		 
				   var reg =/^\+?[0-9]*\.?[0-9]+$/;		   
				   return checkRegexp(o, reg, 'number only valid.', tips);		 
			 } 
			 else{
				 return false;
			 }
 }
 
 function check_int_deci(o, n, tips){
			 if(checkRequired(o, n, tips)){		 
				   var reg = /^(\d{1,9})(\.\d{1,2})?$/;		   
				   return checkRegexp(o, reg, n, tips);		 
			 } 
			 else{
				 return false;
			 }
 }
 
	function ActivateMainNavigation(menutext)
	{
			$('#nav li').each(function(){
					$(this).attr('id','');
					if($(this).find('a:first').html() == menutext)
					{
						$(this).attr('id','current');	
					}
				});	
	}
	
	function popitup(url) 
	{
		newwindow=window.open(url,'name','height=600,width=910,resizable=1,scrollbars=1');
		if (window.focus) {newwindow.focus()}
		return false;
    }
