/*
* (c) 2009 Euddene, S.L.
* You can distribute or modify under the terms of GNU General Public License (GPL) v2.
* 
*/

s = new Object();
s.lastSessionID = 0 // number of sessions started
s.sessions=new Array();

function setOpacity(eID, opacityLevel) {
	
	if(document.getElementById(eID)){
		var eStyle = document.getElementById(eID).style;
		eStyle.opacity = opacityLevel / 100;
		eStyle.filter = 'alpha(opacity='+opacityLevel+')';
	}
}

function fade(eID, startOpacity, stopOpacity, duration) {
	
	var speed = Math.round(duration / 100);
	var timer = 0;

	if (startOpacity < stopOpacity){ // fade in
		for (var i=startOpacity; i<=stopOpacity; i++) {
			setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
			timer++;
		} 	return;
	}

	for (var i=startOpacity; i>=stopOpacity; i--) { // fade out
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
		timer++;
	}
}

function eafw_ajax_creaAjax(){
	var objetoAjax=false;

	try {	
		/*Para navegadores distintos a internet explorer*/
		objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		/*Para explorer*/
		objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
		objetoAjax = false;
		}
	}

	if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
		objetoAjax = new XMLHttpRequest();
	}
	
	return objetoAjax;

}

function eafw_ajax_FAjax (url,capa,valores,metodo, waitMsgHTML, onResponseCode)
{
	var ajax=eafw_ajax_creaAjax();
	var capaContenedora = document.getElementById(capa);

	/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
	if(metodo.toUpperCase()=='POST'){
		ajax.open ('POST', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
//			capaContenedora.innerHTML=waitMsgHTML;
				eafwDisplayLoaderGif(eafwBaseURL+"/eafwimg/ajax-loader.gif");
			}else if (ajax.readyState==4){
				if(ajax.status==200)
				{
					document.getElementById(capa).innerHTML=ajax.responseText;
					eval(onResponseCode);
					eafwHideLoaderGif();
				}
				else if(ajax.status==404)
				{
					capaContenedora.innerHTML = "La direccion no existe";
				}
				else
				{
					capaContenedora.innerHTML = "Error: ".ajax.status;
				}
			}
		}

		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(valores);

		return;
	}

	/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
	if (metodo.toUpperCase()=='GET'){
		ajax.open ('GET', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
//				capaContenedora.innerHTML=waitMsgHTML;
					eafwDisplayLoaderGif(eafwBaseURL+"/eafwimg/ajax-loader.gif");
			}
			else if (ajax.readyState==4){
				if(ajax.status==200)
				{
					document.getElementById(capa).innerHTML=ajax.responseText;
					eval(onResponseCode);
					eafwHideLoaderGif();
				}
				else if(ajax.status==404)
				{
					capaContenedora.innerHTML = "La direccion no existe";
				}
				else
				{
					capaContenedora.innerHTML = "Error: ".ajax.status;
				}
			}
		}
	
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(null);
		return
	}

} 

function eafw_ajax_callURL (url, valores, metodo, onResponseCode)
{
	var ajax=eafw_ajax_creaAjax();

	/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
	if(metodo.toUpperCase()=='POST'){
		ajax.open ('POST', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==4 && ajax.status==200)
			{
				eval(onResponseCode);
			}
		}

		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(valores);

		return;
	}

	/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
	if (metodo.toUpperCase()=='GET'){
		ajax.open ('GET', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==4 && ajax.status==200)
			{
				eval(onResponseCode);
			}
		}
	
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(null);
		return
	}

} 


function eafw_ajax_loadListener (url)
{
	var ajax=eafw_ajax_creaAjax();

	ajax.open ('GET', url, true);
	ajax.onreadystatechange = function() {
		if (ajax.readyState==4 && ajax.status==200)
		{
			eval(ajax.responseText)
//			eval(onResponseCode);
			eafwHideLoaderGif();
		}
	}
	
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send(null);
	return


} 



function eafw_ajax_displayHTML(){
	var workspace=document.getElementById('eafw_admintool_main');
	alert(workspace.innerHTML);
	return
}

function eafw_ajax_loadURL(url, container, waitMsgHTML){
	
	eafw_ajax_FAjax(url, container, '', 'get', waitMsgHTML, null);

	return;
}


function eafwDisplayLoaderGif(imgUrl){

	height = 48;
	width = 48;
	popupwindow = document.getElementById("eafw_loaderPopup");
	if(popupwindow == null){
		popupwindow = document.createElement("div");
		popupwindow.id = "eafw_loaderPopup";
		document.body.appendChild(popupwindow);
	}

	var eafwWidth = 0, eafwHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
		eafwWidth = window.innerWidth;
		eafwHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
		eafwWidth = document.documentElement.clientWidth;
  		eafwHeight = document.documentElement.clientHeight;	
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
		eafwWidth = document.body.clientWidth;
		eafwHeight = document.body.clientHeight;
	}


//	popupwindow.style.backgroundColor = 'transparent';
	popupwindow.style.zindex = '50';	
	popupwindow.style.height = height+'px';
	popupwindow.style.width = width+'px';
	popupwindow.style.top = (eafwHeight-height)/2+'px';
	popupwindow.style.left = (eafwWidth-width)/2+'px';

	popupwindow.style.visibility='visible';
	popupwindow.style.display='block';
	fade('eafw_loaderPopup', 0, 100, 150);
	popupwindow.innerHTML = '<img src="'+imgUrl+'">';
	
	return;
}


function	eafwHideLoaderGif(){
	if(document.getElementById("eafw_loaderPopup")){
		popupwindow = document.getElementById("eafw_loaderPopup");
		fade('eafw_loaderPopup', 100, 0, 200);
		popupwindow.style.visibility='hidden';
		popupwindow.style.display='none';
		document.body.removeChild(popupwindow);
	}
	return;
}




function eafwAnimatedHeightDeleteElem(id){
	e = document.getElementById(id);
//	e.style.display = 'none';
//	e.style.visibility = 'hidden';
	e.parentNode.removeChild(e);

	return true;
}

function eafwLoadAlphaLayer(){
	alphalayer = document.getElementById("eafw_alphaLayer");
	if(alphalayer == null){
		alphalayer = document.createElement("div");
		alphalayer.id = "eafw_alphaLayer";
		document.body.appendChild(alphalayer);
	}
	alphalayer.style.visibility='visible';
	alphalayer.style.display='block';
	return;
}

function	eafwHideAlphaLayer(){
	alphalayer = document.getElementById('eafw_alphaLayer');
	document.body.removeChild(alphalayer);
	return;
}

function eafwLoadPopupWindow(width, height){
	eafwLoadAlphaLayer();
	popupwindow = document.getElementById("eafw_popupWindow");
	if(popupwindow == null){
		popupwindow = document.createElement("div");
		popupwindow.id = "eafw_popupWindow";
		document.body.appendChild(popupwindow);
	}

	var eafwWidth = 0, eafwHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
		eafwWidth = window.innerWidth;
		eafwHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
		eafwWidth = document.documentElement.clientWidth;
  		eafwHeight = document.documentElement.clientHeight;	
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
		eafwWidth = document.body.clientWidth;
		eafwHeight = document.body.clientHeight;
	}


	if(!height){
		height = '500';
	}

	if(!width){
		width = '600';
	}

	popupwindow.style.position = 'fixed';
	popupwindow.style.height = height+'px';
	popupwindow.style.width = width+'px';
	popupwindow.style.top = String((eafwHeight-height)/2).concat('px');
	popupwindow.style.left = String((eafwWidth-width)/2).concat('px');
	popupwindow.style.visibility='visible';
	popupwindow.style.display='block';



	fade("eafw_popupWindow", 0, 100, 500);

	return;
}

function	eafwClosePopupWindow(){
	popupwindow = document.getElementById("eafw_popupWindow");
	document.body.removeChild(popupwindow);
	eafwHideAlphaLayer();
	return;
}


function eafw_displayMenuBar(menuBarName){
	elem = document.getElementById(menuBarName);
	elem.style.visibility='visible';
//	elem.style.display='block';
	return;
}

function eafw_hideMenuBar(menuBarName){
	elem = document.getElementById(menuBarName);
	elem.style.visibility='hidden';
//	elem.style.display='none';
	return;
}



function eafwEventListener(id, fieldName, event, managerURL){
//	onResponseCode = '';
	eafw_ajax_loadListener(managerURL+'?jscmd=loadlistener&id='+id+'&event='+event);
}

function eafwSaveLabel(id, managerURL){

	inputelem = document.getElementById(id+'-input');

	if(inputelem==null){
		return false;
	}
	value = encodeURIComponent(inputelem.value);

	eafw_ajax_FAjax(managerURL+'?jscmd=saveLabel&id='+id, id+"-container", 'label='+value, 'post', 'guardando...', null);


	return true;
}

function eafwSavePassword(id, managerURL){

	inputelem1 = document.getElementById(id+'-input');
	inputelem2 = document.getElementById(id+'-input-verify');
	pw = encodeURIComponent(inputelem1.value);
	pw_verify = encodeURIComponent(inputelem2.value);
	inputelem1.disabled = false;
	inputelem2.disabled = false;
//	onResponseCode = "document.getElementById('"+id+"-input').disabled=false;document.getElementById('"+id+"-input-verify').disabled=false;";
	onResponseCode = "eafwInitPasswordUpdateForm('"+id+"', '"+managerURL+"');eafwEventListener('"+id+"', null, 'update', '"+managerURL+"');";
	eafw_ajax_FAjax(managerURL+'?jscmd=savePassword&id='+id, id+"-errmsg", 'pass='+pw+'&passv='+pw_verify, 'post', 'guardando...', onResponseCode);

	return true;

}

function eafwSaveTextArea(id, managerURL){

	inputelem = document.getElementById(id+'-input');
	value = encodeURIComponent(inputelem.value.replace(/\n/g, "<br>"));

	eafw_ajax_FAjax(managerURL+'?jscmd=saveTextArea&id='+id, id+"-container", 'textarea='+value, 'post', 'guardando...', "eafwEventListener('"+id+"', null, 'update', '"+managerURL+"');");

	return true;

}

function eafwSaveSelector(id, dstElem, remoteCmd, managerURL){

	selector = document.getElementById(id);
	if(selector.value == '---'){
		if(dstElem){
			document.getElementById(dstElem).innerHTML = '';
		}
		return true;
	}
	onResponseCode = "document.getElementById('"+id+"').disabled=false;eafwEventListener('"+id+"', null, 'updateselector', '"+managerURL+"');eafwEventListener('"+id+"', null, 'updateselector', '"+managerURL+"');";
	selector.disabled = true;


//updateSelector
	
	if(dstElem){
		eafw_ajax_FAjax(managerURL+'?jscmd='+remoteCmd+'&id='+id, dstElem, 'selection='+selector.value, 'post', 'cargando...', onResponseCode);
	}else{
	eafw_ajax_callURL (managerURL+'?jscmd='+remoteCmd+'&id='+id, 'selection='+selector.value, 'post', onResponseCode);
	}

	
	return true;
}



/* 
function eafwSaveCategoryLink(id, managerURL){

	selector = document.getElementById(id+'-selector');

	eafw_ajax_FAjax(managerURL+'?jscmd=updateCategoryLink&id='+id, id+"-container", 'selection='+selector.value, 'post', 'guardando...', null);

	return true;
}
*/

function eafwUpdateMultiSelectAdd(id, managerURL){

	selector = document.getElementById(id+'-selector');
	availables = document.getElementById(id+'-availables');

	if(availables.selectedIndex == undefined || availables.selectedIndex == -1){
		return true;
	}
	newElem = document.createElement('option');

	newElem.text = availables.options[availables.selectedIndex].text;
	newElem.value = availables.options[availables.selectedIndex].value;
	
	if(selector.options.length-1 >=0)
		idx=selector.options.length-1;

	else
		idx=0
	 try {
      selector.add(newElem, selector.options[idx]); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      selector.add(newElem, idx); // IE only
    }

	availables.remove(availables.selectedIndex);

	postParams = '';

   for(j=0; j < selector.options.length; j++) { 
	   postParams += 'selection[]='+escape(selector.options[j].value)+'&'; 
	}

	postParams = postParams.substring(0,postParams.length - 1);

	selector.disabled = true;
	availables.disabled = true;

	onResponseCode = "document.getElementById('"+id+"-selector').disabled=false;document.getElementById('"+id+"-availables').disabled=false;eafwEventListener('"+id+"', null, 'update', '"+managerURL+"');";

	eafw_ajax_callURL (managerURL+'?jscmd=updateCategoryLink&id='+id, postParams, 'post', onResponseCode);

//	eafw_ajax_FAjax(managerURL+'?jscmd=updateCategoryLink&id='+id, id+"-container", postParams, 'post', 'guardando...', null);

	return true;


}

function eafwUpdateMultiSelectDel(id, managerURL){

	selector = document.getElementById(id+'-selector');
	availables = document.getElementById(id+'-availables');

	if(selector.selectedIndex == undefined || selector.selectedIndex == -1){
		return true;
	}
	newElem = document.createElement('option');

	newElem.text = selector.options[selector.selectedIndex].text;
	newElem.value = selector.options[selector.selectedIndex].value;

	if(availables.options.length-1 >=0)
		idx=availables.options.length-1;
	else
		idx=0

	 try {
      availables.add(newElem, availables.options[idx]); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      availables.add(newElem, idx); // IE only
    }

	selector.remove(selector.selectedIndex);

	postParams = '';

   for(j=0; j < selector.options.length; j++) { 
	   postParams += 'selection[]='+escape(selector.options[j].value)+'&'; 
	}

	postParams = postParams.substring(0,postParams.length - 1);

	selector.disabled = true;
	availables.disabled = true;

	onResponseCode = "document.getElementById('"+id+"-selector').disabled=false;document.getElementById('"+id+"-availables').disabled=false;eafwEventListener('"+id+"', null, 'update', '"+managerURL+"');";

	eafw_ajax_callURL (managerURL+'?jscmd=updateCategoryLink&id='+id, postParams, 'post', onResponseCode);



//	eafw_ajax_FAjax(managerURL+'?jscmd=updateCategoryLink&id='+id, id+"-container", postParams, 'post', 'guardando...', null);

	return true;


}

function eafwConfirmationMessage(okButtonHTML, koButtonHTML, msgHTML, width, height){

		eafwLoadPopupWindow(width, height);
		popup = document.getElementById('eafw_popupWindow');
		popup.innerHTML = '<div id=\"eafwConfirmationMsgPopup\"><p>'+msgHTML+'</p><ul><li>'+okButtonHTML+'</li><li>'+koButtonHTML+'</li></ul></div>';
		return true;
}

function eafwSaveCategoryLink(id, managerURL){


	selector = document.getElementById(id+'-selector');

	postParams = '';
	if(selector.selectedIndex != undefined && selector.selectedIndex != -1){
	   for(j=0; j < selector.options.length; j++) { 
	      if(selector.options[j].selected == true && selector.options[j].value != '---') {
	         postParams += 'selection[]='+escape(selector.options[j].value)+'&'; 
	}}}

	postParams = postParams.substring(0,postParams.length - 1);

	if(postParams == ''){
		return true;
	}

	selector.disabled = true;

	onResponseCode = "document.getElementById('"+id+"-selector').disabled=false;eafwEventListener('"+id+"', null, 'update', '"+managerURL+"');";

//	eafw_ajax_callURL (managerURL+'?jscmd=updateCategoryLink&id='+id, postParams, 'post', onResponseCode);
	eafw_ajax_FAjax(managerURL+'?jscmd=updateCategoryLink&id='+id, id+"-container", postParams, 'post', 'guardando...', onResponseCode);

	return true;




	postParams = '';
	if(selector.selectedIndex != undefined && selector.selectedIndex != -1){
	   for(j=0; j < selector.options.length; j++) { 
	      if(selector.options[j].selected == true) {
	         postParams += 'selection[]='+escape(selector.options[j].value)+'&'; 
	}}}

	postParams = postParams.substring(0,postParams.length - 1);

	eafw_ajax_FAjax(managerURL+'?jscmd=updateCategoryLink&id='+id, id+"-container", postParams, 'post', 'guardando...');

	return true;
}

function eafwLdSubCategories(sid, catID, managerURL){

	eafw_ajax_FAjax(managerURL+'?jscmd=ldsubcats&sid='+sid+'&catID='+catID, 'eafwCatsSession', '', 'get', 'Recargando...', null);
	return ;


}

function eafwCatMoveUp(sid, catID, managerURL){
	eafw_ajax_FAjax(managerURL+'?jscmd=moveup&sid='+sid+'&catID='+catID, 'eafwCatsSession', '', 'get', 'Recargando...', null);
	return ;

}

function eafwCatMoveDown(sid, catID, managerURL){
	eafw_ajax_FAjax(managerURL+'?jscmd=movedown&sid='+sid+'&catID='+catID, 'eafwCatsSession', '', 'get', 'Recargando...', null);
	return ;
}


function eafwCatDelete(sid, catID, managerURL, opConfirm){

	if(opConfirm == 0){
		eafwConfirmationMessage('<div class="eafwAdminButton1" onclick="eafwCatDelete(\''+sid+'\', \''+catID+'\', \''+managerURL+'\', 1);">aceptar</div>', '<div class="eafwAdminButton1" onclick="eafwClosePopupWindow();">cancelar</div>', 'Confirme que desea eliminar esta categoría', 300, 100);
	}else{
		eafwAnimatedHeightDeleteElem('eafwCatsItem-'+sid+'-'+catID);
		eafwClosePopupWindow()
		url = managerURL+'?jscmd=delete&sid='+sid+'&catID='+catID+'&conf=1';
		eafw_ajax_FAjax(url, 'eafwCatsSession', '', 'get', 'cargando...', null);
	}
	return;

}

function eafwCatAdd(sid, managerURL){
	url = managerURL+'?jscmd=add&sid='+sid;
	eafw_ajax_FAjax(url, 'eafwCatsSession', '', 'get', 'cargando...', null);
	return;
}

function eafwExpandCatalogItem(id, managerURL, parentForm, catalogName){
	eafw_ajax_FAjax(managerURL+'?jscmd=expanditem&id='+id+'&parentform='+parentForm, 'eafwCatalogItem-'+catalogName+'-'+id, '', 'get', 'cargando...', null);
	return;
}

function eafwCollapseCatalogItem(id, managerURL, parentForm, catalogName){
	container = document.getElementById('eafwCatalogItem-'+id);
	eafw_ajax_FAjax(managerURL+'?jscmd=collapseitem&id='+id+'&parentform='+parentForm, 'eafwCatalogItem-'+catalogName+'-'+id, '', 'get', 'cargando...', null);
	return;
}

function eafwCatalogAddItem(managerURL, parentForm, catalogName){
	url = managerURL+'?jscmd=add&parentform='+parentForm;
	eafw_ajax_FAjax(url, 'eafwCatalogSession-'+catalogName+'-'+parentForm, '', 'get', 'cargando...', null);
	return;
}



function eafwCatalogDelItem(id, managerURL, parentForm, catalogName, opConfirm){

	if(opConfirm == 0){
		eafwConfirmationMessage('<div class="eafwAdminButton1" onclick="eafwCatalogDelItem(\''+id+'\', \''+managerURL+'\', \''+parentForm+'\', \''+catalogName+'\', 1);">aceptar</div>', '<div class="eafwAdminButton1" onclick="eafwClosePopupWindow();">cancelar</div>', 'Confirme que desea eliminar este item', 300, 100);
	}else{
//		eafwAnimatedHeightDeleteElem('eafwCatalogItem-'+id);
		eafwClosePopupWindow()
		url = managerURL+'?jscmd=del&id='+id+'&parentform='+parentForm+'&conf=1';
		eafw_ajax_FAjax(url, 'eafwCatalogSession-'+catalogName+'-'+parentForm, '', 'get', 'cargando...', null);
	}
	return;
}


function eafwExpandUsersAdminItem(id, managerURL){
	container = document.getElementById('eafwUsersAdminItem-'+id);
	eafw_ajax_FAjax(managerURL+'?jscmd=expanditem&id='+id, 'eafwUsersAdminItem-'+id, '', 'get', 'cargando...', null);
	return;
}

function eafwCollapseUsersAdminItem(id, managerURL){
	container = document.getElementById('eafwUsersAdminItem-'+id);
	eafw_ajax_FAjax(managerURL+'?jscmd=collapseitem&id='+id, 'eafwUsersAdminItem-'+id, '', 'get', 'cargando...', null);
	return;
}

function eafwUsersAdminAddItem(managerURL){
	url = managerURL+'?jscmd=add';
	eafw_ajax_FAjax(url, 'eafw_admintool_contents', '', 'get', 'cargando...', null);
	return;
}

function eafwGroupsAdminAddItem(managerURL){
	url = managerURL+'?jscmd=add';
	eafw_ajax_FAjax(url, 'eafw_admintool_contents', '', 'get', 'cargando...', null);
	return;
}



function eafwUsersAdminDelItem(id, managerURL, opConfirm){
	if(opConfirm == 0){
		eafwConfirmationMessage('<div class="eafwAdminButton1" onclick="eafwUsersAdminDelItem(\''+id+'\', \''+managerURL+'\', 1);">aceptar</div>', '<div class="eafwAdminButton1" onclick="eafwClosePopupWindow();">cancelar</div>', 'Confirme que desea eliminar el usuario', 300, 100);
	}else{
		eafwAnimatedHeightDeleteElem('eafwUsersAdminItem-'+id);
		eafwClosePopupWindow()
		url = managerURL+'?jscmd=del&id='+id+'&conf=1';
		eafw_ajax_FAjax(url, 'eafw_admintool_contents', '', 'get', 'cargando...', null);
	}
	return;
}

function eafwGroupsAdminDelItem(id, managerURL, opConfirm){
	if(opConfirm == 0){
		eafwConfirmationMessage('<div class="eafwAdminButton1" onclick="eafwGroupsAdminDelItem(\''+id+'\', \''+managerURL+'\', 1);">aceptar</div>', '<div class="eafwAdminButton1" onclick="eafwClosePopupWindow();">cancelar</div>', 'Confirme que desea eliminar el grupo', 300, 100);
	}else{
		eafwAnimatedHeightDeleteElem('eafwGroupsAdminItem-'+id);
		eafwClosePopupWindow()
		url = managerURL+'?jscmd=del&id='+id+'&conf=1';
		eafw_ajax_FAjax(url, 'eafw_admintool_contents', '', 'get', 'cargando...', null);
	}
	return;
}


function eafwEditLabel(id, managerURL){
	container = document.getElementById(id+'-container');

	label = document.getElementById(id);

	label.innerHTML = label.innerHTML.replace(/'/g, '"');

	container.innerHTML = '<input class=\"eafwEditableLabel\" type=text name="eafwEditableLabel" id="'+id+'-input" onchange="eafwSaveLabel(\''+id+'\', \''+managerURL+'\')" onblur="eafwSaveLabel(\''+id+'\', \''+managerURL+'\')" value=\''+label.innerHTML+'\'>';

	inputfield = document.getElementById(id+'-input');
	inputfield.focus();

	return true;
}

function eafwEditPassword(id, managerURL){
	container = document.getElementById(id+'-container');

	origHTML = container.innerHTML;


	container.innerHTML = "<div class=\"eafwFormsPassword-container\" id=\""+id+"-container\"><input type=hidden id=\""+id+"-oldvalue\" name=\""+id+"-oldvalue\" value=\"\"><input type=password name=\""+id+"\" id=\""+id+"-input\" value=\"\" onfocus=\"document.getElementById('"+id+"-errmsg').innerHTML = 'introduzca la contraseña';document.getElementById('"+id+"-input-verify').value='';\" onchange=\"document.getElementById('"+id+"-input-verify').focus();\"><input type=password name=\""+id+"-verif\" id=\""+id+"-input-verify\" onchange=\"eafwSavePassword('"+id+"', '"+managerURL+"');\" onfocus=\"document.getElementById('"+id+"-errmsg').innerHTML = 'verifique la contraseña';\" value=\"\"><div id=\""+id+"-errmsg\" class=\"eafwErrorAlert\">$errMsg</div>";

	inputfield = document.getElementById(id+'-input');
	inputfield.focus();

	return true;
}


function eafwInitPasswordUpdateForm(id, managerURL){

	if(document.getElementById(id+'-errmsg').innerHTML == ''){
		document.getElementById(id+'-container').innerHTML = "<div class=\"eafwFormsPassword-container\" id=\""+id+"-container\"><div class=\"eafwEditableLabel\" onclick=\"eafwEditPassword('"+id+"', '"+managerURL+"');\">Cambiar contraseña</div></div>";
	}

	return true;
}


function eafwDisplayImageToolbar(id, managerURL){

	toolbar = document.getElementById(id+'-toolbar');
	toolbar.style.visibility='visible';

}

function eafwHideImageToolbar(id, managerURL){

	toolbar = document.getElementById(id+'-toolbar');
	toolbar.style.visibility='hidden';
//	toolbar.style.display='none';
	

}

function eafwCatalogImageSetup(id, height, width, managerURL){
	alert("setup id");
	container = document.getElementById(id+'-container');
	container.style.width = width+'px';

}



function eafwInitUploadImage(id, managerURL){

	// Carga la ventana donde se ejecuta el comando
	eafwLoadPopupWindow('400', '150');

	// Hace la solicitud al servidor
	url = managerURL+'?jscmd=uploadimgform&id='+id;
	popup = document.getElementById('eafw_popupWindow');

	popup.innerHTML = "<div class=\"eafwUploadImgDialog\"><div class=\"eafwPopupFloatCloseButton\" onclick=\"eafwClosePopupWindow();\"><img src=\""+eafwBaseURL+"/eafwimg/application-exit.png\"></div><iframe src=\""+url+"\"></iframe></div>";

//	eafw_ajax_FAjax(url, 'eafw_popupWindow', '', 'get', '', null);
	
	return;
}

function eafwUploadCatalogImage(){
	eafwClosePopupWindow();
	return;
}

function eafwImageZoom(imageUrl, width, height){
	eafwLoadPopupWindow(parseInt(width)+2, parseInt(height)+100);
	popup = document.getElementById('eafw_popupWindow');
	popup.innerHTML = "<div id=\"eafwZoomImagePopup\"><div class=\"eafwPopupFloatCloseButton\" onclick=\"eafwClosePopupWindow();\"><img src=\""+eafwBaseURL+"/eafwimg/application-exit.png\"></div><img src=\""+imageUrl+"\"></div>";
//	document.getElementById('eafwZoomImagePopup').style.width = width+'px';
//	document.getElementById('eafwZoomImagePopup').style.height = parseInt(height)+'px';
	return;
}

function eafwInitUploadVideo(id, managerURL){

	// Carga la ventana donde se ejecuta el comando
	eafwLoadPopupWindow('400', '150');

	// Hace la solicitud al servidor
	url = managerURL+'?jscmd=uploadvideoform&id='+id;
	popup = document.getElementById('eafw_popupWindow');

	popup.innerHTML = "<div class=\"eafwUploadImgDialog\"><div class=\"eafwPopupFloatCloseButton\" onclick=\"eafwClosePopupWindow();\"><img src=\""+eafwBaseURL+"/eafwimg/application-exit.png\"></div><iframe src=\""+url+"\"></iframe></div>";

//	eafw_ajax_FAjax(url, 'eafw_popupWindow', '', 'get', '', null);
	
	return;
}


function eafwInitUploadDocument(id, managerURL){

	// Carga la ventana donde se ejecuta el comando
	eafwLoadPopupWindow('400', '150');

	// Hace la solicitud al servidor
	url = managerURL+'?jscmd=uploaddocform&id='+id;
	popup = document.getElementById('eafw_popupWindow');

	popup.innerHTML = "<div class=\"eafwUploadDocDialog\"><div class=\"eafwPopupFloatCloseButton\" onclick=\"eafwClosePopupWindow();\"><img src=\""+eafwBaseURL+"/eafwimg/application-exit.png\"></div><iframe src=\""+url+"\"></iframe></div>";

//	eafw_ajax_FAjax(url, 'eafw_popupWindow', '', 'get', '', null);
	
	return;
}


function eafwEditTextArea(id, managerURL){
	container = document.getElementById(id+'-container');
	textArea = document.getElementById(id);
	width = textArea.offsetWidth;
	height = textArea.offsetHeight;
	container.innerHTML = '<input type=hidden id="'+id+'-oldvalue" name="'+id+'-oldvalue" value="'+textArea.innerHTML+'"><textarea class=\"eafwEditableTextArea\" name="eafwEditableTextArea" id="'+id+'-input" onchange="eafwSaveTextArea(\''+id+'\', \''+managerURL+'\')" onblur="eafwSaveTextArea(\''+id+'\', \''+managerURL+'\')">'+textArea.innerHTML.replace(/\<br\>/ig, "\n")+'</textarea>';

	document.getElementById(id+'-input').style.width = parseInt(width-8)+'px';
	document.getElementById(id+'-input').style.height = parseInt(height-8)+'px';

	inputfield = document.getElementById(id+'-input');
	inputfield.focus();

	return true;
}

function eafwEditRTArticle(id, url, container){
	eafwLoadPopupWindow(null, null);
	popup = document.getElementById('eafw_popupWindow');


	// El código del onResponseCode sirve para que los menús de estilos, tamaños de letra, etc... no tengan position= "absolute".

	eafw_ajax_FAjax(url, 'eafw_popupWindow', '', 'get', 'iniciando editor...', null);
	return true;
}

function eafwViewRTArticle(id, url, container){
	eafwLoadPopupWindow(null, null);
	popup = document.getElementById('eafw_popupWindow');
	eafw_ajax_FAjax(url, 'eafw_popupWindow', '', 'get', 'iniciando editor...', null);
	return true;
}

function eafwPostRTArticle(DocumentID, url, dbconn, container){
		
	var ref = FCKeditorAPI.GetInstance(DocumentID);
	var contents = encodeURIComponent(ref.GetXHTML());
	eafw_ajax_FAjax(url, container, 'DocumentID='+DocumentID+'&editorDBconnector='+dbconn+'&'+DocumentID+'='+contents, 'post', 'guardando artículo...', null);
	return true;
}

/* Gallery */

function eafwZoomInGalleryThumb(id, managerURL, parentForm, width, height, galleryName, container){
	itemFrame = document.getElementById('eafwGalleryItem-gallery-'+id);
	itemFrame.style.zindex=3;
	container.childNodes[0].style.height = 2*height+'pt';
	container.childNodes[0].style.width = 2*width+'pt';
}

function eafwZoomOutGalleryThumb(id, managerURL, parentForm, width, height, galleryName, container){
	itemFrame = document.getElementById('eafwGalleryItem-'+galleryName+'-'+id);
	itemFrame.style.zindex=0;
	container.childNodes[0].style.height = height+'pt';
	container.childNodes[0].style.width = width+'pt';
}

function eafwExpandGalleryItem(id, managerURL, parentForm, galleryName){
	itemFrame = document.getElementById('eafwGalleryItem-'+galleryName+'-'+parentForm);
	itemFrame.style.zindex=10;
	itemFrame.style.visibility="visible";
	itemFrame.style.display="block";
	eafw_ajax_FAjax(managerURL+'?jscmd=expanditem&id='+id+'&parentform='+parentForm, 'eafwGalleryItem-'+galleryName+'-'+parentForm, '', 'get', 'cargando...', null);
	return;
}

function eafwCollapseGalleryItem(id, managerURL, parentForm, galleryName){
	itemFrame = document.getElementById('eafwGalleryItem-'+galleryName+'-'+parentForm);
	itemFrame.style.zindex=0;
	itemFrame.style.visibility="hidden";
	itemFrame.style.display="none";

//	container = document.getElementById('eafwGalleryItem-'+id);
//	eafw_ajax_FAjax(managerURL+'?jscmd=collapseitem&id='+id+'&parentform='+parentForm, 'eafwGalleryItem-'+galleryName+'-'+id, '', 'get', 'cargando...', null);
	return;
}

function eafwGalleryAddItem(managerURL, parentForm, galleryName){
	url = managerURL+'?jscmd=add&parentform='+parentForm;
	eafw_ajax_FAjax(url, 'eafwGallerySession-'+galleryName+'-'+parentForm, '', 'get', 'cargando...', null);
	return;
}

function eafwGalleryInitUploader(managerURL, parentForm, galleryName){
	url = managerURL+'?jscmd=uploader&parentform='+parentForm;
	eafw_ajax_FAjax(url, 'eafwGallerySession-'+galleryName+'-'+parentForm, '', 'get', 'cargando...', null);
	return;
}



function eafwGalleryCloseUploader(managerURL, parentForm, galleryName){
	url = managerURL+'?jscmd=closeuploader&parentform='+parentForm;
	eafw_ajax_FAjax(url, 'eafwGallerySession-'+galleryName+'-'+parentForm, '', 'get', 'cargando...', null);
	return;
}

/* Gallery Uploader Functions */

function uploaderSelectionChanged( uploader ) {
	dumpFileAttributes();
}	
	
			
/*function appletInitialized(applet){
	alert();
//	eval("var gallerySession-'.$conf['galleryName'].'-'.$conf['parentForm'].'-fileNum = 0;");
}
*/
/*
function uploaderStatusChanged( uploader, file ) {
//		traceEvent( "uploaderFileStatusChanged, index=" + file.getIndex() + ", status=" + file.getStatus() + ", content=" + file.getResponseContent() );
}
*/

/*				
function uploaderFileAdded( uploader, file ){
	eval("gallerySession-'.$conf['galleryName'].'-'.$conf['parentForm'].'-fileNum++;");
//	fileNum++;
}

function uploaderFileRemoved( uploader, file){
	eval("gallerySession-'.$conf['galleryName'].'-'.$conf['parentForm'].'-fileNum--;");
//	fileNum--;
}

function closeJumpLoader(uploader){
				
	eval("fileNum = gallerySession-'.$conf['galleryName'].'-'.$conf['parentForm'].'-fileNum++;");

	if(fileNum > 0 ){
		alert("Quedan archivos pendientes de publicar. Cancele su publicación o elimínemlos de la lista antes de cerrar esta ventana");
		return false;
	}else{
		alert("cerrar ventana");
		return true;
	}
}

*/
function eafwGalleryDelItem(id, managerURL, parentForm, galleryName, opConfirm){

	if(opConfirm == 0){
		eafwConfirmationMessage('<div class="eafwAdminButton1" onclick="eafwGalleryDelItem(\''+id+'\', \''+managerURL+'\', \''+parentForm+'\', \''+galleryName+'\', 1);">aceptar</div>', '<div class="eafwAdminButton1" onclick="eafwClosePopupWindow();">cancelar</div>', 'Confirme que desea eliminar este item', 300, 100);
	}else{
//		eafwAnimatedHeightDeleteElem('eafwCatalogItem-'+id);
		eafwClosePopupWindow()
		url = managerURL+'?jscmd=del&id='+id+'&parentform='+parentForm+'&conf=1';
		eafw_ajax_FAjax(url, 'eafwGallerySession-'+galleryName+'-'+parentForm, '', 'get', 'cargando...', null);
	}
	return;
}


/* Funciones del módulo sc (carrito de la compra) */

function eafwSCAddItem(id, driver, managerURL, parentForm){

	url = managerURL+'?jscmd=additem&id='+id+'&scdrv='+driver+'&parentform='+parentForm;
	eafw_ajax_FAjax(url, 'eafwForm-'+id, '', 'get', 'Por favor, espere...', null);


	return;
}

function eafwSCAddSelectionItem(id, scdriver, managerURL, parentForm){

	// alert(CSSContainer);

//	container = document.getElementById('eafwForm-'+id);

	eafwConfirmationMessage('', '', 'Por favor, espere...', 300, 100);
	url = managerURL+'?jscmd=additem&id='+id+'&scdrv='+scdriver;
	eafw_ajax_FAjax(url, 'eafwConfirmationMsgPopup', '', 'get', 'cargando...', null);


	return;
}

function eafwLoadScLinkForm(id, driver, managerURL, parentForm){

	url = managerURL+'?jscmd=ldsclinkform&id='+id+'&scdrv='+driver+'&parentform='+parentForm;
	eafw_ajax_FAjax(url, 'eafwScLinkForm-'+parentForm, '', 'get', 'Por favor, espere...', null);

	return;
}

function eafwSCDelItem(itemId, scdriver, managerURL, CSSContainer){

	container = document.getElementById(CSSContainer);

//	eafwConfirmationMessage('', '', 'Por favor, espere...', 300, 100);
	url = managerURL+'?jscmd=delitem&itemid='+itemId+'&scdrv='+scdriver+'&qty=1';
	eafw_ajax_FAjax(url, CSSContainer, '', 'get', 'cargando...', null);

	return;
}

function eafwSCUpdateShippingCosts(shippingMethod, scdriver, managerURL, CSSContainer){


	url = managerURL+'?jscmd=updateshippingmethod&shipm='+shippingMethod;

	eafw_ajax_FAjax(url, CSSContainer, '', 'get', 'cargando...', null);

	return;
}


function eafwSCQtyUpdate(itemId, scdriver, managerURL, CSSContainer){
	
	qtyInput = document.getElementById('eafwScItemQty-'+itemId);

	qty = qtyInput.value;

	url = managerURL+'?jscmd=setqty&itemid='+itemId+'&qty='+qty+'&scdrv='+scdriver;

	eafw_ajax_FAjax(url, CSSContainer, '', 'get', 'cargando...', null);

	return;
}

function eafwSCQtyUp(itemId, scdriver, managerURL, CSSContainer){

	container = document.getElementById(CSSContainer);

//	eafwConfirmationMessage('', '', 'Por favor, espere...', 300, 100);
	url = managerURL+'?jscmd=qtyup&itemid='+itemId+'&scdrv='+scdriver;
	eafw_ajax_FAjax(url, CSSContainer, '', 'get', 'cargando...', null);

	return;
}

function eafwSCQtyDown(itemId, scdriver, managerURL, CSSContainer){

	container = document.getElementById(CSSContainer);

//	eafwConfirmationMessage('', '', 'Por favor, espere...', 300, 100);
	url = managerURL+'?jscmd=qtydown&itemid='+itemId+'&scdrv='+scdriver;
	eafw_ajax_FAjax(url, CSSContainer, '', 'get', 'cargando...', null);

	return;
}

/* Funciones del gestor de pedidos */

function eafwExpandOrderManagerItem(id, managerURL, parentForm){
	eafw_ajax_FAjax(managerURL+'?jscmd=expanditem&id='+id+'&parentform='+parentForm, 'eafwOrderManagerItem-order-'+id, '', 'get', 'cargando...', null);
	return;
}

function eafwCollapseOrderManagerItem(id, managerURL, parentForm){
	container = document.getElementById('eafwOrderManagerItem-'+id);
	eafw_ajax_FAjax(managerURL+'?jscmd=collapseitem&id='+id+'&parentform='+parentForm, 'eafwOrderManagerItem-order-'+id, '', 'get', 'cargando...', null);
	return;
}


function eafwOrderManagerDelItem(id, managerURL, parentForm, opConfirm){

	if(opConfirm == 0){
		eafwConfirmationMessage('<div class="eafwAdminButton1" onclick="eafwOrderManagerDelItem(\''+id+'\', \''+managerURL+'\', \''+parentForm+'\', 1);">aceptar</div>', '<div class="eafwAdminButton1"  onclick="eafwClosePopupWindow();">cancelar</div>', 'Confirme que desea eliminar este item', 300, 100);
	}else{
//		eafwAnimatedHeightDeleteElem('eafwCatalogItem-'+id);
		eafwClosePopupWindow()
		url = managerURL+'?jscmd=del&id='+id+'&parentform='+parentForm+'&conf=1';
		eafw_ajax_FAjax(url, 'eafwOrderManagerSession-order-'+parentForm, '', 'get', 'cargando...', null);
	}
	return;
}


/* window.onload=init_product_info; */


// 



var eafwStackableContents = new Array();
	

function eafwStackableContentsMenuItemListener(e){
//	link = this;

	e['target']?link = e['target']:link=e['srcElement'];

	eafwAddStackableContent(link.id);
	eafwCollapseFloatingMenu();

	if (e.preventDefault) {
		e.preventDefault();
	}else

	return false;

}

function eafwAddStackableContent(linkID){

	link = document.getElementById(linkID);
	linkParts = link.id.split("---");
	targetID = eafwStackableContents[linkParts[0]]['targetID'];

	var stackableContentsElem = new Array();

	stackableContentsElem['id'] = link.id;
	stackableContentsElem['status'] = 'expanded';

	var noadd = 0;

	for(var i=0;i<eafwStackableContents[linkParts[0]]['contents'].length;i++){
		if(eafwStackableContents[linkParts[0]]['contents'][i]['id'] == stackableContentsElem['id']){
			noadd = 1;
		}
	}

	if(noadd == 1){
		return true;
	}

		eafwStackableContents[linkParts[0]]['contents'][eafwStackableContents[linkParts[0]]['contents'].length] = stackableContentsElem;


	container = document.getElementById(targetID);
	contentFrame = document.createElement("div");
	contentFrame.id = link.id+'-casilla';
	contentFrame.className = 'casilla';
	container.insertBefore(contentFrame, container.firstChild);

//	contentFrame.innerHTML = link.id+" / "+link.innerHTML+" ("+link.href+")";

	eafwInsertStackableContentsLinks(link.id+'-related')

	url = link.href+'?reload=0';
	eafw_ajax_FAjax(url, link.id+'-casilla', '', 'get', 'cargando...', null);

	return true;

}


function eafwInsertIntoStack(linkID){

	link = document.getElementById(linkID);
	linkParts = link.id.split("---");
	targetID = eafwStackableContents[linkParts[0]]['targetID'];

	var stackableContentsElem = new Array();

	stackableContentsElem['id'] = link.id;
	stackableContentsElem['status'] = 'expanded';
	eafwStackableContents[linkParts[0]]['contents'][eafwStackableContents[linkParts[0]]['contents'].length] = stackableContentsElem;


	return true;

}

function eafwStackableContentsToggle(contentID, elem, event){

	menuID = contentID.split("---")[0];

	for(var i=0; i<eafwStackableContents[menuID]['contents'].length; i++){
		if(contentID==eafwStackableContents[menuID]['contents'][i]['id']){
			var idx = i;

		}
	}


	if(elem.innerHTML == 'minimizar'){
		elem.innerHTML = 'maximizar';
		document.getElementById(contentID+'-contents').style.visibility = 'hidden';
		document.getElementById(contentID+'-contents').style.display = 'none';
		eafwStackableContents[menuID]['contents'][idx]['status'] = 'collapsed';
	}else{
		elem.innerHTML = 'minimizar';
		document.getElementById(contentID+'-contents').style.visibility = 'visible';
		document.getElementById(contentID+'-contents').style.display = 'block';
		eafwStackableContents[menuID]['contents'][idx]['status'] = 'expanded';
	}
	
	eafw_ajax_callURL (elem.href+'&reload=0', '', 'get', null);

	if (event.preventDefault) {
		event.preventDefault();
	}

	return false;
	
}


function eafwStackableContentsToggleRelatedLinks(contentID, elem, event){

	menuID = contentID.split("---")[0];


	if(elem.innerHTML == '- info'){
		elem.innerHTML = '+ info';
		document.getElementById(contentID+'-related').style.visibility = 'hidden';
		document.getElementById(contentID+'-related').style.display = 'none';
	}else{
		elem.innerHTML = '- info';
		document.getElementById(contentID+'-related').style.visibility = 'visible';
		document.getElementById(contentID+'-related').style.display = 'block';
	}
	

	if (event.preventDefault) {
		event.preventDefault();
	}

	return false;
	
}

function eafwStackableContentsClose(contentID, elem, event){

	menuID = contentID.split("---")[0];

	for(var i=0; i<eafwStackableContents[menuID]['contents'].length; i++){
		if(contentID==eafwStackableContents[menuID]['contents'][i]['id']){
			eafwStackableContents[menuID]['contents'].splice(i,1);
		}
	}

	eafw_ajax_callURL (elem.href+'&reload=0', '', 'get', null);

	container = document.getElementById(contentID+'-casilla').parentNode;
	container.removeChild(document.getElementById(contentID+'-casilla'));

	if (event.preventDefault) {
		event.preventDefault();
	}else{
		return false;
	}
}


function eafwStartStackableContents(menuID, targetID){

	
	stackInfo = new Array();
	stackInfo['targetID'] = targetID;
	stackInfo['contents'] = new Array();

	eafwStackableContents[menuID] = stackInfo;

	menu = document.getElementById(menuID);
	
	links = menu.getElementsByTagName('A');


	for(i=0;i<links.length;i++){		
		if(links[i].className != 'nostackable'){
			if(links[i].addEventListener){
				links[i].addEventListener("click", eafwStackableContentsMenuItemListener, false); 
			}else{
				links[i].attachEvent("onclick", eafwStackableContentsMenuItemListener); 
			}
			linkParts = links[i].href.split("/");
			links[i].id = menuID+"---"+linkParts[linkParts.length-1]
		}
	}

	return true;
}

function eafwInsertStackableContentsLinks(containerID){

	container = document.getElementById(containerID);
	
	if(!container){
		return false;
	}

	links = container.getElementsByTagName('A');

	for(i=0;i<links.length;i++){		
		if(links[i].className != 'nostackable'){
			if(links[i].addEventListener){
				links[i].addEventListener("click", eafwStackableContentsMenuItemListener, false); 
			}else{
				links[i].attachEvent("onclick", eafwStackableContentsMenuItemListener); 
			}
			linkParts = links[i].href.split("/");
			menuID = links[i].id.split("---")[0];
			links[i].id = menuID+"---"+linkParts[linkParts.length-1]
		}
	}

	return true;

}


function eafwStartFloatingSubmenu(menuID){

	menu = document.getElementById(menuID);
	submenus = menu.getElementsByTagName('UL');

	for(var i=0; i<submenus.length; i++){

		if(submenus[i].className == 'submenu_sup2'){
			if(submenus[i].parentNode.addEventListener){
				submenus[i].parentNode.addEventListener("click", eafwToggleFloatingMenu, true);
			}else{
				submenus[i].parentNode.attachEvent("onclick", eafwToggleFloatingMenu);
			}
		}
	}

	return true;
}

function eafwCollapseFloatingMenu(){
	parentMenu = document.getElementById('menu_sup');
	ulchilds = parentMenu.getElementsByTagName('ul');

	for(var i=0;i<ulchilds.length;i++){
		if(ulchilds[i].className == 'submenu_sup2'){
			ulchilds[i].style.visibility = 'hidden';
			ulchilds[i].style.display = 'block';
		}
	}

	return true;
}

function eafwToggleFloatingMenu(e){

	e['target']?targetElem = e['target']:targetElem=e['srcElement'];

	submenus =	targetElem.parentNode.childNodes;

	for(var i=0;i<submenus.length;i++){
		if(submenus[i].className == 'submenu_sup2'){
			if(submenus[i].style.visibility == 'visible'){
				eafwCollapseFloatingMenu();
				submenus[i].style.visibility = 'hidden';
				submenus[i].style.display = 'none';
			}else{
				eafwCollapseFloatingMenu();
				submenus[i].style.visibility = 'visible';
				submenus[i].style.display = 'block';
			}
		}
	}
}

function eafwSendNewsLetter(id, managerURL){

	// Carga la ventana donde se ejecuta el comando
	eafwLoadPopupWindow('400', '150');
	// Hace la solicitud al servidor
	url = managerURL+'?jscmd=send&id='+id;
	popup = document.getElementById('eafw_popupWindow');

	html = "<img src=\""+eafwBaseURL+"/eafwimg/ajax-loader.gif\">";
//	html = "enviando newsletter";

//	popup.innerHTML = "<div class=\"eafwSendNewsLetterDialog\"><iframe src=\""+url+"\"></iframe></div>";

	popup.innerHTML = html;

	rcode = "popup = document.getElementById('eafw_popupWindow');popup.innerHTML = '<div id=\"eafwNewsLetterSendConfirmationMsgPopup\"><span style=\"color:#000000;font-size:9pt;font-weight:bold;\">newsletter enviado</span><div class=\"eafwAdminButton1\" onclick=\"eafwClosePopupWindow()\">cerrar</div></div>'";

	eafw_ajax_callURL(url, '', 'get', rcode);
//	eafw_ajax_FAjax(url, 'eafw_popupWindow', '', 'get', '', null);
	
	return;
}


function firstClickActions(){

	
	if(fcahomebanner){
		eafw_ajax_FAjax(fcaurl+"/homebanner/", 'cabecera_idx', '', 'get', '', null);
	}

	botonInicio = document.getElementById('boton_inicio');
	botonInicio.style.visibility = 'visible';

	if(document.body.removeEventListener){
		document.body.removeEventListener("click", firstClickActions, false); 
	}else{
		document.body.detachEvent("onclick", firstClickActions); 
	}
	
}

function FCASetup(url, homebanner){
//	setTimeout('updateBanner(\''+url+'\')', 30000);
	botonInicio = document.getElementById('boton_inicio');
	botonInicio.style.visibility = 'hidden';
	if(document.body.addEventListener){
		document.body.addEventListener("click", firstClickActions, false); 
	}else{
		document.body.attachEvent("onclick", firstClickActions); 
	}

	return true;
}









