var toGo = '';

function setPar(url) {
	toGo = url;
}

function goTo(e) {
	if (!e)
		e = window.event;

	if (e.target.tagName != 'a' && toGo)
		location.href = toGo;
}

function showSubMenu(rel) {
	rel = rel.replace(/cat/, 'sub');

	$('#globsubnav > ul').addClass('subhide');

	$('#' + rel).removeClass('subhide');
}

$(document)
		.ready(
				function() {

					$('#globalnav > li').bind('mouseenter', function() {
						showSubMenu($(this).attr('id'))
					});

					if (typeof (keywords_y) == "undefined") {
						keywords_y = cate;
					}

					if (typeof (carousel) != "undefined") {
						carousel_interval = setInterval('showNextImage()', 5000);

					}
					if (typeof (uref) == "undefined") {
						uref= '';
					}

					$
							.getJSON(
									"/ajax/get2.php",
									{
										keyword : keywords_y,
										time : time,
										nonce : nonce,
										service : 'y',
										count : ycount,
										id_tr_y : id_tr_y,
										uref : uref
									},
									function(data) {
										
										if (data[0] == "NULL") {
											if (typeof(vai)=="undefined")
												vai=0;
											
											
											if (location.href.toString()
													.indexOf("search") != -1) {
												$('#y-fall-iframe').css(
														"height", "336px");
												$('#y-fall-iframe').css(
														"width", "662px");
												$('#y-fall-iframe-more').css(
														"height", "336px");
												$('#y-fall-iframe-more').css(
														"width", "662px");
												$('#y-fallback-more').css(
														"background-image",
														"none");
												$(
														$('#hot-products > h2')
																.get(0)).css(
														"display", "none");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"background-image",
														"none");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"padding", "0px !important");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"border", "none !important");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"margin",
														"15px 0px 0px;");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"margin-top", "15px");
												if ($($('#hot-products > #more-y-res'))) {
													$(
															$(
																	$('#hot-products > #more-y-res'))
																	.parent()
																	.children()
																	.get(0))
															.css("display",
																	"none");
													$(
															$('#hot-products > #more-y-res'))
															.css(
																	"background-image",
																	"none");
													$('#y-fallback-more').css(
															"padding", "0px !important");
													$('#y-fallback-more').css(
															"border", "none !important");
													$('#y-fallback-more').css(
															"margin",
															"0px 0px 0px 0px");
													$(
															$(
																	'#hot-products > #more-y-res')
																	.get(0))
															.css("padding",
																	"0px !important");
													$(
															$(
																	'#hot-products > #more-y-res')
																	.get(0))
															.css("border",
																	"none !important");
													$(
															$(
																	'#hot-products > #more-y-res')
																	.get(0))
															.css("margin",
																	"0px 0px 0px 0px");
												}

											} else if (location.href.toString()
													.indexOf("post") != -1) {
												$('#y-fall-iframe').css(
														"height", "120px");
												$('#y-fall-iframe').css(
														"width", "662px");
												$('#y-fallback-more').css(
														"background-image",
														"none");
												$(
														$('#hot-products > h2')
																.get(0)).css(
														"display", "none");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"background-image",
														"none");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"padding", "0px");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"margin",
														"15px 0px 0px;");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"margin-top", "15px");
												$(
														$(
																'#hot-products > #y-fallback')
																.get(0)).css(
														"min-height", "0px");
												vai = '50px';
											}
											$('#y-fall-iframe')
													.attr(
															'src',
															'/ajax/adsense.php?k='
																	+ escape(keywords_y)
																	+ '&v='
																	+ vai);
											$('#y-fallback').show();
											$('#results-y').hide();
											$('#y-fall-iframe-more')
													.attr(
															'src',
															'/ajax/adsense.php?k='
																	+ escape(keywords_y));
											$('#y-fallback-more').show();
											$('#results-y').hide()

										} else {

											/*if (data[0].bidd == 1)
												$('#yahoo_ann').html(" ");*/

											cache_y = ''

											minus = 0;
											
											 if (typeof (text_link) != "undefined") {
												 
                                                 if (text_link["link"]

                                                                 && text_link["text"]

                                                                 && text_link["title"]

                                                                 && text_link["merch"]

                                                                 && (data[0].bidd == 1)) {
                                                	
                                                	 if (id_tr_y == '363'){
                                                		 if (text_link["img"])

                                                             cache_y += '<div class="result bord img">'

                                                                             + '<a rel="nofollow" href="'

                                                                             + text_link["link"]

                                                                             + '" title="'

                                                                             + text_link["title"]

                                                                             + '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''

                                                                             + text_link["link"]

                                                                             + '&go=1\';"><img src="'

                                                                             + text_link["img"]

                                                		 					+ '" alt="" align="left" style="margin-right:5px;width:70px !important;height:55px !important;border:1px solid #CCC;cursor:pointer;"></a>';

                                                     else

                                                             cache_y += '<div class="result img">';

                                                     cache_y += '<strong><a rel="nofollow" href="'

                                                                     + text_link["link"]

                                                                     + '" title="'

                                                                     + text_link["title"]

                                                                     + '" target="_blank">'

                                                                     + text_link["title"]

                                                                     + '</a></strong>'
                                                                     
                                                                     + '<a style="display: inline-block; float: left;" rel="nofollow" href="'

                                                                     + text_link["link"]

                                                                     + '" target="_blank">'

                                                                     + text_link["merch"]

                                                                     + '</a>'

                                                                     + '<p style="display: inline-block; float: left; padding-left: 5px;">'

                                                                     + text_link["text"]

                                                                     + '</p>'

                                                                     + '<div style="clear:both"></div></div>';

                                                     minus = 1;

                                                	 }
                                                	 else{

                                                         if (text_link["img"])

                                                                 cache_y += '<div class="result bord img">'

                                                                                 + '<a rel="nofollow" href="'

                                                                                 + text_link["link"]

                                                                                 + '" title="'

                                                                                 + text_link["title"]

                                                                                 + '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''

                                                                                 + text_link["link"]

                                                                                 + '&go=1\';"><img src="'

                                                                                 + text_link["img"]
                                                         
                                                         						+ '" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;"></a>';

                                                                                
                                                         else

                                                                 cache_y += '<div class="result img">';

                                                         cache_y += '<strong><a rel="nofollow" href="'

                                                                         + text_link["link"]

                                                                         + '" title="'

                                                                         + text_link["title"]

                                                                         + '" target="_blank">'

                                                                         + text_link["title"]

                                                                         + '</a></strong>'

                                                                         + '<a rel="nofollow" href="'

                                                                         + text_link["link"]

                                                                         + '" target="_blank"><p>'

                                                                         + text_link["text"]

                                                                         + '</p></a>'

                                                                         + '<a rel="nofollow" href="'

                                                                         + text_link["link"]

                                                                         + '" target="_blank">'

                                                                         + text_link["merch"]

                                                                         + '</a>'

                                                                         + '<div style="clear:both"></div></div>';

                                                         minus = 1;

                                                 }
                                                 }

                                         }
											for (i = 0; i < (data.length - minus); i++) {
												if (i != (data.length - 1))
													classs = ' bord';
												else
													classs = '';

												if (typeof (isnew) != 'undefined') {
													// appx = '<img
													// class="stelle"
													// src="/img/stelle/voto_small_'+rand(2,5)+'.gif"
													// />';
													appx = '';
													sufx = '<div style="clear:both;"></div>';
												} else {
													appx = '';
													sufx = '';
												}

												if (typeof (ypreview) != 'undefined') {
													if (i < ypreview) {
														if (data[i].bidd != 1) {
															if (typeof (data[i].img) != "undefined")
																imgurll = data[i].img
															else
																imgurll = '/ajax/thumb.php?url=http://'
																		+ data[i].merch;
															imgy = '<img src="'
																	+ imgurll
																	+ '" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;">';
														} else {
															
															if (typeof (data[i].img) != "undefined") {
																imgurll = data[i].img
																imgy = '<a rel="nofollow" href="'
																		+ data[i].url
																		+ '" title="'
																		+ data[i].title
																		+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																		+ data[i].url
																		+ '&go=1\';"><img src="'
																		+ imgurll
																		+ '" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;"></a>';
															} else {
																if (sitelang == "it_IT") {
																	if (id_tr_y == '363'){
																	imgurll = '/ajax/thumb.php?url=http://'
																			+ data[i].merch;
																	imgy = '<a rel="nofollow" href="'
																			+ data[i].url
																			+ '" title="'
																			+ data[i].title
																			+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																			+ data[i].url
																			+ '&go=1\';"><img id="img_default'
																			+ i
																			+ '" src="/img/hotdeal.png" alt="" align="left" style="background-color:'
																			+ bgcolor
																			+ ';margin-right:5px;width:70px !important;height:55px !important;border:1px solid #CCC;cursor:pointer;"></a>';
																	imgy += '<a rel="nofollow" href="'
																			+ data[i].url
																			+ '" title="'
																			+ data[i].title
																			+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																			+ data[i].url
																			+ '&go=1\';"><img id="img'
																			+ i
																			+ '" onLoad="document.getElementById(\'img_default'
																			+ i
																			+ '\').style.display=\'none\';document.getElementById(\'img'
																			+ i
																			+ '\').style.display=\'block\';" src="/ajax/thumb.php?url=http://'
																			+ data[i].merch
																			+ '" alt="" align="left" style="margin-right:5px;width:70px !important;height:55px !important;border:1px solid #CCC;cursor:pointer;display:none;"></a>';	
																	}
																	else{
																	imgurll = '/ajax/thumb.php?url=http://'
																			+ data[i].merch;
																	imgy = '<a rel="nofollow" href="'
																			+ data[i].url
																			+ '" title="'
																			+ data[i].title
																			+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																			+ data[i].url
																			+ '&go=1\';"><img id="img_default'
																			+ i
																			+ '" src="/img/hotdeal.png" alt="" align="left" style="background-color:'
																			+ bgcolor
																			+ ';margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;"></a>';
																	imgy += '<a rel="nofollow" href="'
																			+ data[i].url
																			+ '" title="'
																			+ data[i].title
																			+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																			+ data[i].url
																			+ '&go=1\';"><img id="img'
																			+ i
																			+ '" onLoad="document.getElementById(\'img_default'
																			+ i
																			+ '\').style.display=\'none\';document.getElementById(\'img'
																			+ i
																			+ '\').style.display=\'block\';" src="/ajax/thumb.php?url=http://'
																			+ data[i].merch
																			+ '" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;display:none;"></a>';
																	}
																} else {
																	imgurll = '/ajax/thumb.php?url=http://'
																			+ data[i].merch;
																	imgy = '<a rel="nofollow" href="'
																			+ data[i].url
																			+ '" title="'
																			+ data[i].title
																			+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																			+ data[i].url
																			+ '&go=1\';"><img id="img_default'
																			+ i
																			+ '" src="/img/hotdeal_ENG.png" alt="" align="left" style="background-color:'
																			+ bgcolor
																			+ ';margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;"></a>';
																	imgy += '<a rel="nofollow" href="'
																			+ data[i].url
																			+ '" title="'
																			+ data[i].title
																			+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																			+ data[i].url
																			+ '&go=1\';"><img id="img'
																			+ i
																			+ '" onLoad="document.getElementById(\'img_default'
																			+ i
																			+ '\').style.display=\'none\';document.getElementById(\'img'
																			+ i
																			+ '\').style.display=\'block\';" src="/ajax/thumb.php?url=http://'
																			+ data[i].merch
																			+ '" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;display:none;"></a>';
																}
															}

														}
														// appx = '<img
														// class="stelle"
														// src="/img/stelle/voto_small_'+rand(3,5)+'.gif"
														// />';
														appx = '';
														sufx = '<div style="clear:both;"></div>';
														ccccclass = ' img';
													} else {
														imgy = '';
														// appx = '<img
														// class="stelle"
														// src="/img/stelle/voto_small_'+rand(1,3)+'.gif"
														// />';
														appx = '';
														sufx = '<div style="clear:both;"></div>';
														ccccclass = '';
													}
												} else {
													imgy = '';
													ccccclass = '';
												}
												if (id_tr_y == '363'){
													cache_y += '<div class="result'
														+ classs
														+ ' '
														+ ccccclass
														+ '">'
														+ imgy
														+ '<strong><a rel="nofollow" href="'
														+ data[i].url
														+ '" title="'
														+ data[i].title
														+ '" target="_blank">'
														+ data[i].title
														+ ''
														+ appx
														+ '</a></strong>'
														+ '<a style="display: inline-block; float: left;" rel="nofollow" href="'
														+ data[i].url
														+ '" target="_blank">'
														+ data[i].merch
														+ '</a>'
														+ '<p style="display: inline-block; float: left; padding-left: 5px; font-size:12px !important;">'
														+ data[i].desc
														+ '</p>'
														+ sufx
														+ '<div style="clear:both"></div></div>';
												}
												else {
													if (data[i].bidd != 1){
													cache_y += '<div class="result'
															+ classs
															+ ' '
															+ ccccclass
															+ '">'
															+ imgy
															+ '<strong><a rel="nofollow" href="'
															+ data[i].url
															+ '" title="'
															+ data[i].title
															+ '" target="_blank">'
															+ data[i].title
															+ ''
															+ appx
															+ '</a></strong>'
															+ '<p>'
															+ data[i].desc
															+ '</p>'
															+ '<a rel="nofollow" href="'
															+ data[i].url
															+ '" target="_blank">'
															+ data[i].merch
															+ '</a>'
															+ sufx
															+ '<div style="clear:both"></div></div>';
													}
												else{
													cache_y += '<div class="result'
															+ classs
															+ ' '
															+ ccccclass
															+ '">'
															+ imgy
															+ '<strong><a rel="nofollow" href="'
															+ data[i].url
															+ '" title="'
															+ data[i].title
															+ '" target="_blank">'
															+ data[i].title
															+ ''
															+ appx
															+ '</a></strong>'
															+ '<a rel="nofollow" href="'
															+ data[i].url
															+ '" target="_blank"><p>'
															+ data[i].desc
															+ '</p></a>'
															+ '<a rel="nofollow" href="'
															+ data[i].url
															+ '" target="_blank"><b>'
															+ data[i].merch
															+ '</b></a>'
															+ sufx
															+ '<div style="clear:both"></div></div>';
												}
												}
											}
											$('#results-y').html(cache_y);
											$.post('/ajax/cache.php', {
												keyword : cate,
												service : 'y',
												cache : cache_y,
												time : time,
												nonce : nonce
											});
											$('#more-products').css(
													'visibility', 'visible')
											if ($('#more-y-res').length) {
												cache_y2 = '';
												if (typeof (num_res_y_more) == 'undefined')
													num_res_y_more = 3;
													if(num_res_y_more<data.length)
														num_res_y_more = data.length;
												for (i = 0; i < num_res_y_more; i++) {
													if (i != (data.length - 1))
														classs = ' bord';
													else
														classs = '';

													if (typeof (isnew) != 'undefined') {
														// appx = '<img
														// class="stelle"
														// src="/img/stelle/voto_small_'+rand(2,5)+'.gif"
														// />';
														appx = '';
														sufx = '<div style="clear:both;"></div>';
													} else {
														appx = '';
														sufx = '';
													}
	
													if (typeof (ypreview) != 'undefined') {
														if (i < ypreview) {
															imgy = '<a rel="nofollow" href="'
																	+ data[i].url
																	+ '" title="'
																	+ data[i].title
																	+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																	+ data[i].url
																	+ '&go=1\';"><img id="img_default'
																	+ i
																	+ '" src="/img/hotdeal.png" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;"></a>';
															imgy += '<a rel="nofollow" href="'
																	+ data[i].url
																	+ '" title="'
																	+ data[i].title
																	+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
																	+ data[i].url
																	+ '&go=1\';"><img id="img'
																	+ i
																	+ '" onLoad="document.getElementById(\'img_default'
																	+ i
																	+ '\').style.display=\'none\';document.getElementById(\'img'
																	+ i
																	+ '\').style.display=\'block\';" src="/ajax/thumb.php?url=http://'
																	+ data[i].merch
																	+ '" alt="" align="left" style="margin-right:5px;width:100px;height:70px;border:1px solid #CCC;cursor:pointer;display:none;"></a>';

															// appx = '<img
															// class="stelle"
															// src="/img/stelle/voto_small_'+rand(3,5)+'.gif"
															// />';
															appx = '';
															sufx = '<div style="clear:both;"></div>';
															ccccclass = ' img';
														} else {
															imgy = '';
															// appx = '<img
															// class="stelle"
															// src="/img/stelle/voto_small_'+rand(1,3)+'.gif"
															// />';
															appx = '';
															sufx = '<div style="clear:both;"></div>';
															ccccclass = '';
														}
													} else {
														imgy = '';
														ccccclass = '';
													}

													cache_y2 += '<div class="result'
															+ classs
															+ ' '
															+ ccccclass
															+ '">'
															+ imgy
															+ '<strong><a rel="nofollow" href="'
															+ data[i].url
															+ '" title="'
															+ data[i].title
															+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
															+ data[i].url
															+ '&go=1\';">'
															+ data[i].title
															+ ''
															+ appx
															+ '</a></strong>'
															+ '<a rel="nofollow" href="'
															+ data[i].url
															+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
															+ data[i].url
															+ '&go=1\';"><p>'
															+ data[i].desc
															+ '</p></a>'
															+ '<a rel="nofollow" href="'
															+ data[i].url
															+ '" target="_blank" onclick="document.getElementById(\'conversion-tracking\').src=\''
															+ data[i].url
															+ '&go=1\';">'
															+ data[i].merch
															+ '</a>'
															+ sufx
															+ '<div style="clear:both"></div></div>'
												}
												$('#more-y-res').append(
														cache_y2);
											}
										}
									});
				});

function showNextImage() {
	current = $('#carousel_big > li.currentz').attr('id').replace(/cb_/, '');
	if (current == carousel)
		current = 0;
	current++;
	carouselShow(current)
}

function carouselShow(el) {

	$('#carousel_big > li').stop(true, true);
	$('#carousel_big > li.currentz').fadeOut('slow', function() {
		$('#carousel_big > li').removeClass('currentz');
		$('#cb_' + el).fadeIn('slow');
		$('#cb_' + el).addClass('currentz');
	});
}

function search(val) {
	location.href = "/search/" + val.toLowerCase() + "/";
	return false;
}

function storeAddress() {
	$('#response').html('Adding email address...');
	$.ajax({
		type : "GET",
		url : "/ajaxServer.php",
		data : "address=" + escape($('#address').val()),
		success : function(msg) {
			$("#response").html(msg);
		}
	});
	return false;
}

function checkform() {
	
	if (!document.getElementById("form_checkbox").checked) {
		alert("Per iscriverti devi accettare la privacy policy");
		return;
	}
	
	var mail = escape($('#formmail').val())
	var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!espressione.test(mail))
	{
	    alert("La mail inserita non è valida!");
	}
	
	 $.post("/ajax/form_nl.php", { nome: escape($('#formname').val()), cognome: escape($('#formcognome').val()), email: escape($('#formmail').val()), id_form: escape($('#idform').val()), campo1: escape($('#campo1').val()), campo2: escape($('#campo2').val()), province: escape($('#formprovince').val())},
			 function(data) {
		 		if(data.status==0){
				   $("#formerror").show();
				   $("#formerror").html("");
			   		for (i=0; i < data.error.length; i++)			   			
			   			$("#formerror").append("* "+data.error[i]+"<br>");
			   }			
			   else{
				   location.href= "/thankyou/?idform="+escape($('#idform').val())+"&email="+escape($('#formmail').val())+"&nome="+escape($('#formname').val())+"&cognome="+escape($('#formcognome').val());
			   }	
				   
			 }, 
			 "json"
			);
	return false;
}

function checkform_simple() {
	
	if (!document.getElementById("form_checkbox").checked) {
		alert("Per iscriverti devi accettare la privacy policy");
		return;
	}
	
	var mail = escape($('#formmail').val())
	var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!espressione.test(mail))
	{
	    alert("La mail inserita non è valida!");
	}
	
	 $.post("/ajax/form_nl.php", { nome: "null", cognome: "null", email: escape($('#formmail').val()), id_form: escape($('#idform').val()), campo1: escape($('#campo1').val()), campo2: "null", province: "null"},
			 function(data) {
		 		if(data.status==0){
				   $("#formerror").show();
				   $("#formerror").html("");
			   		for (i=0; i < data.error.length; i++)			   			
			   			$("#formerror").append("* "+data.error[i]+"<br>");
			   }			
			   else{
				   location.href= "/thankyou/?idform="+escape($('#idform').val())+"&email="+escape($('#formmail').val());
			   }	
				   
			 }, 
			 "json"
			);
	return false;
}

function unsubscribe(){
	$.post("/ajax/delete_ml.php", { email: escape($('#usmail').val())},
			 function(data) {
		 		if(data.status==0){
				   $("#formerror").show();
				   $("#formerror").html("");
			   		for (i=0; i < data.error.length; i++)			   			
			   			$("#formerror").append("* "+data.error[i]+"<br>");
			   }			
			   else{
				   location.href= "/delsuccess";
			   }	
				   
			 }, 
			 "json"
			);
	return false;
}

function nlNextstep() {

	$('#nl-nome').css('border', '1px solid ' + maincolor);
	$('#nl-cognome').css('border', '1px solid ' + maincolor);
	$('#nl-email').css('border', '1px solid ' + maincolor);

	err = 0;
	if (!$('#nl-nome').val()) {
		$('#nl-nome').css('border', '1px solid red');
		err++;
	}

	if (!$('#nl-cognome').val()) {
		$('#nl-cognome').css('border', '1px solid red');
		err++;
	}

	if (!$('#nl-email').val()) {
		$('#nl-email').css('border', '1px solid red');
		err++;
	}

	if (err == 0) {
		$('#nl-step1').hide();
		$('#nl-step2').show();
	}
}

function nlShow() {

	if (!document.getElementById("prnl_checkbox").checked) {
		alert("Per iscriverti devi accettare la privacy policy");
		return;
	}

	$('html, body').animate({
		scrollTop : '0px'
	}, 300);
	if ($('#address').val().indexOf('@') != -1)
		$('#nl-email').val($('#address').val());
	$('#nl-step1').show();
	$('#nl-step2').hide();
	$('#nl-results').hide();
	$('#opaque').show();
	$('#newsletter-signup').show();
}

function nlClose() {
	$('#opaque').hide();
	$('#newsletter-signup').hide();
}

function nlBack() {
	$('#nl-step1').show();
	$('#nl-step2').hide();
	$('#nl-results').hide();
}

function nlSubmit() {

	$('#nl-errors').hide();
	fields = new Array();
	if ($('.nl-check > input.checkbox:checked').length > 4) {

		$('#nl-errors').show();

		return false;

	}

	for (a = 0; a < nlNumchecks; a++)
		if ($('#nl-' + a + ':checked').val())
			fields.push($('#nl-' + a + ':checked').attr('name'));

	$.post("/ajax/nl.php?signup=1", {
		nome : $('#nl-nome').val(),
		cognome : $('#nl-cognome').val(),
		email : $('#nl-email').val(),
		eta : $('#nl-giorno').val() + "/" + $('#nl-mese').val() + "/"
				+ $('#nl-anno').val(),
		interessi : fields.join(',')
	}, function(data) {
		$('#nl-step2').hide();
		$('#nl-step1').hide();
		$('#nl-results').show();
		// $('#nl-results').html(data);
	});
}

function footergalleryprev() {
	if (currentmediagallery < 5)
		return

	$('#mediagallery_' + currentmediagallery).hide()
	currentmediagallery--
	$('#mediagallery_' + (currentmediagallery - 4)).show()
}

function footergallerynext() {
	if (currentmediagallery > 8)
		return

	currentmediagallery++
	$('#mediagallery_' + currentmediagallery).show()
	$('#mediagallery_' + (currentmediagallery - 5)).hide()
}

function persiana() {
	if ($('#logosites_container').css('display') != 'none')
		$('#logosites_container').hide();
	else
		$('#logosites_container').show();
}

function persiana_footer() {
	if ($('.twimboosites ul').css('display') != 'none')
		$('.twimboosites ul').hide();
	else
		$('.twimboosites ul').show();
}

$(document).ready(function() {

	$("#pageflip").hover(function() {
		$("#pageflip img , .msg_block").stop().animate({
			width : '307px',
			height : '319px'
		}, 500);
	}, function() {
		$("#pageflip img").stop().animate({
			width : '50px',
			height : '52px'
		}, 220);
		$(".msg_block").stop().animate({
			width : '50px',
			height : '50px'
		}, 200);
	});

});

function rand(min, max) {
	var argc = arguments.length;
	if (argc === 0) {
		min = 0;
		max = 2147483647;
	} else if (argc === 1) {
		throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
	}
	return Math.floor(Math.random() * (max - min + 1)) + min;

}

