/* Author: 

*/


$(document).ready(function() {


$('#slideshow').cycle({ 
    fx:     'fade', 
    speed:  'slow', 
    timeout: 8000, 
    pager:  '#slidenav', 
     after: onAfter,
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#slidenav li:eq(' + idx + ')'; 
    } 

});


function onAfter() {
	//var si = $(this).parent('slideshow'); 
	var sindex = $("#slideshow img").index(this);
	  $('#slidenav li').removeClass("on");
  $('#slidenav li').eq(sindex).toggleClass("on");
		
}

});



$(function() { 	// this function changes the slide, clicked by the li
	$("#slidenav li").hover(
	function () {
		$('#slidenav li').removeClass("on");
		$(this).click();
	});
});


$(function() { 	
	$("#slidenav").hover(
	function () {
		$('#slideshow').cycle('pause');
	},
	function () {
		var sindex = $("#slideshow img").index(this);
		$('#slidenav li').eq(sindex).toggleClass("on");
		$('#slideshow').cycle('resume');
	}
	
	);
	
});

$(function() { 	// this function changes the slide, clicked by the li
	$("#slidenav li a").click(
	function () {
		window.location.href=$(this).attr('href');
	});
});



function openSlideShow(uid, id) {
    username = "<?php echo $user['user']['nsid'];?>";
    var url = "http://flickr.com/";
	if(!isNaN(parseInt(id,10))) { url += 'photos/'+uid+'/sets/'+id+'/show/?no_back=1'; }
    else { return true; }
    var w = Math.max(screen.width-140, 750);
    var h = Math.max(screen.height-140, 400);
    var show = window.open(url, "_blank", "width=" + w + ",height=" + h + ",top=10,left=70,scrollbars=no, status=no, resizable=yes");
    try { show.focus(); } catch(err) {}
    return false;
}

