$(document).ready(function() {
$("ul.subNav li:not(:last) a").each(function() {
$w = $(this).outerWidth() + 7;
$(this).append('');
});
$("ul.subNav li:not(:last) a:not(.hover)").hoverIntent(function() {
$(this).find('span').fadeIn();
}, function() {
$(this).find('span').fadeOut();
});
$(".boxFotosEscolha ul.navEscolha li a").append('');
$(".boxFotosEscolha ul.navEscolha li:not(.current-cat) a:not(.hover)").hover(function() {
$(this).find('span').show();
}, function() {
$(this).find('span').hide();
});
$("ul.navTop5 li a").each(function() {
$text = $(this).find("img").attr("alt");
$(this).append('' + $text + '');
if ($(this).attr("href") == "#") {
$(this).removeAttr("href");
}
}).hover(function() {
$(this).find("span").addClass("hover").end().find("em").show();
}, function() {
$(this).find("span").removeClass("hover").end().find("em").hide();
});
$("a.btnSubmenu").each(function() {
if ($("a.btnProdutos").hasClass("hover")) {
$("#menuProdutos").show();
}
}).click(function() {
$$ = $(this);
$other = $('.headerStatic nav:visible').size();
if ($$.hasClass('hover') && $($$.attr('href')).is(':visible')) {
$($$.attr('href')).slideUp();
$$.removeClass('hover');
} else if (!$$.hasClass('hover') && $($$.attr('href')).is(':hidden') && $other == 0) {
$($$.attr('href')).slideDown();
$$.addClass('hover');
} else if (!$$.hasClass('hover') && $($$.attr('href')).is(':hidden') && $other == 1) {
$('.navHeader li a').removeClass('hover');
$('.headerStatic nav:visible').slideUp(function() {
$($$.attr('href')).slideDown();
$$.addClass('hover');
});
};
return false;
});
//$(".tel").mask('9999-99999');
$("ul.navGaleria li").each(function(i) {
$(this).attr("data-index", (i + 1));
$(".paginateGaleria").append('');
});
/* Funcionalidade inspirada no Twitter */
$(".holding .holder").click(function() {
$(this).parents(".holding").find("input:text").focus();
});
$(".holding input:text").each(function() {
if ($(this).val() != '') {
$(this).parents(".holding").find(".holder").hide();
}
}).focus(function() {
$(this).parents(".holding").find(".holder").animate({
opacity: 0.3
});
}).blur(function() {
$(this).parents(".holding").find(".holder").animate({
opacity: 1.0
});
}).keyup(function() {
($(this).val()) ? $(this).parents(".holding").find(".holder").fadeOut() : $(this).parents(".holding").find(".holder").fadeIn();
}); /* Funcionalidade inspirada no Twitter */
$("ul.navCurtaSiga li").mouseenter(function() {
$(this).find("a").addClass("hover");
$(this).find(".tooltipCurta").stop(true, true).fadeIn();
}).mouseleave(function() {
$(this).find("a").removeClass("hover");
$(this).find(".tooltipCurta").fadeOut();
});
/* Galeria Home */
$galeriaInitCallback = function(carousel, state) {
carousel.buttonNext.bind('click', function() {
carousel.startAuto(0);
});
carousel.buttonPrev.bind('click', function() {
carousel.startAuto(0);
});
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
$(".paginateGaleria a").bind("click", function() {
$idx = $(".paginateGaleria a").index($(this));
carousel.scroll(jQuery.jcarousel.intval($idx + 1));
return false;
});
};
var $firstView = false;
$galeriaVisibleCallback = function($carousel, $li, $index, $state) {
$idx = $($li).attr("data-index");
$(".paginateGaleria a").removeClass("active");
$(".paginateGaleria a:eq(" + ($idx - 1) + ")").addClass("active");
if ($firstView != false) {
omnEvent($("meta[name='omniture-event']").attr("content") + '|' + 'home-banners|banner' + $idx);
} else {
$firstView = true;
};
};
$("body.home").each(function() {
$start = Math.floor((Math.random() * 3) + 1);
$(".boxGaleriaHome ul li").show();
$(".boxGaleriaHome ul").jcarousel({
scroll: 1,
start: $start,
wrap: 'circular',
auto: 5,
itemVisibleInCallback: $galeriaVisibleCallback,
initCallback: $galeriaInitCallback
});
});
/* Galeria Home */
/* Menu Diversao */
$(".boxGaleriaMenuDiversao ul").jcarousel({
scroll: 1,
start: 1,
// wrap: 'circular',
auto: 10,
itemVisibleInCallback: function($carousel, $li, $index, $state) {
$idx = $($li).attr("data-index");
$(".paginateGaleria a").removeClass("active");
$(".paginateGaleria a:eq(" + ($idx - 1) + ")").addClass("active");
},
initCallback: function(carousel, state) {
carousel.buttonNext.bind('click', function() {
carousel.startAuto(0);
});
carousel.buttonPrev.bind('click', function() {
carousel.startAuto(0);
});
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
$(".paginateGaleria a").bind("click", function() {
$idx = $(".paginateGaleria a").index($(this));
carousel.scroll(jQuery.jcarousel.intval($idx + 1));
return false;
});
}
});
$('.listHomeDiversao').gridSony({
width: 1000,
height: 480,
columns: 5,
distance: 2,
closedPanelWidth: 10,
closedPanelHeight: 10,
alignType: 'centerCenter',
slideshow: true,
panelProperties:{
0: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
1: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
2: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
3: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
4: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
5: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
6: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
7: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
8: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
9: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
10: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
11: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
12: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
13: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10},
14: {captionWidth: 450, captionHeight: 100, captionTop: 150, captionLeft: 10}
}
});
// $("ul.listTaxMenu li input").click(function(){
// window.location = $(this).parent().find("a").attr("href");
// });
/* Filtros dos produtos */
$("body:not(.static) ul.listTaxMenu li label a").removeAttr("href");
$("body:not(.static) ul.listTaxMenu li input:checkbox").click(function() {
if($('ul.listTaxMenu li input:checked').size() < 1){ return false; }
$(".loadingMenudiversao").show().css('opacity', '0.7').removeClass('hide');
$.ajax({
type: 'POST',
data: $("form.menuDiversao").serialize(),
dataType: "html",
url: $("form.menuDiversao").attr("action"),
success: function(data) {
var response = $('
' + data + '
');
$("section.results .content").html(response.html() + "
");
setTimeout(function(){
$(".loadingMenudiversao").fadeOut(function(){
$(".loadingMenudiversao").addClass("hide");
});
}, 1000);
$cores.doit();
}
});
});
$(".fancy-panoramic").click(function(){
$$ = $(this);
$.fancybox({
width: 960,
height: 600,
title: 'Arraste e solte a imagem para navegar',
href: '#panoramic-image',
centerOnScroll: true,
titleShow: true,
transitionIn: 'elastic',
transitionOut: 'elastic',
easingIn: 'easeOutBack',
easingOut: 'easeInBack',
padding: 0,
showCloseButton: true,
overlayOpacity: 0.7,
overlayColor: '#000000',
onStart:function(){
// $('.panorama-container').append('
')
$('#holderPanorama').append('');
},
onComplete: function(){
$('.panorama-view').sony360({
start_position: 0, // initial start position for the view
//mouse_wheel_multiplier: 5,
bind_resize: false, // determine if window resize affects panorama viewport
is360: false, // glue left and right and make it scrollable
use_preloader: false
});
},
onClosed:function(){
$('#holderPanorama').empty();
// setTimeout(function(){
// //$('#fancybox-wrap').remove(true)
// $('.panorama-view').sony360.stopEvent();
// },2000);
}
});
return false;
});
/* Menu Diversao */
/* Galeria de fotos do produto */
$("ul.navFotosInterna li a").each(function() {
$(this).append('');
}).hover(function() {
$(this).find('span').addClass("hover");
}, function() {
$(this).find('span').removeClass("hover");
}).click(function() {
$strOmniture = $("meta[name='omniture-event']").attr("content") + '|' + $(this).attr('data-omniture-event');
$(".metainfo .cores span").removeClass("active");
if (!$(this).hasClass("hover")) {
$("ul.navFotosInterna li a").removeClass("hover");
$(this).addClass("hover");
$$ = $(this);
$.imgpreload($$.attr("href"), function() {
if ($(this[0]).data('loaded')) {
$(".boxGaleriaFotos .imgProd img").fadeOut(function() {
$(".boxGaleriaFotos .imgProd img").attr("src", $$.attr("href")).fadeIn();
omnEvent($strOmniture);
});
}
});
}
return false;
});
$galeriaFotosInitCallback = function(carousel, state) {
$(".boxInfProd .metainfo .cores span:not(.active)").live("click", function() {
$$ = $(this);
$$.parent().find("span").removeClass("active");
$$.addClass("active");
$idx = $(".boxInfProd .metainfo .cores span").index($(this));
carousel.scroll(jQuery.jcarousel.intval($idx + 1));
$("ul.navFotosInterna").find("li[data-color='" + $(this).attr("data-color") + "'] a").trigger("click");
return false;
});
};
$(".boxGaleriaFotos ul").jcarousel({
scroll: 1,
/*wrap: 'circular',*/
initCallback: $galeriaFotosInitCallback
});
/* Galeria de fotos do produto */
$("#contenBlosPS a.feed").gFeed({
target: '#contenBlosPS',
tabs: true,
max: 2
});
//Aplica target _blank nos links dos posts do Blog da PSN
$('.gfc-results a').live('click', function() {
$(this).attr('target', '_blank');
});
$(".carousel ul").jcarousel({
scroll: 1,
wrap: 'circular'
});
$cores = {
doit: function(){
$(".metainfo .cores").each(function() {
if ($(this).attr("data-color") != "") {
$$ = $(this);
$colors = $(this).attr("data-color").split("|");
$images = $(this).attr("data-image").split("|");
if ($(".boxInfProd").size() > 0) {
for (i = 0; i <= 10; i++) {
if ($colors[i]) {
$$.append('');
} else {
$$.append('');
}
}
} else {
for (i = 3; i >= 0; i--) {
if ($colors[i]) {
$$.append('');
} else {
$$.append('');
}
}
}
}
});
}
};
$cores.doit();
$("article.product .metainfo .cores span:not(.active)").live("click", function() {
$$ = $(this);
$$.parent().find("span").removeClass("active");
$$.addClass("active");
$.imgpreload($$.attr("data-image"), function() {
if ($(this[0]).data('loaded')) {
$$.parents("article.product").find("img").fadeOut(function() {
$$.parents("article.product").find("img").attr("src", $$.attr("data-image")).fadeIn();
});
}
});
});
$("ul.navProduct li a").each(function() {
$(this).append('');
}).hover(function() {
$(this).find('span').addClass("hover");
}, function() {
$(this).find('span').removeClass("hover");
}).click(function() {
$("ul.navProduct li a").removeClass("hover");
$tab = $(this).addClass("hover").attr("href");
$(".tabsProduct .tab").hide();
$(".tabsProduct").find($tab).show();
return false;
});
($("ul.navProduct li a.hover").size() > 0) ? $("ul.navProduct li a.hover").trigger("click") : $("ul.navProduct li:first a").trigger("click");
$("ul.listEntenda li a").each(function() {
$(this).attr("title", $(this).text());
}).click(function() {
$idx = $("ul.listEntenda li a").index($(this));
var target = ($.browser.opera) ? 'html' : 'html,body';
var targetOffset = $(".boxItens .itens .item").eq($idx).offset().top - 28;
$(target).animate({
scrollTop: targetOffset
}, 1000);
return false;
});
$(".boxCompreAqui:first").each(function(){
$this = $(this);
$jsonURL = $(this).attr("data-product");
if($jsonURL != undefined){
$.ajax({
type: 'GET',
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'sonySite',
url: $jsonURL,
success: function(json) {
$.each(json.products, function(){
$('ul.listCompreAqui').append('
');
});
(json.products.length == 0) ? $(".boxCompreAqui").hide() : $(".boxCompreAqui").show();
},
error: function(){
$(".boxCompreAqui").hide();
}
});
}
});
$("select[name='loja_estado']").change(function() {
$("select[name='loja_cidade']").html('');
$requestURL = ($("body").hasClass("static")) ? $("input[name='templateurl']").val() + "/inc/cidades/" + $(this).val() + ".json" : $("form.formLojas").attr("action");
//alert($requestURL);
$.ajax({
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'sonyCidades',
cache: true,
data: $("form.formLojas").serialize(),
url: $requestURL,
success: function(data) {
var list = '';
$.each(data, function(index, itemData) {
list += '';
});
$("select[name='loja_cidade']").html(list);
}
});
});
$("form.formLojas").validate({
errorContainer: $("form.formLojas .msgError"),
errorLabelContainer: $("form.formLojas .msgError"),
submitHandler: function() {
if ($("select[name='loja_cidade']").val()) {
$url = $("form.formLojas input[name='pageurl']").val() + "/onde-comprar/municipio/" + escape($("select[name='loja_cidade']").val());
omnEvent('sony|site|onde-comprar|municipio|' + escape($("select[name='loja_cidade']").val()));
} else {
$url = $("form.formLojas input[name='pageurl']").val() + "/onde-comprar/estado/" + escape($("select[name='loja_estado']").val());
omnEvent('sony|site|onde-comprar|estado|' + escape($("select[name='loja_estado']").val()));
}
window.location = $url;
}
});
$("form.formLogin").validate({
errorContainer: $("form.formLogin .msgError"),
errorLabelContainer: $("form.formLogin .msgLabelError"),
submitHandler: function() {
$("form.formLogin .loading").fadeIn();
$.ajax({
type: 'POST',
data: $("form.formLogin").serialize(),
dataType: "json",
url: $("form.formLogin").attr('action'),
success: function(json) {
$("form.formLogin .loading").fadeOut();
if (json.status == 'error') {
if (json.showCaptcha == '1' && $.cookie('sony_login_captcha') == 'false') {
$.cookie('sony_login_captcha', 'true');
setTimeout(function() {
location.reload(true);
}, 500);
} else {
$.cookie('sony_login_captcha', 'false');
}
if ($(".boxRecaptcha").size() > 0) {
Recaptcha.reload();
}
switch (json.message) {
case 'invalidLogin':
$msg = 'Login inválido. Por favor tente novamente.';
break;
case 'invalidRecaptcha':
$msg = 'Recaptcha inválido.';
break;
case 'accountIsLocked':
$msg = 'Conta bloqueada.';
break;
case 'unexpectedServerError':
$msg = 'Erro no servidor. Por favor tente novamente.';
break;
}
$("form.formLogin .msgError").text($msg).fadeIn().delay(3000).fadeOut();
} else {
window.location = 'http://www.sony.com.br/eletronicos/';
}
}
});
}
});
$("form.formCadastro").validate({
errorContainer: $("form.formCadastro .msgError"),
errorLabelContainer: $("form.formCadastro .msgLabelError"),
submitHandler: function() {
$("form.formCadastro .loading").fadeIn();
$.ajax({
type: 'POST',
data: $("form.formCadastro").serialize(),
dataType: "json",
url: $("form.formCadastro").attr('action'),
success: function(json) {
$("form.formCadastro .loading").fadeOut();
if (json.status == 'error') {
Recaptcha.reload();
switch (json.message) {
case 'invalidLogin':
$msg = 'Login inválido. Por favor tente novamente.';
break;
case 'invalidRecaptcha':
$msg = 'Recaptcha inválido.';
break;
case 'accountIsLocked':
$msg = 'Conta bloqueada.';
break;
case 'unexpectedServerError':
$msg = 'Erro no servidor. Por favor tente novamente.';
break;
}
$("form.formCadastro .msgError").text($msg).fadeIn().delay(3000).fadeOut();
} else {
window.location = 'http://www.sony.com.br/eletronicos/';
}
}
});
}
});
$("form.recupereDados").validate({
errorContainer: $("form.recupereDados .msgError"),
errorLabelContainer: $("form.recupereDados .msgError"),
submitHandler: function() {
$.ajax({
type: 'GET',
data: $("form.recupereDados").serialize(),
dataType: "json",
url: '/process.html',
success: function(json) {
$(".boxRecupereDados .content").hide();
if (json.msg == 'ok') {
$(".boxRecupereDados .mensagemSucesso").fadeIn();
} else {
$(".boxRecupereDados .mensagemErro").fadeIn().delay(3000).fadeOut(function() {
$(".boxRecupereDados .content").fadeIn();
});
}
}
});
}
});
$("#state").change(function() {
$_primitiveStateCode = $(this).val();
$_stateCode = $(this).val();
$("#city").attr("disabled", true).find('option').remove().end();
if ($_stateCode != "") {
$("#city").attr("disabled", true).find('option').remove().end();
$.ajax({
type: 'POST',
dataType: 'json',
url: $(this).attr('data-url'),
data: {
primitiveStateCode: $_primitiveStateCode,
stateCode: $_stateCode
},
success: function(json) {
if (json.status == "ok") {
var options = '';
for (var i = 0; i < json.content.length; i++) {
options += '';
}
$('#city').attr("disabled", false).html(options).show();
} else {
$("#city").attr("disabled", true).find('option').remove().end();
}
}
});
}
});
$(".boxJaPossuo a.open").click(function() {
$(this).next().slideDown();
return false;
});
$("a.btnCloseJaPossuo").click(function() {
$(this).parent().slideUp();
return false;
});
$(".page-template-page-blog-php .datePost").click(function() {
window.location = $(this).next().attr("href");
});
/* Relógio Blog */
setInterval(function(){
var seconds = new Date().getSeconds();
var sdegree = seconds * 6;
var srotate = "rotate(" + sdegree + "deg)";
$("#sec").show().css({ "-moz-transform": srotate, "-webkit-transform": srotate });
}, 1000);
setInterval(function(){
var hours = new Date().getHours();
var mins = new Date().getMinutes();
var hdegree = hours * 30 + (mins / 2);
var hrotate = "rotate(" + hdegree + "deg)";
$("#hour").show().css({ "-moz-transform": hrotate, "-webkit-transform": hrotate });
}, 1000);
setInterval(function(){
var mins = new Date().getMinutes();
var mdegree = mins * 6;
var mrotate = "rotate(" + mdegree + "deg)";
$("#min").show().css({ "-moz-transform": mrotate, "-webkit-transform": mrotate });
}, 1000);
/* Relógio Blog */
$(".boxTimeLine").each(function() {
if ($.cookie('History-Tracker')) {
$produtos = $.cookie('History-Tracker').split("||");
$.each($produtos, function(i, item) {
if (item != '' && (i > 0 && i <= 7)) {
$title = unescape(item.split(':::')[0].replace(/\+/g, " "));
$link = item.split(':::')[1];
$thumb = item.split(':::')[2];
$(".boxTimeLine .inf ul").append('
' + $title + '');
$(".boxTimeLine").show();
}
});
$(".boxTimeLine .inf ul li:last").addClass("last");
}
});
/* Onde comprar */
$(".map").each(function() {
$id = "map" + Math.floor(Math.random() * 1000);
$(this).attr("id", $id);
var myOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("" + $id + ""), myOptions);
var bounds = new google.maps.LatLngBounds();
$(".item .geo").each(function(i) {
$lat = $(this).find("meta[itemprop='latitude']").attr("content");
$lon = $(this).find("meta[itemprop='longitude']").attr("content");
var myLatLng = new google.maps.LatLng($lat, $lon);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
zIndex: i
});
var infowindow = new google.maps.InfoWindow();
infowindow.setContent('' + $(this).parent().html() + '
');
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
if ($(".item .geo").size() > 1) {
bounds.extend(myLatLng);
map.fitBounds(bounds);
} else {
map.setCenter(new google.maps.LatLng($lat, $lon));
map.setZoom(15);
}
});
});
$(".listLojas .item").click(function() {
$id = $(".mapOndeEncontrar").attr("id");
$(".listLojas .item").removeClass("hover");
$(this).addClass("hover");
$lat = $(this).find("meta[itemprop='latitude']").attr("content");
$lon = $(this).find("meta[itemprop='longitude']").attr("content");
var latlng = new google.maps.LatLng($lat, $lon);
var myOptions = {
scaleControl: true,
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("" + $id + ""), myOptions);
map.setCenter(new google.maps.LatLng($lat, $lon));
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
var marker = new google.maps.Marker({
map: map,
position: map.getCenter()
});
var infowindow = new google.maps.InfoWindow();
infowindow.setContent('' + $(this).html() + '
');
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
return false;
});
$(".accordion:not(.disabled) h4").click(function() {
$(".accordion h4").removeClass("hover");
$(".accordion .accor").slideUp();
if ($(this).next().is(":visible")) {
$(this).next().removeClass("hover").slideUp();
} else {
$(this).next().addClass("hover").slideDown(function() {
$(this).find(".item:first").trigger("click");
});
}
});
($(".accordion h4.active").size() > 0) ? $(".accordion h4.active").trigger("click") : $(".accordion:not(.disabled) h4:first").trigger("click");
/* Onde comprar */
/* Filtros dos produtos */
$("body:not(.static) ul.filters li label a").removeAttr("href");
$("body:not(.static) ul.filters li input:checkbox").click(function() {
$("ul.filters li input").removeAttr('disabled');
$.ajax({
type: 'GET',
data: $("form.filters").serialize(),
dataType: "json",
url: $("form.filters").attr("action") + "?callback=?",
success: function(json) {
$("ul.filters li input").removeAttr('disabled').next().removeClass("disabled");
if (json.filterIds != '') {
$("ul.filters li input").attr('disabled', true).next().addClass("disabled");
}
$arr = json.filterIds.split(",");
$.each($arr, function(index, itemData) {
if (itemData != '') {
$("ul.filters li #opt-" + itemData).removeAttr('disabled').next().removeClass("disabled");
}
});
}
});
});
$("form.filters").submit(function() {
$slugs = $("ul.filters li input:checked:not(:disabled)").map(function() {
return $(this).attr('rel');
}).get().join(',');
if ($slugs != '') {
window.location = $("input[name='postTypeLink']").val() + $slugs;
}
return false;
});
/* DEALERS */
/*$(".espalheRedes").each(function() {
comentado para esconder o SHARE dos dealers
$url = $.getUrlVar("urlDealer");
if ($url != undefined) {
$(".espalheRedes").show();
$(".espalheRedes > a").each(function() {
$(this).attr("href", $(this).attr("href").replace("[URL]", $url));
}).click(function() {
var w = 550;
var h = 450;
var left = (screen.availWidth / 2) - (w / 2);
var top = (screen.availHeight / 2) - (h / 2);
window.open($(this).attr("href"), 'sonyShare', 'width=' + w + ', height=' + h + ', top=' + top + ', left=' + left + ', scrollbars=no, toolbar=no');
return false;
});
$(".g-plusone").attr("data-href", $url);
};
});*/
$(".boxListDealers .top h4").click(function() {
$(".boxListDealers .top h4").removeClass("hover");
$(".boxListDealers .accor").slideUp();
if ($(this).parent().next().is(":visible")) {
$(this).parent().next().removeClass("hover").slideUp();
} else {
$(this).parent().next().addClass("hover").slideDown();
}
});
$(".boxListDealers .top").find("a.script").click(function() {
$(this).parent().find("h4").trigger("click");
return false;
});
$("a.demoDealer").click(function() {
$.fancybox({
'width': 700,
'height': 590,
'href': $(this).attr("href") + '?urlDealer=//www.sony.com.br',
'type': 'iframe',
'centerOnScroll': true,
'titleShow': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'easingIn': 'easeOutBack',
'easingOut': 'easeInBack',
'padding': 0,
'showCloseButton': true,
'overlayOpacity': 0.7,
'overlayColor': '#000000'
});
return false;
});
/* DEALERS */
$("a.btnChangePassword").live("click", function() {
$(this).addClass("active").text("Manter senha atual");
$(".boxSenha .item").fadeIn().find("input").removeClass("error").addClass("required").val("");
return false;
});
$("a.btnChangePassword.active").live("click", function() {
$(this).removeClass("active").text("Alterar minha senha");
$(".boxSenha .item").fadeOut().find("input").removeClass("error").removeClass("required").val("");
$(".msgError").fadeOut();
return false;
});
$(".embedFlash").each(function() {
$src = $(this).attr("rel").split("|")[0];
$width = $(this).attr("rel").split("|")[1];
$height = $(this).attr("rel").split("|")[2];
$(this).flash({
src: $src,
width: $width,
height: $height,
wmode: 'transparent'
}, {
version: 10
});
});
$("ul.listFlash360 li").each(function(i){
$flashId = $(this).data("flashId");
$colorName = $(this).data("colorName");
$colorHexa = $(this).data("colorHexa");
$("ul.listNav360").append(''+ $colorName +'');
});
$("ul.listNav360 li a").live("click", function(){
$id = $(this).attr("href").split("#")[1];
$("ul.listFlash360 li").removeClass("show");
$("ul.listFlash360 li[data-flash-id='"+ $id +"']").hide().addClass("show").fadeIn();
return false;
});
$("ul.listNav360 li:first a").trigger("click");
$("input + label:not([for])").click(function() {
if ($(this).prev().attr("type") == 'checkbox') {
($(this).prev().is(":checked")) ? $(this).prev().attr("checked", false) : $(this).prev().attr("checked", true);
} else {
$(this).prev().attr("checked", true);
}
});
$(".popAskSony, .popChatOnline").click(function() {
var w = 460;
var h = 500;
var left = (screen.availWidth / 2) - (w / 2);
var top = (screen.availHeight / 2) - (h / 2);
settings = 'width=' + w + ',height=' + h + ',top=' + top + ',left=' + left + ',scrollbars=no,toolbar=no';
window.open($(this).attr("href"), 'popAskSony', settings);
return false;
});
$(".videoHome").click(function() {
$(this).embedYoutube(true);
});
$(".video").embedYoutube();
$(".cpf").mask("999.999.999-99");
$(".cep").mask("99999-999");
$(".tel").mask("(99) 9999-9999");
$(".date").mask("99/99/9999");
$("footer .content .box").equalHeight();
$(".content .equalCol").equalHeight();
$("a[href*='//']:not([href*='" + location.hostname + "']):not([target])").attr("target", "_blank");
/* OMNITURE TRACK */
$("[data-omniture-track]").live("click", function() {
$v = $(this).attr('data-omniture-track');
$s1 = $("meta[name='omniture-track']").attr("s1") + ':' + $v;
$s2 = $("meta[name='omniture-track']").attr("s2");
$s3 = $("meta[name='omniture-track']").attr("s3") + '|' + $v;
track($s1, $s2, $s3);
});
$("[data-omniture-event]").live("click", function() {
$str = $("meta[name='omniture-event']").attr("content") + '|' + $(this).attr('data-omniture-event');
omnEvent($str);
});
$(".navProduct a[data-omniture-track]").click(function() {
$v = $(this).attr('data-omniture-track');
$s1 = $("meta[name='omniture-track']").attr("s1") + ':' + $v;
$s2 = $("meta[name='omniture-track']").attr("s2");
$s3 = $("meta[name='omniture-track']").attr("s3") + '|' + $v;
track($s1, $s2, $s3);
});
/* OMNITURE TRACK */
/* DQ&A */
$("[data-doubleclick]").live("click", function() {
var axel = Math.random() + "";
var a = axel * 10000000000000;
$src = $(this).attr('data-doubleclick').split("|")[0];
$type = $(this).attr('data-doubleclick').split("|")[1];
$cat = $(this).attr('data-doubleclick').split("|")[2];
$u3 = $(this).attr('data-doubleclick').split("|")[3];
$.getScript('//fls.doubleclick.net/activityi;src='+ $src +';type='+ $type +';cat='+ $cat + (($u3 != '') ? ';u3=' + $u3: '') + ';ord=' + a + '?');
});
/* DQ&A */
/* EXECUTA O BOTÃO PLUSONE */
gapi.plusone.go();
});
(function($) {
$.cookie = function(key, value, options) {
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
options = jQuery.extend({}, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires,
t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
return (document.cookie = [
encodeURIComponent(key), '=', options.raw ? String(value) : encodeURIComponent(String(value)), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : ''].join(''));
}
options = value || {};
var result, decode = options.raw ?
function(s) {
return s;
} : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
$.extend({
getUrlVars: function() {
var vars = [],
hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name) {
return $.getUrlVars()[name];
},
pageTracker: function(slug) {
return (slug != '') ? _gaq.push(['_trackPageview', slug]) : _gaq.push(['_trackPageview']);
}
});
$.fn.extend({
equalHeight: function() {
var height = 0;
var maxHeight = 0;
this.each(function() {
height = $(this).outerHeight();
maxHeight = (height > maxHeight) ? height : maxHeight;
});
return this.each(function() {
var t = $(this);
var minHeight = maxHeight - (t.outerHeight() - t.height());
var property = $.browser.msie && $.browser.version < 7 ? 'height' : 'min-height';
t.css(property, minHeight + 'px');
});
},
embedYoutube: function(autoplay) {
return this.each(function() {
$urlVideo = $(this).find("a").attr("href");
$urlVideo = $urlVideo.replace(new RegExp("watch\\?v=", "i"), 'index-3.html');
$(this).empty().append('');
});
},
tweetButton: function() {
return this.each(function() {
$("a.twitter-share-button").each(function() {
$tweetURL = ($(this).attr('data-url')) ? $(this).attr('data-url') : window.location.href;
$tweetText = ($(this).attr('data-text')) ? $(this).attr('data-text') : (($("meta[name='tweet:text']").attr("content")) ? $("meta[name='tweet:text']").attr("content") : 'Confira o site da cerveja Skol e tenha acesso a um mundo de informações, promoções, baladas, músicas e muito mais. #skol');
$(this).attr("href", '//twitter.com/share?text=' + encodeURIComponent($tweetText) + '&lang=pt&url=' + $tweetURL);
}).click(function() {
var w = 550;
var h = 450;
var left = (screen.availWidth / 2) - (w / 2);
var top = (screen.availHeight / 2) - (h / 2);
settings = 'width=' + w + ',height=' + h + ',top=' + top + ',left=' + left + ',scrollbars=no,toolbar=no';
window.open($(this).attr("href"), 'Twitter', settings);
return false;
});
});
}
});
$.strToSlug = function(string) {
var accents = "àáäâãèéëêìíïîòóöôùúüûñç·/_,:;";
var without = "aaaaaeeeeiiiioooouuuunc------";
return string.toLowerCase().replace(
new RegExp('[' + accents + ']', 'g'), function(c) {
return without.charAt(accents.indexOf(c));
}).replace(/[^a-z0-9]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
};
$.validator.addMethod("cpf", function(value, element) {
cpf = value.toString().replace(/\_|\.|\-/g, "");
if (cpf != "") {
var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
if (cpf.length != 11 || cpf.match(expReg)) {
return false;
}
add = 0;
for (i = 0; i < 9; i++) {
add += parseInt(cpf.charAt(i)) * (10 - i);
}
rev = 11 - (add % 11);
if (rev == 10 || rev == 11) {
rev = 0;
}
if (rev != parseInt(cpf.charAt(9))) {
return false;
}
add = 0;
for (i = 0; i < 10; i++) {
add += parseInt(cpf.charAt(i)) * (11 - i);
}
rev = 11 - (add % 11);
if (rev == 10 || rev == 11) {
rev = 0;
}
if (rev != parseInt(cpf.charAt(10))) {
return false;
}
}
return true;
}, "Informe um CPF válido.");
$.validator.addMethod("date", function(value, element) {
if (value.length != 10) return false;
var data = value;
var dia = data.substr(0, 2);
var barra1 = data.substr(2, 1);
var mes = data.substr(3, 2);
var barra2 = data.substr(5, 1);
var ano = data.substr(6, 4);
if (data.length != 10 || barra1 != "/" || barra2 != "/" || isNaN(dia) || isNaN(mes) || isNaN(ano) || dia > 31 || mes > 12) return false;
if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && dia == 31) return false;
if (mes == 2 && (dia > 29 || (dia == 29 && ano % 4 != 0))) return false;
if (ano < 1900) return false;
return true;
}, "Informe uma data válida");
$.validator.addMethod("passwordsony", function(value, element) {
var characterRegex = /^[A-Za-z0-9%&?]{8,15}$/;
var assertionRegex = /^.*(?=.{8,15})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[%&?]).*$/;
if (!characterRegex.test(value) || !assertionRegex.test(value)) {
return false;
}
return true;
}, "Senha inválida. Sua senha deve conter:\n1. Letras maiúsculas e minúsculas\n2. Letras e números\n3. No mínimo 8 caracteres\n4. No máximo 15 caracteres\n5. No mínimo um dos seguintes caracteres especiais (%&?)");
})(jQuery);
(function($) {
/*if (!window.google) {
alert('You must include the Google AJAX Feed API script');
return;
}
if (!google.feeds) google.load("feeds", "1");*/
$.fn.gFeed = function(options) {
var opts = jQuery.extend({
target: this,
max: 5
}, options || {});
var g = new google.feeds.FeedControl();
this.each(function() {
var url = this.href || opts.url;
var title = opts.title || this.title || $(this).text();
g.addFeed(url, title);
g.setNumEntries(opts.max);
});
$(opts.target).each(function() {
g.draw(this, opts.tabs ? {
drawMode: google.feeds.FeedControl.DRAW_MODE_TABBED
} : null);
});
return this;
};
})(jQuery);
/* v1.3 */
/* https://github.com/farinspace/jquery.imgpreload */
if("undefined"!=typeof jQuery){(function(a){a.imgpreload=function(b,c){c=a.extend({},a.fn.imgpreload.defaults,c instanceof Function?{all:c}:c);if("string"==typeof b){b=new Array(b)}var d=new Array;a.each(b,function(e,f){var g=new Image;var h=f;var i=g;if("string"!=typeof f){h=a(f).attr("src");i=f}a(g).bind("load error",function(e){d.push(i);a.data(i,"loaded","error"==e.type?false:true);if(c.each instanceof Function){c.each.call(i)}if(d.length>=b.length&&c.all instanceof Function){c.all.call(d)}});g.src=h})};a.fn.imgpreload=function(b){a.imgpreload(this,b);return this};a.fn.imgpreload.defaults={each:null,all:null}})(jQuery)}
function omnEvent($str) {
s.tl(true, 'o', $str);
};
function handleSpeechInput(value){
$("#searchform").submit();
};
function ga(slug){
_gaq.push(['_trackPageview', slug]);
};
function plusone_vote(obj){
$str = $("meta[name='omniture-event']").attr("content") + '|plus1';
omnEvent($str);
};
function omnFacebook(act){
$str = $("meta[name='omniture-event']").attr("content") + '|' + act;
omnEvent($str);
};
function omn360(str){
$str = $("meta[name='omniture-event']").attr("content") + '|' + str;
omnEvent($str);
};