$(document).ready(function(){

	
	
	if ($('#needs').html() != null){
	jQuery('#needs').accordion({ 
				active: ''
				});
	var accordions = jQuery('#needs');
	
	$(".toggle_container").hide();

	$("h2").toggle(function(){
	$(this).addClass("active"); 
	}, function () {
	$(this).removeClass("active");
	});
	
	$("h2").click(function(){
	$(this).next(".toggle_container").slideToggle("slow");
	});
}
});


function regBoxApriPreferenze(quale){
	$('.step3_column[id!='+quale+']').slideUp();
	$('#'+quale).slideToggle("normal");
}

function openslider(divId)
{
$('#register_slider_link').attr('href', "#");
$('#'+divId).slideDown("slow");
$('#'+divId).show();
}
function closeslider(divId)
{
$('#'+divId).slideUp();
$('#register_slider_link').attr('href', "javascript: openslider('reg_slider')");
//document.getElementById('reg_slider').style.visibility = 'hidden';
}

function switchSlider(hideDiv, showDiv) {

$('#'+hideDiv).hide();
$('#'+showDiv).show();
}


function aggiornaEta(value) {

	if (value > 21) {
	
		window.location.href = '/actions/setUserAge.php?utype=std';
		
	} else {
	
		window.location.href = '/actions/setUserAge.php?utype=teen';
	}
}

var container,containerStyle,windowWidth, windowHeight;

function UB_ObjCenter(myObj){

 	container= $('#' + myObj);
 	//alert(container.width());
 	containerStyle=(container.style)?container.style:container;
 	
 if(self.innerHeight){
 
 	 windowWidth=self.innerWidth;
 	 windowHeight=self.innerHeight;

 }else if(document.documentElement&&document.documentElement.clientHeight){
 
 	 windowWidth=document.documentElement.clientWidth;
 	 windowHeight=document.documentElement.clientHeight;

 	 
 }else if(document.body&&document.body.clientHeight){
 
 	 windowWidth=document.body.clientWidth;
 	 windowHeight=document.body.clientHeight;
 }
  	/* alert(windowWidth);
 	 alert(windowHeight);
 	 alert(container.offsetWidth);
 	 alert(container.offsetHeight);
 	 */
 	containerStyle.left=parseInt((windowWidth-container.offsetWidth)/2)+'px';
 	
 if(windowHeight>container.offsetHeight){
 
 	 containerStyle.top=parseInt((windowHeight-container.offsetHeight)/2)+'px';
 	 
 }else{
 
 	 containerStyle.top='0px';
 	 
 }	
}


function displayErrorBox(text){
/*
	$('#___errorMSGBOX').html('');
	box = $('body').append('<div id="___errorMSGBOX"></div>');
	$('#___errorMSGBOX').html(text + '<div onClick="javascript: hideErrorBox();" id="__ERRCLOSE">chiudi</div>');
	//UB_ObjCenter('___errorMSGBOX');
	$('#___errorMSGBOX').fadeIn();
*/
}

function hideErrorBox(){
	$('#___errorMSGBOX').fadeOut();
	$('#___errorMSGBOX').html('');
}

function UB_genPop(myUrl,myWinName,myWidth,myHeight,myPars){var winLeft=(screen.availWidth-myWidth)/2;var winTop=(screen.availHeight-myHeight)/2;var winParameters=myPars+'';if(winParameters==''){winParameters=',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';};newWin=window.open(myUrl,myWinName,'width='+ myWidth +',height='+ myHeight +',left='+ winLeft +',top='+ winTop + winParameters);newWin.focus();}

function setMyStatus(status) {

	getAjaxRequest('/actions/doSetStatus.php','status='+status,'div#status_container');

};