<!--//--><![CDATA[//><!--
//if (window.attachEvent) window.attachEvent("onload", init);
window.onload = init;
window.onresize = resize;
//if (window.attachEvent) window.attachEvent("onresize", resize);

function resize() {
	changeHeight();
}

/*SIMILAR TO getElementById()*/
function getElementsByClassName(node, classname){
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
		if(re.test(els[i].className))a.push(els[i]);
	return a;}
	
	
	function init() {
		try { checkHeight(); }		catch(e) { }

	}


	

/* resize margin-bottom for main */

var orig_margin = 10;
var body_height;
function checkHeight()
{
	body_height = document.body.clientHeight;
	//alert(body_height);
	changeHeight();
}



function changeHeight()
{
	
	// body_height = document.body.clientHeight;
	browser_height = document.documentElement.clientHeight;
	//alert(browser_height);
	if (current_font_size == "large") {
		diff = browser_height - body_height - height_increment;
	}
	else {
		
		diff = browser_height - body_height;
	}
	
	el = document.getElementById("dummy");
//	alert('hi')
	
	if (el.style.paddingBottom == "") {
		orig_paddingBottom = 0;
		//alert("orig_paddingBottom is  is null");
	}
	else {
		orig_paddingBottom = parseInt(el.style.paddingBottom);
		//alert("paddingBottom is not null: " + parseInt(el.style.paddingBottom));
	}
		
		
		if (diff > 0) {
				new_paddingBottom =  diff;
		}
		else {
				new_paddingBottom = 0;
				
		}
		
		el.style.paddingBottom = new_paddingBottom + "px";
		
} 

	function getElementsByClassName(node, classname)
	{
		var a = [];
		var re = new RegExp('\\b' + classname + '\\b');
		var els = node.getElementsByTagName("*");
		for(var i=0,j=els.length; i<j; i++)
			if(re.test(els[i].className))a.push(els[i]);
		return a;
	}




var change_font_size = 0;
var new_body_height;
var height_increment = 0;
var current_font_size = "small";

function compute_height_increment() {
	if (change_font_size == 0) {
		new_body_height = document.body.clientHeight;
		height_increment = new_body_height - current_body_height;
		// alert(height_increment);
		change_font_size = 1;
	}
}
// Toggles Font-Size and Line-Height on content pages.
	function changeLabel(toggle){
		if(document.getElementById("puText")){
			// Number of <li> tags in the document, as well as an array containing references
			var LI_length = document.getElementById("columnMain").getElementsByTagName("li").length;
			var LI_arr = document.getElementById("columnMain").getElementsByTagName("li");
			
			// Number of <p> tags in the document, with an array of references
			var P_length = document.getElementById("columnMain").getElementsByTagName("p").length;
			var P_arr = document.getElementById("columnMain").getElementsByTagName("p");
			
			// Toggles the Text Size Icon and resizes text
			if(toggle == 'large'){
				if (change_font_size == 0) {
					current_body_height = document.body.clientHeight;
				}
				current_font_size = "large";
				
				document.getElementById("puText").className = "iconTextReduce";
				document.getElementById("puText").innerHTML = "smaller type";
				document.getElementById("puText").href = "javascript:changeLabel('small');";
				// Change all <li>s lineHeight to greater percentage
					for(k = 0; k < LI_length; k++){ 
						if(LI_arr[k].className == 'anchors') {
							LI_arr[k].style.lineHeight = "150%" 
							LI_arr[k].style.fontSize = "110%" 
						}
					}
				// Change all <p>s lineHeight to greater percentage
					for(j = 0; j < P_length; j++){ 
						P_arr[j].style.lineHeight = "150%" 
						P_arr[j].style.fontSize = "110%" 
					}
				createCookie('textSize', 'large', 30);
				// added temp YC
				compute_height_increment();
				changeHeight();
				
				
				} 
			else {
				current_font_size = "small";
				document.getElementById("puText").className = "iconTextEnlarge";
				document.getElementById("puText").innerHTML = "larger type";
				document.getElementById("puText").href = "javascript:changeLabel('large');";
				document.getElementById("columnMain").style.fontSize = "";
				// Change all <li>s back to default lineHeight
					for(k = 0; k < LI_length; k++){ 
						LI_arr[k].style.lineHeight = ""; 
						LI_arr[k].style.fontSize= ""; 
					}
				// Change all <p>s back to default lineHeight
					for(j = 0; j < P_length; j++){ 
						P_arr[j].style.lineHeight = ""; 
						P_arr[j].style.fontSize = ""; 
					}
					createCookie('textSize', 'small', 30);
				changeHeight();
				}
		}
	}

// Used to set a cookie with the user's font-size preference
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	//alert('Cookie\n' + name + '\ncreated with a value ' + value);
}

// Returns the cookie value
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// Used onLoad to set document text size
function userTextSize(){
	size = readCookie('textSize'); 
	changeLabel(size);
}


// Select Box Links
// Purpose: To make the option values in a select menu links.
// Useage: 	Place 'onchange="selectLinks('parent',this,0)' in the <select> tag
// 			and give each <option> a value parameter which will serve as the link
// Example:
//		<select style="width: 100%;" onchange="selectLinks('parent',this,0)">
//			<option selected>Select Prospectus</option>
//			<option value="http://www.ml.com">ML Large Cap Core Fund</option>
//			<option value="http://www.website.org">ML Bond Fund - Core Bond Portfolio</option>
//			<option value="http://www.website.com">ML Low Duration Fund </option>
//		</select>
function selectLinks(targ,selObj,restore){
	//alert('hi');
	//selObj.options[selObj.selectedIndex].value += "&cmty=" + community;
	//alert(selObj.options[selObj.selectedIndex].value);
	ddvalue = (selObj.options[selObj.selectedIndex].value)
	
	if (ddvalue == '') {
		return }
	else {
	if (targ=="self") {
		window.open(selObj.options[selObj.selectedIndex].value);
 }
	else {	
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value + "'");
	if (restore) selObj.selectedIndex = 0;
	}
	}
}

// Added: YC
// Purpose: To go to a specific location (i.e. named tag) in the same page using a drop-down (the
// select tag).
// "sel" is the select object.
// Set the value of the first entry to an empty string.

function processOptions(sel) {
	var loc = sel.options[sel.selectedIndex].value;
	if (loc != "") {
		document.location = loc;
	}
}

//estudio popup window

var newwindow = '';

function popitup(url)
{
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'name','height=600,width=600,scrollbars=yes');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}


//--><!]]>

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


function isValidEmail(sText) {
    var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
    return reEmail.test(sText);
}

//Redirect Cookie code
function setRedirectCookie(regionalUrl) {
	var today = new Date();
	today.setTime(today.getTime());
	var expires = 364 * 1000 * 60 * 60 * 24;
	var expiresDate = new Date( today.getTime() + (expires) );

	var cookieString = 'br_regional_redirect=' + escape(regionalUrl) + ';expires=' + expiresDate.toGMTString() + ';path=/;';
 	document.cookie = cookieString;

	//alert("set cookie=" + cookieString);
}
