//NEW IM FILE****
// *****************************************************************************
// **                                SETTINGS                                 **
// *****************************************************************************

// 'linka' use this if part of the URL is the same in ALL the links
// In this example all the files are in a subfolder called 'pages'
linka='';

// get the filename
var pathfrag = document.location.pathname;
var frag = pathfrag.split('/');
var relativeprefix ='';
var currdir='';
var absolutelink='';

var hostName = document.location.hostname;
//alert (location.href);

//this establishes the relative location of dynamic script components.

//alert(hostName.indexOf("vkm") >-1);

if (hostName.indexOf("vkm") >-1)
{
	if (document.location.href.indexOf("11112") > -1) // this is a temporary setting for search cross site linkability
	{
		environ ="devsearch"
		expected_site_parent = "absolute";
		absolutelink = "http://hqiinww16.ms.com:93/im/";		
	}
	else
	{
		environ ="vkm";
		expected_site_parent="im";
	}
}
else if (hostName.indexOf("localhost") >-1)
{				
	environ ="localhost";
	expected_site_parent="im";
	absolutelink = "/Internet_create/docs/";
}
else if (hostName.indexOf("piias762") >-1  || hostName.indexOf("piias19") >-1  || hostName.indexOf("hqias19") >-1 || hostName.indexOf("hqiinww16") >-1 || hostName.indexOf("pubtest") >-1 || hostName.indexOf("msimldevny") >-1)
{				
	environ ="QA-1";
	expected_site_parent="im";
	absolutelink="/im/";
}

else if (hostName.indexOf("search") > -1)
{

		environ ="prodsearch"
		expected_site_parent = "absolute";
		absolutelink = "http://www.morganstanley.com/im/";		
}

else if (hostName.indexOf("morganstanley") >-1 || hostName.indexOf("piiinww12") >-1 ||
			hostName.indexOf("piiinww13") >-1 || hostName.indexOf("hqiinww14") >-1 ||
			hostName.indexOf("hqiinww15") >-1 )
{				
	// production servers
	environ ="prodsearch";
	expected_site_parent="im";
	absolutelink="/im/";	
}

else if (hostName.indexOf("pisws1") >-1)
{
	environ ="webpubDEV";
	expected_site_parent="iim_redesign_site-global";	
}						 

else if (hostName.indexOf("hqsas274") >= -1)
{
	environ ="webpubDEV";
	expected_site_parent="global";
	absolutelink="/iim_public_site/global/"
}




if (document.location.href.indexOf("cgi-bin") >-1)
{				
			expected_site_parent = "absolute";
			absolutelink = "/im/";	
}



frag.reverse();
thisPage=frag[0];
currdir = frag[1]

//*** this portion of the javascript has to be changed depending on the environment in order to ensure correct relative links.

//document.write ("<BR><BR><FONT color='white'>currdir: " + currdir + "</FONT><BR><BR>");

//alert ("frag[2]: " + frag[2] + " currdir: " + currdir);


if (currdir == expected_site_parent)
{
	if (environ.indexOf("prod") == -1)
		{ 
			status = "we are in the " + environ + " environment";
		}
	
	relativprefix = '';
}
else if (currdir == 'msim_redesign')
{
	relativeprefix = '';
}
else if (frag[2] == 'mkinsights' && currdir == 'archive')
{	
	relativeprefix = "../../../";	
}
else if (frag[2] == 'prices' && currdir == 'archive' || currdir == 'servlet' || currdir == 'ffs' || frag[2] == 'publications' && currdir == 'commentary' || currdir == 'prosp' || currdir == 'shrpt' || currdir == 'strategy' || currdir == 'mkinsights'|| frag[2] == 'resources' && currdir == 'news')
{
	relativeprefix = "../../";
}
else
{
	if (expected_site_parent=="absolute")
	{
		relativeprefix = absolutelink;
		status = "we are in the " + environ + " environment";
	} else relativeprefix = "../";
}


//alert("relativeprefix:" + relativeprefix);
// Do you want to use images for the category bullets?
// If so then specify the path to your images folder from the menu page
imgPath=relativeprefix + 'common/images/';

// do you want to use images for the category bullets?
lev1img='yes';					// insert yes or no

// give image names and dimensions
lev1OpName='v_green_arrow.gif';			// open image name
lev1OpHeight='4';				// image height
lev1OpWidth='9';				// image width

lev1ClosName='h_grey_arrow.gif';		// closed image name
lev1ClosHeight='7';			// image height
lev1ClosWidth='9';				// image width

// do you want to use images for the sub-category bullets?
lev2img='no';		// insert yes or no

// give image names and dimensions
lev2Name='v_green_arrow.gif';			// image name
lev2Height='4';				// image height
lev2Width='9';					// image width

// do you want to use a text character for the sub-category bullets?
lev2Char='no';		// insert yes or no

// set bullet character for level 2 bullets
bullet = '';

// base target - the frame that the links are targetting
base = '';

// *****************************************************************************
// **                             END OF SETTINGS                             **
// *****************************************************************************

// pulls 'page' variable out of URL - do not alter
if (!window.page){ //if local override not used
	var x = 0
	page = location.search.substr(1).split("?")
	for (x=0;x<=page.length;x++) {
		eval(page)
		}
page = escape(page);
page = page.slice(7);
}


// do not alter this bit
function subMenu(name,linkb) {
 this.name = name;
 this.linkb = linkb;
}
document.write('<BASE target="' + base + '">');

// *****************************************************************************
// **                             BUILD MENU DATA                             **
// *****************************************************************************

// Home
if (page=='home') {
thisMenu = new Array();
}

if (page=='msil') {
thisMenu = new Array();
}

// Products
if (page=='prod') {
thisMenu = new Array();
thisMenu[0] = new subMenu('&nbsp;&nbsp;&nbsp;Daily Prices',relativeprefix + 'prices/index.html?page=prod');
thisMenu[1] = new subMenu('&nbsp;&nbsp;&nbsp;Alternative Investments',relativeprefix + 'products/altinvest.html?page=prod');
}

// News & Research 
if (page=='publications') {
thisMenu = new Array();
thisMenu[0] = new subMenu('&nbsp;&nbsp;&nbsp;Prospectuses',relativeprefix + 'publications/prosp/index_US.html?page=publications');
thisMenu[1] = new subMenu('&nbsp;&nbsp;&nbsp;Shareholder Reports',relativeprefix + 'publications/shrpt/index.html?page=publications');
}

// About MSIM
if (page=='contactus') {
thisMenu = new Array();
thisMenu[0] = new subMenu('&nbsp;&nbsp;&nbsp;Office Locations',relativeprefix + 'contact/officeloc.html?page=contactus');
//thisMenu[1] = new subMenu('&nbsp;&nbsp;&nbsp;Email',relativeprefix + 'contact/email.html?page=contactus');
//thisMenu[2] = new subMenu('&nbsp;&nbsp;&nbsp;Global Presence','global.html?page=about');
//thisMenu[3] = new subMenu('&nbsp;&nbsp;&nbsp;Our Clients','our_clients.html?page=about');
}

// Legal
if (page=='legal') {
thisMenu = new Array();
thisMenu[0] = new subMenu('&nbsp;&nbsp;&nbsp;Important Disclaimers',relativeprefix + 'legal/disclaimers.html?page=legal');
thisMenu[1] = new subMenu('&nbsp;&nbsp;&nbsp;Section 16 Filings',relativeprefix + 'legal/sec16.html?page=legal');
thisMenu[2] = new subMenu('&nbsp;&nbsp;&nbsp;Proxy Voting',relativeprefix + 'legal/proxy.html?page=legal');

}
