
var h_viewport=0;var w_viewport=0;var image_index_current=1;var gallery_i_current=1;var gallery_thumbnails_width=0;var nv_width=0;var player_var;$(document).ready(function(){h_viewport=$(window).height();w_viewport=$(window).width();if($("#splash_image").length!=0){setTimeout("initialize_splash()",300);return;}if($("#image_index_1").length>0){setTimeout("initialize_front_page()",300);}if($("#gallery_images").length>0){setTimeout("initialize_gallery()",300);}if($("#bio").length>0){setTimeout("initialize_bio()",300);}if($("#clients").length>0){setTimeout("initialize_clients()",300);}if($("#newsletter").length>0){setTimeout("initialize_newsletter()",300);}if($("#contact").length>0){setTimeout("initialize_contact()",300);}if($("#blogs").length>0){setTimeout("initialize_blogs()",300);}});function initialize_splash(){var w=1463;var h=821;if(w_viewport>w&h_viewport>h){var t=Math.round(0.5*(h_viewport-h));var l=0;$("#splash_image").width(1466).height(821).css('margin-top',t+'px').css('margin-left',l+'px');}else{var ratio_w=w_viewport/w;var ratio_h=h_viewport/h;var ratio=Math.min(ratio_w,ratio_h);var w_image=Math.round(ratio*w);var h_image=Math.round(ratio*h);var t=Math.round(0.5*(h_viewport-h_image));var l=Math.round(0.5*(w_viewport-w_image));$("#splash_image").width(w_image).height(h_image).css('margin-top',t+'px').css('margin-left',l+'px');}$("#wrapper").fadeIn();$("#splash_image").show();}function initialize_front_page(){$(".image_index").width(w_viewport);image_index_show(1);setTimeout("image_index_next()",4000);position_nv();$("#wrapper").fadeIn();}function image_index_show(i){var dummy=images_index[i].split('_');var w=dummy[0];var h=dummy[1];height=Math.round(h/w*w_viewport);var top=Math.round(h_viewport-height);$("#image_index_"+i).css('top',top+'px').fadeIn();image_index_current=i;}function image_index_hide(i){$("#image_index_"+i).fadeOut();}function image_index_next(){var i_max=images_index.length;if(i_max==2){return;}image_index_hide(image_index_current);++image_index_current;image_index_current=image_index_current>=i_max?1:image_index_current;image_index_show(image_index_current);setTimeout("image_index_next()",4000);}function position_nv(){if(h_viewport<600){var h=h_viewport-10;var h_1=Math.round(0.17*h);$("#nv").css('top',h_1+'px');}else{var h=parseInt($("#nv").height(),10);var h_available=h_viewport-h;var top=Math.round(0.3*h_available);$("#nv").css('top',top+'px');}if(w_viewport<1000){$("#nv").css('left','10px');}else{var css_left=Math.round(0.13*w_viewport);$("#nv").css('left',css_left+'px');}$("#nv").show();}function gallery_lazy_load(){$.post("/",{task:'gallery_lazy_images',gallery_id:gallery_id},function(data){$("#gallery_images").append(data);});}function initialize_horizontal_bands(){if($("#band_1").length==0){return;}position_nv();var h=h_viewport-10;var h_1=Math.ceil(0.14*h);var h_3=Math.ceil(0.68*h);var h_5=Math.ceil(0.18*h);$("#band_1").height(h_1);$("#band_3").height(h_3);$("#band_5").height(h_5);}function get_nv_width(){$("#nv").show();nv_width=$("#nv").width();alert(nv_width);return;$("a.nv_item").each(function(){var tmp=$(this).width();alert(tmp);if(tmp>nv_width){nv_width=tmp;}});}function initialize_gallery(){initialize_horizontal_bands();setTimeout("gallery_lazy_load()",500);var w_3=Math.ceil(parseInt($("#band_3").height(),10)*1.74);w_3=parseInt(w_3);$("#gallery_images").width(w_3);$("#gallery_thumbnails_mask").width(w_3);var thumbnail_height=parseInt($("#gallery_thumbnail_1").height(),10);gallery_thumbnails_width=Math.ceil(images_total_length*thumbnail_height/200)+4*gallery_i_max+1;$("#gallery_thumbnails").width(gallery_thumbnails_width);if(gallery_thumbnails_width>w_3){$('#gallery_scroll_right').show();}left_thumbnails_min=-gallery_thumbnails_width+w_3;gallery_show(1);$("#wrapper").fadeIn(300);var ml=0;if(w_viewport<1000){ml=parseInt($("#nv").width(),10)+70;}else{ml=parseInt($("#nv").css('left'),10)+parseInt($("#nv").css('width'),10)+Math.round(0.01*w_viewport);}$("#gallery_images").css('left',ml+'px');$("#gallery_thumbnails_mask").css('left',ml+'px');ml+=w_3-30;$("#gallery_counter").css('left',ml+'px');$("#arrow_left, #gallery_area_previous").click(function(){gallery_show_previous();});$("#arrow_right, #gallery_area_next").click(function(){gallery_show_next();});$(".gallery_thumbnail").click(function(){var i=$(this).attr("id").substr(18);gallery_show(i);}).hover(function(){$(this).css('opacity','1.0');},function(){var i=$(this).attr("id").substr(18);if(i!=gallery_i_current){$(this).css('opacity','0.5');}});$('#gallery_scroll_left').hover(function(){var x=Math.ceil(parseInt($("#gallery_thumbnails").css('left'),10));var sec=pixels_to_sec(x);$("#gallery_thumbnails").animate({left:'0px'},sec,function(){show_gallery_scroll_areas();});},function(){$("#gallery_thumbnails").stop();show_gallery_scroll_areas();});$('#gallery_scroll_right').hover(function(){var x=parseInt($("#gallery_thumbnails").css('left'),10);var sec=pixels_to_sec(Math.abs(left_thumbnails_min+x));$("#gallery_thumbnails").animate({left:left_thumbnails_min+'px'},sec,function(){show_gallery_scroll_areas();});},function(){$("#gallery_thumbnails").stop();show_gallery_scroll_areas();});gallery_show(1);$("#wrapper").fadeIn(300);}function show_gallery_scroll_areas(){var x=parseInt($("#gallery_thumbnails").css('left'),10);if(x==0){$('#gallery_scroll_left').hide();}else{$('#gallery_scroll_left').show();}if(x>left_thumbnails_min){$('#gallery_scroll_right').show();}else{$('#gallery_scroll_right').hide();}}function pixels_to_sec(p){if(p<300){return 2000;}else{return p*4;}}function gallery_show(i){gallery_i_current=i;$(".gallery_image").hide();$("#gallery_image_"+gallery_i_current).fadeIn();$(".gallery_thumbnail").css('opacity','0.5');$("#gallery_thumbnail_"+i).css('opacity','1.0');$("#gallery_counter_i").html(i);}function gallery_show_next(){++gallery_i_current;gallery_i_current=gallery_i_current>gallery_i_max?1:gallery_i_current;gallery_show(gallery_i_current);}function gallery_show_previous(){--gallery_i_current;gallery_i_current=gallery_i_current<1?gallery_i_max:gallery_i_current;gallery_show(gallery_i_current);}function initialize_bio(){initialize_video();initialize_horizontal_bands();$("#bio_image_right").click(function(){});var x=0;if(w_viewport<1000){x=parseInt($("#nv").width(),10)+50;x=150;}else{x=parseInt($("#nv").css('left'),10)+parseInt($("#nv").css('width'),10)+Math.round(0.15*w_viewport);}$("#bio").css('left',x+'px');var w=Math.ceil(0.44*w_viewport);var w_image=Math.round(0.6*(w-25));var h_image=Math.round(w_image*640/895);$("#bio_image_left").width(w_image).height(h_image);$("#bio_image_right").width(w_image).height(h_image);var y=Math.round(0.02*h_viewport);$("#bio").css('top',y+'px');y=Math.round(0.03*h_viewport);y=Math.round(0.02*h_viewport);$("#bio_text").css('margin-top',y+'px');$("#wrapper").fadeIn();}function initialize_clients(){initialize_horizontal_bands();var x=0;if(w_viewport<1000){x=250;}else{x=parseInt($("#nv").css('left'),10)+parseInt($("#nv").css('width'),10)+Math.round(0.15*w_viewport);}$("#clients").css('left',x+'px');var y=Math.round(0.05*h_viewport);$("#clients").css('top',y+'px');var w=Math.ceil(0.55*w_viewport);var h=Math.ceil(0.50*h_viewport);$("#clients, #clients_table").width(w);$("#clients_table").height(h);var row_count=$('#clients_table tr').length;var cell_h=Math.floor(h/row_count+1);if(cell_h>40){cell_h=40;}$(".clients_table_cell").height(cell_h);$("#wrapper").fadeIn();}function initialize_newsletter(){initialize_horizontal_bands();var x=0;if(w_viewport<1000){x=350;}else{x=parseInt($("#nv").css('left'),10)+parseInt($("#nv").css('width'),10)+Math.round(0.15*w_viewport);}$("#newsletter").css('left',x+'px');var y=Math.round(0.20*h_viewport);$("#newsletter").css('top',y+'px');$("#newsletter_cancel").click(function(){$("#newsletter_name").val("");$("#newsletter_email").val("");$("#newsletter_feedback").html("");});$("#newsletter_submit").click(function(){$("#newsletter_feedback").html("");$.post("/",{task:'messages_newsletter',name:$("#newsletter_name").val(),email:$("#newsletter_email").val()},function(data){$("#newsletter_feedback").html(data);});});$("#wrapper").fadeIn();}function initialize_contact(){initialize_horizontal_bands();var x=0;var y=0;if(w_viewport<1000){x=250;y=Math.round(0.05*h_viewport);}else{x=parseInt($("#nv").css('left'),10)+parseInt($("#nv").css('width'),10)+Math.round(0.15*w_viewport);y=Math.round(0.15*h_viewport);}$("#contact").css('left',x+'px');$("#contact").css('top',y+'px');$("#contact_cancel").click(function(){$("#contact_name").val("");$("#contact_email").val("");$("#contact_phone").val("");$("#contact_body").val("");$("#contact_feedback").html("");});$("#contact_submit").click(function(){$("#contact_feedback").html("");$.post("/",{task:'messages_contact',name:$("#contact_name").val(),email:$("#contact_email").val(),phone:$("#contact_phone").val(),message:$("#contact_body").val()},function(data){$("#contact_feedback").html(data);});});$("#wrapper").fadeIn();}function initialize_blogs(){position_nv();$("#blogs").css('min-height',h_viewport+'px');var w_blogs=Math.round(0.35*w_viewport);var w_image=Math.round(1.00*w_blogs);$(".blog_image_h").width(w_image);var h_image=Math.round(0.60*w_blogs);$(".blog_image_v").width(w_image);$("#wrapper").fadeIn();}function launch_video_01(){$f('player','http://s3.amazonaws.com/uxp/common_files/flowplayer/flowplayer/flowplayer-3.2.7.swf').ipad({simulateiDevice:true});}function initialize_video(){$("#bio_image_right").click(function(){launch_video();});var player_w=Math.round(0.5*w_viewport);var player_h=Math.round(player_w*720/1280);var player_left=-Math.round(0.5*player_w);$("#player_wrapper, #player").width(player_w).height(player_h);$("#player_wrapper").css('margin-left',player_left+'px');var pos_left=-player_left+player_w;$("#player_close_button").css('left',pos_left+'px');player_var=$f('player',{src:'http://s3.amazonaws.com/davecox/common_files/flowplayer/flowplayer/flowplayer-3.2.7.swf',wmode:'opaque'},{player:{},clip:{autoPlay:false,autoBuffering:true,onStop:function(){}},plugins:{controls:{}}}).ipad();}function launch_video(){var dummy=Math.round(0.5*(w_viewport-1024)+90);$("#video_overlay").width(w_viewport+180).show();$("#player_wrapper").show();$("#player").show();$("#player_close_button").show();player_var.play();}function stop_video(){$("#video_overlay").hide();$("#player_close_button").hide();player_var.stop();$("#player_wrapper").hide();}
