var _root="/";
var _lib="/lib/php/";
$(document).ready(function(){
	
	var pp=String(location);
	if(pp.indexOf('/dev/niconf2010/')>=0 || pp.indexOf('/test.inol3.com/niconf2010/')>=0){
		_root="/niconf2010/";
		_lib="/niconf2010/lib/php/";
	}
	if($('.log_out').length==1){
		$('.log_out').click(function(){
			$.post('lib/php/logout.php',null,function(){
				location.href=_root+'index.php';
			});
		});
	}
	$('.tastiMenu a').each(function(index){
		if($(this).text().toLowerCase()=="profilo"||$(this).text().toLowerCase()=="registrazione"){
			$(this).parent().removeClass("tastiMenu").addClass("tastiMenu_last");
		}
	});
});

function validateEmail(pEmail)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return reg.test(pEmail);
}

function isZero(pn){
	if(pn<10&&pn!=0)
		return 0+""+pn;
	else
		return pn;
}

function getitembag(){

	$(this).oneTime(1500,'ckbag',function(){
		$.post(_lib+'bag.php',{ac:0},function(data){
			if($('#art_cart').length==1){
				$('#art_cart').html(isZero(data));
				return;
			}
			var ht="<div style='width:232px; height:41px; margin-left:719px; display:none; position:absolute; background:url("+_root+"images/bg_carrello.png) no-repeat' id='tgt_bag'>";
			ht+="<div style='margin:8px; float:left; margin-left:60px;' class='txtBluArial'><strong><a href='"+_root+"carrello.php'>visualizza il carrello</a></strong></div>";
			ht+="<div style='margin:8px; float:left; font-weight:bold; width:15px' class='txtRossoArial' id='art_cart' align='center'>"+isZero(data)+"</div></div>";
			$('#mainBox').prepend(ht);
			$('#tgt_bag').fadeIn();
		});
	});
}

(function($){
	$.leOverWin=function(sett) {
		
		$.leOverWin.defSettings={
			offBgColor:[255,255,255],
			offBgAlpha:0.9,
			html:"ciao",
			ajax:"",
			offClass:"",
			modClass:"",
			fadeIn:400,
			fadeOut:400,
			width:400,
			height:400
		};
		var settings = $.extend({}, $.leOverWin.defSettings,sett||{});

		var w2=parseInt(settings.width/2);
		var h2=parseInt(settings.height/2);
		var leOverWinOpen=function(phtm){
			var f="<div class='leOverWin_off "+settings.offClass+"' style='background-color: rgba("+settings.offBgColor[0]+","+settings.offBgColor[1]+","+settings.offBgColor[2]+","+settings.offBgAlpha+"); background:rgba("+settings.offBgColor[0]+","+settings.offBgColor[1]+","+settings.offBgColor[2]+","+settings.offBgAlpha+"); color: rgba("+settings.offBgColor[0]+","+settings.offBgColor[1]+","+settings.offBgColor[2]+","+settings.offBgAlpha+");' id='leOver'>\n";
			f+="<div id='leOverClose' style='position:absolute; top:0; right:0; margin:10px; font-family:Arial, Helvetica, sans-serif; color:#000; font-size:12px; cursor:pointer;' align='right'>\nCHIUDI<br>\n<span style='font-size:10px'>or <strong>esc</strong></span>\n</div>";
			f+="<div class='leOverWin_mod "+settings.modClass+"' style='margin-top:-"+h2+"px; margin-left:-"+w2+"px; width:"+settings.width+"px; height:"+settings.height+"px;'>"+phtm+"</div>\n</div>";
			$('body').prepend(f);
			$('#leOver').fadeIn(settings.fadeIn,function(){
				$(document).bind("keyup",function(e){if(e.keyCode==27){leOverWinClose();}});
			});
			$('#leOverClose').click(function(){leOverWinClose();});
		}
		var leOverWinClose=function(){
			if($('#leOver').length==1){
				$(document).unbind("keyup");
				$('#leOver').fadeOut(settings.fadeOut);
			}
		}
		
		if(settings.ajax!=""){
			$.get(settings.ajax,function(d){
				leOverWinOpen(d);
			})
		}else{
			leOverWinOpen(settings.html);
		}

	};
})(jQuery);



/*

#tgt_zm_img{
	position:fixed;
	width:100%;
	height:100%;
	z-index:500;
	display:none;
	background-color: rgba(0, 0, 0, 0.9);
	background: rgba(0, 0, 0, 0.9);
	color: rgba(0, 0, 0, 0.9);
}
#tgt_zm_img_close{
	position:absolute;
	top:0;
	right:0;
	margin:10px;
	font-family:Arial, Helvetica, sans-serif;
	color:#FFF;
	font-size:12px;
	cursor:pointer;
}
<div id='tgt_zm_img'>
	<div style='position:absolute; top:0; right:0; margin:10px; font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; cursor:pointer;' align='right'>CHIUDI<br><span style='font-size:10px'>or <strong>esc</strong></span></div>
    <div style='position:absolute; top:50%; margin-top:-172px; width:100%; height:344px;'>TXT</div>
</div>

*/






