var FXStreet = 
{
	Version: '1.0.0',
	Libraries: [],
	OnLoadFunctions: [],
	roadBlock: '',
	showBrokersPopup: true,
	jsPath : '',
	httpPath : '',
	strPageIndex : '-page',
	HttpPath: function()
	{
		return this.httpPath;
	},
	require: function(libraryName, onLoadFunction) 
	{
		//
		//	Comprueba si ya está cargada la libreria para no duplicarla.
		//
		for (var i =0;i<this.Libraries.length;i++) 
		{
			if (this.Libraries[i] == libraryName) return;
		}
		this.Libraries[this.Libraries.length] = libraryName;
		document.write('<script type="text/javascript" src="'+ this.jsPath + libraryName + '"></script>');
		
		for (var i = 1 ; i < arguments.length ; i++)
		{
			this.registerOnLoadFunction(arguments[i]);
		}
	},
	registerOnLoadFunction: function(func)
	{
			this.OnLoadFunctions[this.OnLoadFunctions.length] = func;
	},
	init: function(path)
	{
		this.jsPath = path + "/js/";
		this.httpPath = path;
	},
	load: function() 
	{
		
		var showed = this.showRoadBlock();
		//
		//	Aqui hacemos el window.onload de todo lo que tengamos definido
		//
		for (var i = 0 ; i < this.OnLoadFunctions.length ; i++) 
		{
			try
			{
				eval(this.OnLoadFunctions[i]);
			}
			catch (exception)
			{
				alert("Error " + exception.message + " - Ejecutando " + this.OnLoadFunctions[i]);
			}
		}
		if (!showed) this.showRoadBlock();
	},
	trim: function(str)
	{
		return str.replace(/^\s*|\s*$/g,"");
	},
	totalTrim: function(str)
	{
		return str.replace(' ','');
	},
	
	
	previousType: function(uniqueId)
	{
	//
		//
		var form = document.getElementById(uniqueId + '-myform');
		if (!form) 
		{
			alert("No existe el formulario " + uniqueId + '-myform');
			return false;
		}
		var pagecounter = form.elements['page'];
		
		var action = document.location.toString();
		var endChar = action.charAt(action.length - 1);
		if (endChar == "/") action += "default.aspx";
		form.action = action;

		if (!pagecounter) 
		{
			pagecounter = document.getElementById(uniqueId +"-pageIndex");
		}
		
		if (!pagecounter) 
		{
			alert("No existe el contador de pagina " + uniqueId + this.strPageIndex + " ni " + uniqueId +"-pageIndex");
			return false;
		}

		var page = parseInt(pagecounter.value, 10);
		if (isNaN(page))
		{
			alert("Page " + pagecounter.value + " no es un numero");
			return false;
		}
		pagecounter.value = page - 1;
		form.submit();
	},
	
	
	
	showRoadBlock: function()
	{
		if (this.roadBlock.length > 0)
		{
			var roadblockdata = this.roadBlock.toString().split(",");
			var title = roadblockdata[0];
			var url = roadblockdata[1];
			var height = roadblockdata[2];
			var width = roadblockdata[3];
			var hide = parseInt(roadblockdata[4]);
			var cookiename = roadblockdata[5];
			var expire = parseInt(roadblockdata[6], 10);
		
			var RoadBlockCookie = new cookieObject(cookiename, expire, "/");

			if (RoadBlockCookie.found) return;
			RoadBlockCookie.write();

			GB_show(title, url, height, width);
			if (hide > 0)
			{
				window.setTimeout('GB_hide()',hide * 1000);
			}
			return true;
		}
		else
		{
			return false;
		}
	},
	clearInnerHTML: function( obj )
	{
		if ( obj )
		{
			while(obj.firstChild) obj.removeChild(obj.firstChild);
		}
	},
	getParameterUrl: function( name )
	{
		var regexS = "[\?&]"+name+"=([^&#]*)";
		var regex = new RegExp ( regexS );
		var tmpURL = window.location.href;
		var results = regex.exec( tmpURL );

		if( results == null )
			return"";
		else
			return results[1];
	}
}


///popup mini windows

  <!--  
   /* Script by: www.jtricks.com 
   * Version: 20070301 
     * Latest version: 
    * www.jtricks.com/javascript/window/box_alone.html 
    */  
   // Moves the box object to be directly beneath an object.  
   function move_box(an, box)  
   {  
       var cleft = -215;  
      var ctop = -220;  
      var obj = an;  
  
     while (obj.offsetParent)  
      {  
         cleft += obj.offsetLeft;  
         ctop += obj.offsetTop;  
        obj = obj.offsetParent;  
    }  
    
     box.style.left = cleft + 'px';  
    
     ctop += an.offsetHeight + 1;  
     
      // Handle Internet Explorer body margins,  
       // which affect normal document, but not  
      // absolute-positioned stuff.  
      if (document.body.currentStyle &&  
           document.body.currentStyle['marginTop'])  
       {  
           ctop += parseInt(  
               document.body.currentStyle['marginTop']);  
    }  
    
      box.style.top = ctop + 'px';  
   }  
   
   // Hides other alone popup boxes that might be displayed  
  function hide_other_alone(obj)  
   {  
     if (!document.getElementsByTagName)  
           return;  
    
      var all_divs = document.body.getElementsByTagName("DIV");  
   
     for (i = 0; i < all_divs.length; i++)  
      {  
           if (all_divs.item(i).style.position != 'absolute' ||  
              all_divs.item(i) == obj ||  
              !all_divs.item(i).alonePopupBox)  
           {  
              continue;  
         }  
   
         all_divs.item(i).style.display = 'none';  
     }  
       return;  
 }  
    
  // Shows a box if it wasn't shown yet or is hidden  
  // or hides it if it is currently shown  
 function show_hide_box(an, width, height, borderStyle)  
  {  
     var href = an.href;  
      var boxdiv = document.getElementById(href);  
   
    if (boxdiv != null)  
    {  
          if (boxdiv.style.display=='none')  
        {  
           hide_other_alone(boxdiv);  
            // Show existing box, move it  
           // if document changed layout  
            move_box(an, boxdiv);  
             boxdiv.style.display='block';  
  
            // Workaround for Konqueror/Safari  
            if (!boxdiv.contents.contentWindow)  
                  boxdiv.contents.src = href;  
         }  
        else  
            // Hide currently shown box.  
            boxdiv.style.display='none';  
      return false;  
     }  
    
    hide_other_alone(null);  
  
    // Create box object through DOM  
     boxdiv = document.createElement('div');  
   
     // Assign id equalling to the document it will show  
    boxdiv.setAttribute('id', href);  
    
   // Add object identification variable  
     boxdiv.alonePopupBox = 1;  
    
    boxdiv.style.display = 'block';  
    boxdiv.style.position = 'absolute';  
    boxdiv.style.width = width + 'px';  
     boxdiv.style.height = height + 'px';  
    boxdiv.style.border = borderStyle;  
    boxdiv.style.textAlign = 'right';  
     boxdiv.style.padding = '0px';  
    boxdiv.style.background = '#FFFFFF';  
    document.body.appendChild(boxdiv);  
   
     var offset = 0;  
   
    // Remove the following code if 'Close' hyperlink  
    // is not needed.  
     var close_href = document.createElement('a');  
     close_href.href = 'javascript:void(0);';  
	 close_href.onclick = function()  
    { show_hide_box(an, width, height, borderStyle); }  
	var closeImage= document.createElement('img');
	closeImage.alt = "Close";
	closeImage.src = "/themes/en/images/close1.jpg";
	closeImage.border = "0";
//	closeImage.style.float = "right";
    close_href.appendChild(closeImage);  
    boxdiv.appendChild(close_href);  
    offset = close_href.offsetHeight;  
     // End of 'Close' hyperlink code.  
   
     var contents = document.createElement('iframe');  
     //contents.scrolling = 'no';  
    contents.overflowX = 'hidden';  
    contents.overflowY = 'scroll';  
    contents.frameBorder = '0';  
    contents.style.width = width + 'px';  
    contents.style.height = (height - offset) + 'px';  
   
     boxdiv.contents = contents;  
     boxdiv.appendChild(contents);  
   
    move_box(an, boxdiv);  
    
    if (contents.contentWindow)  
         contents.contentWindow.document.location.replace(  
             href);  
     else  
         contents.src = href;  
   
    // The script has successfully shown the box,  
    // prevent hyperlink navigation.  
     return false;  
 }  
 