
function swapImageSrc(num) {
	index = parseInt(num);
	thb = $('fotogde');
	thb.src = 'http://istos.swapi.com.br/sites/pc2006/imagens/spacer.gif';
	thb.src = foto_url[index];

	
	for (var i = 1; i <= qtImgs; i++) {
 		jscss('remove',$('thb'+i),'selecionado');
	}

	jscss('add',$('thb'+index),'selecionado');
	
	$('legenda').innerHTML = foto_caption[index];

}

	
/*
a  => defines the action you want the function to perform.
o  => the object in question.
c1 => the name of the first class
c2 => the name of the second class
Acoes:
swap   => replaces class c1 with class c2 in object o.
add    => adds class c1 to the object o.
remove => removes class c1 from the object o.
check  => test if class c1 is already applied to object o and returns true or false. 
*/
function jscss(a,o,c1,c2)
{
  switch (a){
    case 'swap':
      o.className=!jscss('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
    break;
    case 'add':
      if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
    break;
    case 'remove':
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
    break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className)
    break;
  }
}


