// remote scripting library // (c) copyright 2005 modernmethod, inc var sajax_debug_mode = false; var sajax_request_type = "POST"; var sajax_target_id = ""; var sajax_failure_redirect = ""; function sajax_debug(text) { if (sajax_debug_mode) alert(text); } function sajax_init_object() { sajax_debug("sajax_init_object() called..") var A; var msxmlhttp = new Array( 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'); for (var i = 0; i < msxmlhttp.length; i++) { try { A = new ActiveXObject(msxmlhttp[i]); } catch (e) { A = null; } } if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest(); if (!A) sajax_debug("Could not create connection object."); return A; } var sajax_requests = new Array(); function sajax_cancel() { for (var i = 0; i < sajax_requests.length; i++) sajax_requests[i].abort(); } function sajax_do_call(func_name, args) { var i, x, n; var uri; var post_data; var target_id; sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id); target_id = sajax_target_id; if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "") sajax_request_type = "GET"; uri = "/js/billypavone.js.php"; if (sajax_request_type == "GET") { if (uri.indexOf("?") == -1) uri += "?rs=" + escape(func_name); else uri += "&rs=" + escape(func_name); uri += "&rst=" + escape(sajax_target_id); uri += "&rsrnd=" + new Date().getTime(); for (i = 0; i < args.length-1; i++) uri += "&rsargs[]=" + escape(args[i]); post_data = null; } else if (sajax_request_type == "POST") { post_data = "rs=" + escape(func_name); post_data += "&rst=" + escape(sajax_target_id); post_data += "&rsrnd=" + new Date().getTime(); for (i = 0; i < args.length-1; i++) post_data = post_data + "&rsargs[]=" + escape(args[i]); } else { alert("Illegal request type: " + sajax_request_type); } x = sajax_init_object(); if (x == null) { if (sajax_failure_redirect != "") { location.href = sajax_failure_redirect; return false; } else { sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent); return false; } } else { x.open(sajax_request_type, uri, true); // window.open(uri); sajax_requests[sajax_requests.length] = x; if (sajax_request_type == "POST") { x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } x.onreadystatechange = function() { if (x.readyState != 4) return; sajax_debug("received " + x.responseText); var status; var data; var txt = x.responseText.replace(/^\s*|\s*$/g,""); status = txt.charAt(0); data = txt.substring(2); if (status == "") { // let's just assume this is a pre-response bailout and let it slide for now } else if (status == "-") alert("Error: " + data); else { if (target_id != "") document.getElementById(target_id).innerHTML = eval(data); else { try { var callback; var extra_data = false; if (typeof args[args.length-1] == "object") { callback = args[args.length-1].callback; extra_data = args[args.length-1].extra_data; } else { callback = args[args.length-1]; } callback(eval(data), extra_data); } catch (e) { sajax_debug("Caught error " + e + ": Could not eval " + data ); } } } } } sajax_debug(func_name + " uri = " + uri + "/post = " + post_data); x.send(post_data); sajax_debug(func_name + " waiting.."); delete x; return true; } // wrapper for loadGallery function x_loadGallery() { sajax_do_call("loadGallery", x_loadGallery.arguments); } // wrapper for loadImages function x_loadImages() { sajax_do_call("loadImages", x_loadImages.arguments); } // wrapper for loadLinks function x_loadLinks() { sajax_do_call("loadLinks", x_loadLinks.arguments); } // wrapper for loadContact function x_loadContact() { sajax_do_call("loadContact", x_loadContact.arguments); } // wrapper for loadVideos function x_loadVideos() { sajax_do_call("loadVideos", x_loadVideos.arguments); } // wrapper for loadVideoEmbed function x_loadVideoEmbed() { sajax_do_call("loadVideoEmbed", x_loadVideoEmbed.arguments); } $(function(){ ////////////////////////////////////// //// Centering Functions //// ////////////////////////////////////// var win = $(window); var container = $("#container"); function center() { var topPos = (win.height()-container.outerHeight()) * .5; var leftPos = (win.width()-container.outerWidth()) * .5; if (topPos < 0) { topPos = 0; } if (leftPos < 0) { leftPos = 0; } if (win.height() < 650) { $("#bg").height(650); } else { $("#bg").height(win.height()); } if (win.width() < 1050) { $("#bg").width(1050); } else { $("#bg").width(win.width()); } container.css({ top : topPos, left : leftPos }); } win.resize(function(){ center(); }).trigger("resize"); ////////////////////////////////////// //// Navigation Functions //// ////////////////////////////////////// $("#nav ul li").each(function (i) { var linkText = $("a",this).html(); var linkID = $("a",this).attr("ID") var link = $("a",this).attr("href"); var navMask = $("").attr("src","images/nav-mask.png").attr("class","mask"); $(this).append(navMask); var navMaskOn = $("").attr("src","images/nav-mask-on.png").attr("class","mask-on"); $(this).append(navMaskOn); var linkOn = $("").attr("href",link).attr("class","link-on").attr("ID",linkID).html(linkText).css({ opacity: 0 }).hide(); $(this).append(linkOn).show(); navMask.delay(300*i).animate({ left: 260 }, 650, 'easeInSine'); }); $("#nav ul li").click(function(){ var currID = $("a",this).attr("ID"); $("#nav ul li").each(function (i) { var maskPos = $(".mask-on",this).position(); var navID = $("a",this).attr("ID"); if (maskPos.left != -260) { $(".mask-on",this).animate({ left: 220 }, 350, 'easeInSine', function() { $(this).css({ left: -260 }); }); $(".link-on",this).animate({ opacity: 0 }, 150, 'easeInSine', function() { if (currID != navID) { $(this).hide(); } }); } }); $(".mask-on",this).animate({ left: -20 }, 650, 'easeInSine'); $(".link-on",this).show().delay(150).animate({ opacity: 1 }, 250, 'easeInSine'); }); ////////////////////////////////////// //// Homepage Slideshow Functions //// ////////////////////////////////////// var totalSlides = 0; $('#slides div').each(function(){ var div = $(this); var img = $("img",this); img.css({ "margin-top": (div.height()-img.height()) * .5, "margin-left": (div.width()-img.width()) * .5 }); totalSlides++; }); if (totalSlides > 1) { $('#slides').cycle({ fx: 'fade', speed: 1500, timeout: 6000 }); } }); ////////////////////////////////////// //// Gallery Functions //// ////////////////////////////////////// var currGalleryName = ""; function loadGallery(galleryID,thumbPage,galleryName) { var page = "Page thumbPage"; currGalleryName = galleryName; _gaq.push(['_trackEvent', currGalleryName, 'Load Thumbnails', page]); $("#content").animate({ opacity: 0 }, 500, 'easeInSine', function() { x_loadGallery(galleryID,thumbPage,showGallery); }); } function showGallery(html) { html = html.split("::"); divWidth = html[1]; divHeight = html[2]; $("#content").html(html[0]).animate({ opacity: 1 }, 500, function() { var thumb = $(".thumb"); var thumbImg = $(".thumbImg"); var thumbsDiv = $("#thumbs"); var imagesDiv = $("#images"); thumbsDiv.css({ width: divWidth, height: divHeight, top: (imagesDiv.height()-divHeight) * .5, left: (imagesDiv.width()-divWidth) * .5 }); thumb.each( function(i) { var src = $("img",this).attr("src"); var overlayImg = $("").attr("src","php/overlay.php?src="+src+"").attr("width","75").attr("height","75").attr("class","over").css({ opacity: 0, left: 0 }); $(this).append(overlayImg); var newImg = $("").attr("src","images/thumb-mask.png").attr("width","75").attr("height","75"); $(this).append(newImg); $(this).css({ opacity: 0 }).show(); $(this).delay(i * 100).animate({ opacity: 1 }, 250); $("img:last",this).delay(i * 100).animate({ left: 85 }, 250, function() { $(this).remove(); }); }); thumb.click(function() { var imageID = $(this).attr("id"); $("#content").animate({ opacity: 0 }, 250, function() { $("#content").html("
").css({ opacity: 1 }); x_loadImages(imageID,showImages); }); }); thumb.hover(function() { $(".over",this).clearQueue().animate({ opacity: 1 }, 200);}, function () { $(".over",this).clearQueue().animate({ opacity: 0 }, 200); }); }); } ////////////////////////////////////// //// Video Functions //// ////////////////////////////////////// function loadVideos(thumbPage) { var page = "Page thumbPage"; _gaq.push(['_trackEvent', 'Video', 'Load Thumbnails', page]); $("#content").animate({ opacity: 0 }, 500, 'easeInSine', function() { x_loadVideos(thumbPage,showVideos); }); } function showVideos(html) { html = html.split("::"); divWidth = html[1]; divHeight = html[2]; $("#content").html(html[0]).animate({ opacity: 1 }, 500, function() { var thumb = $(".videoStill"); var thumbImg = $("img",thumb); var thumbsDiv = $("#thumbs"); var imagesDiv = $("#images"); thumbsDiv.css({ width: divWidth, height: divHeight, top: (imagesDiv.height()-divHeight) * .5, left: (imagesDiv.width()-divWidth) * .5 }); thumb.each( function(i) { var newImg = $("").attr("src","images/button-play.png").attr("class","play").attr("width","83").attr("height","95"); $(this).append(newImg); newImg.css({ top: ($(this).height()-newImg.height()) * .5, left: ($(this).width()-newImg.width()) * .5, opacity: 0 }); $(this).css({ opacity: 0 }).show(); $(this).delay(i * 250).animate({ opacity: 1 }, 350); $("img:first",this).delay(i * 250).animate({ opacity: 1 }, 350); }); thumb.click(function() { var videoID = $(this).attr("id"); $("#content").animate({ opacity: 0 }, 250, function() { $("#content").html("
").css({ opacity: 1 }); loadVideoEmbed(videoID); }); }); thumb.hover(function() { $("img:last",this).clearQueue().animate({ opacity: .65 }, 200); }, function () { $("img:last",this).clearQueue().animate({ opacity: 0 }, 200); }); }); } function loadVideoEmbed(videoID) { _gaq.push(['_trackEvent', 'Video', 'View Video', videoID]); $("#images").animate({ opacity: 0 }, 250, function(i) { $(this).html(""); $("#content").html("
"); x_loadVideoEmbed(videoID,showVideoEmbed); }); } function showVideoEmbed(html) { html = html.split("::"); imageID = html[1]; $("#content").html(html[0]).css({ opacity: 1 }); div = $("#images"); vid = $(".video"); vid.css({ opacity: 0, top: (div.height()-vid.height()) * .5, left: (div.width()-vid.width()) * .5 }); vid.animate({ opacity: 1 }, 250); } ////////////////////////////////////// //// Image Functions //// ////////////////////////////////////// function loadImages(imageID) { x_loadImages(imageID,showImages); } function showImages(html) { html = html.split("::"); imageID = html[1]; $("#content").html(html[0]).animate({ opacity: 1 }, 250); setImageNav(imageID); $("#images div").each(function (i) { var div = $(this); var img = $("img",this); var imgID = $(this).attr("id"); if (imageID != imgID) { $(this).css({ opacity: 0 }); } img.css({ opacity: 0 }); img.load(function(){ $(this).css({ "margin-top": (div.height()-img.height()) * .5, "margin-left": (div.width()-img.width()) * .5 }); $(this).parent().removeClass("loading"); $(this).parent().css({ opacity: 0 }); $(this).css({ opacity: 1 }); if (imageID == imgID) { $(this).parent().animate({ opacity: 1 }, 250); } }); }); } function showImage(imageID) { _gaq.push(['_trackEvent', currGalleryName, 'View Image', imageID]); $("#images div").each(function (i) { if (imageID != $(this).attr("id")) { $(this).animate({ opacity: 0 }, 450, function() { }); } else { $(this).animate({ opacity: 1 }, 450); } }); setImageNav(imageID); } function setImageNav(imageID) { var curr = $("#"+imageID); var nextButton = $("#nextButton"); var previousButton = $("#previousButton"); var nextID = curr.next().attr("id"); var previousID = curr.prev().attr("id"); if (nextID != undefined) { nextButton.attr("href","javascript:showImage('"+nextID+"');").removeClass("inactive"); } else { nextButton.addClass("inactive"); } if (previousID != undefined) { previousButton.attr("href","javascript:showImage('"+previousID+"');").removeClass("inactive"); } else { previousButton.addClass("inactive"); } } ////////////////////////////////////// //// Page Functions //// ////////////////////////////////////// function loadPage(page) { _gaq.push(['_trackEvent', page, 'Load Page', '']); $("#content").animate({ opacity: 0 }, 250, function(){ $("#content").html(); if (page == "links") { x_loadLinks(showLinks); } if (page == "contact") { x_loadContact(showContact); } if (page == "video") { x_loadVideos("0",showVideos); } }); } function showLinks(html) { $("#content").html(html); $("#links").css({ top: ($("#images").height()-$("#links").outerHeight())*.5 }); $("#links li").each(function(i){ $(this).css({ opacity: 0 }).delay(i * 150).animate({ opacity: 1 }, 250); }); $("#content").animate({ opacity: 1 }, 250); } function showContact(html) { $("#content").html(html); $("#contact").css({top: (($("#images").height()-$("#contact").outerHeight())*.5)-50 }); $("#content").animate({ opacity: 1 }, 250); }