function Search(
		callback,
		callbackException,
		idApplet,
		sector,
		contributor, 
		ric,
		underlying,
		minstrike, maxstrike,  
		call_put,
		minmaturity, maxmaturity, 
		minratio, maxratio,
		isin,
		currency,
		minvolatility, maxvolatility,
		mindelta, maxdelta,
		mingamma, maxgamma,
		minrho, maxrho,
		minelasticity, maxelasticity,
		mintheta, maxtheta,
		minvega, maxvega,
		marketcode, riskfactor)
{
	this.str = "";
	if (!this.idApplet || this.idApplet =="")
	{
		this.idApplet = Search.applet;
	}else
	{
		this.idApplet = idApplet;
	}
	this.getApplet = function(doc)
	{
		if (!doc) doc = document;		
		return doc.getElementById(this.idApplet);		
	}
	this.callback = callback;
	this.callbackException = callbackException;
	if(!sector){this.sector="";}else{this.sector=sector;};
	if(!contributor){this.contributor="";}else{this.contributor=contributor;};
	if(!ric){this.ric="";}else{this.ric=ric;};
	if(!underlying){this.underlying="";}else{this.underlying=underlying;};
	if(!maxstrike){this.maxstrike="";}else{this.maxstrike=maxstrike;};
	if(!minstrike){this.minstrike="";}else{this.minstrike=minstrike;};
	if(!call_put){this.call_put="";}else{this.call_put=call_put;};
	if(!minmaturity){this.minmaturity="";}else{this.minmaturity=minmaturity;};
	if(!maxmaturity){this.maxmaturity="";}else{this.maxmaturity=maxmaturity;};
	if(!minratio){this.minratio="";}else{this.minratio=minratio;};
	if(!maxratio){this.maxratio="";}else{this.maxratio=maxratio;};
	if(!isin){this.isin="";}else{this.isin=isin;};
	if(!currency){this.currency="";}else{this.currency=currency;};
	if(!minvolatility){this.minvolatility="";}else{this.minvolatility=minvolatility;};
	if(!maxvolatility){this.maxvolatility="";}else{this.maxvolatility=maxvolatility;};
	if(!mindelta){this.mindelta="";}else{this.mindelta=mindelta;};
	if(!maxdelta){this.maxdelta="";}else{this.maxdelta=maxdelta;};
	if(!mingamma){this.mingamma="";}else{this.mingamma=mingamma;};
	if(!maxgamma){this.maxgamma="";}else{this.maxgamma=maxgamma;};
	if(!minrho){this.minrho="";}else{this.minrho=minrho;};
	if(!maxrho){this.maxrho="";}else{this.maxrho=maxrho;};
	if(!minelasticity){this.minelasticity="";}else{this.minelasticity=minelasticity;};
	if(!maxelasticity){this.maxelasticity="";}else{this.maxelasticity=maxelasticity;};
	if(!mintheta){this.mintheta="";}else{this.mintheta=mintheta;};
	if(!maxtheta){this.maxtheta="";}else{this.maxtheta=maxtheta;};
	if(!minvega){this.minvega="";}else{this.minvega=minvega;};
	if(!maxvega){this.maxvega="";}else{this.maxvega=maxvega;};
	if(!marketcode){this.marketcode="";}else{this.marketcode=marketcode;};
	if(!riskfactor){this.riskfactor="";}else{this.riskfactor=riskfactor;};
	this.clear = function()
	{
		this.sector = "";
		this.contributor = ""; 
		this.ric = "";
		this.underlying = "";
		this.minstrike = ""; this.maxstrike = "";  
		this.call_put = "";
		this.minmaturity = ""; this.maxmaturity = ""; 
		this.minratio = ""; this.maxratio = "";
		this.isin = "";
		this.currency = "";
		this.minvolatility = ""; this.maxvolatility = "";
		this.mindelta = ""; this.maxdelta = "";
		this.mingamma = ""; this.maxgamma = "";
		this.minrho = ""; this.maxrho = "";
		this.minelasticity = ""; this.maxelasticity = "";
		this.mintheta = ""; this.maxtheta = "";
		this.minvega = ""; this.maxvega = "";
		this.marketcode = ""; this.riskfactor = "";
	}
	this.search = function()
	{
		return this.getApplet().getSearch(
			this.callback, this.callbackException, 
			this.sector,
			this.contributor, 
			this.ric,
			this.underlying,
			this.minstrike, this.maxstrike,  
			this.call_put,
			this.minmaturity, this.maxmaturity, 
			this.minratio, this.maxratio,
			this.isin,
			this.currency,
			this.minvolatility, this.maxvolatility,
			this.mindelta, this.maxdelta,
			this.mingamma, this.maxgamma,
			this.minrho, this.maxrho,
			this.minelasticity, this.maxelasticity,
			this.mintheta, this.maxtheta,
			this.minvega, this.maxvega,
			this.marketcode, this.riskfactor);
	}
}

Search.applet = "WSlsApplet";

Search.getOptionList = function(idApplet, metodo, metodoExcepcion, metodoapplet)
{
	var a = parent.document.getElementById(idApplet);
	var id;
	if (metodoExcepcion)
	{
		id = eval("a."+metodoapplet+"('"+metodo+"','"+metodoExcepcion+"');");
	}
	else
	{
		id = eval("a."+metodoapplet+"('"+metodo+"');");
	}
//	alert("Lanzado metodo "+metodoapplet+ " id: "+id);
	return id;
}

Search.getSectors = function(idApplet, metodo, metodoExcepcion)
{
	return Search.getOptionList(idApplet, metodo, metodoExcepcion, "getSectors");
}
Search.defGetSectors = function()
{
	return Search.getSectors(Search.applet,"callbackSectores","exceptionCallback");
}

Search.getMaturities = function(idApplet, metodo, metodoExcepcion)
{
	return Search.getOptionList(idApplet, metodo, metodoExcepcion, "getMaturities");
}
Search.defGetMaturities = function()
{
	return Search.getMaturities(Search.applet,"callbackSectores","exceptionCallback");
}
Search.getUnderlyings = function(idApplet, metodo, metodoExcepcion)
{
	return Search.getOptionList(idApplet, metodo, metodoExcepcion, "getUnderlyings");
}
Search.defGetUnderlyings = function()
{
	return Search.getUnderlyings(Search.applet,"callbackSectores","exceptionCallback");
}

Search.getMarketCodes = function(idApplet, metodo, metodoExcepcion)
{
	return Search.getOptionList(idApplet, metodo, metodoExcepcion, "getMarketCodes");
}
Search.defGetMarketCodes = function()
{
	return Search.getMarketCodes(Search.applet,"callbackSectores","exceptionCallbackSectores");
}

function callbackSectores(key, result)
{
	key = javaHelper.var2str(key);
	result = javaHelper.var2str(result);
	alert(key + "->" + result)
};

function exceptionCallbackSectores(key, type, msg)
{
	key = javaHelper.var2str(key);
	type = javaHelper.var2str(type);
	msg = javaHelper.var2str(msg);
	if(!window.___alertservidor)
	{
		window.___alertservidor= true;
		alert("El servidor no esta disponible");	
	}
//	alert(key + "->" + type + "|" + msg)
};





