var norgs;

window.addEvent('domready', function(){

	var customTips = $$('.tooltip');
	var toolTips = new Tips(customTips , {
		className: 'custom_tip'
	});

	$(document.body).removeClass('noscript');
								
	Cufon.replace($$('#mainnav li a'), {hover: true});
	Cufon.replace($$('#subnav li a'), {hover: true});
	Cufon.replace($$('#main h2'));
	//Cufon.replace($$('#main h3'));

	if($('future_conventions_list') != null){
		var news = new noobSlide({
			box: $('future_conventions_list'),
			items: $$('#future_conventions_list li'),
			size: 90,
			autoPlay: true,
			mode: 'vertical',
			handles: $$('#pagination-conventions li'),
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
		
		var highlights_handels_more = $$('#pagination-conventions li');
		news.addHandleButtons(highlights_handels_more);
		news.walk(0);
	}	
	
	if($('news_list') != null){
		var newslst = new noobSlide({
			box: $('news_list'),
			items: $$('#news_list li.row'),
			size: 369,
			autoPlay: true,
                        interval: 10000,
			mode: 'vertical',
			handles: $$('#pagination-news li'),
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
	
	
		var highlights_handels_more = $$('#pagination-news li');
		newslst.addHandleButtons(highlights_handels_more);
		newslst.walk(0);
	}
	if($('lpressrellst') != null){
		var presslst = new noobSlide({
			box: $('lpressrellst'),
			items: $$('#lpressrellst li'),
			size: 486,
			autoPlay: false,
			mode: 'vertical',
			handles: $$('#pagination-lpress li'),
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
	
	
		var highlights_handels_more = $$('#pagination-lnews li');
		presslst.addHandleButtons(highlights_handels_more);
		presslst.walk(0);
	}
	
	if($('lnewslst') != null){
		var lnews = new noobSlide({
			box: $('lnewslst'),
			items: $$('#lnewslst li'),
			size: 486,
			autoPlay: false,
			mode: 'vertical',
			handles: $$('#pagination-lnews li'),
			onWalk: function(currentItem,currentHandle){
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
	
	
		var highlights_handels_more = $$('#pagination-lnews li');
		lnews.addHandleButtons(highlights_handels_more);
		lnews.walk(0);
	}
	if($('country_results') != null){
            norgs = new noobSlide({
                box: $('country_results'),
                items: $$('#country_results li'),
                size: 700,
                autoPlay: false,
                mode: 'vertical',
                handles: $$('#pagination-members li'),
                onWalk: function(currentItem,currentHandle){
                    $$(this.handles).removeClass('active');
                    $$(currentHandle).addClass('active');
                }
            });

            var highlights_handels_more = $$('#pagination-members li');
            norgs.addHandleButtons(highlights_handels_more);
            norgs.walk(0);
	}	

	if($('slides') != null){
		var slides = new viewer($$('#slides img'),{mode:'alpha'});
		var handles = $$('#subnav li');
		handles.each(function(el,i){el.addEvent('mouseover', slides.walk.bind(slides,[i,true]));});
		handles.each(function(el,i){el.addEvent('mouseout', slides.play());});
	}
	
	SqueezeBox.initialize();
	SqueezeBox.assign($$('a[rel=boxed]'), {
		size: {x: 425, y: 349}
	});
	
	
	if($('topnav_members') != null){
	    if($('BirLoginForm_LoginForm') != null) {
		$$('#topnav_members a')[0].removeProperty('href')
		$('topnav_members').addEvent('click', function(e){e.stop(); $('BirLoginForm_LoginForm').toggleClass('hide');});
	    }
	}
	if($('SiteSearchForm_SearchForm') != null)
	{
	    ssq = $$('.SiteSearchQ');
	    //srchbox.addEvent('mouseover', function(){ if(srchbox.value=='What do you want to find?')srchbox.value=''; });
	    ssq.addEvent('focus', function(){ if(ssq.getProperty('value')=='What do you want to find?')ssq.setProperty('value',''); });
	    ssq.addEvent('blur', function(){ if(ssq.getProperty('value')=='')ssq.setProperty('value','What do you want to find?'); });
	}
	//console.log('structure');

        /* tabbed table code */
	if ($$('ul.tab') != null) {
	    var current; var tabs = $$('ul.tab li');
	    tabs.each(function(tab, i){
		    tab.content = $(tab.getProperty('id')+"_content");
		    tab.disable = function(){tab.removeClass('active');tab.content.removeClass('active');}
		    tab.enable = function(){tab.addClass('active');tab.content.addClass('active');}
		    /* tab.getElement('a').removeProperty('href'); */
		    tab.addEvent('click', function(event){current.disable();tab.enable();current=tab;return false;});
		    if(tab.hasClass('active')) {current=tab;}
	    });
	}
	
	if($('structure') != null){
		var tiplinks = $$('a.tiplink'); var tips=[]; var current;
		tiplinks.each(function(tiplink, i){
			var href = tiplink.getProperty('href');
			var pos = href.lastIndexOf('/');
			var id = href.substr(pos+2);
			tips.push(id);
			new Fx.Slide(id).hide();
			tiplink.addEvent('click', 
			function (e){
				e.stop(); 
				if(current){current.removeClass('selected');}
				tips.each(
					function(tip, j)
					{
						if(i!=j){
							var slide = new Fx.Slide(tip).slideOut();
							slide.addEvent("complete",function(e){e.removeClass('selected');});
						}else{
							var slide = new Fx.Slide(tip).toggle();
							slide.addEvent("complete",function(e){$(e).toggleClass('selected');});
							if(e.target != current)
							{
								current = e.target;
								current.addClass('selected');
							}
						}
					});
				
			});
		}); 
	}

});

function SubmitGlobalSearch()
{
    //$('SiteSearchForm_global').submit();
    $('SiteSearchForm_SearchForm').submit();
}

function doLogin()
{
    $('BirLoginForm_LoginForm').submit();
}
function DropDownSubmit(value) {
 if(value !='') {
 window.location.href = value;
 }
} 

