jQuery(document).ready(function() {
	initFireBug();
	initNavLinks();
});

var initNavLinks = function()
{
	//jQuery('.top1 li').removeClass('active');
	/*
	jQuery('.top1 li a').each(function(item,index){
		if (window.parent.document.location.href.contains(item.getProperty('href')) && window.parent.document.location.href.length == item.getProperty('href').length) {
			item.getParent().addClass('active');
		}
		item.addEvent('click',function(e){
			window.parent.document.location.href = item.getProperty('href');

			var event = new Event(e);
			event.stop();
		});
	});
	jQuery('.middle li a').each(function(item,index){
		item.addEvent('click',function(e){
							
			jQuery('.middle li').removeClass('active');
			item.getParent().addClass('active');
			item.setProperty('target','code-page');
		});
	});
	*/
	
	jQuery('.top1 li a').each(function(index, item){
		var location = window.parent.document.location.href;
		if (contains(location, jQuery(item).attr('href')) && window.parent.document.location.href.length == jQuery(item).attr('href').length) {
			jQuery(item).parent().addClass('active');
		}
		jQuery(item).click(function(){
			window.parent.document.location.href = jQuery(item).attr('href');
			return false;
		});
	});
	
	jQuery('.middle li a').each(function(index, item){
		jQuery(item).click(function(){							
			jQuery('.middle li').removeClass('active');
			jQuery(item).parent().addClass('active');
			jQuery(item).attr('target','code-page');
		});
	});
}
var initFireBug = function()
{
	var width = getScrollWidth();
	jQuery('body#code-page').css('width',width + 'px');
}

function getScrollWidth()
{
	if (this.ie) return Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth);
	if (this.webkit) return document.body.scrollWidth;
	return document.documentElement.scrollWidth;
}

function contains(item, from){
	return item.indexOf(from) != -1;
}