var GB_DONE = false;
var GB_HEIGHT = 400;
var GB_WIDTH = 400;
function GB_show(caption, url, height, width) {
  GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  if(url.indexOf("24sports")>0)  GB_WIDTH = 875;
  if(url.indexOf("cfa.com")>0)  GB_WIDTH = 785;
  if(url.indexOf("supermpala.com")>0)  GB_WIDTH = 800;
  $("body").css("margin-right","18px");
  $("body").css("overflow","hidden");

  if(!GB_DONE) {
    $(document.body)
      .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
        + "<img src='images/news_box1/closed.png' alt='Close window'/></div>");
    $("#GB_window img").click(GB_hide);
    $("#GB_overlay").click(GB_hide);
    $(window).resize(GB_position);
    GB_DONE = true;
  }
  $("#GB_frame").remove();
  $("#GB_window").append("<div id=\"holder\" ><iframe id='GB_frame' src='"+url+"' ></iframe></div>");
  $("#GB_caption").html(caption);
  $("#GB_overlay").show();

  GB_position();
  $("#GB_window").slideDown(800);
//$("globalBannerContainerLeft").css("width","0px");

  
var loadit=function(){
	var f=document.getElementById('GB_frame'), l=document.getElementById('preload').style;
	l.display='block';
	if(f.onload==null){
		f.onload=function(){l.display='none'};
		if(window.attachEvent)
			
			f.attachEvent('onload', f.onload);
}
return true;
}
  
  }


function GB_hide() {
//var ifr = document.getElementById("GB_frame");
//ifr.parentNode.removeChild(ifr);
  var ifr = parent.document.getElementById("GB_frame");
  ifr.parentNode.removeChild(ifr);
  ifr=null;
  $("#GB_window,#GB_overlay").hide();
  $("body").css("overflow","auto");
  $("body").css("margin-right","0px");
  
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}



function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  $("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px", left: ((w - GB_WIDTH)/2)+"px", top: (f_scrollTop()+15)+"px" });
  $("#GB_frame").css("height",GB_HEIGHT - 20 +"px");
   $("#GB_overlay").css("top",(f_scrollTop())+"px");
	$("#GB_frame").focus();
}

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
		x=x*80/100;
        return x;
}

