﻿$(document).ready(function(){


var fileTypes = ['doc','xls','pdf','mp3'];
 
/*
$("#ask_a_question").children().toggle();
		$("#ask_a_question").css({'width':'1px'});
*/
		
/*
$("#ask_a_question").hover(
	function() {
		$("#ask_a_question").children().toggle();
		$("#ask_a_question").css({'width':'250px'});
	},
	function() {
		$("#ask_a_question").children().toggle();
		$("#ask_a_question").css({'width':'1px'});
	}
);
*/
 
$("a[href^='http:']").each(function() {
  var alink = $(this);

  var href = $(this).attr('href');
  if (href.length>0) {
	  var hrefArray = href.split('.');
	  var extension = hrefArray[href.length - 1];
 
	  if ($.inArray(extension,fileTypes) != -1) {
	    alink.click(function() {
    	  // get the post title if there is one
	      // and add it to the string for tracking
    	  pageTracker._trackPageview('/documents/' + href);
	    });
	  }
	}
 
});



function reset_textsize_style() {
	$('div#text-size-interface a').each(function() {
		$(this).css({'text-decoration':'none'});
	});
}

$('a#bigger').click(function() {
	$('body').css({'font-size':'19px'});
	reset_textsize_style();
	$(this).css({'text-decoration':'underline'});
	$('div#incidental_info_content').css({'height':'330px'});
	$('#header div.first').css({'height':'343px'});
	return false;
});

$('a#medium').click(function() {
	$('body').css({'font-size':'15px'});
	reset_textsize_style();
	$(this).css({'text-decoration':'underline'});
	$('div#incidental_info_content').css({'height':'230px'});
	$('#header div.first').css({'height':'243px'});
	return false;
});


$('a#smaller').click(function() {
	$('body').css({'font-size':'12px'});
	reset_textsize_style();
	$(this).css({'text-decoration':'underline'});
	$('div#incidental_info_content').css({'height':'130px'});
	$('#header div.first').css({'height':'243px'});
	return false;
});

$("a[href^='http:']").not("[href*='theincidental.org']").attr({'target':'_blank', 'title':'link will open in new window'});


	$('#font_instruction').hide();
	font.setup();
	if (font.isInstalled('lekton22')) {
	
	} else {
//		$('#font_instruction').show();
	}

	$('.flickr_image').each(function() {
		var pic = $(this);

				
		pic.removeAttr("width"); 
		pic.removeAttr("height");

		var pic_real_width = pic.width();
		var pic_real_height = pic.height();

		var new_height = pic_real_height/(pic_real_width/170);

		pic.css({'width':170, 'height': new_height});

	});
	
	
	
	
	$('#webcam_container img').each(function() {
		var pic = $(this);

				
		pic.removeAttr("width"); 
		pic.removeAttr("height");

		var pic_real_width = pic.width();
		var pic_real_height = pic.height();

		var new_height = pic_real_height/(pic_real_width/170);

		pic.css({'width':160, 'height': new_height});

	});
	

// IE6 handling
function isIE() {
        var ie6 = ($.browser.msie && ($.browser.version == "6.0")) ? this : false;
        return ie6;

}; 

function isIE7() {
        var ie7 = ($.browser.msie && ($.browser.version == "7.0")) ? this : false;
        return ie7;

}; 




if(isIE()) {
$('#ask_a_question').css({'margin-top':'-50px', 'margin-bottom':'50px'});

} else { }


if(isIE7()) {
	$('div#primaryContent').css({
		'margin-top':'100px'
	});
}

	
$('#extra_time_remaining').hide();

/*
	$('#time_remaining').hover(function() {
	
			if(isIE()) { } else {
				$('#extra_time_remaining').text($('#time_remaining').text());
				$('#extra_time_remaining').toggle();
			}
		}, function() {
			if(isIE()) { } else {
				$('#extra_time_remaining').text();
				$('#extra_time_remaining').toggle();
			}
});
*/



$('#twitter_info_content').hide();

	$('#twitter_info').hover(function() {
			$('#twitter_info_content').toggle();
		}, function() {
			$('#twitter_info_content').toggle();
});

$('#flickr_info_content').hide();

	$('#flickr_info').hover(function() {
			$('#flickr_info_content').toggle();
		}, function() {
			$('#flickr_info_content').toggle();
});

$('#blog_info_content').hide();

	$('#blog_info').hover(function() {
			$('#blog_info_content').toggle();
		}, function() {
			$('#blog_info_content').toggle();
});







/*	
$('#twitter_last').hide();
$('#twitter_container ul li:first').hide();
$('#twitter_last').html($('#twitter_container ul li:first').html());
$('#twitter_last').show();
*/

	

	
});