// <![CDATA[

function alsImageViewer (frame_left, frame_top, frame_width, frame_height, img_url, img_left, img_top) {
    if (!this.instance_cnt)
	this.instance_cnt = 0;
    else
	this.instance_cnt++;
    this.img_url = ((img_url)?img_url:"");
    this.img_id = "buggyimg_"+(this.instance_cnt);
    this.img_div = "buggydiv_"+(this.instance_cnt);
    this.frame_top=((frame_top)?frame_top:0);
    this.frame_left=((frame_left)?frame_left:0);
    this.frame_width=((frame_width)?frame_width:0);
    this.frame_height=((frame_height)?frame_height:0);
    this.img_top=((img_top)?img_top:0);
    this.img_left=((img_left)?img_left:0);
    this.reset_img_top=((img_top)?img_top:0);
    this.reset_img_left=((img_left)?img_left:0);
    this.img_mag_ndx=1;
    this.img_mag_rate=0.02;
    this.img_width=1000;
    this.reset_img_width=1000;
    this.main_div_name = "buggyvision"+(this.instance_cnt);
    this.left_button = this.main_div_name+"_leftbtn";
    this.left_button = this.main_div_name+"_leftbtn";
    this.bottom_margin=20;
    if (is_msie)
	this.bottom_margin=25;
    this.ctrl_win_id=this.main_div_name+"_ctrlwin";
    this.buttons_enabled=false;

    this.moveLeft = moveBOVLeft;
    this.moveRight = moveBOVRight;
    this.moveUp = moveBOVUp;
    this.moveDown = moveBOVDown;
    this.magIncrease = imageBOVIncrease;
    this.magDecrease = imageBOVDecrease;
    this.moveImage = moveBOVImage;
    this.init = initBOVImage;
    this.setImage = setBOVImage;
    this.close = closeBOVImage;
    this.reset = resetBOVImage;
    this.moveFrameTo = moveBOVFrameTo;
    this.hideObjects = hideObjects;
    this.showObjects = showObjects;

    this.cmd = '<div id="'+this.main_div_name+'" style="position:absolute; overflow:hidden; border:6px ridge rgb(255,255,0); display:none; top:'+(frame_top)+'px; left:'+(this.frame_left)+'px; z-index:2000; width:'+this.frame_width+'px; height:'+(this.frame_height+this.bottom_margin)+'px;"> \
	<div style="position:relative; overflow:hidden; text-align:center; width:'+(this.frame_width)+'px; height:'+(this.frame_height)+'px;"> \
	    <div id="'+this.img_div+'" style="position:relative; top:'+(this.img_top)+'px; left:'+(this.img_left)+'px; z-index:100;"> \
		<img id="'+this.img_id+'" src="'+img_url+'" border="0" style="width:'+this.img_width+'px;" /> \
	    </div> \
	</div> \
	<div id="'+this.ctrl_win+'" style="font-size:8pt; position:absolute; height:'+this.bottom_margin+'px; width:100%; padding-top:6px; padding-bottom:2px; top:'+(this.frame_height)+'px; left:0px; background-color:rgb(255,255,0);"> \
	</div> \
    </div>';
    document.writeln(this.cmd);
}

function setBOVImage (url) {
    document.images[this.img_id].src=url;
}

function initBOVImage (objname) {
    this.hideObjects();
    document.getElementById(this.main_div_name).style.display="block";
    var d = document.getElementById(this.ctrl_win);
    var content ='';
    content+='<div style="position:relative;float:left; top:-5px;margin-left:0.25cm; "><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.moveRight();" onclick=\'\'>Right</a></div>';
    content+='<div style="position:relative;float:left; top:-5px;margin-left:0.25cm; "><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.moveLeft();" onclick=\'\'>Left</a></div>';
    content+='<div style="position:relative;float:left; top:-5px;margin-left:0.25cm; "><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.moveUp();" onclick=\'\'>Up</a></div>';
    content+='<div style="position:relative;float:left; top:-5px;margin-left:0.25cm; "><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.moveDown();" onclick=\'\'>Down</a></div>';
    content+='<div style="position:relative;float:left; top:-15px;margin-left:0.25cm; "><a style="border:none; font-size:2.0em; text-decoration:none;" href="javascript:'+objname+'.magIncrease();" onclick=\'\'><b>&nbsp;+&nbsp;</b></a></div>';
    content+='<div style="position:relative;float:left; top:-15px;margin-left:0.25cm; font-size:2.0em; "><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.magDecrease();" onclick=\'\'><b>&nbsp;-&nbsp;</b></a></div>';
    content+='<div style="position:relative;float:right; top:-5px;margin-left:0.25cm;  margin-right:0.25cm;"><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.close();" onclick=\'\'>Close</a></div>';
    content+='<div style="position:relative;float:right; top:-5px;margin-left:0.25cm;  margin-right:0.25cm;"><a style="border:none; text-decoration:none;" href="javascript:'+objname+'.reset();" onclick=\'\'>Reset</a></div>';

    if (d) {
	d.innerHTML=content;
    }
}
function moveBOVLeft(shift_amt) {
    //this.img_left-=50; 
    var amt =(this.img_width * this.img_mag_rate) 
    if (shift_amt)
	amt = shift_amt;
    var new_left = this.img_left - amt;
    var d = document.getElementById(this.img_div);
    if (d) {
	this.img_left = new_left;
	d.style.left=(this.img_left)+"px";
    }
}
function moveBOVRight(shift_amt) {
    var amt =(this.img_width * this.img_mag_rate); 
    if (shift_amt)
	amt = shift_amt;
    var new_left = this.img_left + amt;
    var d = document.getElementById(this.img_div);
    if (d) {
	this.img_left = new_left;
	d.style.left=(this.img_left)+"px";
    }
}
function moveBOVUp(shift_amt) {
    var amt =(this.img_width * this.img_mag_rate);
    if (shift_amt)
	amt = shift_amt;
    this.img_top = this.img_top - amt; 
    var d = document.getElementById(this.img_div);
    if (d) {
	d.style.top=(this.img_top)+"px";
    }
}
function moveBOVDown(shift_amt) {
    var amt =(this.img_width * this.img_mag_rate);
    if (shift_amt)
	amt = shift_amt;
    this.img_top = this.img_top + amt; 
    var d = document.getElementById(this.img_div);
    if (d) {
	d.style.top=(this.img_top)+"px";
    }
}
function imageBOVIncrease () {
    var new_size = this.img_width + (this.img_mag_rate * this.img_width);
    var d = document.getElementById(this.img_id);
    if (d) {
	this.img_width = new_size;
	d.style.width = (this.img_width)+"px";
    }
    this.moveLeft(12); this.moveUp(8);
}
function imageBOVDecrease () {
    var new_size = this.img_width - (this.img_mag_rate * this.img_width);
    var d = document.getElementById(this.img_id);
    if (d) {
	this.img_width = new_size;
	d.style.width = (this.img_width)+"px";
    }
    this.moveRight(8); 
    this.moveDown(4);
}

function moveBOVImage() {
    var d = document.getElementById(this.img_div);
    if (d) {
	d.style.top=(this.img_top)+"px";
	d.style.left=(this.img_left)+"px";
    }
}

function moveBOVFrameTo (left, top) {
    var d = document.getElementById(this.main_div_name);
    if (d) {
	d.style.left = left+"px";
	d.style.top = top+"px";
    }
}

function resetBOVImage() {
    var d = document.getElementById(this.img_div);
    var i = document.getElementById(this.img_id);
    if (d && i) {
	this.img_width=this.reset_img_width;
	this.img_left=this.reset_img_left;
	this.img_top=this.reset_img_top;
	i.style.width=(this.reset_img_width)+"px";
	d.style.left=(this.reset_img_left)+"px";
	d.style.top=(this.reset_img_top)+"px";
    }
}

function closeBOVImage() {
    this.showObjects();
    document.getElementById(this.main_div_name).style.display="none";
}

function hideObjects() {
    var a = document.getElementsByTagName("object");
    if (a) {
	try {
	    for (var x=0; x<a.length; x++) {
		if (a[x].id) {
		    var q = document.getElementById(a[x].id);
		    if (q)
			q.style.display="none";
		}
	    }
	}
	catch (ex) {
	    ;
	}
    }
    a = document.getElementsByTagName("applet");
    if (a) {
	try {
	    for (var x=0; x<a.length; x++) {
		if (a[x].id) {
		    alert (a[x].id);
		    var q = document.getElementById(a[x].id);
		    if (q)
			q.style.display="none";
		}
	    }
	}
	catch (ex) {
	    ;
	}
    }
}

function showObjects() {
    var a = document.getElementsByTagName("object");
    if (a) {
	try {
	    for (var x=0; x<a.length; x++) {
		if (a[x].id) {
		    var q = document.getElementById(a[x].id);
		    if (q)
			q.style.display="block";
		}
	    }
	}
	catch (ex) {
	    ;
	}
    }
    a = document.getElementsByTagName("applet");
    if (a) {
	try {
	    for (var x=0; x<a.length; x++) {
		if (a[x].id) {
		    var q = document.getElementById(a[x].id);
		    if (q)
			q.style.display="block";
		}
	    }
	}
	catch (ex) {
	    ;
	}
    }
}

// ]]>

