function wlpSwapImage(_image_on,_image_off,_message_on,_message_off,_status,_id){this.message_on=_message_on;this.message_off=_message_off;this.image_on=new Image();this.image_on.src=_image_on;this.image_off=new Image();this.image_off.src=_image_off;this.status=_status;this.id=_id;}wlpSwapImage.prototype.show=function(){if(this.status){$(this.id).src=this.image_off.src;$(this.id).setAttribute("alt",this.message_off);$(this.id).setAttribute("title",this.message_off);}else{$(this.id).src=this.image_on.src;$(this.id).setAttribute("alt",this.message_on);$(this.id).setAttribute("title",this.message_on);}};wlpSwapImage.prototype.swap=function(){if(this.status){this.status=false;$(this.id).src=this.image_on.src;$(this.id).setAttribute("alt",this.message_on);$(this.id).setAttribute("title",this.message_on);}else{this.status=true;$(this.id).src=this.image_off.src;$(this.id).setAttribute("alt",this.message_off);$(this.id).setAttribute("title",this.message_off);}}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpSwapImage(_image_on,_image_off,_message_on,_message_off,_status,_id){
	
	this.message_on = _message_on;
	this.message_off = _message_off;
	
	this.image_on = new Image();
	this.image_on.src = _image_on;
	
	this.image_off = new Image();
	this.image_off.src = _image_off;

	this.status = _status;	
	this.id = _id;
}

wlpSwapImage.prototype.show = function(){
	if (this.status){
		$(this.id).src = this.image_off.src;
		$(this.id).setAttribute("alt",this.message_off);
		$(this.id).setAttribute("title",this.message_off);
	} else {
		$(this.id).src = this.image_on.src;
		$(this.id).setAttribute("alt",this.message_on);
		$(this.id).setAttribute("title",this.message_on);
	}		
}

wlpSwapImage.prototype.swap = function(){
	if (this.status){
		this.status = false;
		$(this.id).src = this.image_on.src;
		$(this.id).setAttribute("alt",this.message_on);
		$(this.id).setAttribute("title",this.message_on);
	} else {
		this.status = true;
		$(this.id).src = this.image_off.src;
		$(this.id).setAttribute("alt",this.message_off);
		$(this.id).setAttribute("title",this.message_off);
	}
}


function wlpImageViewer(_locale,_instanceName,_spinner){this.locale=_locale;this.instanceName=_instanceName;this.image=new Image();this.image.align='absmiddle';this.image.id='image_'+this.instanceName;this.isLoad=false;this.onImageLoadBehaviour=this._defaultOnImageLoadBehaviour;if(typeof(_spinner)!="undefined"){this.spinnerImage=new Image;this.spinnerImage.src=_spinner;this.spinnerImage.align='absmiddle';this.spinnerImage.id='spinner_'+this.instanceName;}else{this.spinnerImage=null;}this._containerPosition=null;}wlpImageViewer.prototype.preloadImage=function(_imgSrc){this._showSpinner();this._resizeContainer(200,160);this.image.src=_imgSrc;};
wlpImageViewer.prototype.generateContainer = function(){var containerHTML ='<scr'+'ipt>function onImageLoad'+this.instanceName+'(){'+this.instanceName+'._onImageLoad();}</script>'
		containerHTML+= '<div id="imageviewer_'+this.instanceName+'" style="position:absolute;display:none;width:200px;height:160px;left:0px;top:0px;border:1px solid #000000;background-color:#FFFFFF;">';
		containerHTML+= '<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" height="100%">';
		containerHTML+= '<tr><td height="15" align="center" style="background-color:#017ad7;padding-top:4px;padding-bottom:4px;color:#FFFFFF;border-bottom:1px solid #000000;"><b>'+this.locale['STR_VIEWING_IMAGE']+'</b></td></tr>';
        containerHTML+= '<tr><td align="center" valign="middle" style="padding:3px;padding-right:5px;padding-left:5px" id="image_container_'+this.instanceName+'"></td></tr>';
        containerHTML+= '<tr><td height="20" align="center" style="padding:3px;padding-top:0px;"><input class="blue_btn" type="button" style="border:1px solid #000000; width:100px;" value="'+this.locale['STR_CLOSE']+'" onclick="'+this.instanceName+'.hideContainer();"></td></tr>';
		containerHTML+= '</table>';containerHTML+= '</div>';document.write(containerHTML);this.image.onload = eval('onImageLoad'+this.instanceName);};wlpImageViewer.prototype.view=function(_imgSrc,_event){if(!_event)var _event=window.event;if(this.image.src!=_imgSrc){this.isLoad=false;this.onImageLoadBehaivor=this._showImageBehaviour;this.preloadImage(_imgSrc);}this.setPosition(this._getPosition(_event));this.showContainer();};wlpImageViewer.prototype.setPosition=function(position){$('imageviewer_'+this.instanceName).style.left=position['x'];$('imageviewer_'+this.instanceName).style.top=position['y'];};wlpImageViewer.prototype.showContainer=function(){this._toggleIEObjects('hide');$('imageviewer_'+this.instanceName).style.display='block';};
wlpImageViewer.prototype.hideContainer=function(){this._toggleIEObjects('show');$('imageviewer_'+this.instanceName).style.display='none';};wlpImageViewer.prototype._resizeContainer=function(width,height){$('imageviewer_'+this.instanceName).style.width=width;$('imageviewer_'+this.instanceName).style.height=height;};wlpImageViewer.prototype._onImageLoad=function(){this.onImageLoadBehaivor();};wlpImageViewer.prototype._defaultOnImageLoadBehaviour=function(){this.isLoad=true;this._hideSpinner();};wlpImageViewer.prototype._showImageBehaviour=function(){this._defaultOnImageLoadBehaviour();this._showImage(this.image);this._resizeContainer(this.image.width+10,this.image.height+60);};wlpImageViewer.prototype._showImage=function(_image){if(typeof(_image)!="undefined"&&_image!=false)$('image_container_'+this.instanceName).appendChild(_image);};wlpImageViewer.prototype._hideImage=function(_imageId){$('image_container_'+this.instanceName).removeChild($(_imageId));};wlpImageViewer.prototype._showSpinner=function(){if(this.spinnerImage!=null){this._showImage(this.spinnerImage);}};wlpImageViewer.prototype._hideSpinner=function(){if(this.spinnerImage!=null){this._hideImage('spinner_'+this.instanceName);}};wlpImageViewer.prototype._toggleIEObjects=function(action){var ie5=document.all&&document.getElementById;if(ie5){var tags=new Array("applet","iframe","select","object");for(var k=tags.length;k>0;){--k;var ar=document.getElementsByTagName(tags[k]);var cc=null;for(var i=ar.length;i>0;){cc=ar[--i];if(action=='hide'){cc.style.visibility='hidden';}else{cc.style.visibility='visible';}}}}};wlpImageViewer.prototype._getPosition=function(e){var position=new Array();if(e.pageX||e.pageY){position['x']=e.pageX;position['y']=e.pageY;}else if(e.clientX||e.clientY){position['x']=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;position['y']=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;}return position;}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */


function wlpImageViewer(/*Assoc array*/_locale,_instanceName,_spinner){
	
	this.locale = _locale;
	this.instanceName = _instanceName;
	
	this.image = new Image();
	this.image.align = 'absmiddle';
	this.image.id = 'image_'+this.instanceName;	
	this.isLoad = false;
	
	
	this.onImageLoadBehaviour = this._defaultOnImageLoadBehaviour;
	
	if (typeof(_spinner)!="undefined"){
		this.spinnerImage = new Image;
		this.spinnerImage.src = _spinner;
		this.spinnerImage.align = 'absmiddle';
		this.spinnerImage.id = 'spinner_'+this.instanceName;	
	} else {
		this.spinnerImage = null;
	}
	
	this._containerPosition = null;	
}

wlpImageViewer.prototype.preloadImage= function(_imgSrc){
	this._showSpinner();
	this._resizeContainer(200,160);
	this.image.src = _imgSrc;		
}

wlpImageViewer.prototype.generateContainer = function(){
	var containerHTML ='<scr'+'ipt>function onImageLoad'+this.instanceName+'(){'+this.instanceName+'._onImageLoad();}</script>'
		containerHTML+= '<div id="imageviewer_'+this.instanceName+'" style="position:absolute;display:none;width:200px;height:160px;left:0px;top:0px;border:1px solid #000000;background-color:#FFFFFF;">';
		containerHTML+= '<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" height="100%">';
		containerHTML+= '<tr><td height="15" align="center" style="background-color:#017ad7;padding-top:4px;padding-bottom:4px;color:#FFFFFF;border-bottom:1px solid #000000;"><b>'+this.locale['STR_VIEWING_IMAGE']+'</b></td></tr>';
        containerHTML+= '<tr><td align="center" valign="middle" style="padding:3px;padding-right:5px;padding-left:5px" id="image_container_'+this.instanceName+'"></td></tr>';
        containerHTML+= '<tr><td height="20" align="center" style="padding:3px;padding-top:0px;"><input class="blue_btn" type="button" style="border:1px solid #000000; width:100px;" value="'+this.locale['STR_CLOSE']+'" onclick="'+this.instanceName+'.hideContainer();"></td></tr>';
		containerHTML+= '</table>';
		containerHTML+= '</div>';	
		
		document.write(containerHTML);
		this.image.onload = eval('onImageLoad'+this.instanceName);
}

wlpImageViewer.prototype.view = function(_imgSrc,_event){
	
	if (!_event) var _event = window.event;
	
	if (this.image.src!=_imgSrc){
		this.isLoad = false;
		this.onImageLoadBehaivor = this._showImageBehaviour;
		this.preloadImage(_imgSrc);
	}
	
	this.setPosition(this._getPosition(_event));
	this.showContainer();
}

wlpImageViewer.prototype.setPosition = function(position){
	$('imageviewer_'+this.instanceName).style.left = position['x'];	
	$('imageviewer_'+this.instanceName).style.top = position['y'];
}

wlpImageViewer.prototype.showContainer = function(){
	this._toggleIEObjects('hide');
	$('imageviewer_'+this.instanceName).style.display = 'block';	
}

wlpImageViewer.prototype.hideContainer = function(){
	this._toggleIEObjects('show');
	$('imageviewer_'+this.instanceName).style.display = 'none';
} 

/* helper functions */

wlpImageViewer.prototype._resizeContainer = function(width,height){
	$('imageviewer_'+this.instanceName).style.width = width;
	$('imageviewer_'+this.instanceName).style.height = height;  
}

wlpImageViewer.prototype._onImageLoad = function(){
	this.onImageLoadBehaivor();
}

wlpImageViewer.prototype._defaultOnImageLoadBehaviour = function(){
	this.isLoad = true;
	this._hideSpinner();
}
wlpImageViewer.prototype._showImageBehaviour = function(){
	this._defaultOnImageLoadBehaviour();
	this._showImage(this.image);
	this._resizeContainer(this.image.width+10,this.image.height+60);
}

wlpImageViewer.prototype._showImage = function(_image){	
	if (typeof(_image)!="undefined" && _image!=false) $('image_container_'+this.instanceName).appendChild(_image);
}

wlpImageViewer.prototype._hideImage = function(_imageId){	
	$('image_container_'+this.instanceName).removeChild($(_imageId));	
}

wlpImageViewer.prototype._showSpinner = function(){
	if (this.spinnerImage!=null){
		this._showImage(this.spinnerImage);
	}
}

wlpImageViewer.prototype._hideSpinner = function(){
	if (this.spinnerImage!=null){
		this._hideImage('spinner_'+this.instanceName);
	}	
}

wlpImageViewer.prototype._toggleIEObjects = function(action) {
   var ie5=document.all&&document.getElementById;   
   if (ie5) {
	   var tags = new Array("applet", "iframe", "select", "object");
	   
	   for (var k = tags.length; k > 0; ) {
	       --k;
	    
		   var ar = document.getElementsByTagName(tags[k]);
	       var cc = null;
	    
		   for (var i = ar.length; i > 0;) {
	           cc = ar[--i];
	           if (action == 'hide') {
	               cc.style.visibility = 'hidden';
	           } else {
	               cc.style.visibility = 'visible';
	           }
	      }
	  }
  }
}

wlpImageViewer.prototype._getPosition = function(e){
   var position = new Array();
   if (e.pageX || e.pageY)        {
      position['x'] = e.pageX;
      position['y'] = e.pageY;
   } else if (e.clientX || e.clientY)         {
      position['x'] = e.clientX + document.body.scrollLeft+document.documentElement.scrollLeft;
      position['y'] = e.clientY + document.body.scrollTop+document.documentElement.scrollTop;
   }
   return position;
}


