// JavaScript Document
var trans=1000;
var delay=1000;
jQuery(function($){
		$.supersized({
			//Functionality
			slideshow               :   1,		//Slideshow on/off
			autoplay				:	1,		//Slideshow starts playing automatically
			start_slide             :   1,		//Start slide (0 is random)
			random					: 	1,		//Randomize slide order (Ignores start slide)
			slide_interval          :   6000,	//Length between transitions
			transition              :   1, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
			transition_speed		:	1500,	//Speed of transition
			new_window				:	0,		//Image links open in new window/tab
			pause_hover             :   0,		//Pause slideshow on hover
			keyboard_nav            :   0,		//Keyboard navigation on/off
			performance				:	1,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
			image_protect			:	1,		//Disables image dragging and right click with Javascript
			image_path				:	'images/', //Default image path

			//Size & Position
			min_width		        :   1440,		//Min width allowed (in pixels)
			min_height		        :   900,		//Min height allowed (in pixels)
			vertical_center         :   1,		//Vertically center background
			horizontal_center       :   1,		//Horizontally center background
			fit_portrait         	:   1,		//Portrait images will not exceed browser height
			fit_landscape			:   0,		//Landscape images will not exceed browser width
			
			//Components
			navigation              :   0,		//Slideshow controls on/off
			thumbnail_navigation    :   0,		//Thumbnail navigation
			slide_counter           :   0,		//Display slide numbers
			slide_captions          :   0,		//Slide caption (Pull from "title" in slides array)
			slides 					:  	[		//Slideshow Images
												{image : 'images/overview_bg.jpg'},  
												{image : 'images/blackandwhite.jpg'},  
												{image : 'images/bamboo_bg.jpg'},  
												{image : 'images/bigsmile.jpg'},  
												{image : 'images/parking_bg.jpg'},  
												{image : 'images/foodcourt.jpg'},  
												{image : 'images/orchid.jpg'},  
												{image : 'images/mall.jpg'}  
										]
										
		}); 
	});
$(document).ready(function(){
		//initialize custom scroll bar. display arrows and allow animation
		$('.scroll-pane').jScrollPane({
			showArrows: true,
			animateScroll: true
		});
		
		//initial all section pages include transparent layers, homepage content, bg with dots' height
		$('.transParent').css({opacity:0.75});
		$('#playerCell .transParent').css({opacity:0.85});
		$('#dotBg').css('height',document.documentElement.clientHeight);
		
		//function of click for li elements under "naviGate" class
		$('.naviGate li').click(function(){
			if($(this).attr('class')!='active'){
				var par=$(this).parent().parent().parent();
				par.find('.naviGate li').removeClass('active');
				$(this).addClass('active');
				par.find('.scrollDown').fadeOut();
				if($(this).attr('id')=='subHighlight'||$(this).attr('id')=='subMarket'||$(this).attr('id')=='subGreen'||$(this).attr('id')=='naviInter'){
					par.find('.scrollDown').fadeIn();
				}
				var num=par.find('.naviGate li').index($(this));
				var thisId=$(this).parent().parent().parent().find('.textMask ul');
				$(thisId).animate({top:-thisId.find('li:first').height()*num},'slow');
			}
		});
		
		//main navigation function;
		$('#menu li').click(function(){
			if($(this).attr('class')!='active'&&$(this).attr('id')!='naviReg'){
				$('#menu li').removeClass('active');
				$('.sectionCell .scrollDown').fadeOut();
				$('.naviGate li').removeClass('active');
				$(this).addClass('active');
				$('.sectionCell').clearQueue();
				$('.sectionCell').stop();
				$('.sectionCell').animate({'bottom':-360},600);
				switch($(this).attr('id')){
					case 'naviOverview':
					$('#overViewCell').animate({'bottom':20},1000);
					$('#overViewCell .naviGate li:first').addClass('active');
					$('#overViewCell .textMask ul').css({top:0});
					break;
					case 'naviDesign':
					$('#designCell').animate({'bottom':-10},1000);
					$('#designCell .naviGate li:first').addClass('active');
					$('#designCell .textMask ul').css({top:0});
					break;
					case 'naviNews':
					$('#newsCell').animate({'bottom':-26},1000,function(){$('.sectionCell .scrollDown').fadeIn();});
					break;
					case 'naviTour':
					$('#tourCell').animate({'bottom':-64},1000);
					break;
					case 'naviFloor':
					$('#floorCell').animate({'bottom':-24},1000);
					$('#floorCell .naviGate li:first').addClass('active');
					$('#floorCell .textMask ul').css({top:0});
					break;
					case 'naviContact':
					$('#contactCell').animate({'bottom':-110},1000);
					break;
					case 'naviAbout':
					$('#aboutCell').animate({'bottom':-100},1000);
					break;
				};
			}
			
		});
		
		//remove antline when a link is active;
		$('a').focus(function(){$(this).blur();});
		
		//pretty photo( a new generation of lightbox-like slide show) activate. 
		$("a[rel^='prettyPhoto']").prettyPhoto({overlay_gallery:false,animationSpeed:'slow',theme:'facebook',autoplay_slideshow: false});
		
		$("#videoVR img").click(function(){
			var fileName=($(this).attr('id')=='btnVideo')?'images/video1':'images/video-oct-done';
			var titleName=($(this).attr('id')=='btnVideo')?'Project Overview Video':'Virtual Tour';
			var mCell=$("#playerCell");
			mCell.css('height',document.documentElement.clientHeight);
			$('#playerHolder').css({
									'left':Math.floor((mCell.width()- $('#playerHolder').width())/2),
									'top':Math.floor((mCell.height()- $('#playerHolder').height())/2)
									});
			mCell.fadeIn("slow",function(){
				$('#playerHolder').html('<img id="btnClose" src="images/btn_close.gif" /><object type="application/x-shockwave-flash" data="flv_player.swf?vInfo='+fileName+'" width="752" height="470" id="vcastr3"><param name="movie" value="flv_player.swf?vInfo='+fileName+'" /><param name="wmode" value="transparent" /></object>');
				$('#btnClose').click(function(){$('#playerHolder').html('');mCell.fadeOut("fast")});
			});
		});
		
		var imgPages=$('#photoUl dd').length;
		$('#photoUl').css('width',500*imgPages);
		var speed=1000;
		//for(x=0;x<imgPages;x++){
			//var temp=(x==0)?'<img src="images/dot_green.gif">':'<img src="images/dot_grey.gif">';
			var temp='<span class="cur">Exterior</span> | <span>interior</span>';
			$('#dotContainer').append(temp);
		//}
		$('#photoUl').css('width',500*imgPages);
		
		//add click event to all dots in dotContainer
		/*
		$('#dotContainer span').click(function(){
			if($(this).attr('src')!='images/dot_green.gif'){
				$('#dotContainer img').attr('src','images/dot_grey.gif');
				$(this).attr('src','images/dot_green.gif');
				var cNum=$('#dotContainer img').index($(this));
				var steps=Math.abs(cNum-parseInt($('#photoUl').css('left'))/-500);
				$('#photoUl').animate({left:-500*cNum},speed*steps,'easeInOutQuad');
			}
			
		});
		*/
		$('#dotContainer span').click(function(){
			if($(this).attr('class')!='cur'){
				$('#dotContainer span').removeClass('cur');
				$(this).addClass('cur');
				var cNum=$('#dotContainer span').index($(this));
				var steps=Math.abs(cNum-parseInt($('#photoUl').css('left'))/-500);
				$('#photoUl').animate({left:-500*cNum},speed*steps,'easeInOutQuad');
			}
			
		});
	
	});
	
window.onresize=function(){$('#dotBg').css('height',document.documentElement.clientHeight);}
