//Dependências
//prototype.js

function softTabs(tab,tabbed,count,param) {	
	var tab_main = tab;
	var tab_sec = tabbed;
	var count = count;
	var conta = 0;
	var op = (param) ? param : {};
	
	//Verifica se existem todas as div's necessárias para se poder aplicar o objecto com sucesso
	for ( var i = 1; i <= count; i++ ) {
		if ( $(tab_main+i) && $(tab_sec+i) ) {
			conta++;
		}
	}
	
	if ( conta == 0 ) {
		alert('Não existem tabs!');
		return;
	}
	conta = null;
	var pointer = this;
	for ( var i = 1; i <= count; i++ ) {
		if ( $(tab_main+i) ) {
			$(tab_main+i).onclick = function (id) { return pointer.selectDiv(this.id); };
		}
	}
	
	this.selectDiv = function (id) {
		this.hideAllDivs();
		var tmp = id.split('_');
		var tmp_length = tmp.length;
		tmp = tmp[(tmp_length-1)];
		$(id).className = 'tab_activa';
		$('tab_link_'+tmp).style.color = '#FFFFFF';
		$(tab_sec+tmp).style.display = 'block';
		if ( op.executeFunctions[tmp-1] && typeof(op.executeFunctions[tmp-1]) == "function" ) {
			op.executeFunctions[tmp-1]();
		}
	}
	
	this.hideAllDivs = function () {
		for ( var i = 1; i <= count;  i++ ) {
			if ( $(tab_sec+i) && $(tab_main+i) ) {
				$(tab_sec+i).style.display = 'none';
				$(tab_main+i).className = 'tab_inactiva';
				$('tab_link_'+i).style.color = '#A8AF97';			
			}
		}
	}
	
	this.selectTab = function (number,exec) {
		this.hideAllDivs();
		if ( $(tab_sec+number) && $(tab_main+number) ) {
			$(tab_sec+number).style.display = 'block';
			$(tab_main+number).className = 'tab_activa';
			$('tab_link_'+number).style.color = '#FFFFFF';
			if ( exec == 1 && op.executeFunctions[number-1] && typeof(op.executeFunctions[number-1]) == "function" ) {
				op.executeFunctions[number-1]();
			}
		}
	}
	
}