var testimonials = [

'"Don Dwiggins is the best Architect in Alaska."<br/><span>--Roger Hickel, President, Roger Hickel Contracting, Inc.</span>',

'"We just refer to him as the Miracle Worker."<br/><span>--Jim Wood, TRF Management Corporation</span>',

'"Tenants, Developers and Contractors always find his work and attitude extremely professional. I am pleased to give Don Dwiggins Associates my highest recommendation and the Stuart Bond Seal of Approval."<br/><span>--Stuart Bond, CCIM, Broker</span>',

'"Don has a great understanding of the code and makes our job at Building Safety a whole lot easier."<br/><span>--Ron Thompson, Building Official, Municipality of Anchorage</span>',

'"My experience with Don has been excellent in that he is very professional and provides projects efficiently designed that can be constructed cost effectively."<br/><span>--Andrew Eker, CEO, The Alaska Club</span>',

'"Don has always been responsive and provided creative solutions to code or design challenges for a variety of projects."<br/><span>--Joseph A Liska, NANA Management Services</span>',

'"Don Dwiggins has a thorough understanding of the entire design and construction process. In particular, he is innovative, practical, knows  the building codes, municipal permit process and understands how contractors carry out their work.<br/><span>--Gary C. Boslough, President, Boslough Construction, Inc.</span>',

'"I am impressed with your ability to shape space to meet a tenant\'s needs, while keeping project costs to a minimum."<br/><span>--Megan G. Benedict, Vice President, BS&J Property Management</span>',

'"We have found Don Dwiggins Associates to be proficient at designing a wide range of projects."<br/><span>--Roger Hickel, President, Roger Hickel Contracting, Inc.</span>',

'"We have always found the work to be of the highest caliber and always completed on time and on budget."<br/><span>--Stuart Bond, CCIM, Broker</span>',

'"His team of professionals anticipates the needs of their client and applies innovative solutions that balance aesthetics with cost and schedule."<br/><span>--Brian G. Tomlinson,  Fluor</span>',

'"I like Don Dwiggins because of his really, really cheap prices!"<br/><span>--Mark Rowley, Pacific Tower Properties, Inc.</span>',

'"Don has a high commitment to quality and he fights hard for his clients."<br/><span>--James D. Gray, P.E., Deputy Building Official Municipality of Anchorage</span>',

'"Don\'s designs have always met our client\'s needs and budget."<br/><span>--Roger Hickel, President, Roger Hickel Contracting, Inc.</span>',

'"Don\'s ability to reorganize a tenant\'s space to be more efficient has saved our tenant time and money, as they need less space. It makes for well-satisfied and happy tenants."<br/><span>--Jim Wood, TRF Management Corporation</span>',

'"We had to do space planning and construction of 15,000 square feet of Class A office space - all within 4 weeks. Don did all this single handedly-on time, and within budget."<br/><span>--Derrick Chang</span>',

'"Don\'s understanding of building codes and relationship with municipal officials, consultants and contractors have been instrumental in completing projects in a timely manner.<br/><span>--Joseph A Liska, NANA Management Services</span>',

'"I can give Don my highest recommendation for anyone needing commercial space planning services."<br/><span>--Chris Stephens, CCIM, President, Bond Stephens and Johnson, Inc</span>',

'"It is a pleasure to work with Don Dwiggins Associates and we highly recommend them."<br/><span>--Roger Hickel, President, Roger Hickel Contracting, Inc.</span>',

'"When we give directions to our house, people always say \'OH! You live in that beautiful house.\'"<br/><span>--Mary Mattoon, Moscow, Idaho</span>',

'"Don Dwiggins is the best Architect I ever worked with"<br/><span>--Dale Jackson, Retired Real Estate Broker</span>',

'"It is always fun working with you in finding the solutions to problems that occur during the design process."<br/><span>--Thomas E. Hammond, PE, SE</span>',

'"Don is a no-nonsense, practical, and highly efficient architect. We have used his services to build out some 200,000 square feet of office space, and we have never had one reason for complaint."<br/><span>--Derrick Chang</span>',

'"Don Dwiggins is a problem-solver."<br/><span>--Craig Watts, H. Watt & Scott, Inc</span>',

'"His knowledge of building design in cold climates is excellent."<br/><span>--Gary C. Boslough, President, Boslough Construction, Inc.</span>',

'"Don\'s knowledge of the building codes as they apply to our specialty - tenant improvements - and his ability to resolve code issues, is without peer."<br/><span>--Mike Gould, President, Excel Construction</span>',

'"I have recommended your services widely to tenants and property owners and will remain very pleased to do so in the future."<br/><span>--Megan G. Benedict, Vice President, BS&J Property Management</span>',

'"I am pleased to recommend without hesitation, Don Dwiggins Associates to any prospective client."<br/><span>--Gary C. Boslough, President, Boslough Construction, Inc.</span>',

'"There is not a better office space planner in Alaska than Don Dwiggins.<br/><span>--Boyd Morganthaler, P.E., President, AMC Engineers</span>',

'"When it comes to fast, efficient and high quality space planning, you won\'t find anyone better than Don Dwiggins in all of Anchorage."<br/><span>--Derrick Chang</span>'

];

	$('body').ready(function(){
	//menu item hover
		$('.menuItem').hover(
			function(){
				$(this).addClass('hover');
			},
			function(){
				if(($(this).attr('class')).indexOf('selected') == -1){
					$(this).removeClass('hover');
					$(this).children('a').removeClass('hover');
				}
			}
		);
		$('.menuItem').one('click',function(){
				window.location = $(this).children('a').attr('href');
		});
		
		//submenu hover
		$('.submenuItem').hover(
			function(){
				$(this).addClass('hover');
				if($.browser.msie){
					$(this).children('span').addClass('hover_ie');
				}
			},
			function(){
				if(($(this).attr('class')).indexOf('selected') == -1){
					$(this).removeClass('hover');
					$(this).children('span').removeClass('hover_ie');
				}
			}
		);
		
		//submenu click
		$('.submenuItem').bind('click',function(){
				//window.location = $(this).children('a').attr('href');
			 	$(this).children('a').click();			
		});

		
		var debug = false;
	//quotes
		
		var currentIndex = Math.floor(testimonials.length*Math.random());
		$('div#quote').children('div').html(testimonials[currentIndex++]);
		var ttime = 12000; //transition time
		
		if(debug) //if in debug mode, take really long.
			ttime = 500000;
		
			var timer = setInterval(showQuote, ttime);

			function showQuote(){
				var quoteContainer = $('div#quote').children('div');
				quoteContainer.fadeOut('slow',function(){
					if(currentIndex == testimonials.length-1)
						currentIndex = -1;
					$(this).html(testimonials[++currentIndex]);
				
				});
				quoteContainer.fadeIn('slow');
			}
		
		//moon tab
		var open = false;
		/*
		
		$('img#moon').bind('click',function(){
			var moonmenu = $('div#moonmenu');
			moonmenu.animate({'width':'320px'});
		})
		*/
		var divRight = $('div#right');
		
		function bindSubmenu(link, framepage, css){

			link.bind('click', function(){
				unBindText($('div#text'));
				var divSm = $('<div id="contain" class="'+css+'"></div>');
				divSm.load(framepage, function(){ 
					divRight.html(divSm);
					bindText($('div#text'));
					initSlideShow($('div.slideshow'));
				});
			 	$('.clicked').removeClass('clicked');

			 	var classes = $(this).parent().attr('class');
			 	if(classes.indexOf('casestudy') > 0){
			 		$('.casestudytitle').addClass('clicked');
			 	}
			 	$(this).parent().addClass('clicked');
				
				return false;			
			});
		}
		
		bindSubmenu($('a#quotes'),'framepages/quotes.html','xlarge');
		bindSubmenu($('a#about'),'framepages/about-about.html','xlarge');
		bindSubmenu($('a#design'),'framepages/about-design.html','xlarge');
		bindSubmenu($('a#ack'),'framepages/about-ack.html','xlarge');
		bindSubmenu($('a#commercial'),'framepages/commercial-commercial.html','large');
		bindSubmenu($('a#case1'),'framepages/commercial-case1.html','large');
		bindSubmenu($('a#case2'),'framepages/commercial-case2.html','large');
		bindSubmenu($('a#services1'),'framepages/services-1.html','xlarge');
		bindSubmenu($('a#services2'),'framepages/services-2.html','xlarge');
		bindSubmenu($('a#services3'),'framepages/services-3.html','xlarge');
		bindSubmenu($('a#services4'),'framepages/services-4.html','xlarge');
		bindSubmenu($('a#services5'),'framepages/services-5.html','xlarge');
		bindSubmenu($('a#services6'),'framepages/services-6.html','xlarge');
		bindSubmenu($('a#services7'),'framepages/services-7.html','xlarge');
		bindSubmenu($('a#spacehome'),'framepages/space-space.html','large');
		bindSubmenu($('a#spacecase1'),'framepages/space-case1.html','large');
		bindSubmenu($('a#spacecase2'),'framepages/space-case2.html','large');
		bindSubmenu($('a#spacecase3'),'framepages/space-case3.html','large');
		
		
		$('a#real').bind('click',function(){
			divRight.html('<div id="contain" class="xlarge"><iframe src="tiltviewer/index.html" class="dda_frame" frameborder="0" /></div>');
		 	$('.clicked').removeClass('clicked');
		 	$(this).parent().addClass('clicked');
			return false;
		});

		
		var slideshow = $('.slideshow');
		if(slideshow.length == 0)
			slideshow = $('.slideshow_small');
		var tspeed = 3000; //transition speed
		if(debug)
			tspeed = 500000;
		
		
		function initSlideShow(show){
			if(show.length > 0){
				show.cycle({
					fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
					speed: tspeed,
					next: '#nextNav',
					prev: '#prevNav'
				});
			}
			/*
			$('.slideshow, #nextNav, #prevNav').hover(
				function(){
					$('div#prevNav').show();
					$('div#nextNav').show();
				},
				function(){
					$('div#prevNav').hide();
					$('div#nextNav').hide();
			});
			*/
		}
		
		initSlideShow(slideshow);
		
		bindText($('div#text'));
		var allowClose = false;
		var allowOpen = true;
		function bindText(text){
			text.hover(function(){
				if($(this).css('height') == '370px'){
					allowClose = true;
				}else if(allowOpen){
					allowClose = false;
					$(this).css({
						position: 'absolute',
						width: '450px',
						zIndex: '999',
						backgroundColor: 'black',
						bottom: '0'
					});
					$(this).animate({
						height: '370px'
					},800, function(){
						//$(this).css({overflowY:'auto'});
						allowClose = true;
					});
					$(this).addClass('transparent_85');
					$(this).children('div.textnav').addClass('textnavdown');
				}
			},function(){
				if($(this).css('height') == '100px'){
					allowOpen = true;
				}
				else if(allowClose){
					allowOpen = false;
					$(this).animate({
						height: '100px'
					},800, function(){ 
						$(this).removeAttr('style');
						allowOpen = true;
					});
					$(this).removeClass('transparent_85');
					$(this).children('div.textnav').removeClass('textnavdown');
				}
			});
			
		}
		
		function unBindText(text){
			text.unbind('hover');
		}
			
		
		
	
		
	});
