


function lookup(inputString) {
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		$.post("/lib/components/search/rpc.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#suggestions').fadeIn(); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}


// What is $(document).ready ? See: http://flowplayer.org/tools/using.html#document_ready
$(document).ready(function() {





 $("#searchform input").tooltip({
												
												tip:'#demotip',
												position:['top', 'center'],
												offset:[0,-70]
												
												}); 
				 
				var api = $("#searchform input").tooltip(0);
			 	
				// show the tooltip 
				//api.show();

// Safely inject CSS3 and give the search results a shadow
	var cssObj = { 'box-shadow' : '#888 5px 10px 10px', // Added when CSS3 is standard
		'-webkit-box-shadow' : '#888 5px 10px 10px', // Safari
		'-moz-box-shadow' : '#888 5px 10px 10px'}; // Firefox 3.5+
	$("#suggestions").css(cssObj);
	
	// Fade out the suggestions box when not active
	 $("input").blur(function(){
	 	$('#suggestions').fadeOut();
	 });



});

///// LOGIN FORM /////////
$(function() {         
         
  
         
    // setup triggers 
    $("#loginbtn").click(function() { 
            
		 $("#login").css({ 'height':'50px'});
			
			
        $("#login").overlay({ 
 			
			
			expose: {
			
						// you might also consider a "transparent" color for the mask
						color: '#000',
						
						// load mask a little faster
						loadSpeed: 200,
						
						// highly transparent
						opacity: 0.5
			},
            // common configuration for each overlay 
           
            closeOnClick: false,  
              
            // setup custom finish position 
            top: 50, 
          
             
            // use apple effect 
           // effect: 'apple' ,
			api: true

// load it immediately after the construction
		}).load();        
    }); 
     
	 
	 
});


$(function() {         
       
       // setup triggers 
    $("#loginform").submit(function() { 
			var username =$("#username").val();	
			var password =$("#password").val() ;
							
			if (username !== "" && password !=="" ) {
				$.ajax({
					type: "POST",
					url: "/section/module/login.php",
					data: "username="+username+"&password="+password,
					success: function(data){
						if(data=="success"){
							//alert("success");
							window.location.reload();
						}
						if(data=="failed"){
							$("span").text("Cannot find user!!").show().fadeOut(1000);
						}
					}
				});
									 
				
				//$("span").text("Validated...").show().fadeOut(1000);
					//return false;
				//return true;
			} else{ // end if username and password not null			
			
			$("span").text("Not valid!").show().fadeOut(1000);
			return false;
			}
			return false;		 
	});// on submit
	

});// on ready
/// END LOGIN FORM ///////


//// logout////
$(function() {  
$("#logoutbtn").click(function() { 
$.ajax({
					type: "POST",
					url: "/section/module/logout.php",
					data: "",
					success: function(data){
						
						if(data=="success"){
							//alert("success");
							window.location.reload();
						}
						if(data=="failed"){
							$("span").text("error logout!!").show().fadeOut(1000);
						}
					}
				});
								
}); // on click
     
	 
	 
});// on ready
//// end log out///



///// SEND TO FRIEND FORM /////////
$(function() {         
         
  
         
    // setup triggers 
    $("#sendfriendclick").click(function() { 
            
		 $("#sendfriend").css({ 'height':'50px'});
			
		var sendfriendform;	
		
       sendfriendform= $("#sendfriend").overlay({ 
 			
			
			expose: {
			
						// you might also consider a "transparent" color for the mask
						color: '#000',
						
						// load mask a little faster
						loadSpeed: 200,
						
						// highly transparent
						opacity: 0.5
			},
            // common configuration for each overlay 
           
            closeOnClick: false,  
              
            // setup custom finish position 
            top: 50, 
          
             
            // use apple effect 
           // effect: 'apple' ,
		   oneInstance: false,
			api: true

// load it immediately after the construction
		});        
	   
	   sendfriendform.load();
	  
	   
    }); 
     
	 
	 
});

$(function() {         
       
       // setup triggers 
    $("#sendfriendform").submit(function() { 
										 
			var youremail =$("#youremail").val();	
			var friendemail =$("#friendemail").val() ;
			
			
			//alert(friendemail);
							
			if (youremail !== "" && friendemail !=="" ) {
				
				$.ajax({
					type: "POST",
					url: "/section/module/sendtofriend.php",
					data: "youremail="+youremail+"&friendemail="+friendemail+"&url="+window.location,
					success: function(data){
						if(data=="success"){
							
							var sendfriendform;
							 
							sendfriendform=$("#sendfriend").overlay();
							
							sendfriendform.close();
							
							//window.location.reload();
						}
						if(data=="failed"){
							$("span").text("Problem sending please try again soon.").show().fadeOut(1000);
						}
					}
				});
									 
				
				
			} else{ // end if if data not null	
			
			$("span").text("Not valid!").show().fadeOut(1000);
			return false;
			}
			return false;		 
	});// on submit
	

});// on ready
/// END SENDFRIEND FORM ///////


