// JavaScript Document

/* INSTRUCTIONS


1. Create an instance of the viewChanger object, and send the arguments ('classSelected', 'classNormal')
     The 1th and 2th arguments are optional
	var a = new viewChanger('s2', 'n2');
2. Push the base ID(s) value(s) to the object base IDs array, this id will 
   be used to with -button and -box to identify the right boxes and buttons
   You can push all the IDs at once or one by one.
	a.pushIDs('a', 'b');
3. Select the box that you want to show first
	a.viewControler('b');
4. HTML Button example:
	<a href="javascript:;" id="Ba-button" onclick="javascript:b.viewControler('Ba');">
5. Box example:
	<div id="Ba-box" style="border:1px solid #996600; padding:20px; display:none;">Box Content</div>
6. Second group of boxes and buttons:
	var b = new viewChanger();
	b.pushIDs('Ba', 'Bb');
	b.viewControler('Bb');	
*/

//Constructor:
// TODO: Deprecate
function viewChanger(classSelected, classNormal) {
	this.classSelected = 'statusSelected';
	this.classNormal = 'statusNormal';
	this.AllIDs=new Array();
	this.pushIDs = pushBaseIDs;
	this.viewControler = changer;
	if (classSelected && classSelected != '') {
		//alert('true');
		this.classSelected = classSelected;
	}
	if (classNormal && classNormal != '') {
		this.classNormal = classNormal;
	}
	//alert(this.classSelected);
}

//Methods:
// TODO: Deprecate
function pushBaseIDs() {
	for (i=0; i<arguments.length; i++) {
		//alert(i);
		this.AllIDs.push(arguments[i]);
	}
}

var selected_ID = '';

// TODO: Deprecate
function changer(ID) {
	var buttonText = '-button';
	if (!document.getElementById(this.AllIDs[0]+'-button')) {
		buttonText = '';
	}
	
	for (i=0; i<this.AllIDs.length; i++)
	{
		
		buttonA = this.AllIDs[i]+buttonText;
		boxA = this.AllIDs[i]+'-box';
		document.getElementById(buttonA).className=this.classNormal;
		document.getElementById(boxA).style.display='none';

	}
	if (selected_ID != ID) {
		box = ID+'-box';
		button = ID+buttonText;
		//alert('show: '+box);
		document.getElementById(button).className=this.classSelected;
		document.getElementById(box).style.display='';
	}
	if (selected_ID == ID) {
		selected_ID ='';
	} else {
	selected_ID = ID;
	}
}

// TODO: Deprecate
function showHideBox(ID, action) {
	
	buttonA = ID+'-button-'+action;
	//alert(buttonA);
	boxA = ID+'-box';
	document.getElementById(buttonA).style.display='none';
	document.getElementById(boxA).style.display='none';

	box = ID+'-box';
	
	if (action == 'show') {
		button = ID+'-button-hide';
		document.getElementById(box).style.display='';
	} else if (action == 'hide') {
		button = ID+'-button-show';
	}
	
	
	
	document.getElementById(button).style.display='';
	
}

