var first_open=true;
function paginaIntera(){
	window.open('','popup',"fullscreen,scrollbars");
    document.getElementById('invio_login').submit()
}
$(document).ready(function(){
	 //$('#top_content_page').fadeOut(0);
});
var box_consigliati_aperto=false;
function box_consigliati()
{
	if(box_consigliati_aperto)
	{
		box_consigliati_aperto=false;
		$('#a_box_consigliati').html('[segue]');
		$('#box_consigliati').animate({height: '53px' }, 1000, function() {});
	}
	else
	{
		box_consigliati_aperto=true;
		$('#a_box_consigliati').html('[chiudi]');
		$('#box_consigliati').animate({height: "600px"}, 1000, function() {$('#box_consigliati').css('height','auto'); });
	}
}
var cronache_delle_contee_aperta=false;
function cronache_delle_contee()
{
	if(cronache_delle_contee_aperta)
	{
		cronache_delle_contee_aperta=false;
		$('#a_cronache_delle_contee').html('[segue]');
		$('#cronache_delle_contee').animate({height: '53px'}, 1000, function() {});
	}
	else
	{
		cronache_delle_contee_aperta=true;
		$('#a_cronache_delle_contee').html('[chiudi]');
		$('#cronache_delle_contee').animate({height: "600px"}, 1000, function() {$('#cronache_delle_contee').css('height','auto');});
	}
}
var meggaggio_bacheca_avventure_aperta=false;
function meggaggio_bacheca_avventure()
{
	if(meggaggio_bacheca_avventure_aperta)
	{
		meggaggio_bacheca_avventure_aperta=false;
		$('#a_meggaggio_bacheca_avventure').html('[segue]');
		$('#meggaggio_bacheca_avventure').animate({height: '53px'}, 1000, function() {});
	}
	else
	{
		meggaggio_bacheca_avventure_aperta=true;
		$('#a_meggaggio_bacheca_avventure').html('[chiudi]');
		$('#meggaggio_bacheca_avventure').animate({height: "600px"}, 1000, function() { $('#meggaggio_bacheca_avventure').css('height','auto');});
	}
}
var flag=true;
function ApriFinestra(PageURL,hei,big)
{
	if(hei=='')
		var hei='500';
	if(flag)
	{
		flag=false;
		$('#top_content_page').fadeOut(300, function(){
 		$('#top_content_page').css('height','0px');
		$('#contenuti_della_pagina').html("<h1>caricamento</h1>");
		$('#contenuti_della_pagina').css('height','0px');
		//window.open(PageURL,PageName,'width='+WindowWidth+',height='+WindowHeight+',resizable=no,toolbar=no,statusbar=no,scrollbars=yes'); 
		$('#top_content_page').fadeIn('slow');
	    $('#top_content_page').css('position','relative');
		$('#top_content_page').css('height','auto');
  	 	$('#top_content_page').css('top','0px');
		$('#contenuti_della_pagina').animate({ height: "100px" }, 600, function() {
			$.ajax({
   			type: "POST",
   			url: PageURL,
			success: function(msg){
  			$('#menu_razze').html("");
 			$('#menu_razze').animate({ height: "0px" }, 500);
			$('#contenuti_della_pagina').animate({ height: "500px"}, 1000, function() {$('#contenuti_della_pagina').html(msg); flag=true;scroll_bar_initialize();});
			}});
			});
		});
	}
	return false;
}
function scroll_bar_initialize(menurazze)
{
	var pane4Settings = {
		scrollbarWidth: 20,
		scrollbarMargin: 10,
		topCapHeight: 10,
		bottomCapHeight: 10
	};
	$('#contenuti_della_pagina').jScrollPane({scrollbarWidth:20, scrollbarMargin:10, animateTo:true})
	$('.jScrollPaneDrag').css('height', '20px');
	$('.jScrollPaneDrag').css('background', ' url(../images/drag.png) no-repeat');
	$('.jScrollPaneTrack').css('background', ' #0a0a0a url(../images/drag_back.png) ');
}

function menurazze(PageURL,big)
{
	if(flag){flag=false;
	$('#top_content_page').fadeOut(300, function(){
 		$('#top_content_page').css('height','0px');
		$('#contenuti_della_pagina').html("<h1>caricamento</h1>");
		$('#contenuti_della_pagina').css('height','0px');
		//window.open(PageURL,PageName,'width='+WindowWidth+',height='+WindowHeight+',resizable=no,toolbar=no,statusbar=no,scrollbars=yes'); 
		$('#top_content_page').fadeIn('slow');
		$('#top_content_page').css('position','relative');
		$('#top_content_page').css('height','auto');
  	 	$('#top_content_page').css('top','0px');
		$('#contenuti_della_pagina').animate({ height: "100px" }, 600, function() {
		$.ajax({
  		type: "POST",
   		url: PageURL,
		success: function(msg){
			$('#contenuti_della_pagina').animate({height: "400px"}, 1000, function() {
				 $('#contenuti_della_pagina').html(msg);
   				 flag=true;
				 var style="flat:left;cursor:pointer;margin:0px;padding:0px;margin-left:0px;margin-top:4px;font-size:15pt;";
				 var html_menu_razze=
			    '<img style="flat:left;cursor:pointer;margin:0px;padding:0px;margin-left:0px;margin-top:4px;"  onclick="animate_Scroll(\'umani\')" src="../images/bottonirazze/umani.jpg">'+
			    '<img style="'+style+'"  onclick="animate_Scroll(\'elfi_alti\')" src="../images/bottonirazze/elfi_alti.jpg">'+
			    '<img style="'+style+'" onclick="animate_Scroll(\'elfi_DROW\');" src="../images/bottonirazze/elfi_drow.jpg">'+
				'<img style="'+style+'"   onclick="animate_Scroll(\'elfi_silvani\');" src="../images/bottonirazze/elfi_silvani.jpg" >'+
				'<img  style="'+style+'"  onclick="animate_Scroll(\'fate\');" src="../images/bottonirazze/fate.jpg">'+
				'<img style="'+style+'" onclick="animate_Scroll(\'folletti\');" src="../images/bottonirazze/folletti.jpg">'+
				'<img style="'+style+'" onclick="animate_Scroll(\'GNOMi\');" src="../images/bottonirazze/gnomi.jpg"</div>'+
				'<img style="'+style+'"  onclick="animate_Scroll(\'GOBLIN\');" src="../images/bottonirazze/goblin.jpg">'+
				'<img style="'+style+'"  onclick="animate_Scroll(\'MEZZELFI\');" src="../images/bottonirazze/mezzelfi.jpg">'+
				'<img  style="'+style+'" onclick="animate_Scroll(\'nani\');"  src="../images/bottonirazze/nani.jpg">'+
				'<img  style="'+style+'"  onclick="animate_Scroll(\'troll\');" src="../images/bottonirazze/troll.jpg">'+
				'<img  style="'+style+'"   onclick="animate_Scroll(\'HOBBIT\');" src="../images/bottonirazze/hobbit.jpg">'+
				'<img   style="'+style+'"  onclick="animate_Scroll(\'MANNARI\')" src="../images/bottonirazze/mannari.jpg">'+
				'<img style="'+style+'"  onclick="animate_Scroll(\'VAMPIRI\');" src="../images/bottonirazze/vampiri.jpg" >'+
				'<img style="'+style+'"  onclick="animate_Scroll(\'ANGELI\');" src="../images/bottonirazze/angeli.jpg" >'+
				'<img style="'+style+'"  onclick="animate_Scroll(\'DAUKRA\');" src="../images/bottonirazze/daukra.jpg" >'+
				'<img style="'+style+'"  onclick="animate_Scroll(\'DRAGHI\');" src="../images/bottonirazze/draghi.jpg" >'+
				'<br>';
				$('#menu_razze').animate({ height: "460px" }, 1000);
				$('#menu_razze').html(html_menu_razze);
				scroll_bar_initialize();
			});
		}});
	});
	});
	}
	return false;
}

function animate_Scroll(target)
{
	var $pane3 = $('#contenuti_della_pagina');
    var pane3top = parseInt($pane3.offset().top);
	var ofset=parseInt($('#'+target).offset().top - pane3top);
	jScrollPaneDrag_position=parseInt((400/75706)*ofset);
	$('#contenuti_della_pagina')[0].scrollTo(ofset,false);
	//alert(ofset);
	//alert($pane3.height());
	//ofset=0-ofset;
	//scrollTo
	//  $('#contenuti_della_pagina').animate({top: ofset}, 1500);
	/*$('.jScrollPaneDrag').animate({top: jScrollPaneDrag_position},1500);*/
}
