
$(document).ready(function(){ 
	Cufon.replace('#slider_data .title', { fontWeight: '400' });
	Cufon.replace('#content h2', { fontWeight: '400' });
	Cufon.replace('#content_right h2', { fontWeight: '400' });
	Cufon.replace('#content h3', { fontWeight: '400' });
	Cufon.replace('#header-nav', { fontWeight: '400' });
	Cufon.replace('.work-headline', { fontWeight: '400' });
	//alignGrid("photoset", 3, 7, 7, 1);
	$(document).pngFix();
	$("a[href^=http://]").not("a[href^=http://clearmpls.com]").attr("target", "_blank");
	$("a[href^=http://]").not("a[href^=http://clearmpls.com]").attr("rel", "external");
 
    Shadowbox.init({
    	players: ['img', 'flv', 'mp4'],
       	fadeDuration: .7
	});
	
	Shadowbox.setup("a.videoplayer");
	$("a[rel*='external']").click(function(){
		pageTracker._trackPageview('/outgoing/'+ $(this).attr('href'));
	});
});

function moveCloseLink() { 
	    cb=document.getElementById( 'sb-nav-close' ); 
	    tb=document.getElementById( 'sb-title' ); 
	
	    if( tb ) 
	        tb.appendChild(cb); 
	} 

function getFlashMovie(movieName) {
  	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		if(document[movieName].length != undefined){
			return document[movieName][1];
		}
		return document[movieName];
	}
}

function triggerVideo(assetPath, titleVar, wid, hei){
	var vidWidth = 640;
	var vidHeight = 480;
	if (wid){
		vidWidth = wid;
	}
	if (hei){
		vidHeight = hei;
	}
	Shadowbox.open({
        player:     'flv',
        title:      titleVar,
        content:    assetPath,
        width:      vidWidth,
		height:     vidHeight
    });
}

function alignGrid(/*string*/ id, /*int*/ cols, /*int*/ cellWidth, /*int*/ cellHeight, /*int*/ padding) {
	var x = 0;
	var y = 0;
	var count = 1;
	jQuery("#" + id).each(function() {1
	    jQuery(this).css("position", "relative");2
	    jQuery(this).children("div").each(function() {3
	        jQuery(this).css("width", cellWidth + "em");
	        jQuery(this).css("height", cellHeight + "em");
	        jQuery(this).css("position", "absolute");
	        jQuery(this).css("left", x + "em");
	        jQuery(this).css("top", y + "em");
	        if ((count % cols) == 0) {4
	            x = 0;
	            y += cellHeight + padding;
	        } else {
	            x += cellWidth + padding;
	        }
	        count++;
	    });
	});
}

function workImageFadeInit() {
	$('#slider ul li').css({opacity: 0.0});
	$('#slider ul li:first').animate({opacity: 1.0}, 700).addClass('show').css({"display":"block"});
	var current = $('#slider ul li:first');
	var next = $('#slider ul li:second');
	$('#slider ul li').click(function(e){
		e.preventDefault();
		nextImage();
	});
}

function nextImage() {
	var current = ($('#slider ul li.show')?  $('#slider ul li.show') : $('#slider ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#slider ul li:first') :current.next()) : $('#slider ul li:first'));	
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 700).css({"display":"block"});
	current.animate({opacity: 0.0}, 700).removeClass('show');
	/*
current.animate({opacity: 0.0}, 300, function() { 
			current.removeClass('show');
			next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 300);
		});
*/
}

