// UTILITY TO RETURN EXPAND OBJECT
function adsExpand_getObj(objKey){
	for (adsExpand_tempX = 0; adsExpand_tempX < ads_expObjArray.length; adsExpand_tempX++){
		if(ads_expObjArray[adsExpand_tempX].objKey == objKey)
			return ads_expObjArray[adsExpand_tempX];
	}
}
// UTILITY TO RETURN EXPAND ARRAY POSITION
function adsExpand_getObjNode(objKey){
	for (adsExpand_tempX = 0; adsExpand_tempX < ads_expObjArray.length; adsExpand_tempX++){
		if(ads_expObjArray[adsExpand_tempX].objKey == objKey)
			return adsExpand_tempX;
	}
}

// UTILITY TO RETURN FLASH OBJECT REFERENCE BASED ON BROWSER TYPE //
function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		if(ads_inFIF)
			return window.parent.document.getElementById(movieName);
		else
			return document.getElementById(movieName);
	} else {
		if(ads_inFIF)
			return window.parent.document[movieName]
		else		
			return document[movieName]
	}
}
// X,Y LOCATION DETECTION UTILITIES
function ads_getY(element){
	var y = 0;
	for (var e = element; e; e = e.offsetParent) // Iterate the offsetParents
		y += e.offsetTop;

	for (var e = element.parentNode; e && e !=document.body; e = e.parentNode) // Iterate the parent Nodes
		if (e.scrollTop) y -= e.scrollTop; 	// subtract scrollbar values

	//This is the Y coordinate with the doucment-internal scrolling accounted for.
	return y;
}
function ads_getX(element){
	var x = 0;
	for (var e = element; e; e = e.offsetParent) // Iterate the offsetParents
		x += e.offsetLeft;

	for (var e = element.parentNode; e && e !=document.body; e = e.parentNode) // Iterate the parent Nodes
		if (e.scrollLeft) x -= e.scrollLeft; 	// subtract scrollbar values

	//This is the Y coordinate with the doucment-internal scrolling accounted for.
	return x;
}
// CHECK MOUSE (make sure the user hasn't left the hotspot while interacting with a rollover expand)
function ads_checkMouse(){
	Handler.add(window.document.body,"mousemove", ads_getCoords);
}

// CHECK MOUSE (make sure the user hasn't left the hotspot while interacting with a rollover expand)
function fifAds_checkMouse(){
	Handler.add(parent.window.document.body,"mousemove", fifAds_getCoords);
}

// CHECK DELAY (make sure the user hasn't left the hotspot within 1 second)
function ads_checkDelay(){
	Handler.remove(window.document.body, "mousemove", ads_getDelayCoords);
	Handler.add(window.document.body,"mousemove", ads_getDelayCoords);
}

// FIF CHECK DELAY COORDS FUNCTIONS - PARENT AND CHILD WINDOW
fifParentAdsCheckDelayCoords = function(){
	Handler.remove(parent.window.document.body, "mousemove", parent.window.cbsiAdOpsObj.ads_getDelayCoords);
	Handler.add(parent.window.document.body,"mousemove", parent.window.cbsiAdOpsObj.ads_getDelayCoords);
}
fifChildAdsCheckDelayCoords = function(){
	Handler.remove(window.document.body, "mousemove", fifAds_getDelayCoords);
	Handler.add(window.document.body,"mousemove", fifAds_getDelayCoords);	
}
// DEFAULT FIF RESPONSE FOR CHILD
function fifAds_getDelayCoords(e){
	cbsiAdOpsObj.checkDelayVar = "child";
}

// MOUSE DETECTION FUNCTIONS //
// GET COORDINATES FOR ROLLOVER AUTO-COLLAPSE
function ads_getCoords(e){
	// Remove any old handlers before adding new one
	Handler.remove(window.document.body, "mousemove", ads_getCoords);	
	// The event object holds the mouse position in window coordinates
	// Convert these to document coordinates using the Geometry module	
	var x = e.clientX + Geometry.getHorizontalScroll();
	var y = e.clientY + Geometry.getVerticalScroll();		
	ads_checkCoords(x,y);
}

// MOUSE DETECTION FUNCTIONS //
// GET COORDINATES FOR ROLLOVER AUTO-COLLAPSE
function fifAds_getCoords(e){
	// Remove any old handlers before adding new one
	Handler.remove(parent.window.document.body, "mousemove", fifAds_getCoords);
	// The event object holds the mouse position in window coordinates
	// Convert these to document coordinates using the Geometry module
	var x = e.clientX + parent.window.cbsiAdOpsObj.Geometry.getHorizontalScroll();
	var y = e.clientY + parent.window.cbsiAdOpsObj.Geometry.getVerticalScroll();
	ads_checkCoords(x,y);
}


// GET COORDINATES FOR ROLLOVER 1 SEC DELAY
function ads_getDelayCoords(e){
	// Remove any old handlers before adding new one
	Handler.remove(window.document.body, "mousemove", ads_getDelayCoords);
	// The event object holds the mouse position in window coordinates
	// Convert these to document coordinates using the Geometry module
	var x = e.clientX + Geometry.getHorizontalScroll();
	var y = e.clientY + Geometry.getVerticalScroll();
	// Set the Coords of current mouse position
	ads_globalDelayRecentX = x;
	ads_globalDelayRecentY = y;
}

// MOUSE X,Y COORDS CHECK FUNCTIONS
// CHECK COORDINATES FOR ROLLOVER AUTO-COLLAPSE
function ads_checkCoords(x,y){

	var collapseBase = false;
	var collapseExpand = false;

	// get expandObj to read its hotspot coordinates
	var expandObj = adsExpand_getObj(ads_globalCurrentKey);

	if(!((x >= expandObj.ads_baseXleft) && (x <= expandObj.ads_baseXright)) || !((y >= expandObj.ads_baseYtop) && (y <= expandObj.ads_baseYbottom)))
		collapseBase = true;
		
	if(!((x >= expandObj.ads_expandXleft) && (x <= expandObj.ads_expandXright)) || !((y >= expandObj.ads_expandYtop) && (y <= expandObj.ads_expandYbottom)))
		collapseExpand = true;	
		
	if(collapseBase && collapseExpand)	
		cnetCollapse(ads_globalRolloffKey);
		
}
// CHECK COORDINATES FOR ROLLOVER 1 SEC DELAY
function ads_checkDelayCoords(){
	// remove the timer checking mouse position
	window.clearInterval(ads_globalDelayTimerInterval);
	
	// Rollover has finished after the 1 second delay
	ads_globalRolloverActive = false;
	
	// Global Var to put expand actions on hold till this expand has finished
	ads_globalOnHold = false;
		
	// get Base panel as an object to determine its position on the page	
	var expandObj = adsExpand_getObj(ads_globalCurrentKey);
	if(((ads_globalDelayRecentX >= expandObj.ads_baseXleft) && (ads_globalDelayRecentX <= expandObj.ads_baseXright)) && ((ads_globalDelayRecentY >= expandObj.ads_baseYtop) && (ads_globalDelayRecentY <= expandObj.ads_baseYbottom)))
		expandObj.runOnLoad(cnetExpandDelay);
}

// CHECK MOUSE IN FIF ENVIRONMENT FOR ROLLOVER 1 SEC DELAY
function fifAdsCheckDelayCoords(){
	
	// remove the timer checking mouse position
	window.clearInterval(fifParent_globalDelayTimerInterval);
	window.clearInterval(fifChild_globalDelayTimerInterval);	
	
	// Rollover has finished after the 1 second delay
	ads_globalRolloverActive = false;
		
	// Global Var to put expand actions on hold till this expand has finished
	ads_globalOnHold = false;		
		
	// get Base panel as an object to determine its position on the page	
	var expandObj = adsExpand_getObj(ads_globalCurrentKey);	
	
	// Simplified FIF environment check.  If mouse is on "parent" page it is not over the base panel.  If mouse is on "child" IFrame page then activate the expand.
	if(cbsiAdOpsObj.checkDelayVar=="child")
		expandObj.runOnLoad(cnetExpandDelay);	

}


// END AUTO-COLLAPSE AND MOUSE DETECTION SCRIPT //

// GLOBAL VARS

// Object to hold the expand content
var ads_expandSlide;
// Boolean for all occurances of Expand. False is closed, True is open.
var ads_globalExpandState = false;
// Global Var to put all expand actions on hold until the current Expand Animation is done animating
var ads_globalOnHold = false;
// Boolean to put expand actions on hold while one expand is still active
var ads_globalRolloverActive = false;
// Remember the Node position of most recent expand
var ads_globalExpandObjNode;
// Remember the Node position for collapse
var ads_globalCollapseObjNode;
// Global for Delay Mouse Cursor - Most Recent Position
var ads_globalDelayRecentX;
var ads_globalDelayRecentY;
// Remember the key of most recent expand
var ads_globalCurrentKey;
// Remember the Rolloff key of most recent rollover expand
var ads_globalRolloffKey;
// Check to see if Expand Movie is available yet
var ads_globalExpandChecker = false;
var ads_globalExpandCheckerCount = 0;
// Global Timer Vars
var ads_globalTimerTimeout;
var ads_globalTimerInterval;
var ads_globalTimerReset;
var ads_globalCheckTimerInterval;
var ads_globalDelayTimerInterval;

var fifParent_globalDelayTimerInterval;
var fifChild_globalDelayTimerInterval;

// CBSI AD OPS OBJECT
var cbsiAdOpsObj = {};

// EXPAND FUNCTIONS

// EXPAND - REQUIRES EXPAND AS STRING AND KEY AS NUMBER
function cnetExpand(a, b) {

// New Component Tracking Class passes 1 variable - key
if(arguments.length==1){
	var key = a;
	var expand = null;
// Old Tracking Class passes expand and key
} else {
	var expand = a;
	var key = b;		
}

// Retrieve expand Obj to access all data
var expandObj = adsExpand_getObj(key);

if(typeof(expandObj.hasRunBool) == "undefined"){
	expandObj.hasRunBool==false;
}

if ( typeof(expandObj.adsExpand_expandType) == "undefined" ) {
	if(expand==null){
		expandObj.adsExpand_expandType = "click";
	} else {
		expandObj.adsExpand_expandType = expand;	
	}
}

if ( typeof(expandObj.adsExpand_collapseType) == "undefined" ) {
	if(expand==null){
		expandObj.adsExpand_collapseType = "click";
	} else if(expand=="rollover") {
		expandObj.adsExpand_collapseType = "rolloff";
	} else {
		expandObj.adsExpand_collapseType = "rolloff";
	}
}

// Do not initiate one expand until another has finished
// if (another expand ad is not animating its expand action) AND ((the expand type is rollover AND another expand is not open currently) OR (expand type is click))
if(!ads_globalOnHold && ((expandObj.adsExpand_expandType=="rollover" && (!ads_globalRolloverActive) || expandObj.adsExpand_expandType=="click"))){
	// if the expand ad is expanded do not expand
	if(!expandObj.expandState){
		
		// Global Var to put expand actions on hold till this expand has finished
		ads_globalOnHold = true;

		// Global Var to set most recent Expand
		ads_globalCurrentKey = key;

		// Retrieve Base Panel DIV Element to control it
		var baseDiv = document.getElementById(expandObj.adsExpand_parDiv);
		// Retrieve Expand Panel DIV Element to control it
		var expandDiv = document.getElementById(expandObj.adsExpand_childDiv);

		// Locate Objects for positioning
		if(ads_inFIF){
		
			// Build the Expand Panel once on initial expand
			if(!expandObj.hasRunBool){
				cbsiRunAd();
				expandObj.hasRunBool = true;
				//parent.window.cbsiAdOpsObj.dhtmlLoadScript("http://i.i.com.com/cnwk.1d/Ads/common/js_common/Geometry.js");
			}						
			// 'baseDiv' equal to IFrame object on parent page that hosts the ad call
			var baseDiv = frameElement;
			// 'fifOffset' equal to base panel object on child page
			var fifOffset = document.getElementById(expandObj.adsExpand_parDiv);
			
			// Get x,y position of Iframe ad host
			var ads_baseXleft = parent.window.cbsiAdOpsObj.adsExpand_getX(baseDiv);
			var ads_baseYleft = parent.window.cbsiAdOpsObj.adsExpand_getY(baseDiv);			

			// Adjust position for child frame offset
			var ads_fifXOffset = ads_getX(fifOffset);
			var ads_fifYOffset = ads_getY(fifOffset);
		} else{
			// Offset value only used for FIF environments
			var ads_fifXOffset = 0;
			var ads_fifYOffset = 0;			
			// 'baseDiv' equal to Base Panel object
			var baseDiv = document.getElementById(expandObj.adsExpand_parDiv);
			// 'expandDiv' equal to Expand Panel object
			var expandDiv = document.getElementById(expandObj.adsExpand_childDiv);
			// find X position of base object
			var ads_baseXleft = ads_getX(baseDiv);
			// find y position of base object
			var ads_baseYleft = ads_getY(baseDiv);
		}
		
		// DETERMINE BASE HOTSPOT COORDINATES
		// find left mouse position
			expandObj.ads_baseXleft = ads_baseXleft + ads_fifXOffset;
		// find right mouse position by adding the base width to the left position 
			expandObj.ads_baseXright = expandObj.ads_baseXleft + expandObj.adsExpand_width;
		// find top mouse position by adding the top offset to the Base panel y position
			expandObj.ads_baseYtop = ads_baseYleft + ads_fifYOffset;
		// find bottom mouse position by adding the expand height to the top position 
			expandObj.ads_baseYbottom = expandObj.ads_baseYtop + expandObj.adsExpand_height;	

		// DETERMINE EXPAND HOTSPOT COORDINATES
		// find left mouse position by adding the left offset to the Base panel x position
			expandObj.ads_expandXleft = expandObj.ads_baseXleft + expandObj.adsExpand_leftOffset;
		// find right mouse position by adding the Expand width to the left position 
			expandObj.ads_expandXright = expandObj.ads_expandXleft + expandObj.adsExpand_widthEx;			
		// find top mouse position by adding the top offset to the Base panel y position
			expandObj.ads_expandYtop = expandObj.ads_baseYtop + expandObj.adsExpand_topOffset;
		// find bottom mouse position by adding the expand height to the top position 
			expandObj.ads_expandYbottom = expandObj.ads_expandYtop + expandObj.adsExpand_heightEx;	

		// if the expand action is a mouse rollover, add 1 second delay
		if(expandObj.adsExpand_expandType=="rollover"){
			// Begin Auto-Detection for Delay
			ads_globalDelayRecentX = expandObj.ads_baseXleft;
			ads_globalDelayRecentY = expandObj.ads_baseYtop;
			// FRIENDLY IFRAME DELAY 
			if(ads_inFIF){
				// DEFAULT SETTING'CHILD' MEANING USER MOUSE IS OVER CHILD (IFRAME) DOCUMENT
				cbsiAdOpsObj.checkDelayVar = "child";
				// SET ONE SECOND DELAY ON ROLLOVER EXPAND
				ads_globalTimerTimeout=setTimeout(fifAdsCheckDelayCoords, 1000);
				// ADD MOUSE DETECTION EVENT HANDLERS TO BOTH PARENT AND CHILD (IFRAME) PAGES
				fifParent_globalDelayTimerInterval=setInterval(fifParentAdsCheckDelayCoords, 100);
				fifChild_globalDelayTimerInterval=setInterval(fifChildAdsCheckDelayCoords, 100);				
			} else {
				// SET ONE SECOND DELAY ON ROLLOVER EXPAND
				ads_globalDelayTimerInterval=window.setInterval(ads_checkDelay, 100);
				// ADD MOUSE DETECTION EVENT HANDLER TO CURRENT PAGE
				ads_globalTimerTimeout=setTimeout(ads_checkDelayCoords, 1000);						
			}
		} else {
			expandObj.runOnReady(cnetExpandDelay);
		}
	}
}
}

// EXPAND DELAY (the expand actions triggered after the initial delay)
function cnetExpandDelay(){
	// Detect Version of IE
	version = parseFloat(navigator.appVersion.split("MSIE")[1]);

	// Retrieve expand Obj to access all data
	var expandObj = adsExpand_getObj(ads_globalCurrentKey);

	// clear the one second delay routine if expand is a rollover
	if(expandObj.adsExpand_expandType=="rollover")
		window.clearInterval(ads_globalTimerInterval);

	// set global Expand state to open
	expandObj.expandState=true;	

	// Remove On Hold from global Var
	ads_globalOnHold = false;
	
	// Unclip Expand Movie
	if(isIE && isWin && !isOpera){	
		if(ads_inFIF)
			parent.window.document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px "+expandObj.adsExpand_widthEx+"px "+expandObj.adsExpand_heightEx+"px 0px)";
		else
			document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px "+expandObj.adsExpand_widthEx+"px "+expandObj.adsExpand_heightEx+"px 0px)";
	} else {
		if(ads_inFIF)
			parent.window.document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px,"+expandObj.adsExpand_widthEx+"px,"+expandObj.adsExpand_heightEx+"px,0px)";
		else
			document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px,"+expandObj.adsExpand_widthEx+"px,"+expandObj.adsExpand_heightEx+"px,0px)";
	}
	
	// SEND COMMAND TO EXPAND MOVIE
	// Create a fast Interval to look for the Expand Movie, if movie is found the expand command will be sent
	// DO NOT SEND IF DISABLED BY VAR
	if(!expandObj.jsFLashDisable)
		ads_globalCheckTimerInterval=window.setInterval(ads_checkExpand, 50);	

	// Retrieve Base DIV to get its coordinates
	var baseDiv = document.getElementById(expandObj.adsExpand_parDiv);
	
	// find left mouse position
	var ads_baseXleft = ads_getX(baseDiv);	
	
	// find top mouse position by adding the top offset to the Base panel y position
	var ads_baseYtop = ads_getY(baseDiv);
	
	// Position Expand Panel
	var expand_x = ads_baseXleft + expandObj.adsExpand_leftOffset;
	var expand_y = ads_baseYtop + expandObj.adsExpand_topOffset;	
	if(ads_inFIF){		
		// 'newBase' equal to IFrame object on parent page that hosts the ad call
		var newBase = frameElement;	
		// 'adSlide' is reference to the expand panel 
		var adSlide = window.parent.document.getElementById(expandObj.adsExpand_childDiv);		
		// Get x,y position of Iframe ad host
		var ads_frameXleft = parent.window.cbsiAdOpsObj.adsExpand_getX(newBase);
		var ads_frameYtop = parent.window.cbsiAdOpsObj.adsExpand_getY(newBase);		
		var finalLeft = ads_frameXleft + expandObj.adsExpand_leftOffset + ads_baseXleft;					
		var finalTop = ads_frameYtop + expandObj.adsExpand_topOffset + ads_baseYtop;
		adSlide.style.top = finalTop + "px";
		adSlide.style.left = ads_frameXleft + "px";
	}else{
		var adSlide = document.getElementById(expandObj.adsExpand_childDiv);
		adSlide.style.top = expand_y + "px";
		adSlide.style.left = expand_x + "px";
	}
	
	// Set Expand DIV z-index to 4999 for proper layering
	if(ads_inFIF)
		parent.window.document.getElementById(expandObj.adsExpand_childDiv).style.zIndex=expandObj.expandIndex;
	else
		document.getElementById(expandObj.adsExpand_childDiv).style.zIndex=expandObj.expandIndex;
	
	ads_globalExpandObjNode = adsExpand_getObjNode(ads_globalCurrentKey);

	// reload tracking gif to track the expand action
	document.getElementById(expandObj.impTrack_name).src=expandObj.expandImpTrack;

	// If 3rd Party Expand Trackign supported
	if(expandObj.expandImpTrack3P){
		// reload tracking gif to track the expand action
		document.getElementById(expandObj.impTrack_name3P).src=expandObj.expandImpTrack3P;
	} 	
	
	// Initiate default mouse detection routine during expand
	if(expandObj.adsExpand_collapseType=="rolloff"){
		if(ads_inFIF){
			// Set a Rolloff Key for Auto-Collapse function
			ads_globalRolloffKey = ads_globalCurrentKey;
			// Set the Boolean to mark that Auto-Collapse is active
			ads_globalRolloverActive = true;
			// Begin Auto-Collapse		
			ads_globalTimerInterval=window.setInterval(fifAds_checkMouse, 50);
		} else {
			// Set a Rolloff Key for Auto-Collapse function
			ads_globalRolloffKey = ads_globalCurrentKey;
			// Set the Boolean to mark that Auto-Collapse is active
			ads_globalRolloverActive = true;
			// Begin Auto-Collapse
			ads_globalTimerInterval=window.setInterval(ads_checkMouse, 10);
		}
	}
}

// COLLAPSE
function cnetCollapse(key) {
	// Detect Version of IE
	version = parseFloat(navigator.appVersion.split("MSIE")[1]);

	// get Base panel as an object and as a node position to determine its position on the page	
	var expandObj = adsExpand_getObj(key);
	var expandObjNode = adsExpand_getObjNode(key);
	
	// Set Global Vars for Timeout scope
	ads_globalCollapseObjNode = expandObjNode;
	
	if(expandObj.expandState){	
		// Stop the mouse detection routine
		if(expandObj.adsExpand_collapseType=="rolloff"){
			// Set the Boolean to mark that Auto-Collapse is not active
			ads_globalRolloverActive = false;
			// Clear Auto-Collapse function
			window.clearInterval(ads_globalTimerInterval);		
		}
	
   		// Send Expand Panel command to collapse
		// DO NOT SEND IF DISABLED BY VAR
		if(!expandObj.jsFLashDisable)
			getMovieName(ads_expObjArray[ads_globalCollapseObjNode].adsExpand_expandName).callCnetCollapse();
 		
		// IE needs special formatting for the clip property
		if(isIE && isWin && !isOpera){
			if(ads_inFIF)
				parent.window.document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px 0px 0px 0px)";
			else
				document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px 0px 0px 0px)";
		} else {
			if(ads_inFIF)
				parent.window.document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px,0px,0px,0px)";
			else
				document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px,0px,0px,0px)";
		}	
		
		// Set Expand DIV z-index back to 0 for proper layering		
		if(ads_inFIF)
			parent.window.document.getElementById(expandObj.adsExpand_childDiv).style.zIndex=0;
		else
			document.getElementById(expandObj.adsExpand_childDiv).style.zIndex=0;

		// Set Global Expand state to "closed"
   		expandObj.expandState=false;

 		// Record Collapse impression
 		document.getElementById(expandObj.impTrack_name).src=expandObj.collapseImpTrack;

		// If 3rd Party Expand Trackign supported
		if(expandObj.collapseImpTrack3P){
			// reload tracking gif to track the expand action
			document.getElementById(expandObj.impTrack_name3P).src=expandObj.collapseImpTrack3P;
		} 				

	}
}

//CHECK FOR EXPAND
function ads_checkExpand(){

	// Get the current expand object
	ads_globalExpandObjNode = adsExpand_getObjNode(ads_globalCurrentKey);
	
	// Put the expand action call in an error catching loops to avoid potential errors
	try{
		// send the Expand Panel Flash Object the command to Expand
	    getMovieName(ads_expObjArray[ads_globalExpandObjNode].adsExpand_expandName).callCnetExpand();
		ads_globalExpandChecker=true;	
	}
	catch(e){
		// If expand action call fails then set the checker to false and try again
		ads_globalExpandChecker=false;
	}
	finally{
		// increase count to restrict number of loops the interval will make
		ads_globalExpandCheckerCount++;	
	}

	//If expand action call was successful or the Interval has looped too many times kill the Interval loop
	if(ads_globalExpandCheckerCount>10 || ads_globalExpandChecker==true){
		window.clearInterval(ads_globalCheckTimerInterval);
		ads_globalExpandCheckerCount=0;
	}
}

function cbsiRunAd(){

	// Retrieve expand Obj to access all data
	var key = ads_globalCurExpandArray.shift();	
	var expandObj = adsExpand_getObj(key);// Retrieve Base Panel DIV Element to control it

	if(ads_inFIF){
		// Retrieve DOM elements for positioning
		var baseDiv = window.parent.document.getElementById("ad_leader");
		var iframePos = frameElement;
		// find left mouse position
		var ads_baseXleft = parent.window.cbsiAdOpsObj.adsExpand_getX(iframePos);
		var ads_baseYleft = parent.window.cbsiAdOpsObj.adsExpand_getY(iframePos);
		var adSlide = window.parent.document.createElement('div');
		baseDiv.appendChild(adSlide);
		adSlide.id = expandObj.adsExpand_childDiv;
		adSlide.style.position = "absolute";	
		adSlide.style.top = ads_baseYleft + "px";
		adSlide.style.left = ads_baseXleft + "px";
		adSlide.style.width = expandObj.adsExpand_widthEx;
		adSlide.style.height = expandObj.adsExpand_heightEx;
		adSlide.style.zIndex = expandObj.expandIndex;				
		if(isIE && isWin && !isOpera)
			adSlide.style.clip = "rect(0px 0px 0px 0px)";
		else
			adSlide.style.clip = "rect(0px,0px,0px,0px)";
		adSlide.innerHTML = '<div>'+expandObj.ads_expandHTML+'</div>';		
		expandObj.onReadyRun();						
	} else{	
		// tempObj is a placeholder for inserting the expand layer
		var tempObj;
		// find either the first available DIV object or the first node
		for(var x=0; x<document.body.childNodes.length; x++){	
			if((document.body.childNodes[x].nodeName)=='DIV'){
				tempObj=document.body.childNodes[x];
				break;
			} else {
				tempObj=document.body.firstChild;
			}			
		}

		// Retrieve Base DIV to get its coordinates
		var baseDiv = document.getElementById(expandObj.adsExpand_parDiv);
	
		// find left mouse position
		var ads_baseXleft = ads_getX(baseDiv);	
	
		// find top mouse position by adding the top offset to the Base panel y position
		var ads_baseYtop = ads_getY(baseDiv);
	
		// Position Expand Panel
		var expand_x = ads_baseXleft + expandObj.adsExpand_leftOffset;
		var expand_y = ads_baseYtop + expandObj.adsExpand_topOffset;
		var adSlide=document.createElement('div');
		adSlide.id = expandObj.adsExpand_childDiv;
		// Insert AdSlide expand panel before the first DIV or child node found
		document.body.insertBefore(adSlide,tempObj);	
		adSlide.style.position = "absolute";	
		adSlide.style.top = expand_y + "px";
		adSlide.style.left = expand_x + "px";
		adSlide.style.width = expandObj.adsExpand_widthEx;
		adSlide.style.height = expandObj.adsExpand_heightEx;
		adSlide.style.zIndex = expandObj.expandIndex;
		if(isIE && isWin && !isOpera)
			adSlide.style.clip = "rect(0px 1px 1px 0px)";
		else
			adSlide.style.clip = "rect(0px,1px,1px,0px)";
		adSlide.innerHTML = '<div>'+expandObj.ads_expandHTML+'</div>';
		expandObj.onReadyRun();
	}
}

function ads_createExpand(o) {

	// Detect Version of IE
	version = parseFloat(navigator.appVersion.split("MSIE")[1]);	
	
	if(o.adsExpand_srcBase.indexOf(".swf") == -1){
		o.adsExpand_srcBase = o.adsExpand_srcBase+".swf";
	}
	if(o.adsExpand_srcExpand.indexOf(".swf") == -1){
		o.adsExpand_srcExpand = o.adsExpand_srcExpand+".swf";
	}
	// List Defaults for 3rd Party tracking GIFs for backwards compatability
	if ( typeof(o.impTrack_name3P) == "undefined" ) {
		o.expandImpTrack3P=""; 
		o.collapseImpTrack3P=""; 
		o.flashImpTrack3P=""; 
		o.impTrack_name3P = "ads_impTrack3P7777";
	}
	
	// jsFLashDisable
	// Var used to disable JS to Flash expand/collapse initiation.  Should be set only for cross talk creatives.
	if(o.jsFLashDisable==undefined)
		o.jsFLashDisable = false;
		
	// Z-Index for Expand Panel
	// Default is 4999 if not specified
	if(o.expandIndex==undefined)
		o.expandIndex = 4999;

	// Third Party Tracking Backwards Compatability
	if(o.defaultTrack3P==undefined)
		o.defaultTrack3P = "http://i.i.com.com/cnwk.1d/Ads/common/dotclear.gif";
			
	if(isIE && isWin && !isOpera){
		document.write('<div align="center" style="position:relative; width:100%;"><div id="'+o.adsExpand_parDiv+'" style="position:relative; width:'+o.adsExpand_width+'px; height:'+o.adsExpand_height+'px; text-align:center; margin-left:auto; margin-right:auto; z-index:0;">');
		document.write('	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+o.adsExpand_width+'" height="'+o.adsExpand_height+'" id="'+o.adsExpand_baseName+'" align="middle">');
		document.write('	<param name="allowScriptAccess" value="always" />');
		document.write('	<param name="FlashVars" value="'+o.adsExpand_flashVarsBase+'" />');
		document.write('	<param name="movie" value="'+o.adsExpand_srcBase+'" /><param name="quality" value="high" /><param name="wmode" value="'+o.adsExpand_wmodeBase+'" /><param name="bgcolor" value="'+o.adsExpand_bgcolorBase+'" /></object>');		
		document.write('<img src="'+o.flashImpTrack+'" border="0" height="1" width="1" name="'+o.impTrack_name+'" id="'+o.impTrack_name+'" style="position:absolute; top:0px; left:0px;" />');
		document.write('</div></div>');
		o.ads_expandHTML = '<div id="'+o.adsExpand_childDiv+'" style="width:'+o.adsExpand_widthEx+'px;height:'+o.adsExpand_heightEx+'px;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+o.adsExpand_widthEx+'" height="'+o.adsExpand_heightEx+'" id="'+o.adsExpand_expandName+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="FlashVars" value="'+o.adsExpand_flashVarsExpand+'" /><param name="movie" value="'+o.adsExpand_srcExpand+'" /><param name="quality" value="high" /><param name="wmode" value="'+o.adsExpand_wmodeExpand+'" /><param name="bgcolor" value="#ffffff" /></object></div>';
	} else {
		document.write('<div align="center"><div align="center" id="'+o.adsExpand_parDiv+'" style="position:relative; width:'+o.adsExpand_width+'px; height:'+o.adsExpand_height+'px; text-align:center; margin:0 auto; z-index:0;">');
		document.write('	<embed src="'+o.adsExpand_srcBase+'" quality="high" wmode="'+o.adsExpand_wmodeBase+'" bgcolor="'+o.adsExpand_bgcolorBase+'" width="'+o.adsExpand_width+'" height="'+o.adsExpand_height+'" name="'+o.adsExpand_baseName+'" align="middle" allowScriptAccess="always" FlashVars="'+o.adsExpand_flashVarsBase+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('<img src="'+ o.flashImpTrack +'" alt="impTrack" border="0" height="1" width="1" name="'+o.impTrack_name+'" id="'+o.impTrack_name+'" style="position:absolute; top:0px; left:0px;" />');
		document.write('</div></div>');
		o.ads_expandHTML = '<div id="'+o.adsExpand_childDiv+'" style="width:'+o.adsExpand_widthEx+'px;height:'+o.adsExpand_heightEx+'px;"><embed src="'+o.adsExpand_srcExpand+'" wmode="'+o.adsExpand_wmodeExpand+'" quality="high" bgcolor="'+o.adsExpand_bgcolorExpand+'" width="'+o.adsExpand_widthEx+'" height="'+o.adsExpand_heightEx+'" name="'+o.adsExpand_expandName+'" align="middle" allowScriptAccess="always" FlashVars="'+o.adsExpand_flashVarsExpand+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></div>';
	}
	// If Third Party Expand Tracking GIF
	if(o.expandImpTrack3P!=""){
		document.write('<img src="'+ o.defaultTrack3P +'" border="0" height="1" width="1" name="'+o.impTrack_name3P+'" id="'+o.impTrack_name3P+'" style="position:absolute; top:0px; left:0px;" />');
	}
	if(!ads_inFIF){
		cbsiRunAd();	
		o.runOnLoad(ads_closeClipping);
	}		
}

// Expand DIV is open with 1 pixel visible for Flash cross communication.  Close this gap after load.
function ads_closeClipping(){
	for(var x=0;x<ads_expObjArray.length;x++){
		// Retrieve expand Obj to access all data
		var expandObj = adsExpand_getObj(ads_expObjArray[x].objKey);// Retrieve Base Panel DIV Element to control it				
		// Don't Run if this is a Pushdown Ad
		if ( typeof(expandObj.pdAutoExpand) == "undefined" ) {
			// IE requires special formatting for the clip property
			if(isIE && isWin && !isOpera){	
				// Unclip the Expand object so users can see and interact with it
				document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px 0px 0px 0px)";
			} else {
				// Unclip the Expand object so users can see and interact with it
				document.getElementById(expandObj.adsExpand_childDiv).style.clip="rect(0px, 0px, 0px, 0px)";
			}
		}
	}
}


// LAUNCH THE EXPAND AD WHEN CALLED
function ads_goAd(o){

	// Version check based upon the values entered above in "Globals"
	var hasReqestedVersion = DetectFlashVer(o.requiredMajorVersion, o.requiredMinorVersion, o.requiredRevision);

	// Check to see if the version meets the requirements for playback
	if (hasReqestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed	
		ads_createExpand(o);
	} else {
		document.write(o.defaultGIF);
	}
}

// RUNTIME CODE
// Check to see if this is an Ajax Friendly IFrame Environment
var ads_inFIF = false;

if ( typeof(inDapIF) == "undefined" && typeof(inFIF) == "undefined" ) {
    // Action to take if variableName is not defined - NO ACTION
} else {
    // Action to take if variableName *is* defined
    ads_inFIF = true;	
	parent.window.cbsiAdOpsObj = {};
	parent.window.cbsiAdOpsObj.adsExpand_getX = function(element){
		var x = 0;
		for (var e = element; e; e = e.offsetParent) // Iterate the offsetParents
			x += e.offsetLeft;
		return x;
	}

	parent.window.cbsiAdOpsObj.adsExpand_getY = function(element){
		var y = 0;
		for (var e = element; e; e = e.offsetParent) // Iterate the offsetParents
			y += e.offsetTop;
		return y;
	}

	parent.window.cbsiAdOpsObj.ads_getDelayCoords = function(e){
		Handler.remove(parent.window.document.body, "mousemove", parent.window.cbsiAdOpsObj.ads_getDelayCoords);
		cbsiAdOpsObj.checkDelayVar = "parent";
	}
	
	// UTILITY TO RETURN FLASH OBJECT REFERENCE BASED ON BROWSER TYPE //
	parent.window.cbsiAdOpsObj.getMovieName = function(movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
			return window.parent.document.getElementById(movieName);
		} else {
			return window.parent.document[movieName]
		}
	}	
	
	parent.window.cbsiAdOpsObj.cbsiRunAd = function(){cbsiRunAd();}
	parent.window.cnetExpand = function(a,b){cnetExpand(a,b);}	
	parent.window.cnetCollapse = function(key){cnetCollapse(key);}	
	// REBUILD GEOMETRY FUNCTION IN PARENT PAGE
	parent.window.cbsiAdOpsObj.Geometry = {};
	if (parent.window.screenLeft) { // IE and others
		parent.window.cbsiAdOpsObj.Geometry.getWindowX = function() { return parent.screenLeft; };
		parent.window.cbsiAdOpsObj.Geometry.getWindowY = function() { return parent.screenTop; };
	}
	else if (parent.window.screenX) { // Firefox and others
		parent.window.cbsiAdOpsObj.Geometry.getWindowX = function() { return parent.screenX; };
		parent.window.cbsiAdOpsObj.Geometry.getWindowY = function() { return parent.screenY; };
	}
	if (parent.window.innerWidth) { // All browsers but IE
		parent.window.cbsiAdOpsObj.Geometry.getViewportWidth = function() { return parent.innerWidth; };
		parent.window.cbsiAdOpsObj.Geometry.getViewportHeight = function() { return parent.innerHeight; };
		parent.window.cbsiAdOpsObj.Geometry.getHorizontalScroll = function() { return parent.pageXOffset; };
		parent.window.cbsiAdOpsObj.Geometry.getVerticalScroll = function() { return parent.pageYOffset; };
	}
	else if (parent.window.document.documentElement && parent.window.document.documentElement.clientWidth) {
		// These functions are for IE6 when there is a DOCTYPE
		parent.window.cbsiAdOpsObj.Geometry.getViewportWidth =
			function() { return parent.window.document.documentElement.clientWidth; };
		parent.window.cbsiAdOpsObj.Geometry.getViewportHeight = 
			function() { return parent.window.document.documentElement.clientHeight; };
		parent.window.cbsiAdOpsObj.Geometry.getHorizontalScroll = 
			function() { return parent.window.document.documentElement.scrollLeft; };
		parent.window.cbsiAdOpsObj.Geometry.getVerticalScroll = 
			function() { return parent.window.document.documentElement.scrollTop; };
	}
	else if (parent.window.document.body.clientWidth) {
		// These are for IE4, IE5, and IE6 without a DOCTYPE
		parent.window.cbsiAdOpsObj.Geometry.getViewportWidth =
			function() { return parent.window.document.body.clientWidth; };
		parent.window.cbsiAdOpsObj.Geometry.getViewportHeight =
			function() { return parent.window.document.body.clientHeight; };
		parent.window.cbsiAdOpsObj.Geometry.getHorizontalScroll =
			function() { return parent.window.document.body.scrollLeft; };
		parent.window.cbsiAdOpsObj.Geometry.getVerticalScroll = 
			function() { return parent.window.document.body.scrollTop; };
	}

	// These functions return the size of the document.  They are not window 
	// related, but they are useful to have here anyway.
	if (parent.window.document.documentElement && parent.window.document.documentElement.scrollWidth) {
		parent.window.cbsiAdOpsObj.Geometry.getDocumentWidth =
			function() { return parent.window.document.documentElement.scrollWidth; };
		parent.window.cbsiAdOpsObj.Geometry.getDocumentHeight =
			function() { return parent.window.document.documentElement.scrollHeight; };
	}
	else if (parent.window.document.body.scrollWidth) {
		parent.window.cbsiAdOpsObj.Geometry.getDocumentWidth =
			function() { return parent.window.document.body.scrollWidth; };
		parent.window.cbsiAdOpsObj.Geometry.getDocumentHeight =
			function() { return parent.window.document.body.scrollHeight; };
	}
	// END GEOMETRY FUNCTION
}	

if(ads_globalCurExpandArray.length!=0){
	// Get Expand Object from Global Array 'ads_expObjArray'
	for(x=0;x<ads_expObjArray.length;x++){
		if(ads_expObjArray[x].objKey==ads_globalCurExpandArray[(ads_globalCurExpandArray.length-1)]){
			ads_goAd(ads_expObjArray[x]);		
		}
	}
}
