/* new javascript code - YM 01/29/10 */
$(document.body).ready(function () {
	/*added dynamic timestap - YM 01/28/10 */
	var pageTimestamp =new Date();
	document.getElementById('pageTimestamp').innerHTML = pageTimestamp.toLocaleString();
	
	for(i=0;i<4;i++){
		$("#pageimage").append(photo_data[i]);
		$("#homeimage_"+i).hover(
			function(){photo_pause = true;}, 
			function(){photo_pause = false;}
		);	
	}
	
	rotate_news();
	rotate_photo();	
	$("img.homepage-images").hover(
		function(){photo_pause = true;}, 
		function(){photo_pause = false;}
	);
	$("span.image_headings").hover(
		function(){
			photo_pause = true;
			photo_next = $(this).attr('id').split('_')[1];
			change_photo();
		}, 
		function(){
			photo_pause = false;
		}
	);
});
var photo_current = 0;
var photo_next = 0;
var photo_pause = false;
function rotate_photo(){
	setTimeout(function(){ 
		if(!photo_pause){
			photo_next++;
			if(photo_next > 4){
				photo_next = 0;
			}
			change_photo();
			rotate_photo();
		}else{
			rotate_photo();
		}
	},8000);
}
function change_photo(){
	style_unhover_all();	
	$("#homeimage_"+photo_current).fadeOut(500,function(){
		$("#homeimage_"+photo_next).fadeIn(500,function(){
			if(photo_next != 0){
				style_hover($("#heading_"+photo_next));	
			}			
		});
		photo_current = photo_next;
	});
}
var photo_data = new Array(
		'<img class="homepage-images" src="images/illus-home_biz.jpg" name="homeimage_1" id="homeimage_1" height="300" width="600" style="display:none;"/>',
		'<img class="homepage-images" src="images/illus-home_ent.jpg" name="homeimage_2" id="homeimage_2" height="300" width="600" style="display:none;"/>',
		'<img class="homepage-images" src="images/illus-home_con.jpg" name="homeimage_3" id="homeimage_3" height="300" width="600" style="display:none;"/>',
		'<img class="homepage-images" src="images/illus-home_sci.jpg" name="homeimage_4" id="homeimage_4" height="300" width="600" style="display:none;"/>'
	)
function style_hover(object_hover){
	object_hover.css("background",'#fff');
	object_hover.css("color",'#372f2c');
	object_hover.css("font-weight",'700');
}
function style_unhover_all(){
	$("#heading_1,#heading_2,#heading_3,#heading_4").css("background",'#372f2c');
	$("#heading_1,#heading_2,#heading_3,#heading_4").css("color",'#fff');
	$("#heading_1,#heading_2,#heading_3,#heading_4").css("font-weight",'normal');
}
var news_data = new Array(
	"Freestyle PR and Foundry CoWorking Partner to Help Educate Startups",
	"ReviewSnap, Caleris, and Navigator Financial Partners Select Freestyle as PR AOR",
	"Debbie Arringdale Joins Freestyle team as Account Manager",
	"Long time client Jim Stickley renews agenting contract with Freestyle Media Group",
	"Freestyle Secures Meeting with client eSoles and U.S. Military via Gov't Relations Program",
	"netForensics Receives Glowing Standalone Review in CRN magazine"
)
var news_counter = 0;
function rotate_news(){
	setTimeout(function(){ 
		  $("#news_contents").fadeOut(1000,function(){
			  if(news_counter < (news_data.length-1)){
				  news_counter++;
			  }else{
				  news_counter = 0;
			  }
			  $("#news_contents").html(news_data[news_counter]);
			  $("#news_contents").fadeIn(1000);
			  rotate_news();
		  });
	},5000);
}