/*
  Function: getPageWidth
  Finds the browser width, and retruns small (1024 or less), medium (1025-1599) or large (1600+).
 */
function getPageWidth() {
    var pageWidth = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	pageWidth = window.innerWidth;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	pageWidth = document.documentElement.clientWidth;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	pageWidth = document.body.clientWidth;
    }
    
    if ( pageWidth <= 1024 ) {
	return "small";
    } else if ( pageWidth >= 1600 ) {
	return "large";
    } else {
	return "medium";
    }
}



/*
  Function: replaceSizes
  Looks for any links containing small/ and replaces it with small/, medium/ or large/, depending on the users browser size.
*/
function replaceSizes() {
    size = getPageWidth()+'/'
    linkcount = document.links.length;
    for(i=0;i<linkcount;i++) {
	document.links[i].href = document.links[i].href.replace('medium/',size)
    }
}

/*
  Function: Preload
  Load the images for the next page.
*/
function Preload() {
  var args = Preload.arguments;
  document.imageArray = new Array(args.length);
  for (var i=0; i<args.length; i++) {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

/*
  Function: alienInvasion
  This function has a silly name
 */
function alienInvasion() {
    user = 'ragnar';
    site = 'queertales.com';
    return ('<a href=\"mailto:' + user + '@' + site + '\">Ragnar Brynj&uacute;lfsson</a>');
}
