// AJAX function callAjaxHandlerProducts( postObj, handlercall ) { new Ajax.Request("http://www.rolandiberia.com/js/../ajax_products.php?uid=&uoid=&un=d41d8cd98f00b204e9800998ecf8427e&ue=d41d8cd98f00b204e9800998ecf8427e&l=", { method: "post", postBody: 'data=' + Object.toJSON(postObj), //onCreate: function(t) { alert("A carregar dados..."); }, onSuccess: function(t) { eval(handlercall+"(t);"); }, on404: function(t) { alert('Erro 404: ' + t.statusText); }, onFailure: function(t) { alert('Erro ' + t.status + ': ' + t.statusText); } }); } // Detalhe dum produto, mostra a info var tab; var prod_oid; var skip_check; var scrollimagesthumb; var scrollimageview; var scrollcomments; var scrollvideos; var asking; asking = false; skip_check = false; function showDetailInfo(obj) { if( obj == null ) { if (asking == false ) { // Se existir conteúdo na "tab" é porque já tem informação e não é necessário ir buscar mais if (!skip_check) { if (!$('dp_'+tab).empty()) { change_menu_detalhe_produto(tab); return; } } // In future, it's a good idea, call main ajax function with the script name in parameters // Good point... :) let's get some real stuff. // Call main products-ajax function asking = true; callAjaxHandlerProducts( { 'action': 'showDetailInfo', // Cool, uh? Now we can always be in same sessions, iohhh-uh ! 'UDSID': '', 'prod_oid': prod_oid, 'tab': tab }, 'showDetailInfo' ); } // Ok, from now it's only about showing info! return; } asking = false; // Oh, it seams that we got mail :p Let's check it out. var tmp = obj.responseText.evalJSON(); if ( tmp.info == "ok" ) { $('dp_'+tmp.tab).innerHTML += tmp.html; if (skip_check == true && tmp.tab == 'comentarios') { set_alert_message(); } skip_check = false; change_menu_detalhe_produto(tmp.tab); if (tmp.tab == 'videos') { changeSelectedVideo(tmp.default_content,'1'); videos_scroll(); } if (tmp.tab == 'imagens') { img_scroll(); imgview_scroll(); image_set = tmp.imgs; } if (tmp.tab == 'comentarios') { comm_scroll(); } } } function timedCountComments(direction) { scrollcomments.setValueBy(direction); tc=setTimeout("timedCountComments(" + direction + ")", 1); } function stopCountComments() { clearTimeout(tc); } function timedCountVideos(direction) { scrollvideos.setValueBy(direction); tv=setTimeout("timedCountVideos(" + direction + ")", 1); } function stopCountVideos() { clearTimeout(tv); } function timedCountImagesthumb(direction) { scrollimagesthumb.setValueBy(direction); tit=setTimeout("timedCountImagesthumb(" + direction + ")", 1); } function stopCountImagesthumb() { clearTimeout(tit); } function timedCountImageview(direction) { scrollimageview.setValueBy(direction); tiv=setTimeout("timedCountImageview(" + direction + ")", 1); } function stopCountImageview() { clearTimeout(tiv); } function changeSelectedImage(new_image,img_id) { scrollimageview.setValue(0); $('img_actual').src = new_image; $('img_actual_click').onclick=function(){return GB_showImageSet(image_set, img_id);}; setTimeout('imgview_scroll()',1000); var ml_elements = $$('#scrollimagesthumb .item'); $A(ml_elements).each(function(e){ e.removeClassName( 'current' ); }); $( 'img_'+img_id ).addClassName('current'); } function changeSelectedVideo(video , vid_id) { //var so = new SWFObject("http://www.rolandiberia.com/playerRoland.swf", "movieplayer", "600px", "340px", "8", "#000000"); //so.addParam('wmode', 'transparent' ); //so.addParam('allowfullscreen','true'); //so.addParam('allowscriptaccess','always'); //so.addParam('flashvars','file=http://www.rolandiberia.com/files//products/'+video+'&autostart=true&fullscreen=true&skin=snel.swf'); //so.write('flash-content'); document.getElementById("iframe_youtube").src=video; var ml_elements = $$('#scrollvideos .item'); $A(ml_elements).each(function(e){ e.removeClassName( 'current' ); }); $( 'vid_'+vid_id ).addClassName('current'); } function showInfo(t,oid) { tab = t; prod_oid = oid; showDetailInfo(); } // scroll the element vertically based on its width and the slider maximum value function scrollVertical(value, element, slider) { element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight)); } // mouse wheel code from http://adomas.org/javascript-mouse-wheel/ function handle_imagesthumb(delta) { scrollimagesthumb.setValueBy(-delta); } /** Event handler for mouse wheel event. */ function wheel_imagesthumb(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } if (delta) { handle_imagesthumb(delta); } if (event.preventDefault) event.preventDefault(); event.returnValue = false; } // mouse wheel code from http://adomas.org/javascript-mouse-wheel/ function handle_imageview(delta) { scrollimageview.setValueBy(-delta); } /** Event handler for mouse wheel event. */ function wheel_imageview(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } if (delta) { handle_imageview(delta); } if (event.preventDefault) event.preventDefault(); event.returnValue = false; } var scrl_img = false; function img_scroll() { $('center-content').removeClassName('no-scroll'); // vertical slider control scrollimagesthumb = new Control.Slider('handle-imagesthumb', 'track-imagesthumb', { axis: 'vertical', range: $R(0,10), onSlide: function(v) { scrollVertical(v, $('scrollimagesthumb'), scrollimagesthumb); }, onChange: function(v) { scrollVertical(v, $('scrollimagesthumb'), scrollimagesthumb); } }); // disable vertical scrolling if text doesn't overflow the div if ($('scrollimagesthumb').immediateDescendants()[0].getHeight() <= $('scrollimagesthumb').getHeight() ) { //scrollimagesthumb.setDisabled(); //$('track-imagesthumb').hide(); scrl_img = false; scrollimagesthumb.setDisabled(); $('wrap-imagesthumb').hide(); $('center-content').addClassName('no-scroll'); } else { scrl_img = true; $('wrap-imagesthumb').show(); // mozilla Event.observe('scrollimagesthumb', 'DOMMouseScroll', wheel_imagesthumb); // IE/Opera Event.observe('scrollimagesthumb', 'mousewheel', wheel_imagesthumb); } } function imgview_scroll() { // mozilla Event.stopObserving('scrollimageview', 'DOMMouseScroll', wheel_imageview); // IE/Opera Event.stopObserving('scrollimageview', 'mousewheel', wheel_imageview); scrollimageview = new Control.Slider('handle-scrollimageview', 'track-scrollimageview', { axis: 'vertical', range: $R(0,10), onSlide: function(v) { scrollVertical(v, $('scrollimageview'), scrollimageview); }, onChange: function(v) { scrollVertical(v, $('scrollimageview'), scrollimageview); } }); // disable vertical scrolling if text doesn't overflow the div if ($('scrollimageview').immediateDescendants()[0].getHeight() <= $('scrollimageview').getHeight()) { scrollimageview.setDisabled(); $('wrap-scrollimageview').hide(); } else { scrollimageview.setDisabled(); $('wrap-scrollimageview').hide(); //$('wrap-scrollimageview').show(); // mozilla //Event.observe('scrollimageview', 'DOMMouseScroll', wheel_imageview); // IE/Opera //Event.observe('scrollimageview', 'mousewheel', wheel_imageview); } } // mouse wheel code from http://adomas.org/javascript-mouse-wheel/ function handle_comments(delta) { scrollcomments.setValueBy(-delta); } /** Event handler for mouse wheel event. */ function wheel_comments(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } if (delta) { handle_comments(delta); } if (event.preventDefault) event.preventDefault(); event.returnValue = false; } function chekCommentScroll() { try { if ($('scrollcomments').immediateDescendants()[0].getHeight() > $('scrollcomments').getHeight()) { comm_scroll(); } } catch (err) { } } function comm_scroll() { scrollcomments = new Control.Slider('handle-comments', 'track-comments', { axis: 'vertical', range: $R(0,10), onSlide: function(v) { scrollVertical(v, $('scrollcomments'), scrollcomments); }, onChange: function(v) { scrollVertical(v, $('scrollcomments'), scrollcomments); } }); // disable vertical scrolling if text doesn't overflow the div if ($('scrollcomments').immediateDescendants()[0].getHeight() <= $('scrollcomments').getHeight()) { scrollcomments.setDisabled(); $('wrap-comments').hide(); } else { $('wrap-comments').show(); // mozilla Event.observe('scrollcomments', 'DOMMouseScroll', wheel_comments); // IE/Opera Event.observe('scrollcomments', 'mousewheel', wheel_comments); } } // mouse wheel code from http://adomas.org/javascript-mouse-wheel/ function handle_videos(delta) { scrollvideos.setValueBy(-delta); } /** Event handler for mouse wheel event. */ function wheel_videos(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } if (delta) { handle_videos(delta); } if (event.preventDefault) event.preventDefault(); event.returnValue = false; } var scrl_vid = false; function videos_scroll() { $('center-content').removeClassName('no-scroll'); scrollvideos = new Control.Slider('handle-videos', 'track-videos', { axis: 'vertical', range: $R(0,10), onSlide: function(v) { scrollVertical(v, $('scrollvideos'), scrollvideos); }, onChange: function(v) { scrollVertical(v, $('scrollvideos'), scrollvideos); } }); // disable vertical scrolling if text doesn't overflow the div if ($('scrollvideos').immediateDescendants()[0].getHeight() <= $('scrollvideos').getHeight()) { scrl_vid = false; scrollvideos.setDisabled(); $('wrap-videos').hide(); $('center-content').addClassName('no-scroll'); } else { scrl_vid = true; $('wrap-videos').show(); // mozilla Event.observe('scrollvideos', 'DOMMouseScroll', wheel_videos); // IE/Opera Event.observe('scrollvideos', 'mousewheel', wheel_videos); } } function getDownloads(obj) { if( obj == null ) { // Call main products-ajax function var form_obj = document.request_manual_form; callAjaxHandlerProducts( { 'action': 'downloadManual', // Cool, uh? Now we can always be in same sessions, iohhh-uh ! 'UDSID': '', 'product_oid': form_obj.elements["prod_oid"].value, 'serial_number': form_obj.elements["serial_number"].value, 'motive': form_obj.elements["motive"].value, 'brought_in': form_obj.elements["brought_in"].value, 'country': form_obj.elements["country"].value }, 'getDownloads' ); // Ok, from now it's only about showing info! return; } // Oh, it seams that we got mail :p Let's check it out. var tmp = obj.responseText.evalJSON(); if ( tmp.success == true ) { $('manuals').innerHTML = tmp.html; $('form_manual').toggle(); $('div_message').innerHTML = tmp.msg; } else { $('div_message').innerHTML = tmp.msg; } }