/* widget simple dialog code */
$(function() {
	var viewport = {
		o: function() {
			if (self.innerHeight) {
				this.pageYOffset = self.pageYOffset;
				this.pageXOffset = self.pageXOffset;
				this.innerHeight = self.innerHeight;
				this.innerWidth = self.innerWidth;
			} else if (document.documentElement && document.documentElement.clientHeight) {
				this.pageYOffset = document.documentElement.scrollTop;
				this.pageXOffset = document.documentElement.scrollLeft;
				this.innerHeight = document.documentElement.clientHeight;
				this.innerWidth = document.documentElement.clientWidth;
			} else if (document.body) {
				this.pageYOffset = document.body.scrollTop;
				this.pageXOffset = document.body.scrollLeft;
				this.innerHeight = document.body.clientHeight;
				this.innerWidth = document.body.clientWidth;
			}
			return this;
		},
		init: function(el) {
			$(el).css("left",Math.round(viewport.o().innerWidth/2) + viewport.o().pageXOffset - Math.round($(el).width()/2));
			$(el).css("top",Math.round(viewport.o().innerHeight/2) + viewport.o().pageYOffset - Math.round($(el).height()/2));
		}
	};
	$(".simple_popup_info").each(function(){
		$(this).css("display","none").siblings(".simple_popup").click(function(){
			$(".simple_popup_div").remove();
			var strSimple = "<div class='simple_popup_div'><div class='simple_popup_inner'>";
			strSimple += "<p class='simple_close'><a href='#'>Close</a></p>";
			strSimple += $(this).siblings(".simple_popup_info").html();
			strSimple += "</div></div>";
			$("body").append(strSimple);
			viewport.init(".simple_popup_div");
			$(".simple_close").click(function(){
				$(".simple_popup_div").remove();
				return false;
			});
			return false;
		});
	});
	
	
	$(".simple_popup_info3").each(function(){
		$(this).css("display","none").siblings(".simple_popup3").click(function(){
			$(".simple_popup_div3").remove();
			var strSimple = "<div class='simple_popup_div3'><div class='simple_popup_inner3'>";
			strSimple += "<div> <div style='float:left'> </div>   <div class='simple_close3' style='float:right' ><div style='margin-top:-2px;float:right;padding-right:8px;'> <a href='#'><img src='http://www.catholictv.com/images/buttons/modalclose.png'/></a></div><div style='padding-right:12px;float:right;'><a href='#'>Close</a></div> </div></div><br><br>";
			strSimple += "<div class='live_video_container'><iframe src='http://www.catholictv.com/templates/flashdev/vidtest-akamai.html' width='550px' height='340px' frameborder='0'></iframe></div>"
			strSimple += $(this).siblings(".simple_popup_info3").html();
			strSimple += "</div></div>";
			$("body").append(strSimple);
			viewport.init(".simple_popup_div3");
			$(".simple_close3").click(function(){
			   $(".ui-widget-overlay").remove();
				$(".simple_popup_div3").remove();
				if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
																		  
				$("div#videocontainer").html("<video id='videotag' width='530' height='300' style='z-index:1; position:relative;' controls><source src='http://38.111.20.205:1935/live/smil:CatholicTV.smil/playlist.m3u8'/></video>");	
						
			}	
				return false;
			});
			
			return false;
		});
	});
	
	$(".simple_popup_info_mobile").each(function(){
		$(this).css("display","none").siblings(".simple_popup_mobile").click(function(){
			$(".simple_popup_div_mobile").remove();
			var strSimple = "<div class='simple_popup_div_mobile'><div class='simple_popup_inner_mobile'>";
			strSimple += "<div> <div style='float:left'> </div>   <div class='simple_close_mobile' style='float:right' ><div style='margin-top:-2px;float:right;padding-right:8px;'> <a href='#'><img src='http://www.catholictv.com/images/buttons/modalclose.png'/></a></div><div style='padding-right:12px;float:right;'><a href='#'>Close</a></div> </div></div><br><br>";
			strSimple += "<div class='live_video_container'><iframe src='http://www.catholictv.com/templates/flashdev/vidtest-AKAMAI-mobile.html' width='550px' height='340px' frameborder='0'></iframe></div>"
			strSimple += $(this).siblings(".simple_popup_info_mobile").html();
			strSimple += "</div></div>";
			$("body").append(strSimple);
			viewport.init(".simple_popup_div_mobile");
			$(".simple_close_mobile").click(function(){
			   $(".ui-widget-overlay").remove();
				$(".simple_popup_div_mobile").remove();
				if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {															  
				$("div#videocontainer").html("<video id='videotag' width='530' height='300' style='z-index:1; position:relative;' controls><source src='http://38.111.20.205:1935/live/smil:CatholicTV.smil/playlist.m3u8'/></video>");			
				}
				return false;
			});
			
			return false;
		});
	});
});
/* END widget simple dialog code */
