﻿//teaser animation
	//timer setting
	var tXS=1500;
	//sets animation to start
	var aniNum="start";
	var usAgent=navigator.userAgent;
	//alert()
	
//setting side navigation height and width
function sideNavBG(){
	
	//get width and height for side navigation
	if(!document.all){
		//for none ie browsers
		var navHeight=$("#blackBoxContainer").css('height');
		var navWidth=$("#blackBoxContainer").css('width');
	}else{
		//for ie's needed version
		navHeight=$('#blackBoxContainer').height()+'px';//get height
		navWidth=$('#blackBoxContainer').width()+'px';//get width
	}
	
	$("#blackBoxTransparency").css({height:navHeight});
	$("#blackBoxColor").css({height:navHeight});
	
	}

//homepage navigation animation
function dropNavBG(){
		if(!document.all)
		$("#NavCapper").animate({height:"76px"},tXS);
		else
		if(usAgent.indexOf("MSIE 6")==-1){
			$("#NavCapper").animate({height:"74px"},tXS);
			}else{
		$("#NavCapper").animate({height:"78px"},tXS);}
	}

//for resizing navigation topper if window is resized
function adjustNavBG(){
		$("#NavCapper").css({width:$(window).width()});
	}


	
	function animateBoxold(){
		
		//set array length
		if(aniNum=="start"){
			aniNum=$('.animateIt').length;
		}
		
			if(!document.all){
				//for all browsers other then ie
				gWidth=$('.animateIt:eq('+aniNum+')').css('width');//get width
			}else{
				//for ie's needed version
				gWidth=$('.animateIt:eq('+aniNum+')').width()+'px';//get width
			}

		//animate it
		$('.animateIt div.cBackground:eq('+aniNum+')').animate({width:gWidth, marginLeft: "0px"},tXS);
		$('.animateIt div.wBackground:eq('+aniNum+')').animate({width:"0px"},tXS);
		if(aniNum>=0){
			aniNum--;
			setTimeout("animateBox()",tXS);
		}else{
			//end animations
			}
		//alert(aniNum)
	}
	
	function animateBox(){
		
		
		
		if($('.wideTease .animateIt div.cBackground')){
			$('.wideTease .animateIt div.cBackground').animate({width:"488px", marginLeft: "0px"},tXS);
			
		}
		
		if($('.wideTease2 .TeaseTitle.animateIt div.cBackground')){
			$('.wideTease2 .animateIt div.cBackground').animate({width:"720px", marginLeft: "0px"},tXS);
			}
		
		
		$('.animateIt div.cBackground').not('.wideTease .animateIt div.cBackground').not('.wideTease2 .TeaseTitle.animateIt div.cBackground').animate({width:"240px", marginLeft: "0px"},tXS);//if(!$('.wideTease2 .TeaseTitle')){}
		
		
		
		
		$('.animateIt div.wBackground').animate({width:"0px"},tXS);	
	}
	
	function getE(){
	//alert($('.animateIt').length)
	//$('.commen div:odd').css({color:"red"});
	//loop over properly clasnamed items
		for(i=0;i<$('.animateIt').length;i++){
			if(!document.all){
				//for all browsers other then ie
				gHeight=$('.animateIt:eq('+i+')').css('height');//get height
				gWidth=$('.animateIt:eq('+i+')').css('width');//get width
			}else{
				//for ie's needed version
				gHeight=$('.animateIt:eq('+i+')').height()+'px';//get height
				gWidth=$('.animateIt:eq('+i+')').width()+'px';//get width
				
			}
			
			//set width and height of the div so background is right on
			$('.animateIt div.wBackground:eq('+i+')').css({height:gHeight, width:gWidth, opacity:.60,display:'block'});
			//position color overlay
			$('.animateIt div.cBackground:eq('+i+')').css({marginLeft:gWidth, height:gHeight })
			
		}
		//loop over regular boxes and transparent them
		//alert($('.defaultColor').length)  .defaultColor div.innerContent
		for(j=0;j<$('.defaultColor').length;j++){
			if(!document.all){
				//for all browsers other then ie
				gHeight=$('.defaultColor:eq('+j+')').css('height');//get height
				gWidth=$('.defaultColor:eq('+j+')').css('width');//get width
			}else{
				//for ie's needed version
				gHeight=$('.defaultColor:eq('+j+')').height()+'px';//get height
				gWidth=$('.defaultColor:eq('+j+')').width()+'px';//get width
				
			}
			//set width and height of the div so background is right on
			$('.defaultColor div.wBackground:eq('+j+')').css({height:gHeight, width:gWidth, opacity:.60,display:'block'});
			$('.defaultColor').hover(function(){
				$(this).find('div.wBackground').animate({opacity:.75}, 1000);//.css({opacity:.95})
				
				}, function(){
						$(this).find('div.wBackground').animate({opacity:.60}, 1000);//.css({opacity:.65});
					})
			
			/*$('.animateIt').hover(function(){
				$(this).find('div.wBackground').animate({opacity:.70}, 500);//.css({opacity:.95})
				
				}, function(){
						$(this).find('div.wBackground').animate({opacity:.60}, 500);//.css({opacity:.65});
					})*/
			
			$('.defaultColor:eq('+j+')').css({background:'none'});
			$('.defaultColor div.innerContent:eq('+j+')').css({background:'none',position:'relative',zIndex:20});
			}
		
		//setTimeout("animateBox()",tXS);
		animateBox();
		
		if(setMainNavDrop==true){
			//set time out for top nav to start
			//setTmoutLvl=tXS;
			//alert(tXS+" "+setTmoutLvl)
			//setTimeout("dropNavBG()",setTmoutLvl);
			dropNavBG()
		}
	}
	
	
	function addScroll(){
			//test for top of page
			osTop=$(window).scrollTop();
			//if top of page--show if not hide		
			if(osTop==0){
				$('#colorImgBg').animate({opacity:1},70);
			}else{
				$('#colorImgBg').animate({opacity:0},270);
			}

		}
		
		
	function lineUp(){
	
		osLft=$('#blackBoxContainer').offset().left+230;
		osTop=$('#blackBoxContainer').offset().top;
		osHeight=$('#blackBoxContainer').height();
		setLftSide=10;
		
		if(usAgent.indexOf("MSIE 6")==-1){
			$("#colorImgBg").css({height:osHeight+'px', width:osLft+'px', left:setLftSide+'px', opacity:0,display:'block'});
			$("#colorImgBg").scrollTo( {top:osTop+'px', left:setLftSide+'px'}, 0 );
			//
			$("#colorImgBg").animate({opacity:1},tXS);
		}

	}

function windowSC(){
	osLft=$('#blackBoxContainer').offset().left+230;
	$("#colorImgBg").css({width:osLft+'px'});
}
	
	//window.onload=function(){}
	
	window.onresize=function(){
		adjustNavBG();
		windowSC();
	}
	
	$(window).scroll(function () {
		addScroll()						   
	})
	
	
// Advocacy Map Light box

	function closeLB(){
		$("#advacyMapLB").remove();
		}
		
	function launchLB(){
			//alert(this.getAttribute('href'))
			$('body').prepend('<div id="advacyMapLB"><div id="opLayer"></div><div class="c" style="width:798px;height:625px;margin:0px auto 0px auto;"><a href="javascript:viod(0)" onclick="closeLB()" ><img src="/common/images/template/gallery_close.gif" alt="close" /></a><iframe scrolling="no" src="'+this.getAttribute('href')+'"  frameborder="0" allowtransparency="true" ></iframe></div></div>');
			$("#advacyMapLB iframe").css({width:'798px',height:'625px',margin:'30px auto 0px auto'});
			$("#advacyMapLB").css({width:$(window).width(),height:$(window).height()});
			$("#advacyMapLB #opLayer").css({width:$(window).width(),height:$(window).height(),opacity:.5});
			return false;
			
			
		}	
		
		function launchLB2(){
			//alert(this.getAttribute('href'))
			$('body').prepend('<div id="advacyMapLB"><div id="opLayer"></div><div class="c" style="width:798px;height:625px;margin:0px auto 0px auto;"><a href="javascript:viod(0)" onclick="closeLB()" ><img src="/common/images/template/gallery_close.gif" alt="close" /></a><iframe scrolling="no" src="/common/flash/advocacy_map/index.html"  frameborder="0" allowtransparency="true" ></iframe></div></div>');
			$("#advacyMapLB iframe").css({width:'798px',height:'625px',margin:'30px auto 0px auto'});
			$("#advacyMapLB").css({width:$(window).width(),height:$(window).height()});
			$("#advacyMapLB #opLayer").css({width:$(window).width(),height:$(window).height(),opacity:.5});
			
			
		}
		
		function determiner(links){
			
				if(links=="/common/flash/advocacy_map/index.html"){
						launchLB2();
					}else{
						window.location=links;
						}
			}
		
	$(document).ready(function(){
		$('a.advocacyLinkMap').bind('click', launchLB);
	
							   })