        $(document).ready(function() {

        $("body").css("background", "#000000 url(http://khoofia-staticsite.s3.amazonaws.com/blog/16/candy/i/renderedbg3.jpg) no-repeat center top");
            
            $("#a1").mouseover(function() {
                $("#cram").stop().animate({
                    marginTop: "0px",
                    height: "280px", marginLeft: "50px"
                }, 1000);
            });
            $("#a1").mouseout(function() {
                $("#cram").stop().animate({
                    height: "230px", marginLeft: "0px",
                    marginTop: "50px"

                }, 500);
            });



            $("#a2").mouseover(function() {
                $("#sez").stop().animate({
                    height: "222px", marginLeft: "161px",
                    marginTop: "-222px"

                }, 1000);
            });
            $("#a2").mouseout(function() {
                $("#sez").stop().animate({
                    height: "172px", marginLeft: "111px",
                    marginTop: "-172px"

                }, 500);
            });

            $("#a3").mouseover(function() {
                $("#hi").stop().animate({
                    height: "164px", marginLeft: "280px",
                    marginTop: "-164px"

                }, 1000);
            });

            $("#a3").mouseout(function() {
                $("#hi").stop().animate({
                    height: "114px", marginLeft: "230px",
                    marginTop: "-114px"

                }, 500);
            });

                 $("#categorylist > li").mouseover(function () {
                    $(this).stop().animate({ 
                         marginLeft: "10px"
                         }, 250 );
                         
                          
                                    
                                                 });

                                       
             $("#categorylist > li").mouseout(function () {       
                            $(this).stop().animate({ 
                                 marginLeft: "0px"
                                 }, 200 );         });
                  


       		var count=5;
            var offset=0;
            var query="http://api.search.live.net/json.aspx?AppId=D69A44051C4E59E8E3EF4E95A3513A8337DCF6A9&Query=";
            var trailer="&Sources=Web&Version=2.0&Market=en-us&JsonType=callback&JsonCallback=?";

      
            $("#searchfield").val("Search This Site");
            $("#searchfield").blur(function(){
             if ($("#searchfield").val() == "")
                    $("#searchfield").val("Search This Site");
            
            
            });   
           $("#searchfield").focus(function(){ 
            if ($("#searchfield").val() == "Search This Site")
                    $("#searchfield").val("");
                    
                    });
                    
                    
			$("#sb2submit").click(function(){
            
         $("#searchfield").val($("#sb2text").val());
			performsearch($("#sb2text").val(), 0);
									 });
						
			$("#sb2submit2").click(function(){			 
									 var search = "search.aspx?q=" + encodeURIComponent($("#sb2text").val());
                                    top.location.href = "http://www.khoofia.com/blog/" + search;
                                            });
			            
			$("#sbr").click(function(){
       		  $("#sb2text").val($("#searchfield").val()); 
			performsearch($("#searchfield").val(), 0);
									 });

            $("#searchfield").keyup(function(e) {
                 if(e.keyCode == 13) {
                    $("#sb2text").val($("#searchfield").val()); 
                    performsearch($("#searchfield").val(), 0);;
                                     }
             });
             						 
			$("#sfootback").click(function(){
            if(offset >= count)
			performsearch($("#searchfield").val(), -5);
									 });
						 
			$("#sfootfront").click(function(){
            
			performsearch($("#searchfield").val(), 5);
									 });
						 
		
				function performsearch(str,of){
				
					$("#sresults").html("Search results will appear shortly. Thanks you for your patience.");

						offset += of;
						var sending= query + str + " site:khoofia.com"
            		   + "&Web.Count=" + count.toString()+ "&Web.Offset="+ offset.toString() + trailer;
            	
            		   
            $.getJSON(sending,
        		function(data){
        			$("#sresults").empty();
        			var reslist = [];
        			if (data.SearchResponse.Web.Results!=null){
          			$.each(data.SearchResponse.Web.Results, function(i,item){
		          		reslist[i]= "<a href=\""+item.Url+"\">" + item.Title + "</a>" + "<br />" + 
          							"<span>" + item.Description + "</span>";
          							});
          			 	$("#sresults").html(reslist.join(''));}
          		    else if(data.SearchResponse.Web.Results==null){
        		$("#sresults").html("<br /><br />Bing could not find any pages, sadly. Lets see if our internal search engine can help you. We\'re sorry to keep you waiting. ");
        			var search = "search.aspx?q=" + encodeURIComponent($("#sb2text").val());
                                    top.location.href = "http://www.khoofia.com/blog/" + search;
        			}
        			});
        			
				$("#senc").modal();

					}					  





     });

