//Configure bookmarking properties
share.url = "http://www.wheeloffortune.com/minisites/lasvegas/sweetheartsweek";
share.title = "Wheel of Fortune from Las Vegas";
share.description = "What do Wheel of Fortune and Las Vegas have in common? How about bright lights, big money, people who like to party and non-stop entertainment! Don't take a gamble on missing a single show– set your DVR now! Wheel's Vegas shows will air 2/8-2/19.";
share.tweet = "I'_  * W_TC_ING * W_EEL * O_* _ORT_ NE* _ROM * L_S * VEG_S! What Are You Doing? http://sonypictures.com/u.php?a=23220";
share.tracking = true;

// Social bookmarking function
function sharethis() {
	if(document.getElementById('share')) {
		var links = document.getElementById('share').getElementsByTagName('a');
		for (var i=0; i<links.length; i++) {
			var link = links[i];
			link.onclick= function() {
				share.send(this.getAttribute('rel'));	
				return false;
			}
		}
	} else {
		return false;
	}
}

addLoadEvent(function (){sharethis()});


var gallery = function (){
	
	var checkNav = function (cur){
		if(cur.prev().length == 0){
			$(".prev a").hide();
			$(".prev").addClass('nomore');
		}
		else {
			$(".prev a").show();
			$(".prev").removeClass('nomore');
		}
		if(cur.next().length == 0){
			$(".next a").hide();
			$(".next").addClass('nomore');
		}
		else {
			$(".next a").show();
			$(".next").removeClass('nomore');
		}
	}
	
	var init = function(){
		var $cur = $(".gallery li:first");
		$cur.show();
		checkNav($cur);
		
		$(".prev a").click(function(){
			if($cur.prev().length >0){
				$cur.hide();
				$cur = $cur.prev();
				$cur.show();
				checkNav($cur);
			}
			return false;
		});	
		$(".next a").click(function(){
			if($cur.next()){
				$cur.hide();
				$cur = $cur.next();
				$cur.show();
				checkNav($cur);
			}
			return false;
		});
	}
	return {
		init: init
	};	
	
}();

/** MAIN **/
$(document).ready(function(){
	
	$(".settour").bind("click", function(){
		var location = $(this).attr("href");
		window.open(location,"newwindow","width=606, height=340");
		return false;
	});

	if($(".gallery").length > 0){
		gallery.init();
	}
	
	//process poll answer
	
	if($("#poll").length >0) {
		$("#poll").bind("submit", function(){
		if (isOmnitureExists())
    {
        sCode.trackOutboundClick('poll/voting.php', 'sweethearts_poll_submit_button');  
    }

			var choice;
			$("#poll input:checked").each(function(){
				choice = $(this).val();
			});
			var path = "poll/voting.php?vote="+choice;
			$("#poll").load(path);
			return false;
		});
	}
	
	if($("#contestant-video-clips").length > 0){
		$("#contestant-video-clips li a").bind("click",function(){
			var video = $(this).attr("href");
			var contestant = $(this).attr("rel");			
			document.getElementById('contestants-video-player').playVideo(video,contestant);
			scroll(0,100);
			return false;
		});
	}
	
	if(document.getElementById('wof-promotions')) {
		$("#wof-promotions > li").hover(
			function () {
				$(this).addClass("over");
			},
			function () {
				$(this).removeClass("over");
			}
		)
	};
	

});

