/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/

this.vtip = function() {    
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 22; // y distance from mouse       
    
    $(".vtip").unbind().hover(    
        function(e) {
            this.t = this.title;
            this.title = ''; 
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
            
            $('body').append( '<p id="vtip"><img id="vtipArrow" />' + this.t + '</p>' );
                        
            $('p#vtip #vtipArrow').attr("src", 'http://mrbinh/vietnamholiday/images/vtip_arrow.png');
            $('p#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
            
        },
        function() {
            this.title = this.t;
            $("p#vtip").fadeOut("slow").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
            var windowwidth=document.width;
			var windowheight=screen.height;
			if((this.left+$('p#vtip').width())>=windowwidth-30){
				leftx=this.left+$('p#vtip').width()-windowwidth;
				$("p#vtip").css("top", this.top+"px").css("left", this.left-$('p#vtip').width()+15+"px");
				$('#vtipArrow').css({'position' : 'absolute' , 'top': '-10px' , 'left': $('p#vtip').width()-15+'px'})
			}else{
				$("p#vtip").css("top", this.top+"px").css("left", this.left+"px");	
			}
			
            
        }
    );            
    
};

jQuery(document).ready(function($){vtip();}) 




function checknumber(id){
		$('#'+id).focus(function(){
			$('p#bmessage').remove();
		});
		var x=$('#'+id).attr('value');
		var anum=/(^\d+$)|(^\d+\.\d+$)/
		if (anum.test(x)){
			$('p#bmessage').remove();
			return true;
		}
		else{
			$('#'+id).focus();
			 $('body').append( '<p id="bmessage">Please input a valid number!</p>' );
			  $('p#bmessage').css("top",$('#'+id).position().top-10+"px").css("left", $('#'+id).position().left +$('#'+id).width()+10+"px").fadeIn("slow");
			 return false;
		}
	}
	function checknull(id){
		var bvalue=$('#'+id).attr('value');
		if(bvalue==''){
			alert('Please enter your infomation in field focus !');
			$('#'+id).focus();
			 return false;
		}else return true;
		
	}
