
		//to make sure iphone doesn't jump around
		if($('input:focus').length === 0) {
			$('#input-word').focus();
		}
		$('#picfog-form p label > a').attr('href','');
		$('#promo-liveflow').hover(function() {
			$('#promo-liveflow a:eq(0)').html('Live flow!');
			$('#promo-liveflow-png').hide();
			$('#promo-liveflow-gif').show();
		},function() {
			$('#promo-liveflow a:eq(0)').html('Live flow');
			$('#promo-liveflow-png').show();
			$('#promo-liveflow-gif').hide();
		});
		
		$('#picfog-form p label > a').click(function(e) {
			e.preventDefault();
			if($(this).parent().hasClass('added')) { $(this).next().focus(); return; }
			var cp = $(this).closest('p');
			$(this).parent().addClass('added');
			$(this).next().focus();
			$(this).parent().siblings().removeClass('added');
			$(this).parent().siblings().hide();
			if($(this).hasClass('extend_near')) {$(this).html('Location:'); cp.find('a.extend_users').html('By @user');}
			else {$(this).html('By @user:'); cp.find('a.extend_near').html('Location');}
			//cp.find('input').hide();
			//$(this).next().show();
		});
		$('#picfog-form p label a').focus(function(e) {
			$(this).click();
		});
		
		$('#picfog-form p label input').blur(function(e) {
			var th = $(this);
			setTimeout(function() {
				if($('#picfog-form p input:focus').length === 0 && th.val() === '') {
					th.parent().removeClass('added').show();
					th.parent().siblings().removeClass('added').show();
					$('#picfog-form a.extend_near').html('Location');
					$('#picfog-form a.extend_users').html('By @user');
				}
			},250);
		});
		
		$('#picfog-form').submit(function(e) {
			e.preventDefault();
			var loc = '/';
			var wnu = {
				"near": $('#input-near').val(),
				"user": $('#input-user').val(),
				"word": $('#input-word').val()
				}
			wnu['word'] = wnu['word'].replace(/^\#/,'H-');
			wnu['user'] = wnu['user'].replace(/^\@/,'');
			if($('#input-near').val() !== '' && $('#input-near').parent().hasClass('added')) {
				loc += 'near/' + encodeURIComponent(wnu['near']) + '/' + encodeURIComponent(wnu['word']); 
			} else if($('#input-user').val() !== '' && $('#input-user').parent().hasClass('added')) {
				loc += 'users/' + encodeURIComponent(wnu['user']) + '/' + encodeURIComponent(wnu['word']);
			} else if($('#input-word').val() !== '') {
				loc += 'search/' + encodeURIComponent(wnu['word']);
			}
			document.location = loc;
		});
		
		$('#input-word').keyup(function() {
			var acval;
			var nowv = $(this).val();
			if($('#input-word').data('busy')) {return false;}
			$('#input-word').data('busy',true)
			$.getJSON('http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=sf0Mei7V34GRESM3j_K0cSCKLzzq.9kM3jFUTIb97DSMpeJY.Gj8SV67gjma2z1fq7zgbDc-&query=' +encodeURIComponent($('#input-word').val())+ '&output=json&callback=?', function(data) {
			/*	if(data && data.ResultSet && data["ResultSet"]["Result"]) {
					acval = '';
					$.each(data["ResultSet"]["Result"], function(di,dv) {
						acval += '<a href="' + dv + '">' + dv + '</a>'
					});
					$('#ac-word').html(acval);
					$('#input-word').data('busy', false);
				} else {
					$('#input-word').data('busy', false);
					$('#ac-word').html('');

				}
			*/
			}); 
		});
		PICFOG.query.processed = {};
		PICFOG.user.process();
		PICFOG.viewport = $(window);

		if(typeof(window.orientation) !== 'number') {
			PICFOG.inittooltip();
		}


