
/*************** open print window */
var printWin;

function Print(x){
/* check value of x */
    var printURI;
    if (x == null){
    printURI = "";
    } else {
    printURI = x;
    }

/* execute open popup window */
	if (printWin == null || printWin.closed){
		printWin = window.open(printURI,"","toolbar=no,personal=no,menubar=no,status=yes,resizable=yes,width=550,height=400,location=no,scrollbars=yes");
		}else{
		printWin.focus();
		printWin.location.replace("/~adlab/print/"+printURI);
		
	}
	
	
	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function changepic(img_name,img_src, title, desc) {
document.getElementById(img_name).src=img_src;
document.getElementById(img_name).alt=title;
document.getElementById(img_name).title=desc;
var titleRef = document.getElementById('titleBox');
titleRef.innerHTML = title+"<br>"+desc;
}


/**
 * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
 */

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}


function ShowTitle(title,im) {
	var titleRef = document.getElementById('titleBox');
   	titleRef.innerHTML = title;
   	for(i=0;i<10;i++){
   		if(document.getElementById("f"+i)!=null){
   			if(i==im){
   			setOpacity(document.getElementById("f"+i), 100);
   			document.getElementById("f"+i).style.borderColor = '#39acbe';
   			}else{
   			setOpacity(document.getElementById("f"+i), 30);
   			document.getElementById("f"+i).style.borderColor = '#ffffff';
   			}
   		}
   	}
}

function HideTitle() {
	var titleRef = document.getElementById('titleBox');
   	titleRef.innerHTML = '';
   	for(i=0;i<10;i++){
   		if(document.getElementById("f"+i)!=null){
   			setOpacity(document.getElementById("f"+i), 100);
   		}
   	}
}

function setOpacity(obj, opacity) {

  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function currentBrowser() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)	
	this.min = parseFloat(navigator.appVersion)
	this.opera = (navigator.userAgent.indexOf('Opera')>0)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	this.ie55 = (navigator.userAgent.indexOf('MSIE 5.5')>0)
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6')>0)
	this.ie7 = (navigator.userAgent.indexOf('MSIE 7')>0)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.dom = (this.ie5 || this.ie7 || this.ie6 || this.opera || this.ns5)
	this.ie = (this.b=="ie" && this.v>=4)
}

me = new currentBrowser()

function browserObject() {
	if (me.ie && !me.opera) {
		this.bodyWidth = parseInt(document.body.clientWidth)-8
		this.bodyHeight = parseInt(document.body.clientHeight)-8
	}
	else {
		this.bodyWidth = parseInt(window.innerWidth)
		this.bodyHeight = parseInt(window.innerHeight)
	}
	this.screenHeight = screen.availHeight
	this.screenWidth = screen.availWidth
	this.screenActualHeight = screen.height
	this.screenActualWidth = screen.width
}


function xObject(cid,nest) {
	if (arguments.lenth < 2) {nest = null}
	if (me.ie4) {
		this.css = document.all[cid].style
		this.elm = document.all[cid]
		this.event = document.all[cid]
	}
	else if (me.dom) {
		this.css = document.getElementById(cid).style
		this.elm = document.getElementById(cid)
		this.event = document.getElementById(cid)
	}
	else if (me.ns4 || me.ns) {
		if (nest == null) {
			this.css = document.layers[cid]
			this.elm = document.layers[cid].document
			this.event = document.layers[cid]
		}
		else {
			this.css = document.layers[nest].document.layers[cid]
			this.elm = document.layers[nest].document.layers[cid].document
			this.event = document.layers[nest].document.layers[cid]
		}
	}		

	this.w = this.getWidth()
	this.ow = this.getWidth()
	this.h = this.getHeight()
	this.oh = this.getHeight()
	
	if (me.opera) {
		this.x = parseInt(this.css.pixelLeft)
		this.y = parseInt(this.css.pixelTop)
	}
	else if (me.ie || me.ns5) {
		this.x = (parseInt(this.elm.offsetLeft))
		this.y = (parseInt(this.elm.offsetTop))
	}
	else {
		this.x = (isNaN(parseInt(this.css.left)))? 0:parseInt(this.css.left)
		this.y = (isNaN(parseInt(this.css.top)))? 0:parseInt(this.css.top)
	}

	this.ox = this.x
	this.oy = this.y

	this.name = cid
	this.nest = nest
	this.id = cid
	this.obj = cid + "x"
	eval(this.obj + " = this")
}

xObject.prototype.getWidth = function () {
	if (me.opera) { var w = parseInt(this.css.pixelWidth)}
	else if (me.ie || me.ns5) {var w = parseInt(this.elm.offsetWidth)}
	else if (me.ns4) {var w = this.css.clip.width}
	else  {var w = parseInt(this.elm.offsetWidth)}
	this.w = w
	return this.w
}

xObject.prototype.getHeight = function () {
	if (me.opera) { var h = parseInt(this.css.pixelHeight)}
	else if (me.ie || me.ns5) {var h = parseInt(this.elm.offsetHeight)}
	else if (me.ns4) {var h = this.css.clip.height}
	this.h = h
	return this.h
}

xObject.prototype.setPlace = function(x,y) {
	if (arguments.length < 1 || x == null) {x = this.x}
	if (arguments.length < 2 || y == null) {y = this.y}
	this.x = x
	this.ox = x
	this.y = y
	this.oy = y
	this.css.left = this.x
	this.css.top = this.y
}

xObject.prototype.setPlaceDefault = function() {
	this.setPlace(this.x,this.y)
}

xObject.prototype.moveTo = function (x,y) {
	if (arguments.length < 1)  {var x = this.x}
	if (arguments.length < 2)  {var y = this.y}
	
	if (x!=null) {
		this.x = x
		if (me.ie) {this.css.offsetLeft = this.x}
		this.css.left = this.x
	}

	if (y!=null) {	
		this.y = y
		if (me.ie) {this.css.offsetTop = this.y}
		this.css.top = this.y
	}
}

xObject.prototype.moveBy = function (pixelLeft,pixelTop) {
	if (arguments.length < 1 || pixelLeft==null) {pixelLeft = 0}
	if (arguments.length < 2 || pixelTop==null) {pixleTop = 0}
	this.moveTo(this.x+pixelLeft,this.y+pixelTop)
}

xObject.prototype.moveAt = function (where,obj,pixelGap) {
	var gap = ((arguments.length<3)? 0:pixelGap)
	this.moveTo(this.getBase("x",where,obj,gap),this.getBase("y",where,obj,gap))
}

xObject.prototype.moveCenter = function() {
	var tmpBW = new browserObject()
	this.moveTo(((tmpBW.bodyWidth - this.getWidth())/2),((tmpBW.bodyHeight - this.getHeight())/2))
}

xObject.prototype.moveToRandom = function () {
	bwTemp = new browserObject();
	x = (Math.random() * bwTemp.bodyWidth) - this.getWidth()
	y = (Math.random() * bwTemp.bodyHeight) - this.getHeight()
	this.moveTo(x,y)
	delete bw;
}

xObject.prototype.show = function(visual) {
	var visual = (arguments.length < 1)? true:visual
	if (visual) {
		this.css.visibility = (me.ns4)? "show":"visible"
		this.onShow()
	}
	else {
		this.css.visibility = (me.ns4)? "hide":"hidden"
		this.onHide()
	}
}

xObject.prototype.onShow = new Function()

xObject.prototype.hide = function() {
	this.show(false);
}

xObject.prototype.isVisual = function() {
	var hideFlag = (me.ns4)? "hide":"hidden"
	return (this.css.visibility != hideFlag)
}

xObject.prototype.onHide = new Function()

xObject.prototype.setIndex = function(indexValue) {
	if (arguments.length > 0) {
		this.css.zIndex = arguments[0]
	}
}


xObject.prototype.getIndex = function() {
	return (this.css.zIndex=="")? 0:this.css.zIndex
}

xObject.prototype.write = function (text) {	
	if (!me.opera) {
		if (me.ns4) {		
			this.elm.open()
			this.elm.write(text)
			this.elm.close()
		}
		else if (me.ie || me.ns5) {		
			this.elm.innerHTML = text
		}
		this.onWrite();
	}
}

xObject.prototype.onWrite = new Function()

xObject.prototype.slideTo = function(endx,endy,speed,timer,nextStep) {
	if (!this.slideActive) {
		if (!arguments.length<4) {		
			var xDist = (endx==null)? 0:(endx-this.x)
			var yDist = (endy==null)? 0:(endy-this.y)		
			var xySteps = Math.sqrt(Math.pow(xDist,2) + Math.pow(yDist,2))/speed	
			if (xySteps == 0) {return}
			var xSpeed = xDist/xySteps
			var ySpeed = yDist/xySteps	
			this.slideEnd = nextStep
			if (arguments.length < 5) { nextStep = null}
			this.slideStart(endx,endy,xSpeed,ySpeed,xySteps,timer,nextStep)	
		}
	}
}

xObject.prototype.slideStart = function (endx,endy,xSpeed,ySpeed,xySteps,timer,nextStep) {
	if (this.slideActive) {return}
	this.slideActive = true	
	this.onSlideStart();
	this.slideLoop(endx,endy,xSpeed,ySpeed,xySteps,1,timer)
}

xObject.prototype.onSlideStart = new Function()

xObject.prototype.slideLoop = function(endx,endy,xSpeed,ySpeed,xySteps,inc,timer) {
	if (!this.slideActive) {return}
	if (inc++ < xySteps) {	
		this.moveBy(xSpeed,ySpeed)
		this.onSlide()
		setTimeout(this.obj+".slideLoop("+endx+","+endy+","+xSpeed+","+ySpeed+","+xySteps+","+inc+","+timer+")" ,timer)
	}
	else {
		this.moveTo(endx,endy)
		this.slideActive = false		
		eval(this.slideEnd)
		this.onSlideEnd();
	}
}

xObject.prototype.onSlide = new Function()
xObject.prototype.onSlideEnd = new Function()

xObject.prototype.slideAt = function(where,obj,gap,speed,timer,nextStep) {
	if (arguments.length < 5) {return}
	if (arguments.length < 6) {nextStep = null}
	var x = this.getBase("x",where,obj,gap)
	var y = this.getBase("y",where,obj,gap)
	this.slideTo(x,y,speed,timer,nextStep)
}

xObject.prototype.getBase = function (what,where,obj,pixelGap) {
	var gap = ((arguments.length<4)? 0:pixelGap)
	switch (where) {
		case "t":		// Top
				var x = obj.x
				var y = ((obj.y - obj.getHeight())-gap)
				break
		case "tr":		// Top Right
				var x = ((obj.x + obj.getWidth())+gap)
				var y = ((obj.y - obj.getHeight())-gap)
				break		
		case "tl":		// Top Left
				var x = ((obj.x-this.getWidth())-gap)
				var y = ((obj.y - obj.getHeight())-gap)
				break		
		case "tc": 
				var x = (obj.x + ((obj.getWidth() - this.getWidth()) /2)) 
				var y = ((obj.y - obj.getHeight())-gap)
				break
		case "r":		// Right
				var x = ((obj.x + obj.getWidth())+gap)
				var y = obj.y
				break

		case "rb":		// Right Bottom
				var x = ((obj.x + obj.getWidth())+gap)
				var y = ((obj.y + obj.getHeight()) - this.getHeight())
				break		

		case "rc":		// Right center
				var x = ((obj.x + obj.getWidth())+gap)
				var y = (obj.y + ((obj.getHeight() - this.getHeight())/2))
				break		
		
		case "b":		// Bottom
				var x = obj.x
				var y = ((obj.y+obj.getHeight())+gap)
				break
		case "br":		// Bottom Right
				var x = ((obj.x + obj.getWidth())+gap)
				var y = ((obj.y+obj.getHeight())+gap)
				break
		case "bl":		// Bottom Left
				var x = ((obj.x-this.getWidth())-gap)
				var y = ((obj.y+obj.getHeight())+gap)
				break
		case "bc":		// Bottom Center
				var x = (obj.x + ((obj.getWidth() - this.getWidth()) /2)) 
				var y = ((obj.y + obj.getHeight())+gap)
				break
		case "l":		// Left
				var x = ((obj.x-this.getWidth())-gap)
				var y = obj.y
				break
		case "lc":
				var x = ((obj.x - obj.getWidth()) - gap)
				var y = (obj.y + ((obj.getHeight() - this.getHeight())/2))				
				break
		default: 
				var x = null
				var y = null
				break
	}
	return ((what=="x")? x:y)
}
