var BioItemList = {
	
	ajax_url: '/BioItemList/115/get_all_items',
	data:null,
	current_page:10,
	button_prev:null,
	button_next:null,
	
	init:function() {
		if ($('div.bio-item-list').size() == 0) return;
		
		// store buttons
		BioItemList.button_prev = $('div.bio-item-list div.buttons div.prev').html();
		BioItemList.button_next = $('div.bio-item-list div.buttons div.next').html();
		
		$.getJSON(BioItemList.ajax_url, function(data) {
			if (data.length>0) {
				BioItemList.data = data;
				BioItemList.generate_nav();
			}
		});
	},
	generate_nav:function() {
		var data = BioItemList.data;
		
		var nav = '<ul class="bio-item-list reset">';
		if (BioItemList.current_page>1) {
			nav+='<li class="prev">' + BioItemList.button_prev + '</li>';
		}
		for (i=1;i<=data.length;i++) {
			if (i==BioItemList.current_page) {
				nav+= '<li class="active"><a href="#">' + i + '</a></li>';
			} else {
				nav+= '<li><a href="#">' + i + '</a></li>';
			}
		}
		if (BioItemList.current_page<data.length) {
			nav+='<li class="next">' + BioItemList.button_next + '</li>';
		}
		nav += '</ul>';
		$('div.bio-item-list div.bio-txt').append(nav);
		
				$('div.bio-item-list p.txt-right a').click(function() {
			BioItemList.go_to_page(BioItemList.current_page);
			return false;
		});
		
		$('div.bio-item-list .txt-links a').click(function() {
			var url = $(this).attr('href');
			var url_clean = url.replace(/(\/[a-z]{2})?\/bio/,'');
			url_clean = url_clean.replace(/.html/,'');
				if (url_clean>0) {
					BioItemList.go_to_page(url_clean-1);
				}
			return false;
		});
		
		$('div.bio-item-list ul.bio-item-list li').click(function() {
			switch($(this).attr('class')) {
				case 'prev':
					if (BioItemList.current_page>1) BioItemList.go_to_page(BioItemList.current_page - 2);
				break;
				
				case 'next':
					if (BioItemList.current_page<data.length) BioItemList.go_to_page(BioItemList.current_page);
				break;
				
				default:
					var page_id = parseInt($(this).find('a').text()) - 1;
					BioItemList.go_to_page(page_id);
				break;
			}
			return false;
		});
		WidgetButton.init();
	},
	go_to_page:function(i) {
		var text_container = $('div.bio-item-list div.bio-txt');
		var image_container = $('div.bio-item-list div.bio-image img');
		
		if (i>=0) {
			text_container.html(BioItemList.data[i].item_text);
			image_container.attr('src',BioItemList.data[i].item_image);
			BioItemList.current_page = i + 1;
			BioItemList.generate_nav();
		}
		return false;
	}
}
$(document).ready(function(){ BioItemList.init(); });
(function(a){a.extend(a.fn,{livequery:function(b,c,d){var e=this,f;if(a.isFunction(b)){d=c;c=b;b=undefined}a.each(a.livequery.queries,function(g,h){if(e.selector==h.selector&&e.context==h.context&&b==h.type&&(!c||c.$lqguid==h.fn.$lqguid)&&(!d||d.$lqguid==h.fn2.$lqguid))return(f=h)&&false});f=f||new a.livequery(this.selector,this.context,b,c,d);f.stopped=false;f.run();return this},expire:function(b,c,d){var e=this;if(a.isFunction(b)){d=c;c=b;b=undefined}a.each(a.livequery.queries,function(f,g){if(e.selector==
g.selector&&e.context==g.context&&(!b||b==g.type)&&(!c||c.$lqguid==g.fn.$lqguid)&&(!d||d.$lqguid==g.fn2.$lqguid)&&!this.stopped)a.livequery.stop(g.id)});return this}});a.livequery=function(b,c,d,e,f){this.selector=b;this.context=c||document;this.type=d;this.fn=e;this.fn2=f;this.elements=[];this.stopped=false;this.id=a.livequery.queries.push(this)-1;e.$lqguid=e.$lqguid||a.livequery.guid++;if(f)f.$lqguid=f.$lqguid||a.livequery.guid++;return this};a.livequery.prototype={stop:function(){var b=this;if(this.type)this.elements.unbind(this.type,
this.fn);else this.fn2&&this.elements.each(function(c,d){b.fn2.apply(d)});this.elements=[];this.stopped=true},run:function(){if(!this.stopped){var b=this,c=this.elements,d=a(this.selector,this.context),e=d.not(c);this.elements=d;if(this.type){e.bind(this.type,this.fn);c.length>0&&a.each(c,function(f,g){a.inArray(g,d)<0&&a.event.remove(g,b.type,b.fn)})}else{e.each(function(){b.fn.apply(this)});this.fn2&&c.length>0&&a.each(c,function(f,g){a.inArray(g,d)<0&&b.fn2.apply(g)})}}}};a.extend(a.livequery,
{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if(a.livequery.running&&a.livequery.queue.length)for(var b=a.livequery.queue.length;b--;)a.livequery.queries[a.livequery.queue.shift()].run()},pause:function(){a.livequery.running=false},play:function(){a.livequery.running=true;a.livequery.run()},registerPlugin:function(){a.each(arguments,function(b,c){if(a.fn[c]){var d=a.fn[c];a.fn[c]=function(){var e=d.apply(this,arguments);a.livequery.run();return e}}})},run:function(b){if(b!=
undefined)a.inArray(b,a.livequery.queue)<0&&a.livequery.queue.push(b);else a.each(a.livequery.queries,function(c){a.inArray(c,a.livequery.queue)<0&&a.livequery.queue.push(c)});a.livequery.timeout&&clearTimeout(a.livequery.timeout);a.livequery.timeout=setTimeout(a.livequery.checkQueue,20)},stop:function(b){b!=undefined?a.livequery.queries[b].stop():a.each(a.livequery.queries,function(c){a.livequery.queries[c].stop()})}});a.livequery.registerPlugin("append","prepend","after","before","wrap","attr",
"removeAttr","addClass","removeClass","toggleClass","empty","remove");a(function(){a.livequery.play()});var i=a.prototype.init;a.prototype.init=function(b,c){var d=i.apply(this,arguments);if(b&&b.selector){d.context=b.context;d.selector=b.selector}if(typeof b=="string"){d.context=c||document;d.selector=b}return d};a.prototype.init.prototype=a.prototype})(jQuery);
var FtpWebClientViewer = {

	init:function() {
		if ($('.online-now').size() == 0) return;
		
		$('a.online-show-client').click(function(event) {
			event.preventDefault(); 
			var href=$(".online-show-client").attr('href');
			window.open(href,'ftpwebpoker','menubar=0,location=0,toolbar=0,width=798px,height=557px');
		});

		var target = $.browser.msie ? 'object' : 'embed';

		$('div.main-content div.video-player-skin-container ' + target + ':visible').livequery(function() {
			$('.online-now').hide();
		})

		$('div.main-content div.video-player-skin-container ' + target + ':not(:visible)').livequery(function() {
			$('.online-now').show();
		})
	
		
    }
	
}

$(document).ready(function(){FtpWebClientViewer.init();});

var BioNav = {
	init:function() {
		if ($('div.bio-nav').size() == 0) return;
		
		if ($.browser.mozilla) {
			$('div#content').css('margin-top','-18px');
		}
		
		$('div.bio-nav li').hover(function() {
			$(this).addClass('active');
		}, function () {
			if (!$(this).is('.clicked')) {
				$(this).removeClass('active');
			}
		});
	}
}
$(document).ready(function(){ BioNav.init(); });
/* Button */
var WidgetButton = {

	init:function() {
		if ($('span.button').size() == 0) return;
		$('span.button').hover(function() {
			$(this).addClass('button-hover');
		}, function () {
			$(this).removeClass('button-hover');
		});
	}
}
$(document).ready(function(){ WidgetButton.init(); });
/* Target Attribute Fix */
var TargetAttribute = {
	init:function() {
		$('a[rel="internal"], a[rel="external"], a[rel="external nofollow"]').attr('target', '_blank');
					$('#footer').addClass('us');
			}
}
$(document).ready(function(){ TargetAttribute.init();});
