loading_dynlayer_wev8.js 14.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
// DynLAYER LIB
// www.microbians.com / Gabriel Suchowolski power[z]one - powerz@microbians.com
//
// Distributed under the terms of the GNU Library General Public License
//
// This routins are modifications based on Steinman DynAPI,
// so please... better use the original one.
// http://www.dansteinman.com/dynduo/
// 
// - added DIVs Array copy to regenerate on NS with RESIZE FIX LIB
// - added better code for load content on a DIV

// BrowserCheck Object
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	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.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

// DynLayer Main Functions
function DynLayer(id,nestref,frame) {
	if (!DynLayer.set && !frame) DynLayerInit()
	this.frame = frame || self
	if (is.ns) {
		if (is.ns4) {
			if (!frame) {
				if (!nestref) var nestref = DynLayer.nestRefArray[id]
				if (!DynLayerTest(id,nestref)) return
				this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			}
			else this.css = (nestref)? eval("frame.document."+nestref+".document."+id) : frame.document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		if (is.ns5) {
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
	}
	else if (is.ie) {
		this.elm = this.event = this.frame.document.all[id]
		this.css = this.frame.document.all[id].style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.y = this.elm.offsetTop
		this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
		this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
	}

	this.clipt = this.clipValues('t')
	this.clipr = this.clipValues('r')
	this.clipb = this.clipValues('b')
	this.clipl = this.clipValues('l')

	this.id = id
	this.nestref = nestref
	this.obj = id + "DynLayer"
	eval(this.obj + "=this")
	this.name = this.id.substring(0, this.id.lastIndexOf("Div"))

	this.SCROLLobj = null
	this.link      = ""
}

function DynLayerMoveTo(x,y) {
	if (x!=null) {
		this.x = x
		if (is.ns) this.css.left = Math.ceil( this.x )
		else this.css.pixelLeft  = Math.ceil( this.x )
	}
	if (y!=null) {
		this.y = y
		if (is.ns) this.css.top = Math.ceil( this.y )
		else this.css.pixelTop  = Math.ceil( this.y )
	}
}

function DynLayerResizeTo(w,h, clip) {
	if (w!=null) {
		this.w = w
		if (is.ns) this.css.clip.width = Math.ceil( this.w )
		else 	   this.css.pixelWidth = Math.ceil( this.w )
	}
	if (h!=null) {
		this.h = h
		if (is.ns) this.css.clip.height = Math.ceil( this.h )
		else 	   this.css.pixelHeight = Math.ceil( this.h )
	}
	if (clip == null) this.clipTo(0, Math.ceil( this.w ), Math.ceil( this.h ),0);
}

function DynLayerMoveBy(x,y) {
	this.moveTo(this.x+x,this.y+y)
}

function DynLayerShow() {
	this.css.visibility = (is.ns)? "show" : "visible"
}

function DynLayerHide() {
	this.css.visibility = (is.ns)? "hide" : "hidden"
}

function DynLayerisVisible() {
	     if ( is.ns && this.css.Visibility == "hide"  ) return false
	else if ( is.ie && this.css.Visibility == "hidden" ) return false
	else return true
}

DynLayer.prototype.resizeTo  = DynLayerResizeTo
DynLayer.prototype.moveTo    = DynLayerMoveTo
DynLayer.prototype.moveBy    = DynLayerMoveBy
DynLayer.prototype.show      = DynLayerShow
DynLayer.prototype.hide      = DynLayerHide
DynLayer.prototype.isVisible = DynLayerisVisible
DynLayerTest = new Function('return true')

// DynLayerInit Function
function DynLayerInit(nestref) {
	if (!DynLayer.set) DynLayer.set = true
	if (is.ns) {
		if (nestref) ref = eval('document.'+nestref+'.document')
		else {nestref = ''; ref = document;}
		for (var i=0; i<ref.layers.length; i++) {
			var divname = ref.layers[i].name
			DynLayer.nestRefArray[divname] = nestref
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'","'+nestref+'")')
				DynLayer.DynLayerobj.i++;
				eval('DynLayer.DynLayerobj['+ DynLayer.DynLayerobj.i +']=' + divname.substr(0,index) )
				DynLayer.DynLayercrt[DynLayer.DynLayerobj.i]= false;
			}
			if (ref.layers[i].document.layers.length > 0) {
				DynLayer.refArray[DynLayer.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
			}
		}
		if (DynLayer.refArray.i < DynLayer.refArray.length) {
			DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
		}
	}
	else if (is.ie) {
		for (var i=0; i<document.all.tags("DIV").length; i++) {
			var divname = document.all.tags("DIV")[i].id
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
				DynLayer.DynLayerobj.i++;
				eval('DynLayer.DynLayerobj['+ DynLayer.DynLayerobj.i +']=' + divname.substr(0,index) )
				DynLayer.DynLayercrt[DynLayer.DynLayerobj.i]= false;
			}
		}
	}
	return true
}

DynLayer.DynLayerobj = new Array()
DynLayer.DynLayercrt = new Array()
DynLayer.DynLayerobj.i = 0

DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

// Clip Methods
function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (is.ie) {
		if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft)
		else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0)
	}
}
function DynLayerClipTo(t,r,b,l) {
	if (t==null) t = this.clipValues('t')
	if (r==null) r = this.clipValues('r')
	if (b==null) b = this.clipValues('b')
	if (l==null) l = this.clipValues('l')
	if (is.ns) {
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	}
	else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"

	this.clipt = t
	this.clipr = r
	this.clipb = b
	this.clipl = l
}
function DynLayerClipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}
function DynLayerClipValues(which) {
	if (is.ie && this.css.clip ) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
	if (is.ns) {
		if (which=="t") return this.css.clip.top
		if (which=="r") return this.css.clip.right
		if (which=="b") return this.css.clip.bottom
		if (which=="l") return this.css.clip.left
	}
	else {
		if (this.css.clip) {
			if (which=="t") return Number(clipv[0])
			if (which=="r") return Number(clipv[1])
			if (which=="b") return Number(clipv[2])
			if (which=="l") return Number(clipv[3])
		}
		else {
			if (which=="t") return 0
			if (which=="r") return this.w
			if (which=="b") return this.h
			if (which=="l") return 0
		}
	}
}
DynLayer.prototype.clipInit = DynLayerClipInit
DynLayer.prototype.clipTo = DynLayerClipTo
DynLayer.prototype.clipBy = DynLayerClipBy
DynLayer.prototype.clipValues = DynLayerClipValues

// Write Method
function DynLayerWrite(html) {
	if (is.ns) {
		if (html != "" ) {
			this.doc.open()
			this.doc.clear()
			this.doc.write(html)
			this.doc.close()
		}
		else {
			this.doc.open()
			this.doc.clear()
			this.doc.write("<body></body>")
			this.doc.close()
		}
	}
	else if (is.ie) {
		this.event.innerHTML = html
	}
}
DynLayer.prototype.write = DynLayerWrite

// DynLayer Load power[Z]one's Method v.20

var DynLayerLoadSTILL = 0;

function DynLayerLoad(url,fn, ncpy) {
	this.url=url
	if ( DynLayerLoadSTILL == 0 || is.ie) {
		DynLayerLoadSTILL++
		this.onread = fn;
		this.onload = this.onLoadHanddler
		if (is.ie) this.write("<font size=1 face=verdana><b>&nbsp;l o a d i n g . . . </b></font>");
		if (is.ns) {
			this.doc.clear()
			this.elm.onload = this.onLoadHanddler
			this.elm.load(url,this.w)
		}
		else if (is.ie) { 
			this.createIFRAME()
			this.loadDocument(url, ncpy)
		}
	}
	else {
		setTimeout( this.obj+'.load("'+url+'","'+fn+'",'+ncpy+')', 20 );
	}
}

DynLayerENLACES = new Array()

function regenerateLINKARRAYonNS(nselobj) {
	var nsel = eval(nselobj)
	if ( nsel.doc.links.length ){
		delete DynLayerENLACES
		DynLayerENLACES = new Array()
		if ( nsel.doc.links.length >0) {
			var ll=nsel.doc.links.length
			for (var i=0; i<ll; i++) {
				DynLayerENLACES[i]=nsel.doc.links[i].href
				nsel.doc.links[i].href=""
			}
	
			for (var i=0; i<ll; i++) {
				nsel.doc.links[i].href=DynLayerENLACES[i]
			}
		}
	}
	else {
		setTimeout( "regenerateLINKARRAYonNS('"+nselobj+"')" ,  20)
	}
}

function DynLayeronLoadHanddler(doc, ncpy) {
	this.onload = null
	if (is.ie) { 
		if (ncpy != true) this.write(doc)
		eval(this.onread)
		DynLayerLoadSTILL--;
	} else {
		var nsel = eval(this.id.substring(0, this.id.lastIndexOf("Div")))
		if (ncpy == true) eval( "nsel.write('')");
		regenerateLINKARRAYonNS(nsel.obj)
		setTimeout( nsel.onread , 20);
		setTimeout( "DynLayerLoadSTILL--;", 30);
     	}
}

function DynLayercreateIFRAME() {
	this.frameName = this.id + 'bufferframe'
	var destFrame = document.frames[this.frameName]
	if (destFrame==null) {
		var html = '';
		html += '<IFRAME ID="' + this.frameName + '"';
    		html += ' NAME="' + this.frameName + '"';
		html += ' STYLE="position: absolute; left: -10px; top: -10px; visibility:none; width:0; height:0; "';
    		html += ' SRC="about:blank">';
    		html += '<\/IFRAME>';
    		document.body.insertAdjacentHTML('beforeEnd', html);
	}
}

function DynLayerloadDocument(url, ncpy) {
  if (url)
    	this.url = url
  	this.loaded = false
  	this.document = null
	var ifrWin = document.frames[this.frameName]
  	
	var html = ''
  	html += '<HTML>'
	html += '<HEAD><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><\/HEAD>'
  	html += '<BODY ONLOAD=\''
  	html += 'var fl = parent.' + this.name + ';'
  	html += 'fl.loaded = true;'
  	html += 'fl.document = window.frames["loader"].document;'
  	if (ncpy) html += 'fl.onload(fl.document.body.innerHTML,'+ncpy+');'
	else      html += 'fl.onload(fl.document.body.innerHTML);'
  	html += 'document.location.replace("about:blank")'
 	html += '\'>'
  	html += '<IFRAME id="loader" name="loader" SRC="' + this.url + '">'
  	html += '<\/IFRAME>'
  	html += '<\/BODY>'
  	html += '<\/HTML>'
  	ifrWin.document.open();
  	ifrWin.document.write(html);
  	ifrWin.document.close();
}

DynLayer.prototype.load           = DynLayerLoad
DynLayer.prototype.createIFRAME   = DynLayercreateIFRAME
DynLayer.prototype.loadDocument   = DynLayerloadDocument
DynLayer.prototype.onLoadHanddler = DynLayeronLoadHanddler


// DynLayer set-get zIndex / POWERZONE 
function DynLayerSetz(zIndex) {
	this.css.zIndex = zIndex
}

function DynLayerGetz(zIndex) {
	return this.css.zIndex
}

DynLayer.prototype.SetzIndex = DynLayerSetz
DynLayer.prototype.GetzIndex = DynLayerGetz

// DynLayer Set Background Method
// changes the background (the layer must be clipped)
// POWERZONE // Corrected ins NS doc by elm for work ok in NS4

hexa = new Array();
for(var i = 0; i < 10; i++) hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
function hex(i) {
         if (i <= 0)   return "00";
    else if (i >= 255) return "ff";
    else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function DynLayerSetbg(color) {
	if (is.ns) this.elm.bgColor         = color
	else       this.css.backgroundColor = color
}

function DynLayerSetbgRGB(r,g,b) {
	var hr = hex(r); 
	var hg = hex(g); 
	var hb = hex(b);
	this.setbg("#"+hr+hg+hb)
}

DynLayer.prototype.setbg    = DynLayerSetbg
DynLayer.prototype.setbgRGB = DynLayerSetbgRGB

// Preload IMG
function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

// DynLayer ChangeImage Method swaps an image in the layer
// v.2.0 added a control to no chage the conection
function DynLayerImg(imgName,imgObj) {
	var ELimg   = eval(imgObj)
	var HTMLimg = this.elm.document.images[imgName]
	if ( ELimg && ELimg.src && ELimg.src.toString() != HTMLimg.src.toString() ) {
		HTMLimg.src = ELimg.src
	}
}
function DynLayerImgURL(imgName,imgURL) {
	var HTMLimg = this.elm.document.images[imgName]
	HTMLimg.src = imgURL
}

DynLayer.prototype.img    = DynLayerImg
DynLayer.prototype.imgURL = DynLayerImgURL


// DynLayer GetRelative Methods
// retrieves the real location of a relatively positioned layer
function DynLayerGetRelativeX() {
	return (is.ns)? this.css.pageX : this.elm.offsetLeft
}
function DynLayerGetRelativeY() {
	return (is.ns)? this.css.pageY : this.elm.offsetTop
}
DynLayer.prototype.getRelativeX = DynLayerGetRelativeX
DynLayer.prototype.getRelativeY = DynLayerGetRelativeY

// DynLayer GetContent Width/Height Methods
// retrieves the total width/height of the contents of the layer when they are not known
function DynLayerUpdateSize() {
	this.updateWidth()
	this.updateHeight()
}

function DynLayerUpdateHeight() {
	this.h = this.getContentHeight()
}

function DynLayerUpdateWidth() {
	this.w = this.getContentWidth()
}

DynLayer.prototype.updateSize   = DynLayerUpdateSize
DynLayer.prototype.updateHeight = DynLayerUpdateHeight
DynLayer.prototype.updateWidth  = DynLayerUpdateWidth

function DynLayerGetContentWidth() {
	return (is.ns)? this.doc.width : this.elm.scrollWidth
}
function DynLayerGetContentHeight() {
	return (is.ns)? this.doc.height : this.elm.scrollHeight
}
DynLayer.prototype.getContentWidth = DynLayerGetContentWidth
DynLayer.prototype.getContentHeight = DynLayerGetContentHeight

// Basic Flash Write function / power[Z]one

function DynLayerpintaflashHTML(name, archivo, w, h, bg) {
	if (is.ie)  {
        	this.write('<object id="'+ name +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" WIDTH="'+ w +'" HEIGHT="'+ h +'"><PARAM NAME=movie VALUE="'+ archivo +'"><PARAM NAME=quality VALUE=high><PARAM NAME=menu    VALUE=false><PARAM NAME=loop VALUE=false><PARAM NAME=BGCOLOR VALUE="'+bg+'"><param NAME=WMODE VALUE=opaque></object>');
	} else {
		this.write('<EMBED name='+ name +' SRC="'+ archivo +'" WIDTH='+ w +' HEIGHT='+ h +' swliveconnect=true MENU=true QUALITY=high LOOP=no TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" PLAY=true BGCOLOR="'+bg+'"></EMBED>');
	}
}

DynLayer.prototype.writeFlash = DynLayerpintaflashHTML

function DynLayergetObject(objectname) {
	return is.ie ? eval(this.name+".doc."+objectname) : eval(this.name+".doc.embeds['"+objectname+"']");
}

DynLayer.prototype.getObject = DynLayergetObject