var delay = 100; //animation speed
//var imgLocation = "http://img.superpages.com/images-yp/alert/images/";
var imgLocation = "https://imgssl.superpages.com/images-yp/alert/images/";
var alertDiv, alertTb, containerBox;
var tableTop, tableLeft, tableWidth, tableHeight, twexp, thexp;
function preloadImages() {
var d=document;
if(d.images){
if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=preloadImages.arguments;
for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){
d.MM_p[j]=new Image;
d.MM_p[j++].src=imgLocation+a[i];
}
}
}
function findDOM(objectId) {
if (document.getElementById) {
return (document.getElementById(objectId));}
if (document.all) {
return (document.all[objectId]);}
if (document.layers) {
return (document.layers[objectId]);}
}
//calls the function to change the background image at repeated intervals
//start index, incremented by increment, until we reach stop index
//this can go up or down - (used to open or close)
function doChangeStyle(elem,backImage,intervals,start,increment,stop) {
if (elem.changeMemInt)
window.clearInterval(elem.changeMemInt);
var step = start;
elem.changeMemInt = window.setInterval(
function() {
if (step==0) {
elem.style.background= 'transparent url('+imgLocation+'spacer.gif) repeat-x 0 0;';
}
else {
elem.style.background= 'transparent url('+imgLocation+backImage+step+'.gif) repeat-x 0 0;';
}
step+=increment;
if (step == stop) window.clearInterval(elem.changeMemInt);
}
,intervals);
}
function doClose(elem, winFile, fr){
doChangeStyle(elem,winFile,delay,fr,-1,0);
setTimeout("containerBox.style.visibility='hidden'",delay*fr+100);
}
function setupTb(div, tb, w, h) {
alertDiv=findDOM(div);
alertTb=findDOM(tb);
tableTop = getStyle(alertTb, "top");
tableLeft = getStyle(alertTb, "left");
tableWidth = getStyle(alertTb, "width");
tableHeight = getStyle(alertTb, "height");
twexp = parseFloat(tableWidth.replace('px',""))+w;
thexp = parseFloat(tableHeight.replace('px',""))+h;
}
function setupContainer(box) {
var scroll = scrollingDetector();
var psHeight = getPageSize('windowHeight');
var tbd = thexp/2;
var sTop = psHeight/2-tbd + scroll;
containerBox=findDOM(box);
containerBox.style.visibility="visible";
containerBox.style.top=sTop+"px";
}
function tbPropsc(){
alertTb.style.top=0;
alertTb.style.left=0;
alertTb.style.width=twexp+"px";
alertTb.style.height=thexp+"px";
alertTb.style.visibility="visible";
}
function tbPropnm(c){
var vis;
if(c == "op"){
alertDiv.style.visibility="visible";
}else {
vis = "hidden";
alertTb.style.visibility="hidden";
alertDiv.style.visibility="hidden";
}
alertTb.style.width=tableWidth;
alertTb.style.height=tableHeight;
alertTb.style.top=tableTop;
alertTb.style.left=tableLeft;
}
/* from http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/
Example call of the function:
getStyle(document.getElementById("container"), "font-size");
The version if you expect any IE 5.0 users whatsoever
*/
function getStyle(oElm, strCssRule){
var strValue = "";
if(document.defaultView && document.defaultView.getComputedStyle){
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
}
else if(oElm.currentStyle){
try{
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
return p1.toUpperCase();
});
strValue = oElm.currentStyle[strCssRule];
}
catch(e){
// Used to prevent an error in IE 5.0
}
}
return strValue;
}
function scrollingDetector(){
var position = 0;
if (navigator.appName == "Microsoft Internet Explorer"){
position = document.body.scrollTop;
} else {
position = window.pageYOffset;
}
return position;
}
function getPageSize(w){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
var pageHeight, pageWidth;
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
if(w=="pageWidth") return pageWidth;
else if(w=="pageHeight") return pageHeight;
else if(w=="windowWidth") return windowWidth;
else if(w=="windowHeight") return windowHeight;
}
function needHideSelect(ID) {
if(document.getElementById(ID)) {
var test = document.getElementById(ID);
if (test.currentStyle) return true;
else return false;
}
}
function ieHideSelect(ID,show) {
if(!document.getElementById("boxHide")) {
// create the iframe if it doesn't already exist
var boxHideIframe = document.createElement("iframe");
boxHideIframe.setAttribute("id","boxHide");
boxHideIframe.setAttribute("src","about:blank");
boxHideIframe.setAttribute("scrolling","no");
boxHideIframe.setAttribute("frameBorder","0");
boxHideIframe.style.display = "none";
boxHideIframe.style.position = "absolute";
boxHideIframe.style.top = "0";
boxHideIframe.style.left = "0";
boxHideIframe.style.zIndex = "1";
boxHideIframe.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
document.body.appendChild(boxHideIframe);
}
var iframe = document.getElementById("boxHide");
if(document.getElementById(ID)) {
var subnavmenu = document.getElementById(ID);
if (subnavmenu.currentStyle) {
iframe.style.display = (!show) ? "block" : "none";
if(!show) {
iframe.src = "javascript:;";
iframe.style.display = "block";
iframe.style.top = subnavmenu.currentStyle['top'];
iframe.style.left = subnavmenu.currentStyle['left'];
iframe.style.width = subnavmenu.offsetWidth;
iframe.style.height = subnavmenu.offsetHeight;
iframe.style.position = "absolute";
iframe.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
subnavmenu.iframe = subnavmenu.parentNode.insertBefore(iframe, subnavmenu);
}
}
}
}
