var thisDir = './';
var inDir = 'home';
var graphicsDir = './graphics/';
var testimonialDir = './testimonials/';

function myDir() {
//	alert('myDir');
	try {
		if (this.document.URL.match('products/'))	{
			inDir = 'products';
		} else if (this.document.URL.match('press/')) {
			inDir = 'press';
		} else if (this.document.URL.match('newsandpress.html')){
			inDir = 'press_index';
		} else if (this.document.URL.match('testimonials/')) {
			inDir = 'testimonials';
		} else if (this.document.URL.match('products/')) {
			inDir = 'products';
		} else if (this.document.URL.match('updates.html')) {
			inDir = 'updates';
		} else if (this.document.URL.match('resellers.html')) {
			inDir = 'partners';
		} else if (this.document.URL.match('shopping.html')) {
			inDir = 'shopping';
		} else {
			inDir = 'home';
		}
	} catch (errMsg) {
		alert('myDir\n'+errMsg);
	}
}

function setupVars() {
	try {
		myDir();
		switch(inDir) {
			case 'shopping':
			case 'partners':
			case 'updates':
			case 'home':
				graphicsDir = './graphics/';
				testimonialDir = './testimonials/';
				thisDir = './';
				break;
			case 'press':
				graphicsDir = '../graphics/';
				testimonialDir = '../testimonials/';
				thisDir = '../';
				break;
			case 'press_index':
				graphicsDir = './graphics/';
				testimonialDir = './testimonials/';
				thisDir = './';
				break;
			case 'testimonials':
				graphicsDir = '../graphics/';
				testimonialDir = './testimonials/';
				thisDir = '../';
				break;
			case 'products':
				graphicsDir = '../../graphics/';
				testimonialDir = '../../testimonials/';
				thisDir = '../../';
				break;
			default:
				alert('No Dir Found inDir:'+inDir+'in Switch Statement');
				graphicsDir = './graphics/';
				testimonialDir = './testimonials/';
				thisDir = './';
				break;
		}
	} catch (errMsg) {
		alert('setupVars\n'+errMsg);
	}
}

function setupPanels() {
	try {
		setupVars();
		var cPanelHome = '<div align="left" class="CollapsiblePanel" id="CollapsiblePanelHome"><div class="CollapsiblePanelTab">Home</div><div class="CollapsiblePanelContent"><a href="'+thisDir+'">RTS</a><br><a href="http://www.lettermark.com">LetterMark</a></div></div>';
		var cPanelNews = '<div align="left" class="CollapsiblePanel" id="CollapsiblePanelNews"><div class="CollapsiblePanelTab"><a href="'+thisDir+'newsandpress.html">News and Press</a></div></div>';
		var cPanelTest = '<div align="left" class="CollapsiblePanel" id="CollapsiblePanelTest"><div class="CollapsiblePanelTab">Testimonials</div><div class="CollapsiblePanelContent"><a href="'+thisDir+testimonialDir+'lettermark.html">Lettermark</a><br><a href="'+thisDir+testimonialDir+'securityproducts.html">Security Products</a></div></div>';
		var cPanelUpdates = '<div align="left" class="CollapsiblePanel" id="CollapsiblePanelUpdates"><div class="CollapsiblePanelTab"><a href="'+thisDir+'updates.html">Updates</a></div></div>';
		var cPanelPartners = '<div align="left" class="CollapsiblePanel" id="CollapsiblePanelPartners"><div class="CollapsiblePanelTab"><a href="'+thisDir+'resellers.html">Partners</a></div></div>';
		var cPanelShopping = '<div align="left" class="CollapsiblePanel" id="CollapsiblePanelShopping"><div class="CollapsiblePanelTab"><a href="'+thisDir+'shopping.html"><img alt="Shopping Banner" src="'+graphicsDir+'shopping.gif" width="166" height="118"></a></div></div>';
		var sideMenu = cPanelHome + cPanelNews + cPanelTest + cPanelUpdates + cPanelPartners + cPanelShopping;
		var topMenu = '<a href="'+thisDir+'aboutrts.html">About Us</a><a href="'+thisDir+'products.html">Products</a><a href="'+thisDir+'downloads.html">Downloads</a><a href="'+thisDir+'support.html">Support</a><a href="'+thisDir+'shopping.html">Shopping</a><a href="'+thisDir+'contactus.html">Contact</a>';
		var disclaimer = '<a href="'+thisDir+'disclaimer.html">2008 Research Triangle Software All rights reserved.</a>';
	} catch (errMsg) {
		alert('setupPanels\ncPanel\n'+errMsg);
	}
	try {
		var mySideMenu = document.getElementById('SideMenu');
		mySideMenu.innerHTML = sideMenu;
//		alert(mySideMenu.innerHTML);
		var myTopMenu = document.getElementById('TopMenu');
		myTopMenu.innerHTML = topMenu;
//		alert(myTopMenu.innerHTML);
		var myDisclaimer = document.getElementById('Disclaimer');
		if(myDisclaimer) {
			myDisclaimer.innerHTML = disclaimer;
		}
		var CollapsiblePanelHome = new Spry.Widget.CollapsiblePanel("CollapsiblePanelHome",{contentIsOpen:false, fps:80});
		var CollapsiblePanelNews = new Spry.Widget.CollapsiblePanel("CollapsiblePanelNews",{contentIsOpen:false, fps:80});
		var CollapsiblePanelTest = new Spry.Widget.CollapsiblePanel("CollapsiblePanelTest",{contentIsOpen:false, fps:80});
		var CollapsiblePanelUpdates = new Spry.Widget.CollapsiblePanel("CollapsiblePanelUpdates",{contentIsOpen:false, fps:80});
		var CollapsiblePanelPartners = new Spry.Widget.CollapsiblePanel("CollapsiblePanelPartners",{contentIsOpen:false, fps:80});
		var CollapsiblePanelShopping = new Spry.Widget.CollapsiblePanel("CollapsiblePanelShopping",{contentIsOpen:false, fps:80});
	} catch (errMsg) {
		alert('setupPanels\nCollapsiblePanel\n'+errMsg);
	}
	try {
		if(CollapsiblePanelHome.isOpen())
			CollapsiblePanelHome.close();
		if(CollapsiblePanelTest.isOpen())
			CollapsiblePanelTest.close();
	} catch (errMsg) {
		alert("opening and closing\n"+errMsg);
	}
	try
	{
		switch(inDir) {
			case 'home':
				CollapsiblePanelHome.open();
				break;
			case 'press':
			case 'press_index':
				//CollapsiblePanelNews.open();
				break;
			case 'testimonials':
				CollapsiblePanelTest.open();
				break;
			case 'updates':
				//CollapsiblePanelUpdates.open();
				break;
			case 'partners':
				//CollapsiblePanelPartners.open();
				break;
			case 'shopping':
				//CollapsiblePanelShopping.open();
				break;
			case 'products':
				//CollapsiblePanelShopping.open();
				break;
			default:
				alert('No Dir Found in Switch Statement');
				break;
		}
	} catch (errMsg) {
		alert('setupPanels\nswitch\ninDir:'+inDir+'\n'+errMsg);
	}
}
