$(document).ready(function() {
		
				
		//load the first image:
		//$("#bg_holder").append( "<div id=\"img_0\" class=\"bg_img_holder\"><img src=\"" +  all_bg_imgs[0] + "\" width=\"1232\" height=\"693\" class=\"bg_img\" id=\"bg_img_0\"></div>" );
		
		
		current_img_div = 0;
		resize_bg_image();
		
		init_panels();
		ga_tracking('home/','')
		place_content_panels( 0 );		
		
               //$(this).mouseenter
               
               
		
		fill_testimonial();
		fill_testimonial_a();
		fill_testimonial_cs();
		
		
		//position the footer:
		temp = footer_spacer + $("#panel_0").height();
		$("#footer").css("top",temp);
		$("#footer").show();
		
		//set timout since this is homepage:
		$("#logo_dark").show();
		init_animation( 'home' );
		
		$("#logo_dark, #logo_light").click( function(){
			play_content( '' );
		});
		
		$("#menu_button").mouseenter( function(){
				//menu_button_label_on
				$('#menu_label').removeClass('menu_button_label_off').addClass('menu_button_label_on');
				clearTimeout (menu_timer);
				open_menu();
		});
		
		$("#menu_button").mouseleave( function(){					
				set_menu_timer();
		});
		
		$("#menu_container").mouseenter( function(){
			clearTimeout (menu_timer);
			
		});

		$("#menu_container").mouseleave( function(){
			//close_menu();
			close_menu()
			//set_menu_timer();
		});

		
		$(".menu_links a, .menu_links").mouseenter( function(){
				clearTimeout (menu_timer);
				//rollover
		})
		
		$("#menu_links a").mouseleave( function(){
				//set_menu_timer();
				//rollover
		})
		
		
		$(".menu_links a").click( function(){
				close_menu();
				$(this).blur();
				//$(".selected_menu").removeClass("selected_menu");
				//change all images to unselected
				play_content( $(this).attr("id") );
				//$(this).addClass("selected_menu");
		})
		
		$(".footer_link").click( function(){
			
			tempid = ( $(this).attr("id") ).replace("footer", "links")
			play_content( tempid );
		})
		
		
		$("#tagline_mouseover").mouseenter( function(){
				toggle_tagline();
		});
		
		$(".hwh_link").mouseenter( function(){
			//alert( $(this).parent().attr("id") );
			$(this).parent().removeClass("hwh_label_off").addClass("hwh_label_on");
			$(this).parent().parent().removeClass("hwh_row_off").addClass("hwh_row_on");
		});
		$(".hwh_link").mouseleave( function(){
			//alert( $(this).parent().attr("id") );
			$(this).parent().removeClass("hwh_label_on").addClass("hwh_label_off");
			$(this).parent().parent().removeClass("hwh_row_on").addClass("hwh_row_off");
		});
		$(".hwh_link").click( function(e){
		    e.preventDefault();
			temp = $(this).parent().attr("id");
			if( temp == "hwh_design"){
			    play_content( 'links_design' )
			}
			if( temp == "hwh_dev"){
			    play_content( 'links_development' )
			}
			if( temp == "hwh_con"){
			    play_content( 'links_consultation' )
			}
		});
		
		
		$(".testimonial_launcher").live("mouseenter", function(){
			$(this).parent().parent().parent().parent().removeClass("bg_panel_blue").addClass("bg_panel_blue_100");
		
		});
		
		$(".testimonial_launcher").live("mouseleave", function(){
			$(this).parent().parent().parent().parent().removeClass("bg_panel_blue_100").addClass("bg_panel_blue");
			
		});
		
		$(".testimonial_launcher").live("click", function(e){
			e.preventDefault();
			
			
			id = $(this).attr("id")
			if (id=='about_testimonials') {
				testmonial_to_show = next_testmonial_a;
			}else if(id=='cs_testimonials'){
				testmonial_to_show = next_testmonial_cs;
			}else{
				testmonial_to_show = next_testmonial;
			}
			
			//open_modal ( "testimonials.htm #tp_container" );
			play_content( 'links_testimonials' )
		});
		
		$(".tp_nav_block_off, .tp_nav_block_on").live("click", function(e){
			replace_testimonial( $(this).attr("id") );
		});
		
		/********************************************
		modal links
		*********************************************/
		//
		$("#modal_overlay, #modal_close").live( 'click', function(){
			close_modal();
		});
		$("#modal_close, .folio_close").live( 'mouseenter', function(){
			$(this).attr("src", "images/modals/close_on.png");
		});
		$("#modal_close, .folio_close").live( 'mouseleave', function(){
			$(this).attr("src", "images/modals/close_off.png");
		});
		
		$(".folio_close").live('click', function() {
			close_folio_example( $(this).parent().parent().parent().attr("id") );
		});
		
		/**/
		//folio_thumb
		$(".folio_thumb_overlay").mouseenter( function(){
			$(this).parent().parent().removeClass('folio_thumb_container').addClass('folio_thumb_container_on')
			id = $(this).parent().attr('id');
			//console.log( id + " entering");
			$("#" + id + "_c").animate(
				{top: 0},
				600
			)
		});
		
		$(".folio_thumb_overlay").mouseleave(function() {
			$(this).parent().parent().removeClass('folio_thumb_container_on').addClass('folio_thumb_container')
			id = $(this).parent().attr('id');
			//console.log( id + " leaving");
			$("#" + id + "_c").animate(
				{top: 140},
				600
			)
		});
		
		
		$(".folio_thumb_overlay").click( function(){
			open_folio_example( parseInt(  $(this).parent().attr("id").toString().replace("ft","") ) );
			//console.log('fired')
		});
/*		
	    $("div").click(function(event) {
              console.log($(this).attr("id"))
              //  console.log(event.target.id + " " + $(this).attr("id"));
                
         });
	
	*/	
		$(".tp_nav_block_off").live("mouseenter", function(){
			$(this).removeClass("tp_nav_block_off").addClass("tp_nav_block_on");
		
		});
		
		$(".tp_nav_block_on").live("mouseleave", function(){
			$(this).removeClass("tp_nav_block_on").addClass("tp_nav_block_off");
			
		});
		
		
		
		//$("#tl_1").animate({left: -( $("#tl_1").width()+150 )}, 500);
		//$("#tl_2").delay(250).animate({left: -( $("#tl_2").width()+150 )}, 500);
		
		//init the taglines:
		$("#tl_1").css( "left", -( $("#tl_1").width()+150 ));
		$("#tl_2").css( "left", -( $("#tl_2").width()+150 ) );
		
		
		$("#tl_1").animate({left: 0}, 500);
		$("#tl_2").delay(250).animate({left: 0}, 500, function(){
				$("#tl_1").delay(1500).animate({left: -( $("#tl_1").width()+100 )}, 500);
				$("#tl_2").delay(1700).animate({left: -( $("#tl_2").width()+170 )}, 500, function(){
					
					tagline_state = "closed";	
					
				});
			}
		);
		
		$('.folio_tab').live("mouseenter",function(){
		    $(this).addClass('tab_on');
		    
		});
		
		$('.folio_tab').live("mouseleave",function(){
		    $(this).removeClass('tab_on');
		    
		});
		
		$(".t_tab_off").live('click', function() {
			play_testimonial_tab();
		});
		
		$(".cl_tab_off").live('click', function() {
			play_clientlist_tab();
		});
		
		
		$('.folio_tab').live("click",function(){
		    $(".folio_tab_sel").removeClass('folio_tab_sel').addClass("folio_tab");
		    $(this).removeClass().addClass('folio_tab_sel');
		    temp = $(this).attr("id");
		    //alert($(this).attr("id"))
		    //$('.folio_example_container').html('<img src="images/folio/' + $(this).attr("id") + '.png">')
		    $('#folio_image').animate( {opacity:0},500,function(){
		    	
		    	
		    	$('#folio_image').html('<img src="images/folio/' + temp + '.png" id="folio_img_tag">')
		    	
		    	
		    	$('#folio_image').delay(500).animate( {opacity:1},500 );
		    });
		});
		
		$(window).bind("resize", function(){
			
			
			resize_bg_image();
			
			init_panels();
			place_content_panels(current_pos);			
		 });
});

var footer_spacer = 80;
var current_img_div = "";
var current_pos, current_left, menu_timer, panel_width, panel_count, panel_total_width,win_width,base_left,panel_container_width, tagline_state;
var menu_open = false;
var design_thumbs_loaded = false;
var development_thumbs_loaded = false;
var intervalID;

function init_animation( str ){
	//console.log("init: ", str)
	if( str == 'home'){
		val = 5000;
	}else{
		val = 7500;
	}
	intervalID = setInterval('play_' + str + '_animation()', val);
	
}
function toggle_tagline(){
	
	if( tagline_state == "closed"){
		open_taglines()
	}
}

function open_taglines(){
		tagline_state = "open";	
		$("#tl_1").animate({left: 0}, 500);
		$("#tl_2").delay(250).animate({left: 0}, 500, function(){
				
					
					close_taglines()
			
			}
		);

}


function close_taglines(){
	
				$("#tl_1").delay(1500).animate({left: -( $("#tl_1").width()+100 )}, 500);
				$("#tl_2").delay(1700).animate({left: -( $("#tl_2").width()+170 )}, 500, function(){
					
					tagline_state = "closed";	
					
				});
		
		
	
}

function init_panels(){
	
	//the width of the content panels:
	panel_width = $(".content_panel").width();
	//the number of content panels:
	panel_count = $(".content_panel").size();
	//the total width of all panels:
	panel_total_width = panel_width * panel_count;
	
	//get the window width at the time this function is called
	win_width = $(window).width();
	
	//the left margin of screen not taken by panel 
	base_left = parseInt( ( win_width - panel_width )/2 );
	
	panel_container_width = panel_total_width + ( base_left * panel_count );
	
	$(".content_panel").css("margin-left", base_left + "px");
	$("#panel_container").css("width", panel_container_width + "px");
}

function place_content_panels( pos ){
	
	
	//console.log( "CP IS: " + current_pos );
	//use the positions (pos) past to establish the left position of the panel. always a negative value since its to the left of screen:
	var step = pos * ( base_left + panel_width ) * -1;
	
	$("#panel_container").css("left", step + "px");

	//the current panel
	current_pos = pos;
	
	//the current left point:
	current_left = step;

}



function move_content_panel( moveto, bg ){
	
	
	
	if( moveto != current_pos ){
		
	
		//$("#tagline_container").fadeOut();
		temp = footer_spacer + get_tallest_panel( current_pos, moveto );
		speed = Math.abs( moveto - current_pos ) * 500;
		
		$("#footer").animate({
				top: temp 
				}, 100,function(){
					//use the positions (pos) past to establish the left position of the panel. always a negative value since its to the left of screen:
					var step = moveto * ( base_left + panel_width );
				
					
					$("#panel_container").animate({
						left: -step 
						//left: '-=' + ( current_left + step ) 
					 }, speed,function(){
						
						
						
						current_pos = moveto;
						
						if( moveto == 0 ){
							replace_bg_img( 0 );
							init_animation( 'home' )
							//$("#tagline_container").fadeIn();
						}else if( moveto == 3 ){
							replace_bg_img( 7 );
							init_animation( 'design' )
							load_folio_thumbs( 'design' );
						}else if( moveto == 4 ){
								replace_bg_img( 13 );
								init_animation( 'development' )
								load_folio_thumbs( 'development' );
						}else if( moveto ==2 || moveto == 5 || moveto == 6 ){
								//rand from 7 to 17
								n = randomFromTo(7,17)
								replace_bg_img( n );
								init_animation( 'services' )
						}
						else{
							replace_bg_img( bg );
						}
						
						adjust_footer(current_pos);
						
						
						 
					 })
				})
	 
	}
	 
	 
}


function adjust_footer(current_pos){
	
	temp = footer_spacer + $("#panel_" + current_pos).height();;
						$("#footer").animate({
						top: temp 
						}, 500)
						
}


function resize_bg_image(){
	
	var original_width = $(".bg_img").attr("width");
	var original_height = $(".bg_img").attr("height");
	
	var $win_width = $(window).width();
	var $win_height = $(window).height();

	
	
	$(".bg_img").attr({
				width: $win_width,
				height: $win_width * (original_height/original_width)
	});
	if( $(".bg_img").attr("height") <   $win_height ){
		$(".bg_img").attr({
				height: $win_height,
				width: $win_height * (original_width/original_height)
		});	
	}
	
}



function replace_bg_img( n ){
	
	
	
	
	//this_img_div = "img_" + n;
	img_to_load = all_bg_imgs[n];
	
		
		
		//$("#lower_src").onImagesLoad( function(){
		//	alert("i have loaded")
		//}).load().attr("src", all_bg_imgs[n]);
		
		$("#top_image").css({opacity:1})
		//console.log("asked to load ", img_to_load)
		/*
		$("#lower_src").attr('src', img_to_load).load(function() {
                    //fade out upper image on top of lower image
                    
                    //console.log("loaded ", img_to_load)
                    
                    $("#top_image").animate( {opacity:0},1000,function(){
                    	//on callback: add the src of lower to upper
                    	//make upper opaque     
                    	$("#top_src").attr('src', $("#lower_src").attr('src') );
                    	$("#top_image").css({opacity:1})
                    	current_img_div = n;
                    })
                    
        });
		*/
		
		$("#lower_src").attr('src', img_to_load).one( "load" ,function() {
                    //fade out upper image on top of lower image
                    
                   // console.log("loaded ", img_to_load)
                    
                    $("#top_image").animate( {opacity:0},1000,function(){
                    	//on callback: add the src of lower to upper
                    	//make upper opaque    
                    	//console.log("complete ", img_to_load) 
                    	$("#top_src").attr('src', $("#lower_src").attr('src') );
                    	//$("#top_image").css({opacity:1})
                    	current_img_div = n;
                    })
                    
        });

		//store the current image for future removal:
		//tempimg = "#img_" + current_img_div;
		
		
		

	
}

function switch_logo( n ){
	//all_logo_states[0]
	$("#logo_dark").hide();
	$("#logo_light").hide();
	$("#logo_" + all_logo_states[n]).show();
}


function play_home_animation(){
	
	
	if( current_img_div < 4 ){
		n = current_img_div + 1;
		replace_bg_img(n);
	}
	if( current_img_div > 4 ){
		replace_bg_img(0);
	}
	//alert( current_img_div );
		
}


function play_design_animation(){
	
	if( current_img_div < 12 ){
		n = current_img_div + 1;
		replace_bg_img(n);
	}
	if( current_img_div >= 12 ){
		replace_bg_img(7);
	}
	//alert( current_img_div );
		
}

function play_development_animation(){
	
	if( current_img_div < 18 ){
		n = current_img_div + 1;
		replace_bg_img(n);
	}
	if( current_img_div >= 18 ){
		replace_bg_img(13);
	}
	//alert( current_img_div );
		
}

function play_services_animation(){
	
	if( current_img_div < 18 ){
		n = current_img_div + 1;
		replace_bg_img(n);
	}
	if( current_img_div >= 18 ){
		replace_bg_img(7);
	}
	//alert( current_img_div );
		
}

all_bg_imgs = new Array();
all_bg_imgs[0] = "images/bg/hand_1.jpg";
all_bg_imgs[1] = "images/bg/hand_2.jpg";
all_bg_imgs[2] = "images/bg/hand_3.jpg";
all_bg_imgs[3] = "images/bg/hand_4.jpg";
all_bg_imgs[4] = "images/bg/hand_5.jpg";
all_bg_imgs[5] = "images/bg/contact.jpg";
all_bg_imgs[6] = "images/bg/retro_crew.jpg";
all_bg_imgs[7] = "images/folio/cag.jpg";
all_bg_imgs[8] = "images/folio/csb.jpg";
all_bg_imgs[9] = "images/folio/exp.jpg";
all_bg_imgs[10] = "images/folio/ssj.jpg";
all_bg_imgs[11] = "images/folio/stl.jpg";
all_bg_imgs[12] = "images/folio/zsq.jpg";

all_bg_imgs[13] = "images/folio/bdm.jpg";
all_bg_imgs[14] = "images/folio/bfm.jpg";
all_bg_imgs[15] = "images/folio/jux.jpg";
all_bg_imgs[16] = "images/folio/mck.jpg";
all_bg_imgs[17] = "images/folio/mep.jpg";
all_bg_imgs[18] = "images/folio/mk3.jpg";


all_logo_states = new Array();
all_logo_states[0] = "dark";
all_logo_states[1] = "dark";
all_logo_states[2] = "dark";
all_logo_states[3] = "dark";
all_logo_states[4] = "dark";
all_logo_states[5] = "light";
all_logo_states[6] = "light";
all_logo_states[7] = "dark";
all_logo_states[8] = "dark";
all_logo_states[9] = "dark";
all_logo_states[10] = "dark";
all_logo_states[11] = "dark";
all_logo_states[12] = "dark";
all_logo_states[13] = "dark";
all_logo_states[14] = "dark";
all_logo_states[15] = "dark";
all_logo_states[16] = "dark";
all_logo_states[17] = "dark";
all_logo_states[18] = "dark";


function play_content( id ){
	
	clearInterval(intervalID);
	//if id=home,
	//show the taagline
	//ekse hide the tagline
	
	//alert( current_pos );	
	if( current_pos==3 || current_pos==4){
		
		close_folio(current_pos);
	}
	
	//defaults, will go home if nothing set:
	n = 0;
	bg= 0;
	
	ga_tracking(id, '');
	
	
	if( id == "links_about" ){
		n = 1;
		bg = 6;
		//replace_bg_img( n );
	}
	
	if( id == "links_services" ){
		n = 2;
		bg = 2;
		//replace_bg_img( n );
	}
	
	if( id == "links_contact" ){
		n = 7;
		bg=5;
		//replace_bg_img( n );
	}
	
	if( id == "links_design" ){
		n = 3;
		bg=7;
		//replace_bg_img( n );
	}
	
	
	if( id == "links_development" ){
		n = 4;
		bg=13;
		//replace_bg_img( n );
	}
	
	if( id == "links_clients" ){
		n = 6;
		bg=13;
		play_clientlist_tab();
		populate_testimonial();
		//load client list
		//replace_bg_img( n );
	}
	
	if( id == "links_testimonials" ){
		n = 6;
		bg=13;
		play_testimonial_tab();
		populate_testimonial();
		//load testimonials:
		//replace_bg_img( n );
	}
	
	
	if( id == "links_consultation" ){
		n = 5;
		bg=13;
		//replace_bg_img( n );
	}
	
	//
	move_content_panel( n, bg );
}

function get_tallest_panel( current, future ){
	
	if( current > future ){
		
		start = future;
		end = current;
		
	}else{
		
		end = future;
		start = current;
		
	}
	
	//console.log( start + " _ " + end );
	var tallest_panel = 0;
	while( start <= end ){
		
		temp = $("#panel_" + start).height();
		
		//console.log( temp )
		
		if( temp > tallest_panel ){
			//console.log(temp + " is greater than " + tallest_panel )
			tallest_panel = temp;
		}
		
		start++;	
	}
	
	//console.log("returning " + tallest_panel )
	return tallest_panel;
	//temp = 140 + $("#panel_0").height();
	//$("#footer").css("top",temp);
	
}



function fill_testimonial(){
	
		
		
		var n;
		n = Math.floor(Math.random()* testimonial.length  );
		next_testmonial = n+1;
		if( n >= testimonial.length){
			n=1;
		}
		
		
		$("#quote_quote").html(testimonial[n]);
		$("#quote_by").html(testimonial_by[n]);
		$("#quote_co").html(testimonial_co[n]);

	
}

//get_next_testimonial()
function fill_testimonial_a(){
	
		
		
		var n;
		n = get_next_testimonial();
		next_testmonial_a = n+1;
		if( n >= testimonial.length){
			n=1;
		}
		$("#quote_quote_a").html(testimonial[n]);
		$("#quote_by_a").html(testimonial_by[n]);
		$("#quote_co_a").html(testimonial_co[n]);

	
}

function fill_testimonial_cs(){
	
		
		
		var n;
		n = randomFromTo(0, testimonial.length)
		next_testmonial_cs = n+1;
		
		if( n >= testimonial.length){
			n=1;
		}

		$("#quote_quote_cs").html(testimonial[n]);
		$("#quote_by_cs").html(testimonial_by[n]);
		$("#quote_co_cs").html(testimonial_co[n]);

	
}


function open_modal( url ){
	
	$("body").append('<div id="modal_overlay"></div>');
	$("#modal_overlay").css({opacity:0.95});
	$("#modal_overlay").fadeIn(800, function(){
		
		
		$("body").append('<div id="modal_container"><div id="modal_content"></div></div>');
		
		$("#modal_content").load(url, function(){
					
					
					if( url == "testimonials.htm #tp_container"  ){
						
						load_testimonial_content();	
					}
					
					temph =  $("#modal_content").height() ;

					var windowHeight = document.documentElement.clientHeight;
					var popupHeight = $("#modal_container").height() + temph ;
					var headerHeight = 160;
					var idealHeight = windowHeight/2-popupHeight/2;
					
					if( idealHeight <= headerHeight ){
						 idealHeight = headerHeight;	
					}
					
					
					$("#modal_container").css({
						"position": "absolute",
						"top":  idealHeight
					});
					
					$("#modal_container").slideDown( 50, function(){
						//alert("show");
						$("#modal_content").css({"visibility": "visible", "display": "none"});
						$("#modal_content").css("display: none");
						$("#modal_content").slideDown( function(){
							$("#modal_close").show();	
						});
						
						
						
					});
			
		});
		
	});
}



function replace_testimonial( str ){
	temp = str.toString().substring(7);
	n = temp-1;
	
	$(".tp_nav_block_sel").removeClass("tp_nav_block_sel").addClass("tp_nav_block_off");
	
	$("#tp_nav_" + temp).removeClass("tp_nav_block_on").addClass("tp_nav_block_sel");
	
	$("#tp_quote_by").slideUp();
	$("#tp_quote_co").slideUp();
	$("#tp_quote_quote").slideUp( function(){
		$("#tp_quote_quote").html(testimonial[n]);
		$("#tp_quote_by").html(testimonial_by[n]);
		$("#tp_quote_co").html(testimonial_co[n]);
		
		$("#tp_quote_quote").slideDown(function(){
			$("#tp_quote_by").slideDown();
			$("#tp_quote_co").slideDown();
			
		});
		
		
		
		
		
	})
	
	
}

function get_next_testimonial(){
	
	if(	next_testmonial >=  testimonial.length){
		return 0;
	}else{
		return next_testmonial;
	}
}


function close_modal(){
	

			$("#modal_overlay").fadeOut(500, function(){
				$("#modal_overlay").empty().remove();
			});
			if( $.browser.msie ){
				$("#modal_container").hide(); //fadeOut(500);
				$("#modal_container").empty().remove();
			}else{
				
				$("#modal_container").fadeOut(500, function(){
					$("#modal_container").empty().remove();
				});
			}
			//
			//$("#modal_container").empty().remove();
}


function open_menu(){
	if (!menu_open) {
		$("#menu_container").animate({top: 0}, 1000, function(){
			menu_open=true;
		})
	};
}

function close_menu(){
	//change meny open variable to something based on actual position
	//like a css value for height/top, etc.
	
	if (menu_open) {
		$("#menu_container").animate({top: -200}, 500, function(){
			menu_open = false;
		});
		$('#menu_label').removeClass('menu_button_label_on').addClass('menu_button_label_off');
	}
}

function set_menu_timer(){
	//alert("set menu")
	menu_timer = setTimeout( close_menu,1000 );
}


function load_folio_thumbs( str ){
	
	if( str == 'design' && !design_thumbs_loaded ){
		
		//alert("loading");
		
		$('#ft1').css("backgroundImage", "url(images/folio/cag_t.jpg)"); 
		$('#ft2').css("backgroundImage", "url(images/folio/csb_t.jpg)");
		$('#ft3').css("backgroundImage", "url(images/folio/exp_t.jpg)");
		$('#ft4').css("backgroundImage", "url(images/folio/ssj_t.jpg)");
		$('#ft5').css("backgroundImage", "url(images/folio/stl_t.jpg)");
		$('#ft6').css("backgroundImage", "url(images/folio/zsq_t.jpg)");
		
		design_thumbs_loaded = true;
			
	}
	
	if( str == 'development' && !development_thumbs_loaded ){
		
		//alert("loading");
		
		$('#ft7').css("backgroundImage", "url(images/folio/bdm_t.jpg)"); 
		$('#ft8').css("backgroundImage", "url(images/folio/bfm_t.jpg)");
		$('#ft9').css("backgroundImage", "url(images/folio/jux_t.jpg)");
		$('#ft10').css("backgroundImage", "url(images/folio/mck_t.jpg)");
		$('#ft11').css("backgroundImage", "url(images/folio/mep_t.jpg)");
		$('#ft12').css("backgroundImage", "url(images/folio/mk3_t.jpg)");
		
		development_thumbs_loaded = true;
			
	}
	
}

function open_folio_example( id ) {
	
	/*
		
		The image id is the folio id + 6
		This is because of the placement of the images
		in the all_bg array
		
	 */
	
	
	clearInterval(intervalID);
	
	//console.log("open folio example")
	//console.log( temp )
	if( id < 7){
		//in design section
		$("#folio_row_1").fadeOut();
		$("#folio_row_2").fadeOut( function(){
			play_folio("design",id)
		
			
		});
	}else{
		//in dev section
		$("#folio_row_3").fadeOut();
		$("#folio_row_4").fadeOut( function(){
			
			play_folio("dev",id)
		});
	}
	
}

function close_folio( pos ){
	
	//do nothing at all if there is no example open:
	if( current_folio_example > 0 ){
		
		if (pos==3) {
			str="folio_design_container";
		} else{
			str="folio_dev_container";
		};
		close_folio_example( str );
	}
	
}

var current_folio_example;
function close_folio_example( str ){
	//alert(str)
	if (str=="folio_design_container") {
		intro = "design_intro"	;
		block = "folio_design_block";
		rows = "#folio_row_1,#folio_row_2";
		anim_str = "design";
	}else{
		intro = "dev_intro"	;
		block = "folio_dev_block";
		rows = "#folio_row_3,#folio_row_4";
		anim_str = "development"
	}
	example_to_unload = "folio_container_" + current_folio_example;
	
	$(".folio_closer").hide();
	$("#" + example_to_unload).slideUp("slow",function(){
		
		$("#" + intro).slideDown( function(){
			block_height = $("#" + intro).height();
			//padding = parseInt ( $("#" + block).css("padding-top").replace("px", "") ) + parseInt ( $("#" + block).css("padding-bottom").replace("px", "") )
			total_height = block_height;
			$("#" + block).animate({height:total_height},500, function(){
				$(rows).fadeIn();
			});
			init_animation( anim_str )
		});
		$("#" + str).empty();

	});	
	current_folio_example=0;
}

function play_folio(str,id){
	
	//console.log("play folio")

	current_folio_example = id;
		$("#folio_" + str + "_block").animate(
				{height:600}, 1000, function(){
				    $("#" + str + "_intro").slideUp( function(){
				    	
				    	
				    	$("#folio_" + str + "_loader").fadeIn();
				        example_to_load = "folio_container_" + id;
				        
				        ga_tracking("folio", example_to_load);
				        
			       		$("#folio_" + str + "_container").load("folio.htm  #" + example_to_load, function(){
			       			$("#folio_" + str + "_loader").delay(1000).fadeOut( function(){
			       				
			       				$("#" + example_to_load).slideDown("slow",function(){
				       				$(".folio_closer").show();
				       			});	
				       				n = id + 6;
									//console.log( all_bg_imgs[n])
									replace_bg_img(n);
			       			});
			       			
			       		})
				      	
				     	
				    })
				    
				}
			)
			
}

function randomFromTo(from, to){
       return Math.floor(Math.random() * (to - from + 1) + from);
}


function play_testimonial_tab(){
	
	if($("#t_tab").attr("class") != "t_tab_on"){
		//$("#t_tab").animate({opacity:0},250, function(){
			
			$("#t_tab").animate({left:0,top:60},250, function(){
				
				$("#t_tab").css('z-index',7)
				$("#t_tab").removeClass().addClass("t_tab_on");
				
			});
			
			
		//})
		$("#cl_tab").animate({left:50,top:0},250);
		$("#cl_tab").css('z-index',6)
		$("#cl_tab").removeClass().addClass("cl_tab_off");
	}

}

function play_clientlist_tab(){
	
	if($("#cl_tab").attr("class") != "t_tab_on"){
		//$("#cl_tab").animate({opacity:0},250, function(){
			
			$("#cl_tab").animate({left:0,top:60},250, function(){
				
				$("#cl_tab").css('z-index',7)
				$("#cl_tab").removeClass().addClass("cl_tab_on");
				
			});
			
		//})
		$("#t_tab").animate({left:50,top:0},250);
		$("#t_tab").css('z-index',6)
		$("#t_tab").removeClass().addClass("t_tab_off");
	}
}
			
function populate_testimonial(){
	
	//console.log("calling pop test now")
	
	if(	testmonial_to_show >=  testimonial.length){
		testmonial_to_show = 0;
	}
	
	var n = testmonial_to_show;

	$("#tp_quote_quote").html(testimonial[n]);
	$("#tp_quote_by").html(testimonial_by[n]);
	$("#tp_quote_co").html(testimonial_co[n]);
	
	$(".tp_nav_block_sel").removeClass("tp_nav_block_sel").addClass("tp_nav_block_off");
	
	//console.log( "nav click: " + "#tp_nav_" + (n+1))
	$("#tp_nav_" + (n+1)).removeClass().addClass("tp_nav_block_sel");
	
	
}

function  ga_tracking(str, str2){
	
	var url_to_track;
	
	if( str == "folio"){
		url_to_track = "folio/" + str2;
	}else{
		
		str2 = str.replace("links_","")
		url_to_track = str2 + "/";
	}
	
	//console.log(url_to_track);
	_gaq.push(['_setAccount', 'UA-812180-1']);
	_gaq.push(['_trackPageview', '/' + url_to_track]);
	
}

var next_testmonial = '';
var next_testmonial_a  = '';
var next_testmonial_cs  = '';
var testmonial_to_show = 0;


var testimonial  = new Array();
var testimonial_by  = new Array();
var testimonial_co  = new Array();

testimonial[0]='Marc was a recommended to us for a fast turn-around micro site that we needed. He jumped right in and helped us meet that deadline with style. We have since used him on several other projects and plan to continue our relationship with him for a long time to come. He is fast, creative, reasonably priced and a pleasure to deal with! A really great resource!';
testimonial_by[0]='Meira Smith, Account Executive';
testimonial_co[0]= 'Mc|K Healthcare';


testimonial[1]='We contracted Marc to work on our new mass market web app/site. The project was complex, had an aggressive schedule and required high-quality work. Marc quickly blended into the project, produced great work, and met all the deadlines. He is the ideal web technology service provider and we continue to use his services whenever we can. I highly recommend Marc.';
testimonial_by[1]='Larry Gormley, VP and Co-founder';
testimonial_co[1]= 'Juxio, Inc.';

testimonial[2]='We are really happy to have found Curry Interactive. CI has been a tremendous resource to us throughout our start-up phase and continues to help us as we grow. Curry Interactive helped our team with our original product design and recently helped rebrand our company. I&rsquo;ve already recommended CI several times and will continue to do so in the future.';
testimonial_by[2]='Josh Walker, President and Founder';
testimonial_co[2]= 'CityVoter';

testimonial[3]='I had asked some colleagues if they knew someone who could help us translate print materials into an interactive format that would launch our client&rsquo;s new corporate image and new drug therapy. They recommended Marc. And after a successful launch and a dozen other projects he has helped us with—I would recommend Marc for any interactive project.';
testimonial_by[3]='Keith Finch, Vice President Creative Director';
testimonial_co[3]= 'Mc|K Healthcare';

testimonial[4]='Marc produced a great, attractive web site that served me well during the time I used it! During these challenging economic times, he offers a great value for his expert services.';
testimonial_by[4]='Joe Waters, Director, Cause and Event Marketing';
testimonial_co[4]= 'Boston Medical Center';

testimonial[5]='It was great working with Marc to create the Central Square Business Association web site – he listened carefully to what we wanted, patiently worked with us on design and organization of information, and has been very receptive to changes that we have needed since its launch.  I highly recommend Curry Interactive!';
testimonial_by[5]='Susan Fleischmann, Corresponding Secretary';
testimonial_co[5]= 'Central Square Business Association';

testimonial[6]='I first hired Marc for a not-for-profit organization I was assisting. Since then, I have worked with him on a variety of very complex and challenging assignments. Marc&rsquo;s true value is that he can totally immerse himself in your company&rsquo;s needs and still maintain an objective and helpfully critical eye to how to improve your online presence. In addition to all of this, he is a wonderful, easy-going person and great to be part of any marketing team.';
testimonial_by[6]='Mark Cestari, VP Marketing and Sales';
testimonial_co[6]= 'Charter Air Transport';

testimonial[7]='I&rsquo;ve collaborated with Marc on several projects and have always found him highly professional, knowledgeable, and results driven. What sets Marc apart is the skill and proficiency he brings to the table and the intuitive way he anticipates and delivers on client needs.';
testimonial_by[7]='William Hatcher, Account Director';
testimonial_co[7]= 'Mc|K Healthcare';

testimonial[8]='Marc was a pleasure to work with. It is rare to find an outside vendor with the ability to get inside the mind of the client as well as he does. We relied on him so heavily that he was considered an integral part of the team, and we never started a project without his input and advice. Marc also has the rare ability to creatively design within the parameters of an existing framework. He is not only a skilled graphic designer, but also understands code so effectively that he considers maintenance and growth even during initial conception and brainstorming. I truly hope I have the opportunity to work with Marc again in the future, and would highly recommend him to clients looking for an outstanding designer. ';
testimonial_by[8]='Priscilla Hofmann, Online Marketing Manager';
testimonial_co[8]= 'Explorica';

testimonial[9]='Marc is our resource for digital solutions. He interprets our concepts well, is always timely and a pleasure to work with. I highly recommend him, but make sure he has time for my work, too.';
testimonial_by[9]='Breda Kenyon, Chief Creative Officer';
testimonial_co[9]= 'Mc|K Healthcare';

testimonial[10]='Curry Interactive has provided Reflection Films with outstanding web design services. The highest compliment I can pay, perhaps, is to mention the numerous times that visitors have gone to the Reflection Films website and mentioned how much they like its design and ease-of-use. Every time we have gone to Marc – from the very beginning during conceptualization of the site through the several permutations that have taken place since - he has listened well to what we are striving to accomplish and responded with the solutions we have needed. He&rsquo;s a great resource and we recommend him all the time.';
testimonial_by[10]='Geoffrey Birmingham, Partner ';
testimonial_co[10]= 'Reflection Films';

testimonial[11]='Marc has been a long-term partner for Explorica, providing web maintenance, design, and creative consultation. He is unique in that he quickly understands and visualizes concepts and consistently executes them to the highest quality standard. His professionalism and straight-forward, personable approach makes him a pleasure to work with.';
testimonial_by[11]='Jessica K. Cartwright, Online Marketing Manager';
testimonial_co[11]= 'Explorica';

testimonial[12]='You know those people that you just love working with because you can always trust them to do a great job no matter what? Marc is one of those people. He is fast, efficient, smart and talented. He adds value, he adds ideas, and he&rsquo;ll just figure it out when needed. What&rsquo;s more, Marc has the patience of a saint when it comes to explaining the things us less tech-savvy people need to know. Marc can see both the big picture and the minute details, and I recommend him highly.';
testimonial_by[12]='Lisa Hickey, CEO';
testimonial_co[12]= 'Good Men Media';


