var adPositions = new Array;


// DIV moving code
function OpenX_findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
    }
	return curleft;
}

function OpenX_findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
    }
	return curtop;
}

function OpenX_moveAbove(sourceObj,targetObj) {
    var height = 0;
    if (sourceObj.offsetHeight) {
        height = sourceObj.offsetHeight;
    } else if (sourceObj.clip && sourceObj.clip.height) {
        height = sourceObj.clip.height;
    } else if (sourceObj.style && sourceObj.style.pixelHeight) {
        height = sourceObj.style.pixelHeight;
    }
    
    if (window.XMLHttpRequest) {
		if(document.all) { //IE7
		} else { // Mozilla, etc
			targetObj.style.paddingTop=0;targetObj.style.paddingBottom=0;
		}
	} else{ // IE6, older browsers
	}
    if (height > 0) {targetObj.style.height = height; }
    $(sourceObj).css('left',OpenX_findPosX(targetObj));
    $(sourceObj).css('top',OpenX_findPosY(targetObj));
    $(sourceZoneDivID).fadeIn(1000);
    setTimeout(function(){$(targetObj).css('background','none');$(targetObj).html('')},1000);
  
}

function OpenX_positionDivs() {

    for (var zoneName in adPositions) {
        var offScreenZoneName = zoneName + '-Hidden';
        if (document.getElementById) {
            targetZoneDivID = document.getElementById(zoneName);
            sourceZoneDivID = document.getElementById(offScreenZoneName);
        } else if (document.all) {
            targetZoneDivID = document.all[zoneName];
            sourceZoneDivID = document.all[offScreenZoneName];
        } else if (document.layers) {
            targetZoneDivID = document.layers[zoneName];
            sourceZoneDivID = document.layers[offScreenZoneName];
        }
        if ((targetZoneDivID != null) && (sourceZoneDivID != null)) {
    		OpenX_moveAbove(sourceZoneDivID, targetZoneDivID);
    		
        }
    }
}

function OpenX_positionDiv(divId) {
	var zoneName = divId;
	var offScreenZoneName = divId + '-Hidden';
        if (document.getElementById) {
            targetZoneDivID = document.getElementById(zoneName);
            sourceZoneDivID = document.getElementById(offScreenZoneName);
        } else if (document.all) {
            targetZoneDivID = document.all[zoneName];
            sourceZoneDivID = document.all[offScreenZoneName];
        } else if (document.layers) {
            targetZoneDivID = document.layers[zoneName];
            sourceZoneDivID = document.layers[offScreenZoneName];
        }
        if ((targetZoneDivID != null) && (sourceZoneDivID != null)) {
    		OpenX_moveAbove(sourceZoneDivID, targetZoneDivID);
        }
    
}
var addEventAdPositioning = function(elem, type, eventHandle) {
    if (elem == null || elem == undefined) return;
    if ( elem.addEventListener ) {
        elem.addEventListener( type, eventHandle, false );
    } else if ( elem.attachEvent ) {
        elem.attachEvent( "on" + type, eventHandle );
    }
};



