var agent = navigator.userAgent;

function OpenSite(getquery, delay) {
  url = 'flhome.php' + getquery.split("&amp;").join("&");
  var wname = "ttHomeWin";
  var delay = delay * 1;
  //alert("url: "+url+"\nwname: "+wname+"\ndelay: "+delay);
  //window.setTimeout("wname=window.open(url,wname,'resizable=1,scrollbars=1,toolbar=0,location=0,menubar=0,status=1');wname.focus();", delay);
  ttHomeWin = window.open(url,'ttHomeWin','resizable=1,scrollbars=1,toolbar=0,location=0,menubar=0,status=1');
  ttHomeWin.focus();
}

function OpenPopUp(url) {
  wname  = "ReactPopUp";
  width  = 435;
  height = 380;
  intAnchoScreen = screen.availWidth;
  intAltoScreen  = screen.availHeight;
  posX   = (intAnchoScreen - width) / 2;
  posY   = (intAltoScreen - height) / 2;
  wname=window.open(url,wname,'resizable=0,scrollbars=0,toolbar=0,location=0,menubar=0,status=1,width=435,height=380,top='+posY+',left='+posX+',screenX=0,screenY=0');
  wname.focus();
}

function ExtraWin(url,width,height) {
  if (width=="")  width  = 700;
  if (height=="") height = 600;
  //alert(agent);
  MyWindow = window.open(url,'MyWindow','resizable=1,scrollbars=1,toolbar=0,location=0,menubar=0,status=1,left=0,top=0,width='+width+',height='+height);
  if (agent.indexOf("MSIE") == -1) MyWindow.focus();
}

function WriteFavLink(code,url,title) {
  if (window.sidebar) {
    code = "";
    //code = code.split("JS_FUNCTION").join("javascript:window.sidebar.addPanel('"+title+"', '"+url+"', '');");
  }
  else if (window.external) {
    code = code.split("JS_FUNCTION").join("javascript:window.external.AddFavorite('"+url+"', '"+title+"');");
  }
  else {
    code = "";
  }
  return code;
}


function maxWindow(width,height,position) {
  if (position == "center") {
    intAnchoScreen = screen.availWidth;
    intAltoScreen  = screen.availHeight;
    posX   = (intAnchoScreen - width) / 2;
    posY   = (intAltoScreen - height) / 2;
    window.moveTo(posX,posY);
  }
  if (document.all)  {
    top.window.resizeTo(width,height);
  }
  else if (document.layers||document.getElementById) {
    if (top.window.outerHeight<height||top.window.outerWidth<width) {
      top.window.outerHeight = height;
      top.window.outerWidth = width;
    }
  }
}

function Resize(width,height,position) {
  if (position == "center") {
    intAnchoScreen = screen.availWidth;
    intAltoScreen  = screen.availHeight;
    posX   = (intAnchoScreen - width) / 2;
    posY   = (intAltoScreen - height) / 2;
  }
	else {
    posX   = 0;
    posY   = 0;
	}
  window.moveTo(posX,posY);
  window.resizeTo(width,height);
}

function InitWindow(agent,mode) {
  if (mode=="fullscreen") {
    if (agent=="MSIE")   window.setTimeout("maxWindow("+screen.availWidth+","+screen.availHeight+",'center')", 1);
    else                 window.setTimeout("Resize("+screen.availWidth+","+screen.availHeight+",'center')", 1);
  }
  else {
    if (agent=="MSIE")       window.setTimeout("maxWindow(445,420,'none')", 1);
    else if (agent=="MSIE7") window.setTimeout("maxWindow(445,440,'none')", 1);
    else                     window.setTimeout("Resize(435,420,'none')", 1);
  }
}

function ChangeStyle(elem,what,value) {
  document.getElementById("skinchoice").style.visibility = value;
}
