function resize() {
$(".project").height($("body").innerHeight()+"px");
}

$(document).ready(function(){

$("#topInner").show();
$("#bottInner").show().delay(1500).slideUp();

$(".play").click(function(){
var videoID = $(this).attr("rel");
//<iframe title="YouTube video player" width="100%" height="100%" src="http://www.youtube.com/embed/ENoCW1YCzOQ?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe>
$("#video").fadeIn();
$("#videoIN").height($("#video").innerHeight()+"px");
$("#videoIN").html('<iframe title="YouTube video player" width="90%" height="90%" src="http://www.youtube.com/embed/'+videoID+'?rel=0&amp;hd=1&amp;autoplay=1" frameborder="0" allowfullscreen></iframe>')
return false;
});

$("#closeVideo").click(function(){
$("#video").fadeOut();
$("#videoIN").html("");
return false;
});
$("#closeThumbs").click(function(){
$("#thumbs").hide();
return false;
});
resize();

var cycl = $('#portfolio').cycle({ 
    fx:     'fade', 
    random: 1,
    speed:   200, 
    timeout: 0, 
    next:   '#portfolio',
    pause: 1,
    prev: "#prev",
    next: "#next",
    after: onAfter,
    pager:  '#thumbsIn', 
    pagerAnchorBuilder: pagerFactory
});
function pagerFactory(idx, slide) {
				var bg = $(".project:eq("+idx+")").css('background-image');
				bg = bg.replace("url(","");
				bg = bg.replace(")","");
				bg = bg.replace("\"","");
				bg = bg.replace("\"","");
                return '<div class="th" style="background-image:url('+bg+');"><a href="#"></a></div>';
            }; 

$('#portfolio').cycle("pause"); 

//cteme hash
var hash = window.location.hash;
if (hash != "") {
var index = $("div.project").index($(hash));
//alert(index);
$('div.th:eq('+index+') a').trigger('click');  
//alert($('div.th:eq('+index+') a').html());
}

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    var idecko = $(".project:eq("+index+")").attr("id");
    if ($(".project:eq("+index+")").is(':animated')) {
    location.href="#"+idecko;
    }
}

$('#portfolio').cycle('pause');

$("#top").hover(function(){
$(".project:visible .project_inner").slideDown();
},function(){
$(".project:visible .project_inner").slideUp();
});

$("#bott").hover(function(){
$("#bottInner").slideDown();
},function(){
});

$("#next, #prev, .project").hover(function(){
//$("#topInner:visible").slideUp();
$("#bottInner:visible").slideUp();
},function(){
});
$(".in").hover(function(){
$("#nav:visible").fadeOut();
},function(){
});

$(".slider").slider({ max: 100,min: 5, value: 100, slide: function(event, ui) {
var f = (ui.value/100);
$(".project_inner").css('opacity',f);
}});

$(".showsalpha").click(function(){
$("#sliderOuter").toggle();
return false;
});
$(".showsthumbs").click(function(){
$("#thumbs").toggle();
return false;
});

});

window.onresize = resize;
