// xp_progressbar
// Copyright 2004 Brian Gosselin of ScriptAsylum.com
//
// v1.0 - Initial release
// v1.1 - Added ability to pause the scrolling action (requires you to assign
// the bar to a unique arbitrary variable).
// - Added ability to specify an action to perform after a x amount of
// - bar scrolls. This requires two added arguments.
// v1.2 - Added ability to hide/show each bar (requires you to assign the bar
// to a unique arbitrary variable).
// var xyz = createBar(
// total_width,
// total_height,
// background_color,
// border_width,
// border_color,
// block_color,
// scroll_speed,
// block_count,
// scroll_count,
// action_to_perform_after_scrolled_n_times
// )
// With modifications by Henry Postulart 2008
// to support a lightbox-like implementation
// Additional support code required from calling application
var w3c = (document.getElementById)?true:false;
var ie = (document.all)?true:false;
var N = -1;
var scW = document.documentElement.offsetWidth;
function createBar(w, h, bgc, brdW, brdC, blkC, speed, blocks, count, action, frameDoc, message)
{
if (ie || w3c)
{
var l = parseInt(((document.documentElement.clientWidth - w) / 2), 10);
var top = parseInt(((document.documentElement.clientHeight - h) / 2), 10);
var t = '' +
'
' +
'' +
'
' + message + '' +
'
' +
'';
for (i = 0; i < blocks; i++)
{
t += '';
}
t += '
';
document.write(t);
var bA = (ie)?document.all.blocks:document.getElementById('blocks');
bA.bar = (ie)?document.all.xpbar:document.getElementById('xpbar');
bA.barC = (ie)?document.all.progressBarContainer:document.getElementById('progressBarContainer');
bA.barM = (ie)?document.all.progressBarMask:document.getElementById('progressBarMask');
bA.barF = (ie)?document.all.xpbar_frame:document.getElementById('xpbar_frame');
bA.blocks = blocks;
bA.N = N;
bA.w = w;
bA.h = h;
bA.speed = speed;
bA.ctr = 0;
bA.count = count;
bA.action = action;
bA.togglePause = togglePause;
bA.showBar = function()
{
this.barC.style.display = "block";
this.barF.style.display = "block";
this.barM.style.display = "block";
this.bar.style.display = "block";
};
bA.hideBar = function()
{
//return;
this.bar.style.display = "none";
this.barM.style.display = "none";
this.barF.style.display = "none";
this.barC.style.display = "none";
};
bA.tid = setInterval('startBar()', speed);
return bA;
}
}
function startBar()
{
var t = (ie)?document.all.blocks:document.getElementById('blocks');
if (parseInt(t.style.left, 10) + t.h + 1 - (t.blocks * t.h + t.blocks) > t.w)
{
t.style.left = -(t.h * 2 + 1) + 'px';
t.ctr++;
if (t.ctr >= t.count)
{
eval(t.action);
t.ctr = 0;
}
}
else t.style.left = (parseInt(t.style.left) + t.h + 1) + 'px';
}
function togglePause()
{
if (this.tid == 0)
{
this.tid = setInterval('startBar()', this.speed);
}
else
{
clearInterval(this.tid);
this.tid = 0;
}
}
var regBar = createBar(300, 15, 'white', 1, 'black', '#3399FF', 25, 7, 3, '', '/main/shared/inc/blank.inc', 'Please wait while your request is processed...');
regBar.hideBar();
regBar.togglePause();
function displayProgressBar()
{
regBar.showBar();
regBar.togglePause();
}
function progressTimer()
{
setTimeout("displayProgressBar();", 8000);
}
function isValidForm(form)
{
var isValid = true;
if (form.target)
{
isValid = false;
}
return isValid;
}
function isValidLink(link)
{
var isValid = true;
if (link.target)
{
isValid = false;
}
else if (link.href.indexOf("#") >= 0)
{
isValid = false;
}
else if (link.href.indexOf("javascript") != -1)
{
isValid = false;
}
else if (link.href.indexOf("mailto") != -1)
{
isValid = false;
}
else if (link.href.indexOf(".mp3") != -1)
{
isValid = false;
}
else if (link.href.indexOf(".exe") != -1)
{
isValid = false;
}
else if (link.href.indexOf(".pdf") != -1)
{
isValid = false;
}
else if (link.href.indexOf(".zip") != -1)
{
isValid = false;
}
else if (link.href.indexOf(".php") != -1)
{
isValid = false;
}
else if (link.href.indexOf("/redirect/") != -1)
{
isValid = false;
}
else if (link.href.indexOf("/jsd") != -1)
{
isValid = false;
}
else if (link.href.indexOf("jepptech.com") != -1)
{
isValid = false;
}
else if (link.href.indexOf("textviewer") != -1)
{
isValid = false;
}
else if (link.href.indexOf("jifp") != -1)
{
isValid = false;
}
return isValid;
}
function assignProgressTimer()
{
if (window.addEventListener)
{
for (var i = 0; i < document.forms.length; i++)
{
if (isValidForm(document.forms[i]))
{
document.forms[i].addEventListener('submit', progressTimer, false);
}
}
for (var i = 0; i < document.links.length; i++)
{
if (isValidLink(document.links[i]))
{
document.links[i].addEventListener('click', progressTimer, false);
}
}
}
else if (window.attachEvent)
{
for (var i = 0; i < document.forms.length; i++)
{
if (isValidForm(document.forms[i]))
{
document.forms[i].attachEvent('onsubmit', progressTimer);
}
}
for (var i = 0; i < document.links.length; i++)
{
if (isValidLink(document.links[i]))
{
document.links[i].attachEvent('onclick', progressTimer);
}
}
}
}
if (window.addEventListener)
{
window.addEventListener('load', assignProgressTimer, false);
}
else if (window.attachEvent)
{
window.attachEvent('onload', assignProgressTimer);
}