Event.observe(window, 'load', function() {


  $('topnavi').select('li').invoke('observe','mouseover',function(ev) {
		$$('ul.sub_menu').invoke('hide');
	  $(ev.findElement('li').id + '_more').show();
	});

  $$('.fp_AutocompleteField').invoke('observe','focus',function(ev) {
				if (this.value == 'Start typing a name')	{
					this.value='';
				}
  });
 
  $$('p.openComments').invoke('observe','click',function(ev)	{
  	var this_article = ev.findElement('p').id;
    new Ajax.Updater($("comments_" + this_article),"/inc/comments_display.php",{
      parameters: {
        cm_Article: this_article
      },
      onSuccess: function(){
        //alert('!!');
      },
      onFailure: function(){
      },
      onComplete: function(){
        $("comments_" + this_article).toggle('blind',{duration:1});
      }
    });
  });


 
  $$('div.gallery div.article_image').each(function(el,i)	{
 	if (i%3 == 0)	{
  		el.style.clear = "both";
  	}
  });


	$$('div.fp_YouTube').each(function(el)	{
		var player = el.select('.player');
		var playlist = el.select('.playlist');
		playlist[0].select('li').invoke('observe','click',function(video)	{
			var yt = this.id.replace(/YouTubeID_/,'');
			player[0].update('<object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/' + yt + '&amp;border=1&amp;color1=0x3a3a3a&amp;color2=0x999999&amp;feature=player_embedded&amp;fs=1"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="http://www.youtube.com/v/' + yt + '&amp;border=1&amp;color1=0x3a3a3a&amp;color2=0x999999&amp;feature=player_embedded&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="425" height="349"></object>');
		});
	});

  
});


function submitComment()	{
	
	var cm_Article = $('cm_Article').value;

        new Ajax.Updater($("comments_" + cm_Article),"/inc/comments_display.php",{
          parameters: $('fm_SubmitComment').serialize()
        });

}


function setSearchCookie(whichWay)	{

	Cookie.set('fp_SearchOrder',whichWay);
	location.reload(true);
	
}




	function getAutocompleteQuery(a,b)	{
		return b;
	}


