var active_previews = new Array();
var amf_gateway = 'http://cams.dnxlive.com/stream.enjoy.be/gateway.php';

function startChat(account) {
  maxWindow(param_payment+'?service='+account+'&ref='+param_ref+'&mref='+param_mref+'&language='+param_lang+'&pp='+param_pp, '', 700, 750);
}
function addPreviewListeners(account) {
  if($("#t_"+account).length > 0) {
    $("#t_"+account).bind(
      "mouseenter",
        function(event) {
          var arr = this.id.split("_");
          var account = arr[1];

          if($('#teaser_'+account).length == 0) {
            $("#t_"+account+' .teaser').append('<div id="teaser_'+account+'" style="z-index:1;position: absolute;left: 0px;top: 0px;"></div>');
          }
          $.each(active_previews, function(index, val) {
            swfobject.removeSWF("teaser_"+val);
          });
          
          if($.inArray(account, active_previews) < 0) {
            active_previews = new Array();
            active_previews.push(account);
            var teaser_flashvars = { gateway: amf_gateway };
            var teaser_params = { wmode: "transparent", allowScriptAccess: "sameDomain"};
            var teaser_attributes = {};
            var account_flashvars = teaser_flashvars;
            account_flashvars["account"] = account;

            swfobject.embedSWF("swf/live_preview_public.swf", 'teaser_'+account, 94, 80, "9.0.0", "swf/expressInstall.swf", account_flashvars, teaser_params, teaser_attributes);
          }
        }
    );
    $("#t_"+account).bind(
      "mouseleave",
        function(event) {
          var arr = this.id.split("_");
          var account = arr[1];
          hidePreview(account);
        }
    );
  }
}
function hidePreview(account) {
  active_previews = $.grep(active_previews, function(val) { return val != account; });
  swfobject.removeSWF("teaser_"+account);
}

function bookmark() {
	title = document.title;
	url = document.location.href;
	
    if (window.sidebar)
    {
    	window.sidebar.addPanel(title, url,"");
    }
    else if( document.all )
    {
   		window.external.AddFavorite(url, title);
    }
    else
    {
   		return true;
    }
}


  
function openNewWindow(URLtoOpen, windowName, windowFeatures)   { 
	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
  
function maxWindow(url, name, width, height)   {
    features = 'scrollbars=1,resizable=1,menubar=0,toolbar=0,location=0,status=0,top=0,left=0,screenX=0,screenY=0,';
    if (window.screen) {
      aw = screen.availWidth;
      ah = screen.availHeight;
      features = features+'width='+(aw-20)+',height='+(ah-38);
    }
    else {
      features = features+'width='+width+',height='+height;
    }
    window.open(url, name, features);
}

function popupWindow(url, w, h)   {
    var middleLeft = 400 - w;
    var middleTop = 10;
	        
    if (window.screen) {
      middleLeft = (screen.availWidth / 2) - (w / 2);
    }
			          
    window.open(url, '', 'scrollbars=1,resizable=0,menubar=0,toolbar=0,location=0,status=0,top='+middleTop+',left='+middleLeft+',width='+w+',height='+h);
}

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}