//twitter feed function (http://tweet.seaofclouds.com/)
 jQuery(function($)
 {
        $("#feedit_tweet").tweet({
            
            avatar_size: 32,
            join_text: "",
            count: 4,
            query: "#feedit OR @collemcvoy OR @hunterweeks",
            loading_text: "loading tweets..."
            
        });
});


//functions for facebook share
	var storedUrl = "";
	
	function shareOnFacebook(url)
	{
		storedUrl = url;
		var success = window.open(url,'FacebookShare','toolbar=0,status=0,width=626,location=no,menubar=no,height=436');
		if (!success)
		{
			alert("Your browser does not allow pop-ups");
		}		
	}
	
	
	

var mobile = false;

if(isIphone == true){
	mobile = true;
}
if(isAndroidPhone == true){
	mobile = true;
}
if(isTierIphone == true){
	mobile = true;
}
if(isTierTablet == true){
	mobile = true;
}
if(isTierGenericMobile == true){
	mobile = true;
}

// get random number from 1 to N
function randomToN(maxVal,floatVal)
{
   var randVal = Math.random()*maxVal;
   return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

//function to generate suggessted search

function checkSearchMatches(field) 
{
	//alert(field.value);
	//alert("key up " + field.value);
	var searchString = '';
	var returned_match_sucess = '';
	
	$('#live_search').empty(); //clear out suggested search
		
		$.getJSON("wp-content/themes/colle_mcvoy/webservices/search_assist.php",
				{searchString:field.value},
				
				function(data)
				{
					
					var suggestedSearch = "";
					
					if(data.response.errorString != "no_matches")
					{
						document.getElementById('live_search').innerHTML = ""; //clear out live search
						
						$.each(data.response.matching_keywords, function(key, value) 
        				{
							suggestedSearch = suggestedSearch + '<div class="suggested_result"><a href="#"  onclick="populateSearch(\''+ value.keyword+ '\'); return false;">'+value.keyword+'</a></div>';
							
						});//end of each
						
						
						$('#live_search').append(suggestedSearch);
						//$('.suggested_result a').toTitleCase();
						
					} //end of if
					
				}	//end of data response function			
					
		)//end of getJSON
	
	
}//end of function

//function to populate the search and submit a search when a link is clicked
function populateSearch(newSearch) 
{
	//fill in search word
	$("input#search_term").val(newSearch);
	
	//trigger click on post
	$('#submit').trigger('click');
}

//function to submit the search when a link is clicked
function submitSearchForm()
{
	//trigger click on post
	$('#submit').trigger('click');
}

/*
 * jQuery Title Case Plugin
 *
 * Copyright (c) 2010 Sean Flanagan <sean@redflannelgroup.com>
 * Based on David Gouch's To Title Case Javascript <http://individed.com/code/to-title-case/>
 * Itself based on John Gruber's Title Case Perl Script <http://daringfireball.net/2008/05/title_case, http://daringfireball.net/2008/08/title_case_update>
 *
 * To use, add .toTitleCase() to a selector. 
 * e.g. $("h1").toTitleCase();
 */
(function($) {
$.fn.toTitleCase = function() {
	$(this).each(function(){
	var headline = $(this).text();
	$(this).text(headline.replace(/([\w&`'''"".@:\/\{\(\[<>_]+-? *)/g,function(match, pl, index, title){
		if (index > 0 && title.charAt(index - 2) !== ":" && match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1)
			return match.toLowerCase();
		if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1)
			return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
		if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 || title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
			return match;
		return match.charAt(0).toUpperCase() + match.substr(1);
	}));
	});
};
})(jQuery);



/* ######################################################

ABOVE THIS BREAK WAS common_julie.js

BELOW THIS BREAK WAS ORIGINAL common.js

#########################################################*/


var theWindow        = theWindow || $(window);
var siteUrl = "";
var theBg              = $("#bg");
var searchTerm = "";						
var bgOffset = "0px";
var aspectRatio = '';
var $scrollPos = 1;
var inTransition = false;
var inSearchBar = false; 
var suggested_is_highlighted = false;
var current_suggested_result= "";
var hideSearch = "";
var typeFocus = false;
var topArr = [];
var activeTile = "";
var scrollOffset = 0;
var animated = false;
//var theWindow = $(window);
var direction = "equal";
var scrollID = "";
var displacement = "";
var diff = "";
var scrollIndex = "";
var continueScrolling = false;
var scrollTimeout = "";
var scrollKill = false;
var leader = 0;
var gap = 1000;
var tempGap = 0;	
var initScroll = true; 
var urli = 0;
var global_el = '';
var searchText = '';
var headlock = true;
var scrolledlock = false;
var history_timer = '';
var easterEggHunt = "";
var browser = ""; // will be filled on load
var dsq = "";// Disqus script child element
var disqus_shortname = 'collemcvoyunofficial';//'collemcvoycom'; // required: replace example with your forum shortname
//var disqus_identifier = "temp";// fill with id on demand
//var disqus_url = "http://dev.collemcvoy.com/collemcvoy/cm_site_redesign_2011/josh_working/";
/*
var srcText = srcText || [];
srcText.push(new Array ("blurredfoot_blur_","Foot"));
srcText.push(new Array ("mtgdoor_","Meeting Door"));
srcText.push(new Array ("brickwall_","Brick Wall"));
srcText.push(new Array ("lobby_blurred_","Lobby"));
srcText.push(new Array ("pasteup_","Paste Up"));
srcText.push(new Array ("sixfloor_blurred_","Sixth Floor"));
srcText.push(new Array ("stairview_blur_","Stair View"));

var srcSize = new Array("2400","1900","1400");	
var bgSize = "1400";
*/	

var winWidth = theWindow.width();
	
	
	
			
function bgInit(){
	for ( var i = 0 ; i < srcSize.length ; i++){
		if( winWidth  < srcSize[i] ){
			bgSize = srcSize[i];
		}
	}
	var randText = randomToN( (srcText.length - 1),0);
	if(requestBG != ""){
		randText = parseInt(requestBG) -1;
	}
	//var randSize = randomToN( (srcSize.length - 1),0);
	currentBG = parseInt(randText) + 1;
	$("#foot_nav_current").text(currentBG);
	$("#foot_nav_total").text(srcText.length);
	$("#foot_nav_title").text(srcText[randText][1]);
	//alert(srcText[randText] + srcSize[randSize])
	
		//if(!mobile){
			$("#bg").attr("src",base_url+"/wp-content/themes/images/cmbackgrounds/"+srcText[randText][0]+bgSize+"px.jpg");
		//} else {
			//$("body").css("background-image",base_url+"/wp-content/themes/images/cmbackgrounds/"+srcText[randText][0]+bgSize+"px.jpg");
		//}
		$("#bg_view").attr("href",base_url+"/?q=background view&bg="+currentBG);
		//if(!mobile){
			$("#bg").show();
		//}
		if(mobile){
			//alert('hit');
		}
}



var sd = ""; // timout var for #head_slide hover off state
function setAR(){
	aspectRatio = $("#bg").width() / $("#bg").height();
}
function hideComments(el){
	//alert(el.text());
	//el.text("+show comments");
	el.removeClass("hide_comments");
	el.addClass("show_comments");
	//el.html("<a class=\"show_comments\" href=\"#\" onclick=\"showComments($(this).parent());return false;\"><strong>show comments</strong></a>");
	el.unbind('click').bind('click',function(){
		showComments(el);
	});
	$("#disqus_thread").slideUp();
	
	return false;		
}
function showComments(el){
		//alert(el.text());
		//el.text("-hide comments");
		el.removeClass("show_comments");
		el.addClass("hide_comments");
		//el.html("<a class=\"hide_comments\" href=\"#\" onclick=\"hideComments($(this)); return false;\"><strong>hide comments</strong></a>");
		el.unbind('click').bind('click',function(){
			hideComments(el);
		});
		$("#disqus_thread").slideDown();
		return false;	
}
function createDSQ(clicked){
		//clicked.attr("onclick","alert('hi');return false;");
		clicked.removeAttr('onclick');
		clicked.unbind('click').bind('click',function(){
			//alert('hi');
			var el = $(this);
			hideComments(el);
		});
		clicked.removeClass("show_comments");
		clicked.addClass("hide_comments");
		//clicked.text("-hide comments");
		if(dsq == ""){
			dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
		   	dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
		    //dsq.src = "wp-content/themes/assets/js/dsq_hijack.js";
			(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
		} else {
			
				
			//DISQUS.alerty({config:function(){ this.page.identifier = disqus_identifier; this.page.url = disqus_url; } });
			//alert(disqus_identifier + "\n\n" + disqus_url);
			var to = setTimeout(function(){
				//alert(disqus_identifier+"\n"+disqus_url);
				DISQUS.reset({ reload: true, config: function(){ 
					this.page.identifier = disqus_identifier; this.page.url = disqus_url; this.page.title = disqus_title; }
				});
			},250);
			//var karl = new DISQUS();
			//alert(karl);
			
			/*
			dsq.parentNode.removeChild(dsq);
			dsq = "";
			
			dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
		   	//dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
		    dsq.src = "wp-content/themes/assets/js/dsq_hijack.js";
			(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
			*/
		}
		//alert( disqus_identifier);
	}
	
function instantiateDisqus(el,id,url,title){
	//alert(title);
	var uncle = el.parent().siblings(".expanded_bg");
	//$("#disqus_thread").removeAttr("id");
	$("#disqus_thread").remove();
	uncle.find(".disqus").html("<div id='disqus_thread'></div>");
	
	//$(".disqus").attr("id","disqus_thread");
	disqus_identifier = "staging_test_"+id;// fill with id on demand
	//alert(disqus_identifier);
	//alert(url);
	disqus_url = "http://www.collemcvoy.com/?q="+id;//josh_working/test"//url;
	//disqus_url = "http://dev.collemcvoy.com/collemcvoy/cm_site_redesign_2011/josh_working/dq4.html";

	//alert(disqus_url);
	disqus_title = title;
	//alert(disqus_url);
	
	uncle.find(".disqus").prepend("<a class=\"show_comments\" href=\"#\" onclick=\"createDSQ($(this)); return false; \"><strong>show comments</strong></a>");
	

}
function fadeHistory(){
	$("#search_history_list").stop();
	$("#search_history_list").fadeOut(600);
}

function resizeBg() {
                           
	if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
    	$("#bg")
        .removeClass()
        .addClass('bgheight');
		
    } else {
    	$("#bg")
        .removeClass()
        .addClass('bgwidth')
		
		
    }
	if(mobile){
		$("#bg").removeClass();
		//window.onscroll = function() {
  			//document.getElementById('bg').style.top = (window.pageYOffset + window.innerHeight - 25) + 'px';
		//};
		//$("#bg").width(960);
		//alert(theWindow.height());
	}
	//alert('resize');
	//$("#report").html(aspectRatio +" vs "+theWindow.width() / theWindow.height());                                                    
}
                        
                $(function() { 
				
						var to = setTimeout('setAR()',300);
  
                			//to = setTimeout('alert($("#bg").height())',5);
                        
                        //if(mobile){
							//theWindow.resize(function() {
                              //  resizeBg();
								//alert('hitne');
                       		//}).trigger("resize");
						//}
						//var rsb = setTimeout('resizeBg()',400);
                		theWindow.bind('scroll',function(){
						if(mobile==false){
							$scrollPos = ( Math.round( 100 * ( theWindow.scrollTop() + 1 ) / ( theWindow.height() * 1 ) ) / 100 );
							$bgOffset = "-"+$scrollPos*40+"px";
							$("#report").html($scrollPos);
							$("#bg").css('top',$bgOffset);
							//var windowPosition = theWindow.scrollTop();
							if(theWindow.scrollTop() < 90 && headlock == false && scrollIndex > 1 && $("#head_slider").hasClass('open') != true){
								headlock = true;
								scrolledlock = true;
								typeFocus = false;
								if(sd != ""){
									clearTimeout(sd);
									sd = "";
								}
								var headerHeight = 121;
								if(mobile==true){
									headerHeight = 121;
								}
									$("#head_slider").stop().animate({height:headerHeight},150,function(){
										
								if(browser == 'Explorer'){
									$("#head_slider").children().not("#search_history_list").show();
								}
							}).addClass("open");
								//$("#head_slider").stop(true,false).slideDown(300).addClass("open");
							}
							if(theWindow.scrollTop() > 90 && scrollIndex > 1 && headlock == false){
								//alert(scrollIndex);
								//headlock = false;
								typeFocus = true;
								if(browser == 'Explorer'){
									$("#head_slider").children().hide();
								}
								var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
								$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
								//$("#head_slider").stop(true,false).slideUp(300).removeClass("open");
							}
							if(theWindow.scrollTop() > 90 && scrollIndex > 1 && scrolledlock == true){
								
								scrolledlock = false;
								headlock = false;
								typeFocus = true;
								if(browser == 'Explorer'){
									$("#head_slider").children().hide();
								}
								var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
								$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
								
							}
						} else {
							//theWindow.scroll = function() {
  								//$("#bg").css("bottom","0px");
								//var footTop = $('#footer').offset().top;//pageYOffset;
								//alert(footTop);
								//document.getElementById('bg').style.bottom = footTop+'px';// (/*window.pageYOffset /*+ window.innerHeight - 25 */ 0) + 'px';
								//alert('hi');
							//};
		
							//$("#bg").css("top",theWindow.scrollTop());
							//$("#bg").css("bottom",110);
							//$("#bg").css("border-bottom","10px solid red");
							//$("body").css("background-position","0px "+theWindow.scrollTop+"px");
							
						}
						});
						
                });
function slide_swap(el){
	//alert(el.html());
	var elementParent = el.parent();
	var totalSlides = $("li",el.parent().parent()).size();
	var slideNav = el.parent().parent().parent().siblings(".slide_nav");
	var slideNav_next = el.parent().parent().parent().siblings(".slide_nav").children("a").children(".next_link");
	var slideNav_prev = el.parent().parent().parent().siblings(".slide_nav").children("a").children(".prev_link");
	var currentIndex = $("li",el.parent().parent()).index(elementParent);
	var slideFeature = el.parent().parent().parent().siblings(".slide_holder");
	//var overNav = slideFeature.children(".slide_over_nav");
	//var overPrev = overNav.children(".slide_over_previous");
	//var overNext = overNav.children(".slide_over_next");
	var prevBtn = slideFeature.children(".slide_over_btn_previous");
	var nextBtn = slideFeature.children(".slide_over_btn_next");
	var prevHalf = slideFeature.children(".slide_over_half_previous");
	var nextHalf = slideFeature.children(".slide_over_half_next");
	var prevSlide = slideFeature.children(".the_slide");
	var currentSelected = slideFeature.attr("class");
	var currentString = "";
	var newSlideText = "";
	var newSlideContent = "";
	var newMobileContent = "";
	if(currentSelected.indexOf("current_")!= -1){
		currentString = (currentSelected.substring(currentSelected.indexOf("current_"), ( currentSelected.length) ) );
		//alert(currentIndex);
		
	}
	//alert("current_"+currentIndex+" is compared against: "+currentString);
	if("current_"+currentIndex != currentString){
		//prevBtn.hide();
		//nextBtn.hide();
		//overNav.hide();
		//overNav.html("");
		
		slideNav_prev.unwrap();
		var prevSlideLi = "";
		
		if( currentIndex > 0  ){
			prevSlideLi = $("li:eq("+ (currentIndex-1) +")",el.parent().parent());
		} else {
			prevSlideLi = $("li:eq("+(totalSlides-1)+")",el.parent().parent() ) ;
		}
		var prevSlideA = $("a",prevSlideLi);
		slideNav_prev = el.parent().parent().parent().siblings(".slide_nav").children(".prev_link");
		slideNav_prev.wrap("<a href='#' />");
			//alert('previous');
			//overNav.append("<a href='#' class='slide_over_previous' onclick='return false;'>&nbsp;</a>");
			//prevSlideLi.hide();
			//var prevSlideA = $("a",el.parent());
			//alert(currentIndex);
			//slideNav_prev.hide();
		prevHalf.unbind('click').bind('click',function(){
			slide_swap(prevSlideA);
			return false; });
		slideNav_prev.parent().unbind().bind('click',function(){
			slide_swap(prevSlideA);
			return false;
			});
		//}
		
		slideNav_next.unwrap();
		var nextSlideLi = "";
		if(currentIndex < (totalSlides-1) ){
			var nextSlideLi = $("li:eq("+ (currentIndex+1) +")",el.parent().parent());
		} else {
			var nextSlideLi = $("li:eq(0)",el.parent().parent());
		}
		slideNav_next = el.parent().parent().parent().siblings(".slide_nav").children(".next_link");
		slideNav_next.wrap("<a href='#' />");
			//alert('next');
			//overNav.append("<a href='#' class='slide_over_next' onclick='return false;'>&nbsp;</a>");
		var nextSlideA = $("a",nextSlideLi);
			//var nextSlideA = $("a",el.parent());
			
			
			
		nextHalf.unbind('click').bind('click',function(){
			slide_swap(nextSlideA);
			return false;
			});
		slideNav_next.parent().unbind().bind('click',function(){
			slide_swap(nextSlideA);
			return false;
			});
		//}
		
		
		
		
		el.parent().siblings().children('a').removeClass('selected');
		el.parent().siblings().children('a').children('.overlay').remove();
		if(mobile){
			el.removeClass("mobile_selected");
		}
		el.addClass('selected');
		el.prepend("<div class='overlay'>&nbsp;</div>");
		
		
		// ANALYTICS ADD FOR SLIDE SWITCHING
		var gaqSlug = el.parentsUntil(".result").find(".condensed").attr("url");
		var gaqIndex = "slide_"+(1 + parseInt(el.parent().parent().children().index(el.parent())));
		//$("#debugger").html("_gaq.push(['_trackEvent','slideshow','view','"+gaqSlug+"','"+gaqIndex+"'])");
		_gaq = _gaq || [];
		_gaq.push(['_trackEvent','slideshow','view',gaqSlug,gaqIndex]);
		
		
		newSlideTarget = el.siblings(".invisible");
		newSlideText = newSlideTarget.html();
		if ( newSlideTarget.hasClass("youtube") ) {
			newSlideContent ='<iframe width="910" height="512" src="http://www.youtube.com/embed/'+newSlideText+'?rel=0" hd = "1" frameborder="0" allowfullscreen></iframe>';
		} else if (newSlideTarget.hasClass("vimeo") ){
			//var to = setTimeout(function(){
			//if(mobile){
				//newSlideContent = '';
				//newMobileContent = '<iframe src="http://player.vimeo.com/video/'+newSlideText+'?title=0&amp;byline=0&amp;portrait=0" color="00abe9" width="910" height="512" frameborder="0"></iframe>';
			//} else {
				newSlideContent = '<iframe src="http://player.vimeo.com/video/'+newSlideText+'?title=0&amp;byline=0&amp;portrait=0&amp;color=00abe9" width="910" height="512" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
			//}
			
			//alert('pause');
			//},500);
		} else if (newSlideTarget.hasClass('image') ){
			newSlideContent = '<img src="'+newSlideText+'" />';
		} else {
			newSlideContent = newSlideText;
		}
		
		//slideFeature.prepend("<div class='the_slide'>"+newSlideContent+"</div>");
		slideFeature.children(".the_slide").before("<div class='the_slide' >"+newSlideContent+"</div>");
		var newSlide = slideFeature.children("div.the_slide:eq(0)");
		if(browser != "Explorer"){
			newSlide.css('opacity',0);
		}
		var newHeightDelay = setTimeout(function(){
			var newHeight = newSlide.contents().height();//contents().outerHeight());
		
			if(newHeight > 0){
				newSlide.css({top:Math.floor( ( 512 - newHeight ) * .5)+"px"});//var timer = setTimeout('alert("'+ parseInt( (512 - newHeight) / 2 ) +'")');
			}
		},100);
		if(browser != "Explorer"){
			newSlide.animate({opacity:1},300,function(){
				//newSlide.css("opacity","");
				if(newMobileContent!=""){
					//newSlide.html("<h1>mod</h1>");
					newSlide.html(newMobileContent);
					//newSlide.parent().css( { width:320, height:480 } );
				}
			});
			prevSlide.fadeOut(300,function(){
				($(this).remove());
			});
		} else {
			prevSlide.remove();
		}
		/*
		var ifTo = setTimeout(function(){
			//alert(newSlide.css("visibility"));
			el.parentsUntil(".result").find(".condensed").html(newSlideContent);
		},1500);
		*/
		slideFeature.removeClass(currentString);
		slideFeature.addClass("current_"+currentIndex);
		//overNav.show();
		//var tempHTML = newSlide.html();
		if(mobile){
			
		}
		return false;
	} else {
		return false;
		//alert('that is already active');
	}
}
function scroller(displacement,diff,scrollIndex,f){
	
	if(direction == "add"){
		if( diff >= 35){	
			//theWindow.scrollTop(theWindow.scrollTop() + 35);
			theWindow.scrollTop(theWindow.scrollTop() + (diff*.1));
		} else {
			theWindow.scrollTop(theWindow.scrollTop() + diff);
		}
		if(theWindow.scrollTop() < displacement){
			continueScrolling = true;
		} else {
			continueScrolling = false;
		}
	
	}
	if(direction == "subtract"){
		if( diff >= 35){	
			//theWindow.scrollTop(theWindow.scrollTop() - 35);
			theWindow.scrollTop(theWindow.scrollTop() - (diff*.1));
		} else {
			theWindow.scrollTop(theWindow.scrollTop() - diff);
		}
		if(theWindow.scrollTop() > displacement){
			continueScrolling = true;
		} else {
			continueScrolling = false;
		}
	
	}
	//alert('hi');
	//theWindow.scrollTop(el.offset().top + 10 - $("#header").outerHeight());//animate({scrollTop:500},1000,function(){			
	if( continueScrolling == true ){
		//el.offset().top){
		//alert('yo');
		
	} else {
		theWindow.scrollTop(displacement);// + 10);
		if(scrollIndex == 1){
			theWindow.scrollTop(0);
			if($("#head_slider").hasClass("open")){
			} else {
				headlock = true;
				typeFocus = false;
				if(sd != ""){
					clearTimeout(sd);
					sd = "";
				}
				var headerHeight = 121;
								if(mobile==true){
									headerHeight = 121;
								}				
				$("#head_slider").stop().animate({height:headerHeight},150,function(){
					if(browser == 'Explorer'){
						$("#head_slider").children().not("#search_history_list").show();
					}
				}).addClass("open");
								//$("#head_slider").stop(true,false).slideDown(300).addClass("open");
			}
				
		}
		$("#current_result").text(scrollIndex);	
		$("#back_to_top").unbind('click').bind('click',function(){
			//if(scrollIndex > 1){
				transitionLarger( $(".condensed" , $(".result:eq(0)" ) ) );
			//}
		});
		$("#up_btn").unbind('click').bind('click',function(){
			if(inTransition == true){
                    return false;
            } else if( scrollIndex >= 2 )
            {
				//alert(scrollIndex);
				clearInterval(scrollID);
				scrollKill = true; 
				inTransition = true;
                transitionLarger(  $(".condensed" , $(".result:eq("+ (scrollIndex-2) +")") ) );
			} else {
				clearInterval(scrollID);
				//scrollKill = true; 
		
				//alert('hie');
			}
			return false;
		});
		$("#down_btn").unbind('click').bind('click',function(){
			if(inTransition == true){
                return false;
                } else if(scrollIndex < $("#total_results").text()){
				headlock = false;
				typeFocus = true;
				if($("#head_slider").hasClass("open")){
					
					if(browser == 'Explorer'){
						$("#head_slider").children().hide();
					}
					var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
					$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
					//$("#head_slider").stop(true,false).slideUp(300).removeClass("open");
				}
				clearInterval(scrollID);
				scrollKill = true; 
				inTransition = true;
                transitionLarger(  $(".condensed" , $(".result:eq("+scrollIndex+")") ) );
				//alert(scrollIndex);//
				//$(".result:eq("+scrollIndex+")").hide();
			} else {
                clearInterval(scrollID);
            }
			return false;
		});
		clearInterval(scrollID);
		scrollKill = false;
		inTransition = true;
        if(typeof f == "function")f(); else var throwaway = ""; 
	}
	//$("#debugger").html("<p>current index is:"+scrollIndex+"&nbsp;&nbsp;&nbsp;diff:"+diff+"&nbsp;&nbsp;&nbsp; displacement:"+displacement+"&nbsp;&nbsp;&nbsp; window.scrollTop:"+theWindow.scrollTop()+"</p>");
}
				
function scrollToEl(el,f){
		scrollIndex = $(".result").index(el.parent())+1;
		//return false;
		//alert(el.attr('class'));
		var windowPos = theWindow.scrollTop();
		if(el.offset()){
			if(mobile==false){
				displacement = el.offset().top  - 48;//$("#header").outerHeight();
			} else { 
				displacement = el.offset().top;
			}
		}
		if(scrollIndex == 1){
			//alert('hdhdhdhd');
			displacement = 0;
		}
		direction = 'equal';
		if(windowPos < displacement){// el.offset().top){
			direction = "add";
		} else if(windowPos > displacement){//el.offset().top){
			direction = "subtract";
		}
		diff = Math.abs(windowPos - displacement);
		
		if(direction != "equal"){
			scrollID = setInterval("scroller(displacement,diff,scrollIndex,"+f+")",20);
		} else {
			$("#current_result").text(scrollIndex);	
			$("#back_to_top").unbind('click').bind('click',function(){
				//if(scrollIndex > 1){
					transitionLarger( $(".condensed" , $(".result:eq(0)" ) ) );
				//}
			});
			$("#up_btn").unbind('click').bind('click',function(){
				if(inTransition == true){
                    return false;
                } else if( scrollIndex >= 2 )
				{
					//alert(scrollIndex);
					clearInterval(scrollID);
					scrollKill = true; 
					inTransition = true;
                    transitionLarger(  $(".condensed" , $(".result:eq("+ (scrollIndex-2) +")") ) );
				} else {
					clearInterval(scrollID);
					//scrollKill = true; 
			
					//alert('hie');
				}
				return false;
			});
			$("#down_btn").unbind('click').bind('click',function(){
				if(inTransition == true){
                    return false;
                } else if(scrollIndex < $("#total_results").text()){
					headlock = false;
					typeFocus = true;
					if($("#head_slider").hasClass("open")){
						
						if(browser == 'Explorer'){
							$("#head_slider").children().hide();
						}
						var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
					$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
						//$("#head_slider").stop(true,false).slideUp(300).removeClass("open");
					}
					clearInterval(scrollID);
					scrollKill = true; 
					inTransition = true;
                    transitionLarger(  $(".condensed" , $(".result:eq("+scrollIndex+")") ) );
					//alert(scrollIndex);//
					//$(".result:eq("+scrollIndex+")").hide();
				}
				return false;
			});
			if(typeof f == "function")f(); else var throwaway = ""; 
		}
		//if (typeof f == "function") {
			//var cback = setTimeout(f,2000);
		//} else {
			//alert('meh');
		//}

}


function getClosestEl(pos){
	gap = 1000;
	tempGap = 0;
	var adjPos = pos;// - 130;
	//alert(pos);
	//var leader = "";
	for(var i=0;i<topArr.length;i++){
		var theDiff = adjPos - topArr[i][1];
		if(theDiff < 0){
			theDiff = 2 * Math.abs(theDiff);
		}
		//alert(topArr[i][1]);
		//alert(gap+" vs "+ theDiff);
		if( theDiff <= gap){
			gap = theDiff;
			tempGap = theDiff;
			templeader = topArr[i][0];
			
		}
		
	}
	//alert(tempGap);
	if(templeader!=leader){
		leader = templeader;
		//alert("new leader: "+leader);
		scrollKill = true;
		inTransition = true;
        transitionLarger(  $(".condensed" , $(".result:eq("+leader+")") ) );
	} else {
		return false;
	}
}

function getCurrentScrolled(){
	//alert('hine');
	
	clearTimeout(scrollTimeout);
	
	scrollOffset = parseInt($("#header").css('height'));
	
	var scrollPos = $(window).scrollTop();
	if(scrollKill != true && initScroll == false ){
		//alert('wtf');
		scrollTimeout = setTimeout("getClosestEl("+scrollPos+");",1000);
	} 		

	//var currentlyFeatured =  $("#feature_holder").attr('class');
	//currentlyFeatured = currentlyFeatured.split(/ /)[0].replace(/[^\d]/g, '');
	//$("#scrollTracker").html("current: "+scrollPos);
	
}

function assignTops(){
topArr.length = 0; // reset the array;
$(".result_full").each(function(){
					var myPos = $(this).position();
					var myTop = myPos.top;
					//var myLimit = myTop+$(this).outerHeight()-1;
					var myIndex = $(".result_full").index(this);
					$(this).attr("myTop",myTop);
					//$(this).attr("myLimit",myLimit);
					topArr.push([myIndex,myTop]);//,myLimit]);
					//alert(topArr[myIndex]);
					});
					
}

function transitionLarger(el){
	
	if(el.hasClass("in_progress")){
		//alert('in progress');
	} else {
		if(dsq!=""){
			//dsq.parentNode.removeChild(dsq);
			//dsq = "";
			//alert(disqus_identifier);
			disqus_identifier = "";
			
		}
		if(el.attr("id") != ""){
			instantiateDisqus(el,el.attr("id"),el.attr("url"),el.find("h1").text());
		}
	
		el.addClass("in_progress");
		animated = true;
		var subIndex = $(".condensed").index(el)
		if(subIndex > 0 && headlock == true){
			headlock = false;
			typeFocus = true;
			if($("#head_slider").hasClass("open")){
				if(browser == 'Explorer'){
					$("#head_slider").children().hide();
				}
				var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
				$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
				//$("#head_slider").stop(true,false).slideUp(300).removeClass("open");
			}
			
		}
		$(".currently_expanded").each(function(){
			// comment out conditional to close all tiles, leave conditional in to leave above tiles expanded
			// BUGGY WITHOUT CONDITIONAL FOR NOW
			
			
			//if( $(".expanded_bg").index($(this)) > $(".condensed").index(el) ){
				//alert(  $(".expanded_bg").index( $(this) )  );
					transitionSmaller($(this));
			//}
			
			
		});
		
		// swap/expand first, then scroll 
		/*
		$(".titleBox",el).css("max-width",$(".titleBox",el).css('width'));
		$(".titleBox",el).animate({width:0} , 300 , function(){
			//assignTops();
			//scrollToEl(el.parent().parent());
			el.parent().siblings(".expanded_bg").slideDown(300);
			el.fadeOut(300,function(){
				animated = false;
				el.removeClass("in_progress");
				el.parent().siblings(".expanded_bg").addClass("currently_expanded");
				assignTops();
				scrollToEl(el.parent().parent());
			});
		});
		*/
		
		// scroll first, then expand/swap
		//
		assignTops();
		global_el = el;
		//global_el.children().fadeOut(300,function(){
			scrollToEl(el.parent().parent(),function(){
				
				
				//alert(global_el.parent().siblings(".expanded_bg").size());
				
				global_el.children().fadeOut(300,function(){
				//global_el.parent().siblings(".expanded_bg").children().animate({opacity:0},0);
				if(global_el.parent().siblings(".expanded_bg").hasClass("currently_expanded")){
						animated = false;
						inTransition = false;
                        global_el.removeClass("in_progress");
						//global_el.parent().siblings(".expanded_bg").addClass("currently_expanded");
				
				} else {
					global_el.parent().siblings(".expanded_bg").animate({opacity:0},0);
					global_el.parent().siblings(".expanded_bg").each(function()
					{
						//var tempData = $(this).data("height"); 
						//alert(tempData);
					});
					//global_el.fadeOut(300);//,function(){
						
							if(mobile){
								
								global_el.parent().siblings(".expanded_bg").each(function(){
									var origHeight = ($(this).data("height"));
									$(this).animate( { height : origHeight } , 300,function(){
									//$(this).slideDown(300,function(){
										$(this).height("");
										$(this).find(".mobile_selected").each(function(){
											slide_swap($(this));
										});//.trigger('click');
										/*if($("li",$(this).parent().parent()).index($(this).parent()) == 0 ) {
											slide_swap($(this));
										}*/
										$(this).find(".column_left").show();
										
										$(this).css("height");
										var footTop = $(".tile_footer_wrapper:last").offset().top;
										var resultTop = $(".result:last").offset().top + 130;
										if(resultTop > footTop){
											footTop = resultTop;
										}
										document.getElementById('bg').style.top = (footTop /* - window.innerHeight */ ) + 'px';// (/*window.pageYOffset /*+ window.innerHeight - 25 */ 0) + 'px';
									});
								});
							} else {
								global_el.parent().siblings(".expanded_bg").slideDown(300,function(){
								
								});
							}
						var cat = global_el.attr("type");
						_gaq.push(['_trackPageview',"/"+cat+"/"+global_el.attr('url')]);
						//alert("/"+cat+"/"+global_el.attr('url'));
						//$(".titleBox",global_el).css("max-width",$(".titleBox",global_el).css('width'));
						//$(".titleBox",global_el).animate({width:0} , 300 );
						global_el.parent().siblings(".expanded_bg").animate({opacity:1},300,function(){
							
							//$(this).css("filter","none");
							//$(this).css("opacity","");
							//$(this).attr("style").replace(/filter[^;]+;?/, "");	
						})
						//global_el.parent().siblings(".expanded_bg").children().animate({opacity:1},500);
						animated = false;
						inTransition = false;
                        global_el.removeClass("in_progress");
						global_el.parent().siblings(".expanded_bg").addClass("currently_expanded");
						
						//alert($(".result","#wrapper").index( global_el.parent().parent().parent() ));
						//alert(scrollIndex);
						//assignTops();
					
					//});
				//});
				}
				});
			});
		//
	}
}

function transitionInit(el){
	if(el.hasClass("in_progress")){
		//alert('in progress');
	} else {
		if(dsq!=""){
			dsq.parentNode.removeChild(dsq);
			dsq = "";
			//alert(disqus_identifier);
			disqus_identifier = "";
			
		}
		if(el.attr("id") != ""){
			instantiateDisqus(el,el.attr("id"),el.attr("url"),el.find("h1").text());
		}
	
		el.addClass("in_progress");
		animated = true;
		
		$(".currently_expanded").each(function(){
			// comment out conditional to close all tiles, leave conditional in to leave above tiles expanded
			// BUGGY WITHOUT CONDITIONAL FOR NOW
			if( $(".expanded_bg").index($(this)) > $(".condensed").index(el) ){
				//alert(  $(".expanded_bg").index( $(this) )  );
				transitionSmaller($(this));
			}
		});
		
		// swap/expand first, then scroll 
		/*
		$(".titleBox",el).css("max-width",$(".titleBox",el).css('width'));
		$(".titleBox",el).animate({width:0} , 300 , function(){
			//assignTops();
			//scrollToEl(el.parent().parent());
			el.parent().siblings(".expanded_bg").slideDown(300);
			el.fadeOut(300,function(){
				animated = false;
				el.removeClass("in_progress");
				el.parent().siblings(".expanded_bg").addClass("currently_expanded");
				assignTops();
				scrollToEl(el.parent().parent());
			});
		});
		*/
		
		// scroll first, then expand/swap
		//
		
		assignTops();
		global_el = el;
		//global_el.children().fadeOut(300,function(){
			//alert('init');
			scrollToEl(el.parent().parent(),function(){
				//alert('scrolled');
				global_el.children().fadeOut(0,function(){
				//global_el.parent().siblings(".expanded_bg").children().animate({opacity:0},0);
				if(global_el.parent().siblings(".expanded_bg").hasClass("currently_expanded")){
						animated = false;
						inTransition = false;
                        global_el.removeClass("in_progress");
						//global_el.parent().siblings(".expanded_bg").addClass("currently_expanded");
				
				} else {
					global_el.parent().siblings(".expanded_bg").animate({opacity:0},0);
					
					//global_el.fadeOut(300);//,function(){
						if(mobile==true){
							
							//global_el.parent().siblings(".expanded_bg").show();//,function(){
						} else {
							global_el.parent().siblings(".expanded_bg").slideDown(300);//,function(){
						}
						//alert(url_search);
						var cat = global_el.attr("type");
						var resultDef = "true";
						if(global_el.attr('url') == 'no-results'){
							resultDef = 'no-result';
						}
						_gaq = _gaq || [];
						_gaq.push(["_trackPageview","/"+cat+"/"+global_el.attr('url')+"?q="+url_search+"&def="+resultDef]);
						//alert(_gaq[1]);
						//alert("/"+cat+"/"+global_el.attr('url')+"?q="+url_search+"&def="+resultDef);
						//$(".titleBox",global_el).css("max-width",$(".titleBox",global_el).css('width'));
						//$(".titleBox",global_el).animate({width:0} , 300 );
						global_el.parent().siblings(".expanded_bg").animate({opacity:1},300,function(){
							//$(this).css("filter","none");
							//$(this).css("opacity","");
							//$(this).attr("style").replace(/filter[^;]+;?/, "");
						});
						//global_el.parent().siblings(".expanded_bg").children().animate({opacity:1},500);
						animated = false;
						inTransition = false;
                        global_el.removeClass("in_progress");
						global_el.parent().siblings(".expanded_bg").addClass("currently_expanded");
						//alert($(".result","#wrapper").index( global_el.parent().parent().parent() ));
						//alert(scrollIndex);
						//assignTops();
					
					//});
				//});
				}
				});
			});
		//
	}
}
	
function transitionSmaller(el){
	var condensedBro = el.siblings(".condensed_wrapper").children(".condensed");
	
	if(condensedBro.hasClass("in_progress")){
	} else {
		animated = true;
		condensedBro.addClass("in_progress");
		if(mobile){
			//var tempHeight = el.data("height");
			el.animate( { height:0 } , 0 );
			el.find(".column_left").hide();
			el.find(".the_slide").html("");
			el.find(".slide_holder").removeClass().addClass("slide_holder");
			el.find(".selected").addClass("mobile_selected").removeClass("selected");
			el.find(".overlay").remove();
		} else {
			el.slideUp(0);//300);
		}
		condensedBro.children().fadeIn(300,function(){
		//condensedBro.fadeIn(300,function(){
			//alert("hit");
			//titleSlideIn($(".titleBox", condensedBro));//condensedBro.children(".titleBox"));//.animate( {width:960} , 300);// , function(){
			condensedBro.removeClass("in_progress");
			el.removeClass("currently_expanded");
			animated = false;
			//});
		});
	}
}

function titleSlideIn(el){
	//alert(el);
	var myWidth = el.css("max-width");
	//alert(myWidth);
	el.animate({width:myWidth},300,function(){
		$(this).parent().parent().removeClass("in_progress");
	});
}
function checkHighlight(){
	if(suggested_is_highlighted == true){
		//return false;
		//highlighResult('execute_currentt');
		//alert(searchText);
		return highlightResult("execute_current");
	}
}
function highlightResult(cmd) {
	//alert(cmd);
	//$("#search_term").blur();
	clearTimeout(hideSearch);
	searchText = "";
	if(cmd == 'escape'&& suggested_is_highlighted == true) {
		current_suggested_result = "";
		$("#live_search .suggested_result").removeClass("highlighted_suggestion");
		suggested_is_highlighted = false;
		clearSuggested();
		$("#search_term").focus();
	}
	if(cmd == 'execute_current' && suggested_is_highlighted == true ) {
		$("#search_term").blur();
		$("body").append('<div style="display:none"><form name="dummy_form"><input type="text" id="dummy_input" name="dummy_input" /></form></div>');
		$("#dummy_input").focus();
		searchText = current_suggested_result.text();
		populateSearch(searchText);
		// search function here
		//alert('should be list');
		return true;
		
	} else if ( cmd == 'execute_current' && suggested_is_highlighted == false ){
		//alert('should submit from input');
		return false;
		// nothing needed here?
		
	} else if ( cmd == 'next' ) {
		if(suggested_is_highlighted != true ) {
			if( $("#live_search div").size() > 0){
				current_suggested_result = $("#live_search .suggested_result:eq(0)");
				current_suggested_result.addClass('highlighted_suggestion');
				suggested_is_highlighted = true;
			} else { 
				return false;
			}
			
		} else {
			//alert(current_suggested_result.attr('class'));
			var CSI = ($("#live_search div").index(current_suggested_result)); // index of currently selected suggested result
			var TSR = ($("#live_search div").size());  // total suggested results
			if( parseInt(CSI + 1) < TSR){
				$("#live_search .suggested_result").removeClass("highlighted_suggestion");
				current_suggested_result = $("#live_search .suggested_result:eq("+parseInt(CSI+1)+")");
				current_suggested_result.addClass('highlighted_suggestion');
				//alert(current_suggested_result.text());
			} else {
				return false;
			}
		}
	} else if ( cmd == 'previous' ) {
		if(suggested_is_highlighted == true ) {
			var CSI = ($("#live_search div").index(current_suggested_result)); // index of currently selected suggested result
			var TSR = ($("#live_search div").size());  // total suggested results
			if( parseInt(CSI - 1) >= 0){
				$("#live_search .suggested_result").removeClass("highlighted_suggestion");
				current_suggested_result = $("#live_search .suggested_result:eq("+parseInt(CSI-1)+")");
				current_suggested_result.addClass('highlighted_suggestion');
				//alert(current_suggested_result.text());
			} else {
				highlightResult('escape');
			}
		} else {
			return false;
		}
	} else { 
		return false;
	}
	return false;
	
}

function scrollTight(el){
	
	var myOffset = el.offset();
	//alert(myOffset.top);
	//$.animate({ scrollTop : 20 },500,function(){
	
	//});//$("html").scrollTo(myOffset.left,myOffset.top,{duration:200});
}

function getScreen( url, size )
{
  if(url === null){ return ""; }

  size = (size === null) ? "big" : size;
  var vid;
  var results;

  results = url.match("[\\?&]v=([^&#]*)");

  vid = ( results === null ) ? url : results[1];

  if(size == "small"){
    return "http://img.youtube.com/vi/"+vid+"/2.jpg";
  }else {
    return "http://img.youtube.com/vi/"+vid+"/0.jpg";
  }
}
function clearSuggested(){
	if(searchTerm != "" && $("input#search_term").val() == "" ){
		$("input#search_term").val(searchTerm);
		searchTerm = ""; 
	}
	//alert('bapperdale');
	inSearchBar = false;
	suggested_is_highlighted = false;
	$("#live_search").html("");
	if(typeFocus == true){
		typeFocus = false;
					if(browser == 'Explorer'){
						$("#head_slider").children().hide();
					}
					var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
		$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
		//$("#head_slider").stop(true,false).slideUp(300).removeClass("open");
	}
}

var tempText = "";
function moveH1Container(){
	$(".result_full").each(function(){
		if( $(this).hasClass("has_hero") ){
			//$(this).addClass("modified_post");
			//$(".column_right", $(this)).hide();
			var h1ContainerHtml = "";//$(".h1_container",$(this)).html();
		// headeraddressed in templates	$(".h1_container",$(this)).remove();
			//$(".h1_container",$(this)).html("").css("display","none").hide();
			//$(".h1_container", $(this) ).append("<div class='column_right'>"+$(".column_right", $(this) ).html() +"</div>" );
			if(h1ContainerHtml != ""){
				$(".column_right", $(this) ).after("<div class='h1_container flex_width'>"+ h1ContainerHtml +"</div>" );
			} else {
				//alert('yo');
			}
			
			//var leftoverWidth = (885 - parseInt($(".column_right img",$(this)).attr('width')));
			
			
			//alert( leftoverWidth );
			//leftoverWidth = $(".column_right img",$(this));//.width();//css('width');
			//leftoverWidth = leftoverWidth.attr("width");//width();
			//alert(leftoverWidth);
			$(".flex_width", $(this)).css("width",405);//leftoverWidth);
			//$(".column_left", $(this) ).prepend("<div class='h1_container'>"+$(".h1_container", $(this) ).html() +"</div>" );
			if($(".copy_wrap",$(this)).html()!=null){
				/*$(".copy_wrap",$(this)).contents().each(function() {
  				  	if( this.nodeType == 3 ) {
    			    	var text = this.textContent? this.textContent: this.innerText;
    			    	text = $.trim( text );
    			    	if ( text.length ) {
							text.wrap("<div class='stormatron' />");
    			    	    alert ( text ) ;
        				}
    				}
				});*/
				
				$(".copy_wrap",$(this)).before($(".copy_wrap",$(this)).html());
				$(".copy_wrap",$(this)).remove();
			}
		}
	});
}
function modURL(){
	urli=urli+1;
	window.location.hash = urli;
	//window.history.pushState("", "", "adifferenturl"+urli+".html");
}

function jsReplace(strObj,regObj,replaceStr,dupString,matchString,dummy){
	//strObj.html(strObj.html().replace(regObj,replaceStr));
	return false;
						if(dupString!=""){
						//action
							//alert(matchString+" is contained in "+dupString);
							strObj.html(strObj.html().replace( regObj,replaceStr ));//,function(){
								//alert('ho');
							//});
							strObj.html(strObj.html().replace(dummy,dupString));
								
						} else {
							strObj.html(strObj.html().replace( regObj, replaceStr ));
						}
						//previouslyMatched.push(matchString);
}

var bgArr = [];
bgArr.push('fdsa');
bgArr.push('fas');
bgArr.push('aeve');
var currentBG = 1;

function setCurrent(ct){
	//alert('hit');
	currentBG = ct;
	//alert(mobile);
	//if(mobile==false){
		$("#bg").attr("src",base_url+"/wp-content/themes/images/cmbackgrounds/"+srcText[ct-1][0]+bgSize+"px.jpg");
	//} else {
		//$("body").css("background-image",base_url+"/wp-content/themes/images/cmbackgrounds/"+srcText[ct-1][0]+bgSize+"px.jpg");
	//}
	$("#foot_nav_current").text(ct);
	//$("#foot_nav_total").text(srcText.length);
	$("#foot_nav_title").text(srcText[ct-1][1]);
	$("#bg_view").attr("href",base_url+"/?q=background view&bg="+currentBG);
		// ANALYTICS ADD FOR SLIDE SWITCHING
		var gaqSlug = "footer";//el.parentsUntil(".result").find(".condensed").attr("url");
		var gaqIndex = "slide_"+ct;//(1 + parseInt(el.parent().parent().children().index(el.parent())));
		_gaq = _gaq || [];
		_gaq.push(['_trackEvent','backgrounds','view',gaqSlug,gaqIndex]);
		
	
	//alert(ct);
}

function changeBG(dir){
	var inc = 1;
	
	if(dir == 'prev'){
		inc = -1;
	}
	var bgnum = srcText.length;
	if(currentBG + inc < 1 ){
		setCurrent(bgnum);
	}
	else if(currentBG + inc > bgnum ){
		setCurrent(1);
	}
	else {
		setCurrent(currentBG + inc);
	}
	
	
}

function appKeydown(evt){	
	if($("#dsq-popup-message").size() > 0 ){
		//alert($("#dsq-popup-message").size());
	} else if(evt.target.className == "noKeyJack") {
		//alert(evt.target.className);
	} else {
		switch ( evt.keyIdentifier ) {
            case "Enter":  // Space bar
                if(inSearchBar == true){
					highlightResult('execute_current');
				}
                break;
            case "Up": // Up
				if(inSearchBar == true){
					highlightResult('previous');
				} else {
					$("#up_btn").trigger('click');
				}
                break;
			case "Down": // Down
				if(inSearchBar == true){
					highlightResult('next');
				} else {
					$("#down_btn").trigger('click');
				}
                break;
			case "Left":    // Left arrow
                if(inSearchBar == true){
					
				} else {
					$(".expanded_bg:eq("+parseInt(scrollIndex-1)+") .prev_link").parent().trigger("click");
				}
                break;
            case "Right":   // Right arrow
                if(inSearchBar == true){
					
				} else {
					$(".expanded_bg:eq("+parseInt(scrollIndex-1)+") .next_link").parent().trigger("click");
				}
                break;
            case "U+001B":  // Escape key
				if(inSearchBar == true){
					highlightResult('escape');
				}
				if(typeFocus == true){
					$("#search_term").val("");
					highlightResult('escape');
					$("#search_term").blur();
					//clearSuggested();
				}
                break;
			case "U+0009":  // Tab key
				
                break;
			default :
			
				var tempLetter = parseInt(evt.keyIdentifier.substr(2,4),16);
					if( (tempLetter >= 65 && tempLetter <= 90) || ( tempLetter >= 48 && tempLetter <= 57 ) ){
							
						var theTempLetter = String.fromCharCode(tempLetter);//eval("\\u"+codeVal1);
						easterEggHunt = easterEggHunt+theTempLetter;
						if(easterEggHunt.indexOf('EASTER',0) > -1 ){
							$(".autotag").addClass("easterEgg");
						}
						if(easterEggHunt.indexOf('POOP',0) > -1){
						//	alert("Colle+McVoy doesn't do that kind of work.  You'll find that up next.");
						}
					}
							
				//if(inSearchBar == true){
					//alert('default');
					
					if(scrollIndex > 1){
						if($("#head_slider").hasClass("open")){
							//typeFocus = false;
					
						} else {
							if(sd != ""){
								clearTimeout(sd);
								sd = "";
							}
							if(browser == 'Firefox'){
							$("#head_slider").stop().animate({height:121},0).addClass("open");
							} else {
								var headerHeight = 121;
								if(mobile==true){
									headerHeight = 121;
								}
								$("#head_slider").stop().animate({height:headerHeight},150,function(){
								if(browser == 'Explorer'){
									$("#head_slider").children().not("#search_history_list").show();
								}
							}).addClass("open");
							}
							//$("#head_slider").stop(true,false).slideDown(100).addClass("open");
							headlock = true;
							typeFocus = true;
						
						}
					}
					
					$("#search_term").focus();
					//var delay = setTimeout( function(){
						if($("#search_term").val() == ""){
							//var num = myform.num.value.toUpperCase();
							//var uni = '"\\u' + num+'"';
							
							//if (/^[A-F\d]{4}$/.test(num)) document.getElementById('val').firstChild.data = eval(uni);
							
							var codeVal1 = parseInt(evt.keyIdentifier.substr(2,4),16);
							if( (codeVal1 >= 65 && codeVal1 <= 90) || ( codeVal1 >= 48 && codeVal1 <= 57 ) ){
							
								//var codeVal2 = evt.keyIdentifier.substr(5,1);
								//alert(String.fromCharCode(codeVal));
								//alert(codeVal);
								var theLetter = String.fromCharCode(codeVal1);//eval("\\u"+codeVal1);
								$("#search_term").val(theLetter.toLowerCase());
								$("#search_term").val($("#search_term").val());
								
							}
						}
					
						var searchInput = document.search_form.search_term;
						checkSearchMatches(searchInput);
					//} , 450 );
				//}
				break;
        }
	}
}

$(function(){
	var _gaq = _gaq || [];
	_gaq.push(['_trackPageLoadTime']);
	browser = BrowserDetect.browser;
	var browser_version = BrowserDetect.version;
	if(browser == "Explorer" && browser_version == "6"){
		alert("Your browser is out of date and will not properly display this site.");
		//alert("This site is far too pretty to be destroyed by Internet Explorer 6.  \n\nYou are being redirected in order for you to update to the newest version of Internet Explorer.");
		//window.location = "http://microsoft.com/IE9";
	}
	var bgTo = setTimeout(function(){
	bgInit();
	//alert('done');
	},500);
	
	//$(".column_right img").attr("width","700");
	var delayInitScroll = setTimeout("initScroll = false;",1000);
	var juggleH1Container = setTimeout('moveH1Container()',400);
	
	//$(".condensed:eq(0) .titleBox").css("max-width",$(".condensed:eq(0) .titleBox").css("width")).animate({width:0},0)
	//$(".condensed:eq(0)").hide();
	//$(".condensed:last").show();
	if(mobile==true){
		//var teh = setTimeout(function(){
			$(".expanded_bg").each(function(){
				var currentEx = $(this);
				var myHeight = (currentEx.height() >= 470) ? currentEx.height() : 470;
				//alert(myHeight);
				currentEx.data( "height" , myHeight ); //content().outerHeight() );
				
			});
			$(".expanded_bg").not(":eq(0)").each(function(){
				var currentEx = $(this);
				currentEx.animate({ height:0} ,0);
				$(this).find(".the_slide").html("");
				$(this).find(".slide_holder").removeClass().addClass("slide_holder");
				$(this).find(".selected").addClass("mobile_selected").removeClass("selected");
				$(this).find(".overlay").remove();
				$(this).find(".column_left").hide();
			});
		//},2500);
		//$(".expanded_bg:last").hide();
	} else {
		if( keep_expanded != true ){
				
			$(".expanded_bg").hide();
		
		}
	}
	//$(".expanded_bg:eq(0)").show();
	//$(".expanded_bg:eq(0)").addClass("currently_expanded");
	//$(".condensed").hide();
	//var sn = setInterval('modURL()',2000);
	
	var d = new Date(1304715753000);
	var thisYear = d.getFullYear();
	$("#copy_date").text(thisYear);
	$("#current_result").text('1');//$(".result").size());
	$("#total_results").text($(".result").size());
	
	
	/* 
	
	DO NOT WORRY ABOUT DATES ANY MORE - SHOULD BE POPULATED BY PHP FROM WP NOW
	
	$(".expanded").each(function(){
		if( $(".tile_date",$(this)).text() != "" ){
			var thisDate = new Date(parseInt($('.tile_date', $(this) ).text() ) );
			var thisDay = thisDate.getDay().toString();
			if(thisDay.length < 2){
				thisDay = "0"+thisDay;
			}
			var thisMonth = thisDate.getMonth().toString();
			if(thisMonth.length < 2){
				thisMonth = "0"+thisMonth;
			}
			var thisYear = thisDate.getFullYear().toString();
			var formatted_date_html = "<span class=\"month_"+thisMonth+"\">&nbsp;</span><span class=\"day_"+thisDay+"\">&nbsp;</span><span class=\"year_"+thisYear+"\">&nbsp;</span>";
			$(".formatted_date",$(this)).html(formatted_date_html);
			$(".tile_day",$(this)).text(thisDay);
			$(".tile_month",$(this)).text(thisMonth);
			$(".tile_year",$(this)).text(thisYear);
			
		}
	});
	$("#shy").hover(function(){
	tempText = $(this).text();
			$(this).text("Please don't touch me!");
			$(this).stop();
			$(this).animate( { fontSize: "12px" , fontColor: '#0xFFFFFF' },1150,function(){
			//alert('hit');
			})
	},
			function(){
				$(this).text(tempText);
				$(this).stop();
				$(this).animate( { fontSize: "36px" },1500, function(){
				
			});
	});
	*/
		
	$("#back_to_top").unbind('click').bind('click',function(){
			//if(scrollIndex > 1){
				transitionLarger( $(".condensed" , $(".result:eq(0)" ) ) );
			//} 
	});
		
	$("#up_btn").unbind('click').bind('click',function(){
		if(inTransition == true){
            return false;
        } else {
            //clearInterval(scrollID);
            //scrollKill = true; 
            //inTransition = true;
            return false;
        }
	});
	
	$("#down_btn").unbind('click').bind('click',function(){
		if(inTransition == true){
            return false;
        } else {
            headlock = false;
			typeFocus = true;
			if($("#head_slider").hasClass("open")){
				if(browser == 'Explorer'){
					$("#head_slider").children().hide();
				}
				var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
				$("#head_slider").stop().animate({height:headerHeight},300).removeClass("open");
				//$("#head_slider").stop(true,false).slideUp(300).removeClass("open");
			}
			clearInterval(scrollID);
            scrollKill = true; 
            inTransition = true;
            transitionLarger(  $(".condensed" , $(".result:eq(1)") ) );
            return false;
        }
	});
	assignTops();	
	//$("body").scrollTop(0);
	// was in formula below $("#header").outerHeight() +
	if(mobile == false){
//		$("#content_padding").height(theWindow.outerHeight() + (  46));
	}
	//$(".expanded_bg").click(function(){
		//transitionSmaller($(this));
	//});
	
	//theWindow.bind('scroll',function(){
		//getCurrentScrolled();
	//});
	
//	});
	//$(".condensed").click(function(){
		//transitionLarger($(this));
	//});
	$(".slide_thumbs a").each(function(){
		$(this).unbind().bind('click',function(){
			slide_swap($(this));
			return false;
		});
		if($("li",$(this).parent().parent()).index($(this).parent()) == 0 ) {
			slide_swap($(this));
		}
	});
	$(".expanded").each(function(){
		if($(".slide_thumbs a", $(this)).size() < 2){
			$(".slide_thumbs , .slide_nav, .slide_over_nav, .slide_over_btn_previous, .slide_over_btn_next, .slide_over_half_previous, .slide_over_half_next",$(this)).hide();
			$(".slide_thumbs",$(this)).css("visibility","hidden");
		}
	});

	$("input#search_term").bind('focus',function(){
		//alert('ha');
		if(scrollIndex > 1){
			if($("#head_slider").hasClass("open")){
				//typeFocus = false;
				
			} else {
				if(sd != ""){
					clearTimeout(sd);
					sd = "";
				}
				var headerHeight = 121;
								if(mobile==true){
									headerHeight = 121;
								}
				$("#head_slider").stop().animate({height:headerHeight},150,function(){
					if(browser == 'Explorer'){
						$("#head_slider").children().not("#search_history_list").show();
					}
				}).addClass("open");
								//$("#head_slider").stop(true,false).slideDown("100").addClass("open");
				headlock = true;
				typeFocus = true;
				
			}
		}
		if(searchTerm == ""){
			searchTerm = $(this).val();
			$(this).val("");
			inSearchBar = true;
		} else {
			inSearchBar = true;
		}
	});
	$("input#search_term").bind('blur',function(){
		hideSearch = setTimeout('clearSuggested()',300);
	});
	
	
	//$("body").focus(alert('hello there'));
	//var theDoc = document;
    //$("#search_term").attr("onkeyup","alert('hit');");
	
	
	jsLib.event.add ( document, "keyup", appKeydown );
	
	/*	
	//theWindow.bind("keyup",function(e){
		var unicode=e.keyCode? e.keyCode : e.charCode;
		//alert(inSearchBar);
		if(inSearchBar == true){
			if ( unicode == 40 ) {
				highlightResult('next');
				return false;
			} else
			if ( unicode == 38 ) {
				highlightResult('previous');
				return false;
			} else 
			if ( unicode == 13 ) {
				highlightResult('execute_current');
				
			} else 
			if ( unicode == 27 ) {
				highlightResult('escape');
				
			} else {
				var searchInput = document.search_form.search_term;
				checkSearchMatches(searchInput);
				
			}
		} else {
			if( unicode == 40 ) {
				$("#down_btn").trigger('click');
			} else
			if ( unicode == 38 ) {
				$("#up_btn").trigger('click');
			} else
			if ( unicode == 37 ) {
				$(".expanded_bg:eq("+parseInt(scrollIndex-1)+") .prev_link").parent().trigger("click");
			} else
			if ( unicode == 39 ) {
				$(".expanded_bg:eq("+parseInt(scrollIndex-1)+") .next_link").parent().trigger("click");
			} else {
				return false;
        	}
		}
	});
	*/
	
	$("a.tag_drawer").click(function(){
		var tagDrawerHeight = 140;
		if(mobile==true){
			tagDrawerHeight = 140;
		}
		if($(this).children(".tag_view").size() > 0){
			$(this).parent().parent().parent().parent().siblings(".tag_container_wrapper").animate({height:tagDrawerHeight},300,function(){
				});
			$(this).children(".tag_view").addClass("tag_hide").removeClass("tag_view");
		} else {
			$(this).parent().parent().parent().parent().siblings(".tag_container_wrapper").animate({height:34},300,function(){
				});
			$(this).children(".tag_hide").addClass("tag_view").removeClass("tag_hide");
			
		}
	});
	
	$("#search_history").hover(function(){
		clearTimeout(history_timer);
	},function(){
		history_timer = setTimeout('fadeHistory()',300);
	});
	
	$("#search_history_list").hover(function(){
		clearTimeout(history_timer);
	} , function(){
		history_timer = setTimeout('fadeHistory()',300);
	});
	
	$("#search_history").bind("click",function(){
		//$("#search_history_list").stop();
		$("#search_history_list").fadeIn(150);
	});
	$("#search_term").attr("tabIndex","1");
	$("#trending_searches a:eq(0)").attr('tabIndex','2');
	transitionInit($(".condensed:eq(0)"));//.trigger("click");
	
	$("#head_slider").addClass("open");
	$("#header").hover(function(){
		//if ( headlock == false ){
			
			if(sd != ""){
				clearTimeout(sd);
				sd = "";
			}
		if ( headlock == false ) {	
		var headerHeight = 121;
								if(mobile==true){
									headerHeight = 121;
								}
			$("#head_slider").stop().animate({height:headerHeight},150,function(){
					if(browser == 'Explorer'){
						$("#head_slider").children().not("#search_history_list").show();
					}
				}).addClass("open");
								//$("#head_slider").stop(true,false).slideDown(300);
		}
	},function(){
		if(headlock == false ) {
			//alert('out no headlock');
					if(browser == 'Explorer'){
						$("#head_slider").children().hide();
					}
				var headerHeight = 0;
								if(mobile==true){
									headerHeight = 121;
								}
			sd = setTimeout(function(){if(headlock==false){$("#head_slider").stop().animate({height:headerHeight},300); }},500);
		}
	});
	
	if(browser == "Explorer"){
		$(".slide_over_half_previous").hover(function(){
			$(this).siblings('.slide_over_btn_previous').show();//fadeIn(200);
		}, function(){
			$(this).siblings('.slide_over_btn_previous').hide();//fadeOut(200);
		});
		
		$(".slide_over_half_next").hover(function(){
			$(this).siblings('.slide_over_btn_next').show();//fadeIn(200);
		}, function(){
			$(this).siblings('.slide_over_btn_next').hide();//fadeOut(200);
		});
	} else if(mobile==false) {
		$(".slide_over_half_previous").hover(function(){
			$(this).siblings('.slide_over_btn_previous').stop().fadeTo(200,1);
		}, function(){
			$(this).siblings('.slide_over_btn_previous').stop().fadeTo(200,0);
		});
		
		$(".slide_over_half_next").hover(function(){
			$(this).siblings('.slide_over_btn_next').stop().fadeTo(200,1);
		}, function(){
			$(this).siblings('.slide_over_btn_next').stop().fadeTo(200,0);
		});
	}
	/*
	$(".slide_holder").delegate(".slide_over_half_previous","mouseenter",function(){
		//alert('previous in ');
		$(this).siblings(".slide_over_btn_previous").fadeIn(200);
	});
	$(".slide_holder").delegate(".slide_over_half_previous","mouseleave",function(){
		//alert('previous out');
		$(this).siblings(".slide_over_btn_previous").fadeOut(200);
	});
	
	$(".slide_holder").delegate(".slide_over_half_next","mouseenter",function(){
		//alert('next in');
		$(this).siblings(".slide_over_btn_next").fadeIn(200);
	});
	$(".slide_holder").delegate(".slide_over_half_next","mouseleave",function(){
		//alert('next out');
		$(this).siblings(".slide_over_btn_next").fadeOut(200);
	});
	*/
	if(mobile==false){
		$(".slide_over_btn_previous,.slide_over_btn_next").hide();
	}
	if(browser=="Explorer"){
		//$(".slide_over_btn_prev img").attr("src","wp-content/themes/images/lt_arrow_ie.png");	
		//$(".slide_over_btn_next img").attr("src","wp-content/themes/images/rt_arrow_ie.png");	
	}
	
	/*$(".result").each(function(){
		var theTags = [];
		//alert(tags.length);
			$(".tag_container a",$(this)).each(function(){
				if($(this).text() != ""){	
					//alert($(this).text());
					var tempText = $.trim($(this).text());
					//tempText.trim();
					theTags.push(tempText);
				}
				
			});
		//theTags.push("in her");
		//theTags.push("in");
		//tags.push("chachi");
		
		
		if(theTags.length > 0){
			//alert("::"+tags[3]+"::");
			//tags.push("tea");
			//tags.push('Erbert');
			//tags.push('caribou');
			var thisCopy = $(this).contents();
			var previouslyMatched = [];
			previouslyMatched.push("n0M4tch");
			$('.expandedd',$(this)).children().not('.column_right img, .disqus,.type_twitter,.autotag,.h1_container,.condensed,.tag_container_wrapper,.tile_footer_wrapper, img , a ,strong,.tag_container,.slideshow_container,.slide_nav,.formatted_date,.tile_date,.slide_thumbs,.the_slide,.slide_holder,.tile_footer,.tile_tags,.tile_share').each(function(){
				for(var i = 0; i < theTags.length ; i++){
					//if(tags[i] != 'coffee'){
					var currentObj = $(this);
					//currentObj.html("");
					var matchString = theTags[i];
					//var matchLc = matchString.toLowerCase();
					var dupString = "";
					var dupA = "";
					var dupA_B = "";
					var dupB = "";
					var tempMatch = "";
					var Mymatch = "";
					var replaceText = "::n0th1ng5h0u1dm4tchTH15::";
					var resetMatch = new RegExp(replaceText,"gi");
					
					var delayedReplace = "";//setTimeout(function(){
							//Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
							//currentObj.html(currentObj.html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4"));
							//previouslyMatched.push(theTags[i]);
							//alert('hi');
						//},500);
					
					var delayedReset = "";
					
					//var tempReplaceVar = currentObj.html();
					//alert(tempReplaceVar);
								
					for(var j = 0 ; j < previouslyMatched.length ; j++){
						dupA = "";
						dupB = "";
						dubA_B = "";
						var lcm = previouslyMatched[j].toLowerCase();
						var lct = theTags[i].toLowerCase();
						
						
						
						if ( lct != ""){
							//clearTimeout(delayedReplace);
							if(lcm.indexOf(lct,0) > -1){
								//matchString = 'n0th1ng5h0u1dm4tchTH1$';
								dupString = previouslyMatched[j];
								tempMatch = new RegExp("([^a-zA-Z0-9_<>])("+dupString+")([^a-zA-Z0-9_<>])","gi");
								//var tempReplaceVar = currentObj.html();
								//alert(tempReplaceVar);
								currentObj.html(currentObj.html().replace(tempMatch,"$1"+replaceText+"$3"));//,function(){
									//action
									
										//Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
										//jsReplace(currentObj,Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4",dupString,matchString);
										//previouslyMatched.push(matchString);
					//					currentObj.html(currentObj.html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4"),function(){
						//				currentObj.html(currentObj.html().replace(tempMatch,dupString));	
										//});
//										previouslyMatched.push(theTags[i]);
					
									//},500);
									
								
									//})
								//);
								
								/*if(lcm.indexOf(lct,0) > 0){
									dupA = "(?:(?!"+(dupString.substring(0,lcm.indexOf(lct,0)))+")";
									dupA_B = ".)";
									//alert(dupA);
								}
								*/
								/*
					
								if(lct.length + lcm.indexOf(lct,0) < lcm.length){
									dupB = lcm.substring((lct.length + lcm.indexOf(lct,0)),lcm.length);//.trim();
									//alert(dupB);
								}
							} */ /*else {
								//delayedReplace = setTimeout(function(){
									Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
									currentObj.html(currentObj.html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4"));
									previouslyMatched.push(theTags[i]);
					
								//},500);
							} */ /*
						}
					}
					*/
					/*
					if(dupString==""){
						//alert(matchString);
						Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
						jsReplace(currentObj,Mymatch,"$1<a class='autotag' href='#' title=\"search site for: "+matchString+"\" onclick=\"populateSearch('"+matchString+"');return false;\">$2</a>$3$4",dupString,matchString);
						previouslyMatched.push(matchString);
						
					} else {
							//alert(matchString);
						Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
						jsReplace(currentObj,Mymatch,"$1<a class='autotag' href='#' title=\"search site for: "+matchString+"\" onclick=\"populateSearch('"+matchString+"');return false;\">$2</a>$3$4",dupString,matchString);
						previouslyMatched.push(matchString);
						
					}
					*/
					/*
						//alert(matchString);
						Mymatch = new RegExp("([^a-zA-Z0-9_<>])("+matchString+")([^a-zA-Z0-9_<>])","i");
						jsReplace(currentObj,Mymatch,"$1<a class='autotag' href='"+siteUrl+"?q="+matchString+"' title=\"search site for: "+matchString+"\" >$2</a>$3",dupString,matchString,resetMatch);
						previouslyMatched.push(matchString);
						
					*/
					/*
					
					if(dupString!=""){
						//action
						//$(this).html($(this).html().replace(tempMatch,replaceText),function(){
							//action
								Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
							$(this).html($(this).html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4"));//,function(){	
							//	if ( dupString != ""){
							//		$(this).html($(this).html().replace( resetMatch,dupString));
							//	}
				//			});
							
						//});
								
					} else {
						Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
						$(this).html($(this).html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4"));
							
					}
					previouslyMatched.push(theTags[i]);
						*/
					
					/*
					if ( dupString != ""){
						//alert(tempMatch);
						//$(this).html($(this).html().replace(tempMatch,":::t3mpm4tch:::"));
						//alert(dupString + matchString);
						//alert(matchString +" <- "+previouslyMatched +" :"+ dupB);
						//Mymatch = new RegExp("([^\w])("+matchString+")\'?s?(?!"+dupB+")([^\w])","i");
						//Mymatch = new RegExp("([^\w\"\'_])("+matchString+")(?!"+dupB+")(\'s)?(?!\')(?!\</a\>)([^\w\"\'_])","i");
						//matchString = matchString+dupB;
						//Mymatch = new RegExp("([^\w\"\'_])("+matchString+"(?!"+dupB+"))(\\'s)?(?!\\')(?!\</a\>)([^\w\"\'_])","i");
						//MymatchStr = "/([^w\"\'_])("+matchString+"(?!"+dupB+"))(\'s)?(?!\')(?!\</a\>)([^\w\"\'_)/i";
						
						//alert(Mymatch);//$(this).prepend("<h1>hit</h1>");//alert(matchString+dupB);
						//Mymatch = new RegExp("([^\w\"\'_])("+matchString+")(\'s)?(?!\')(?!\</a\>)([^\w\"\'_])","i");
						Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
						
						//$(this).html($(this).html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"');return false;'>$2</a>$3$4"));
						//alert(Mymatch);
						//$(this).html($(this).html().replace(MymatchStr,"[[[found it]]]"));
						//var resetMatch = new RegExp("(^a-zA-Z0-9)(:::t3mpm4tch:::)(^a-zA-Z0-9)","i");
						//$(this).html($(this).html().replace( resetMatch,dupString));
					} else {
						//Mymatch = new RegExp("([^\w\"\'_])("+matchString+")(\'s)?(?!\')(?!\</a\>)([^\w\"\'_])","i");
						Mymatch = new RegExp("([^\w_])("+matchString+")(\'s)?([^\w_])","i");
						//MymatchStr = "/([^w\"\'_])("+matchString+")(\'s)?(?!\')(?!\</a\>)([^\w\"\'_)/i";
						//alert(Mymatch);
						//alert(matchString);
						$(this).html($(this).html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick='populateSearch(\'"+matchString+"\');return false;'>$2</a>$3$4"));
						//$(this).html($(this).html().replace(/in/gi,"[[[found it]]]"));
					
					
						//if ( dupString != ""){
							//$(this).html($(this).html().replace( resetMatch,dupString));
						//}
					}
					*/ /*
					//$(this).html($(this).html().replace( Mymatch,"$1<a class='autotag' href='#' title='search site for: "+matchString+"' onclick=\"populateSearch('"+matchString+"');return false;\">$2</a>$3"));
				
					//alert(tags[i]);
					//previouslyMatched.push(theTags[i]);
					//}
					
					//alert(tags[i]);
					//if(easterEgg == true){
						//$(this).html($(this).html().replace( Mymatch,"<a class='autotag easterEgg' href='#' title='search site for: "+tags[i]+"' onclick=\"populateSearch('"+tags[i]+"');return false;\">$1</a>"));	
					//} else {
						//$(this).html($(this).html().replace( Mymatch,"<a class='autotag' href='#' title='search site for: "+tags[i]+"' onclick=\"populateSearch('"+tags[i]+"');return false;\">$1</a>"));
					//}
				}
				
			});
		}
	});*/
	
	/*if(browser=="Explorer"){
		$(".slide_over_nav").delegate(".slide_over_previous","mouseenter",function(){
				$(this).css("background","url(wp-content/themes/images/lt_arrow_ie.png) no-repeat top left");//animate({opacity:1.0},300);
				$(this).css("background-position","0px 186px");
			});
		$(".slide_over_nav").delegate(".slide_over_previous","mouseleave",function(){
				$(this).css("background","none");//.animate({opacity:0.0},300);
		});
		$(".slide_over_nav").delegate(".slide_over_next","mouseenter",function(){
				$(this).css("background","url(wp-content/themes/images/rt_arrow_ie.png) no-repeat top right");//animate({opacity:1.0},300);
				$(this).css("background-position","330px 186px");
			});
		$(".slide_over_nav").delegate(".slide_over_next","mouseleave",function(){
				$(this).css("background","none");//animate({opacity:0.0},300);
		});
	} else {
		$(".slide_over_nav").delegate(".slide_over_previous","mouseenter",function(){
				$(this).animate({opacity:1.0},300);
			});
		$(".slide_over_nav").delegate(".slide_over_previous","mouseleave",function(){
				$(this).animate({opacity:0.0},300);
		});
		$(".slide_over_nav").delegate(".slide_over_next","mouseenter",function(){
				$(this).animate({opacity:1.0},300);
			});
		$(".slide_over_nav").delegate(".slide_over_next","mouseleave",function(){
				$(this).animate({opacity:0.0},300);
		});
	}*/
	
	$(".titleBox").each(function(){
		var kidWidth = parseInt($(this).width()) + 35 ;
		//alert(kidWidth);
		if(kidWidth>55 && kidWidth <= 900){
		//	$(this).css("width",kidWidth);
		}
	});
	if(mobile){
		var footTop = $(".result:last").offset().top + 130;
		document.getElementById('bg').style.top = (footTop /* - window.innerHeight */ ) + 'px';// (/*window.pageYOffset /*+ window.innerHeight - 25 */ 0) + 'px';
								
		//alert(browser);
		//$("#content_padding").hide();
		//$("#footer").css("margin-top",theWindow.height()+200);
	}
});


