var newWidth;
var newHeight;
var popupHeight;
var popupWidth;
var popupCount=0;
var hPop;
var wPop;
function func1(x,y){
	oldHeight=x;
	newHeight=x;
	newWidth=y;
	var myHeight;
	var myWidth;
	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	var screenHeight=myHeight;
	var horzBump=0;
	if(newHeight>screenHeight-300){
		document.getElementById('GOD_image').height=screenHeight-300;
		newHeight=screenHeight-300;
		horzBump=8;
	}
	var popupHeight=newHeight+200;
	var popupWidth = (newWidth / oldHeight) * newHeight;
	
	/*@cc_on
/*@if (@_jscript_version >= 5)
   	  document.getElementById('GOD_image').width=popupWidth;
	  popupHeight+=20;

   /*@end
@*/
	popupCount=1;
	document.getElementById('popup_loader').style.display="none";
	hPop = popupHeight+40+'px';
	wPop = popupWidth+20+'px';
	$.fn.colorbox({inline:true, href:"#inline_example1", scalePhotos:"true", maxHeight:hPop, innerWidth:wPop});
}

function imageAjax(image,title){
pageTracker._trackEvent('Stratfor', 'GOtD', title);
document.getElementById('cboxOverlay').style.display="block";
document.getElementById('popup_loader').style.display="block";
if(popupCount==0){
document.getElementById('loader').innerHTML="";	
	$(function () {
        var img = new Image();
        $(img).load(function () {
            $(this).hide();
            $('#loader').append(this);
            $(this).fadeIn();
			popupWidth=$(this).width();
			popupHeight=$(this).height();
			func1($(this).height(),$(this).width());
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', image).attr("id", "GOD_image");
    });
}else{
	$.fn.colorbox({inline:true, href:"#inline_example1", scalePhotos:"true", maxHeight:hPop, innerWidth:wPop});
	document.getElementById('popup_loader').style.display="none";
}
}
function GOD_nonuser(){
	var boxWidth='430px';
	$.fn.colorbox({inline:true, href:"#nonlogged", innerWidth:boxWidth});
}

var matttestvar = 0;


///////////
//Map Popup
function map_popup(){
	showMapHelp();
	$.fn.colorbox({inline:true, href:"#mapIframe"});
  //$('#mapIframe').removeClass('mapHide');

  if (matttestvar == 1) {
    //remove_map_layers();
  }

  if (matttestvar == 0) {
    matttestvar = 1;
    init_map_layers();
  }
  //init_map_layers();
}
function mapGAtracking(r,n){
	pageTracker._trackEvent('Stratfor', 'Mapnav:'+r, n);
	
}

