function goToMarketingPage(advPage, version, fpn_base) {
	var randomNumber = Math.floor(Math.random() * 9999999);
	var advMarketPage = "/downloads/fpn/fpnMarketingPage.html";
	if (version == 'P' || version == 'p') {
		advMarketPage = "/downloads/fpn/fpnMarketingPagep.html";
	}
	var userEmail = "";
	if(parent.document.getElementById("userEmail"))
		userEmail = parent.document.getElementById("userEmail").value;
	if(parent.document.getElementById("mainfpn")) {
		parent.document.getElementById("mainfpn").src = fpn_base + advMarketPage + "?user=" + userEmail + "&page=" + advPage + "&r=" + randomNumber;
	}
}

function goToArticle(link) {
	var userEmail = "";
	if(document.getElementById("userEmail"))
		userEmail = document.getElementById("userEmail").value;
	if(parent.document.getElementById("mainfpn")) {
		if(link.indexOf("?") > -1)
			parent.document.getElementById("mainfpn").src = link + "&user=" + userEmail;
		else
			parent.document.getElementById("mainfpn").src = link + "?user=" + userEmail;
	}
}
	
function setSearchType(theImage, version, fpn_base) {
	var button = "Ticker";
	if(theImage == 1) {
		document.getElementById('tickerBtn').className = 'srchBtnsOn';
		document.getElementById('nameBtn').className = 'srchBtnsOff';
		document.getElementById('advisenBtn').className = 'srchBtnsOff';
	} else if(theImage == 2) {
		document.getElementById('tickerBtn').className = 'srchBtnsOff';
		document.getElementById('nameBtn').className = 'srchBtnsOn';
		document.getElementById('advisenBtn').className = 'srchBtnsOff';
		button = "Company Name";
	} else if(theImage == 3) {
		document.getElementById('tickerBtn').className = 'srchBtnsOff';
		document.getElementById('nameBtn').className = 'srchBtnsOff';
		document.getElementById('advisenBtn').className = 'srchBtnsOn';
		button = "Advisen Search";
	} else if(theImage == 4) {
		document.getElementById('personBtn').className = 'srchBtnsOn';
		document.getElementById('companyBtn').className = 'srchBtnsOff';
		button = "Person Name";
	} else if(theImage == 5) {
		document.getElementById('personBtn').className = 'srchBtnsOff';
		document.getElementById('companyBtn').className = 'srchBtnsOn';
		button = "Person Company";
	}
	goToMarketingPage(button, version, fpn_base);
}

function enterKeySearch(searchType, version, fpn_base) {
	if(searchType == 'Name')
		setSearchType(2, version, fpn_base);
	else if(searchType == 'CompanyId')
		setSearchType(3, version, fpn_base);
	else if(searchType == 'Ticker')
		setSearchType(1, version, fpn_base);
	else if(searchType == 'Person')
		setSearchType(4, version, fpn_base);
	else if(searchType == 'Company')
		setSearchType(5, version, fpn_base);
} 

// Menu Functions & Properties

var activeMenu = null;

function showLeftMenu(menuGroupName, imageDir) {
	var selectedMenu = document.getElementById(menuGroupName);
	var menu = selectedMenu.getElementsByTagName('ol');
	var selectedMenuImg = document.getElementById(menuGroupName + '_img');

	if(activeMenu) {
		if(activeMenu != menuGroupName) {
			var prevMenu = document.getElementById(activeMenu);
			var prevMenuList = prevMenu.getElementsByTagName('ol');
			var prevMenuImg = document.getElementById(activeMenu + '_img');
			for(i = 0; i < prevMenuList.length; i++) {
				var prevMenuItem = prevMenuList[i];
				prevMenuItem.style.display = "";
				prevMenuImg.src = imageDir + '/leftmenu_plus.gif';
			}
		}
	}
	for(j = 0; j < menu.length; j++) {
		var item = menu[j];
		activeMenu = menuGroupName;
		if(item.style.display == '') {
			item.style.display = "block";
			selectedMenuImg.src = imageDir + '/leftmenu_minus.gif';
		}
		else {
			item.style.display = "";
			selectedMenuImg.src = imageDir + '/leftmenu_plus.gif';
		}
	}
}

function changeToCompany() {
	showCompanyLinks();
	hideIndustryLinks();

	show(document.getElementById('quickViewLabel'));
	show(document.getElementById('quickFindLabel'));
	show(document.getElementById('leftcustom'));
	show(document.getElementById('requestMoreDataLink'));

	changeColor('999966');
	show(document.getElementById('companyTxt'));
	show(document.getElementById('currentCo'));

	show(document.getElementById('industryTxt'));
	show(document.getElementById('currentInd'));
	show(document.getElementById('lefmenutable'));
	show(document.getElementById('tr15'));
	hidePeopleLinks();
	hide(document.getElementById('toolsQV'));
	change_QVTab(1)
}

function changeToIndustry() {
	hideCompanyLinks();
	showIndustryLinks();
	show(document.getElementById('quickViewLabel'));
	show(document.getElementById('quickFindLabel'));
	hide(document.getElementById('leftcustom'));
	show(document.getElementById('requestMoreDataLink'));

	changeColor('A5AFBD')

	show(document.getElementById('companyTxt'));
	show(document.getElementById('currentCo'));

	show(document.getElementById('industryTxt'));
	show(document.getElementById('currentInd'));
	show(document.getElementById('lefmenutable'));
	show(document.getElementById('tr15'));
	hidePeopleLinks();
	hide(document.getElementById('toolsQV'));
	change_QVTab(2)
}

function changeToPeople() {
	hideCompanyLinks();
	hideIndustryLinks();
	hide(document.getElementById('quickFindLabel'));
	hide(document.getElementById('leftcustom'));
	hide(document.getElementById('requestMoreDataLink'));

	changeColor('CE8F56');

	hide(document.getElementById('companyTxt'));
	hide(document.getElementById('currentCo'));

	hide(document.getElementById('industryTxt'));
	hide(document.getElementById('currentInd'));
	hide(document.getElementById('lefmenutable'));
	show(document.getElementById('tr15'));

	showPeopleLinks();
	hide(document.getElementById('toolsQV'));
	change_QVTab(4)
}

function changeToTools() {
	hideCompanyLinks();
	hideIndustryLinks();
	hide(document.getElementById('quickFindLabel'));
	hide(document.getElementById('quickViewLabel'));
	hide(document.getElementById('leftcustom'));
	hide(document.getElementById('requestMoreDataLink'));

	changeColor('D8C280');

	hide(document.getElementById('companyTxt'));
	hide(document.getElementById('currentCo'));

	hide(document.getElementById('industryTxt'));
	hide(document.getElementById('currentInd'));
	hide(document.getElementById('lefmenutable'));
	hide(document.getElementById('tr15'));
	hidePeopleLinks();
	show(document.getElementById('toolsQV'));
	change_QVTab(3)
}

function hideCompanyLinks() {
	hide(document.getElementById('advancedsearch'));
	hide(document.getElementById('coQV1'));
	hide(document.getElementById('coQV2'));
	hide(document.getElementById('coQV3'));
	hide(document.getElementById('coQV4'));
	hide(document.getElementById('coQV5'));
	hide(document.getElementById('coQV6'));
	hide(document.getElementById('coQV7'));
	hide(document.getElementById('coQV8'));
	hide(document.getElementById('coQV9'));
	hide(document.getElementById('coQV10'));
	hide(document.getElementById('coQV11'));
	hide(document.getElementById('coQV12'));
	hide(document.getElementById('coQV13'));
}

function showCompanyLinks() {
	show(document.getElementById('advancedsearch'));
	show(document.getElementById('coQV1'));
	show(document.getElementById('coQV2'));
	show(document.getElementById('coQV3'));
	show(document.getElementById('coQV4'));
	show(document.getElementById('coQV5'));
	show(document.getElementById('coQV6'));
	show(document.getElementById('coQV7'));
	show(document.getElementById('coQV8'));
	show(document.getElementById('coQV9'));
	show(document.getElementById('coQV10'));
	show(document.getElementById('coQV11'));
	show(document.getElementById('coQV12'));
	show(document.getElementById('coQV13'));
}

function hideIndustryLinks() {
	hide(document.getElementById('indQV1'));
	hide(document.getElementById('indQV2'));
	hide(document.getElementById('indQV3'));
	hide(document.getElementById('indQV4'));
	hide(document.getElementById('indQV5'));
	hide(document.getElementById('indQV6'));
	hide(document.getElementById('indQV7'));
	hide(document.getElementById('indQV8'));
	hide(document.getElementById('indQV9'));
}

function showIndustryLinks() {
	show(document.getElementById('indQV1'));
	show(document.getElementById('indQV2'));
	show(document.getElementById('indQV3'));
	show(document.getElementById('indQV4'));
	show(document.getElementById('indQV5'));
	show(document.getElementById('indQV6'));
	show(document.getElementById('indQV7'));
	show(document.getElementById('indQV8'));
	show(document.getElementById('indQV9'));
}

function hidePeopleLinks() {
	hide(document.getElementById('peopleSearch'));
	hide(document.getElementById('peopleMenu'));
	hide(document.getElementById('personTxt'));
	hide(document.getElementById('personCompanyTxt'));
	hide(document.getElementById('currentPerson'));
	hide(document.getElementById('currentPersonCompany'));
	hide(document.getElementById('peopleButtons'));
	hide(document.getElementById('addContact'));
}

function showPeopleLinks() {
	show(document.getElementById('peopleSearch'));
	show(document.getElementById('peopleMenu'));
	show(document.getElementById('personTxt'));
	show(document.getElementById('personCompanyTxt'));
	show(document.getElementById('currentPerson'));
	show(document.getElementById('currentPersonCompany'));
	show(document.getElementById('peopleButtons'));
	show(document.getElementById('addContact'));
}

//changing/switchings of qv tab by wpidor
function change_QVTab(swvar){
	var qvtb1 = document.getElementById("qvtab1")
	var qvtb2 = document.getElementById("qvtab2")
	var qvtb3 = document.getElementById("qvtab3")
	var qvtb4 = document.getElementById("qvtab4")

	qvtb1.className = qvtb1.className.replace("qvcompon text10BoldVerdana","qvcompoff qvoff")
	qvtb2.className = qvtb2.className.replace("qvtoolson text10BoldVerdana","qvtoolsoff qvoff")
	qvtb2.className = qvtb2.className.replace("qvindustryon text10BoldVerdana","qvindustryoff qvoff")
	qvtb1.className = qvtb1.className.replace("qvpeopleon text10BoldVerdana","qvpeopleoff qvoff")

	var onclickhandler = {
			blank:function(){},
			company:function(){changeToCompany();},
			industry:function(){changeToIndustry();},
			tool:function(){changeToTools();},
			people:function(){changeToPeople();}
		}


	var classhandler = {
			companyon:"qv qvcompon text10BoldVerdana",
			companyoff:"qv qvtab3 qvcompoff qvtop",
			industryon:"qv qvtab4 qvindustryon text10BoldVerdana",
			industryoff:"qv qvtab4 qvindustryoff qvtop",
			toolon:"qv qvtab3 qvtoolson text10BoldVerdana",
			tooloff:"qv qvtab3 qvtoolsoff qvtop",
			peopleon:"qv qvtab4 qvpeopleon text10BoldVerdana",
			peopleoff:"qv qvtab4 qvpeopleoff qvtop"
		}
	if ((screen.width < 900)){
		classhandler = {
				companyon:"qv qv_small qvcompon text10BoldVerdana",
				companyoff:"qv qv_small qvtab3 qvcompoff qvtop",
				industryon:"qv qv_small qvtab4 qvindustryon text10BoldVerdana",
				industryoff:"qv qv_small qvtab4 qvindustryoff qvtop",
				toolon:"qv qv_small qvtab3 qvtoolson text10BoldVerdana",
				tooloff:"qv qv_small qvtab3 qvtoolsoff qvtop",
				peopleon:"qv qv_small qvtab4 qvpeopleon text10BoldVerdana",
				peopleoff:"qv qv_small qvtab4 qvpeopleoff qvtop"
			}
	}

	switch(swvar){
		case 1:
			qvtb1.innerHTML = "Company"
			qvtb1.className = classhandler.companyon
			qvtb1.onclick = onclickhandler.company

			qvtb4.innerHTML = "People(beta)"
			qvtb4.onclick = onclickhandler.people
			qvtb4.className = classhandler.peopleoff
			break;
		case 2:
			qvtb2.innerHTML = "Industry"
			qvtb2.className = classhandler.industryon
			qvtb2.onclick = onclickhandler.industry

			qvtb3.innerHTML = "Tools"
			qvtb3.className = classhandler.tooloff
			qvtb3.onclick = onclickhandler.tool
			break;
		case 3:
			qvtb2.innerHTML = "Tools"
			qvtb2.className = classhandler.toolon
			qvtb2.onclick = onclickhandler.tool

			qvtb3.innerHTML = "Industry"
			qvtb3.onclick = onclickhandler.industry
			qvtb3.className = classhandler.industryoff
			break;
		case 4:
			qvtb1.innerHTML = "People(beta)"
			qvtb1.className = classhandler.peopleon
			qvtb1.onclick = onclickhandler.people

			qvtb4.innerHTML = "Company"
			qvtb4.onclick = onclickhandler.company
			qvtb4.className = classhandler.companyoff
			break;
	}
}

function changeColor(thecolor) {
	document.getElementById('leftmenutable').style.backgroundColor = "#" + thecolor;
}
