//-----------------------------------------------
// OpenX Functions :
//-----------------------------------------------
var adPositions = new Array;
function writeAdDiv(name, ad_width, ad_height) {
    document.write('<div id="'+name+'" style="padding:0; margin:0; width:'+ad_width+'px; height:'+ad_height+'px; line-height:' + ad_height + 'px;">&nbsp;</div>');
    adPositions[name] = name;
}
//-----------------------------------------------
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; }
	
	
	
	var p = $(targetObj).offset();
		
    sourceObj.style.left = p.left;
    sourceObj.style.top = OpenX_findPosY(targetObj);		
	sourceObj.style.display = "block";
}
//-----------------------------------------------
function OpenX_positionDiv(zoneName) {

	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);
	}
}
