// JavaScript Document
var defEase = "easeInOutQuad";
var selectorDur = 30;

function onYouTubePlayerReady(){
	playing = false;
	ytplayer = document.getElementById("myytplayer");
	ytplayer.cueVideoById(ytId,0);  
 	ytplayer.addEventListener("onStateChange", "onytplayerStateChange");

}

function onytplayerStateChange(newState) {
	if(newState == 1){
		playing = true;
		$("#playerToggle").text("Pause");
		
	} else if (newState == 2){
		playing = false;
		$("#playerToggle").text("Play");
	}
}


function playPause(){
	if(playing){
		ytplayer.pauseVideo();
	} else {
		ytplayer.playVideo();
	}
}


$("#ytapiplayer").ready(function(){
	var params = { allowScriptAccess: "always", bgcolor: "#e7e1c9" };
	// this sets the id of the object or embed tag to 'myytplayer'.
	// You then use this id to access the swf and make calls to the player's API
	var atts = { id: "myytplayer" };
	swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer","ytapiplayer", "235", "215", "8", null, null, params, atts);
});

$("#splashdiv").ready(function(){
	var params = { allowScriptAccess: "always", bgcolor: "#e7e1c9", wmode:"opaque" };
	// this sets the id of the object or embed tag to 'myytplayer'.
	// You then use this id to access the swf and make calls to the player's API
	var atts = { id: "splashswf" };
	//swfobject.embedSWF("flash/splash2.swf","splashdiv", "585", "235", "8", null, null, params, atts);
	swfobject.embedSWF("flash/sod2.swf","splashdiv", "585", "235", "8", null, null, params, atts);
});

function prep(){
	//alert("contact");
	$("#companyNav li.navItem").mouseover(function(){
			//alert(this);	
			var pos = $(this).position();
			$('#companyNav li.navItem a').css("color","#816629");
			href = $(this).children('a');
			href.css("color","#FFF");
			$("#companyNav .selector").animate({opacity:0.3,top:(pos.top+12)},selectorDur,defEase);
	});
	
	$("#homesNav li.navItem").mouseover(function(){
			//alert(this);	
			var pos = $(this).position();
			$('#homesNav li.navItem a').css("color","#816629");
			href = $(this).children('a');
			href.css("color","#FFF");
			$("#homesNav .selector").animate({opacity:0.3,top:(pos.top+12)},selectorDur,defEase);
	});
	$(".navCat div.backing").animate({opacity:0.1},0);
	
}

$('document').ready(function(){
	prep();
});

$('div#blog').ready(function(){
	$('div#blog>p.content').load("blog/latestBlog.php");
});

$('div#twitter').ready(function(){
	$('div#twitter>p.content').load("twitter/twitter.php");
});

$('div#flickr').ready(function(){
	$('div#flickr>div#flickrWrap').load("Flickr/flickr.php");
});

$('div#facebook').ready(function(){
	//$('div#facebook>p.content').load("facebook/latest.php");
});

$('#featured').ready(function(){
	$('#featured').css("cursor","pointer");				
	var href = $('#featured p.widgetHead>a').attr("href");
	$('#featured').mousedown(function(){
		window.location.assign(href);
	});
});

$('#finder').ready(function(){
	$('#finder').css("cursor","pointer");				
	var href = $('#finder p.widgetHead>a').attr("href");
	$('#finder').mousedown(function(){
		window.location.assign(href);
	});
});

$('#comMap').ready(function(){
	$('#comMap').css("cursor","pointer");				
	var href = $('#comMap p.widgetHead>a').attr("href");
	$('#comMap').mousedown(function(){
		window.location.assign(href);
	});
});

$('#homeSearch').ready(function(){
	$('#homeSearch').css("cursor","pointer");				
	var href = $('#homeSearch p.widgetHead>a').attr("href");
	$('#homeSearch').mousedown(function(){
		window.location.assign(href);
	});
});

$('#puget').ready(function(){
	$('#puget').css("cursor","pointer");				
	var href = "puget.html";
	$('#puget').mousedown(function(){
		window.location.assign(href);
	});
});

$('div#companyNav div.selector').ready(function(){
	$('div#companyNav div.selector').animate({opacity : 0},0,defEase);
});

$('div#homesNav div.selector').ready(function(){
	$('div#homesNav div.selector').animate({opacity : 0},0,defEase);
});

function createDialog(){
	$("#dialog").dialog({
			bgiframe: true,
			modal: true});
}

$('#findHome').ready(function(){
	$('#findHome').css("cursor","pointer");	
	$('#findHome').mousedown(function(){
		createDialog();
	});
});

$('.socialImg').ready(function(){
	$('.socialImg').each(function(){
		$(this).css("cursor","pointer");
		var aTag = $(this).children('p.smWidgetHead').children('a');
		var href = aTag.attr("href");
		$(this).mousedown(function(){
			window.location.assign(href);
		});
	});
});

$('div#logo').ready(function(){
	$(this).css("cursor","pointer");
	/*var aTag = $(this).children('p.smWidgetHead').children('a');
	aTag.css("font-size","20px");
	var href = aTag.attr("href");
	$(this).mousedown(function(){
		alert(href);
		window.location.assign(href);
	});*/
});


