/**
 **  Copyright 2006 Blingo, Inc.
 **/

function pngImage(imageURI, width, height) {

    var string;
    var agent = navigator.userAgent.toLowerCase();

    if (agent.indexOf("msie") != -1) {
	var style = 'width: ' + width + 'px; height: ' + height + 'px; ' +
		    'filter:progid:' +
		    'DXImageTransform.Microsoft.AlphaImageLoader(src=' +
		    imageURI + ');';

	string = '<div style="' + style + '"></div>';

    } else {
	string = '<img src="' + imageURI + '" width=' + width +
		 ' height=' + height + '>';
    }

    document.write(string);
}

/**  PENDING: [bkr] allow hostname parm to be passed
 *   to this routine rather than using hardcoded string.
 *   Used by Promotion.pm 
 */ 

function setHomePageIE(obj) {
    var agent = navigator.userAgent.toLowerCase();

    if (agent.indexOf("msie") != -1 &&
	parseInt(navigator.appVersion) >= 4 &&
	agent.indexOf("win") != -1) {

	obj.style.behavior = 'url(#default#homepage)';
	obj.setHomePage('http://www.blingo.com/?src=hp');

	return 1;
    } else {
	return 0;
    }
}


function eliminateFrame() {
    if (top.location != location) {
	top.location.href = document.location.href;
    }
}


function preload(src) {
	var image = new Image();
	image.src = src;
}

function getDescendantWithName(ancestor, name) {
	var descendant;
	for (var i = ancestor.childNodes.length - 1; i >= 0; i--) {
		var child = ancestor.childNodes[i];
		if (child.getAttribute && (child.getAttribute("name") == name)) {
			descendant = child;
		} else if (child.hasChildNodes) {
			descendant = getDescendantWithName(child, name);
		}
		if (descendant) {
			break;
		}
	}

	return descendant;
}


