
$.fn.cycle.defaults = {
    fx:             'scrollLeft', // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle)
    timeout:         4000,  // milliseconds between slide transitions (0 to disable auto advance)
    timeoutFn:       null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
    continuous:      0,     // true to start next transition immediately after current one completes
    speed:           1000,  // speed of the transition (any valid fx speed value)
    height:         'auto', // container height
    startingSlide:   0,     // zero-based index of the first slide to be displayed
    sync:            1,     // true if in/out transitions should occur simultaneously
    random:          0,     // true for random, false for sequence (not applicable to shuffle fx)
    fit:             0,     // force slides to fit container
    containerResize: 1,     // resize container to fit largest slide
    pause:           1,     // true to enable "pause on hover"
    pauseOnPagerHover: 1,   // true to pause when hovering over pager link
    autostop:        0,     // true to end slideshow after X transitions (where X == slide count)
    autostopCount:   0,     // number of transitions (optionally used with autostop to define X)
    delay:           0,     // additional delay (in ms) for first transition (hint: can be negative)
    slideExpr:       null,  // expression for selecting slides (if something other than all children is required)
    cleartype:       !$.support.opacity,  // true if clearType corrections should be applied (for IE)
    cleartypeNoBg:   false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
    nowrap:          0,     // true to prevent slideshow from wrapping
    fastOnEvent:     0,     // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
    randomizeEffects:1,     // valid when multiple effects are used; true to make the effect sequence random
    rev:             0,     // causes animations to transition in reverse
    manualTrump:     true,  // causes manual transition to stop an active transition instead of being ignored
    requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
    requeueTimeout:  250,   // ms delay for requeue
    activePagerClass: 'active', // class name used for the active pager link
    updateActivePagerLink: null // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
};

$(window).load(function(){

	$("#cycle-home ul").cycle();
	$("#img-prodotti ul").cycle({fx:"fade"});

	$('#banner-home li').mouseover(function(){ $(this).addClass("hover"); });
	$('#banner-home li').mouseout(function(){ $(this).removeClass("hover"); });

	$('#top').click(function(){ location.href = '/'; });

	$('.col').append('<div class="arrow"></div>');
	$('.col').bind("click", function(){ window.location = $(this).children("a").attr('href'); });
	$('.col').mouseover(function(){ $(this).children("div.arrow, h2").addClass("hover"); });
	$('.col').mouseout(function(){ $(this).children("div.arrow, h2").removeClass("hover"); });

	$('.colt').append('<div class="arrow"></div>');
	$('.colt').bind("click", function(){ $(this).children("a").click(); });
	$('.colt').mouseover(function(){ $(this).children("div.arrow, h2").addClass("hover"); });
	$('.colt').mouseout(function(){ $(this).children("div.arrow, h2").removeClass("hover"); });

	$('.fiera').append('<div class="arrow"></div>');
	$('.fiera').bind("click", function(){ $(this).children("a").click(); });
	$('.fiera').mouseover(function(){ $(this).children("div.arrow, h3").addClass("hover"); });
	$('.fiera').mouseout(function(){ $(this).children("div.arrow, h3").removeClass("hover"); });

	$("a.gal").fancybox({
		'titleShow': false,
		'overlayColor': '#000',
		'overlayOpacity': 0.8,
		'hideOnContentClick': false,
		'callbackOnClose': function() {
			$("#fancy_content").empty();}
	});


	$.fn.maphilight.defaults = {
		fill: true,
		fillColor: 'ffcc00',
		fillOpacity: 1,
		stroke: true,
		strokeColor: 'ffcc00',
		strokeOpacity: 1,
		strokeWidth: 1,
		fade: true,
		alwaysOn: false,
		neverOn: false,
		groupBy: false
	}

	$('#mappa').load('inc/map.html', function() {
		$('.map').maphilight();

		$(".area").click(function(e){
			e.preventDefault();
			$('div[rel^="opened"]').hide();
			var ident = $(this).attr("title");
			$("."+ident).css({"position":"absolute","top":e.pageY-112,"left":e.pageX-104}).show();
			$("."+ident).attr({"rel":"opened"})
			$("."+ident).click(function(){$(this).hide();})
		});
	});


});

function sendMail1(){
	var sendingMail = 1;
	if ( document.getElementById('email1').value == '' ) { document.getElementById('email1').className = 'inputError'; sendingMail = 0 } else { document.getElementById('email1').className = 'inputok'; }
	if ( document.getElementById('person1').value == '' ) { document.getElementById('person1').className = 'inputError'; sendingMail = 0 } else { document.getElementById('person1').className = 'inputok'; }
	if ( document.getElementById('request1').value == '' ) { document.getElementById('request1').className = 'inputError'; sendingMail = 0 } else { document.getElementById('request1').className = 'inputok'; }
	if ( !document.getElementById('privacy1').checked ) { document.getElementById('privacy1_label').className = 'labelError'; sendingMail = 0 } else { document.getElementById('privacy1_label').className = 'labelok'; }
	if (sendingMail == 1) {

		var ajax = new sack();
		function whenLoading(){ }
		function whenCompleted(){
			//alert(ajax.response);
			alert('Grazie per l\'interesse nei nostri prodotti.\nRisponderemo quanto prima alle tue richieste.');
			document.getElementById('person1').value = '';document.getElementById('email1').value = '';document.getElementById('request1').value = '';
			pageTracker._trackPageview("/richiesta-contatto");
		}
		ajax.encVar("email", document.getElementById('email1').value);
		ajax.encVar("name", document.getElementById('person1').value);
		ajax.encVar("request", document.getElementById('request1').value);
		ajax.encVar("action", "MAIL1");
		ajax.requestFile = baseurl+"/lib/proxy.php";
		ajax.method = "POST";
		ajax.onCompletion = whenCompleted;
		ajax.runAJAX();
	}
}

function readFile(nome){
	var ajax = assegnaXMLHttpRequest(), jsonArray={};
	if(ajax && ajax.readyState === 0) {
		ajax.open("get", baseurl+"/lib/maps/"+nome+".txt", true);
		ajax.onreadystatechange = function() {
			if(ajax.readyState === 4) {
					jsonArray = ajax.responseText.parseJSON();
					ajax = assegnaXMLHttpRequest();
					load(jsonArray);
			}
		}
		ajax.send(null);
	}
}

function sendMail2(){
	var sendingMail = 1;
	if ( document.getElementById('email2').value == '' ) { document.getElementById('email2').className = 'inputError'; sendingMail = 0 } else { document.getElementById('email2').className = 'inputok'; }
	if ( document.getElementById('person2').value == '' ) { document.getElementById('person2').className = 'inputError'; sendingMail = 0 } else { document.getElementById('person2').className = 'inputok'; }
	if ( document.getElementById('company').value == '' ) { document.getElementById('company').className = 'inputError'; sendingMail = 0 } else { document.getElementById('company').className = 'inputok'; }
	if ( document.getElementById('phone').value == '' ) { document.getElementById('phone').className = 'inputError'; sendingMail = 0 } else { document.getElementById('phone').className = 'inputok'; }
	if ( document.getElementById('request2').value == '' ) { document.getElementById('request2').className = 'inputError'; sendingMail = 0 } else { document.getElementById('request2').className = 'inputok'; }
	if ( !document.getElementById('privacy2').checked ) { document.getElementById('privacy2_label').className = 'labelError'; sendingMail = 0 } else { document.getElementById('privacy2_label').className = 'labelok'; }
	if (sendingMail == 1) {

		var ajax = new sack();
		function whenLoading(){ }
		function whenCompleted(){
			//alert(ajax.response);
			alert('Grazie per il suo interesse nel diventare Riveditore Jumpking.\nRisponderemo quanto prima alle sue richieste.');
			document.getElementById('person2').value = '';document.getElementById('email2').value = '';document.getElementById('request2').value = '';document.getElementById('company').value = '';document.getElementById('phone').value = '';
			pageTracker._trackPageview("/richiesta-rivenditore");
		}
		ajax.encVar("email", document.getElementById('email2').value);
		ajax.encVar("name", document.getElementById('person2').value);
		ajax.encVar("request", document.getElementById('request2').value);
		ajax.encVar("company", document.getElementById('company').value);
		ajax.encVar("phone", document.getElementById('phone').value);
		ajax.encVar("settore", document.getElementById('settore').value);
		ajax.encVar("action", "MAIL2");
		ajax.requestFile = baseurl+"/lib/proxy.php";
		ajax.method = "POST";
		ajax.onCompletion = whenCompleted;
		ajax.runAJAX();
	}
}

