//document.write("<div id='aDiv' style='position:absolute;z-index:150; overflow:hidden ; background-color:#FFFFFF; border:3px solid #444444; visibility:hidden;text-align:center;color:#CCCCCC;font-size:4em;'>&nbsp;</div>")
//var fsrc = (document.all && window.location.protocol=="https:")?document.images[0].src:"about:blank"
//document.write("<iframe name='defaultFrameframe' id='defaultFrameframe' src='" + document.images[0].src + "' style='position:absolute;left:0px;top:0px;width:0px;height:0px;visibility:hidden;z-index:151;' frameborder='0' scrolling='No' marginheight='0px' marginwidth='0px'></iframe>")

var defaultFrame = {
	winheight:605,winwidth:750,rowheight:26,openLeft:-80,
	pframe:null,openerror:false,closedTop:null,closedHeight:null,closedLeft:null,closedWidth:null
}

defaultFrame.init = function(loadPG){
	var f = document.createElement('iframe');	
	f.id="defaultFrameframe";
	f.name="defaultFrameframe";
	f.src=document.images[0].src
	f.setAttribute('frameBorder','0');
	document.getElementsByTagName("BODY")[0].appendChild(f)
	this.pframe = new frameobj()
	this.pframe.setFrame('defaultFrameframe')
	this.pframe.setResizeCmd("defaultFrame.pframe.browserResize()")
	framemain.setFrameobjs(this)
}
defaultFrame.getParentTag = function(obj,parentTag){
	while(obj != null && obj.tagName!=parentTag){
		obj = obj.parentNode
	}
	return obj
}
defaultFrame.getOffsetTopLeft = function(obj){
	with(this){
		closedHeight = obj.offsetHeight
		closedWidth = obj.offsetWidth
		closedTop = 0
		closedLeft = 0
		while(obj!=null){
			closedTop=closedTop+obj.offsetTop;
			closedLeft=closedLeft+obj.offsetLeft;
			obj = obj.offsetParent
		}
		closedLeft = closedLeft - alayer.getBrowserMidX()
	}
}

defaultFrame.open = function(linkobj,parentTag){
	try{
		var scrollPos, openTop, closeObj,url
		with(this){
			if(!this.pframe)init(true)
			scrollPos=(document.body.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop
			closeObj = getParentTag(linkobj,parentTag)
			getOffsetTopLeft(closeObj)
			openTop = (scrollPos < 60)? 180 : 100+scrollPos
			pframe.setClosePosition(closedLeft,closedTop,closedWidth,closedHeight);
			pframe.setOpenPosition(
								   linkobj.openLeft?linkobj.openLeft:openLeft,
								   linkobj.openTop?linkobj.openTop:openTop,
								   linkobj.winwidth?linkobj.winwidth:winwidth,
								   linkobj.winheight?linkobj.winheight:winheight
								   );
			url = linkobj.href
			try{
				if(url.indexOf("used")>-1 && param.addSessionParam("popUp:true")){
					param.setPageCheck(url);
				}else{
					url = url + ((url.indexOf("?")>-1)?"&popUp=true":"?popUp=true");
				}
			}catch(err){
				url = url + ((url.indexOf("?")>-1)?"&popUp=true":"?popUp=true");
			}
			pframe.openURL(url)
			framemain.openpart1(this)
		}
		//if(window.event)event.returnValue = false;
		return defaultFrame.openerror
	}catch(er){
		this.openerror = true 
		return defaultFrame.openerror
		location = linkobj.href
	}
}
defaultFrame.frameLoaded = function() {
	if(!this.pframe)this.init(true)
	this.pframe.frameLoaded()
}
defaultFrame.doDrag = function(x,y) {
	this.pframe.doDrag(x,y)
}
defaultFrame.closeAndUpdate = function(val){
	this.pframe.closeFrame(val)
}



var alayer = {
	minRes : 12,
	animationtime : 350,
	contentwidth : 746,
	showload:false,aFrameObj:null,openclose:false,starttime:0,minRestime:5
}



alayer.init = function() {
	with (alayer){
		var d = document.createElement('div');	
		d.id="framewindowdiv";
		document.getElementsByTagName("BODY")[0].appendChild(d)
		this.div = document.getElementById('framewindowdiv')	
		this.minRestime = (animationtime/minRes)/3
	}
}

alayer.setClosePosition = function(cLeft,cTop,cWidth,cHeight) {
	if(!alayer.div)alayer.init()
	with(alayer){
		this.closewidth = cWidth
		this.closeheight = cHeight
		this.closetop = cTop
		this.closeleft = cLeft
	}
}

alayer.setOpenPosition = function(oLeft,oTop,oWidth,oHeight) {
	if(!alayer.div)alayer.init()
	with(alayer){
		this.openwidth = oWidth
		this.openheight = oHeight
		this.opentop = oTop
		this.openleft = oLeft
	}
}


alayer.openScroll = function(fo) {
	with (alayer){
		aFrameObj=fo
		var osRes
		if(showload){
			this.div.innerHTML="&nbsp;"
			this.showload=false
			osRes=minRes*2/3
		}else{
			position(closeleft,closetop,closewidth,closeheight)
			osRes=minRes
			this.starttime = new Date()
			resTime = animationtime/minRes
		}
		this.wsteps		= (openwidth-width)/osRes
		this.hsteps		= (openheight-height)/osRes
		this.tsteps		= (opentop-top)/osRes
		this.lsteps		= (openleft-left)/osRes
		this.stepstogo	= osRes
		this.openclose = true
		visible(true)
		this.aniTimer	= window.setTimeout("alayer.scroll()",resTime)
	}
}

alayer.closeScroll = function(fo){ //position to close from
	with (alayer){
		aFrameObj=fo
		this.starttime = new Date()
		position(aFrameObj.left+aFrameObj.midx,aFrameObj.top,aFrameObj.width,aFrameObj.height)
		this.wsteps		= (closewidth-width)/minRes
		this.hsteps		= (closeheight-height)/minRes
		this.tsteps		= (closetop-top)/minRes
		this.lsteps		= (closeleft-left)/minRes
		this.stepstogo	= minRes
		this.openclose = false
		visible(true)
		resTime = animationtime/minRes
		this.aniTimer	= window.setTimeout("alayer.scroll()",resTime)
	}
}

alayer.scroll = function(){
	with (alayer){
		position(left+lsteps, top+tsteps, width+wsteps, height+hsteps)
		stepstogo = --stepstogo
		if(this.aniTimer) window.clearTimeout(this.aniTimer)
		if(stepstogo>0){
			resTime = (animationtime - ((new Date()).getTime() - this.starttime.getTime()))/stepstogo
			if(resTime<minRestime)resTime=minRestime
			if(openclose)resTime=resTime + stepstogo //this is to slow opening at start
			this.aniTimer	= window.setTimeout("alayer.scroll()",resTime)
		}else{
			if(showload){
				this.div.innerHTML="Loading.."
			}else{
				visible(false)
				aFrameObj.scrollDone(openclose)
			}
		}
	}
}

alayer.showLoading = function(){
	with (alayer){
		var slRes = minRes/2
		position(closeleft,closetop,closewidth,closeheight)
		this.wsteps		= ((openwidth-width)/2)/slRes
		this.hsteps		= ((openheight-height)/2)/slRes
		this.tsteps		= ((opentop-top)/2)/slRes
		this.lsteps		= ((openleft-left)/2)/slRes
		this.stepstogo	= slRes
		this.openclose = false
		this.showload=true
		this.starttime = new Date()
		visible(true)
		this.scroll()
	}
}

alayer.position = function(pLeft,pTop,pWidth,pHeight){
	with(alayer){
		this.width		= pWidth //div.offsetWidth
		this.height		= pHeight
		this.top		= pTop //div.offsetTop
		this.left		= pLeft
		div.style.width = width + "px"
		div.style.height = height + "px"
		div.style.top = top + "px"
		div.style.left = (left) + "px"	
		div.style.lineHeight = (height) + "px"
	}
}


alayer.visible = function(show){
	with (alayer){
		div.style.visibility = (show)?"visible":"hidden"
	}
}

alayer.getBrowserMidX = function(){
	with(alayer){
		var mx
		if (window.innerWidth){ //firefox
			mx = (window.innerWidth/2)-(contentwidth/2)-6 //+window.pageXOffset;
		}else if (document.body){ //ie
			mx = (document.body.clientWidth/2)-(contentwidth/2) //+document.body.scrollLeft;
		}else{
			mx = window.innerWidth/2-(contentwidth/2)
		}
		if(mx<0)mx=12
		return mx
	}
}



function frameobj(){
	this.obj = null
	this.documentObj = null
	this.loadedState = "not"
	this.contentVisibleFlag=false
	this.frameId = ""
	this.frameURL
	this.frameState="closed"
	this.closeURL = null
	this.closeRefresh =null
	this.resizeCmd,this.midx;this.left;this.top;this.width;this.height
}

frameobj.prototype.setFrame = function (idname){
	this.frameId = idname
	if(document.all){
		this.obj = document.all(this.frameId)
	}else{
		this.obj = document.getElementById(this.frameId)
	}
	this.documentObj = window.frames[idname]
}

frameobj.prototype.openURL = function (fURL) {
	if(this.loadedState != "loaded" || this.documentObj.location.href.indexOf(fURL)==-1){
		if(this.loadedState == "loaded")this.loadedState=""
		if(this.frameState == "open")this.closeFrame()
		this.frameURL=fURL
		this.documentObj.location.replace(fURL)
	}
}

frameobj.prototype.visible = function (show){
	with(this){
		if(show){
			contentVisibleFlag=true
			obj.style.visibility = "visible"
			eval("onresize = function(){" + resizeCmd +"}")
		}else{
			contentVisibleFlag=false
			obj.style.visibility = "hidden"
			onresize = null
			obj.style.width = "0px"
			obj.style.height = "0px"
		}	
	}
}

frameobj.prototype.position = function (pLeft,pTop,pWidth,pHeight){
	with(this){
		this.left=pLeft;this.top=pTop;this.width=pWidth;this.height=pHeight
		obj.style.width = pWidth+"px"
		obj.style.height = pHeight+"px"
		obj.style.top = pTop+"px"
		obj.style.left = (pLeft+midx)+"px"
	}
}

frameobj.prototype.doDrag = function(x,y) {
	with(this){
		position(left+x,top+y,width,height)
	}
}

frameobj.prototype.frameLoaded = function() {
	if(this.loadedState=="open" && this.documentObj.location.href.indexOf(this.frameURL)!=-1){
		this.loadedState="loaded"
		this.openFrame()
	}else{
		if(this.frameURL==null || this.documentObj.location.href.indexOf(this.frameURL)!=-1)this.loadedState="loaded"
	}
}

frameobj.prototype.setResizeCmd = function(rc){
	this.resizeCmd = rc
}

frameobj.prototype.setClosePosition = function(cLeft,cTop,cWidth,cHeight) {
	this.closewidth = cWidth
	this.closeheight = cHeight
	this.closetop = cTop
	this.closeleft = cLeft
}

frameobj.prototype.setOpenPosition = function(oLeft,oTop,oWidth,oHeight) {
	this.openwidth = oWidth
	this.openheight = oHeight
	this.opentop = oTop
	this.openleft = oLeft
}

frameobj.prototype.openFrame = function() {
	with(this){
		this.midx = alayer.getBrowserMidX()
		alayer.setClosePosition(closeleft+midx,closetop,closewidth,closeheight)
		alayer.setOpenPosition(openleft+midx,opentop,openwidth,openheight)
		if(loadedState=="loaded"){
			this.frameState = "open"
			alayer.openScroll(this)
		}else{
			alayer.showLoading()
			this.loadedState="open"
		}
	}
}

frameobj.prototype.closeFrame = function(val) {
	with(this){
		if(frameState == "open"){
			visible(false)
			closeURL = (val && val!=true && val.indexOf("html")!=-1 )? val:null
			closeRefresh = (val && val==true)? val:null
			//alayer.setClosePosition(closeleft+midx,closetop,closewidth,closeheight)
			//alayer.setOpenPosition(openleft+midx,opentop,openwidth,openheight)
			alayer.closeScroll(this)
		}
	}
}

frameobj.prototype.scrollDone = function(openclose) {
	with(this){
		if(openclose){
			position(openleft,opentop,openwidth,openheight)
			visible(true)
		}else{
			this.frameState = "closed"
			if(closeURL){
				location=closeURL
				return
			}
			if(closeRefresh && closeRefresh==true) {
				try {
					location=refreshURL
					return
				} catch(er) {
					alert("refreshURL not set");	
				}
			}
			try{
				framemain.openpart2()
			}catch(er){}
		}
	}
}


frameobj.prototype.browserResize = function () {
	with(this){
		this.midx = alayer.getBrowserMidX()
		position(left, top, width, height)
	}
}




var framemain = {
	openeval:"",frameobjs:null
}
framemain.setFrameobjs = function (obj){
	with(this){
		if(frameobjs == null)this.frameobjs = new Array()
		frameobjs[frameobjs.length] = obj
	}
}
framemain.closewin = function(){
	with(this){
		var l=false
		for(n in frameobjs){
			if(frameobjs[n].pframe && frameobjs[n].pframe.frameState=="open"){
				l=true
				frameobjs[n].closeAndUpdate()
			}
		}
		if(!l)openpart2()
	}
}
framemain.openpart1 = function(ope){
	framemain.openeval = ope
	framemain.closewin()
}
framemain.openpart2 = function(){
	with(framemain){
		if(openeval!=null)openeval.pframe.openFrame()
		openeval=null
	}
}