function	add_nfo()
{
	if (type != prevtype) {
		$(".nfo_disp").slideUp(300);
		$("#type_"+type).slideDown(300);
		prevtype = type;
	}
}

var vni = false;

function	viewnode()
{
	if (vni == false) {
		vni = true;
		var tab = new Array('001', '002');
		var maximum = tab.length - 1;
		var rand = Math.floor(Math.random() * (maximum + 1));
		$.ajax({url:'templates/nodes/'+tab[rand]+'.txt',
						success: function(data) {
							$('#walltxt').fadeTo(500, 0.3).html(data).fadeTo(500, 1.0, function() {vni = true});
						}
			   }
			);
	}
}

function	pageload(hash) {
	if(hash) {
		var elems = hash.split('/');
		var i = 0;
		var maximum = elems.length;
		while (maximum > 0) {
			if (document.getElementById('t'+elems[maximum])) {
				$('ul[class*=menu]>li').each(function() {
					$(this).children('a').removeClass('current');
				});
				$('#t'+elems[maximum]).addClass('current');
				break ;
			}
			maximum -= 1;
		}
		$("#xhrLoader").load("./loader.php?hash="+hash, function() {
			viewnode();
		});
	}
}
function	titleview(title)
{
	if (title) {
		$("#titleview").html('&laquo; '+title+' &raquo;');
	}
}

$(document).ready(function() {
	$("a").live('mouseover', function() {
		titleview($(this).attr('title'));
	});
	$("a").live('click', function() {
		titleview($(this).attr('title'));
	});
	$("a.button").live('click', function() {
		var state = $(this).attr('rel');
		var mode = $(this).attr('rev');
		var id = $(this).attr('id');
		var letter = id.substring(0, 1);
		var opt = id.substring(2);
		var obj = $(this);
		if (state == '0') {
			if (mode == 'uniq') {
				$(".button[id*='"+letter+"']").each(function() {
					$(this).removeClass('actived_button').addClass('inactived_button');
				});
				opts[get_number(letter) - 1] = opt;
			}
			obj.removeClass('inactived_button').addClass('actived_button');
			obj.parent('a').attr('rel', '1');
		}
		else {
			obj.removeClass('actived_button').addClass('inactived_button');
			obj.parent('a').attr('rel', '0');
		}
		var final = calc_price();
		if (final != '?')
			$('#price').fadeOut(200).fadeIn(400).html(final+'&euro;');
	});
	
	$.history.init(pageload);
	$("a[rel='internal']").live('click', function(){
		var hash = this.href;
		var rev = $(this).attr('rev');
		$('ul[class*=menu]>li').each(function() {
			$(this).children('a').removeClass('current');
		});
		$('#t'+rev).addClass('current');
		hash = hash.replace(/^.*#/, '');
		$.history.load(hash);
		return false;
	});
	viewnode();
	$("a[id='devis_contact']").live('click', function() {
		$(this).attr('href', $(this).attr('href')+'?device='+my);
	});
});
