

var vids;

//procedural that embeds the swf into the div.
function initHomePage(){
	
	// resizes required template containers for liquid content area.
	minDivHeight =600;
    
    divCRef = $("div.marketing-content"); 
	divMRef = $("div.page-marketing");
	resizeDivs();
	
	$(function(){
	    $(window).resize(function(){
	       	resizeDivs();
		});
	});
	
	
	
	var requiredMajorVersion = 9;
	    // Minor version of Flash required
	    var requiredMinorVersion = 0;
	    // Minor version of Flash required
	    var requiredRevision = 0;
	    
	  
		//------swfobject embed code---------
		var deeplink = true;
		var flashvars = false;

		params = {
			flashvars: "",
			wmode:"transparent",
		  	id:"swf_div",
		  	allowscriptaccess:"always",
			allowfullscreen:"true",
			menu:"false"
		};
		var attributes = {};
		attributes = {
			id:"swf_div",
			name:"swf_div"
		}
		/*
		 * 					swf filename
		 *					div_id to write to
		 *					width
		 *					height
		 *					fp version
		 *					expressinstall location
		 *					flashvars (false)
		 *					embed parameters (include flashvars in these)
		 *					document attributes (name & id)
		*/
		var d =new Date();
		var fr = d.getDate();
		
		//for testing:
		//var content_path = "xml/home_content_rotator.xml&d="+fr;
		//var swf_path = "home_main2011.swf?datapath="+content_path+"&slideTime=5000&d="+fr
		
		//for live:
		var content_path = "/marketing/home/xml/home_content_rotator.xml&d="+fr;
		var swf_path = "/marketing/home/home_main2011.swf?datapath="+content_path+"&slideTime=5000&d="+fr;
		
		swfobject.embedSWF(	swf_path,
							"swf_div",
							"100%", 
							"100%", 
							"9.0.124", 
							"swf/expressInstall.swf",
							flashvars,
							params,
							attributes);
}

/*
 * Opens share pop up for facebook
 */
function fbSharePopUp() {
	 FB.ui(
{
method: 'feed',
name: 'Need Copy',
link: 'http://www.johnvarvatos.com/',
picture: '',
caption: '',
description: "Need Copy",
 message: ""
},
function(response) {
if (response && response.post_id) {
 <!-- alert('Post was published.');-->
} else {
  <!--alert('Post was not published.');-->
}
}
);
}

//resizes required template containers for liquid content area.
function resizeDivs(){
	var nh = (($(window).height()-171)<minDivHeight) ? minDivHeight : $(window).height()-171;
	divMRef.css('height',nh);

}


function closeVideoModal(dialog){
	var slideshowSwf = $('#swf_div')[0];
	// TODO: close the modal...
	try{
		dialog.data.fadeOut('slow', function () {
			dialog.container.hide('fast', function () {
				dialog.overlay.slideUp('fast', function () {
					$.modal.close();
				});
			});
		});
	} catch(e){};
	
	try{
		// resume the slideshow...
		slideshowSwf.resumeSlideShow();
	} catch(e){
		
	}
}
function animateModalIn (dialog){
	dialog.overlay.fadeIn('fast', function () {
		dialog.data.hide();
		dialog.container.fadeIn('fast', function () {
			dialog.data.slideDown('fast');
		});
	});
}
function openVideoModal(s){
	var slideshowSwf = $('#swf_div')[0];
	// TODO: open the video you tube video modal...
	var vid_markup = '<div id="video_display"><div id="vid_frame"><iframe height="315" width="560" src="'+s+'" frameborder="0" allowfullscreen></iframe></div></div>';
	$.modal(vid_markup,{onClose:closeVideoModal,onOpen:animateModalIn});
	try{
		// pause the slideshow...
		slideshowSwf.pauseSlideShow();
	} catch (e){
		
	}
}
