/* Greybox Redux
 * Required: http://jquery.com/
 * Written by: John Resig
 * Based on code by: 4mir Salihefendic (http://amix.dk)
 * License: LGPL (read more in LGPL.txt)
 */

var GB_DONE = false;
var GB_HEIGHT = 290;
var GB_WIDTH = 434;


function GB_show(openType) {
//alert(openType);
  var SpalshscrollH =  $(window).scrollTop() + 100;
  
  if(!GB_DONE) {
  var GB_windowHeight = $("#bgflashobject").height() + 35;
 
 $("body","html").css({height: "100%", width: "100%"});
    $(document.body).append("<div id='GB_overlay'></div><div id='GB_window'></div>");
    $("#GB_window").css({top:SpalshscrollH});
    $("#GB_overlay").css({height: GB_windowHeight+"px", width: "100%"});
    $("#GB_window img").click(GB_hide);
    $(window).resize(GB_position);
    GB_DONE = true;
  }
  
  var LangCode = $("body").attr('id');
  var silverLang;
          //DK
          if(LangCode == 'da-dk'){
           silverLang = '';
          }
          //DE
          else if(LangCode == 'de-de'){
            silverLang = '?lc=de';
          }
          //UK
          else if(LangCode == 'en-gb'){
             silverLang = '?lc=en';
          }
          else
            silverLang = '?lc=en';
          {
             
   }
   //var stype = 'puzzelStart';
    if(openType == 'puzzelStart'){
    //alert('1');
    SplashURL = '/Static/Game/puzzelstarter.aspx'+silverLang;
    }
    else{
    //alert('2');
    SplashURL = '/Static/Game/gamepopper.aspx'+silverLang;
    }
 
  $("#GB_frame").remove();
  
  
  $("#GB_window").append("<div id='GB_frame'><div onclick='GB_hide();'><a href='#'></a></div><iframe id='GB_iframe' frameborder='0' allowtransparency='true' src='"+SplashURL+"' /></div>"); 
  
 
   //Firefox hack start
  /*if($.browser.mozilla) { $( function() { 
  
        $("#bg-flash").css({ display:"none" });
  } ); }*/
  
  $("#GB_overlay").show();
  
  
  //$("#GB_window").append("<iframe id='GB_iframe' frameborder='0' allowtransparency='true' src='"+SplashURL+"' />"); 
 
  
  //Firefox hack end
 /* if($.browser.mozilla) { $( function() { 
        
        $("#bg-flash").css({ display:"block" });
  } ); }*/
  
  GB_position();
 
 
}

function GB_hide() {
  
  $("#GB_window,#GB_overlay").remove();
  GB_DONE = false;
}

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" });
  $("#GB_frame").css("height",GB_HEIGHT + 32 +"px");
}

