/* ----------- SWITCH PORTFOLIO CATEGORIES ---------- */
function switch_portfolios(showthis) {
	tabtoshow = 'show_'+showthis;
	var targetmain = document.getElementById("mainContent");
	targetmain.className = tabtoshow;

}


/* ----------- FADES CONTENT DIVS ---------- */


var n_prevTab; 			// last active tab
var n_prevSubTab;		// last active subtab
var timeout;					// timeout have been assigned to a var so it can be cleared if a tab is clicked
//var n_numTabs 	= 5; 	// number of Tabs

function hideslides() {
	document.getElementById("blockupInnerContent1").style.display = "none";
}


function changeTab(n_id, s_stop){
	if (s_stop !== "TRUE") {
	switchTab(n_id, s_stop); // fade in new tab
		(n_id === n_numTabs) ? n_nextId = 1 : n_nextId = n_id + 1; // figure out next tab to move to.  if current tab is the last tab then back to first.
		timeout = setTimeout("changeTab(" + n_nextId + ")", 7000); // If not set to stop then wait 3 second and call this function again to move to next tab.
	} else {
		clearTimeout(timeout);
		timeout = setTimeout("changeTab(" + n_nextId + ")", 15000); // If any tab is selected, changes the interval to 10 seconds, to give some time to read the content.
	}
}

function getBlock(s_type, n_id) { 
	return document.getElementById("blockup" + s_type + n_id);
}

function switchTab(n_id, s_stop){	
	 // clear previous tab
	if (n_prevTab) {
		//getBlock('InnerTabs', n_prevTab).className = 'tab' + n_id;
		getBlock('InnerContent', n_prevTab).style.display = 'none';	
		changeOpac(0, 'blockupInnerContent' + n_prevTab);
	}
	n_prevTab = n_id; //set previous tab var with the current id

	// show current tab
	//getBlock('InnerTabs', n_id).className = 'tab' + n_id + ' current';
	getBlock('InnerContent', n_id).style.display = 'block';
	opacity('blockupInnerContent' + n_id, 0, 100, 300);
}

/* OPACTITY FUNCTIONS */
function opacity(id, opacStart, opacEnd, millisec) {
    var speed = Math.round(millisec / 100);    //speed for each frame
    var timer = 0;

    //determines fade direction
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--, timer++) setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++, timer++) setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
    }
}

function changeOpac(opacity, id) {
    var el = document.getElementById(id).style;
    el.opacity = (opacity / 100);
    el.MozOpacity = (opacity / 100);
    el.KhtmlOpacity = (opacity / 100);
    el.filter = "alpha(opacity=" + opacity + ")";
}

function expand_collapse(elem)
	{
	elem.parentNode.parentNode.parentNode.className = (elem.parentNode.parentNode.parentNode.className == 'expanded')?'':'expanded';
}

