/**
 * @author Gavin Williams
 */

jQuery(document).ready(function(){

	var $primary = jQuery('#primary'), $secondary = jQuery('#secondary');
	
	if($primary.height() > $secondary.height()){
		$secondary.height($primary.height());
	} else {
		$primary.height($secondary.height());
	}
	
	jQuery('#primaryNav li ol').css({visibility: 'hidden', display: 'block'});
	jQuery('#primaryNav li').each(function(){
		var $this = jQuery(this), width = 0;
	});
	
	jQuery('#primaryNav li ol').css({visibility: 'visible', display: 'none'});
	
	jQuery('form.nobreaks br').remove();
	
	jQuery('#primaryNav li').hover(function(){
		var $this = jQuery(this);
		// $this.find('ol').css({display: 'block'});
		$this.find('ol').fadeIn('fast');
	}, function(){
		var $this = jQuery(this);
		// $this.find('ol').css({display: 'none'});
		$this.find('ol').fadeOut('fast');
	});
	
	jQuery('#primaryNav li ol li').hover(function(){
		var $this = jQuery(this);
		// $this.find('ol').css({display: 'block'});
		$this.find('ul').fadeIn('fast');
	}, function(){
		var $this = jQuery(this);
		// $this.find('ol').css({display: 'none'});
		$this.find('ul').fadeOut('fast');
	});

});


//here you place the ids of every element you want.
var ids=new Array('post-entry','cforms');

var primaryHeight = 0;

function switchid(id){	
	hideallids();
	showdiv(id);
	if (id == 'cforms') {
		primaryHeight = jQuery('#primary').height();
		jQuery('#primary').height(jQuery('#cforms').height() + 150);
	}
	
	if(id == 'post-entry'){
		jQuery('#primary').height(primaryHeight);
	}
	
	document.getElementById('footerLinks').style.bottom = 0;
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
