window.addEvent('domready', function() {
	setupNav();
	//wrapText();
	//alert('lh=' + );
});

var timer = null;

function wrapText() {
//	            1  2  3  4  5  6  7  8  9 10  11  12  13  14  15  16  17  18  19 20 21 22 23 24 25 26 27 28 29
	var pos = [25,35,46,54,64,70,78,86,90,96,100,103,106,109,109,108,107,105,101,96,88,82,74,66,54,38,25,20,12]
	
	for (i=30; i>0; i--) {
		var div = new Element('div', {
			'class': 'wrap',
			'id': 'w'+i,
			'style': 'width: ' + pos[i-1] + 'px',
			'title': 'w'+i
		});
		div.inject($('content'), 'top');
	}
}

function setupNav() {
	hideNavs();
	//$('nav_fires').setStyle('display','block');
	navs = $$('div#btns a');
	subs = $$('div.subnav');
	
	subs.each(function(item, index) {
		subs[index].addEvent('mouseover', function(){
			subs[index].setStyle('display','block');
			if (timer != null) {
				window.clearTimeout(timer);
				timer = null;
			}
		});
		subs[index].addEvent('mouseout', function(){
			timer = window.setTimeout('hideNavs()', 1000);
		});
	});
	
	navs.each(function(item, index) {
		var j = index;
		navs[index].addEvent('mouseover', function(){
		    hideNavs();
			subs[j].setStyle('display','block');
			if (timer != null) {
				window.clearTimeout(timer);
				timer = null;
			}
		});
		navs[index].addEvent('mouseout', function(){
			timer = window.setTimeout('hideNavs()', 1000);
		});
	});
}

function hideNavs() {
	navs = $$('div.subnav');
	navs.each(function(item, index) {
		navs[index].setStyle('display','none');
	});
}

function writecurve() {
	document.write('<div class="wrap" style="width: 14px"></div>');
	document.write('<div class="wrap" style="width: 24px"></div>');
	document.write('<div class="wrap" style="width: 42px"></div>');
	document.write('<div class="wrap" style="width: 46px"></div>');
	document.write('<div class="wrap" style="width: 54px"></div>');
	document.write('<div class="wrap" style="width: 64px"></div>');
	document.write('<div class="wrap" style="width: 70px"></div>');
	document.write('<div class="wrap" style="width: 78px"></div>');
	document.write('<div class="wrap" style="width: 86px"></div>');
	document.write('<div class="wrap" style="width: 90px"></div>');
	document.write('<div class="wrap" style="width: 96px"></div>');
	document.write('<div class="wrap" style="width: 100px"></div>');
	document.write('<div class="wrap" style="width: 103px"></div>');
	document.write('<div class="wrap" style="width: 106px"></div>');
	document.write('<div class="wrap" style="width: 109px"></div>');
	document.write('<div class="wrap" style="width: 109px"></div>');
	document.write('<div class="wrap" style="width: 108px"></div>');
	document.write('<div class="wrap" style="width: 107px"></div>');
	document.write('<div class="wrap" style="width: 105px"></div>');
	document.write('<div class="wrap" style="width: 101px"></div>');
	document.write('<div class="wrap" style="width: 96px"></div>');
	document.write('<div class="wrap" style="width: 88px"></div>');
	document.write('<div class="wrap" style="width: 82px"></div>');
	document.write('<div class="wrap" style="width: 74px"></div>');
	document.write('<div class="wrap" style="width: 66px"></div>');
	document.write('<div class="wrap" style="width: 54px"></div>');
	document.write('<div class="wrap" style="width: 38px"></div>');
	document.write('<div class="wrap" style="width: 25px"></div>');
	document.write('<div class="wrap" style="width: 20px"></div>');
	document.write('<div class="wrap" style="width: 12px"></div>');
}