// Enable caching while loading in a new set of images
var postFixVersion = '2';

function OnLoad(){
		ContextHeaders();
		setScreenResolution();
}

function setScreenResolution(){
	h 		= screen.height;
	view = gup('view');

	// for laptops and desktops (now)
	if (h<=768) { 
		screenSize 		= 'small'; 
		cssBkgHeight 	= '819px';	
	}
	else if (h>768) { 
		screenSize 		= 'medium';
		cssBkgHeight 	= '1024px';	
	}

	if(view==''){view = 'opening';}

	pageImageFile = view+'-'+screenSize+'-'+postFixVersion+'.jpg';

	// write new CSS for the background image
    var screenSettings = {
'background-image' : 'url("css/page-images/'+pageImageFile+'")',
'height' : cssBkgHeight
    }
	// insert CSS with jQuery
    $("#ph-image").css(screenSettings);
    $("#ph-image").hide();
    $("#ph-image").fadeIn("fast");
    
    //alert(pageImageFile);
	

}

// Reading GET params with Javasript (hack)
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

// window.onload = function(){ alert("welcome"); }

window.onload = OnLoad;

//google.setOnLoadCallback(OnLoad);

// on document ready, OnLoad()


