//limitedBrowserList: Array to determine whether a client has limited java
//support. Strings should be lowercase, and a limited java version will
//occur if the any of the strings are found in navigator.userAgent.toLowerCase()
var limitedBrowserList = ["blackberry"];
function limitedBrowser()
{
	var b = false;
	var uagent = navigator.userAgent.toLowerCase();
	for (i=0; i<limitedBrowserList.length;i++)
	{
		if (uagent.search(limitedBrowserList[i]) > -1)
		{	b=true; 	}
	}
	return b;
}

if (limitedBrowser()) {
	animate=false;	//disable graphics animations
	}

if (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function() {} };

urlParts = location.href.split("/");
if (window.animate==undefined) { animate=false; }
else if (window.animate==true) { document.write('<style type="text/css">div.graphics h1,div.graphics h2,div.graphics p{display:none}</style>'); }

if (urlParts[urlParts.length - 1].length) { // if the end of the url isn't just a slash
	currentURL = urlParts[urlParts.length - 1];
	} 
else {currentURL = 'index.php';}

$(document).ready(function () {


Cufon.replace('h1', { fontFamily: 'myriad-extended-italic' });
Cufon.replace('h2', { fontFamily: 'myriad-extended-italic' });
Cufon.replace('.our-communities h3');
Cufon.replace('.faq h4');
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);

if (jQuery.browser.msie){ $(".p7VSC_scrollbox_wrapper").first().css("padding-top","14"); }

if (animate){
if (jQuery.browser.msie){	$("h1").before('<div id="graphics2" class="graphics"></div>');
							$(".graphics .hider").customFadeTo(0,0);
							$(".wrapper").addClass('ie');
							//$(".graphics p").first().css("padding-top","93");
							$(".graphics h2").after('<div id="graphics3" class="graphics"></div>');
							$(".hider").after('<div id="graphics4" class="graphics"></div>');
							//if($('.graphics h2').length == 0){$(".graphics h3:first").first().css("padding-top","56");}
							//unhide
							$(".graphics h1").css("display","block");$(".graphics h1").css("visibility","visible");
							$(".graphics h2").css("display","block");$(".graphics h2").css("visibility","visible");
							$(".graphics p").css("display","block");$(".graphics p").css("visibility","visible");
							$(".graphics h3").css("display","block");$(".graphics h3").css("visibility","visible");
							$(".graphics h4").css("display","block");$(".graphics h4").css("visibility","visible");
							$(".graphics h5").css("display","block");$(".graphics h5").css("visibility","visible");

							
}
else{	$(".graphics .hider").customFadeTo(0,0);
		$(".graphics h1").customFadeTo(0,0);
		$(".graphics h2").customFadeTo(0,0);
		$(".graphics h1").css("display","block");$(".graphics h1").css("visibility","visible");
		$(".graphics h2").css("display","block");$(".graphics h2").css("visibility","visible");
		$(".graphics p").css("display","block");$(".graphics p").css("visibility","visible");
		$(".graphics h3").css("display","block");$(".graphics h3").css("visibility","visible");
		$(".graphics h4").css("display","block");$(".graphics h4").css("visibility","visible");
		$(".graphics h5").css("display","block");$(".graphics h5").css("visibility","visible");
		$(".hider").after('<div id="graphics2" class="graphics"></div>');
		}







//fade in for ie
	
if (jQuery.browser.msie){

$("#graphics4").delay(500).animate({ opacity: 0.0 }, 1000, 	function(){$("#graphics4").hide();});

	if($('.graphics h2').length == 0){$("#graphics2").delay(1500).animate({ opacity: 0.0 }, 1000, 	function(){$("#graphics2").hide();$(".graphics .hider").delay(0).customFadeTo(1000,1.0);});}
		else{
			$("#graphics3").delay(1500).animate({ opacity: 0.0 }, 1000, function(){$("#graphics3").hide();});
			$("#graphics2").delay(1500).animate({ opacity: 0.0 }, 1000, function(){$("#graphics2").hide();$(".graphics .hider").delay(0).customFadeTo(1000,1.0);});
}
}

//fade in for non-ie

else{

$(".graphics h1").delay(500).customFadeTo(1000,0.7);
$("#graphics2").delay(1500).animate({ opacity: 0.0 }, 1000, function(){$("#graphics2").hide();});
if($('.graphics h2').length == 0){
	$(".graphics .hider").delay(1500).customFadeTo(1000,1);}
else{
	$(".graphics h2").delay(1500).customFadeTo(1000,0.7,function(){$(".graphics .hider").delay(0).customFadeTo(1000,1);});
}
}
} 


// else, no animate:

else {


	$(".graphics h1").css("visibility","visible");$(".graphics h1").css("display","block");$(".graphics h1").customFadeTo(0,.7);
	if($('.graphics h2').length != 0){$(".graphics h2").css("display","block");$(".graphics h2").css("visibility","visible");$(".graphics h2").customFadeTo(0,.7);}
	if($('.graphics h3').length != 0){$(".graphics h3").css("display","block");$(".graphics h3").css("visibility","visible");$(".graphics h3").customFadeTo(0,1.0);}
	if($('.graphics h4').length != 0){$(".graphics h4").css("display","block");$(".graphics h4").css("visibility","visible");$(".graphics h4").customFadeTo(0,1.0);}
	if($('.graphics h5').length != 0){$(".graphics h5").css("display","block");$(".graphics h5").css("visibility","visible");$(".graphics h5").customFadeTo(0,1.0);}
	if($('.graphics p').length != 0){$(".graphics p").css("display","block");$(".graphics p").css("visibility","visible");$(".graphics h5").customFadeTo(0,1.0);}


	}
	



//mark current links

 




 
   selectedPage = $("ul li a[href='" + currentURL + "']").parent(); 
  

   $(selectedPage).addClass("current");
   
   
 
 if(	currentURL=='services-and-amenities.php'|| 
			currentURL=='our-communities.php'|| 
			currentURL=='affordable-living.php'|| 		
			currentURL=='specialty-programs.php'|| 
			currentURL=='careers-join-our-team.php'

		)	{ $("#bottom li a").addClass('over');}


   
   

/*for current submenu over on load, look at top of submenu.php*/
/*also make sure .wrapper has proper class line 55*/     
   
   
   
				//mark top current links by href = current url  
	var lwcategory;
	lwcategory=urlParts[urlParts.length - 1].split("-");
	//alert(lwcategory[0]);
	 if (urlParts[urlParts.length - 1].length) {
				lwcategory1=lwcategory[0];
				//alert(lwcategory1);
				selectedPage2 = $(".wrapper ul#top li a[href\^\=\'"+lwcategory1+"\-\'\]").parent();
				//alert(selectedPage2.length);
				$(selectedPage2).addClass("current");
		 
   				}
 
   
   
   
//add growy text if there is no custom scroller  

 if ($('#p7VSC_1').length != 0) {
    //console.log('Found an custom scroller (element with id "#p7VSC_1"). Skipping text grower');
     $('.text-size').addClass('disabled');
    
     } else {
        //console.log('No item with id "#p7VSC_1" found. Adding text grower');
        
         $('.text-size a').click(function(){
                var ourText = $('.graphics p');
    var currLineHeight = ourText.css('lineHeight');
               var currFontSize = ourText.css('fontSize');
                var finalNum = parseFloat(currFontSize, 10);
    var finalNum2 = parseFloat(currLineHeight, 10);
                var stringEnding = currFontSize.slice(-2);
                if(this.id == 'large') {
                    finalNum *= 1.2;
    finalNum2 *= 1.2;
                }
                else if (this.id == 'small'){
                    finalNum /=1.2;
    finalNum2 /= 1.2;
                }
                ourText.animate({fontSize: finalNum + stringEnding, lineHeight: finalNum2 + stringEnding},600);    
            });
       

  }

	



});
