var $j = jQuery.noConflict(); $j(document).ready(function(){ $j(".frontpage-1row").fadeTo(0,0.8); $j("#home-x").click(function(){ $j("#home-box").fadeTo(300,0); }); //h1 alignment with side-menu var leftside_height = $j("#header h1 a").height() + 120; var rightside_height = $j("#index_container .page_title").height() + 122; if (leftside_height > rightside_height) { var diff = leftside_height - rightside_height; $j("#index_container").css('padding-top', diff); } else if (leftside_height < rightside_height) { var diff = (rightside_height - leftside_height) + 69; $j("#side_menu p:first-child").css('padding-top', diff); } // Single Blog/News Post Effects //$j(".info_content_top").fadeTo(0,0.3); $j(".info_content_top div, .info_content_bottom div, #comment_holder").fadeTo(0,0.3); $j(".info_content_top div, .info_content_bottom div, #comment_holder").bind("mouseenter", function(){ $j(this).stop().fadeTo('normal', 1); }).bind("mouseleave", function () { $j(this).stop().fadeTo('fast', 0.3); }); //} else { //$j(".info_content_top div").show().fadeTo(0,1); //} // search bar text $j(".widget_search input[type=text]").fadeTo(0,0.3).val("Search + Enter").focus(function(){ $j(this).val(""); $j(this).unbind("mouseleave"); }).blur(function(){ $j(this).val("Search + Enter"); $j(this).stop().fadeTo(300,0.3); bindSearch($j(this)); }); bindSearch($j(".widget_search input[type=text]")); function bindSearch(el){ el.bind("mouseenter", function(){ $j(this).stop().fadeTo(300,1); }).bind("mouseleave", function(){ $j(this).stop().fadeTo(300,0.3); }); } // set homepage ribbon opacity var ribbon = $j(".frontpage-1row").css("opacity"); //alert(ribbon); ribbon = parseFloat(ribbon); $j(".frontpage-1row, .frontpage-2row, .frontpage-3row").fadeTo(0,ribbon); // remove all image titles $j("[title]").removeAttr("title"); // stop right click on images $j("img").live("contextmenu", function(){return false;}); // stop drag and dropping images $j("img").live("mousedown", function(){return false;}); // check if iphone and assign boolean var var iphone = false; if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1){ iphone = true; } } var showcontent = $j("#content-first").is(":visible"); if($j("#background-images").length === 0){ showcontent = true; } $j('#right_buttons, #left_buttons').fadeTo(0,0); function liveLeftHover(){ if(!iphone){ $j('#left_side').show().bind("mouseenter", function(){ $j('#left_buttons').show().stop().fadeTo('normal', 1); }).bind("mouseleave", function () { $j('#left_buttons').stop().fadeTo('fast', 0, function(){$j('#left_buttons').hide();}); }); } else { $j('#left_buttons').show().fadeTo(0,1); } } function killLeftHover(){ if(!iphone){ $j('#left_side').unbind("mouseenter").unbind("mouseleave").hide(); $j('#left_buttons').stop().fadeTo('fast', 0, function(){$j('#left_buttons').hide();}); } else { $j('#left_buttons').hide().fadeTo(0,0); } } function liveRightHover(){ if(!iphone){ $j('#right_side').bind("mouseenter", function(){ $j('#right_buttons').show().stop().fadeTo('normal', 1); }).bind("mouseleave", function () { $j('#right_buttons').stop().fadeTo('fast', 0, function(){$j('#right_buttons').hide();}); }); } else { $j('#right_buttons').show().fadeTo(0,1); } } function killRightHover(){ if(!iphone){ $j('#right_side').unbind("mouseenter").unbind("mouseleave"); $j('#right_buttons').stop().fadeTo('fast', 1); } } /* function liveRightClick(){ $j('#right_buttons').bind("click", function(){ window.location = $j("a", this).attr("href"); }); } function killRightClick(){ $j('#right_buttons').unbind("click"); } */ // fancy boxes on posts/pages : /* $j('#info_container img, #page_container img').each(function(){ $j(this).parent().addClass('lightbox'); }); $j("a.lightbox").fancybox({ 'opacity' : true, 'overlayShow' : false, 'transitionIn' : 'elastic', 'transitionOut' : 'none' }); */ // hides items in side menu and adds click/hover bindings /* function hideSideMenu(){ $j("#filterby-container").hide(); $j("#sidemenu-container #menu_names li").each(function(){ $j(this).hide(); if($j("a", this).hasClass("active")){ $j(this).show(); } }); $j("#menu-click").bind("click", function(){ $j("#sidemenu-container, #sidemenu-container #filterby-container, #sidemenu-container #menu_names li").slideDown(); $j(this).text("Latest Works"); }); $j("#side_menu").bind("mouseleave", function(){ $j("#sidemenu-container #menu_names li").each(function(){ if(!$j("a", this).hasClass("active")){ $j(this).slideUp(); } }); $j("#sidemenu-container #filterby-container").slideUp(); $j("#menu-click").text("View All Works"); }); } */ // shows all items in side menu and removes bindings /* function showSideMenu(){ $j("#sidemenu-container #menu_names li, #filterby-container, #sidemenu-container").show(); $j("#menu-click").unbind("click"); $j("#side_menu").unbind("mouseleave"); } */ //$j('.menu').append(''); // spaces out menu to width of nearest grid (BUGGY): /* var oldwidth = $j('.menu ul').width(); var n = Math.ceil((oldwidth + 20)/60); var newwidth = (40*n)+(20*(n-1)); var numitems = $j('.menu li').size(); var space = 0; if(numitems>1){ space = (newwidth-oldwidth)/(numitems-1); } var active_cats = new Array(); //if(space < 15){ // adds extra column if items are too crowded : //newwidth += 60; //if(numitems > 1){ //space = (newwidth-oldwidth)/(numitems-1); //} //} $j('.menu ul').css('width', newwidth); $j('.menu li').css('padding-right', space); function calcMenuWidth(){ var rightmargin = $j('#blog-description').width(); $j(".menu ul").css("margin-right", rightmargin); } */ // adds left margin to feature text so it gets narrow as the window gets small : var menuwidth = $j('.menu ul').width(); var featuremargin = menuwidth + 290; $j('#blog-description').css('margin-left', featuremargin); // filter-by menu : $j('#menu_cats div').bind("click", function() { if ($j(this).hasClass('all_cats')) { $j(this).addClass('boldtext'); $j('.check_box_inner', this).addClass('checked'); $j('#menu_cats div').not(this).each(function() { $j(this).removeClass('boldtext'); $j('.check_box_inner', this).removeClass('checked'); }); $j('#menu_names li').each(function() { $j(this).slideDown(); }); active_cats = []; } else if ($j('.check_box_inner', this).hasClass('checked')){ var checkcheck = false; $j('.check_box_inner', this).removeClass('checked'); $j(this).removeClass('boldtext'); var cat = $j(this).attr('class'); //PULL OUT CHECKED CLASS var i; for (i = 0; i < active_cats.length; ++i) { if (cat == active_cats[i]) { active_cats.splice(i, 1); } } if (active_cats.length === 0) { $j('#menu_names li').slideDown(); } else { $j('#menu_names li').each(function() { var isactive = false; var g; for (g = 0; g < active_cats.length; ++g) { if ($j(this).hasClass(active_cats[g])) { isactive = true; } } if (isactive === true) { $j(this).slideDown(); } else { $j(this).slideUp(); } }); } $j('#menu_cats div .check_box_inner').each(function() { if ($j(this).hasClass('checked')) { checkcheck = true; } }); if (checkcheck === false) { $j('.all_cats').addClass('boldtext'); $j('.all_cats .check_box_inner').addClass('checked'); } } else { var cat = $j(this).attr('class'); active_cats.push(cat); $j(this).addClass('boldtext'); $j('.check_box_inner', this).addClass('checked'); $j('.all_cats').removeClass('boldtext'); $j('.all_cats .check_box_inner').removeClass('checked'); $j('#menu_names li').each(function() { if (!$j(this).hasClass(cat)) { $j(this).slideUp(); } }); } }); // frontpage script : $j(".tx-home-container a").hover(function(){ showBg($j(this).attr("class").replace(/[^\d]/g, "")); }, function(){ //showBg(null); }); // show first dynamic bg if no static bg found : if($j(".static-frontpage-backgrounds div").length === 0){ showBg("0"); } // homepage slideshow : var currenthomepage = 1; if($j(".static-frontpage-backgrounds div").length > 1){ $j(".static-frontpage-backgrounds div").hide(); $j(".static-frontpage-backgrounds div:eq(0)").show(); var timer = setInterval(nextSlideshowImage, 5000); } function nextSlideshowImage(){ frontpageHeaderColours($j(".static-frontpage-backgrounds div:eq("+currenthomepage+") span").attr("class")); $j(".static-frontpage-backgrounds div").fadeOut(2500); $j(".static-frontpage-backgrounds div:eq("+currenthomepage+")").fadeIn(2500); if($j(".static-frontpage-backgrounds div").length > (currenthomepage+1)){ currenthomepage += 1; } else { currenthomepage = 0; } } frontpageResize(); if($j(".static-frontpage-backgrounds span").size() > 0){ frontpageHeaderColours($j(".static-frontpage-backgrounds span:eq(0)").attr("class")); } else if ($j(".frontpage-backgrounds span").size() > 0){ frontpageHeaderColours($j(".frontpage-backgrounds span:eq(0)").attr("class")); } function frontpageHeaderColours(scheme){ //alert(scheme); //var changes = $j("#header, #menu-main-nav, #side_menu, #right_buttons, #navi-thumbs, #left_buttons, #right_buttons, #thumbnails-btn"); $j("#header, #menu-main-nav, #side_menu").removeClass("light"); $j("#header, #menu-main-nav, #side_menu").removeClass("dark"); $j("#blog-description").parent().attr("class", ""); $j("#header, #side_menu, #menu-main-nav").addClass(scheme); $j("#blog-description").parent().addClass(scheme); } function showBg(no){ $j(".tx-home-container a").removeClass("active"); $j(".tx-home-container a:eq("+no+")").addClass("active"); $j(".frontpage-backgrounds div").each(function(){ if(no){ if($j(this).hasClass(no)){ $j(this).show(); frontpageHeaderColours($j("span", this).attr("class")); } else { $j(this).hide(); } } }); } function frontpageResize(){ $j(".frontpage-backgrounds div, .static-frontpage-backgrounds div").each(function(){ var iW = $j(this).width(); var iH = $j(this).height(); var iR = iW/iH; var vW = $j(window).width(); var vH = $j(window).height(); var vR = vW/vH; var newWidth; var newHeight; if(vR > iR){ // screen is wider newWidth = vW; newHeight = newWidth/iR; } else { newHeight = vH; newWidth = newHeight * iR; } $j(this).parent().width(vW); $j(this).parent().height(vH); $j(this).width(newWidth); $j(this).height(newHeight); $j("img", this).width(newWidth); $j("img", this).height(newHeight); newLeft = (vW - newWidth) / 2; newTop = (vH - newHeight) / 2; $j(this).css("top", newTop); $j(this).css("left", newLeft); }); } $j(window).resize(frontpageResize); if($j(".static-frontpage-backgrounds div, .frontpage-backgrounds div").size() === 0){ // gallery script : // loads images in sequentially based on info in #imagesinfo var allBgImages = new Array(); $j("#imagesinfo ul").each(function(){ var image = new Array(); $j("li", this).each(function(){ image.push($j(this).text()); }); allBgImages.push(image); }); var max = allBgImages.length; //alert("batfight"); if(max > 0){ LoadImages(0,max); } // generate arrays for widths, height, ratio : var imagegap = 0; var current; var imagesLoaded = 0; if(!showcontent){ current = 1; } else { current = 0; } var imageWidths = new Array(); var imageHeights = new Array(); var imageRatios = new Array(); // --- resizeAndScroll(); setNaviSizes(); resetDim(); resetLeftRightNavi(); // thumnbails code //$j("#thumbnails").height($j(document).height()); function setThumbWidth(){ $j("#thumbnails").width($j(window).width()-270); } setThumbWidth(); $j(window).resize(setThumbWidth); $j("#thumbnails a").click(function(){ current = $j(this).index()+1; if(showcontent){ current -= 1; } $j("#thumb-bg").hide(); $j(this).parent().hide(); //$j("#header div").show(); scrollToLeft(1200,'easeInOutExpo', true); resetDim(); setActiveNavi(); resetLeftRightNavi(); }); $j("#thumbnails-btn").click(function(){ if($j("#thumbnails").is(":visible")){ hideThumbs(); } else { showThumbs(); } }); //$j("#header div").hide(); function hideThumbs(){ swapMenuColours(); $j("#thumbnails").stop().animate({top:$j(window).height()}, 500, function(){ $j(this).hide(); $j("#thumb-bg").stop().fadeTo(500, 0, function() { $j(this).hide(); }); //$j("#header div").fadeIn(500); }); } function showThumbs(){ var changes = $j("#header, #menu-main-nav, #side_menu, #right_buttons, #navi-thumbs, #left_buttons, #right_buttons, #thumbnails-btn"); changes.removeClass("light"); changes.removeClass("dark"); changes.addClass($j("body").attr("class")); //$j("#header div").fadeOut(500); $j("#thumb-bg").stop().fadeTo(500,1, function(){ $j("#thumbnails").stop().show().css("top", $j(window).height()); $j("#thumbnails").animate({top:0}, 500); }); } // navi click functions : $j("#navi-thumbs a").click(function(){ current = $j(this).parent().index(); scrollToLeft(1200,'easeInOutExpo', true); resetDim(); setActiveNavi(); resetLeftRightNavi(); }); $j(".prev").click(function(){ var min = 1; if(showcontent){ min = 0; } if(current>min){ current -= 1; } scrollToLeft(1200,'easeInOutExpo', true); resetDim(); setActiveNavi(); resetLeftRightNavi(); }); $j(".next").click(function(){ if(current<$j("#background-images td").size()){ // if there is an image to scroll to current += 1; scrollToLeft(1200,'easeInOutExpo', true); resetDim(); setActiveNavi(); resetLeftRightNavi(); } else if(current < max){ // if next image is loading return false; } else { // if on last image var location = window.location.href.replace("#", ""); var nextloc = $j("a", this).attr("href"); if(location != nextloc){ window.location = $j("a", this).attr("href"); } else { window.location = $j("#menu_names li:eq(0) a").attr("href"); } } }); $j("#showhide").click(function(){ $j("#sidemenu-container").slideToggle(); var a = $j("a", this); if(a.text() == "Show"){ a.text("Hide"); } else { a.text("Show"); } var leftbtn = $j("#left_buttons .prev"); if(leftbtn.css("left").replace(/[^\d]/g,"")==270){ leftbtn.css("left", 0); } else { leftbtn.css("left", 270); } }); // --- // resize on window resize : $j(window).resize(function(){ resizeAndScroll(); setNaviSizes(); }); } // endif (not frontpage) function resizeImages(){ //alert($j("#background-images td").size()); getImageSizes(); var vH = $j(window).height(); var vW = $j(window).width(); var vR = vW/vH; $j("#content-first span").height(vH); var i = 0; $j("#background-images .bg-image").each(function(){ var currentRatio = imageRatios[i]; var newWidth = vW; var newHeight = vH; var newTop = 0; if(currentRatio <= 1){ // portrait if (vH > 500){ newHeight = vH; newWidth = newHeight * currentRatio; } else { newHeight = 500; newWidth = newHeight * currentRatio; } // add left margin to first image if portrait /* if ((i==0)&&(newWidth < vW)){ var x = Math.floor((vW - newWidth)/2); var newContainerWidth = newWidth + x; $j("img", this).css("margin-left", x); } */ if ((i==$j("#background-images .bg-image").size()-1)&&(newWidth < vW)){ var x = Math.floor((vW - newWidth)/2); var newContainerWidth = newWidth + x; //$j("img", this).css("margin-right", x); } } else { // landscape if (vR > currentRatio){ // screen is wider newWidth = vW; newHeight = newWidth/currentRatio; newTop = (vH - newHeight) / 2; } else { newHeight = vH; newWidth = newHeight * currentRatio; } } $j(this).height(newHeight); $j('img', this).height(newHeight); if(newContainerWidth){ $j(this).width(newContainerWidth+imagegap); $j('span', this).width(newContainerWidth); } else { $j(this).width(newWidth+imagegap); $j('span', this).width(newWidth); $j('span', this).height(newHeight); } $j('img', this).width(newWidth); $j('img', this).css("top", newTop); i += 1; }); } // resize all background images function resizeImagesOnce(){ resizeImages(); // don't resize after scroll scrollToLeft(0,'',false); } // --- // resize, scroll and resize again (in case scrollbar comes or goes) function resizeAndScroll(){ resizeImages(); // resize again after scroll : scrollToLeft(0,'',true); } // --- // scroll to centre "current" image function scrollToLeft(speed, easing, resizeafter){ var imagesLeft; var contentLeft; var prevwidth = $j("#content-first").width(); if(current === 0){ contentLeft = 0; imagesLeft = -prevwidth; } else { prevwidth = 0; var currentimg = current-1; if(currentimg >= 0){ for(var i=0;i=naviLoaded){ $j("#navi-thumbs a:eq("+i+")").show().animate({"top": "0px"}, 400, "easeOutBack"); } } } // --- function resetLeftRightNavi(){ if(current===0){ killLeftHover(); killRightHover(); //showSideMenu(); $j(".next").delay(300).stop().animate({"right":0}, 1000, "easeOutBounce"); } else if (current===1 && showcontent===false){ killLeftHover(); killRightHover(); $j(".next").delay(300).stop().animate({"right":0}, 1000, "easeOutBounce"); } else { //hideSideMenu(); liveLeftHover(); liveRightHover(); $j(".next").stop().animate({"right":-80}); } } function getImageSizes(){ imageWidths = []; imageHeights = []; imageRatios = []; $j("#imagesinfo ul").each(function(){ var image = new Array(); $j("li", this).each(function(){ image.push($j(this).text()); }); imageWidths.push(image[2]); imageHeights.push(image[3]); imageRatios.push(image[2]/image[3]); }); } function LoadImages(no,max){ if(no < max){ var img = new Image(); $j(img).load(function(){ $j(this).attr("width", allBgImages[no][2]).attr("height", allBgImages[no][3]); var newtd = $j("").attr("class", allBgImages[no][0]); var newdiv = $j("
").attr("class", "bg-image").append($j("")).append(this); newtd.append(newdiv); $j("#background-images tr").removeClass("loading").append(newtd); if(no==0){ resizeImagesOnce(); } else { resizeImages(); } resetDim(); setNavi(); imagesLoaded += 1; // load thumbnails as large images load : if($j("#thumbnails").length){ //alert("blah"); $j("#thumbnails a:eq("+ no +") span").fadeOut(); $j("#thumbnails .thumbnails:eq("+no+")").fadeIn(); } LoadImages(no+1,max); }).error(function(){ // on error remove current //$j(curr).remove(); // trigger the next image LoadImages(no+1,max); }).attr("src", allBgImages[no][1]); } if (no==1){ resetLeftRightNavi(); setActiveNavi(); } } });