// JavaScript Document

$(document).ready(function() {
	$('#modal').jqm({
		ajax: '@href',
		trigger: 'a.trigger',
		modal: false,
		onLoad: function(){			
			window.scrollTo(0,0);
			var list2 = $(".gallery ul.video a:not(.caseTrigger), .gallery ul li.video a:not(.caseTrigger)");
			list2.each( function(index){
				// set new window features
				var features = 'width=400,height=500,directories=no,location=no,menubar=no,status=no,toolbar=no';

				// launch videos in a popup window
				$(this).click( function(){
					//alert(this.href);
					var vidWindow = window.open(this.href,'',features);
					return false;
				});
			});

			var list = $(".gallery ul:not(.video) a:not(.caseTrigger,.download)");
			var content_tables = $("#content_2 table").hide();

			content_tables.eq(0).show();

			list.removeClass("selected");
			list.eq(0).addClass("selected");
			
			list.each( function(index){
				// hide inactive content
				$(this).click( function(){
					list.removeClass("selected");
					$(this).addClass("selected");
					content_tables.hide();
					content_tables.eq(index).show();
					return false;
				});
			});

			// get rid of PNG bg in ie6
			if ( $.browser.msie )
			{
				$("#page,#footerWrapper").css("background","url(cmsimages/background.gif)");
			}
			$('#nestedModal').jqm({
				ajax: '@href',
				trigger: 'a.caseTrigger',
				modal: false,
				onLoad: function(){
				},
				onHide: function (h) {
					$('#nestedModal').html('Please wait... <img src="cmsimages/busy.gif" alt="loading" />'); //Clear Content HTML on Hide.
					h.o.remove(); // remove overlay
					h.w.hide(); // hide window
					/* if ( $.browser.msie )
					{
						window.location.reload(true);
					}*/
				}
			});
		},
		onHide: function(h) {
			$('#modal').html('Please wait... <img src="cmsimages/busy.gif" alt="loading" />'); //Clear Content HTML on Hide.
			h.o.remove(); // remove overlay
			h.w.hide(); // hide window
			if ( $.browser.msie )
			{
				//window.location.reload(true);
			}
		}
	});
				$('.rileyTrigger').click(function(){
					var features = 'width=400,height=500,directories=no,location=no,menubar=no,status=no,toolbar=no';
					var vidWindow = window.open(this.href,'',features);
					return false;
				});
});

/*
$(document).ready(function(){

				$('#modal').jqm({
					ajax: '@href',
					trigger: 'a.trigger',
					modal: false,
					onLoad: function(){
						var list = $(".gallery a:not(.caseTrigger,.download)");
						list.each(function(index){
							$(this).click(function(){
								$("#content_2").load(this.href);
								return false;
							});
						});

						var list2 = $(".gallery a:not(.caseTrigger,.download)");
						list2.each(function(index){
							$(this).click(function(){
								$("#content_2").load(this.href);
								return false;
							});
						});
					},
					onHide: function(h) {
						$('#modal').html('Please wait... <img src="cmsimages/busy.gif" alt="loading" />'); //Clear Content HTML on Hide.
						h.o.remove(); // remove overlay
						h.w.hide(); // hide window
					}
				});

				$("a.trigger").click(function(){
					var so = new SWFObject("http://client.staging2.accelas.com/watsons/cmsflash/player_flv_maxi.swf", "movie", "430", "322", "8", "#FFFFFF");
					so.addParam("wmode","transparent");
					so.addParam("movie", "player_flv_maxi.swf");
					so.addParam("allowFullScreen", "true");
					so.addVariable("flv", "http://client.staging2.accelas.com/watsons/cmsflash/nyl_2girl_talk.flv");
					so.write("mytest");

					return false;
				});
	
});
*/
