
// slide the account tab
window.addEvent('domready', function(){
	var login = $('loginform');
	var toggle = $('toggle');
	if(login && toggle){
		var slide = new Fx.Slide('loginform');
		slide.hide();
		toggle.addEvent('click', function(e){
			e = new Event(e);
			slide.toggle();
			e.stop();
		});
	}
});

// navigation
window.addEvent('domready', function() {
	navli = $('nav').getChildren();
	navli.each(function(el) {
		var subnav = el.getElement('div');
		if(subnav){
			subnav.set('styles', {'opacity': 0});
			subnav.set('morph', {duration: 250});
			el.addEvent('mouseenter', function(e){
				this.addClass('over');
				subnav.morph({
					'opacity': 1,
					'display': 'block',
					'visibility': 'visible'
				});
			});
			el.addEvent('mouseleave', function(e){
				this.removeClass('over');
				subnav.morph({
					'opacity': 0,
					'display': 'none',
					'visibility': 'hidden'
				});
			});
		}else{
			el.addEvent('mouseenter', function(e){
				this.addClass('over');
			});
			el.addEvent('mouseleave', function(e){
				this.removeClass('over');
			});
		}			
	});
});



// show/hide tab management
window.addEvent('domready', function(){
	var tablinks = $$('#tabs a');
	var tabmodifier = "-tab";
	var currentTab;
	if(tablinks){
		var activetabs = tablinks.filter(function(el){
		  var id = el.get('id');
		  if(id){ var tabcontent = $(id + tabmodifier); }
      if(tabcontent){
      	return el;
      }
		});
		
		activetabs.each(function(el) {
			el.set({
		    'events': {
	        'click': function(){ showTab(el); currentTab = el; return false; }
		    }
			});
			if(el.hasClass('current')){
				currentTab = el;
			}
		});
		
		if(!currentTab){
			currentTab = activetabs[0];
		}
		showTab(currentTab)
	}
	
	function showTab(tab){
		activetabs.each(function(el) {
			var id = el.get('id');
		  if(id){ var tabcontent = $(id + tabmodifier); }
      if(tabcontent){
      	if(tab == el){
					el.set('class', 'current');
					tabcontent.set('class', 'tabcontent');
				}else{
					if(el.hasClass('current')){ el.removeClass('current'); }
					tabcontent.set('class', 'hide');
				}
      }
		});
	}
});

// Pop Up Window
var newwindow;
function popup(url){
	newwindow=window.open(url,'name','height=580,width=560, scrollbars=yes, toolbar=no, menubar=no, resizable=yes');
	if (window.focus) {newwindow.focus()}
}

// Bookmarking
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  	window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}


