$('document').ready(function(){
    var count = 0;
    $('#bulletin-board').load('bulletin-info.php', function(){
        var bload = Math.floor(Math.random()*348000);
		//var bload = Math.floor(Math.random()*100);
        /*$('.bulletindiv:even').css({
            "background-color": "#f1f1f1"
        });*/
        fn_bulletingclick();
        timeoutID = window.setTimeout(fn_movebulletin, bload, true);
    });
    
    var movedowncount = 0;
    $('#movedown').click(function(){
        //fn_movebulletin();
        if (movedowncount != 15) {
            movedowncount++;
            $('#movebooking').animate({
                "top": "-" + (100 * movedowncount) + "px"
            });
        }
        return false;
    })
    
    $('#moveup').click(function(){
        //fn_movebulletin();
        if (movedowncount > 0) {
            movedowncount--;
            $('#movebooking').animate({
                "top": "-" + (100 * movedowncount) + "px"
            });
        }
        return false;
    })
    
    // fn_movebulletin.delay(800);
    function fn_movebulletin(){
        var randomload = Math.floor(Math.random()*348000);
      
        //var randomload = 1000;
        
        $.get('loadinfo.php', {
            'passinfo': (10 + count)
        }, function(data){
            $('#movebooking').prepend(data).fadeIn(1400);
            fn_bulletingclick();
        })
        count++;
        if (count != 16) {
            timeoutID = window.setTimeout(fn_movebulletin, randomload, true);
        }
    }
    
    function fn_bulletingclick(){
        $('.bulletindiv').each(function(index){
            $('#booking' + index).click(function(){
              
                var sendinfo = window.location.search;
                
				        hotelid = $('#hotelid' + index).html();
				        if(hotelid == "LGWICH"){
				          window.location.href = "http://www.gatwickhotels.info/ifieldcourt/index.php";
				        } else {
                  $('#soldoutpopup').dialog('open');
                }
                //alert($('#hotelid'+index).html());
                window.clearTimeout(timeoutID)
            })
        })
    }
	$('.navclick').each(function(index){
		$('#navbook'+index).click(function(){

			hotelid = $('#hotelidnav' + index).html();
			//alert(hotelid);
		    $('#soldoutpopup').dialog('open');
		    
			return false;
		})
	})
})

