var ichurch_loaded = false
//Cufon.replace('.latest-tweets p.left, .slider2 h2, .slider2editable h2');

var siteURL = 'http://rwoc.org';

//Carousel 2 Callback
function mycarousel2_initCallback(carousel){
	$('.slider2 #next').bind('click', function() {
        carousel.next();
        return false;
    });
	$('.slider2 #prev').bind('click', function() {
        carousel.prev();
        return false;
    });
}

/**jQuery Cookie plugin
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses
 */
function jCookie (key, value, options) {
    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);
		if (value === null) {
            options.expires = -1;
        }
		if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
		return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }
	// key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

jQuery.cookie = $.cookie = jCookie;

jQuery.alwaysFalse = function() {
	return false;
};

jQuery(function($){ 
	$(".cms-nav .adminWelcome b:contains('glance')").each(function(){
		$('.streamingAdmin,.adminWelcome .admin').remove();
		$('.GridViewRow td div:contains("sitefuze"),.GridViewAlternatingRow td div:contains("sitefuze")').parent().parent().remove();
	});
	if($('.logout').length){
		$('#header-columns div[id$=_divSettings]').prev().remove().end().prev().remove().end().remove();
		$('.thirdColItem h3 span').show();
	};
	
	$('.boxHeader:contains("Most Recent Entries")').each(function(){
		$(this).next().find('span span a').unwrap().unwrap().unwrap().wrapAll('<ul class="custom-bullet" />').wrap('<li />');
	});
	
	//PNG Fix for IE6
	if($.browser.msie && $.browser.version.substr(0,1) == 6){
		DD_belatedPNG.fix('#logo a, .trigger .btn, .custom-bullet li, .custom-bullet li a, .book-cover img, .footer-btn, .dd-t, .dd-c, .dd-b, .watch-live img, .watch-archives img');
	}
	
	// Subnavigations
	if( $('.page-location div.breadcrumb').length > 0 ) {
		$('.page-location div.breadcrumb').html( $('.page-location div.breadcrumb').html().replace(/&gt;/gi, '<span>/</span>') ) ;
	}
	
	var sidebar = $('.inner-template #main #sidebar');
	
	if( sidebar.length > 0 ) {
		if( sidebar.find('.boxLinksWithin').length > 0 && sidebar.find('.boxQuickLinks').length > 0) {
			sidebar.find('.boxQuickLinks').hide();
		}
		var ex_bread = $('.page-location div.breadcrumb').text().split('/');
		var last = ex_bread[ex_bread.length-1];
		var before_last = ex_bread[ex_bread.length-2];
		var title = last;
		if( sidebar.find('.boxQuickLinks:visible').length > 0 ){
			title = before_last;
		}
		var ex_title = title.split('-');
		title = ex_title[0];
		$('#page-title').html( title );
		
	}
	
	$('.slider1-content ul').jshowoff();
	$('.header-dd .header-col:last').addClass('last');
	
	$('#navigation ul:eq(0) > li > a').each(function(){
		var ex_html = $(this).html().split('-');
		var new_html = '<span>' + $(this).html() + '</span>';
		if(ex_html.length > 1) {
			new_html = '<span>' + ex_html[0] + '</span><em>'+ex_html[1]+'</em>';
		}
		$(this).html( new_html );
	});
	
	$('#navigation li .dd .dd').each(function(){
		var html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="dd-tl">&nbsp;</td><td class="dd-tc">&nbsp;</td><td class="dd-tr">&nbsp;</td></tr><tr><td class="dd-l">&nbsp;</td><td class="dd-c">';
		html += $(this).html();
		html += '</td><td class="dd-r">&nbsp;</td></tr><tr><td class="dd-bl">&nbsp;</td><td class="dd-bc">&nbsp;</td><td class="dd-br">&nbsp;</td></tr></table>';
		$(this).html(html);
	});
	
	$('#navigation li .dd').each(function(){
		var html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="dd-tl">&nbsp;</td><td class="dd-tc">&nbsp;</td><td class="dd-tr">&nbsp;</td></tr><tr><td class="dd-l">&nbsp;</td><td class="dd-c">';
		html += $(this).html();
		html += '</td><td class="dd-r">&nbsp;</td></tr><tr><td class="dd-bl">&nbsp;</td><td class="dd-bc">&nbsp;</td><td class="dd-br">&nbsp;</td></tr></table>';
		$(this).html(html);
	});
	
	$('#navigation a[href=/imembers.aspx]').replaceWith('<a href="/imembers.aspx"><span class="lowercase">i</span>Members</a>');
	$('#navigation a[href=/imember.aspx]').replaceWith('<a href="/imember.aspx"><span class="lowercase">i</span>Members</a>');
	//Cufon.replace('#navigation a', {fontFamily:'Futura',hover:true});
	
	$('#dd-nav > ul > li > .dd').each(function(){
		$(this).show();
		var w = $(this).find('table:eq(0)').width() + 20;
		if( w < 170 ) w = 170;
		$(this).find('table:eq(0)').css('width', w);
		var l = w;
		$(this).find('.dd').each(function(){
			$(this).show();
			var w = $(this).find('table:eq(0)').width() + 20;
			if( w < 170 ) w = 170;
			$(this).find('table:eq(0)').css('width', w);
			$(this).hide();
			$(this).css('left', l-40);
		});
		$(this).hide();
	});
	
	var is_opened = false; 
	// What to do after the header ajax request is complete
	// Checked in on_window_load()
	var command_queue = ''; // 'live' | 'archive'
	// Whether to pay the first video on 'more video' button click
	var archives_autoplay_first = false
	var video_match = window.location.hash.match(/^#watch-archives\/(.*)$/);
	
	new nicEditor().panelInstance('myStudyNotes');
	$('#myStudyNotes').prev().addClass('editMyStudyNotes').prev().addClass('notesEditingBar');
	$('.editMyStudyNotes, .notesEditingBar').wrapAll('<div class="notesEditContainer" />');
	
	//Header Drop Down
	$('.trigger-button').live("click", function(){ 
		if(!is_opened) {
			//var h = !is_logged() ? 360 : 415;
			$('.thermalStream, #header-columns').animate({top: 0});
			$('.header-dd .holder').show().stop().animate({ 'height': '360px'}, function() {
				if (ichurch_loaded && $('.thermalStream').css('display') == 'block') {
					//$('.thermalTabs').show();
					if ( ichurch_loaded ) {
						$('.closeStreaming').show();
					};
				}
			});
			is_opened = true;
			if (!ichurch_loaded) {
				$('.header-dd .holder #streaming').css({
					'background': 'url(/resources/1/rwoc/ajaxload.gif) no-repeat center center'
				});
				$('.header-dd .holder #streaming').load('/?header-ajax=true .header-dd .holder #streaming > *', function() {
					$('.header-dd .holder #streaming').css({'background': 'url("/resources/1/rwoc/css/images/stream-bg.jpg") no-repeat center 0'});
					$('a.fancy').fancybox({
						width: '50%',
						height: '70%',
						type : 'iframe'
					});
					if ( $('.thermalStream:visible').length ) {
						//$('.thermalTabs').show();
						$('.closeStreaming').show();
					};
					fix_mobiles();

					window_already_loaded = false;
					do_not_trigger_again = true;
					on_window_load();
					ichurch_loaded = true;
				});
			} 
		}else {
			$('.thermalStream, #header-columns').animate({top: -395});
			$('.header-dd .holder').stop().animate({ 'height': '0'});
			//$('.thermalTabs, .closeStreaming').hide();
			$('.closeStreaming').hide();
			is_opened = false;
		}
		
		if (typeof do_not_trigger_again == 'undefined') {
			if ( window.location.hash.match(/watch-live/) ) {
				$('.watch-live').trigger('click');
			};
			if ( window.location.hash.match(/watch-archives/) ) {
				$('.watch-archives').trigger('click');
			};
		}
		$('.trigger-button').toggleClass('trigger-button-active');
		return false;
	 });
	 
	if ( window.location.hash.match(/watch-live/) ) {
		$('.watch-live').trigger('click');
	};
	if ( window.location.hash.match(/watch-archives/) ) {
		$('.watch-archives').trigger('click');
	};

	$('.trigger-button2').live("click", function(){ 
		if($('.trigger-text').css('display') != 'none'){
			if(!is_opened) {
				$('.thermalStream, #header-columns').animate({top: 0});
				$('.header-dd .holder').show().stop().animate({ 'height': '360px'}, function() {
					if (ichurch_loaded && $('.thermalStream').css('display') == 'block') {
						//$('.thermalTabs').show();
						if ( ichurch_loaded ) {
							$('.closeStreaming').show();
						};
					}
				});
				is_opened = true;
				if (!ichurch_loaded) {
					$('.header-dd .holder #streaming').css({
						'background': 'url(/resources/1/rwoc/ajaxload.gif) no-repeat center center'
					});
					$('.header-dd .holder #streaming').load('/?header-ajax=true .header-dd .holder #streaming > *', function() {
						$('.header-dd .holder #streaming').css({'background': 'url("/resources/1/rwoc/css/images/stream-bg.jpg") no-repeat center 0', 'border-width': '0 1px'});
						$('a.fancy').fancybox({
							width: '50%',
							height: '70%',
							type : 'iframe'
						});
						//$('.thermalTabs').show();
						if ( $('.thermalStream:visible').length ) {
							$('.closeStreaming').show();
						};
						fix_mobiles();
					
						do_not_trigger_again = true;
						window_already_loaded = false;
						on_window_load();
						ichurch_loaded = true;
					});
				}
			}else {
				$('.thermalStream, #header-columns').animate({top: -395});
				$('.header-dd .holder').stop().animate({ 'height': '0'});
				//$('.thermalTabs, .closeStreaming').hide();
				$('.closeStreaming').hide();
				is_opened = false;
			}
			if (typeof do_not_trigger_again == 'undefined') {
				if ( window.location.hash.match(/watch-live/) ) {
					$('.watch-live').trigger('click');
				};
				if ( window.location.hash.match(/watch-archives/) ) {
					$('.watch-archives').trigger('click');
				};
			}
			$('.trigger-button').toggleClass('trigger-button-active');
		};
		return false;
	 });
	 
	//Carousel 2
	$('.slider2-content ul').jcarousel({
		wrap: "both",
		scroll: 1,
		visible: 3,
		initCallback: mycarousel2_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
	});
	
	//Blink Fields
	 $('.blink').
	    focus(function() {
	        if(this.title==this.value) {
	            this.value = '';
	        }
	    }).
	    blur(function(){
	        if(this.value=='') {
	            this.value = this.title;
	        }
	    }).blur();
	
	//Form Button Hover
    $('.submit-btn').hover(function(){ 
    	$(this).toggleClass('submit-btn-hover');
     });
     
     _animate_horizontal();
     
     $('.closeStreaming').live("click", function(){
     	var streaming = $('.thermalStream');
     	var box = $('#header-columns');
		var closeBTN = $('.closeStreaming');
		//$('.thermalTabs').fadeOut();
		$('#player-controls').parent().css({'width' : 'auto'});
		window.location.hash = '';
     	if(streaming.css('display') == 'block') {
     		closeBTN.fadeOut();
			streaming.fadeOut(function(){
     			box.fadeIn();
				$('.trigger-holder').addClass('trigger-button2');
     			$('.trigger-text').show();
     			if ( typeof stream_fp_instance != 'undefined' && stream_fp_instance.isPlaying() ) {
     				stream_fp_instance.pause();
     			};
     			$('#player-controls').css('position', 'absolute').css('top', '-1000px');
				$('#player-controls-archive').css({'position': 'absolute'}).hide();
				$('#player2').html('');
				$('.archive-clips a.playing').removeClass('playing');
     		});	
     	}
     	return false;
	});
	
	
	$('#navigation a.iframe-link, #logo a.iframe-link').live('click', function(){
		var href = $(this).attr('href');
		if ( href == "/watch-live.aspx" || href == "/on-demand.aspx" ) {
			return false;
		};
		if ( href.indexOf(window.location.hostname.toString()) == -1 ) {
			href = 'http://' + window.location.hostname.toString() + href;
		}
		$('#iframe').attr('src', href + '?rd=' + Math.ceil(Math.random*100));
		return false;
	});
	$('#navigation a[href="/online-giving.aspx"]').live('click', function(){
		_gaq.push(['_trackEvent', 'Online Giving', 'Give Online', 'Give - Main Navigation']);
		if(!$(this).hasClass('iframe-link')){
			window.setTimeout(function() {
				window.location = 'http://www.rwoc.org/online-giving.aspx';
			}, 1000);
		};
		return false;
	});
	$('#footer a[href="/online-giving.aspx"]').live('click', function(){
		_gaq.push(['_trackEvent', 'Online Giving', 'Give Online', 'Give - Footer']);
		window.setTimeout(function() {
			window.location = 'http://www.rwoc.org/online-giving.aspx';
		}, 1000);
		return false;
	});
	
	$('#faqstab a.iframe-link').live('click', function(){
		var href = $(this).attr('href');
		if ( href.indexOf(window.location.hostname.toString()) == -1 ) {
			href = 'http://' + window.location.hostname.toString() + href;
		}
		$('#iframe').attr('src', href + '?rd=' + Math.ceil(Math.random*100));
		
		return false;
	});
	$('a.feedbackTab.iframe-link,#header-columns .header-col a.iframe-link, #streaming-nav a.iframe-link, a.ichurchmembersTab.iframe-link').live('click', function(){
		var href = $(this).attr('href');
		if ( href.indexOf(window.location.hostname.toString()) == -1 ) {
			href = 'http://' + window.location.hostname.toString() + href;
		}
		$('#iframe').attr('src', href + '?rd=' + Math.ceil(Math.random*100));
		$('body,html').animate({ scrollTop: 395 }, 200);
		if($(this).attr('href') == 'http://www.rwoc.org/online-giving.aspx'){
			_gaq.push(['_trackEvent', 'Online Giving', 'Give Online', 'Give - Header']);
			window.setTimeout(function() {
				window.location = 'http://www.rwoc.org/online-giving.aspx';
			}, 1000);
		};
		return false;
	});
	$('a.giveTab.iframe-link').live('click', function(){
		var href = $(this).attr('href');
		if ( href.indexOf(window.location.hostname.toString()) == -1 ) {
			href = 'http://' + window.location.hostname.toString() + href;
		}
		$('#iframe').attr('src', href + '?rd=' + Math.ceil(Math.random*100));
		$('body,html').animate({ scrollTop: 395 }, 200);
		_gaq.push(['_trackEvent', 'Online Giving', 'Give Online', 'Give - Tab']);
		return false;
	});
	$('a.ichurchmembersTab').hover(function(){
		$('.ichurchMemberInfo').show();
	}, function(){
		$('.ichurchMemberInfo').hide();
	});
	
	_init_iframe_functions();
	
	function blinkify( $textbox ) {
		//Blink Fields
		$textbox.focus(function() {
			if(this.title==this.value) {
				this.value = '';
			};
		}).blur(function(){
			if(this.value=='') {
				this.value = this.title;
			};
		}).blur();
	}
	
	//Blink Fields
	blinkify($('.blink'));
	
	var window_already_loaded = false;
	$(window).load(on_window_load);
	function on_window_load() {
		$(window).unbind('load', on_window_load);
		// Notes Tab - set message text to the cookie contents
		var myStudyNotesData = jCookie('myStudyNotesData');
		if ( myStudyNotesData && myStudyNotesData != 'null' ) {
			$('.nicEdit-main').html(myStudyNotesData);
		} else {
			$('.nicEdit-main').html('<br />');
		};
		var flow_settings = {
			key:'#@92eb9b1ce7cb08a7a0e',
			debug: false,
			clip: {
				autoPlay: true,
				autoBuffering: true,
				wmode: 'transparent',
				provider: 'rtmp'
			},
			onPause: function(){
				$('.clips a.playing').each(function(){
					$(this).removeClass('playing').addClass('paused');
				});
			},
			onResume: function(){
				$('.clips a.paused').each(function(){
					$(this).removeClass('paused').addClass('playing');
				});
			},
			onVolume: function(volume) {
				$('#player-controls-archive  .volume .volume-progress').css({'width' : volume + '%'});
			},
			plugins: {
				rtmp: {
					url: siteURL + '/resources/1/rwoc/js/flowplayer/flowplayer.rtmp-3.2.3.swf',
					netConnectionUrl: "rtmp://cp23245.edgefcs.net/ondemand"
				},
				viral: {
					url: siteURL + '/resources/1/rwoc/js/flowplayer/flowplayer.viralvideos-3.2.3.swf',
					share: {
						description: 'Redemption World Outreach Center',
						shareUrl: siteURL + '/#watch-live'
					},
					email: {
						script: siteURL + '/resources/1/rwoc/mailer.php?swf',
						pageUrl: siteURL + '/#watch-live'
					}
				},
				controls: {
					url: siteURL + '/resources/1/rwoc/js/flowplayer/flowplayer.controls-3.2.3.swf',
					left: 0,
					bottom: 0,
					opacity: 0.8,
					background: '#000',
					backgroundGradient: 'low',
					play: true,
					volume: true,
					mute: true,
					time: true,
					stop: false,
					playlist: false,
					fastBackward: false,
					fastForward: false,
					slowBackward: false,
					slowForward: false,
					fullscreen: true,
					scrubber: true,
					timeColor: '#ffffff',
					durationColor: '#999999',
					progressColor: '#666666',
					progressGradient: 'none',
					bufferColor: '#999999',
					bufferGradient: 'none',
					sliderColor: '#000000',
					sliderGradient: 'none',
					buttonColor: '#666666',
					buttonOverColor: '#cccccc',
					volumeSliderColor: '#000000',
					volumeColor: '#666666',
					volumeSliderGradient: 'none',
					timeBgColor: '#2b2a2a',
					timeBorderColor: '#ffffff',
					sliderBorderWidth: 0,
					sliderBorderColor: '#ffffff',
					timeBorderColor: '#ffffff',
					timeBorderWidth: 0,
					volumeBorderWidth: 0,
					volumeBorderColor: '#ffffff',
					scrubberHeightRatio: 0.4,
					scrubberBarHeightRatio: 1,
					volumeSliderHeightRatio: 0.4,
					volumeBarHeightRatio: 1,
					timeBgHeightRatio: 0.7,
					timeSeparator: '/',
					timeFontSize: 9,
					tooltips: {
						buttons: true,
						fullscreen: 'Enter fullscreen mode'
					},
					autoHide: {
						enabled: true,
						fullscreenOnly: false,
						hideDelay: 4000,
						hideDuration: 800,
						hideStyle: 'fade',
						mouseOutDelay: 500
					}
				}
			}
		}
		
		if ( window_already_loaded == false ) {
			$.ajax({
				url: '/resources/global/thermal/video-archive/videolist.php',
				success: function(data) {
					$('.archive-clips').html($(data));
					//$('.archive-clips').height($('.archive-clips').find('tr').length * 65);
					fix_archives();
					//flow_settings.clip.url = $('.archive-clips a:first').attr('href');
					if ( is_mobile() || is_mobile2() ) {
						$('.archive-list').addClass('mobile')
					} else {
						$('.archive-list').jScrollPane({
								showArrows: false,
								horizontalGutter: 10
						});
					}
					$('#player-controls-archive .pause').removeClass('pause').addClass('play');
					
					//Blink Fields
					blinkify($('.archive-clips .blink'));
					(function() {
						// Quicksearch
						var search_timeout = 0,
							search_box = $('#quicksearch-box .text'),
							search_btn = $('#quicksearch-box .button'),
							clips = [],
							search_fns = function() {
								var terms = $.trim(search_box.val().toLowerCase()).split(' ');
								$('.archive-clips').parent().css('top', 0);
								
								if (terms.length > 0 && !(terms.length == 1 && (terms[0] == 'search' || terms[0] == '' )) ) {
									$.each(clips, function(index1, clip) {
										var found = true;
										
										$.each(terms, function(index2, term) {
											if ( clip.text.toLowerCase().indexOf(term) < 0 ) {
												found = false;
											}
										});
								
										if ( found ) {
											clip.node.show();
										} else {
											clip.node.hide();
										}
									});
									
									search_btn.addClass('close-btn');
								} else {
									
									search_btn.removeClass('close-btn');
									$('.archive-clips a').show();
								}
							};
						
						$('.archive-clips a').each(function() {
							var text = $(this).text();
							text = text.replace(/(http:\/\/[a-zA-Z0-9.\-/#_]+)/, '');
							clips.push({text: text, node: $(this)});
						});
							
						search_box.keydown(function() {
							if ( search_timeout ) clearTimeout(search_timeout);
							search_timeout = setTimeout(search_fns, 100);
						});
						
						search_box.change(function() {
							search_fns();
						});
						
						search_btn.click(function() {
							if ( search_timeout ) clearTimeout(search_timeout);
							search_box.val('SEARCH');
							search_fns();
							return false;
						});
					})();
					
					var playedGiveVideo = false;
					if( !is_mobile() && !is_mobile2() && FlashDetect.installed ){
						$('.archive-clips a').removeAttr('onclick');
						$('.archive-clips a').live('click',function(e) {
							e.stopImmediatePropagation();
							e.preventDefault();
							if($(this).hasClass('playing')){
								flowplayer().pause();
								return false;
							} else if($(this).hasClass('paused')){
								flowplayer().resume();
								return false;
							} else {
								$('.archive-clips a').removeClass('playing').removeClass('paused');
								$('#player-controls-archive .pause').removeClass('pause').addClass('play');
								// IE appends the protocol + host to the href attribute
								var url = $(this).attr('href').replace(window.location.protocol.toString() + '//' + window.location.hostname.toString() + '/', '');
								if($.cookie('viewedArchiveGiveVideo') == 'true' || playedGiveVideo){
									//flow_settings.clip.url = url;
									flow_settings.playlist = [{
											url: url,
											autoPlay: true,
											autoBuffering: true,
											wmode: 'transparent',
											provider: 'rtmp'
									}];
								} else {
									var date = new Date();
									date.setTime(date.getTime() + (40 * 60 * 1000)); //40 minutes
									$.cookie("viewedArchiveGiveVideo", "true", { expires: date, path: "/" });
									flow_settings.playlist = [{
											//url: 'mp4:23245/mm/flvmedia/1145/r/6/1/r61c332f_h264_252K.mp4',
											url: 'mp4:23245/mm/flvmedia/1145/b/2/2/b220qx71_k4huk90g_h264_1328K.f4v',
											loop: false,
											onBegin: function() {
												window.arch_fp_instance.getPlugin("controls").hide();
											},
											onFinish: function() {
												window.arch_fp_instance.getPlugin("controls").show();
											},
											onBeforePause: $.alwaysFalse,
											onBeforeSeek: $.alwaysFalse,
											onBeforeStop: $.alwaysFalse
										},{
											url: url,
											autoPlay: true,
											autoBuffering: true,
											wmode: 'transparent',
											provider: 'rtmp'
									}];
									playedGiveVideo = true;
								};
								
								flow_settings.plugins.viral.share.description = $(this).find('.description-full').text().replace(/['"]/, '\$1');
								flow_settings.plugins.viral.share.shareUrl = $(this).find('.shareurl').text();
								var clipName = $(this).find('span.onclick').text();
								flow_settings.onStart = function() {
									_gaq.push(['_trackEvent', 'On Demand', 'Play On Demand', clipName]);
								};
								window.location.hash = '#watch-archives/' + url;
								window.arch_fp_instance = $f("player2", {src: siteURL + "/resources/1/rwoc/js/flowplayer/flowplayer.commercial-3.2.5.swf", wmode: 'opaque'}, flow_settings).controls("player-controls-archive");
								$(this).addClass('playing');
								$('#player-controls-archive .volume').remove();
								$('#player-controls-archive').append($('<div class="volume"><div class="volume-background"> </div><div class="volume-progress"> </div></div>'));
								var volume_change_enabled = false;
								$('#player-controls-archive .volume').mousedown(function() { volume_change_enabled = true; });
								$('#player-controls-archive .volume').mouseleave(function() { volume_change_enabled = false; });
								$('#player-controls-archive .volume').mouseup(function() { volume_change_enabled = false; });
								$('#player-controls-archive .volume').mousemove(function(event) {
									if ( !volume_change_enabled ) return;
									var percent = parseInt( ((event.pageX - $(this).offset().left)/50)*100 );
									window.arch_fp_instance.setVolume(percent);
									$(this).find('.volume-progress').css({'width' : percent + '%'});
								});
								$('#player-controls-archive .volume').live("click", function(event) {
									var percent = parseInt( ((event.pageX - $(this).offset().left)/50)*100 );
									window.arch_fp_instance.setVolume(percent);
									$(this).find('.volume-progress').css({'width' : percent + '%'});
								});
							};
							return false;
						});
						if ( archives_autoplay_first && !(video_match && $('.archive-clips a[href*=' + video_match[1] +  ']'))) {
							if( !is_mobile() && !is_mobile2() && FlashDetect.installed ){
								//$('.archive-clips a:first').click();
							};
						};
					};
					if ( video_match && $('.archive-clips a[href*=' + video_match[1] +  ']') ) {
						$('.archive-clips a[href*=' + video_match[1] +  ']').stop().click();
						$('#streaming-nav a[rel=archives]').trigger('click');
					}
				},
				error: function() {	
					$('.archive-clips').html('Error');
				}
			});
		};
		window_already_loaded = true;
		
		if ( command_queue == 'live' ) {
			$('.watch-live').trigger('click');
		};
		if ( command_queue == 'archives' ) {
			$('.watch-archives').trigger('click');
		};
		// Clear the command
		command_queue = '';
		
		if ( typeof do_not_trigger_again == 'undefined' && !$('.trigger-button').is('.trigger-button-active') ) {
			if ( window.location.hash.match(/watch-live/) ) {
				$('.trigger-button').trigger('click');
			};
			if ( window.location.hash.match(/watch-archives/) ) {
				$('.trigger-button').trigger('click');
			};
		};
	}
	
	// Twiiter
	$(".twitter-holder").tweet({
		username: "rwoc",
		count: 5,
		loading_text: "loading tweets...",
		callback : function(){
			$('.twitter-holder').animate_vertical();
		}
	});	
	
	$('#streaming-nav a').live('click', function(){
		if( $(this).attr('rel') != '' ) {
			var id = $(this).attr('rel');
			var nav_x = id == 'chats' ? '582' : 0;
			if ( id == 'archives' ) {
				$('.trigger-text').hide();
				$('.trigger-holder').removeClass('trigger-button2');
				$('#player-controls').hide();
				$('#player-controls-archive').show().css('position','relative').parent().css({'width':'auto'});
				// set the url to the currently active video
				if ( $('.archive-clips a.playing').length > 0 ) {
					var url = $('.archive-clips a.playing:first').attr('href').replace(window.location.protocol.toString() + '//' + window.location.hostname.toString() + '/', '');
					window.location.hash = '#watch-archives/' + url;
				} else {
					archives_autoplay_first = true;
					if( !is_mobile() && !is_mobile2() && FlashDetect.installed ){
						//$('.archive-clips a.playing:first').click();
					};
				}
			} else if( id == 'chats' ) {
				archives_autoplay_first = false;
				if ( window.livestreamIsPlaying ) {
					$('.trigger-text').hide();
					$('.trigger-holder').removeClass('trigger-button2');
					if ( typeof stream_fp_instance != 'undefined' ) {
						$('#player-controls').show().css({'position': 'relative', 'top' : 0, 'left': 0}).parent().width(218);
					}
				} else {
					$('.trigger-holder').addClass('trigger-button2');
					$('.trigger-text').show();
					$('#player-controls').hide();
				}
     			if ( typeof window.arch_fp_instance != 'undefined' && window.arch_fp_instance.isPlaying() ) {
     				window.arch_fp_instance.pause();
     			};
				window.location.hash = 'watch-live';
				$('#player-controls-archive').hide();
				if($(this).hasClass('link-chat')){
					$('#prayer-chat').hide();
					$('#streaming-chat').show();
				} else {
					$('#streaming-chat').hide();
					$('#prayer-chat').show();
				};
			}
			if(!$('#' + id).is(':visible')){
				$('.tabbed .tab').hide();
				$('#' + id).fadeIn();
			};
			$('#streaming-nav li').removeClass('active');
			$(this).parent().addClass('active');
			$('#streaming-nav').stop().animate({ 'left' : nav_x + 'px' }, function() {
				if ($('.archive-clips:visible a').length && $('.archive-clips a.playing').length < 1) {
					if( !is_mobile() && !is_mobile2() && FlashDetect.installed ){
						//$('.archive-clips a:first').click();
					};
				};
				if ( is_mobile() || is_mobile2() ) {
					$('.archive-list').css({'overflow': 'scroll'})
				} else {
					$('.archive-list').jScrollPane({
							showArrows: false,
							horizontalGutter: 10
					});
				}
			});
			return false;
		};
		if($(this).hasClass('link-give')){
			_gaq.push(['_trackEvent', 'Online Giving', 'Give Online', 'Give - Streaming Nav']);
		};
	});
	
	window.onLivestreamBegin = function() {
		if ( $('#chats:visible') ) {
			$('.trigger-text').hide();
			$('.trigger-holder').removeClass('trigger-button2');
			$('#player-controls').show().css({'position': 'relative', 'top': 0, 'left': 0}).parent().width(218);
		};
	}
	
	$('.watch-live, .watch-archives').click(function(){
     	var streaming = $('.thermalStream');
     	var box = $('#header-columns');
		var closeBTN = $('.closeStreaming');
     	if(streaming.css('display') == 'none') {
     		box.fadeOut(function(){
     			streaming.fadeIn();
				if (ichurch_loaded) {
					//$('.thermalTabs').fadeIn();
					closeBTN.fadeIn();
				}
     		});
     	}
     	
		// Show current tab
		if($(this).hasClass('watch-live')) {
			$('#streaming-nav a.link-chat').trigger('click');
			if ( typeof stream_fp_instance != 'undefined' ) {
				$('#player-controls').css({'position': 'relative', 'top': 0, 'left': 0}).parent().width(218);
			}
			archives_autoplay_first = false
			window.location.hash = 'watch-live';
		}else {
			$('#streaming-nav a[rel=archives]').trigger('click');
			$('#player-controls-archive').css('position', 'relative');
			command_queue = 'archives';
			archives_autoplay_first = true
			if ( !video_match && window_already_loaded ) {
				window.location.hash = 'watch-archives';
			};
		}
     		
     	if(!is_logged() && !is_iframed()){
			show_iframe();
		}
     	return false;
	});
	
	/*$('#notestab a').live("click", function() {
		var notestab = $('#notestab');
		var faqstab = $('#faqstab');
		var feedbacktab = $('#feedbacktab');
		var notesForm = notestab.find('.form');
		if ( $(this).hasClass('closed') ) {
			notesForm.show();
			faqstab.css('z-index','0');
			feedbacktab.css('z-index','0');
			$(this).removeClass('closed');
			notestab.animate({'bottom': '-314px'}, 300)
		} else {
			notestab.animate({'bottom': '3px'}, 300, 'linear', function() {
				notestab.find('a').addClass('closed');
				notesForm.hide();
				faqstab.css('z-index','3');
				feedbacktab.css('z-index','3');
			});
		}
		return false;
	});
	
	var notestabTextChanges = function() {
		var notestab = $('#notestab');
		notestab.find('.notes-sent').removeClass('notes-sent');
		notestab.find('.notes-saved').removeClass('notes-saved');
	}
	
	$('#notestab textarea').change(notestabTextChanges);
	$('#notestab textarea').keypress(notestabTextChanges);
	
	$('#notestab input:not(.blink)').live("click", function() {
		var notestab = $('#notestab');
		var _this = $(this);
		if ( $(this).hasClass('notes-send') ) {
			// ajax request to send msg and clear the cookie
			if ( !notestab.find('.notes-mail').val().match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/) || notestab.find('.notes-mail').val() == 'email@domain.com' ) {
				alert('Please enter valid Email address!');
				return false;
			} else if( notestab.find('textarea').val() == '' ) {
				alert('Please take your notes down before sending them!');
				return false;
			}
			var data = {'notes-message': notestab.find('textarea').val(), 'notes-mail': notestab.find('.notes-mail').val()};
			notestab.find('textarea, .notes-mail').attr('disabled', 'disabled');
			$(this).addClass('notes-sending');
			$.post("/resources/1/rwoc/mailer.php", data, function(recv_data) {
				notestab.find('textarea, .notes-mail').attr('disabled', false);
				if ( recv_data == 'ok' ) {
					notestab.find('textarea').val('');
					_this.removeClass('notes-sending').addClass('notes-sent');
					notestab.find('.notes-saved').removeClass('notes-saved');
				} else {
					alert('Error occured while sending your notes! Please try again!');
				}
			});
		} else if ( $(this).hasClass('notes-save') ) {
			$.cookie('notestab_msg', $('#notestab textarea').val());
			$(this).addClass('notes-saved');
		} else if ( $(this).hasClass('notes-clear') ) {
			$.cookie('notestab_msg', '');
			$('#notestab textarea').val('');
			notestabTextChanges();
		} 
		return false;
	});*/
	
	$('.thermalTabs a.myStudyTab').live("click", function() {
		var thermalTabs = $('.thermalTabs');
		var _this = $(this);
		var myStudy = thermalTabs.find('.myStudy');
		if ( !$(this).hasClass('close') ) {
			myStudy.show();
			$(this).addClass('close');
			thermalTabs.animate({'bottom': '-292px'}, 300);
		} else {
			thermalTabs.animate({'bottom': '0px'}, 300, function(){
				_this.removeClass('close');
				myStudy.hide();
			});
		}
		return false;
	});
	
	var myStudyButtonReset = function() {
		var thermalTabs = $('.thermalTabs');
		thermalTabs.find('.notesSent').removeClass('notesSent');
		thermalTabs.find('.notesSaved').removeClass('notesSaved');
	}
	
	$('.nicEdit-main').change(myStudyButtonReset);
	$('.nicEdit-main').keypress(myStudyButtonReset);
	
	$('.myStudyNotes input[type=submit]').live("click", function() {
		var myStudyNotes = $('.myStudyNotes');
		var _this = $(this);
		if ( $(this).hasClass('notesSend') ) {
			// ajax request to send msg and clear the cookie
			if ( !myStudyNotes.find('.notesEmail').val().match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/) || myStudyNotes.find('.notesEmail').val() == 'email@domain.com' ) {
				alert('Please enter a valid Email address!');
				return false;
			} else if( myStudyNotes.find('.nicEdit-main').html() == '<br />' ) {
				alert('Please take your notes down before sending them!');
				return false;
			}
			var data = {'myStudyNotesData': myStudyNotes.find('.nicEdit-main').html(), 'notesEmail': myStudyNotes.find('.notesEmail').val()};
			myStudyNotes.find('.nicEdit-main, .notesEmail').attr('disabled', 'disabled');
			$(this).addClass('notesSending');
			$.post("/resources/global/thermal/mailer.php", data, function(recv_data) {
				myStudyNotes.find('.nicEdit-main, .notesEmail').attr('disabled', false);
				if ( recv_data == 'ok' ) {
					myStudyNotes.find('.nicEdit-main').html('<br />');
					_this.removeClass('notesSending').addClass('notesSent');
					myStudyNotes.find('.notesSaved').removeClass('notesSaved');
					$.cookie('myStudyNotesData', '');
				} else {
					alert('Error occured while sending your notes! Please try again!');
				}
			});
		} else if ( $(this).hasClass('notesSave') ) {
			$.cookie('myStudyNotesData', myStudyNotes.find('.nicEdit-main').html());
			$(this).addClass('notesSaved');
		} else if ( $(this).hasClass('notesClear') ) {
			$.cookie('myStudyNotesData', '<br />');
			$('.nicEdit-main').html('<br />');
			myStudyButtonReset();
		} 
		return false;
	});
	
	$('a.fancy').fancybox({
		width: '50%',
		height: '70%',
		type : 'iframe'
	});
	
	if( !is_mobile() && !is_mobile2() && FlashDetect.installed ){
		$('a[href="/resources/global/thermal/give-online-video.html"]').live('click', function(){
			$.fancybox({
				href:'/resources/global/thermal/give-online-video.html',
				width: '600',
				height: '355',
				scrolling: 'no'
			});
			return false;
		});
	} else {
		$('a[href="/resources/global/thermal/give-online-video.html"]').live('click', function(){
			$(this).attr({
				'target':'_parent',
				'href':'/resources/global/apostleiCHURCH-2.mp4'
			});
		});
	};
	$('a[href="/resources/global/thermal/our-story.html"]').fancybox({
		width: '600',
		height: '355',
		scrolling: 'no'
	});
	// !give video
	/*var giveVideoShown = $.cookie('giveVideoShown');
	if ( !giveVideoShown || giveVideoShown == 'null' ) {
		$('<a href="/resources/global/thermal/give-online-video.html" class="rwocGiveVideo" style="display:none;">&nbsp;</a>').appendTo('body');
		$('a.rwocGiveVideo').fancybox({
			width: '575',
			height: '330',
			scrolling: 'no'
		}).trigger('click');
		$.cookie('giveVideoShown', 'true'); //, { expires: 7 }
	};*/
	
	var faqsVisible = false;
	var faqsPageVisible = false;
	$('.faqsButton').live('click', function(){
		if(!$(this).hasClass('faqVisible')){
			$('.faqsText').fadeOut();
			$(this).prev().fadeIn();
			$(this).addClass('faqVisible');
		} else {
			$(this).prev().fadeOut();
			$(this).removeClass('faqVisible');
		};
		return false;
	});
	$('.faqsTab').click(function(){
		if(!faqsPageVisible){
			var href = $(this).attr('href');
			if ( href.indexOf(window.location.hostname.toString()) == -1 ) {
				href = 'http://' + window.location.hostname.toString() + href;
			}
			$('#iframe').attr('src', href + '?rd=' + Math.ceil(Math.random*100));
			faqsPageVisible = true;
		};
		if(!faqsVisible){
			$('.faqsContainer').fadeIn('slow');
			if(!$('.faqsContainer.noBlink .faqsText').is(':visible')){
				$('.faqsContainer.noBlink .faqsButton').trigger('click');
			};
			var fsp = 800;
			var fd = 500;
			$('.faqsContainer:not(".noBlink")').fadeOut().delay(100).fadeIn().delay(100).fadeOut().delay(100).fadeIn().delay(100).fadeOut().delay(100).fadeIn().delay(100).fadeOut().delay(100).fadeIn();
			faqsVisible = true;
		} else {
			$('.faqsContainer').hide();
			faqsVisible = false;
		};
		return false;
	});
	
	function ichurch_link_click() {
		if(!is_opened){
			$('.trigger-button').trigger('click');
		};
		if($(this).attr('href') == '/watch-live.aspx') {
			//command_queue = 'live';
			$('.watch-live').trigger('click');
		}else {
			command_queue = 'archives';
			window.location.hash = 'watch-archives';
			$('.watch-archives').trigger('click');
		}
		return false;
	}

	function ichurch_iframe_link_click() {
		if(!is_opened){
			$('.trigger-button', window.parent.document).trigger('click');
		};
		if($(this).attr('href') == '/watch-live.aspx') {
			//command_queue = 'live';
			$('.watch-live', window.parent.document).trigger('click');
		}else {
			command_queue = 'archives';
			window.parent.location.hash = 'watch-archives';
			$('.watch-archives', window.parent.document).trigger('click');
		}
		return false;
	}
	window.show_iframe = function (){
		$('#navigation a').removeClass('active');
		$('#navigation a, #logo a').each(function(){
			if( $(this).attr('target') != '_blank' ) {
				$(this).addClass('iframe-link');
			}
		});
		$('#header-columns .header-col a').addClass('iframe-link');
		$('#iframable').addClass('hidden-div');
		//appending the iframe
		var iframe_html = '<div id="iframe-holder">';
		iframe_html += '<iframe id="iframe" src="" width="100%" height="200" scrolling="no" frameborder="0"></iframe>';
		iframe_html += '</div>';
		$('#header').after(iframe_html);
		var href = window.location.href.toString().replace(/#.*/, '', 'gi') + '?framed=true';
		$('#iframe').attr('src', href);
		$('#iframe').load(function() {
			$('#sidebar a[href="/watch-live.aspx"], #sidebar a[href="/on-demand.aspx"]', $('#iframe').contents()).click(ichurch_iframe_link_click);
		})
	}
	
	$('#navigation a[href="/watch-live.aspx"], #navigation a[href="/on-demand.aspx"]').click(ichurch_link_click);
	$('.slider1-content li a[href*="watch-live"]').live('click', ichurch_link_click);
	
	$('#sidebar a[href="/watch-live.aspx"], #sidebar a[href="/on-demand.aspx"], .slider a[href="http://rwoc.org/#watch-live"]').click(ichurch_link_click); //, .jshowoff a[href$="#watch-live"]
	
	if(is_logged()){
		$('.editHomeLogos,.footer-col1 .editGeneralInfo').css('display','block');
		if($('span[id$=_lblPageStatus] b').html() == 1){
			$('.pagetool').css('margin-top','20px');
		};
	};
	
	$('a[href=""]').removeAttr('href').css('cursor','default');
	
	/*$('.studyFaqTabs .giveTab').
	_gaq.push(['_trackEvent', 'On Demand', 'Play On Demand', archiveVideoName]);
	window.setTimeout(function() {
		window.location = archiveVideoHref;
	}, 1000);
	return false;*/
	
});

// not used function
function hide_iframe(){
	$('#navigation a.iframe-link').removeClass('iframe-link');
	$('#header-columns .header-col a').removeClass('iframe-link');
	window.location.href = $('#iframe').attr('src');
	$('#iframe-holder').remove();
}

function _init_iframe_functions(){
	var parent_body = $('#iframe-holder', parent.document.body);
	if( parent_body.length == 0 ) return;
	$('#header').hide();
	parent_body.find('#iframe').attr('height', $('body').height());
	if(is_logged()){
		parent.window.location.href = window.location.href;
	}
}

function is_logged(){
	return $('.cms-nav a.logout').length > 0;
}

function is_iframed(){
	var parent_body = $('#iframe-holder', parent.document.body);
	return parent_body.length > 0;
}

function _animate_horizontal(){
	var li = $('.ads li');
	var ul = li.parent();
	var clip = ul.parent();
	if( li.length <= 4 ) 
		return;
	var direction = 'right';
	var clip_w = clip.width();
	var clip_x = clip.position().left;
	var clip_offset_x = clip.offset().left;
	// set width to 2000 for Chrome/Safari
	ul.css({ 'width': '2000px' });
	var time = li.length * 500;
	var $t = this;
	var animated = false;
	var direct;
	clip.mousemove(function(e){
		var x = e.pageX - clip_offset_x;
		var left_x = clip_w / 2 - 150;
		var right_x = clip_w / 2 + 150;
		if( x > clip_w / 2 ) {
			direct = 'right';
		}else {
			direct = 'left';
		}
		if( direction != direct || !animated ){
			direction = direct;
			$t._animate();
		}
		if( x > left_x && x < right_x ) {
			$t._stop();
		}
	});
	clip.hover(function(){}, function(){
		$t._stop();
	});
	_stop = function(){
		ul.stop();
		animated = false;
	}
	_animate = function(){
		var ul_w = 0;
		li.each(function(){ ul_w += $(this).outerWidth() + 12; });
		ul.css({ 'width': ul_w + 'px' });
		if( direction == 'left' ) {
			left_position = 0;
		}else {
			left_position = clip_w - ul_w;
		}
		var space_left = Math.abs( left_position - ul.position().left )
		time = Math.ceil(space_left / ul_w * 20000);
		ul.stop();
		ul.animate({ 'left' : left_position + 'px' }, time, 'linear');
		animated = true;
	}
}

function jq_animate_vertical (settings){
	var holder = $(this);
	var ul = $(this).find('ul');
	var li = $(this).find('li');
	if(ul.length == 0 || li.length == 0 || li.length == 1 )
		return;
	var li_height = li.height();
	var index = 0;
	var all_items = li.length;
	ul.css({ 'position' : 'absolute', 'top' : '0', 'left' : '0' });
	window.setInterval(function(){
		index++;
		if( all_items == index ) index = 0;
		var top = -1 * li.height() * index;
		ul.animate({ 'top' : top + 'px' });
	}, 6000);
}
$.fn.animate_vertical = jq_animate_vertical;

// Check if is mobile browser
var mobile_clients = [
	"iphone",
	"ipad"
];

var mobile_clients2 = [
	"android"
];

function is_mobile(){
	var uagent = navigator.userAgent.toLowerCase();
	for (var i in mobile_clients) {
		if (uagent.indexOf(mobile_clients[i]) != -1) {
			return true;
		}
	}
    return false;
}

function is_mobile2(){
	var uagent = navigator.userAgent.toLowerCase();
	for (var i in mobile_clients2) {
		if (uagent.indexOf(mobile_clients2[i]) != -1) {
			return true;
		}
	}
    return false;
}

function archiveImageClick(){
	var archiveImageHref = $('.archive-clips a:first').attr('rel');
	var archiveVideoName = $('.archive-clips a:first span.onclick').text();
	_gaq.push(['_trackEvent', 'On Demand', 'Play On Demand', archiveVideoName]);
	window.setTimeout(function() {
		window.location = archiveImageHref;
	}, 1000);
	return false;
};

function archiveVideoClick(archiveVideoHref, archiveVideoName){
	//var archiveVideoHref = $(this).find('a').attr('rel');
	//var archiveVideoName = $(this).find('a span.onclick').text();
	_gaq.push(['_trackEvent', 'On Demand', 'Play On Demand', archiveVideoName]);
	window.setTimeout(function() {
		window.location = archiveVideoHref;
	}, 1000);
	return false;
};
	
function fix_mobiles(){
	if( is_mobile() || is_mobile2() || !FlashDetect.installed ){
		$('.archive-video').html('<a class="archiveImage" onclick="archiveImageClick()"><img src="/resources/1/rwoc/css/images/placeholder-archive-launch.jpg" /></a>');
	};
}

function fix_archives(){
	if( is_mobile() || is_mobile2() || !FlashDetect.installed ){
		$('.archive-clips a').each(function(){
			$(this).removeAttr('href');
			//$(this).attr('onclick','archiveVideoClick()');
		});
	};
}

var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){}
return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){}
return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};}
return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";

