$(window).load(function() {
if ($("#nslider").length > 0) { $('#nslider').nivoSlider({effect: 'fade', pauseTime: 6000, directionNav: false, controlNav: true, pauseOnHover: false}); }
if ($("#intslider").length > 0) { $('#intslider').nivoSlider({effect: 'fade', pauseTime: 6000, directionNav: false, controlNav: false, pauseOnHover: false}); }
});
//toggle visibility
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block') e.style.display = 'none';
else e.style.display = 'block';
}
//Custom Select
(function($){
$.fn.extend({
customStyle : function(options) {
if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
return this.each(function() {
var currentSelected = $(this).find(':selected');
$(this).after(''+currentSelected.text()+'').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
var selectBoxSpan = $(this).next();
var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));
var selectBoxSpanInner = selectBoxSpan.find(':first-child');
selectBoxSpan.css({display:'inline-block'});
selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
$(this).height(selectBoxHeight).change(function(){
// selectBoxSpanInner.text($(this).val()).parent().addClass('changed'); This was not ideal
selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
// Thanks to Juarez Filho & PaddyMurphy
});
});
}
}
});
})(jQuery);
//jQuery
$(document).ready(function(){
//Custom Form
if ($("#cform").length > 0) { $("input, textarea, select, button").uniform(); }
//Comune click
if ($(".fooleft").length > 0) { $(".fooleft").click(function(){ window.location=$(this).find("a").attr("href"); return false; }); }
//toggle input value
swapValue = [];
$(".itxt").each(function(i){
swapValue[i] = $(this).val();
$(this).focus(function(){
if ($(this).val() == swapValue[i]) {
$(this).val("");
}
$(this).addClass("focus");
}).blur(function(){
if ($.trim($(this).val()) == "") {
$(this).val(swapValue[i]);
$(this).removeClass("focus");
}
});
});
//Fadeimg
$(".pimg").fadeTo("slow", 1.0);
$(".pimg").hover(
function(){ $(this).fadeTo("fast", 0.7); },
function(){ $(this).fadeTo("fast", 1.0);
});
//Menu funcs
if ($("#menu").length > 0) {
$("#menu li").mouseover( function(){ $(this).addClass("active"); $(this).find("div:first").fadeIn('fast'); });
$("#menu li").mouseleave( function(){ $(this).removeClass("active"); $(this).find("div:first").fadeOut('fast'); });
$("#menu li div span").hover( function(){ $(this).css({"color":"#000", "cursor":"pointer"}); }, function(){ $(this).css({"color":"#fff"}); });
$("#menu li div span").click( function(){ window.location=$(this).find("a:first").attr("href"); return false; });
$(".selects").mouseover( function(){ $("#selsite").fadeIn('fast'); });
$("#selsite").mouseover( function(){ $("#selsite").show(); });
$("#selsite").mouseleave( function(){ $("#selsite").fadeOut('fast'); });
}
//Boxes
if ($(".rbtn").length > 0) {
$(".rbtn").hover( function(){ $(this).fadeTo("fast", 0.7); }, function(){ $(this).fadeTo("fast", 1.0); });
$(".rbtn").click( function(){ document.enquire.submit(); return false; });
$("#ecprice, #rcprice, #dcprice").hover( function(){ $(this).css({"color":"#000"}); }, function(){ $(this).css({"color":"#f90"}); });
$("#ecprice").click( function(){ $("#eprice").show(); $("#rprice").hide(); $("#dprice").hide(); });
$("#rcprice").click( function(){ $("#eprice").hide(); $("#rprice").show(); $("#dprice").hide(); });
$("#dcprice").click( function(){ $("#eprice").hide(); $("#rprice").hide(); $("#dprice").show(); });
if ($("#eprice2").length > 0) {
$("#ecprice2, #rcprice2, #dcprice2").hover( function(){ $(this).css({"color":"#000"}); }, function(){ $(this).css({"color":"#f90"}); });
$("#ecprice2").click( function(){ $("#eprice2").show(); $("#rprice2").hide(); $("#dprice2").hide(); });
$("#rcprice2").click( function(){ $("#eprice2").hide(); $("#rprice2").show(); $("#dprice2").hide(); });
$("#dcprice2").click( function(){ $("#eprice2").hide(); $("#rprice2").hide(); $("#dprice2").show(); });
}
}
//Notice
if ($(".notice").length > 0) { $('.notice').fadeIn().delay(4000).fadeOut('slow'); }
//Mail
if ($(".mailaddr").length > 0) { $('.mailaddr').append('assprogettocitta' + '@' + 'gmail.com'); }
//Toggle elements onload
if ($("h1").length > 0) { $("h1").fadeIn(); }
if ($("h2").length > 0) { $("h2").fadeIn(); }
if ($("h3").length > 0) { $("h3").fadeIn(); }
if ($("#ltop").length > 0) { $("#ltopl").fadeIn(); $("#ltopr").fadeIn(); }
if ($("#menu").length > 0) { $("#menu").fadeIn(); }
//if ($("#lang").length > 0) { $("#lang").fadeIn(); }
if ($("#footer").length > 0) { $("#footer").delay(1000).fadeIn(); }
//Clickable div
if ($(".dclick").length > 0) {
$(".dclick").fadeTo("slow", 1.0);
$(".dclick").hover(
function(){ $(this).fadeTo("fast", 0.65); },
function(){ $(this).fadeTo("fast", 1.0);
});
$(".dclick").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
}
//Sliders
if( $("#news_slider").length > 0) { $("#news_slider").fadeIn(); $('#news_slider').bxSlider({auto: true, speed: 1000, autoHover: true, controls:false, pager: true, pagerSelector: '#nsliderctrl', pagerActiveClass: 'active'}); }
if( $("#prslider").length > 0) { $("#prslider").fadeIn(); $('#prslider').bxSlider({auto: true, speed: 1000, autoHover: true, controls:false, pager: true, pagerSelector: '#sliderctrl', pagerActiveClass: 'active'}); }
if( $("#cslider").length > 0) { $("#cslider").fadeIn(); $('#cslider').bxSlider({auto: true, controls:false, pager: false, pause: 8000, autoHover: true}); }
if( $("#newslider").length > 0) { $("#newslider").fadeIn(); $('#newslider').bxSlider({auto: true, speed: 1000, pause: 4000, autoHover: true, controls:false, pager: true, pagerSelector: '#slidernews', pagerActiveClass: 'active'}); }
//Validate Contact Form
if( $("#contact_form").length > 0) {
$("#contact_form").click(function() {
if ($("#nome").val() == "") { $(".lnome").addClass('error_red'); $("#nome").focus(); return false; } else { $(".lnome").removeClass('error_red'); }
if ($("#cognome").val() == "") { $(".lcognome").addClass('error_red'); $("#cognome").focus(); return false; } else { $(".lcognome").removeClass('error_red'); }
if ($("#email").val() == "") { $(".lemail").addClass('error_red'); $("#email").focus(); return false; } else { $(".lemail").removeClass('error_red'); }
if ($("#telefono").val() == "") { $(".ltel").addClass('error_red'); $("#telefono").focus(); return false; } else { $(".ltel").removeClass('error_red'); }
if ($("#mess").val() == "") { $(".lmess").addClass('error_red'); $("#mess").focus(); return false; } else { $(".lmess").removeClass('error_red'); }
//if ($("#scode").val() == "") { $(".lscode").addClass('error_red'); $("#scode").focus(); return false; } else { $(".lscode").removeClass('error_red'); }
document.contact_form.submit();
});
}
});
//ShadowBox
Shadowbox.init({
overlayColor: '#000000',
overlayOpacity: '0.7',
language: 'it',
players: ['img', 'html', 'iframe']
});