var winLeft = 0;
var winTop = 0;
var winWidth = 400;
var winHeight = 480;
var winOptions = false;
var popUpWin = '';

function showPicture(URLStr, winLeft, winTop, winWidth, winHeight, winOptions) {
// opens a new browser window, sized to the specifics passed in

	if (popUpWin) {
		if (!popUpWin.closed) { popUpWin.close(); }
	}
	
	configOptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=1,';
	configOptions += 'width='+winWidth+',height='+winHeight+',left='+winLeft+',top='+winTop+',screenX='+winLeft+',screenY='+winTop;
		
	if (winOptions) { // make sure this function wasn't called with that option already specified
		configOptions += ',' + winOptions;
	}
	
	popUpWin = open('media/photos/' + URLStr, 'newWin', configOptions); // show the popup with the defined options
}; // end function showPicture()

function showDocumentary() {
// opens a new browser window with the documentary

	if (popUpWin) {
		if (!popUpWin.closed) { popUpWin.close(); }
	}
	
	configOptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=1,';
	configOptions += 'width=716,height=486,left=40,top=40,screenX=40,screenY=40';
	
	popUpWin = open('documentary_window.html', 'newWin', configOptions); // show the popup with the defined options
}; // end function showPicture()

function showRadioInterview() {
// opens a new browser window with the interview

	if (popUpWin) {
		if (!popUpWin.closed) { popUpWin.close(); }
	}
	
	configOptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,copyhistory=1,';
	configOptions += 'width=400,height=300,left=40,top=40,screenX=40,screenY=40';
	
	popUpWin = open('/media/audio/kendall_on_wort.mp3', 'newWin', configOptions); // show the popup with the defined options
}; // end function showRadioInterview()

function playSong(container, songFile, songTitle) {
	
	document.getElementById(container).innerHTML = '<object type="audio/mpeg" data="media/audio/' + songFile + '" width="100" height="20">'+
		'<param name="src" value="media/audio/' + songFile + '">'+
		'<param name="autoplay" value="true">'+
		'<param name="autoStart" value="1">'+
		'alt : <a href="media/audio/'+ songFile +'">'+ songTitle +'</a>'+
		'</object>';
};

var blank = new Image();
blank.src = 'images/clear.gif';

$(document).ready(function() {
  var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
  if (badBrowser) {
    // get all pngs on page
    $('img[src$=.png]').each(function() {
      if (!this.complete) {
        this.onload = function() { fixPng(this) };
      } else {
        fixPng(this);
      }
    });
  }
});

function fixPng(png) {
  // get src
  var src = png.src;
  // set width and height
  if (!png.style.width) { png.style.width = $(png).width(); }
  if (!png.style.height) { png.style.height = $(png).height(); }
  // replace by blank image
  png.onload = function() { };
  png.src = blank.src;
  // set filter (display original image)
  png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}