
function enterHandler(field, e, splash) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
   		emailSignup(field.value, splash);
	}
}
function emailSignup(emailAddr, splash) {

  $.post("emailSignup.php", { email: emailAddr }, function (response) {
	
	field = document.getElementById('email_signup');
	if(response == 0) {
		$('#sign_up_container').hide("fast");
                if( splash )
                     $('#signed_up_container').show("slow").fadeOut(2000, function() {  window.location = "home.php"; });
                else
                     $('#signed_up_container').show("slow");

	} else if (response == 1) {
		//invalid email
		field.style.background = "#FF5555";
		field.style.color = "#FFFFFF";
	} else {
		//server failure
		//do nothing.  maybe user will try again?
	}

  });

}


function endSession() {
  $.post("endSession.php", { }, function() {
    window.location.reload();
  });
}

function scrollNext() {

        jScroller = $('#tweet_scroller');
        scroller = document.getElementById("tweet_scroller");

        scroller.scrollItem++;
        if(scroller.scrollItem >= buzzers.length)
                scroller.scrollItem = 0;

        
        buzz = buzzers[scroller.scrollItem];
        userurl = "http://twitter.com/" + buzz.from_user;
        tweeturl = userurl + "/status/" + buzz.tweet_id;

        //rendering
        var tweet = "";
        tweet += "<a href='" + userurl + "'>" + buzz.from_user + "</b> &mdash; ";
        tweet += "<a href='" + tweeturl + "'>" + buzz.text + "</a><br /><i>(" 
                        + buzz.time + ")</i>";


        scroller.innerHTML = tweet;
  


        //animation loop
       jScroller.fadeIn(1000).animate({opacity: 1.0}, 5000).fadeOut(1000, scrollNext);

}

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name,
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=no, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}

$(document).ready(function() {

        // initialize the tweet scroller
        if(typeof($('#tweet_scroller')) != 'undefined'  && typeof buzzers != 'undefined') {
                jScroller = $('#tweet_scroller');
                scroller = document.getElementById("tweet_scroller");
                scroller.scrollItem = 0;
                jScroller.hide("fast", scrollNext);

        }
});

$(document).ready(function(){
  if(typeof($('#orderonline')) != 'undefined') {
        $("#orderonline").dialog({autoOpen: false, modal: true, draggable: false, resizable: false, title: "Select a vendor :"});
        }
});

function showorder() {
  $("#orderonline").dialog('open');
}
