// Browse Z-index Values

$.maxZIndex = $.fn.maxZIndex = function(opt) {
    var def = { inc: 10, group: "*" };
    $.extend(def, opt);    
    var zmax = 0;
    $(def.group).each(function() {
        var cur = parseInt($(this).css('z-index'));
        zmax = cur > zmax ? cur : zmax;
    });
    if (!this.jquery)
        return zmax;

    return this.each(function() {
        zmax += def.inc;
        $(this).css("z-index", zmax);
    });
};


//show loading bar  
function showLoading(){  
    $('#loading').css({visibility:"visible"});
    $('#loading').css({opacity:"1"}); 
    $('#loading').css({display:"block"});  
}  
//hide loading bar  
function hideLoading(){  
    $('#loading').fadeTo(1000, 0);  
    $('#pic').fadeIn('slow');  
}; 

$(document).ready(function(){
	$("#videoWrapper").jqDrag('.drag');
	$(".cast").jqDrag('.drag').jqResize('.resize');
	$(".synopsis").jqDrag('.drag').jqResize('.resize');
	$(".pressclip").jqDrag('.drag').jqResize('.resize');
	$('#loading').hide();
	$(".post-items li a").click(function(){
	var largeAlt = $(this).attr("title");
	  $("."+largeAlt).slideToggle("fast");
	  //$(this).toggleClass("active");
	  return false;
	});
	
	$('.windowWrapper').click(function(){
		$(this).maxZIndex({ inc: 10 });
	});
	
	$('.drag').click(function(){
		$(this).parent().maxZIndex({ inc: 10 });
	});

$('.gallery-list a').click(function(){
	showLoading();					  
	var toLoad = $(this).attr('href');
	$('#pic').fadeOut('fast');
	$('#pic').load(toLoad, hideLoading);
	return false;
	});
	
$('.video-list a').click(function(){
		var vidLoad = $(this).attr('href');
		$("#showVideo").load(vidLoad);
		$("#videoWrapper").fadeIn('fast');
		return false;
	});

$('.video-link a').click(function(){
		var linkLoad = $(this).attr('href');
		$("#showVideo").load(linkLoad);
		$("#videoWrapper").fadeIn('fast');
		return false;
});
	
$('.close').click(function(){
		$(this).parent().parent().fadeOut('fast');
	});
	
});