var tabView = new YAHOO.widget.TabView('facultyTabView');

function getTabView(index) {
	tabView.set('activeIndex', index);
}


if (window.document.location.hash === '#orgLocations') {
	tabView.set('activeIndex', 2);
	
}

function showSubTab(subID) {
	var elem1 = document.getElementById('AllArticles'),
	elem2 = document.getElementById('YMGArticles'),
	elem3 = document.getElementById('STWArticles'),
	subT1 = document.getElementById('allArtTab'),
	subT2 = document.getElementById('ymgArtTab'),
	subT3 = document.getElementById('stwArtTab');
	
	if (subID == 'AllArticles') {
		elem1.style.display = 'block';
		elem2.style.display = 'none';
		elem3.style.display = 'none';
		subT1.style.color = '#C7511F';
		if(subT2 !== null){	subT2.style.color = '#585858'; }
		if(subT3 !== null){	subT3.style.color = '#585858'; }
	} else if (subID == 'YMGArticles') {
		elem1.style.display = 'none';
		elem2.style.display = 'block';
		elem3.style.display = 'none';
		if(subT1 !== null){	subT1.style.color = '#585858'; }
		subT2.style.color = '#C7511F';
		if(subT3 !== null){	subT3.style.color = '#585858'; }
	} else if (subID == 'STWArticles') {
		elem1.style.display = 'none';
		elem2.style.display = 'none';
		elem3.style.display = 'block';
		if(subT1 !== null){	subT1.style.color = '#585858'; }
		if(subT2 !== null){	subT2.style.color = '#585858'; }
		subT3.style.color = '#C7511F';
	}
}

window.location.querystring = (function() {
 
    // by Chris O'Brien, prettycode.org
 
    var collection = {};
 
    // Gets the query string, starts with '?'
 
    var querystring = window.location.search;
 
    // Empty if no query string
 
    if (!querystring) {
        return { toString: function() { return ""; } };
    }
 
    // Decode query string and remove '?'
 
    querystring = decodeURI(querystring.substring(1));
 
   // Load the key/values of the return collection
 
    var pairs = querystring.split("&");
 
    for (var i = 0; i < pairs.length; i++) {
 
        // Empty pair (e.g. ?key=val&&key2=val2)
 
        if (!pairs[i]) {
            continue;
        }
 
        // Don't use split("=") in case value has "=" in it
 
        var seperatorPosition = pairs[i].indexOf("=");
 
        if (seperatorPosition == -1) {
            collection[pairs[i]] = "";
        }
        else {
            collection[pairs[i].substring(0, seperatorPosition)] 
                = pairs[i].substr(seperatorPosition + 1);
        }
    }
 
    // toString() returns the key/value pairs concatenated
 
    collection.toString = function() {
        return "?" + querystring;
    };
 
    return collection;
})();

function initSubTabs() {
	if (window.location.querystring['artpage'] 
	|| window.location.querystring['ymgpage']
	|| window.location.querystring['stwpage']) {
		tabView.set('activeIndex', 3);
	}
}
