/*
* tabswitch.js -- Version 04-Feb-2006
*
* Copyright (c) 2006 Jochen Kupperschmidt <webmaster@nwsnet.de>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* The above license is the MIT License. It was copied from the website of the
* Open Source Initiative: http://www.opensource.org/licenses/mit-license.php
*   _                               _
*  | |_ ___ _____ ___ _ _ _ ___ ___| |_
*  |   | . |     | ._| | | | . |  _| . /
*  |_|_|___|_|_|_|___|_____|___|_| |_|_\
*    http://homework.nwsnet.de/
*
* History:
*   23-Jan-2006: First release.
*   04-Feb-2006: Rewrote it to be object-oriented, try..catch used.
*
* This piece of JavaScript allows to switch (i.e. show one, hide the others)
* from a group of XHTML elements. That kind of behaviour is widely used in
* graphical applications and was adopted for use in websites.
*
* Include it in a website's <head> section like this (adjust the path):
*     <script type="text/javascript" src="/js/tabswitch.js"></script>
*/

// A tab group class.
function TabGroup(prefix, suffixes)
{
	this.prefix = prefix;
	this.suffixes = suffixes;

	// Show the specified tab.
	this.show = function (suffix, hideOthers, id, size)
	{	
		
		if (! hideOthers) {
			this.hideAll();
		
			reset2('color'+id, id, size);
//			var ajaxIndex = ajaxObjects.length;
//			ajaxObjects[ajaxIndex] = new sack();
//			ajaxObjects[ajaxIndex].setVar('color', false);
//			ajaxObjects[ajaxIndex].setVar('size', id);
//
//			ajaxObjects[ajaxIndex].createURLString();
//			totalurlstring = 'webroot/addProduct.php' + ajaxObjects[ajaxIndex].queryStringSeparator + ajaxObjects[ajaxIndex].URLString+'';
//			//alert(totalurlstring);
//		
//			ajaxObjects[ajaxIndex].requestFile = totalurlstring;	// Saving product in this file
//			//	ajaxObjects[ajaxIndex].onCompletion = whenCompleted(ajaxObjects[ajaxIndex]);;	// Specify function that will be executed after file has been found
//			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
		}
		try {
			document.getElementById(this.prefix + suffix).style.display = '';
		} catch (e) {}
	}

	// Hide the specified tab.
	this.hide = function (suffix)
	{
		try {
			document.getElementById(this.prefix + suffix).style.display = 'none';
		} catch (e) {}
	}

	// Hide all tabs of this group.
	this.hideAll = function ()
	{
		for (var i in this.suffixes){

			this.hide(this.suffixes[i]);

		}
	}
}
function whenCompleted(ajax){
	var e = document.getElementById('sackdata');
	if (ajax.responseStatus){
		var string = "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
	} else {
		var string = "<p>URLString Sent: " + ajax.URLString + "</p>";
	}
	e.innerHTML = string;
}

