function openVideo(link) {
	var formHtml = '<div id="popupVideo" style="width:454px; height:315px; float:left; margin-left:28px;">';
	formHtml	+= '<object width="640" height="385">';
	formHtml	+= '<param name="movie" value="'+link+'?hl=en_US&fs=1&autoplay=1&showinfo=0&rel=0"></param>';
	formHtml	+= '<param name="allowFullScreen" value="true"></param>';
	formHtml	+= '<param name="allowscriptaccess" value="always"></param>';
	formHtml	+= '<embed src="'+link+'?hl=en_US&fs=1&autoplay=1&showinfo=0&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed>';
	formHtml	+= '</object>';
	formHtml	+= '</div>';
	var shadowHeight = jQuery(document).height()+"px";
	
	var shadow = jQuery(document.createElement("div")).attr({"id":"shadow"}).appendTo("body").click(function () {
	}).css({"height":shadowHeight});
	var box = jQuery(document.createElement("div")).attr({"id":"shadowBox"}).appendTo(shadow);
	var close = jQuery(document.createElement("div")).attr({"id":"closeBox"}).appendTo(box).click(function () {
		closeOffer();
	});
	
	jQuery(box).append(formHtml);
	
	jQuery(shadow).fadeIn(600);
	
	window.onresize = positionShadowBox;
	positionShadowBox();

}

function closeOffer() {
	jQuery("#shadow").fadeOut(400).remove();
}

function positionShadowBox() {
/*	var shadowTop = jQuery(window).height() / 2 - jQuery("#shadowBox").outerHeight() / 2;
	jQuery("#shadowBox").css({"margin-top": shadowTop + "px"});*/
	var shadowTop = jQuery(document).scrollTop() + getViewPortHeight()/2 - 203;
	jQuery("#shadowBox").css({"margin-top": shadowTop + "px"});
}

function doNothing() {
	return;
}

function openShare() {
//	alert(document.location.protocol);
//	alert(document.location.host);
//	alert(document.location.pathname);
	var newURL	= document.location.protocol + "//" + document.location.host + document.location.pathname;
//	alert(newURL);
	var formHtml = '<div id="popupVideo" style="width:551px; position:relative; height:314px; float:left;" onSubmit="return this;">';
	formHtml	+= '<form method="POST" action="http://';
	formHtml	+= document.location.host;
	formHtml	+= '/popup/savecomment.php?url=';
//	formHtml	+= document.location.href;
	formHtml	+= newURL;
	formHtml	+= '">';
//	formHtml	+= '<input id="name" name="name" value="Name" />';
	formHtml	+= '<input id="name" name="name" value="Name" onblur="if(this.value==\'\') this.value=\'Name\';" onfocus="if(this.value==\'Name\') this.value=\'\';" />';
	formHtml	+= '<select id="user" name="user"><option>-- Relationship to experience --</option><option>Patient</option><option>Friend</option><option>Family</option><option>Associate</option><option>Other</option></select>';
	formHtml	+= '<textarea id="comment" name="comment" onblur="if(this.value==\'\') this.value=\'Share your Centura story...\';" onfocus="if(this.value==\'Share your Centura story...\') this.value=\'\';">Share your Centura story...</textarea>';
	formHtml	+= '<input type="image" id="submit_button" src="/popup/img/clr.gif" width="179" height="41" style="border:none; background:transparent;" onclick="this.submit();" />';
	formHtml	+= '</form>';
	formHtml	+= '<div style="position:absolute; top:224px; left:238px; width:33px; height:33px;"><a href="http://www.facebook.com/CenturaHealth" target="_blank"><img src="/popup/img/clr.gif" width="33" height="33"></a></div>';
	formHtml	+= '<div style="position:absolute; top:224px; left:271px; width:33px; height:33px;"><a href="http://twitter.com/CenturaHealth" target="_blank"><img src="/popup/img/clr.gif" width="33" height="33"></a></div>';
	formHtml	+= '</div>';
	var shadowHeight = jQuery(document).height()+"px";
	
	var shadow = jQuery(document.createElement("div")).attr({"id":"shadow"}).appendTo("body").click(function () {
	}).css({"height":shadowHeight});
	var box = jQuery(document.createElement("div")).attr({"id":"shadowBox2"}).appendTo(shadow);
	var close = jQuery(document.createElement("div")).attr({"id":"closeBox2"}).appendTo(box).click(function () {
		closeOffer();
	});
	
	jQuery(box).append(formHtml);
	
	jQuery(shadow).fadeIn(600);
	
	window.onresize = positionShadowBox2;
	positionShadowBox2();

}

function closeOffer() {
	jQuery("#shadow").fadeOut(400).remove();
}

function positionShadowBox2() {
//	var shadowBottom = jQuery(document).height() / 2 - 100;
//	var shadowBottom = jQuery(document).height() - 800;
//	var shadowBottom = screen.height/2;
//	alert("height="+jQuery(document).height());
//	alert(jQuery(document).scrollTop());
	
//	alert("top:"+jQuery(document).scrollTop()+", portHeight:"+getViewPortHeight());
	// get y-position of screen  + height of screen/2     - half height of popup
	var shadowTop = jQuery(document).scrollTop() + getViewPortHeight()/2 - 158;
	jQuery("#shadowBox2").css({"margin-top": shadowTop + "px"});
}


function getViewPortHeight() {
 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }

 return viewportheight;
 
 }
 
 
function openSpoke() {
	var formHtml = '<div style="width:1100px; height:1402ox; float:left;">';
	formHtml	+= '<img src="/popup/img/spoke2.jpg" style="padding:10px;">';
	formHtml	+= '</div>';
	var shadowHeight = jQuery(document).height()+"px";
	
	var shadow = jQuery(document.createElement("div")).attr({"id":"shadow"}).appendTo("body").click(function () {
	}).css({"height":shadowHeight});
	var box = jQuery(document.createElement("div")).attr({"id":"shadowBox3"}).appendTo(shadow);
	var close = jQuery(document.createElement("div")).attr({"id":"closeBox3"}).appendTo(box).click(function () {
		closeOffer();
	});
	
	jQuery(box).append(formHtml);
	
	jQuery(shadow).fadeIn(600);
	
	window.onresize = positionShadowBox3;
	positionShadowBox3();

}

function positionShadowBox3() {
	// get y-position of screen  + height of screen/2     - half height of popup
	var shadowTop = jQuery(document).scrollTop() + getViewPortHeight()/2 - 355;
	jQuery("#shadowBox3").css({"margin-top": shadowTop + "px"});
}
/*
function CheckForm1(f) {
	alert("val: "+document.getElementById('comment').value);
	if (document.getElementById('comment').value == "" || document.getElementById('comment').value == "Share your Centura story...") {
		closeOffer();
		return false;
	}
	return true;
};
*/

function thankyou() {
	var formHtml = '<div style="width:551px; height:314px; float:left; position:relative;">';
	formHtml	+= '<div style="position:absolute; top:153px; left:90px; width:351px; text-align:center; color:#fff; font-family:arial; font-size:11px;"><a style="color:#fff; font-family:arial; font-size:11px; text-decoration:underline;" href="http://www.facebook.com/CenturaHealth?sk=app_11007063052" target="_blank">Visit us here</a> to read stories shared across the state.</div>';
	formHtml	+= '<div style="position:absolute; top:224px; left:243px; width:33px; height:33px;"><a href="http://www.facebook.com/CenturaHealth" target="_blank"><img src="/popup/img/clr.gif" width="33" height="33"></a></div>';
	formHtml	+= '<div style="position:absolute; top:224px; left:276px; width:33px; height:33px;"><a href="http://twitter.com/CenturaHealth" target="_blank"><img src="/popup/img/clr.gif" width="33" height="33"></a></div>';
	formHtml	+= '</div>';
	var shadowHeight = jQuery(document).height()+"px";
	
	var shadow = jQuery(document.createElement("div")).attr({"id":"shadow"}).appendTo("body").click(function () {
	}).css({"height":shadowHeight});
	var box = jQuery(document.createElement("div")).attr({"id":"shadowBox4"}).appendTo(shadow);
	var close = jQuery(document.createElement("div")).attr({"id":"closeBox4"}).appendTo(box).click(function () {
		closeOffer();
	});
	
	jQuery(box).append(formHtml);
	
	jQuery(shadow).fadeIn(600);
	
	window.onresize = positionShadowBox3;
	positionShadowBox4();

}

function positionShadowBox4() {
	// get y-position of screen  + height of screen/2     - half height of popup
	var shadowTop = jQuery(document).scrollTop() + getViewPortHeight()/2 - 158;
	jQuery("#shadowBox4").css({"margin-top": shadowTop + "px"});
}

