
/* This functions are used to load a portlet in a parent porltetset with controller card 
if this portletset has a hidden ProxyPortlet where it can load the new portlet.
If there are not a portletset with controller card and a hidden ProxyPortlet, the portlet loads maximized.
*/

CardProxyUrls = new Array ();						
CardProxyNames = new Array ();	
CurrentCard = -1; //Marca el la posicion del array que contiene el card con el proxy oculto activo.
	
function loadCardProxy (portlet,position,extraname,extravalue,extraname1,extravalue1,extraname2,extravalue2){
	if (position >= 0 && position < CardProxyUrls.length)
	{
		document.forms.LoadCardProxy.elements[0].name= CardProxyNames[position]+'.target';
		document.forms.LoadCardProxy.elements[0].value= portlet;
		document.forms.LoadCardProxy.action = CardProxyUrls[position];
		if (extraname != ''){
			document.forms.LoadCardProxy.elements[1].name= extraname;
			document.forms.LoadCardProxy.elements[1].value= extravalue;			
		}
		if (extraname1 != ''){
			document.forms.LoadCardProxy.elements[2].name= extraname1;
			document.forms.LoadCardProxy.elements[2].value= extravalue1;
		}
		if (extraname2 != ''){
			document.forms.LoadCardProxy.elements[3].name= extraname2;
			document.forms.LoadCardProxy.elements[3].value= extravalue2;
		}
		document.forms.LoadCardProxy.submit ();
	} else {
		document.forms.LoadCardProxy.elements[0].name= 'portlet';
		document.forms.LoadCardProxy.elements[0].value= portlet;	
		urlAction = "";
		/* Home is declarated in head of the page */
		if (Home.indexOf (";jsessionid=") > -1){
			urlAction = Home.substring(0,Home.indexOf (";jsessionid=")) + '/portlet/' + portlet + Home.substring(Home.indexOf (";jsessionid="),Home.length);			
		} else {
			urlAction = Home + '/portlet/' + portlet;
		}				
		document.forms.LoadCardProxy.action = urlAction; 
		if (extraname != ''){
			document.forms.LoadCardProxy.elements[1].name= extraname;
			document.forms.LoadCardProxy.elements[1].value= extravalue;			
		}
		if (extraname1 != ''){
			document.forms.LoadCardProxy.elements[2].name= extraname1;
			document.forms.LoadCardProxy.elements[2].value= extravalue1;			
		}
		document.forms.LoadCardProxy.submit ();		
	}
	return false;
}		

function getPositionCard (){
	return (CurrentCard);
}	

function mChange(elem, clase) {
	elem.className=clase;
}

function gotoSection(section){
	window.location.hash = section;
	var dir = window.location.href;
	window.location.href=dir;
}

function mostrarFicha(formulario, imageUrl, linkname, loadProxy, position){
	var dirPrincipal = imageUrl.substring(0, imageUrl.lastIndexOf("/"));
	var pegatinasDir=dirPrincipal+"/pegatinas";
	var bynDir=dirPrincipal+"/byn";
	if (loadProxy){
		if (position >= 0 && position <= CardProxyUrls.length)
		{
			formulario.elements[0].name=CardProxyNames[position]+".target";
		} else {
			formulario.elements[0].name='portlet';
			urlAction = "";
			/* Home is declarated in head of the page */
			if (Home.indexOf (";jsessionid=") > -1){
				urlAction = Home.substring(0,Home.indexOf (";jsessionid=")) + '/portlet/' + formulario.elements[0].value + Home.substring(Home.indexOf (";jsessionid="),Home.length);			
			} else {
				urlAction = Home + '/portlet/' + formulario.elements[0].value;
			}				
			formulario.action = urlAction; 
		}
	}
	formulario.elements[1].value=imageUrl;
	formulario.elements[2].value=linkname;
	formulario.elements[3].value=pegatinasDir;
	formulario.elements[4].value=bynDir;
	formulario.elements[5].value=dirPrincipal;
	
	formulario.submit();
}


