var myFontSize = "";
var CurrMenuID=0;
var userEmail="";
function getSetFontSize() {
	myFontSize = readCookie("fontSize");
	if (myFontSize == null) {
		createCookie("fontSize","regular",30);
		myFontSize = "regular";
	}
	setFontSize(myFontSize);
}

function CheckUserRegistered()
{
    //read the cookie for registered user
	var cChars = document.cookie.split(';');
	var nameEQ = "OSAM.Web.UserRequest" + "=";
	var blnCookieFound=false;
	for(var i=0; i < cChars.length; i++) 
	{
		var c = cChars[i];
		while (c.charAt(0)==' ') c = c.substring(1, c.length); 
		if (c.indexOf(nameEQ) == 0) 
		{
		    userEmail=c.substring(nameEQ.length, c.length);
		    blnCookieFound = true;
		    break;
		}
	}
	return blnCookieFound;
}

//previous function for popup
function NavigateUser1(urltoNavigate)
{
//checking whethe the user is registered or not 
    if (CheckUserRegistered() == true)
    {
	 window.open('UserNavigate.aspx?urlID='+ urltoNavigate + '&'+ userEmail);
	}
	else
	{  
	    var browser=navigator.appName;
        var b_version=navigator.appVersion;
        var version=parseFloat(b_version);
        //checking Internet Explorer
        if (browser=="Microsoft Internet Explorer")
        {
         if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
            { 
                var ieversion=new Number(RegExp.$1) ;
            }
        if(ieversion<=6)
           //open up user request window;
          window.showModalDialog('user_Request.aspx','UserRequest','dialogHeight:380px;dialogWidth=485px;status=off');  
         else
           window.showModalDialog('user_Request.aspx','UserRequest','dialogHeight:343px;dialogWidth=485px;status=off'); 
        } 
        //For other browsers  
       else
       {
        if (window.showModalDialog)
            {
            //open up user request window;
            window.showModalDialog('user_Request.aspx','UserRequest','dialogHeight:320px;dialogWidth=485px;status=off');  
            }
            //For browsers Eg:NetScape doesnot support Showmodaldialog window
        else
         {
             var w=window.open('user_Request.aspx?urlID='+ urltoNavigate,'UserRequest','height=320px,width=485,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');  
             w.focus();
         } 
         }
       
	    //Check again the cookie
	    if (CheckUserRegistered() == true)
	    {
	       window.open('UserNavigate.aspx?urlID='+ urltoNavigate + '&'+ userEmail);
	    }
	}    
}

function NavigateUser(urltoNavigate) 
{
//checking whethe the user is registered or not 
    var curURL=window.location; 
    if (CheckUserRegistered() == true)
    {
	 window.open('UserNavigate.aspx?urlID='+ urltoNavigate + '&'+ userEmail);
	}
	else
	{
	window.open('user_download_request.aspx?urlID='+ urltoNavigate + '&' + 'prevURL=' + curURL,'_self'); 
	}    
}

function toggleFontSize() {
	if (myFontSize == "regular") {
		setFontSize("large");
		updateCookieFontSize("large");
	} else if (myFontSize == "large") {
		setFontSize("regular");
		updateCookieFontSize("regular");
	}
}

function updateCookieFontSize(fS) {
	createCookie("fontSize","",30);
	createCookie("fontSize",fS,30);
}

function setFontSize(fS) {
	var contentDiv = document.getElementById("MainGroup");
//	var contentDiv1 = document.getElementById("MainGroupTable1");
//	var contentDiv2 = document.getElementById("MainGroupTable2");
//	var contentDiv3 = document.getElementById("MainGroupTable3");
//	var contentDiv4 = document.getElementById("MainGroupTable4");
//	var contentDiv5 = document.getElementById("MainGroupTable5");
//	var contentDiv6 = document.getElementById("MainGroupTable6");
//	var contentDiv7 = document.getElementById("MainGroupTable7");
//	var contentDiv8 = document.getElementById("MainGroupTable8");
//	var contentDiv9 = document.getElementById("MainGroupTable9");
//	var contentDiv10 = document.getElementById("MainGroupTable10");
//	var contentDiv11 = document.getElementById("MainGroupTable11");
	var imgEl = "fontSizeButton";
	if (fS == "large") {
		contentDiv.style.fontSize = "120%";
		
		//Check whether the table object is found - Sara
//		if (contentDiv1 !=null)	contentDiv1.style.fontSize = "120%";
//		if (contentDiv2 !=null) contentDiv2.style.fontSize = "120%";
//		if (contentDiv3 !=null) contentDiv3.style.fontSize = "120%";
//		if (contentDiv4 !=null) contentDiv4.style.fontSize = "120%";
//		if (contentDiv5 !=null) contentDiv5.style.fontSize = "120%";
//		if (contentDiv6 !=null) contentDiv6.style.fontSize = "120%";
//		if (contentDiv7 !=null)	contentDiv7.style.fontSize = "120%";
//		if (contentDiv8 !=null)	contentDiv8.style.fontSize = "120%";
//		if (contentDiv9 !=null)	contentDiv9.style.fontSize = "120%";
//		if (contentDiv10 !=null)	contentDiv10.style.fontSize = "120%";
//		if (contentDiv11 !=null)	contentDiv11.style.fontSize = "120%";
		myFontSize = "large";
		document[imgEl].src = "img/button_font_size_regular.gif";
	} else if (fS == "regular") {
		contentDiv.style.fontSize = "100%";
		//Check whether the table object is found - Sara
//		if (contentDiv1 !=null)	contentDiv1.style.fontSize = "100%";
//		if (contentDiv2 !=null) contentDiv2.style.fontSize = "100%";
//		if (contentDiv3 !=null) contentDiv3.style.fontSize = "100%";
//		if (contentDiv4 !=null) contentDiv4.style.fontSize = "100%";
//		if (contentDiv5 !=null) contentDiv5.style.fontSize = "100%";
//		if (contentDiv6 !=null) contentDiv6.style.fontSize = "100%";
//		if (contentDiv7 !=null) contentDiv7.style.fontSize = "100%";
//		if (contentDiv8 !=null) contentDiv8.style.fontSize = "100%";
//		if (contentDiv9 !=null) contentDiv9.style.fontSize = "100%";
//		if (contentDiv10 !=null)    contentDiv10.style.fontSize = "100%";
//		if (contentDiv11 !=null)    contentDiv11.style.fontSize = "100%";

		myFontSize = "regular";
		document[imgEl].src = "img/button_font_size_large.gif";
	}
}

function selectTab(itemCount, startAt, itemSelected) {

    if (CheckUserRegistered() == false && itemSelected != 1) {
        var curURL = window.location;
        NavigateUser('90');
    }
    else {
        var endAt = (startAt + itemCount) - 1;
        for (var i = startAt; i <= endAt; i++) {
            var itemID = "TabContent_" + i;
            var itemDiv = document.getElementById(itemID);
            var itemIndicatorID = "TabIndicator_" + i;
            var itemIndicatorImg = document.getElementById(itemIndicatorID);
            var itemButtonID = "TabButton_" + i;
            var itemButtonElement = document.getElementById(itemButtonID);
            if (i == itemSelected) {
                itemIndicatorImg.className = 'TabIndicatorOn';
                itemButtonElement.className = 'On';
                itemDiv.style.display = 'block';
            } else {
                itemIndicatorImg.className = 'TabIndicatorOff';
                itemButtonElement.className = 'Off';
                itemDiv.style.display = 'none';
            }
        }
    }
}



function showHideExtended(elID,anchorEl) {
	var obj1 = document.getElementById('showHideExtendedDiv_'+elID);
	var obj2 = document.getElementById('showHideExtendedButtonOpen_'+elID);
	if (obj1) {
		if (obj1.style.display == 'inline') {
			// close
			obj1.style.display = 'none';
			obj2.style.display = 'inline';
			location.href = '#'+anchorEl;
		} else {
			// open
			obj1.style.display = 'inline';
			obj2.style.display = 'none';
		}
	}
}

function showHide(e1) {
	var obj1 = document.getElementById(e1);
	if (obj1) {
		if (obj1.style.display == 'block') {
			obj1.style.display = 'none';
		} else {
			obj1.style.display = 'block';
		}
	}
}
var mfAsk = "You are leaving the O'Shaughnessy Asset Management website and entering the O'Shaughnessy Mutual Funds website.";
var amAsk = "You are leaving the O'Shaughnessy Mutual Funds website and entering the O'Shaughnessy Asset Management website.";
var osam = "http://www.osam.com";
var osmf = "http://www.osfunds.com";
function askDirect(nurl,desc) {
    if (confirm(desc) == true) {
        location.assign(nurl);
    }
}

function navOverOut(imgType,elementID,imgState) {
if(CurrMenuID==elementID)
{
return false;
}
	if (document.images) {
		var elementName = imgType + elementID + 'Img';
		var imgPath = eval(imgType + imgState + '[' + Number(elementID) + '].src');
		document[elementName].src = imgPath;
	}
}

function menuImage(imgType,elementID){
CurrMenuID=elementID;
if (document.images) {
		var elementName = imgType + elementID + 'Img';
		var imgPath = eval(imgType +'Over'+ '[' + Number(elementID) + '].src');
				document[elementName].src = imgPath;
			}
}

function imageOverOut(imgEl,imgState) {
	if (document.images) {
		var elementName = imgEl + imgState;
		var imgPath = eval(elementName + '.src');
		document[imgEl].src = imgPath;
	}
}

function fontButtonOverOut(imgState) {
	var imgEl;
	if (myFontSize == "regular") {
		imgEl = 'largerType';
	} else if (myFontSize == "large") {
		imgEl = 'regularType';	
	}
	var elementName = imgEl + imgState;
	if (document.images) {
		var elementName = imgEl + imgState;
		var imgPath = eval(elementName + '.src');
		document['fontSizeButton'].src = imgPath;
	}
}

/*---------- START: Top Nav Images ----------*/

var topNavItems = new Array(
	'Home',
	'About',
	'Philosophy',
	'Strategies',
	'Commentary',
	'Research',
	'News',
	'Careers',
	'Contact',
	'Mutual Funds'
);
var topNavOff = new Array();
var topNavOver = new Array();
var topNavAltOff = new Array();
var topNavAltOver = new Array();

/*---------- END: Top Nav Images ----------*/

/*---------- START: Toolbar Images ----------*/

var printButtonOff = new Image();
printButtonOff.src = 'img/button_print.gif';
var printButtonOver = new Image()
printButtonOver.src = 'img/button_print_over.gif';
var rssFeedButtonOff=new Image();
rssFeedButtonOff.src='img/button_rssFeed.gif';
var rssFeedButtonOver=new Image();
rssFeedButtonOver.src='img/button_rssFeed_over.gif';
var allRssFeedButtonOff=new Image();
allRssFeedButtonOff.src='img/button_allrssFeeds.gif';
var allRssFeedButtonOver=new Image();
allRssFeedButtonOver.src='img/button_allrssFeeds_over.gif';

var largerTypeOff = new Image();
largerTypeOff.src = 'img/button_font_size_large.gif';
var largerTypeOver = new Image();
largerTypeOver.src = 'img/button_font_size_large_over.gif';
var regularTypeOff = new Image();
regularTypeOff.src = 'img/button_font_size_regular.gif';
var regularTypeOver = new Image();
regularTypeOver.src = 'img/button_font_size_regular_over.gif';

/*---------- END: Toolbar Images ----------*/

function createCookie(varName, varValue, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expiration = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = varName+"="+varValue+expiration+"; path=/";
}

function readCookie(varName) {
	var cChars = document.cookie.split(';');
	var nameEQ = varName + "=";
	for(var i=0; i < cChars.length; i++) {
		var c = cChars[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;
	
}

function eraseCookie(varName) {
  createCookie(varName, "", -1);
}

  function printImage(elementID){
    if (document.images) {
		var imgPath = 'img/print_top_nav_' + elementID + '.gif';
		var elementName = 'Menu_Print_Image';
		document[elementName].style.visibility = 'visible';
				document[elementName].src = imgPath;
			}
}

//function to renavigate to the download url after user enters the details
function Renavigate(urltoNavigate,userEmail,prevURL)
{
    window.open(prevURL,'_self');
    var w=window.open('UserNavigate.aspx?urlID='+ urltoNavigate + '&EmailID='+ userEmail,'_blank');
    w.focus();
}

function OpenContactUserRequest()
{
        var browser=navigator.appName;
        var b_version=navigator.appVersion;
        var version=parseFloat(b_version);
        if (browser=="Microsoft Internet Explorer")
        {
         if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
            { 
                var ieversion=new Number(RegExp.$1) ;
            }
        if(ieversion<=6)
           //open up user request window;
          window.showModalDialog('user_Request.aspx?FromContact=true','UserRequest','dialogHeight:330px;dialogWidth=485px;status=off');  
         else
           window.showModalDialog('user_Request.aspx?FromContact=true','UserRequest','dialogHeight:250px;dialogWidth=485px;status=off'); 
        }   
       else
       {
        if (window.showModalDialog)
        {
             window.showModalDialog('user_Request.aspx?FromContact=true','UserRequest','dialogHeight:250px;dialogWidth=485px;status=off');  
        }
        else
        {
             var w=window.open('user_Request.aspx?FromContact=true','UserRequest','height=250,width=485,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');  
             w.focus();
         } 
       }
}

function CheckDownload()
{
//To set the submit button focus in userrequest
    var er = window.event.keyCode;
    if(window.event.keyCode==13)
    {
        var Button1=document.getElementById("btnDownload");
        Button1.focus();
        Button1.click();
        window.event.cancel=true;
       
    }
}

function check()
{
//To set the download button focus in userrequest
    var er = window.event;
    if(window.event.keyCode==13)
    {
    var Button1=document.getElementById("btnSubmit");
       Button1.focus();
       window.event.cancel=true;
    }
}

//function to display news content 
function DisplayNewsLink(url,type)
{
 var fileType=url.substring(url.lastIndexOf("."),url.length);
     if(fileType==".html" && type=="VID")
    {
     window.open(url,'OpenVideo','height=480,width=510,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
    }
    else
    {
     window.open(url,'OpenLink');
   }
}
function ConCatAll()
{       
    if(document.getElementById('txtPhone1').value==''|| document.getElementById('txtPhone2').value=='' || document.getElementById('txtPhone3').value=='')
    {
        document.getElementById('txtPhneConcat').value=''
    }
    else
    {
        document.getElementById('txtPhneConcat').value=document.getElementById('txtPhone1').value+'-'+document.getElementById('txtPhone2').value+'-'+document.getElementById('txtPhone3').value
    }        
    
}
function ConCatAllForContactDetail()
{       
    if(document.getElementById('ctl00_ContentPlaceHolder1_txtPhone1').value==''|| document.getElementById('ctl00_ContentPlaceHolder1_txtPhone2').value=='' || document.getElementById('ctl00_ContentPlaceHolder1_txtPhone3').value=='')
    {
        document.getElementById('ctl00_ContentPlaceHolder1_txtPhneConcat').value=''
    }
    else
    {
        document.getElementById('ctl00_ContentPlaceHolder1_txtPhneConcat').value=document.getElementById('ctl00_ContentPlaceHolder1_txtPhone1').value+'-'+document.getElementById('ctl00_ContentPlaceHolder1_txtPhone2').value+'-'+document.getElementById('ctl00_ContentPlaceHolder1_txtPhone3').value
    }        
    
}
 
 function numbersonly(e) {
var key;
var keychar;

if (window.event) {
   key = window.event.keyCode;
}
else if (e) {
   key = e.which;
}
else {
   return true;
}
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
   return true;
}
else if ((("0123456789").indexOf(keychar) > -1)) {
   return true;
}
else
   return false;
}


