function download(cid,self,arguments)
{
   var args = '';
   if (arguments)
   {
      for (var i=0; i < arguments.length; i++)
         args += (args ? '&' : '?') + arguments[i].name + '=' + arguments[i].value;
   }

   var url  = '/download2.php' + args + (args ? '&' : '?') + 'cid=' + cid;
   var width = 620; height = 575;

   if (self)
   {
   	var w = window.screen.width; var h = window.screen.height;
      var left = (w - width) / 2;  var top = (h - height) / 3;

      window.moveTo(left,top);
      window.resizeTo(width,height);
      window.location.href = url;
   }
   else
   {
      ringtone_stop_preview();
      abrePopUp(url,width,height);
   }
}

function mobile(cid,arguments)
{
   var args = '';
   if (arguments)
   {
      for (var i=0; i < arguments.length; i++)
         args += (args ? '&' : '?') + arguments[i].name + '=' + arguments[i].value;
   }

   var url = '/mobile.php' + args;
   var width = 620; height = 575;

   // Si vengo desde download, actulizo la url y el tamaño del popup
   if (cid)
   {
   	var w = window.screen.width; var h = window.screen.height;
      var left = (w - width) / 2;  var top = (h - height) / 3;

      window.moveTo(left,top);
      window.resizeTo(width,height);
      window.location.href = url + (args ? '&' : '?') + 'cid=' + cid;
   }
   else abrePopUp(url,width,height);
}

function documentation(type)
{
   var url = '/popup.php?sct=' + type;
   var width = 620; height = 575;
   abrePopUp(url,width,height);
}

function abrePopUp(url, width, height, name)
{
	var anchoVent = width;	            var altoVent = height;
	var w = window.screen.width;        var h = window.screen.height;
   var leftVent = (w - anchoVent) / 2; var topVent = (h - altoVent) / 3;

   if (!global_popup || typeof(global_popup)=="undefined" || global_popup.closed)
   {
      if (!name) name='popup';
      global_popup = window.open(url, name, 'buttons=0, toolbar=0, location=0, status=0, directories=0, menubar=0, scrollbars=0, resizable=0');
      global_popup.resizeTo(anchoVent,altoVent);
      global_popup.moveTo(leftVent,topVent);
      if (!global_popup || typeof(global_popup)=="undefined")
   		alert('Su navegador ha bloqueado la apertura de un popup, por favor corrija ésta configuracion para que el sitio funcione normalmente');
   }
   else
   {
      global_popup.location.href = url;
      global_popup.resizeTo(anchoVent,altoVent);
      global_popup.moveTo(leftVent,topVent);
      global_popup.focus();
   }
}
var global_popup = null;
