
jQuery.fn.exists = function() { return ($(this).length > 0); }

// OnLoad



/*$(function () {
	var tds = $(".list-table tr td").length;
	var trs = $(".list-table tr").length;
	var w = (tds/(trs-1));
	
	
	
	$('.list-table tr td').each(function(index) {
		$(this).width(700/w);
	})
})*/
/*var myCol = $(this).index();
		var $tr = $(this).closest('tr');
		var myRow = $tr.index();*/
		

/*
======================================================== review-page tabs
*/


$(function () {	

	if ($('.related-articles').length == 0) {
		$('.bottom-end').addClass('regular');
	} else {
		$('.bottom-end').addClass('relative');
	}
	
	
	
});


		
$(function () {	
	
	$(".tab_content").hide(); 
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show(); 
	
	$("ul.tabs li").click(function() {
		
		//alert (length);
	
		$("ul.tabs li").removeClass("active"); 
		$(this).addClass("active"); 
		$(".tab_content").hide(); 
	
		var activeTab = $(this).find("a").attr("href"); 
		$(activeTab).fadeIn(); 
		return false;
	});	
	
});


$(function () {	
	
	var length = $('.screenshots').find('a img').size();
	
	if (length > 6 ) {
		$('.navlinks').show();
	}
	
	var pos = 0;

	
	$(".next").live('click',function() {
		//alert(pos)
		$('.screenshots').animate({"top": "+=140px"}, "500");
		pos +=140;
		return false
	
	});
	
	
		
	$(".prev").live('click',function() {
	//	alert(pos)
		$('.screenshots').animate({"top": "-=140px"}, "500");
		pos -=140;
		return false
	
	});
		
		
	
	
	
});


/*
======================================================== 
*/	

$(function() {

	// :first|last-child|odd|hover
	
	$("li:first-child, tr:first-child, td:first-child, dt:first-child, .text-box h3:first-child").addClass("first");
	$("li:last-child, .box:last-child, .content > div:last-child, tr:last-child, td:last-child ").addClass("last");
	
	$("tr:odd").addClass("odd");
	$(".casinos-list ul li:odd").addClass("odd");
	
	
	
	
	
	
	
	$(".online-casinos .container table tr, .review-tabs .nav li").hover(
		function(){$(this).addClass("hover");},
		function(){$(this).removeClass("hover");}
	);

	// Logo > swfObject
    if ( $("#logo-swf").exists() ){
		var flashvars = {};
		var params = {};
		params.allowfullscreen = "true";
		params.loop = "true";
		params.menu = "false";
		params.wmode = "transparent";
		var attributes = {};
		swfobject.embedSWF(imageDir + "logo.swf", "logo-swf", "280", "110", "9.0.0", false, flashvars, params, attributes);
	}

	// Menu
	
	$(".menu > li:first-child").prepend("<span></span>").addClass("first");
	
	$(".menu > li:first-child > a").hover(
		function(){$(".menu > li:first-child span").addClass("hover");},
		function(){$(".menu > li:first-child span").removeClass("hover");}
	);
	
	$(".menu > li:last-child").append("<span></span>").addClass("more");
	
	$(".menu > li:last-child > a").hover(
		function(){
			$(".menu > li:last-child a img").addClass("hover");
			$(".menu > li:last-child span").addClass("hover");
		},
		function(){
			$(".menu > li:last-child a img").removeClass("hover");
			$(".menu > li:last-child span").removeClass("hover");
		}
	);
	
	$(".menu li ul li:last-child, .menu li.more ul li:last-child").addClass("last");
	$(".menu > li").hover(function() {
        $(this).children("ul").addClass("hover");
    }, function() {
        $(this).children("ul").removeClass("hover");
    });
	$(".menu").css("display", "block");

	// jScroll > jScrollPane
	$('#jScroll').jScrollPane({showArrows:true, scrollbarWidth: 25, scrollbarMargin: 10});

	// ReviewMenu > Toggle
	$(".reveiw-menu .container").css("cssText", "display: none; visibility: visible");
	$(".reveiw-menu em").click(function(){
		$(".reveiw-menu .container").slideToggle("slow");
	});
	$(".reveiw-menu").hover(
		function(){$(".reveiw-menu").addClass("reveiw-menu-hover");},
		function(){$(".reveiw-menu").removeClass("reveiw-menu-hover");}
	);

	// reviewTabs > Cycle
    if ( $("#reviewTabs").exists() ){
		$('#reviewTabs .container').cycle({
			fx: 'fade', timeout: 0, speed: 500, next:   '#viewScreenshots', pager: '#reviewTabs .nav', cleartypeNoBg: true, pagerAnchorBuilder: function(idx, slide) {
    		return '#reviewTabs .nav li:eq(' + idx + ') a'; }
		});
	}

	// TO DO get the link working for View ScreenShots - doesn't work!
	if ( $("#reviewTabs").exists() ){
		$('#reviewTabs .container').cycle({
			fx: 'fade', timeout: 0, speed: 500, pager: '#reviewTabs .image left', cleartypeNoBg: true, pagerAnchorBuilder: function(idx, slide) {
    		return '#reviewTabs .image left:eq(' + idx + ') a'; }
		});
	}


	// onlinecasinosTabs > Cycle & More/Less Toggle
    if ( $("#onlinecasinosTabs").exists() ){

		function getTabHight(){
			return $('#onlinecasinosTabs .container div:visible').height();
		}

		$('#onlinecasinosTabs .nav').css("display", "block");

		$('#onlinecasinosTabs .container').cycle({
			fx: 'blindY', timeout: 0, speed: 500, pager: '#onlinecasinosTabs .nav', cleartypeNoBg: true, pagerAnchorBuilder: function(idx, slide) {
    		return '#onlinecasinosTabs .nav li:eq(' + idx + ') a'; }
		});
		$('#onlinecasinosTabs .view-more span').click(function(){
			if ( $(this).hasClass("less")){
				$('#onlinecasinosTabs .container').animate({height: 266}, 1500,
					function() {
    					$('#onlinecasinosTabs .view-more span em').html("view more");
						$('#onlinecasinosTabs .view-more span').removeClass("less").addClass("more");
	  			});
			} else {
				$('#onlinecasinosTabs .container').animate({height: getTabHight()}, 1000,
					function() {
    					$('#onlinecasinosTabs .view-more span em').html("view less");
						$('#onlinecasinosTabs .view-more span').removeClass("more").addClass("less");
	  			});
			}
		});
	}

// set height of textbox and related articles divs 
/*
 		function setHeightRelatedarticlesTextbox(){ 			textboxHeight = $('.text-box.category').height();
 			relatedarticlesHeight = $('.related-articles.right div.container').height(); 			textboxBottomY = $('div.text-box.category').offset().top+$('.text-box.category').height();
 			relatedBottomY = $('.related-articles.right div.container').offset().top+$('.related-articles.right div.container').height();

 			maxY = Math.max(textboxBottomY,relatedBottomY);
 			minY = Math.min(textboxBottomY,relatedBottomY);
 			diff = maxY - minY;            if (textboxBottomY==minY){ //the textbox is the one to get wider            	$('.text-box.category').css('height',eval(textboxHeight+diff));
            }else{            	$('.related-articles.right div.container').css('height',eval(relatedarticlesHeight+diff));            }		}

       if ( $('.related-articles.right div.container').exists())
       		setRelatedarticlesPosition();

       if ( $('div.text-box.category').exists() && $('.related-articles.right div.container').exists() ){
       setHeightRelatedarticlesTextbox();
       }


 		function setRelatedarticlesPosition(){ 			if ( $('div.text-box.summary').exists() )
 			{  obj = $('div.text-box.summary');
 			   obj2 = $('div.related-articles'); 			   x = obj.offset().left;
 			   y = obj.offset().top;
 			   h = obj.height();
 			   w = obj.width();
 			   w2 = obj2.width();
 			   x2 = x+w-w2-5;
 			   y2 = y+h+5;
 			   obj2.css('left',x2);
 			   obj2.css('top',y2); 			}else if($('h1.categorie-header').exists() ){				obj = $('h1.categorie-header');
 			   obj2 = $('div.related-articles');
 			   x = obj.offset().left;
 			   y = obj.offset().top;
 			   h = obj.height();
 			   w = obj.width();
 			   w2 = obj2.width();
 			   x2 = x+w-w2+15;
 			   y2 = y+h+5;
 			   obj2.css('left',x2);
 			   obj2.css('top',y2); 			}
		}

*/
});
