/* Theme constants */ var slidePopupYOffset = 123; //Y position of slide popup in pixel var slidePopupDelay = 0; var recentPortfolioURL = 'http://www.interguide.it/it/ajax/portfolio'; var recentBlogPostsURL = 'http://localhost/ajax_posts.html'; var contactURL = 'http://www.interguide.it/it/ajax/contatti'; /* Begin Custom plugins */ /* Detect browser and version plugin Author: http://www.quirksmode.org/js/detect.html */ var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i div').size(); var current_index = 0; $(this).scrollTo($(this).find(settings.each)[0]); $('a' +settings.nav).css('visibility', 'hidden'); $(this).parent().mouseenter(function(){ $('a' +settings.nav).css('visibility', 'visible'); }); $(this).parent().mouseleave(function(){ $('a' +settings.nav).css('visibility', 'hidden'); }); // Add current index element $(this).parent().append(''); // Previous button $('a' +settings.nav+ '.prev').click(function(){ current_index = parseInt($('#'+current_id+'_current').val()); current_index = current_index - 1; if(typeof($('#' +current_id).find(settings.each)[current_index]) != 'undefined') { $('#'+current_id+'_current').val(current_index); $('#' +current_id).scrollTo($('#' +current_id).find(settings.each)[current_index], 500 ); } }); // Next button $('a' +settings.nav+ '.next').click(function(){ current_index = parseInt($('#'+current_id+'_current').val()); current_index = current_index + 1; $('#'+current_id+'_current').val(current_index); if(current_index+1 > size) { // if scroll out of parent then go to first element $('#' +current_id).scrollTo($('#' +current_id).find(settings.each)[0], 500 ); $('#'+current_id+'_current').val(0); } else { $('#' +current_id).scrollTo($('#' +current_id).find(settings.each)[current_index], 500 ); } }); } /* slidePopup plugin Author: Peerapong Pulpipatnan http://themeforest.net/user/peerapong */ jQuery.fn.slidePopup = function(url, options) { settings = jQuery.extend({ size: 'small', //options are small, big position: 'top', //options are top, relative displayAsMenu: false //options are true or false }, options); var showSlide = 0; var thisId = $(this).attr('id'); var targetId = thisId+'_popup'; // Cache when first load page $('body').append('
'); if(settings.displayAsMenu) { $('#'+targetId+' .content .inner').addClass('menu'); } $('#'+targetId+' .content .inner').load(url); $('#'+targetId).attr('rel', settings.position); if(url.length > 0) { if($('#'+targetId).length == 0) { $('body').append('
'); $('#'+targetId+' .content .inner').load(url); } $(this).mouseenter(function(){ if(showSlide == 0) { positionPopup(thisId, targetId); $('#'+targetId).show('slide', {direction: 'left'}, 200); } }); $(this).mouseleave(function(){ setTimeout(function(){ if(showSlide == 0) { $('#'+targetId).hide('slide', {direction: 'left'}, 200); } }, slidePopupDelay); }); $('#'+targetId).mouseenter(function(){ showSlide = 1; $('#'+thisId).find('a').addClass('hover'); $(this).show(); }); $('#'+targetId).mouseleave(function(){ showSlide = 0; setTimeout(function(){ if(showSlide == 0) { $('#'+targetId).hide('slide', {direction: 'left'}, 200); $('#'+thisId).find('a').removeClass('hover'); } }, slidePopupDelay); }); // When window resized re calculate slide popup position $(window).resize(function() { positionPopup(thisId, targetId); }); $(window).scroll(function() { positionPopup(thisId, targetId); }); } } /* Find element's Y axis position */ function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (1) { curtop+=obj.offsetTop; if (!obj.offsetParent) { break; } obj=obj.offsetParent; } } else if (obj.y) { curtop+=obj.y; } return curtop; } /* Find element's X axis position */ function findPosX(obj) { var curtop = 0; if (obj.offsetParent) { while (1) { curtop+=obj.offsetLeft; if (!obj.offsetParent) { break; } obj=obj.offsetParent; } } else if (obj.x) { curtop+=obj.x; } return curtop; } /* Calculate slide popup */ function positionPopup(menuId , slideId) { popupPosition = $('#'+slideId).attr('rel'); if(popupPosition == 'top') { slidePosY = slidePopupYOffset; } else { if(BrowserDetect.browser!="Safari"&&BrowserDetect.browser!="Chrome"){ slidePosY = findPosY(document.getElementById(menuId))-10; }else{ slidePosY = findPosY(document.getElementById(menuId))-12; } if(BrowserDetect.browser=="Explorer"){ if(BrowserDetect.version < 8) { slidePosY = findPosY(document.getElementById(menuId))-110; } else { slidePosY = findPosY(document.getElementById(menuId))-12; } } } slidePosX = findPosX(document.getElementById(menuId))+212; if(BrowserDetect.browser == 'Explorer') { slidePosX = slidePosX + 2; } // Get scroll postion if(BrowserDetect.browser == 'Explorer') { var slideScrollY = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; } else { slideScrollY = window.pageYOffset; } $('#'+slideId).css('top', parseInt(slidePosY+slideScrollY) +'px'); $('#'+slideId).css('left', slidePosX+'px'); } /* function to switch between each skins */ function switchSkin(skin) { $('head').append(''); } /* End Custom plugins */ $(function(){ // Preload images $.preloadCssImages(); // Setup click to hide to all alert boxes $('.alert_warning').click(function(){ $(this).fadeOut('fast'); }); $('.alert_info').click(function(){ $(this).fadeOut('fast'); }); $('.alert_success').click(function(){ $(this).fadeOut('fast'); }); $('.alert_error').click(function(){ $(this).fadeOut('fast'); }); }); $(document).ready(function(){ // Setup slider 5 second to change each slide $('#img_slider').nivoSlider({ effect: 'fade', directionNav:true, pauseTime: 5000 }); // Setup slider 5 second to change each slide in fold effect $('#img_slider_fold').nivoSlider({ effect: 'fold', directionNav:true, pauseTime: 5000 }); // Hide slider nav $('.nivo-directionNav').hide(); // Important to make left menu stay above others $('#main_menu').css('zIndex', 999); // Setup tooltips for all recent portfolio items $('#recent_portfolio ul li a').tipsy({gravity: 'w'}); /* Begin setup popup for menu */ $('#8').slidePopup(recentPortfolioURL, { size: 'small' }); //$('#menu_pages').slidePopup(pagesURL, { size: 'small', displayAsMenu: true }); //$('#menu_skins').slidePopup(skinsURL, { size: 'small', displayAsMenu: true }); //$('#menu_blog').slidePopup(recentBlogPostsURL, { size: 'big' }); $('#menu_contact').slidePopup(contactURL, { size: 'big', position: 'relative' }); /* End setup popup for menu */ // Find all the input elements with title attributes and add hint to it $('input[title!=""]').hint(); // Setup featured works showcase in home $('#work_slideshow').workSlideshow(); // Setup vimeo video modal window for portfolio $('#portfolio_vimeo').fancybox({ padding: 10, overlayColor: '#000000', overlayOpacity: .7 }); // Setup youtube video modal window for portfolio $('#portfolio_youtube').fancybox({ padding: 10, overlayColor: '#000000', overlayOpacity: .7 }); // Setup photo gallery $('.thumbnail li a[rel=slide]').fancybox({ padding: 0, overlayColor: '#000000', overlayOpacity: .7 }); // Setup all image caption $('img.caption').captify({ // all of these options are... optional // --- // speed of the mouseover effect speedOver: 'fast', // speed of the mouseout effect speedOut: 'normal', // how long to delay the hiding of the caption after mouseout (ms) hideDelay: 100, // 'fade', 'slide', 'always-on' animation: 'slide', // text/html to be placed at the beginning of every caption prefix: '', // opacity of the caption on mouse over opacity: '0.7', // the name of the CSS class to apply to the caption box className: 'caption-bottom', // position of the caption (top or bottom) position: 'bottom', // caption span % of the image spanWidth: '100%' }); // Setup eaxmple click to slide featued works setTimeout(function(){ $('.work_nav.next').click(); }, 2000); $('#menu_skins a').click(function(){ return false; }); });