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 OpenAnySite(file, getquery, delay) {
  url = file + 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);
  }
  else window.moveTo(1,1);

  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;
    }
  }
	
  if (position == "center")   window.moveTo(posX,posY);
  else                        window.moveTo(1,1);

}

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

  window.resizeTo(width,height);
}


function InitWindow(agent,mode) {
  if (mode=="") mode = "center";
  var width;
  var height;

  if (mode=="fullscreen") {
    width  = screen.availWidth;
    height = screen.availHeight;
  }
  else {
    width  = 1020;
    height = 800;
  }

  if (agent=="MSIE")   window.setTimeout("maxWindow('"+width+"','"+height+"','"+mode+"')", 100);
  else                 window.setTimeout("Resize('"+width+"','"+height+"','"+mode+"')", 100);
}

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


function ShowWEBPODX(mode,ppid,plid,pro_ser,pro_id,boxmode) {

	if (document.getElementById("WEBPODX")) {
		if (mode=="show") {

      if (!boxmode) boxmode = "show";

      document.getElementById("WEBPODX").style.visibility = "visible";
      document.getElementById("WEBPODX").style.display    = "block";
      var so = new SWFObject("../webpodx/webpodx.swf", "webpodxmovie", "640", "378", "10", "#000000");
      so.addParam("quality", "high");
      //so.addParam("menu", "false");
      so.addParam("scale", "noscale");
      so.addParam("allowfullscreen", "true");
      so.addParam("allowScriptAccess", "always");
      so.addParam("wmode", "transparent");
      so.addVariable("pro_ser", pro_ser);
      so.addVariable("ppid", ppid);
      so.addVariable("pro_id", pro_id);
      so.addVariable("plid", plid);
      so.addVariable("myskin", "1");
      so.addVariable("pathlevel", "../");
      so.addVariable("wpx_path", "webpodx/");
	    so.addVariable("contentpath", "webpodx");
      so.addVariable("skinAlpha", "0.0");
      so.addVariable("skinColor", "0x000000");
      so.addVariable("volume", "0.7");
      so.addVariable("boxmode", boxmode);
      so.write("WEBPODX");
    }
		else {
			if (document.getElementById("WEBPODX")) {
        document.getElementById("WEBPODX").style.visibility = "hidden";
        document.getElementById("WEBPODX").style.display    = "none";
			}
    }
	}
}


function ShowWEBPODX(mode,ppid,plid,pro_ser,pro_id,boxmode) {

	if (document.getElementById("WEBPODX")) {
		if (mode=="show") {

      if (!boxmode) boxmode = "show";

      document.getElementById("WEBPODX").style.visibility = "visible";
      document.getElementById("WEBPODX").style.display    = "block";
      var so = new SWFObject("../webpodx/webpodx.swf", "webpodxmovie", "640", "378", "10", "#000000");
      so.addParam("quality", "high");
      //so.addParam("menu", "false");
      so.addParam("scale", "noscale");
      so.addParam("allowfullscreen", "true");
      so.addParam("allowScriptAccess", "always");
      so.addParam("wmode", "transparent");
      so.addVariable("pro_ser", pro_ser);
      so.addVariable("ppid", ppid);
      so.addVariable("pro_id", pro_id);
      so.addVariable("plid", plid);
      so.addVariable("myskin", "1");
      so.addVariable("pathlevel", "../");
      so.addVariable("wpx_path", "webpodx/");
	    so.addVariable("contentpath", "webpodx");
      so.addVariable("skinAlpha", "0.0");
      so.addVariable("skinColor", "0x000000");
      so.addVariable("volume", "0.7");
      so.addVariable("boxmode", boxmode);
      so.write("WEBPODX");
    }
		else {
			if (document.getElementById("WEBPODX")) {
        document.getElementById("WEBPODX").style.visibility = "hidden";
        document.getElementById("WEBPODX").style.display    = "none";
			}
    }
	}
}


function ShowHide(showid, hideid) {
  if (document.getElementById(showid)) document.getElementById(showid).style.display = '';
  if (document.getElementById(hideid)) document.getElementById(hideid).style.display = 'none';
}

function SendMailTo(email, subject, id) {
  alert(email);
  alert(subject);
  alert(id);
  //this.location.href = 'mailto:e@e.de';
}



function OpenDuplex(url) {
  var box1  = "waitduplex_body";
  var box2  = "waiter_body";

  url += "&showb=on&tt_aw_lay=off";
  //alert ("URL: "+url);

  if (document.getElementById(box1)) document.getElementById(box1).style.display  = "block";
  if (document.getElementById(box2)) document.getElementById(box2).style.display  = "block";

  if (document.getElementById('waiter_headline')) document.getElementById('waiter_headline').innerHTML = 'AMK-Shop';

  if (document.getElementById('waiter_content')) {
		document.getElementById('waiter_content').innerHTML = '<iframe src="'+url+'" id="ShopFrame"></iframe>';
  }

}



function CloseDuplex() {
  var box1  = "waitduplex_body";
  var box2  = "waiter_body";

  if (document.getElementById('waiter_content')) document.getElementById('waiter_content').innerHTML = '';
  if (document.getElementById(box1)) document.getElementById(box1).style.display  = "none";
  if (document.getElementById(box2)) document.getElementById(box2).style.display  = "none";
}



function Minimize(id) {
  var box   = id;
  var btn   = id + "Img";

  if (document.getElementById(box)) {
    var state = document.getElementById(box).style.display;

    if (state == 'none') {
      document.getElementById(box).style.display  = "block";
      if (document.getElementById(btn)) document.getElementById(btn).src = document.getElementById(btn).src.split("down").join("up");
    }
    else {
      document.getElementById(box).style.display  = "none";
      if (document.getElementById(btn)) document.getElementById(btn).src = document.getElementById(btn).src.split("up").join("down");
    }

  }
}


function Format4Facebook(str) {
  str = str.split("?").join("%3F");
  str = str.split("&").join("%26");
  str = str.split(":").join("%3A");
  str = str.split("/").join("%2F");
  str = str.split(" ").join("+");

  return str;
}


//Facebook oeffnen
function ShareOnFacebook(mode, FileName, jpgStamp) {
  var fburl = "";
  //var fburl = "http://www.facebook.com/sharer.php?t=New+"+root.Site.WpxVars.ModeFileName+"-design+on+4sportlife.com&u=http://www.4sportlife.com/flash.php?MF="+root.Site.WpxVars.ModeFileName;
  //var fburl = "http://www.facebook.com/sharer/sharer.php?u=http://www.4sportlife.com/flash.php?MF="+root.Site.WpxVars.ModeFileName+"&t=New "+root.Site.WpxVars.ModeFileName+"-design on 4sportlife.com";

  if (mode=="ourwall") {
    fburl = "http://www.facebook.com/profile.php?id=100001076925658";
  }
  else {
    var tmpfburl   = "http://www.4sportlife.com/flash.php?MF="+FileName+"&Stamp="+jpgStamp;
    var tmpfbtitle = "New "+FileName+"-design on 4sportlife.com";
    fburl = "http://www.facebook.com/sharer/sharer.php?u=" + Format4Facebook(tmpfburl) + "&t=" + Format4Facebook(tmpfbtitle);
  }

  //alert(fburl);
  window.open(fburl);

}

