/**
 * @author Izzet Mustafayev (webdizz@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2007
 * @version 1.0
 */

function wlpConditionsAction(url,_params){
	this.url = url;
	this.params = new wlpPropertyList(_params);
};

wlpConditionsAction.prototype = new wlpAction;

wlpConditionsAction.prototype.check = function(){
	var conditionValue = this.params.get('condition');
	var checkingValue = this.params.get('value');
	if(conditionValue && checkingValue){
		if(checkingValue > conditionValue){		/*check values*/
			this.displayUnconditionMsg();
			return false;
		}else{
			var messageStr = this.params.get('message');
			return this.displayMsg(messageStr);
		}
	}
};
/**
* display message correspondent to wrang conditions
*/
wlpConditionsAction.prototype.displayUnconditionMsg = function(){
	var uncondMsg = this.params.get('wrang_msg');
	if(uncondMsg){
		alert(uncondMsg);
	}
};
/**
* show mrssage
*/
wlpConditionsAction.prototype.displayMsg = function(messageStr){
	if (messageStr){
		return window.confirm(messageStr);
	} else {
		return window.confirm("Undefined Message :)");
	}
};

function wlpConditionsAction(url,_params){this.url=url;this.params=new wlpPropertyList(_params);};wlpConditionsAction.prototype=new wlpAction;wlpConditionsAction.prototype.check=function(){var conditionValue=this.params.get('condition');var checkingValue=this.params.get('value');if(conditionValue&&checkingValue){if(checkingValue>conditionValue){this.displayUnconditionMsg();return false;}else{var messageStr=this.params.get('message');return this.displayMsg(messageStr);}}};wlpConditionsAction.prototype.displayUnconditionMsg=function(){var uncondMsg=this.params.get('wrang_msg');if(uncondMsg){alert(uncondMsg);}};wlpConditionsAction.prototype.displayMsg=function(messageStr){if(messageStr){return window.confirm(messageStr);}else{return window.confirm("Undefined Message :)");}};

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpSimpleOpenAction(url,_params){
	this.url = url;
	this.params = new wlpPropertyList(_params);
};

wlpSimpleOpenAction.prototype = new wlpAction;

wlpSimpleOpenAction.prototype.check = function(){
    window.open(this.url);
};

function wlpAction(_url,_params){this.url=_url;this.params=new wlpPropertyList(_params);}wlpAction.prototype.check=function(){return true;}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpSimpleAction(url,_params){
	this.url = url;
	this.params = new wlpPropertyList(_params);
};

wlpSimpleAction.prototype = new wlpAction;

function wlpSimpleOpenAction(url,_params){this.url=url;this.params=new wlpPropertyList(_params);};wlpSimpleOpenAction.prototype=new wlpAction;wlpSimpleOpenAction.prototype.check=function(){window.open(this.url);};

var wlpActionFactory;if(!wlp_def("wlpActionFactory")){wlpActionFactory={getInstance:function(_type,_url,_params){switch(_type){case wlpConst.WLP_ACTION_SIMPLE:return new wlpSimpleAction(_url,_params);case wlpConst.WLP_ACTION_CONFIRM:return new wlpConfirmAction(_url,_params);case wlpConst.WLP_ACTION_CONDITIONS_CONFIRM:return new wlpConditionsAction(_url,_params);case wlpConst.WLP_ACTION_SIMPLE_OPEN:return new wlpSimpleOpenAction(_url,_params);default:return new wlpBaseAction(_url,_params);}}}}

function wlpConfirmAction(url,_params){this.url=url;this.params=new wlpPropertyList(_params);}wlpConfirmAction.prototype=new wlpAction;wlpConfirmAction.prototype.check=function(){var messageStr=this.params.get('message');if(messageStr!==false)return window.confirm(messageStr);else return window.confirm("Undefined Message :)");}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpConfirmAction(url,_params){
	this.url = url;
	this.params = new wlpPropertyList(_params);
}

wlpConfirmAction.prototype = new wlpAction;

wlpConfirmAction.prototype.check = function(){
	var messageStr = this.params.get('message');
	if (messageStr!==false)	return window.confirm(messageStr);
		else return window.confirm("Undefined Message :)");
}

function wlpSimpleAction(url,_params){this.url=url;this.params=new wlpPropertyList(_params);};wlpSimpleAction.prototype=new wlpAction;

