// This file sets the rollovers for the navigation

var navImages = new Array();
var navSeps = new Array();
var buttonImages = new Array();
var selectedNavImage = false;

function doRollover(i, s) {
	//s can be over, out, on, off
	switch (s) {
		case 'on': i.src = i.on; break;
		case 'off': i.src = i.off; break;
		case 'over': i.src = i.over; break;
		case 'out': i.src = i.out; break;
	}
}

function setPosition(){
		divSearch.style.left = 700;
		divSearch.style.top = 55;
}

	
function getRollover(state, origSrc) {

    path = window.location.href;
    customerPath = "/customer/";
	customerCorpPath = "ct_in_corp";
	customerLawPath = "ct_in_law";
	customerGovPath = "ct_in_gov";
	compliancePath = "/compliance/";
	complianceAgentPath = "agent_services";
	complianceProcPath = "process_mgmt";
	complianceCompPath = "compliance_mgmt";
	complianceStaffPath = "compliance_staffing";
	complianceInternPath = "compliance_international";
	complianceCorpRecPath = "corporate_records";
	complianceEdgarPath = "edgar_solutions";
	complianceConversionPath = "edgar_conversion";
	complianceBureauPath = "edgar_bureau";
	compliancehCuePath = "hcue";
	transactPath = "/transactions/";
	transactAdvPath = "advantage";
	transactCorp = "corporate_formation";
	transactDue = "due_diligence";
	transactMerger = "mergers";
	transactBankrupt = "bankrupt";
	transactReal = "real_estate";
	transactSecured = "secured_lending";
	transactSpecial = "special_transaction";
	transactRA = "golden_window";
	litigationPath = "/litigation/";
	litEbillPath = "ebill_matter";
	litTymetrix = "tymetrix";
	litCase = "case_file";
	litElectronic = "electronic_discovery";
	litSummation = "ct_summation";
	litCasevault = "casevault_hosting";
	litSupport = "litigation_support";
	edPath = "/events/";
	edSeminar = "ct_seminars";
	edSeminarList = "seminarsList";
	edProduct = "product_training";
	edTradeshows = "tradeshows";
	aboutPath = "/about/";
	aboutContact = "contact_us";
	aboutEmployment = "employment";
	aboutPressroom = "press_room";
	aboutCtnews = "ct_news";
	aboutReleases = "press_releases";
	aboutBios = "executive_bios";
	aboutHistory = "history";
	aboutImage = "image_bank";
	trademarkPath = "/trademark/";
	
	resultTrademark = path.match(trademarkPath);
	resultAbout = path.match(aboutPath);
	resultAbContact = path.match(aboutContact);
	resultEmployment = path.match(aboutEmployment);
	resultPressroom = path.match(aboutPressroom);
	resultCtnews = path.match(aboutCtnews);
	resultReleases = path.match(aboutReleases);
	resultBios = path.match(aboutBios);
	resultHistory = path.match(aboutHistory);
	resultImage = path.match(aboutImage);
	
	resultEd = path.match(edPath);
	resultSeminars = path.match(edSeminar);
	resultEdProduct = path.match(edProduct);
	resultTradeshows = path.match(edTradeshows);
	resultSeminarsList = path.match(edSeminarList);
	
	resultLit = path.match(litigationPath);
	resultLitEbill = path.match(litEbillPath);
	resultLitTymetrix = path.match(litTymetrix);
	resultLitCase = path.match(litCase);
	resultLitElectronic = path.match(litElectronic);
	resultLitSummation = path.match(litSummation);
	resultLitCasevault = path.match(litCasevault);
	resultLitSupport = path.match(litSupport);
	
	resultTransact = path.match(transactPath);
	resultTransactAdv = path.match(transactAdvPath);
	resultTransactCorp = path.match(transactCorp);
	resultTransactDue = path.match(transactDue);
	resultTransactMerger = path.match(transactMerger);
	resultTransactBankrupt = path.match(transactBankrupt);
	resultTransactReal = path.match(transactReal);
	resultTransactSecured = path.match(transactSecured);
	resultTransactSpecial = path.match(transactSpecial);
	resultTransactRA = path.match(transactRA);
	
    resultCustomer = path.match(customerPath);
	resultCustomerCorp = path.match(customerCorpPath);
	resultCustomerLaw = path.match(customerLawPath);
	resultCustomerGov = path.match(customerGovPath);
	
	resultCompliance = path.match(compliancePath);
	resultComplianceAgent = path.match(complianceAgentPath);
    resultCompProcPath = path.match(complianceProcPath);
	resultCompMgt = path.match(complianceCompPath);
	resultCompStaff = path.match(complianceStaffPath);
	resultCompIntern = path.match(complianceInternPath);
	resultCorpRec = path.match(complianceCorpRecPath);
	resultCompEdgar = path.match(complianceEdgarPath);
	resultCompConv = path.match(complianceConversionPath);
	resultCompBureau = path.match(complianceBureauPath);
	resultComphCue = path.match(compliancehCuePath);
	
	if (resultTrademark == "/trademark/"){
	document.navImg_trademark.src = "http://www.ctlegalsolutions.com/images/shared/navImg_trademark-on.gif";
	document.navImg_sep_3.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	document.navImg_sep_4.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	}else{
	}
	
    if (resultCustomer == "/customer/"){
    document.navImg_solutions.src = "http://www.ctlegalsolutions.com/images/shared/navImg_solutions-on.gif";
	document.navImg_sep_0.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
    }else{		
    }
	
	if (resultCustomerCorp == "ct_in_corp"){
	spanCorp.className = "selected"; 
	}else{
	}
	
	if (resultCustomerLaw == "ct_in_law"){
	spanLaw.className = "selected"; 
	}else{
	}
	
	if (resultCustomerGov == "ct_in_gov"){
	spanGov.className = "selected"; 
	}else{
	}
	
	 if (resultCompliance == "/compliance/"){
    document.navImg_compliance.src = "http://www.ctlegalsolutions.com/images/shared/navImg_compliance-on.gif";
	document.navImg_sep_1.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	document.navImg_sep_0.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
    }else{		
    }
	
	 if (resultComplianceAgent == "agent_services"){
    spanCompReg.className = "selected";
    }else{		
    }
	
	 if (resultCompProcPath == "process_mgmt"){
    spanCompProcess.className = "selected";
    }else{		
    }
	
	if (resultCompMgt == "compliance_mgmt"){
    spanCompMgmt.className = "selected";
    }else{		
    }
	
	if (resultComphCue == "hcue"){
    spanComphCue.className = "selected";
    }else{		
    }
	
	if (resultCompStaff == "compliance_staffing"){
    spanCompInd.className = "selected";
    }else{		
    }
	
	if (resultCompIntern == "compliance_international"){
    spanIntServ.className = "selected";
    }else{		
    }
	
	if (resultCorpRec == "corporate_records"){
    spanCompCorp.className = "selected";
    }else{		
    }
	
	if (resultCompEdgar == "edgar_solutions"){
    spanCompEDGAR.className = "selected";
    }else{		
    }
	
	if (resultCompConv == "edgar_conversion"){
    spanCompConversion.className = "selected";
    }else{		
    }
	
	if (resultCompBureau == "edgar_bureau"){
    spanCompBureau.className = "selected";
    }else{		
    }
	
	 if (resultTransact == "/transactions/"){
    document.navImg_transaction.src = "http://www.ctlegalsolutions.com/images/shared/navImg_transactions-on.gif";
	document.navImg_sep_1.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	document.navImg_sep_2.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
    }else{		
    }
	
	if (resultTransactAdv == "advantage"){
    spanTranAd.className = "selected";
    }else{		
    }
	
	if (resultTransactCorp == "corporate_formation"){
    spanTranCorp.className = "selected";
    }else{		
    }
	
	if (resultTransactDue == "due_diligence"){
    spanTranDue.className = "selected";
    }else{		
    }
	
	if (resultTransactMerger == "mergers"){
    spanTranMergers.className = "selected";
    }else{		
    }
	
	if (resultTransactBankrupt == "bankrupt"){
    spanTranBank.className = "selected";
    }else{		
    }
	
	if (resultTransactReal == "real_estate"){
    spanTranReal.className = "selected";
    }else{		
    }
	
	if (resultTransactSecured == "secured_lending"){
    spanTranSecured.className = "selected";
    }else{		
    }
	
	if (resultTransactSpecial == "special_transaction"){
    spanTranSpecial.className = "selected";
    }else{		
    }
	
	if (resultTransactRA == "golden_window"){
    spanTranRA.className = "selected";
    }else{		
    }
	
	if (resultLit == "/litigation/"){
    document.navImg_litigation.src = "http://www.ctlegalsolutions.com/images/shared/navImg_litigation-on.gif";
	document.navImg_sep_2.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	document.navImg_sep_3.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
    }else{		
    }
	
	if (resultLitEbill == "ebill_matter"){
    spanEbill.className = "selected";
    }else{		
    }
	
	if (resultLitTymetrix == "tymetrix"){
    spanTymetrix.className = "selected";
    }else{		
    }
	
	if (resultLitCase == "case_file"){
    spanCtCase.className = "selected";
    }else{		
    }
	
	if (resultLitElectronic == "electronic_discovery"){
    spanElectronic.className = "selected";
    }else{		
    }
	
	if (resultLitSummation == "ct_summation"){
    spanSummation.className = "selected";
    }else{		
    }
	
	if (resultLitCasevault == "casevault_hosting"){
    spanCasevault.className = "selected";
    }else{		
    }
	
    if (resultLitSupport == "litigation_support"){
    spanLitSupport.className = "selected";
    }else{		
    }
	
	 if (resultEd == "/events/"){
    document.navImg_educationAndEvents.src = "http://www.ctlegalsolutions.com/images/shared/navImg_education-on.gif";
	document.navImg_sep_3.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	document.navImg_sep_4.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
    }else{		
    }
	
	if (resultSeminars == "ct_seminars"){
    spanSeminars.className = "selected";
    }else{		
    }
	
	if (resultSeminarsList == "seminarsList"){
    spanSchedule.className = "selected";
    }else{		
    }
	
	
	if (resultEdProduct == "product_training"){
    spanProduct.className = "selected";
    }else{		
    }
	
	if (resultTradeshows == "tradeshows"){
    spanTradeshows.className = "selected";
    }else{		
    }
	
	if (resultAbout == "/about/"){
    document.navImg_aboutUs.src = "http://www.ctlegalsolutions.com/images/shared/navImg_aboutUs-on.gif";
	document.navImg_sep_4.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
	document.navImg_sep_5.src = "http://www.ctlegalsolutions.com/images/shared/navImg_sep-on.gif";
    }else{		
    }
	
	if (resultAbContact == "contact_us"){
    spanContact.className = "selected";
    }else{		
    }
	
	if (resultEmployment == "employment"){
    spanEmployment.className = "selected";
    }else{		
    }
	
	
	if (resultPressroom == "press_room"){
    spanPressroom.className = "selected";
    }else{		
    }
	
	if (resultCtnews == "ct_news"){
    spanNews.className = "selected";
    }else{		
    }
	
	if (resultReleases == "press_releases"){
    spanPressreleases.className = "selected";
    }else{		
    }
	
	if (resultBios == "executive_bios"){
    spanExecutive.className = "selected";
    }else{		
    }
	
	if (resultHistory == "history"){
    spanHistory.className = "selected";
    }else{		
    }
	
	if (resultImage == "image_bank"){
    spanImagebank.className = "selected";
    }else{		
    }
	
	//var lastSlashIndex = origSrc.lastIndexOf('/') + 1;
	var lastPeriodIndex = origSrc.lastIndexOf('.');
	
	var srcSubString = origSrc.substr(0, lastPeriodIndex);
	var ext = origSrc.substr(lastPeriodIndex, origSrc.length);
	
	var returnString = new String();
	if (srcSubString.indexOf('-on') < 0) {
		// Current State is off
		if (state == 'over' || state == 'on') {
			returnString = srcSubString + '-on' + ext;
		}
		else if (state == 'out' || state == 'off') {
			returnString = srcSubString + ext;
		}		
	}
	else {
		// Current state is on 
		returnString = srcSubString + ext;
		if (state == 'out' || state == 'on'|| state == 'over') {
			returnString = srcSubString + ext;
		}
		else if (state == 'off') {
			var offIndex = srcSubString.lastIndexOf('-on');
			returnString = srcSubString.substr(0, offIndex) + ext;
		}
	}
	
	return returnString;
}

function initRollovers() {
	navImages[0] = document.getElementById('navImg_solutions');
	navImages[1] = document.getElementById('navImg_compliance');
	navImages[2] = document.getElementById('navImg_transaction');
	navImages[3] = document.getElementById('navImg_litigation');
	navImages[4] = document.getElementById('navImg_trademark');
	navImages[5] = document.getElementById('navImg_educationAndEvents');
	navImages[6] = document.getElementById('navImg_aboutUs');
	
	navSeps[0] = document.getElementById('navImg_sep_0');
	navSeps[1] = document.getElementById('navImg_sep_1');
	navSeps[2] = document.getElementById('navImg_sep_2');
	navSeps[3] = document.getElementById('navImg_sep_3');
	navSeps[4] = document.getElementById('navImg_sep_4');
	navSeps[5] = document.getElementById('navImg_sep_5');
	navSeps[6] = document.getElementById('navImg_sep_6');
	
	allImages = document.getElementsByTagName('IMG');
	for (var h = 0; h< allImages.length; h++) {
		if (allImages[h].className == 'RolloverUI') {
			buttonImages.push(allImages[h]);		
		}
	}
	
	allInputs = document.getElementsByTagName('INPUT');
	for (var h = 0; h< allInputs.length; h++) {
		if (allInputs[h].className == 'RolloverUI') {
			buttonImages.push(allInputs[h]);		
		}
	}

	for (var i = 0; i<navImages.length ; i++) {
		
		if (navImages[i].src.lastIndexOf('-on') > 0) {
			selectedNavImage = navImages[i];
		}

		//set rollover attributes
		navImages[i].over = getRollover('over', navImages[i].src);
		navImages[i].out =  getRollover('out' ,navImages[i].src);
		navImages[i].on = getRollover('on', navImages[i].src);
		navImages[i].off = getRollover('off', navImages[i].src);
		
		//alert(navImages[i].over + ' | ' + navImages[i].out);
		
		navSeps[i].over = getRollover('over', navSeps[i].src);
		navSeps[i].out = getRollover('out', navSeps[i].src);
		navSeps[i].on = getRollover('on', navSeps[i].src);
		navSeps[i].off = getRollover('off', navSeps[i].src);
		
		//alert(navSeps[i].rollout + ' p '  + navSeps[i].rollover);
		
		navImages[i].rightSep = navSeps[i];
		if (i>0) {
			navImages[i].leftSep = navSeps[i-1];
		}
		
		navImages[i].onmouseover = function (){
			//this.doRollover();
			if (selectedNavImage != false) {
				doRollover(selectedNavImage, 'off' );
				doRollover(selectedNavImage.rightSep , 'off' );
				if (selectedNavImage.leftSep) {
					doRollover(selectedNavImage.leftSep, 'off');
				}
			}
			
			doRollover(this, 'over');
			doRollover(this.rightSep, 'over');
			if (this.leftSep) {
				doRollover(this.leftSep, 'over');
			}
		}
		
		navImages[i].onmouseout = function () {
			if (selectedNavImage != false) {
				doRollover(selectedNavImage, 'on' );
				doRollover(selectedNavImage.rightSep , 'on' );
				if (selectedNavImage.leftSep) {
					doRollover(selectedNavImage.leftSep, 'on');
				}
			}
			
			doRollover(this, 'out');
			doRollover(this.rightSep, 'out');
			if(this.leftSep) {
				doRollover(this.leftSep, 'out');
			}
		}
	}
	for (var j = 0; j<buttonImages.length; j++) {
		
		buttonImages[j].over = getRollover('over', buttonImages[j].src);
		buttonImages[j].out = getRollover('out', buttonImages[j].src);
		
		buttonImages[j].onmouseover = function () {
			doRollover(this, 'over');
		}
		buttonImages[j].onmouseout = function () {
			doRollover(this, 'out');	
		}
	}
}