	var filterTimeout = "";
	var filterFlag = 0;
	//var filterTabTop = $("#filters_tab").css("top");
	var filterTabTop = "235px";
	var filterHeight = "400px";
	//var filterTabTop2 = (parseInt($("#filters_tab").css("top")) + 194) + "px" ;
	var filterTabTop2 = "634px";

	var slideshowStart = 1;
	var slideshowCurrent = 1;
	var slideshowEnd = 0;
	var slideshowInterval = "";
	var slideshowTimer = 15000;
	
	var firstFlag = 0;

	$(document).ready(function() {
	    //$("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_2.jpg)");

	    $("#gridHover").addClass("xlarge");

	    $("#projectDetail").fadeOut(0);

	    $("#projectClose").click(function() {

	        $("#projectDetail").fadeOut();
	    });


	    //initialize the filters
	    FilterListAllCallback.callback('init');

	    //$("#slideshow_left, #slideshow_right").hide();

	    //setTimeout ( "showDetail()", 1000 );

	    $("#filters_tab").click(function() {




	        //alert(filterFlag);


	        if (filterFlag == 0) {
	            filterFlag = 1;
	            expandFilters();
	        }
	        else {
	            resetFilter();
	        }
	    });

	    $("#filters_tab").hover(function() {
	        clearTimeout(filterTimeout);
	        if (filterFlag == 1) {

	        }
	        else {
	            //filterFlag = 1;	
	            //expandFilters();
	        }

	    }, function() {
	        //filterTimeout = setTimeout("resetFilter()", 1000);
	    });

	    $("#filters").hover(function() {
	        clearTimeout(filterTimeout);
	        if (filterFlag == 1) {

	            //alert(1);
	        }
	    }, function() {
	        contractFilters();
	        //alert(2);
	        //filterTimeout = setTimeout("resetFilter()", 1000);
	    });

	    $(".featured_index").click(function() {
	        var theID = $(this).attr("id").replace("featured_", "");
	        slideshowCurrent = theID;
	        clearInterval(slideshowInterval);


	        $(".featured_index").attr("src", "images/featured_off.png");

	        $("#featured_" + theID).attr("src", "images/featured_on.png");
	        //alert($("#featured_" + theID).attr("src"));
	        changeFeatured(theID);

	    });

	    //start slideshow timer
	    slideshowEnd = $(".featured_index").length;
	    slideshowInterval = setInterval("changeFeaturedAuto()", slideshowTimer);


	    //bindGrid();

	    //activeFilterCallbackComplete();

	    ///////////////////////////////////////////////////activeFilterCallback.callback("filter", "featured");



	    bindFilters();
	    bindActiveFilters();

	    if (getParameter2("pid") != '') {
	        displayWork();
	        activeFilterCallback.callback("resetfilters");
	        //var passid = ;

	        window.setTimeout("displayProject2('pid=' + getParameter2('pid'));", 3000);

	      


	    } else {
	        activeFilterCallback.callback("filter", "featured");
	    }




	    $('input.request').keydown(function(event) {
	        if (event.keyCode == 13) {
	            return false;
	        }
	    });

	});

//begin featured related js

function changeFeaturedAuto() {
	slideshowCurrent = slideshowCurrent+1;
	if(slideshowCurrent > slideshowEnd) {
		slideshowCurrent = slideshowStart;
	}
	
	
	changeFeatured(slideshowCurrent);
	
}


function changeFeatured(featuredID) {
	hidePages();
	hideProjectDetail(true);




	slideShowCallback.callback("featured",featuredID);
	CallbackHomeProject.callback("featured", featuredID);
	CallbackHomeCrumbs.callback(featuredID);
	completeSlideShowTransition();

}

var preLoad1 = 0;
var preLoad2 = 0;
var preLoad3 = 0;
var preLoad4 = 0;
var preLoad5 = 0;
var preLoad6 = 0;
var preLoad7 = 0;
var preLoad8 = 0;
var preLoad9 = 0;

function completeSlideShowTransition() {

    featuredID = slideshowCurrent;
    	$(".featured_index").attr("src","images/featured_off.png");
	$("#featured_" + slideshowCurrent).attr("src","images/featured_on.png");

    if(featuredID == 1) {
        $("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_1.jpg)");
        if (preLoad2 == 0) {
            $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_2.jpg");
            preLoad2 = 1;
        }
	}
	else if (featuredID == 2) {
	 $("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_2.jpg)");
	    if (preLoad3 == 0) {
	   
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_3.jpg");
	    preLoad3 = 1;
	    }
	}
	else if (featuredID == 3) {
	    if (preLoad4 == 0) {
	    $("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_3.jpg)");
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_4.jpg");
	    preLoad4 = 1;
	    }
	}
	else if (featuredID == 4) {
	$("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_4.jpg)");
	    if(preLoad5 == 0) {
	    
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_5.jpg");    
	    preLoad5 = 1;
	    }
	}
	else if (featuredID == 5) {
	$("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_5.jpg)");
	    if(preLoad6 == 0) {
	    
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_6.jpg");
	    preLoad6 = 1;
	    }
	}
	else if (featuredID == 6) {
	$("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_6.jpg)");
	    if(preLoad7 == 0) {
	    
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_7.jpg");    
	    preLoad7 = 1;
	    }
	}
	else if (featuredID == 7) {
	$("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_7.jpg)");
	    if(preLoad8 == 0) {
	    
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_8.jpg");
	    preLoad8 = 1;
	    }
	}
	else if (featuredID == 8) {
	    $("body").css("background-image", "url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_8.jpg)");
	    if(preLoad9 == 0) {
	    $.preloadImages("http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_9.jpg");
	    preLoad9 = 1;
	    }
	}
	else if (featuredID == 9) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_9.jpg)");
	}
	



}

//begin filter related js

function resetFilter() {
			filterFlag = 0;
		
			contractFilters();
			
			//initiate callback of keyword search here
			//alert('callingx1');
			activeFilterCallback.callback("filter","search_" + $("#filter_search").attr("value"));
			
	
};

function expandFilters() {
				$("#filters_tab,#filters").stop(true);
				$("#filters_tab").animate({
				top:filterTabTop2
				},500);
				$("#filters").animate({
				height:filterHeight
				},500);	
				
				$("#filter_button").attr("src",$("#filter_button").attr("src").replace("_off","_on"));
	
};
function contractFilters() {
			$("#filters_tab,#filters").stop(true);
			$("#filters_tab").animate({
			top:filterTabTop
			},500);
			$("#filters").animate({
			height:"1px"
			},500);	
			
			$("#filter_button").attr("src",$("#filter_button").attr("src").replace("_on","_off"));
			filterFlag = 0;
};


function bindFilters() {
    $(".super_filter_off,.filter_off,.filter_disabled,#filter_clear,#filter_go,#filter_search").unbind();
      $('input.search').unbind();
     $('input.search').keydown(function(event) {
            if (event.keyCode == 13) {
                resetFilter();
                return false;
            }
        });

    $(".filter_disabled").click(function() {
    //alert('calling2');
		activeFilterCallback.callback("filter","clear_filters_" + $(this).attr("id"));
		    
		    $(".filter_disabled").addClass("filter_off");
		    $(".filter_disabled").removeClass("filter_disabled");
		    
		    $(".filter_on").addClass("filter_off");
		    $(".filter_on").removeClass("filter_on");
		    
		    $(".super_filter_on").addClass("super_filter_off");
		    $(".super_filter_on").removeClass("super_filter_on");
		
		
            $(this).removeClass("filter_off");
			$(this).addClass("filter_on");
		
		});

		$(".super_filter_off").click(function() {
		//alert('calling3');
		activeFilterCallback.callback("filter",$(this).attr("id"));
		
		if($(this).hasClass("super_filter_on")) {
			$(this).removeClass("super_filter_on");
		}
		else {
			$(this).addClass("super_filter_on");	
		}
		
		});

		$(".filter_off").click(function() {
		//alert('calling4');
		activeFilterCallback.callback("filter",$(this).attr("id"));
		if($(this).hasClass("filter_on")) {
			$(this).removeClass("filter_on");
		}
		else {
			$(this).addClass("filter_on");	
		}
		
		});

		$(".super_filter_on").click(function() {
		//alert('calling5');
		activeFilterCallback.callback("filter",$(this).attr("id"));
		
		if($(this).hasClass("super_filter_on")) {
			$(this).removeClass("super_filter_on");
			$(this).addClass("super_filter_off");
		}
		else {
			$(this).addClass("super_filter_off");	
		}
		
		});

		$(".filter_on").click(function() {
		//alert('calling6');
		activeFilterCallback.callback("filter",$(this).attr("id"));
		if($(this).hasClass("filter_on")) {
			$(this).removeClass("filter_on");
			$(this).addClass("filter_off");	
		}
		else {
			$(this).addClass("filter_off");	
		}
		
		});

		$("#filter_clear").click(function() {
		//alert('calling7');
		activeFilterCallback.callback("filter","clear_filters_");
		$("#filter_search").attr("value","")
		});	
		
		$("#filter_go").click(function() {
		    resetFilter();
		
		});
		/*
		$("#filter_search").keyup(function() {
		    //activeFilterCallback.callback("filter","search_" + $("#filter_search").attr("value"));
		
		});
		*/		

};

function bindActiveFilters() {

    $(".filter_list").click(function() {
        if($(this).attr("id").indexOf("search_") >= 0) {
        
            $("#filter_search").attr("value","");    
        }
        activeFilterCallback.callback("filter",$(this).attr("id"));
    });

};

function activeFilterCallbackComplete() {
    if(firstFlag == 1) {
    $("#featured_index").css("visibility","hidden");
    }


    hideProjectDetail(true);//hide project page if open
    
    redrawJuicyMenu();

    bindActiveFilters();


    FilterListAllCallback.callback();
    
   // featuredCallback.callback();
   // juicyCallback.callback();
   // industryCallback.callback();
   // deliverableCallback.callback();
   // processCallback.callback();
    GridCallback.callback("filter","");

};

function redrawJuicyMenu() {

    var theArray = $(".filter_list");
    
    $("#juicy_1").attr("src",$("#juicy_1").attr("src").replace("_on","_off"));
    $("#juicy_2").attr("src",$("#juicy_2").attr("src").replace("_on","_off"));
    $("#juicy_3").attr("src",$("#juicy_3").attr("src").replace("_on","_off"));
    $("#juicy_4").attr("src",$("#juicy_4").attr("src").replace("_on","_off"));
    $("#juicy_5").attr("src",$("#juicy_5").attr("src").replace("_on","_off"));
    $("#juicy_6").attr("src",$("#juicy_6").attr("src").replace("_on","_off"));
    $("#juicy_7").attr("src",$("#juicy_7").attr("src").replace("_on","_off"));
    $("#juicy_8").attr("src",$("#juicy_8").attr("src").replace("_on","_off"));
    $("#juicy_9").attr("src",$("#juicy_9").attr("src").replace("_on","_off"));
    
    for(x = 0;x < theArray.length; x++) {
    
       if(theArray[x].id.indexOf("juicy") >= 0) {
       
                if(theArray[x].id.indexOf("820117") >= 0) {
		           $("#juicy_1").attr("src",$("#juicy_1").attr("src").replace("_off","_on"));
	            }
	            else if (theArray[x].id.indexOf("820073") >= 0) {
		           $("#juicy_2").attr("src",$("#juicy_2").attr("src").replace("_off","_on"));
	            }
	            else if (theArray[x].id.indexOf("820097") >= 0) {
		           $("#juicy_3").attr("src",$("#juicy_3").attr("src").replace("_off","_on"));
             
	            }
	            else if (theArray[x].id.indexOf("820060") >= 0) {
		           $("#juicy_4").attr("src",$("#juicy_4").attr("src").replace("_off","_on"));

	            }
	            else if (theArray[x].id.indexOf("820174") >= 0) {
		           $("#juicy_5").attr("src",$("#juicy_5").attr("src").replace("_off","_on"));

	            }
	            else if (theArray[x].id.indexOf("714936") >= 0) {
		            $("#juicy_6").attr("src",$("#juicy_6").attr("src").replace("_off","_on"));
	            }
	            else if (theArray[x].id.indexOf("820163") >= 0) {
		           $("#juicy_7").attr("src",$("#juicy_7").attr("src").replace("_off","_on"));
	            }
	            else if (theArray[x].id.indexOf("820203") >= 0) {
		           $("#juicy_8").attr("src",$("#juicy_8").attr("src").replace("_off","_on"));
	            }
	            else if (theArray[x].id.indexOf("820164") >= 0) {
		           $("#juicy_9").attr("src",$("#juicy_9").attr("src").replace("_off","_on"));
	             }
            
       
       }
       
    
    }

};




//end filter related js


/*begin grid js components*/

var currentJuicyTags = 0;

function changeJuicy(bgID) {
	$("#featured_index").css("visibility","hidden");
	clearInterval(slideshowInterval);
	
	hidePages();
	hideProjectDetail(true);
	
	var theJuicyTag = "";
	var theJuicyTagID = "";
	
	/***hard code of juicy ids and strings here**/
	 if(bgID == 1) {
		theJuicyTag = "Building Analysis";
		theJuicyTagID = "820117";
	}
	else if (bgID == 2) {
		theJuicyTag = "Real Estate Marketing";
		theJuicyTagID = "820073";
	}
	else if (bgID == 3) {
		theJuicyTag = "Fundraising Video";
		theJuicyTagID = "820097";
 
	}
	else if (bgID == 4) {
		theJuicyTag = "Interactive Presentations";
		theJuicyTagID = "820060";

	}
	else if (bgID == 5) {
		theJuicyTag = "Website Design";
		theJuicyTagID = "820174";

	}
	else if (bgID == 6) {
		theJuicyTag = "Architectural Visualization";
		theJuicyTagID = "714936";
	}
	else if (bgID == 7) {
		theJuicyTag = "Digital Asset Management";
		theJuicyTagID = "820163";

	}
	else if (bgID == 8) {
		theJuicyTag = "Touchscreen Kiosk";
		theJuicyTagID = "820203";

	}
	else if (bgID == 9) {
		theJuicyTag = "Graphic Design";
		theJuicyTagID = "820164";

	}
	
	/***end hard code**/
	//alert('calling9');
	activeFilterCallback.callback("juicy",theJuicyTagID,theJuicyTag);
	
	//GridCallback.callback("juicy",theJuicyTagID); deprecated
	
	slideShowCallback.callback("juicy",theJuicyTag); //UDF Item ID is hard coded
		//$("#slideshow_left").html('<span class="juicy_title">Building Analysis</span><br /><span class="juicy_desc">We are story tellers, artists and technologists - blending images, motion and sound. Our in-house team of animators, visual effects artists and video editors bring every detail of your vision to "virtual" life.</span>');
		//$("#slideshow_right").html('<img class="juicy_image" src="images/search_placeholder.jpg" alt="" />');	
	
	currentJuicyTags = bgID;
	//setTimeout("bindGrid()",200);
	completejuicyTagsChange();
};


function completejuicyTagsChange() {

bgID = currentJuicyTags;
    return false;
    if(bgID == 1) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_1.jpg)");
	}
	else if (bgID == 2) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_2.jpg)");
	}
	else if (bgID == 3) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_3.jpg)");
 
	}
	else if (bgID == 4) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_4.jpg)");

	}
	else if (bgID == 5) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_5.jpg)");

	}
	else if (bgID == 6) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_6.jpg)");
	}
	else if (bgID == 7) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_7.jpg)");

	}
	else if (bgID == 8) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_8.jpg)");

	}
	else if (bgID == 9) {
		$("body").css("background-image","url(http://hwcdn.net/e7i9s6j8/cds/ifmm_site/bg_9.jpg)");

	}

}

	var gridHoverTop = "";
	var gridHoverLeft = "";
	var hoverTimeout = "";
	var borderTimeout = "";
	var $border;
	var $hover;
	var thumbID = 0;
	var hoverFlag = -1;

function gridPage(pageNumber) {

    GridCallback.callback("paging",pageNumber);

}


function prebindGrid(sender, eventArgs) {
    if (eventArgs.get_parameter() != 'paging') {
        $("#grid").fadeTo(800, 0.4); // fade out
    }
      
}

function displayProject(theID) {
hidePages();
projectCallback.callback(theID);

$("#currentProjectIndex").html(theID + 1);

};

function displayProject2(theID) {
    hidePages();
    projectCallback.callback(theID);
    $("#currentProjectIndex").html(1);
};


function bindGrid() {
    if(firstFlag == 0) {
        changeFeatured(1);
        firstFlag = 1;
    }
	
	projectIndexCallback.callback();
	gridPagingCallback.callback();
	
	gridHoverTop = "";
	gridHoverLeft = "";
	clearTimeout(hoverTimeout);
	clearTimeout(borderTimeout);
	thumbID = 0;
	hoverFlag = -1;
	
	
	$("#grid div.xlarge img,#grid div.large img,#grid div.medium img,#grid div.small img,#grid div.xsmall img").unbind();
	$("#grid div div.hover").unbind();

	$("#grid div.xlarge img,#grid div.large img,#grid div.medium img,#grid div.small img,#grid div.xsmall img").click(function() {

	    //showProjectDetail();

	    theID = parseInt($(this).parent().attr("id"));

	    projectCallback.callback(theID);

	    //set the index
	    //$(".project_index").attr("src", "images/index_off.jpg");
	    //$("#project_" + (theID)).attr("src","images/index_on.jpg");

	    $("#currentProjectIndex").html(theID + 1);

	});
	
	$("#grid div.xlarge img,#grid div.large img,#grid div.medium img,#grid div.small img,#grid div.xsmall img").hover(function() {
		
		if(hoverFlag == 1) {
			if($(this).parent().attr("id") != thumbID) {
				clearTimeout(borderTimeout);
				clearTimeout(hoverTimeout);
				resetBorder();
				hideHover();
			}
			else {
				clearTimeout(borderTimeout);
				clearTimeout(hoverTimeout);
			}
			
			hoverFlag = 0;
		}
		else if(hoverFlag == 0)
		{		
				clearTimeout(borderTimeout);
				clearTimeout(hoverTimeout);
				resetBorder();
				hideHover();
		}
			
		if($(this).parent().hasClass("xlarge") || $(this).parent().hasClass("large") || $(this).parent().hasClass("medium")) {
		$hover = $(this).parent().find("div.hover");
		$hover.fadeIn(500);
		}
		
		$border = $(this).parent().find("img");
		thumbID = $(this).parent().attr("id");
		
		//$border.css("border-color","#ea8f00");

		$border.animate({
		borderTopColor:"#ea8f00",
		borderBottomColor:"#ea8f00",
		borderLeftColor:"#ea8f00",
		borderRightColor:"#ea8f00"
		},500);
			
	}, function() {
		if($(this).parent().hasClass("xlarge") || $(this).parent().hasClass("large") || $(this).parent().hasClass("medium")) {
		hoverTimeout = setTimeout("hideHover()",50);
		}
		borderTimeout = setTimeout("resetBorder()",50);
		hoverFlag = 0;
	});
	
	$("#grid div div.hover").hover(function() {
		if(hoverFlag != 1) {
		clearTimeout(hoverTimeout);
		clearTimeout(borderTimeout);
		}
			
	}, function() {
		borderTimeout = setTimeout("resetBorder()",50);
		if($hover.parent().attr("class") == "large" || $hover.parent().attr("class") == "medium") {
		hoverTimeout = setTimeout("hideHover()",50);
		}
		hoverFlag = 1;
	});

	    $("#grid").fadeTo(300, 1); // fade in

};

function bindGridPaging() {
$(".paging_off").unbind();
$(".paging_off").click(function() {
    gridPage($(this).attr("id").replace("paging_",""));

});


if($("#GridCallback img").length == 1) {
    //pop up project page automatically if result = 1, pick the first of the list
    
   // projectCallback.callback($("#GridCallback div:first").attr("id"));
   //   $(".project_index").attr("src", "images/index_off.jpg");
	//    $("#project_" + ($("#GridCallback div:first").attr("id"))).attr("src","images/index_on.jpg");
}


};

function hideHover() {
	$hover.fadeOut(500);
	
};

function resetBorder() {
	//$border.css("border-color","#ffffff");
	$border.animate({
		borderTopColor:"#ffffff",
		borderBottomColor:"#ffffff",
		borderLeftColor:"#ffffff",
		borderRightColor:"#ffffff"
	},500);
};

function showDetail() {

	$("#slideshow_left, #slideshow_right").show(500);	
	
};

var theCarousel;

function mycarousel_initCallback(carousel) {
theCarousel = carousel;
};

function showProjectDetail() {
    //$('body').scrollTo(200,{duration:333});
    clearInterval(slideshowInterval);
    activeImage = 1;
    $(".image2").fadeOut(0);
	$("#projectDetail").fadeIn();
	$(".projectLightsOff").fadeIn();
	pageTracker._trackPageview("/ProjectDetail");
	var strProjectName = $("#project_summary").html();
	strProjectName = strProjectName.replace(/&(lt|gt);/g, function (strMatch, p1){
	 	return (p1 == "lt")? "<" : ">";
	});
	var strProjectName = strProjectName.replace(/<\/?[^>]+(>|$)/g, "");
    pageTracker._trackPageview("/ProjectDetail?dt="+strProjectName);
	pageTracker._trackEvent('ProjectDetailView', 'Popup', 'New');
	pageTracker._trackEvent('ProjectDetailView', 'PopupDetail', strProjectName);

	
	if($('#project_thumbnails .thumb').length == 0) {
	    toggleDetails();
	}
	if($('.videoHover').length > 0) {
		switchVideo($('.videoHover:first').attr("id"));
	}
	$("#page_body").animate({
			height:"835px"
	},500);	
	if($('#project_thumbnails .thumb').length > 0) { //if 0, then no carousel to initialize
	
	$("div.scrollable").scrollable(); 
	
	
    
	}	
    };

function hideProjectDetail(scrollUp) {
	$("#projectDetail").fadeOut();
	$(".projectLightsOff").fadeOut();
	if(scrollUp) {
	$("#page_body").animate({
			height:"585px"
	},500);	
	}
	
	destroyFlash();
	//try to unbind carousel
	if($('#project_thumbnails .thumb').length > 0) {
	//theCarousel.reset();
	$("div.scrollable").unbind();
	$("div.scrollable").html("");
	}
};

function toggleDetails() {
	if($("#project_details").css("display") == "none") {
		$("#project_details").show(500);
		$("#project_summary .project_more a").text("LESS INFORMATION");
	}
	else {
		$("#project_summary .project_more a").text("MORE INFORMATION");
		$("#project_details").hide(500);	
	}
	
};
var activeImage = 0;
function switchImage(theURL) {

	if(activeImage == 1) {
	    activeImage = 2;
		$(".image2 img").attr("src",theURL);
		//$(".image2").fadeIn();

		$(".image2 img").unbind();
		$(".image2 img").load(function() {
		    destroyFlash();
		    $(".image1, .image3").fadeOut(function() {
		        $(".image3").html("");
		    });
		    //alert($(".image2 img").attr("src"));
		    $(".image2").fadeIn();
		});
		
		
	}
	else {
	    activeImage = 1;
	    
		$(".image1 img").attr("src",theURL);
		// $(".image1").fadeIn();
		
		$(".image1 img").unbind();
		$(".image1 img").load(function() {
		    destroyFlash();
		    $(".image2, .image3").fadeOut(function() {
			    $(".image3").html("");	
		    });
		
		    $(".image1").fadeIn();
		});
		
	}
	
	/*
	else if(imageNumber == 3) {
		
	}
	*/
};
function switchVideo(theID)  {
        renderFlash(theID);
         $(".image1, .image2").fadeOut();
		$("#image3").fadeIn();
		

};

function renderFlash(theID) {
    //alert(theID);
     var so = new SWFObject("video.swf?video=" + theID, "sotester", "864", "486", "9", "#000000");
     so.useExpressInstall('expressinstall.swf');
     so.addParam("wmode", "transparent");
     so.addParam("allowscriptaccess","always");
     so.write("image3");
	
	
};

/*project index code*/



function bindProjectIndex() {



//$(".project_index").unbind();
$(".project_left").unbind();
$(".project_right").unbind();

/*
$(".project_index").click(function() {
    theID = $(this).attr("id").replace("project_","");
	projectCallback.callback(theID);	
	
	$(".project_index").attr("src", $(this).attr("src").replace("_on","_off"));
	
		
	activeSrc = $(this).attr("src");
	activeSrc = activeSrc.replace("_off","_on");
	$(this).attr("src",activeSrc);
});
*/

$(".project_left").click(function() {
    //var theID = $(".project_index[src='images/index_on.jpg']").attr("id").replace("project_","");
    var theID = $("#currentProjectIndex").html();

    if (theID == '') {
        theID = 1;
        $("#totalProjectIndex").html(1);
    }
    totalProject = parseInt($("#totalProjectIndex").html());

    theID = parseInt(theID) - 1;
    if (theID < 1) {
        theID = totalProject;
    }
    $("#currentProjectIndex").html(theID);
    projectCallback.callback(theID - 1);

});

$(".project_right").click(function() {

var theID = $("#currentProjectIndex").html();

if (theID == '') {
    theID = 1;
    $("#totalProjectIndex").html(1);
}
	totalProject = parseInt($("#totalProjectIndex").html());
	theID = parseInt(theID) + 1;

	if(theID > totalProject) {
		theID = 1;	
	}
	$("#currentProjectIndex").html(theID);
	projectCallback.callback(theID - 1);	
});

}


/*end project index code*/

function destroyFlash() {
	$("#image3").html("");	
}

var aboutCarousel = 0;

function displayPage(pageNumber) {
    hideProjectDetail(false);
    if (displayWorkFlag == 0) {
        displayWork();
    }
    $("#body_container").css("background","url(images/page_bg.png)");
	$("#grid,#filter_list,#filters_tab,#grid_paging").fadeOut();
	
	$("#juicy_1").attr("src",$("#juicy_1").attr("src").replace("_on","_off"));
    $("#juicy_2").attr("src",$("#juicy_2").attr("src").replace("_on","_off"));
    $("#juicy_3").attr("src",$("#juicy_3").attr("src").replace("_on","_off"));
    $("#juicy_4").attr("src",$("#juicy_4").attr("src").replace("_on","_off"));
    $("#juicy_5").attr("src",$("#juicy_5").attr("src").replace("_on","_off"));
    $("#juicy_6").attr("src",$("#juicy_6").attr("src").replace("_on","_off"));
    $("#juicy_7").attr("src",$("#juicy_7").attr("src").replace("_on","_off"));
    $("#juicy_8").attr("src",$("#juicy_8").attr("src").replace("_on","_off"));
    $("#juicy_9").attr("src",$("#juicy_9").attr("src").replace("_on","_off"));
	
	
	if(pageNumber == 1) {
	
	    if(aboutCarousel == 0) {
	        $("div.scrollable_about").scrollable({size:1}); 
	        aboutCarousel = 1;
	    }
	    $("#page_body").animate({
			height:"1375px"
	    },500);
	
		$("#about_page").fadeIn();
		$("#news_page").fadeOut();
		$("#contact_page").fadeOut();
		pageTracker._trackPageview("/AboutUs");
	}
	else if(pageNumber == 2) {
	    $("#page_body").animate({
			    height:"835px"
	    },500);
		$("#about_page").fadeOut();
		$("#news_page").fadeIn();
		$("#contact_page").fadeOut();
		toggleNewsScroll();
		pageTracker._trackPageview("/News");
	}
	else if(pageNumber == 3) {
	    $("#page_body").animate({
			    height:"835px"
	    },500);
		$("#about_page").fadeOut();
		$("#news_page").fadeOut();
		$("#contact_page").fadeIn();
		pageTracker._trackPageview("/ContactUs");
	}
	
	
	
};

function projectTag(theTag) {
    //alert('calling11');
activeFilterCallback.callback('filter',theTag);
};

function hidePages() {
    $("#body_container").css("background","url(images/body_bg.png)");
	$("#page_body").animate({
			height:"585px"
	},500);	
	$("#grid,#filter_list,#filters_tab,#grid_paging").fadeIn();
	$("#about_page,#news_page,#contact_page").fadeOut();
	
	$("#menu_about").attr("src",$("#menu_about").attr("src").replace("_on","_off"));
	$("#menu_news").attr("src",$("#menu_news").attr("src").replace("_on","_off"));
	$("#menu_contact").attr("src",$("#menu_contact").attr("src").replace("_on","_off"));
	$("#menu_login").attr("src",$("#menu_login").attr("src").replace("_on","_off"));
	
	
};

function switchNews(index) {

newsContentCallback.callback(index);

};

function scrollNewsUp() {

$(".news_article_content").scrollTo("-=300px",{duration:333});

};

function scrollNewsDown() {
$(".news_article_content").scrollTo("+=300px",{duration:333});

};

function scrollAboutUp() {

$(".services_container").scrollTo("-=300px",{duration:333});

};

function scrollAboutDown() {
$(".services_container").scrollTo("+=300px",{duration:333});

};

function toggleNewsScroll() {
var theInnerHeight = parseInt($(".news_article_content_inner").height());
var theOuterHeight = parseInt($(".news_article_content").height());

if(theInnerHeight > theOuterHeight) {
    $(".news_scroll").fadeIn(0);
}
else {
    $(".news_scroll").fadeOut(0);
}


};

function submitForm() {

    var firstName = $("#request_fname").attr("value");
    var lastName = $("#request_lname").attr("value");
    var email = $("#request_email").attr("value");
    var address = $("#request_address").attr("value");
    var city = $("#request_city").attr("value");
    var state = $("#request_state").attr("value");
    var zip = $("#request_zip").attr("value");
    var comment = $("#request_comment").attr("value");
    
    var theValidation = "";
    if(firstName == "" || firstName == "First Name*") {
        theValidation = theValidation + "Please input your first name.\n\n";
    
    }
      if(lastName == "" || lastName == "Last Name*") {
        theValidation = theValidation + "Please input your last name.\n\n";
    
    }
     if(email == "" || email == "E-mail Address*") {
        theValidation = theValidation + "Please input your e-mail address.\n\n";
    
    }
    if(theValidation == "") {
    contactFormCallback.callback(firstName,lastName,email,address,city,state,zip,comment);
    }
    else {
        alert(theValidation);
    }
    
    

};
/*end grid js components*/




/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Robert Nyman | http://robertnyman.com/ */
function removeHTMLTags(val){
 	if(document.getElementById && document.getElementById("input-code")){
 		var strInputCode = document.getElementById("input-code").innerHTML;
 		/* 
  			This line is optional, it replaces escaped brackets with real ones, 
  			i.e. < is replaced with < and > is replaced with >
 		*/	
 	 	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		});
 		var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
 		return strTagStrippedText;	
   // Use the alert below if you want to show the input and the output text
   //		alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
 	}	
};


var displayWorkFlag = 0;
function displayWork() {
   
        clearInterval(slideshowInterval);
        hidePages();
        $("#slideshow ,#navi,#filters,#filters_tab img,#body_container").css("visibility", "visible");
        $("#home_page").fadeOut();

        if (displayWorkFlag == 0) {
        displayWorkFlag = 1;
        }


};

function surpressCallbacksErrors() {
    return true;
}




function getParameter2 (  parameterName ) {
try
{
var queryString = window.location.href;
var parameterName = parameterName + "=";
if ( queryString.length > 0 ) {
begin = queryString.indexOf ( parameterName );
if ( begin != -1 ) {
begin += parameterName.length;
end = queryString.indexOf ( "&" , begin );
if ( end == -1 ) {
end = queryString.length
}
return unescape ( queryString.substring ( begin, end ) );
}
return "";
}
}
catch (err)
{
return "";
}
}







