<!--

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	if ( !selObj || selObj.options[selObj.selectedIndex].value == "" )
		return;

	// if menu2 then external URL; pop new window
	if ( selObj && selObj.name == "menu2" ) {
      // MG  2000/8/30 - no longer spawinging new window to WSJ.com
      var target = selObj.options[selObj.selectedIndex].value;
      self.location.href = target;
      //var winName = 'WSJ';
      //var winParams = '';
		//window.open( target, winName )	
		//winName.focus;
		//return;	
	}
		
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore)
		selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v3.0
	var p,i,x;
	if(!d)
		d=document;
	if( (p=n.indexOf("?") ) > 0 && parent.frames.length ) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if( !(x=d[n]) && d.all )
		x=d.all[n];
	for  (i=0; !x && i < d.forms.length; i++ )
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document); 
   return x;
}

function MM_jumpMenuGo( selName, targ, restore ) { //v3.0
	var selObj = MM_findObj(selName);
	if (selObj)
		MM_jumpMenu(targ,selObj,restore);
}


function submitSearch() {
   if( document.forms['ojsearch'].where[1].checked ) {
		var target = "http://online.wsj.com/archive/search.cgi?template=atlas-srch-searchrecent-nf.tmpl&";
			target += "form=atlas-srch-searchrecent-nf.html&from-and=AND&to-and=AND&sort=Article-Doc-Date+desc&qand=&";
			target += "bool_query=" + escape(document.forms['ojsearch'].words.value) + "&dbname=wsjie&named=dbname&location=article&period=:27&maxitems=30";
			window.open(target,"");
	} else {
		document.forms['ojsearch'].submit();
	}
}

// -------------------------------------------------
// doubleclick, segment code & UBID

// for layers to be exposed at end of page before body
var dcLayerExpose = new Array();

// this will expose all of the doubleclick ad layers
function exposeDcLayers() 
{
   if ( dcLayerExpose && document.layers ) {
   	var i;
   	for ( i=0; i<dcLayerExpose.length; i++ ) {
   		document.write( dcLayerExpose[i] );
   	}
   }
}

// for page's doubleclick ads
var globalRand;
var UBIDCookie;
var segmentCookie;

// Assign my default segment value if no cookie segments are available
var firstSeg = '';
var secondSeg = '';
var thirdSeg = '';
	

function getCookieVal (offset) { 
   var endstr = document.cookie.indexOf (";", offset); 
   if (endstr == -1) 
      endstr = document.cookie.length; 
   return unescape(document.cookie.substring(offset, endstr)); 
} 

function GetCookie (name) { 

        var arg = name + "="; 
        var alen = arg.length; 
        var clen = document.cookie.length; 
        var i = 0; 

        while (i < clen) { 
                var j = i + alen; 
                if (document.cookie.substring(i, j) == arg) 
                        return getCookieVal (j); 
                i = document.cookie.indexOf(" ", i) + 1; 
                        if (i == 0) 
                                break; 
                } 
   return null; 
} 

function GetUBID (ubid) { 
	var str = ubid;
	if(str == null) return "";	
	var end=(str.indexOf("!"));
	
	if (end == "0" || end == "") {
		
		return "";
		
	} else {
		
		return escape(str.substring(0,end));
	}

} 


function parseDmSegment() {
   // Declare variables
	var segCookie, ampTokens, numSegs, segs;
	
	// Segment cookie name
	var cookieNameDm = "DMSEG";
	
	// Grab the segment cookie
	if( (segCookie = getDMCookie(cookieNameDm)) != null)
	{
	
	// Decode cookie
	segCookie = unescape(segCookie);	
	
	// Split the segment cookie
	ampTokens = segCookie.split("&");
	
		// Check to make sure there are 6 tokens
		if(ampTokens.length >= 6)
		{
		
			// Split out the segments
			segs = ampTokens[5].split(",");
			if (segs.length > 0)
			{
			
				// Grab the highest priority segment
				firstSeg = segs[0];
							
				// Grab the highest priority segment
				secondSeg = segs[1];
		
				// Grab the highest priority segment
				thirdSeg = segs[2];
		
			}
		}
	}
   return;
}
	
// Supporting function to extract cookie value
function getDMCookie(n) {

   var co = document.cookie;
   var pos = co.indexOf(n+"=");
   return pos != -1 ? co.substring(pos+n.length+1,(co.indexOf("; ",pos)!= -1 ?
   co.indexOf("; ",pos):co.length)):null;
}

// assigns firstSeg, secondSeg, & thirdSeg
parseDmSegment();

// doubleclick-specific vars
globalRand = Math.round( Math.random() * 9000000000000000 ) + 1000000000000000;
UBIDCookie = GetUBID(GetCookie("UBID"));
segmentCookie = ( GetCookie("segment") ) ? GetCookie("segment") : "";

//-->


