var _VOTA = "Vota: ";var _VOTA2 = "Hai già votato per questo prodotto";var _VOTA_GRAZIE = "Grazie per aver votato!";var _REWIND = "Indietro";var _SCHD_FORM = "/inc/img/sfnd/schd_form_sfnd2.jpg";var _FORWARD = "Avanti";var _REWIND = "Indietro";var ovt = null;
function nl2br(text){
var text = escape(text);
if(text.indexOf('%0D%0A') > -1){
var re_nlchar = /%0D%0A/g ;
}else if(text.indexOf('%0A') > -1){
var re_nlchar = /%0A/g ;
}else if(text.indexOf('%0D') > -1){
var re_nlchar = /%0D/g ;
}
return unescape( text.replace(re_nlchar,' ') );
}
function immins(){
var lingua = arguments[0];
var numero = arguments[1];
var filtro = arguments[2];
var valore = arguments[3];
if(window.location.href.split('/').getLast().substr(0,7) != 'sel.php'){
window.location = 'catalogue/sel.php?gender='+value;
}
if(!filtro) filtro = 0;
if(!valore && valore != 0) valore = -1;
var url = '/www-grp/catalogue/paging.php?l='+lingua+'&i='+numero+'&filter='+filtro+'&value='+valore;
var req = new Json.Remote(url, {
onComplete: function(jsonObj) {
printBrand(jsonObj.brands);
if($('sel_frc1')){
$('sel_frc1').empty();
}
if($('sel_num')){
$('sel_num').empty();
}
if($('sel_frc2')){
$('sel_frc2').empty();
}
var npage = jsonObj.nmax.npage;
if(npage == 0){
if($('sel_nav')){
$('sel_nav').setStyle('display','none');
}
}
var n_p_a = numero;
var n_p_b = numero;
if(n_p_a < (npage-1)) { n_p_a = numero + 1;}
else { n_p_a = npage; }
if(n_p_b > 0) {n_p_b = numero -1;}
else { n_p_b = numero;}
//Tasto Indietro
if($('sel_frc1')){
var indietro = new Element('a').injectInside('sel_frc1');
indietro.addEvent('click', function(e){
var ev2 = new Event(e).stop();
immins(lingua,n_p_b,filtro,valore);
});
var imm_ind = new Element('img').setProperties({
'src':'/inc/img/tp_mb/sel_frcsx.jpg',
'alt':_REWIND,
'title':_REWIND
}).injectInside(indietro);
}
//Numero di Pagina
var cont = new Element('p').setHTML(' '+(n_p_a)+' - '+npage+' ').injectInside('sel_num');
var av = n_p_a;
if(n_p_a < (npage)) { av = n_p_a;}
else {av = (n_p_a-1);}
//Tasto Avanti
if($('sel_frc2')){
var avanti = new Element('a').injectInside('sel_frc2');
avanti.addEvent('click', function(e){
var ev2 = new Event(e).stop();
immins(lingua,av,filtro,valore);
});
var imm_ava = new Element('img').setProperties({
'src':'/inc/img/tp_mb/sel_frcdx.jpg',
'alt':_FORWARD,
'title':_FORWARD
}).injectInside(avanti);
}
}
}).send();
}
function printBrand(tot){
var i = 1;
$$('div.sel_thumbimg').empty();
$$('div.sel_thumbdscr').empty();
tot.each(function(ele) {
if($('div_thumb_img'+i) && $('div_thumb_dscr'+i)){
var target_img = $('div_thumb_img'+i);
target_img.empty();
var target_desc = $('div_thumb_dscr'+i);
target_desc.empty();
var link_img = new Element('a').setProperties({
'href' : '/brand/'+ele.bid,
'id' : 'link_img'+i
}).injectInside(target_img);
var img = new Element('img').setProperties({
'src' : '/images/'+ele.bid+'/common/logo.png',
'alt' : (ele.brand),
'title' : (ele.brand),
'longdesc' : ele.story
}).setStyles({
'width' : '95px',
'height' : '95px'
}).injectInside(link_img);
var link_nome = new Element('a').setHTML((ele.brand)).setProperties({
'href' : '/brand/'+ele.bid
}).injectInside(target_desc);
}
i++;
});
if(i<10){
while(i<=10){
$('div_thumb_dscr'+i).empty();
i++;
}
}
}
function goToBrand(id){ //tendina di ricerca brand
window.location = '/brand/'+id;
}
function filterCat(lang,id){ //filtra la tendina dei subgeneri in base alla categoria
$('subgenre_sel').empty();
if(id=='dis') { $('subgenre_sel').setProperty('disabled','disabled'); $('subgenre_sel').empty(); return;}
new Element('option').setHTML(' - ').injectInside('subgenre_sel');
var n = Object.toQueryString({filter: id, mode: 1, lingua:lang});
var url = '/inc/filter.php?'+n;
var request = new Json.Remote(url, {
onComplete: function(risposta) {
(risposta.subs).each(function(sub){
new Element('option').setProperty('value',id+'-'+sub.id).setHTML(sub.title).injectInside('subgenre_sel');
});
$('subgenre_sel').setProperty('disabled','');
}
}).send();
}
function filterSub(id){
window.location = '/www-grp/corporate/corporate.php?ss=25&ssu=48&filter='+id;
}
function filterSex(lang,id){
immins(lang,0,'gender',id);
}
//tasto apertura/chiusura strumenti di supporto
function closerb(divo,tasto,freccia){
if($(divo)){
var mySlide = new Fx.Slide(divo,{
transition: Fx.Transitions.Quad.easeOut,
duration: 750
});
mySlide.hide();
$(divo).setStyle('visibility', 'hidden');
if($(tasto)){
$(tasto).addEvent('click', function(e){
var ev2 = new Event(e).stop();
if($(divo).getStyle('visibility')=='hidden'){
mySlide.slideIn();
$(freccia).setProperties({'src':'/inc/img/menus/tools_frc2.gif'});
$(divo).setStyle('visibility', 'visible');
} else {
mySlide.slideOut();
$(freccia).setProperties({'src':'/inc/img/menus/tools_frc1.gif'});
$(divo).setStyle('visibility', 'hidden');
}
});
}
}
}
//funzione per personalizzare brand e scheda
function pBrand(id,bg,mode){
var corpo = $$('body')[0];
if(corpo){
corpo.setStyle('background','#'+bg+' url(/images/'+id+'/common/sfondo.jpg) no-repeat top center');
}
if(mode == 0){
$('br_pg').setStyle('background','transparent url(/images/'+id+'/common/brand_sfondo.jpg) no-repeat top center');
} else if(mode == 1){
$('schd_cnt').setStyle('background','transparent url(/images/'+id+'/common/scheda_sfondo.jpg) no-repeat top center');
}
}
//scheda.php
/******************************
function populateScheda();
bid = id del brand (INT)
cat = id della categoria (INT)
sub = id del sotto genere (INT)
*******************************/
function populateScheda(bid,cat,sub,urlo){
//stampo il menu dei prodotti
var n = Object.toQueryString({'bid': bid, 'cat': cat, 'sub': sub, 'mode': 1});
var url = '/inc/getScheda.php?'+n;
new Json.Remote(url,{
autocancel: true,
onComplete: function(jsonObj){
$('schd_dscr').empty(); //svuoto il div che contiene l'elenco dei prodotti.
$('schd_story').getElement('p').empty(); //svuoto il div che contiene la storia del prodotto attivo.
$('schd_dxdscr').getElement('p').empty(); //svuoto il div che contiene la storia della variante
$('ulc').empty(); //svuoto la lista che contiene le thumbs delle varianti
$('schd_varnt').getElement('p').empty(); //svuoto il div che contiene il titolo della variante
var menu_item = '';
(jsonObj.dati.menu).each(function(menu){
menu_item += ''+menu.name_cat+' '; //voci del menu
});
$('schd_dscr').setHTML('
'+menu_item+'
');
if(jsonObj.dati.menu.length > 6){
$('scr_ele_prod').show();
new MooScroller($('schd_dscr'), $('scrollKnob'), {
scrollLinks: {
forward: $('scrollForward'),
back: $('scrollBack')
}
});
} else {
$('scr_ele_prod').hide();
}
(jsonObj.dati.fprod).each(function(fprod){
if($('prod_code')){
$('prod_code').setHTML(fprod.code);
}
$('schd_logo').getElement('img').setProperties({
'src' : '/inc/img/loghi/scheda/'+fprod.did+'.jpg',
'alt' : fprod.distributor,
'title' : fprod.distributor
});
if(fprod.text_cat){
$('schd_story').getElement('p').setHTML(nl2br(fprod.text_cat.clean())); //stampa la storia della prima referenza
if((fprod.text_cat).length > 200){
$('temp_scroll').show();
new MooScroller($('schd_story'), $('scrollKnob2'), {
scrollLinks: {
forward: $('scrollForward2'),
back: $('scrollBack2')
}
});
} else {
$('temp_scroll').hide();
}
}
var ele = '';
var get_first_var = true;
(jsonObj.dati.varianti).each(function(variante){
ele = ele + '
';
if(get_first_var){
changeVariante(bid,fprod.id,fprod.code,variante.id);
get_first_var = false;
}
});
$('ulc').setHTML(ele);
if(jsonObj.dati.varianti.length > 12){
$('scrollLeft').show();
$('scrollRight').show();
new IconMenu({
container: $('ulc'),
images: $$('#userHistoryBar img')
});
} else {
$('scrollLeft').hide();
$('scrollRight').hide();
}
});
(jsonObj.dati.bdata).each(function(dbrand){
if(dbrand.url){ // inizio tasto minimondo
$('minimondo_href').setProperty('href',dbrand.url).show();
$('minimondo_img').setProperties({
alt : 'minimondo '+dbrand.brand,
title: 'minimondo '+dbrand.brand
});
} else {
$('minimondo_href').hide();
}
if(dbrand.conc){ //inizio tasto concorso
$('concorso_href').setProperty('href','/www-grp/catalogue/concorsi.php?conc='+dbrand.conc).show();
$('concorso_img').setProperties({
alt : 'concorso '+dbrand.brand,
title: 'concorso '+dbrand.brand
});
} else {
$('concorso_href').hide();
}
if(dbrand.spot && (dbrand.spot).length > 5){ //imposto il div dello spot
$('schd_spot').setHTML('');
$('spot_img').show();
} else {
$('spot_img').hide();
}
pBrand(jsonObj.dati.bid_bg,dbrand.bg_hex,1)
});
}
}).send();
}
/******************************
function changeScheda();
bid = id del brand (INT)
cat = id della categoria (INT)
sub = id del sotto genere (INT)
pid = id del prodotto (INT)
*******************************/
function changeScheda(bid,cat,sub,pid,urlo){
var n = Object.toQueryString({bid: bid, cat: cat, sub: sub, pid: pid, mode: 2});
var url = '/inc/getScheda.php?'+n;
new Json.Remote(url,{
autocancel: true,
onComplete: function(jsonObj){
$('schd_story').getElement('p').empty();
$('ulc').empty();
$$('div.hided').hide();
$('schd_img').show();
(jsonObj.dati.fprod).each(function(fprod){
if($('prod_code')){
$('prod_code').setHTML(fprod.code);
}
$('schd_logo').getElement('img').setProperties({
'src' : '/inc/img/loghi/scheda/'+fprod.did+'.jpg',
'alt' : fprod.distributor,
'title' : fprod.distributor
});
if(fprod.text_cat){ //DESCRIZIONE DEL PRODOTTO!
$('schd_story').getElement('p').setHTML(nl2br(fprod.text_cat.clean())); //stampa la storia della prodotto
if((fprod.text_cat).length > 200){
$('temp_scroll').show();
new MooScroller($('schd_story'), $('scrollKnob2'), {
scrollLinks: {
forward: $('scrollForward2'),
back: $('scrollBack2')
}
});
} else {
$('temp_scroll').hide();
}
}
var get_first_var = true;
var ele = '';
(jsonObj.dati.varianti).each(function(variante){
ele = ele + '
';
if(get_first_var){
changeVariante(bid,fprod.id,fprod.code,variante.id);
get_first_var = false;
}
});
$('ulc').setHTML(ele);
if(jsonObj.dati.varianti.length > 12){
$('scrollLeft').show();
$('scrollRight').show();
new IconMenu({
container: $('ulc'),
images: $$('#userHistoryBar img')
});
} else {
$('scrollLeft').hide();
$('scrollRight').hide();
}
if(jsonObj.dati.fprod[0].flv != false){ //spot del singolo prodotto (FLV)
$('schd_spot').setHTML('');
$('spot_img').show();
} else if(jsonObj.dati.fprod[0].spot != null){ //spot del singolo prodotto (YOUTUBE)
$('schd_spot').setHTML('');
$('spot_img').show();
} else if(jsonObj.dati.fprod[0].b_spot != null){ //spot del brand
$('schd_spot').setHTML('');
$('spot_img').show();
} else {
$('spot_img').hide();
}
});
}
}).send();
}
/******************************
function changeVariante();
bid = id del brand (INT)
pid = id del prodotto (INT)
code = codice del prodotto (CHAR)
vid = id della variante
*******************************/
function changeVariante(bid,pid,code,vid){
var n = Object.toQueryString({vid: vid, mode: 3});
var url = '/inc/getScheda.php?'+n;
new Json.Remote(url, {
autocancel: true,
onComplete: function(jsonObj){
$('schd_varnt').getElement('p').empty(); //svuoto il div che contiene il titolo della variante
ovt = new OverText($$('#commento_form input[type!=hidden]'));
$$('div.hided').hide();
$('schd_img').show();
$('schd_dxdscr').getElement('p').empty();
$('vid_rating').setProperty('value',vid);
$('vid_comment').setProperty('value',vid);
$('rating_1').show();
var copyright = '';
(jsonObj.dati.variante).each(function(variante){
copyright = variante.cp;
document.title = variante.title;
$('schd_varnt').getElement('p').setHTML(variante.title);
if(variante.text){
$('schd_dxdscr').getElement('p').setHTML(nl2br(variante.text.clean()));
if((variante.text).length > 300){
$('temp_scroll2').show();
new MooScroller($('schd_dxdscr'), $('scrollKnob3'), {
scrollLinks: {
forward: $('scrollForward3'),
back: $('scrollBack3')
}
});
} else {
$('temp_scroll2').hide();
}
}
$('schd_img').getElement('img').setProperties({
'src' : '/inc/photo.php?bid='+bid+'&vid='+vid+'&mode=0&code='+code+'&w=250',
'alt' : variante.title,
'title' : variante.title
});
$('link_zoom').setProperties({
'href' : '/images/'+bid+'/prod/'+code+'/'+code+'_'+vid+'.jpg',
'title' : copyright
});
if(variante.shop_url){
$('link_buy').setProperty('href', variante.shop_url);
$('link_buy').getParent().show();
} else {
$('link_buy').getParent().hide();
}
if(variante.game_url){
$('gioca_img').getParent().setProperty('href', variante.game_url);
$('gioca_img').show();
} else {
$('gioca_img').hide();
}
new Lightbox({
anchors: $$('a[rel=lightbox_scheda]'),
zIndex : 100
});
getRatingVar(vid); //creo le stelle
$('schd_comments').setProperty('rel',jsonObj.dati.num_comments);
if(jsonObj.dati.num_comments>0){
$$('a.schd_form_leggi').show();
getComment(0,vid,jsonObj.dati.num_comments);
} else {
$$('a.schd_form_leggi').hide();
}
ovt.repositionAll();
});
}
}).send();
}
/****************
Area Corporate
****************/
function corporate(n,t,l){
var q = Object.toQueryString({p: n});
var url = '/www-grp/corporate/corporate.php?'+q;
var divo = $('crprt_cnt');
cambiaTesto(3);
$('print_ref').setProperties({
'href' : '/www-grp/corporate/print.php?id='+n,
'target' : '_blank'
})
new Ajax(url, {
method: 'get',
evalScripts: true,
update: divo,
onComplete: function(){
new Asset.image('/www-grp/corporate/img/tp/'+n+'_'+l+'.jpg', {id: 'tit_pag', title: t}).injectTop(divo);
var path = $('ppath');
if($('temp_path')){
$('temp_path').setHTML(' › '+t);
} else {
var ti = new Element('txt').setProperties({'id':'temp_path'}).setHTML(' › '+t).injectInside(path);
}
document.title = t;
}
}).request();
}
function corporate_popup(n,t,arg,id){
window.location = '/www-grp/corporate/popup_controller.php?link='+n+'&'+arg;
}
//Usato nel popup
function mostra(id){
$$('.hided').each(function(hid){
hid.hide();
});
$(id).show();
}
function cambiaClasse(ele,classe,mode){
if(!mode){mode=0;}
if(mode == 0){
var menu = $$('ul#crprt_menup li.sel, li.opn_sel');
} else if (mode == 1){
var menu = $$('ul#crprt_menup li');
}
menu.each(function(li){
if(li.hasClass('sel')){
li.setProperties({
'class':''
});
} else if(li.hasClass('opn_sel')){
li.setProperties({
'class':'opn'
});
}
});
if($(ele)){
$(ele).setProperties({
'class':classe
});
}
}
function cambiaTesto(modo){
var obb = $$('div#container');
var testo = $$('p');
if(modo==1){
if(Cookie.get("font-size") == '13px'){
obb.setStyle('font-size','');
Cookie.set("font-size", '');
} else {
obb.setStyle('font-size','13px');
Cookie.set("font-size", '13px');
}
} else if (modo==2){
if(Cookie.get("color") == 'black'){
testo.setStyle('color','');
Cookie.set("color", '');
} else {
testo.setStyle('color','black');
Cookie.set("color", 'black');
}
} else if (modo==3){
if(Cookie.get("font-size") == ''){
obb.setStyle('font-size','');
} else if(Cookie.get("font-size") == '13px'){
obb.setStyle('font-size','13px');
}
if(Cookie.get("color") == ''){
testo.setStyle('color','');
} else if (Cookie.get("color") == 'black'){
testo.setStyle('color','black');
}
}
}
/********************
Rating delle schede
********************/
function displayHover(ratingId,vid,star){
for(var i = 0; i <= star; i++){
$('star_'+ratingId+vid+'_'+i).setAttribute('src', '/inc/img/rating/rating_over.gif');
}
}
function displayNormal(ratingId,vid,star){
for(var i = 0; i <= star; i++){
var status = $('star_'+ratingId+vid+'_'+i).className;
$('star_'+ratingId+vid+'_'+i).setAttribute('src', '/inc/img/rating/rating_'+status+'.gif');
}
}
function submitRating(evt){
var tmp = new Event(evt).target.getAttribute('id').substr(5);
var ratingId = tmp.substr(0,1);
var widgetId = tmp.substr(1, (tmp.indexOf('_')-1));
var starNbr = tmp.substr(tmp.indexOf('_')+1).toInt();
$('rating_comment').setProperty('value',(starNbr+1));
for(var i=0;i<=starNbr;i++){
$('star_'+ratingId+widgetId+'_'+i).removeClass('off').addClass('on');
}
for(i=starNbr+1;i<5;i++){
$('star_'+ratingId+widgetId+'_'+i).removeClass('on').addClass('off');
}
displayNormal(ratingId,widgetId,4);
}
function displayNormal(ratingId,vid, star){
for (var i = 0; i <= star; i++){
var status = $('star_'+ratingId+vid+'_'+i).className;
$('star_'+ratingId+vid+'_'+i).setAttribute('src', '/inc/img/rating/rating_'+status+'.gif');
}
}
function displayClick(ratingId,vid,star){
for(i=0;i<=star;i++){
$('star_'+ratingId+vid+'_'+i).className = 'on';
}
for(i=star+1;i<5;i++){
$('star_'+ratingId+vid+'_'+i).className = 'off';
}
displayNormal(ratingId,vid,5-1);
}
function getRatingVar(vid){
var n = Object.toQueryString({'m':0, 'vid': vid});
var url = '/inc/rating.php?'+n;
var star = $('stelle_din');
star.empty();
var request = new Ajax(url, {
autocancel: true,
method : 'GET',
onComplete: function(res) {
var images = new Array();
var min_img = 5 - res.toInt();
for(i = 0; i < res; i++){
images.include(new Element('img',{'src':'/inc/img/rating/rating_on.gif', 'alt':''}));
}
while(min_img != 0){
images.include(new Element('img',{'src':'/inc/img/rating/rating_off.gif', 'alt':''}));
min_img--;
}
images.each(function(img){
img.injectInside(star);
});
}
}).request();
}
function setRating(vid,value){
var n = Object.toQueryString({'m' : 2, 'vid': vid, 'val': value});
var myAjax = new Ajax('/inc/rating.php?'+n).request();
if($('vid_rating_star_1')){
$('vid_rating_star_1').setHTML('
'+_VOTA_GRAZIE+'
');
}
Cookie.set(vid, "1", {duration: 1});
}
/*****************************
Fine del rating delle schede
*****************************/
/*RICERCA*/
function ls(query){ //Usata nel footer, ricerca LIVE
var query = query;
if(query.length < 3){
$('gbl_livesearch').hide();
} else {
var q = Object.toQueryString({s: query});
var req = new Ajax('/inc/live_search.php?'+q,{
evalScripts: true,
method:'GET',
autoCancel: true,
update:$('gbl_livesearch'),
onComplete : function(){
$('gbl_livesearch').show();
}
});
req.request.delay(500, req);
}
}
/* COMMENTI */
var div_temp;
function saveComment(){
var url = '/inc/rating.php?m=3';
var div_comm = $('commento_table');
new Ajax(url,{
method: 'post',
data: $('commento_form'),
onComplete: function(res){
$$('#commento_form input[type!=hidden]').each(function(div){
if(div.getNext() && div.getNext().id != 'commento_leggi'){
div.setProperty('alt',div.getNext().getText());
}
});
$$('.overTxtDiv').each(function(fiv){
fiv.remove();
});
$$('.overTxtSetup').each(function(fiv){
fiv.removeClass('overTxtSetup');
});
var inn = div_comm.innerHTML;
div_temp = inn;
res = res.split(',');
if(res[0] == 1){
$('commento_form').hide();
$('stelle_voto').hide();
$('schd_form').setStyles({
'background-color': 'transparent',
'background-image': 'url('+_SCHD_FORM+')',
'background-repeat': 'no-repeat',
'background-position': 'top center'
});
} else {
var testo = '