    $(document).load(function() {
        
    repos();
    var ua=navigator.userAgent.toLowerCase();
    var sf=(ua.indexOf('safari')!=-1);var ge=(ua.indexOf('gecko')!=-1);
    i=ua.indexOf('msie');var ie6up=(i!=-1&&(parseInt(ua.charAt(i+5)))>=6)?true:false;
    i=ua.indexOf('opera');var o7up=(i!=-1&&(parseInt(ua.charAt(i+6))>=7))?true:false;
    if (sf&&ge) 
        $('ul#image-nav').get(0).style.marginTop = '1px';
    if (ge&&!sf) 
        $('ul#image-nav').get(0).style.marginTop = '4px';

	$('#copy-link').click(function(){
		if (copyStatus == 0) {
			$('#copy-explanation').get(0).style.display = 'block';
			copyStatus = 1;
		}
		else {
			$('#copy-explanation').get(0).style.display = 'none';
			copyStatus = 0;			
		}
		this.blur();
		return false;
	});

}).resize(function(){
    repos();
});

var currImage = 1;
var copyStatus = 0;

var currOffset = 0;

function repos() {
    var tb = $('div#top-bar').get(0);
    var bb = $('div#bottom-bar').get(0);
    var bi = $('div#bottom-image-bar').get(0);
    var la = $('div#left-area').get(0);
	var ce = $('div#copy-explanation').get(0);
	var im = $('div#image').get(0);
	var il = $('div#image-loader').get(0);
    var cw = xClientWidth();
    var ch = xClientHeight();

    tb.style.width = (cw-105)+'px';
    bb.style.width = (cw-300-75-20)+'px';
    la.style.height = (ch-130)+'px';

    highestRatio = 1.65;
	
	neww = Math.round(xClientWidth()-320);
	newh = Math.round(neww/highestRatio);
	
	if (newh >= (xClientHeight()-130)) {
    	newh = Math.round(xClientHeight()-130);
    	neww = Math.round(newh*highestRatio);	    
	}
    
	tb.style.width = (neww+300-75)+'px';
	
	var nl = Math.round(((xClientWidth()-neww-275)/2))+50;

	bb.style.width = (neww+20)+'px';
	
	ce.style.left = '15px';
	ce.style.width = (neww+5)+'px';
	
	tb.style.left = '85px';//(nl+5)+'px';
	la.style.left = '80px';//nl+'px';
	
	im.style.left = '310px';//(nl+300-75)+'px';
	im.style.height = (xClientHeight()-130)+'px';
	
	bb.style.left = '287px';//(nl+300-20-75)+'px';
	bi.style.left = '80px';//(nl-20)+'px';
	
	bb.style.display = 'block';
	tb.style.display = 'block';
	la.style.display = 'block';
	$('div#copy').get(0).style.display = 'block';
		
    if(typeof sIFR == "function"){
        sIFR.replaceElement(" div#left-area li.active", "/assets/swfs/centaur_bold4.swf", "#FFFFFF", null, null, "#280D0D", 0, 0, 0, 0);
    	sIFR.replaceElement(" div#left-area li.inactive", "/assets/swfs/centaur_bold4.swf", "#7f6951", null, null, "#280D0D", 0, 0, 0, 0);
    }

	if (xClientHeight()<504) {
        $('img#coverimage').get(0).style.display = 'none';
	}
	else {
        $('img#coverimage').get(0).style.display = 'block';	    
	}
	    
	
	showImage(currImage); 
}

function showImage(i) {
    if (i>=pressImages.length)
        i=1;
    currImage = i;
    doImage(i);
}

function doImage(i) {
	$("div#image").get(0).innerHTML = "";
	
	$('#image'+i).addClass('active');
	
	$('#image-nav li a').each(function(){
		if (this.id != 'image'+i) {
			$('#image-nav li a#'+this.id).removeClass('active');
		}
	});
	
	if (pressRatios.length == 0) {
		pressRatios[i] = 1.25;
		pressDescriptions[i] = 'Coming soon';
		$('#image-loader').get(0).style.visibility = 'hidden';
	}
	
	neww = Math.round(xClientWidth()-320);
	newh = Math.round(neww/pressRatios[i]);
	
	if (newh >= (xClientHeight()-130)) {
    	newh = Math.round(xClientHeight()-130);
    	neww = Math.round(newh*pressRatios[i]);	    
	}

    newww = Math.ceil(neww/500)*500;
    newhh = Math.ceil(newh/500)*500;
		
	if (newww > newhh)
        var nx = newww;
    else
        var nx = newhh;
	
	var so = new SWFObject("/assets/swfs/imgShellDotCom.swf", "jli", neww, newh, "6", "#280D0D");
	so.addParam("align", "bottom");
	so.addVariable("filepath", '/assets/images/press/cache2/'+pressImages[i].split('.jpg')[0]+'_'+nx+'.jpg');
	so.write("image");

/*	if(typeof sIFR == "function"){
		it.addClass('sIFR-replaced');
		it.get(0).innerHTML = '<embed style="width: 200px; height: 18px;" class="sIFR-flash" type="application/x-shockwave-flash" sifr="true" bgcolor="#280D0D" wmode="" flashvars="txt='+pressDescriptions[i]+'&amp;textcolor=#FFFFFF&amp;w=200&amp;h=18" quality="best" src="/assets/swfs/centaur_bold4.swf" height="18" width="200"><span class="sIFR-alternate">'+pressDescriptions[i]+'</span>';
	}*/
}

var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
    var i=xUA.indexOf('opera');
    if(i!=-1){
        var v=parseInt(xUA.charAt(i+6));
        xOp7Up=v>=7;
        xOp6Dn=v<7;
    }
}
else 
    if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
        xIE4Up=parseFloat(navigator.appVersion)>=4;
        xIE4=xUA.indexOf('msie 4')!=-1;
        xIE5=xUA.indexOf('msie 5')!=-1;
    }
    else 
        if(document.layers){
            xNN4=true;
        }

xMac=xUA.indexOf('mac')!=-1;

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xClientHeight()
{
  var h=0;
  if(xOp6Dn) h=window.innerHeight;
  else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientHeight)
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}

function xClientWidth()
{
  var w=0;
  if(xOp6Dn) w=window.innerWidth;
  else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientWidth)
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}
