debug = { enabled:true, obj:null, initialize: function() { if(debug.obj == null) { debug.obj = $('<div></div>'); debug.obj.appendTo(document.body); debug.obj.css('position', 'absolute').css('z-index', '1000').css('top', '0').css('overflow', 'visible').css('backgroundColor', '#FFF').css('padding', '6px').css('color', '#000').css('fontFamily', 'Courier New').css('fontSize', '11px').css('opacity', 0.60); var close = $('<div>[X]</div>'); debug.obj.append(close); close.css('cursor', 'pointer'); close.bind('click', function(){debug.clear();}); } }, show: function(msg) { if(!debug.enabled || !debug.isDev()) return; debug.initialize(); debug.obj.append($('<div>' + msg + '</div>')); }, clear: function() { if(debug.obj != null) { debug.obj.remove(); debug.obj = null; } }, isDev: function() { return (document.URL.toLowerCase().indexOf('http://localhost/') == 0);
} }; var baseFilesFolder = '/public/CMS/Files/'; var ajaxPage = '/AJAX.aspx'; var htmlObjs = new Object(); var bgImage = null; var images_rotator = null; var company = null; var settings = new Object(); settings.animLength = 1000; settings.animFast = 200; settings.bg = new Object(); settings.bg.opacityOff = 0.2; settings.bg.opacityOn = 1.0; settings.bg.animLength = 1000; settings.bg.animFast = 200; settings.videoProjectorPath = '/swf/FlashMedia'; $(function(){ var loading = $('div#loading'); if(loading.length != 0) loading.hide().bind("ajaxStart", function(){ $(this).fadeIn(); }).bind("ajaxComplete", function(){ { $(this).fadeOut(); } }); $('.logo, .products_gallery_logo').bind('click', function(){document.location = env.applicationPath + '/';}); }); function SetSelected(context, obj) { $('*.selected', context).toggleClass('selected', false); if(obj) obj.toggleClass('selected', true); }; function OpenWindow(targetURL, width, height) { var init_width = (width != null)?width:840; var init_height = (height != null)?height:600; var init_left = Math.floor((screen.availWidth - init_width)/2); var init_top = Math.floor((screen.availHeight - init_height)/2); var newWin = window.open(targetURL, '_new', 'width=' + init_width + ',height=' + init_height + ',top=' + init_top + ',left=' + init_left + ',resizable=yes,scrollbars=yes'); if (window.focus) newWin.focus(); return newWin; }; function OpenWindowImagePrint(cmsImage, width, height) { var init_width = (width != null)?width:840; var init_height = (height != null)?height:600; var init_left = Math.floor((screen.availWidth - init_width)/2); var init_top = Math.floor((screen.availHeight - init_height)/2); var imageUrl = env.applicationPath + '/public/CMS/Files/' + cmsImage.IDnode + '/' + cmsImage.fileName; var newWin = window.open('', '_new', 'width=' + init_width + ',height=' + init_height + ',top=' + init_top + ',left=' + init_left + ',resizable=yes,scrollbars=yes'); newWin.document.open(); newWin.document.writeln('<html><body onload="window.print();"><img src="' + imageUrl + '" /></body></html>'); newWin.document.close(); return newWin; }; function CMSImage(IDnode, fileName, width, height, dida) { this.urlTrigger = '/Images/'; this.pageExtension = '.aspx'; this.IDnode = IDnode; this.fileName = fileName; this.width = width; this.height = height; this.dida = dida; }; CMSImage.prototype.getBySize = function(width, height, canCrop, canEnlarge) { if(!width) width = this.width; if(!height) height = this.height; if(canCrop == null) canCrop = false; if(canCrop == null) canCrop = false; return env.applicationPath + this.urlTrigger + width.toString() + 'x' + height.toString() + '/' + this.IDnode.toString() + '/' + this.fileName + this.pageExtension + '?canCrop=' + ((canCrop)?'true':'false') + '&canEnlarge=' + ((canEnlarge)?'true':'false'); }; var resizeManager = { toString:function(){return 'resizeManager class'}, settings: { minW:960, minH:550, maxW:5000, maxH:4000 }, _obj:null, listeners:null, w:null, initialize:function() { this.listeners = new Array(); this.w = $(window); this.w.data('resizeManager', this); this.w.resize(function(){ var handle = $(this).data('resizeManager'); handle._obj = null; handle.onresize(); }); this.w.resize(); }, getSize:function() { if(this._obj == null) { var b = $(document.body); var previous_overflow = b.css('overflow'); b.css('overflow', 'hidden'); var obj = new Object(); obj.width = this.width(); obj.height = this.height(); obj.marginH = Math.floor((obj.width - this.settings.minW) / 2); obj.marginV = Math.floor((obj.height - this.settings.minH) / 2); this._obj = obj; b.css('overflow', previous_overflow); } return this._obj; }, onresize:function() { var o = this.getSize(); for(var i = 0; i < this.listeners.length; i++) this.listeners[i].onresize(o); }, width:function() { return Math.min(Math.max(this.w.width(), this.settings.minW), this.settings.maxW); }, height:function() { return Math.min(Math.max(this.w.height(), this.settings.minH), this.settings.maxH); }, addListener:function(obj) { for(var i = 0; i < this.listeners.length; i++) if(this.listeners[i] == obj) return; this.listeners.push(obj); }, removeListener:function(obj) { var new_listeners = new Array(); for(var i = 0; i < this.listeners.length; i++) if(this.listeners[i] != obj) new_listeners.push(this.listeners[i]); } }; $(document).ready(function(){ resizeManager.initialize(); }); ajaxUrl = { settings: { ajaxTimeout:30000, pollingInterval:100, serverExt:'.aspx' }, pollingInterval:null, latestHash:'', htmlTargetID:null, pollingChangeSection:null, initialize:function() { this.latestHash = ''; var ajaxLinks = $('a[onmousedown^="ajaxUrl.go("]'); ajaxLinks.each(function(){ $(this).click(function(event){ event.preventDefault(); this.onmousedown(); }); }); this.startPolling(); }, go:function(content, section) { if(content.indexOf('#') != -1 && content.indexOf('#') != 0) content = content.substring(content.indexOf('#')); if(!section) section = env.section; if(section == env.section) { this.latestHash = window.location.hash = content; this.changeSection(); } else document.location = env.applicationPath + '/' + env.lang + '/' + section + this.settings.serverExt + content; return false; }, poll:function() { if(window.location.hash == this.latestHash) return; this.latestHash = window.location.hash; if(this.pollingChangeSection != null) this.pollingChangeSection(); this.changeSection(); }, startPolling:function() { window.clearInterval(this.pollingInterval); this.pollingInterval = window.setInterval('window.ajaxUrl.poll();', this.settings.pollingInterval); }, stopPolling:function() { window.clearInterval(this.pollingInterval); }, changeSection:function() { var hash = window.location.hash; if(hash == '') { this.changeSectionNull(); return; } var page = hash.substring(1).split('|').join('/'); var loadUrl = env.applicationPath + '/' + env.lang + '/' + env.section + '/' + page + this.settings.serverExt; $.ajax({ url:loadUrl, timeout:this.settings.ajaxTimeout, success:function(data, status) { var content = data; content = content.substring(content.indexOf('<body>') + 6, content.lastIndexOf('</body>')); ajaxUrl.changeSectionSuccess(content, status); }, error:function (request, status, errors) { ajaxUrl.changeSectionError(request, status, errors); } }); }, changeSectionSuccess:function(content, status) { $('#' + this.htmlTargetID).empty(); $('#' + this.htmlTargetID).append($(content)); }, changeSectionError:function(request, status, errors) { }, changeSectionNull:function() { $("#ajaxTarget").empty(); } }; $(document).ready(function(){ajaxUrl.initialize();}); var bgManager = { settings:{ fadeIn:500, step:100, margin:{top:0,right:0,bottom:0,left:0} }, base:null, initialize:function() { if(this.base != null) return; this.base = $('<div></div>'); $('*:first', document.body).before(this.base); this.base.css('position', 'absolute').css('top', this.settings.margin.top).css('left', this.settings.margin.left).css('z-index', 0).css('overflow','hidden'); resizeManager.addListener(this); resizeManager.onresize(); }, show:function(cmsImage, canCrop) { if(!cmsImage) return; if(canCrop == null) canCrop = true; var w = resizeManager.width() - this.settings.margin.left - this.settings.margin.right; var h = resizeManager.height() - this.settings.margin.top - this.settings.margin.bottom; w = Math.floor(w / this.settings.step) * this.settings.step; h = Math.floor(h / this.settings.step) * this.settings.step; var image = $('<img src="' + cmsImage.getBySize(w, h, canCrop, true) + '" width="' + w.toString() + '" height="' + h.toString() + '" />'); this.base.append(image); image.css('position', 'absolute'); image.css('opacity', 0.0); image.data('cmsImage', cmsImage); image.data('canCrop', canCrop); image.load(function(){ var j = $(this); var imageSize = {width:j.width(), height:j.height()}; j.data('size', imageSize); bgManager.onresize(resizeManager.getSize()); j.animate({ 'opacity': 1.0 }, { duration:bgManager.settings.fadeIn, queue:false, easing:'swing', complete:function(){ bgManager.refactor(); $(this).toggleClass('removable', true); } } ); }); }, onresize:function(obj) { var baseWidth = obj.width - this.settings.margin.left - this.settings.margin.right; var baseHeight = obj.height - this.settings.margin.top - this.settings.margin.bottom; this.base.width(baseWidth).height(baseHeight); $('img', this.base).each(function(){ var jThis = $(this); var imageSize = jThis.data('size'); if(!imageSize) return; var canCrop = jThis.data('canCrop'); var factorX = imageSize.width / baseWidth; var factorY = imageSize.height / baseHeight; var factor = null; if(canCrop) factor = Math.min(factorX, factorY); else factor = Math.max(factorX, factorY); jThis.width(Math.ceil(imageSize.width / factor)); jThis.height(Math.ceil(imageSize.height / factor)); jThis.css('left', Math.round((baseWidth - jThis.width()) / 2)); jThis.css('top', Math.round((baseHeight - jThis.height()) / 2)); }); }, refactor:function() { $('img.removable', this.base).each(function(){ $(this).remove(); }); } }; $(function(){bgManager.initialize()}); var mainMenu = { settings:{ openLength:300, closeLength:500, openHeight:145, closeHeight:60, mouseSensitivity:false }, base:null, label:null, items:null, isOpen:false, initialize:function() { this.base = $('div#mainMenu'); this.label = this.base.find('.label'); this.items = $('div#mainMenu .items'); if($('div#mm_bg').length == 0) this.base.prepend($('<div id="mm_bg"></div>')); $('div#mm_bg').css('opacity', 0.8); resizeManager.addListener(this); resizeManager.onresize(); this.open(true); this.setMouseSentitivity(this.settings.mouseSensitivity); } , setMouseSentitivity:function(isSensitive){ this.settings.mouseSensitivity = isSensitive; this.base.unbind('mouseleave'); if(this.settings.mouseSensitivity) this.base.bind('mouseleave', function(){ if(mainMenu.isOpen) mainMenu.close() }); this.base.unbind('mouseenter'); this.base.bind('mouseenter', function(){ if(!mainMenu.isOpen) mainMenu.open() }); }, onresize:function(size) { this.base.width(size.width); }, open:function(hard) { if(this.isOpen) return; this.isOpen = true; hard = (hard == true); var duration = (hard)?0:this.settings.closeLength; this.base.animate({'height':this.settings.openHeight}, { duration:(hard)?0:this.settings.closeLength, queue:false, easing:'swing' }); this.label.animate({'opacity':0.0}, {queue:false, duration:duration}); this.items.animate({'opacity':1.0}, {queue:false, duration:duration}); }, close:function(hard) { if(!this.isOpen) return; this.isOpen = false; hard = (hard == true); var duration = (hard)?0:this.settings.closeLength; this.base.animate({'height':this.settings.closeHeight}, { duration:duration, queue:false, easing:'swing' }); this.label.animate({'opacity': 1.0}, {queue:false, duration:duration}); this.items.animate({'opacity': 0.0}, {queue:false, duration:duration}); }, collapse:function(hard) { hard = (hard == true); this.base.animate({'height':0}, (hard)?0:this.settings.closeLength); this.label.fadeTo((hard)?0:this.settings.opencloseLengthLength, 0.0); this.items.fadeTo((hard)?0:this.settings.closeLength, 0.0); }, showPanel:function(sender) { if(typeof(sender) == 'string') sender = $('#' + sender); else sender = $(sender); SetSelected(sender.parents('div.item'), sender); var id = sender.attr('id'); var parts = id.split('_'); var level = parseInt(parts[1]); var IDnode = parts[2]; $('div[id^="panel_' + (level + 1) + '_"]').hide().each(function(){SetSelected($(this), null)}); $('div[id^="panel_' + (level + 2) + '_"]').hide().each(function(){SetSelected($(this), null)}); $('div[id^="panel_' + (level + 3) + '_"]').hide().each(function(){SetSelected($(this), null)}); $('div[id^="panel_' + (level + 4) + '_"]').hide().each(function(){SetSelected($(this), null)}); $('div[id^="panel_' + (level + 5) + '_"]').hide().each(function(){SetSelected($(this), null)}); var s = 'div[id="panel_' + (level + 1) + '_' + IDnode + '"]'; $(s).fadeTo(this.settings.openLength, 1.0); }, makeVisible:function(IDnode){ var lastLink = $('li[id$="_' + IDnode.toString() + '"]'); if(lastLink.length != 0) { var openerLink = mainMenu.getOpenerLink(lastLink); if(openerLink.length != 0) { var grandParent = mainMenu.getOpenerLink(openerLink); if(grandParent.length != 0) mainMenu.showPanel(grandParent); mainMenu.showPanel(openerLink); } SetSelected(lastLink.parents('div.item'), lastLink); } }, getOpenerLink:function(jLi) { var panel_container = jLi.parents('div[id^="panel_"]'); var panelID = panel_container.attr('id').substring(panel_container.attr('id').lastIndexOf('_') + 1); return $('li[id$="_' + panelID.toString() + '"]'); } }; $(function(){mainMenu.initialize();}); var icons = { base:null, li_flag:null, iconZoom:null, iconNews:null, iconFlag_off:null, iconHome:null, initialize:function() { this.base = $('<div id="icons"></div>'); this.base.appendTo(document.body); var ul = $('<ul class="clearfix"></ul>'); ul.appendTo(this.base); this.iconZoom = $('<li class="zoom"><img class="off" src="' + env.applicationPath + '/imgs/icon_zoom.png" width="21" height="21" /></li>'); this.iconNews = $('<li class="rss" style="width:20px;"><img class="off" src="' + env.applicationPath + '/imgs/icon_rss_off.png" width="20" height="21" /><img class="on" src="' + env.applicationPath + '/imgs/icon_rss_on.png" width="21" height="21" /></li>'); this.iconNews.appendTo(ul); this.iconNews.css('margin-top', '-1px'); this.iconNews.bind('click', function(){ document.location = env.applicationPath + '/' + env.lang + '/News.aspx'; }); if(env.section.toLowerCase() == 'news') this.iconNews.find('img.on').attr('src', env.applicationPath + '/imgs/icon_rss_click.png').css('opacity', 0.5).prev().remove(); else { this.iconNews.find('img.on').css('opacity', 0.0).css('cursor', 'pointer').css('position', 'relative').css('left', 0).css('top', -21).bind('mouseover', function(){ $(this).animate({'opacity':1.0}, {queue:false}); }).bind('mouseout', function(){ $(this).animate({'opacity':0.0}, {queue:false}); }); } var lang_icon = env.applicationPath + '/imgs/' + ((env.IDlanguage == 260)?'eng':'ita') + '.png'; this.li_flag = $('<li class="flag" style="width:18px;"></li>'); ul.append(this.li_flag); this.iconFlag_off = $('<img class="off" src="' + env.applicationPath + '/imgs/icon_flag.png" width="19" height="21" />'); this.iconFlag_on = $('<img class="on" src="' + lang_icon + '" />'); this.li_flag.append(this.iconFlag_off); this.iconFlag_on.appendTo(this.li_flag).css('opacity', 0.0).css('position', 'absolute').css('left', '116px').css('top', '3px'); this.li_flag.css('cursor', 'pointer').bind('mouseover', function(){ icons.iconFlag_on.animate({'opacity':1.0}, {queue:false}); icons.iconFlag_off.animate({'opacity':0.0}, {queue:false}); }).bind('mouseout', function(){ icons.iconFlag_on.animate({'opacity':0.0}, {queue:false}); icons.iconFlag_off.animate({'opacity':1.0}, {queue:false}); }).bind('click', function(){ document.location = env.applicationPath + '/' + ((env.IDlanguage == 260)?'EN':'IT') + '/Home.aspx'; }); this.iconHome = $('<li class="home"><img class="off" src="' + env.applicationPath + '/imgs/icon_home.png" width="24" height="23" /><img class="on" src="' + env.applicationPath + '/imgs/icon_home_on.png" width="24" height="23" /></li>'); this.iconHome.appendTo(ul); this.iconHome.css('margin-top', '-1px'); this.iconHome.bind('click', function(){ document.location = env.applicationPath + '/' + env.lang + '/Home.aspx'; }); ul.css('margin-left', this.base.width() - ul.width()); if(env.section.toLowerCase() == 'home') this.iconHome.find('img.on').css('opacity', 0.5).prev().remove(); else { this.iconHome.find('img.on').css('opacity', 0.0).css('cursor', 'pointer').css('position', 'relative').css('left', -24).css('top', 0).bind('mouseover', function(){ $(this).animate({'opacity':1.0}, {queue:false}); }).bind('mouseout', function(){ $(this).animate({'opacity':0.0}, {queue:false}); }); } } }; $(function(){icons.initialize()}); 
