// -------- start of jQuery document.ready() ---------- //
  
$(document).ready(function() {

  //create rollover effect for logo
  $("#logo-link img").hover(function(){this.src = this.src.replace("-off","-on");},function(){this.src = this.src.replace("-on","-off");});
   
  //adding ID menu for compatibility
  $("menu").attr({id: "menu"});
  
  //on click remove value from search input
    $("#header fieldset input:text").click(function() {
    $("#header fieldset input:text").attr({value: ""});
    });
    $(".subscription fieldset input:text").click(function() {
    $(".subscription fieldset input:text").attr({value: ""});
    });
  
  //special graphics
  $("#header .inside").append('<span class="balloon"></span> <span class="opera-eifel"></span>');
  
  $("#main .inside").append('<div id="special"><span class="pisa-jesus"></span> <span class="pyramids"></span> <span class="sfinx"></span> <span class="safari"></span> <span class="elephants"></span></div>');
  
  //find all holders of a.more link and add class right to them
  $("p:has('a.more')").addClass("right");
  
  //finding &raquo; inside of a.more links and wrapping it inside <span></span>
  $("a.more").append(' <span>&raquo;</span>');
  
  //removing background from the last li in footer
  $("#footer li:last").css({background: 'none', paddingRight: '0'});  
  
  var dwidth = $(document.body).innerWidth()-300;
  var dheight = $(document.body).innerHeight();
  var inmotion = false;
  //var mouseX = mouseY = 0; 
  //$().mousemove(function(e) { mouseX = e.pageX; mouseY = e.pageY; });

  function animateballoon (h,w) {
	hstr = h+"px";
	wstr = w+"px";
	$("#header span.balloon").animate({ 
	        left: wstr,
	        top: hstr
	      }, 15000, function(){
			goto_height = (Math.round((Math.random()*dheight)+1));
			goto_width = (Math.round((Math.random()*dwidth)+1));
			//goto_width=mouseX;
			//goto_height=mouseY;
			//alert ("move to:"+goto_width+","+goto_height);
			animateballoon (goto_height,goto_width);
			});
  }

  $("#header span.balloon").click(function(){
	if (inmotion==false){
	
	goto_height = (Math.round((Math.random()*dheight)+1));
	goto_width = (Math.round((Math.random()*dwidth)+1));
	animateballoon (goto_height,goto_width);
			
	inmotion=true;
	}
	});
	
});
// -------- end of jQuery document.ready() ---------- //


// -------- start search form support --------------- //

function searchsubmit() {
	if (document.forms[0].searchtype.checked==true) {
		strsearchtype = "users";
	}
    else {
      	strsearchtype = "editorial";
    }

	if (document.forms[0].search_term.value!=null && document.forms[0].search_term.value!=""){
		window.location = "/search/"+strsearchtype+"/"+escape(document.forms[0].search_term.value.replace(/ /g,"+"))+"/1.html";
	}
	else {
		window.location = "/latest-experiences";
	}
}

// -------- end search form support ---------------- //