function showModalWindow( url, title )
{
	Modalbox.show(url, {title: title, width: 600}); 
	return true;	 
}

function showModalWindowGet( url, title, formElements )
{
	var queryString = "";
	for( var i=0;i<formElements.length;i++)
	{
		var currentElement=formElements[i];
		if( currentElement.name )
			queryString += "&" + currentElement.name + "=" + escape(currentElement.value);
	}
	showModalWindow( url + queryString, title );
	return true;
	//submit();
}

window.alert2 = function( msg )
{
	showModalWindow( '/error/alertModal/msg/'+msg, 'Mensaje');
};

function managecheckbox(value) {
	contacts = $$("input.checkboxclass");
	
	for(index in contacts) {
		contacts[index].checked = value;			
	}
}

function getXmlHttpObject()
{
	var xmlHttp;
	try
  	{  // Firefox, Opera 8.0+, Safari  
  		xmlHttp=new XMLHttpRequest();  
  	}catch (e){  
	  	// Internet Explorer  
	  	try
	    {    
	    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	    }catch (e){
	        try
      		{      
      			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
      		}catch (e)
      		{      
      			alert("Your browser does not support AJAX!");      
      			return false;      
      		}    
      	}  
     }
     return xmlHttp;
}
window.alert2 = function( msg )
	{
		showModalWindow( '/error/alertModal/msg/'+msg, 'Mensaje');
	};

var divLoading = null;

function loadDivContent( divId, contentUrl )
{
  	alert("reemplazarme (loadDivContent): " + divId + ", " + contentUrl);
  	new Ajax.Updater($(divId), contentUrl, {method: 'get'});
}

function managmentDetails(divId, imgId) {
	div_js = $(divId);
	img_js = $(imgId);
		
	if(div_js.name == divId+"_1") {
		Effect.SlideUp(divId, { duration: 1.0 });
		div_js.name = divId+"_0";
		img_js.src = "/images/b_deta_1.gif";
	} else {
		Effect.SlideDown(divId, { duration: 1.0 });
		div_js.name = divId+"_1";
		img_js.src = "/images/b_deta_2.gif";
	}
	
}

// We have to resize the modalbox windows, when you show the detaills
height_modal = 90;

function managmentDetailsModalBox(divId, imgId) {

	div_js = $(divId);
	img_js = $(imgId);
			
	if(div_js.name == divId+"_1") {
		Effect.SlideUp(divId, { duration: 1.0 });
		div_js.name = divId+"_0";
		img_js.src = "/images/b_deta_1.gif";
	} else {
		Effect.SlideDown(divId, { duration: 1.0 });
		div_js.name = divId+"_1";
		img_js.src = "/images/b_deta_2.gif";
	}
	refreshSizeModalBox();
}

// How we can't modify the Slideup function, and we can't execute one function per iteration
//of slide efect, we have to build a sequence to make the animation of resizing modal box
function refreshSizeModalBox()
{
	setTimeout("Modalbox.resizeToContent();", 200);
	setTimeout("Modalbox.resizeToContent();", 400);
	setTimeout("Modalbox.resizeToContent();", 600);
	setTimeout("Modalbox.resizeToContent();", 800);
	setTimeout("Modalbox.resizeToContent();", 1000);
	setTimeout("Modalbox.resizeToContent();", 1200);
	setTimeout("Modalbox.resizeToContent();", 1400);
	setTimeout("Modalbox.resizeToContent();", 1500);

}