var deselection_Cbs;
function deselection_OneCheckBox(){
 deselection_Cbs=document.getElementsByTagName('INPUT');
 for (deselection_0=0;deselection_0<deselection_Cbs.length;deselection_0++){
  if (deselection_Cbs[deselection_0].title){
   if (deselection_Cbs[deselection_0].title.match('deselection_')){
    deselection_AddCheckOnlyOne(deselection_Cbs[deselection_0]);
    deselection_Cbs[deselection_0].title=deselection_Cbs[deselection_0].title.replace('deselection_','');
    if (deselection_Cbs[deselection_0].title.length<1){
     deselection_Cbs[deselection_0].title=null;
    }
   }
  }
 }
}

function deselection_CheckOnlyOne(){
 for (deselection_0=0;deselection_0<deselection_Cbs.length;deselection_0++){
  if (deselection_Cbs[deselection_0].title==this.title&&deselection_Cbs[deselection_0]!=this){
   deselection_Cbs[deselection_0].checked=false;
  }
 }
}

function deselection_EventAdd(deselection_o,deselection_t,deselection_f) {
 if ( deselection_o.addEventListener ){ deselection_o.addEventListener(deselection_t, function(e){ deselection_o[deselection_f](e);}, false); }
 else if ( deselection_o.attachEvent ){ deselection_o.attachEvent('on'+deselection_t,function(e){ deselection_o[deselection_f](e); }); }
 else {
  var deselection_Prev=deselection_o['on' + deselection_t];
  if (deselection_Prev){ deselection_o['on'+deselection_t]=function(e){ deselection_Prev(e); deselection_o[deselection_f](e); }; }
  else { deselection_o['on'+deselection_t]=deselection_o[deselection_f]; }
 }
}

function deselection_AddCheckOnlyOne(deselection_){
 if (deselection_.addCheckOnlyOne){ return; }
 deselection_.addCheckOnlyOne=deselection_CheckOnlyOne;
 deselection_EventAdd(deselection_,'click','addCheckOnlyOne');
}


function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',3000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};


var active_tab = 0;
var active_tab_first = 1;
function switch_tabs(prefix, new_tab, first)
{
	if ( typeof(first) != 'undefined' ) {
		if ( active_tab_first == 1 ) {
			$('#'+prefix + '_' + new_tab + '_content').show();
			$('#'+prefix + '_' + new_tab + '_tab').addClass("active");
			active_tab = new_tab;
			active_tab_first = 0;
		}
	}
	else if ( active_tab != new_tab ) {
		$('#'+prefix + '_' + active_tab + '_content').hide(300);
		$('#'+prefix + '_' + active_tab + '_tab').removeClass("active");

		$('#'+prefix + '_' + new_tab + '_content').show(300);
		$('#'+prefix + '_' + new_tab + '_tab').addClass("active");
		active_tab = new_tab;
	}
}

function showhide_field(name, show)
{
    if ( $('#'+name).css("display") == "none"  &&  (show == '' || show == undefined)  ||  show == 1 )
    {
        $('#'+name).fadeIn("fast");
    }
    else
    {
        $('#'+name).fadeOut("fast");
    }
}



