	function tog(wha) {
		var whi = $('#left .collapse:eq('+wha+')');
		
			whi.toggleClass('on');
			whi.children('.inside').children().not("script").slice(1).toggle();
		return false;
	}
	function sho(wha) {
		var whi = $('#left .collapse:eq('+wha+')');
		
			whi.toggleClass('on');
			whi.children('.inside').children().slice(1).show();
		return false;
	}
	
	function scrollPos() {
		var yScrolltop;
		var offset = $('#main').offset();
		if (self.pageYOffset) {
			yScrolltop = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScrolltop = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScrolltop = document.body.scrollTop;
		}
		var arrrr = new Array(offset.left + 5,yScrolltop + offset.top);
		return arrrr;
	}
	
	function closeDemo() {
		$('#overlayTB iframe').remove();
		$('#overlayTB,#fader').hide();
		return false;
	}
	
	function showForresterForm()
	{
		var target = $('#forrester_link').attr("href");
		
		var popupWidth = 760;
		var popupHeight = 740;		
      var popupLeft = (screen.width - popupWidth) / 2;
		var popupTop = (screen.height - (popupHeight + 110)) / 2;
		var popupName = "Forrester";
		
		var parameters = "location=" + target +
                         ",menubar=" + 0 +
                         ",height=" + popupHeight +
                         ",width=" + popupWidth +
                         ",toolbar=" + 0 +
                         ",scrollbars=" + 1 +
                         ",status=" + 0 +
                         ",resizable=" + 1 +
                         ",left=" + popupLeft +
                         ",screenX=" + popupLeft +
                         ",top=" + popupTop +
                         ",screenY=" + popupTop;

		var popup = window.open(target, name, parameters);
		
		return false;
	}
	
	
	$(function() {
		
		var collapsecheck = ($('#left .collapse').size() >= 1);
		
		$('#left .collapse').each(function(i) {
			
			$(this).addClass('on');
	
			var link = $(this).children('a.btn');
			if(collapsecheck) {
			if(link.attr('href')) { $(this).children('.inside').children('h2').children('a').attr('href',link.attr('href')).attr('target','_blank');
				link.attr('target','_blank');
			} else {
				$(this).children('a.btn').click(function() { return tog(i); });
				$('h2:eq('+i+')').click(function() { return tog(i); });
			}
			} else { 
				$(this).children('a.btn').click(function() { return false; });
			}
			var hash = '#' + $(this).prev().attr('name');
			if(hash != window.location.hash ) { tog(i); }
			else { window.location.hash = window.location.hash; }
		});
		var maxheight = $('#footer').height() + ($('#footer').offset()).top;
		$('#fader').height(maxheight);
		$('.pop').click(function() {
			var scrolld = scrollPos();
			$('#overlayTB').append('<iframe src="' + $(this).attr('href') + '" width="825" height="491" scrolling="no" frameborder="0"></iframe>').css('left',scrolld[0]).css('top',scrolld[1]).show();
			$('#fader').show();
			//alert('Demo Coming Soon');
			return false;
		});
		$('#overlayTB #closer,#fader').click(closeDemo);
		
		$('#forrester_link').click(showForresterForm);

	});