// JavaScript Document
function CheckForSubmit(NomeCampo, NomeForm, NomeBottone, Codice) {
	var idform = 1;
	var Valore = document.forms[NomeForm].elements[NomeCampo].checked;
	if (Valore) {
		document.forms[NomeForm].elements[NomeBottone].disabled=false;
		document.forms[NomeForm].elements[Codice].value="1";
		document.forms[NomeForm].action = "formsub.asp?send=true"
	}
	else {
		document.forms[NomeForm].elements[NomeBottone].disabled=true;
		document.forms[NomeForm].elements[Codice].value="0";
	};
};

var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-2458432-18']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



function SetSiteAsHomeBrowser() {
	var s_url = "http://www.periodicoilgrillo.com/";
	var s_nn="Il tuo browser non supporta l\'impostazione automatica della HomePage. Occorre impostarla manualmente.\nPer rendere questa pagina come vostra Home Page, dovete trascinare l\'icona presente alla sinistra dell\' indirizzo web presente nella vostra barra di navigazione sull\'icona \"Home\" della vostra toolbar. Alcuni browsers si comportano in modo differente; comunque potete sempre cambiare la vostra Home Page con le preferenze del vostro browser.";
	var s_op = s_nn;
	var s_other = s_nn;
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		oHomePage.style.behavior = "url('#default#homePage')"
		oHomePage.setHomePage(s_url);
		return true;
	} else if (navigator.appName == "Netscape") {
		alert(s_nn);
	} else if (navigator.appName == "Opera") {
		alert(s_op);
	}
	else {
		document.write("" + s_other + "");
	};
};

function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
};

if ($$('a.addthis_button_facebook_like')) $$('a.addthis_button_facebook_like').setProperty('fb:like:layout','button_count');

function azzera_margin() {
	
	if ($$('a.addthis_button_facebook_like').length > 0) $$('a.addthis_button_facebook_like')[0].getChildren('iframe').setStyle('margin',0);

}
function leggiparamurl(key,url){  
    if(arguments.length < 2) url =location.href;  
    if(arguments.length > 0 && key != ""){  
        if(key == "#"){  
            var regex = new RegExp("[#]([^$]*)");  
        } else if(key == "?"){  
            var regex = new RegExp("[?]([^#$]*)");  
        } else {  
            var regex = new RegExp("[?&]"+key+"=([^&#]*)");  
        }  
        var results = regex.exec(url);  
        return (results == null )? "" : results[1];  
    } else {  
        url = url.split("?");  
        var results = {};  
            if(url.length > 1){  
                url = url[1].split("#");  
                if(url.length > 1) results["hash"] = url[1];  
                url[0].split("&").each(function(item,index){  
                    item = item.split("=");  
                    results[item[0]] = item[1];  
                });  
            }  
        return results;  
    }  
} 

if ($('frm_sondaggio')) {
	$('frm_sondaggio').addEvent("submit", function() {
		$('Screen_W').value = window.screen.width;
		$('Screen_H').value = window.screen.height;
		$('Screen_C').value = window.screen.colorDepth;
	});
};
if ($('facebookfacepill')) {
	
	var id_wrap_div = $$('div.fb-like-box')[0];
	id_wrap_div.setProperty('data-href','http://www.facebook.com/pages/Il-Grillo/194936307334');
	id_wrap_div.setProperty('data-width','304');
	id_wrap_div.setProperty('data-height','330');
	id_wrap_div.setProperty('data-show-faces','true');
	id_wrap_div.setProperty('data-stream','false');
	id_wrap_div.setProperty('data-header','false');
	
	
};
window.addEvent("domready", function() {
	$$('#tabs-nav a, #tabs-body li').tabify({
    	
	});
	
	if ($('cmdvedi')) {
		$('cmdvedi').addEvent("click", function(e) {
			e = new Event(e).stop();
			var id_sondaggio_loc = $('ID_Sondaggio_Frm').value;
			document.location.href = "/sondaggio.asp?E=" + id_sondaggio_loc;
		});
	};
	
	
	var totale_gg = $$('a.linkgg').length;
	if (totale_gg > 0) {
		$$('a.linkgg').addEvent('click', function(e){
			e = new Event(e).stop();
			var link_gg = this.getProperty('href');
			var link_gg_g = leggiparamurl("giorno", link_gg);
			var link_gg_m = leggiparamurl("mese", link_gg);
			var link_gg_a = leggiparamurl("anno", link_gg);
			
			
			var req = new Request({
				method: 'get',
				url: '/include/conta_notizie_data.asp?giorno=' + link_gg_g + '&mese=' + link_gg_m + '&anno=' + link_gg_a,
				onComplete:function(response) {
					var numero_news = response.toInt();
					if (numero_news>0) {
						document.location.href = this.getProperty('href');
					};
				}.bind(this)
			}).send();
			
			
			
		});
	
	};
	
	if ($('bodycalendario')) {
		var num_settimane = $$('#bodycalendario div.clear').length;
		if (num_settimane<6) {
			$('wrap_calendario').setStyle('padding-top',15);
		};
	};
	
	if ($('issuubox5')) {
		var indice_f = $('issuubox5').getProperty('class');
		
		
		var attributes = {
			id: 'issuuViewer2'
		};
		
		var params = {
			allowfullscreen: 'true',
			allowScriptAccess: 'always',
			menu: 'false',
			wmode: 'transparent'
		};
		
		var flashvars = {
			jsAPIClientDomain: 'issuu.com',
			mode: 'mini',
			viewMode: 'singlePage',
			documentId: indice_f
		};
		
		swfobject.embedSWF("http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf", "issuubox5", "233", "310", "9.0.0", "/expressInstall.swf", flashvars, params, attributes);
				
		
	};
	
	var params2 = { allowScriptAccess: "always", menu: "false", wmode: "transparent"};
	if ($('youtube_grillo')) {
		if (Browser.Engine.trident) {
			var linkVideo = $('youtube_grillo').getProperty('href');
			var atts = { id: "primopianolist" };
			var myURI = new URI(linkVideo);
			var valoreIdVideo = myURI.getData('v');
			//$("primopianolist").empty();
			$("youtube_grillo").destroy();
			
			swfobject.embedSWF("http://www.youtube.com/v/" + valoreIdVideo + "?enablejsapi=1&playerapiid=ytplayer", "primopianolist", "324", "196", "8", null, null, params2, atts);
		
		}
		else {
			
			var linkVideo = $('youtube_grillo').getProperty('href');
			var myURI = new URI(linkVideo);
			var valoreIdVideo = myURI.getData('v');
			var myFrame = new Element('iframe', {
				'width': '324',
				'height': '196',
				'src': 'http://www.youtube.com/embed/' + valoreIdVideo,
				'frameborder':'0',
				'allowfullscreen':'true'
				
			});
			$('spacer_grillotv').destroy();
			myFrame.inject($('primopianolist'));
			$("youtube_grillo").destroy();
		};
		
	};
	if ($('youtube_view')) {
		
		var linkVideo = $('youtube_view_aid').getProperty('href');
		var atts = { id: "youtube_view" };
		var myURI = new URI(linkVideo);
		var valoreIdVideo = myURI.getData('v');
		$("youtube_view").setStyle('background-color','FFFFFF');
		$("youtube_view").empty();
		swfobject.embedSWF("http://www.youtube.com/v/" + valoreIdVideo + "?enablejsapi=1&playerapiid=ytplayer", "youtube_view", "480", "360", "8", null, null, params2, atts);
		
		
		
	};
	

	if ($('newsticker')) {
		
		var myTicker = new mooTicker($('boxticker').getElement('.newsticker'),{groupBy:1, interval:4000});
		
	};
	
	
	
	
	if ($('frmmail')) new FormCheck('frmmail');
	if ($('frmaddcomment')) new FormCheck('frmaddcomment');
	
	//var scroller = new UvumiScrollbar("primopianolist");
	//var scrollBox1 = new MooScroll({selector:'#primopianolist'});

	
	$('logo').addEvent('click', function(e){
		e = new Event(e).stop();
		document.location.href = this.getElements('a').getProperty('href');
	});
	
	
	azzera_margin.delay(1000);
	
	//new SmoothScroll({duration: 1000}); 
	new SmoothScroll({ duration:700 }, window);
	/*if ($('myGallery')) {

		if (($$('div.imageElement h3')).length > 0) {
			var myGallery = new gallery($('myGallery'), {showInfopane:true});
		}
		else {
			var myGallery = new gallery($('myGallery'), {});
		};
	};*/
	
	
	
	
	
	if($$('a.zoom')) {
		if (!Browser.Engine.trident) {
			ReMooz.assign('a.zoom', {
				'origin': 'img',
				'shadow': 'onOpenEnd', // fx is faster because shadow appears after resize animation
				'resizeFactor': 0.8, // resize to maximum 80% of screen size
				'cutOut': false, // don't hide the original
				'opacityResize': 0.4, // opaque resize
				'dragging': true, // disable dragging
				'centered': true // resize to center of the screen, not relative to the source element
			});
		};
	};
	
	
	
	
	
	
	
	if ($('accordion')) AccordionMenu();
	
	/*carmine12345();
	
	$('navbar').setStyle('height','auto');
	
	$('menubar').setStyle('height','auto');
	$('menubar').setStyle('overflow','visible');
	$$('#navbar ul.submenu_grp').removeClass('start');
	
	$('menubar').setStyle('display','none');*/
	$('menubar').setStyle('display','inline-block');
	$('navbar').setStyle('overflow','visible');
	var menu = new UvumiDropdown('menubar');
	

});


function carmine12345() {

var bl_swfUrl = "http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf";

var bl_flashver = "9.0.0"; //flex publishing version

var bl_params = {
allowfullscreen: "true",
menu: "false",
salign: "tl",
scale: "noscale",
allowscriptaccess: "never",
base: "http://static.issuu.com/site/",
wmode: "transparent"
};
var bl_attr = { 
id: bl_domId,
name: bl_domId
}; 

swfobject.embedSWF(bl_swfUrl, bl_domId, bl_width, bl_height,
bl_flashver, {}, bl_flashvars, bl_params, bl_attr);

}




