
function processNavigationRequest(link){			
	if(link.length == 0){return;}
	navigatingTo = link;
	
	rootWindow = findRootWindow(window);
	
	//Check if this is the root window
	if(rootWindow != window){
		//Call processNavigationRequest in the rootWindow
		rootWindow.processNavigationRequest(link);	
	}else{	
		var otherPagesWindowMapping;
		var otherPagesWindowMappingIndex = 5;
		
		if(topNavigationSection.setting == 'single'){			
			//If single window, redirect the content frame of the parentWindow
			if(link.indexOf('interactiveMap.aspx') > -1 && parentWindow.content.location.href.indexOf('interactiveMap.aspx') > -1){				
				var srch = parentWindow.content.location.search;
				var linkDR = (link.lastIndexOf('&') < link.indexOf('dr=')) ? parseInt(link.substring(link.indexOf('dr=') + 3, link.length)) : parseInt(link.substring(link.indexOf('dr=') + 3, link.indexOf('&', link.indexOf('dr='))));
				var currentDR = (srch.lastIndexOf('&') < srch.indexOf('dr=')) ? parseInt(srch.substring(srch.indexOf('dr=') + 3, srch.length)) : parseInt(srch.substring(srch.indexOf('dr=') + 3, srch.indexOf('&', srch.indexOf('dr='))));
	
				if(linkDR == currentDR && link.indexOf('&businessLocationID=') > -1){
					//Get all the offsets for different parameters
					var businessLocationID = parseInt(link.substr(link.indexOf('&businessLocationID=') + 20));
					var mapPage = parentWindow.content;	
					mapPage.top.focus();
					
					if(!isNaN(businessLocationID)){
						var location = mapPage.nemo.mapLocationSets.currentMapLocationSet.locations.getLocationByID(businessLocationID);
						mapPage.nemo.selectLocationFromMapIndex(location);
						mapPage.nemo.selectLocationFromMapDisplay(location);}
				}else{
					parentWindow.top.focus();
					parentWindow.content.location.href = (link.indexOf('http://') > -1) ? link : 'http://' + parentWindow.content.location.hostname + link;	
				}
			}else if(link.indexOf('looperTrolley.aspx') > -1 || link.indexOf('moreInfo.aspx') > -1 || link.toLowerCase().indexOf('intowntrolleychart.aspx') > -1 || 
					link.toLowerCase().indexOf('tecolinestreetcarchart.aspx') > -1 || link.toLowerCase().indexOf('parkingdowntownchart.aspx') > -1 || 
					link.toLowerCase().indexOf('parkingyborchart.aspx') > -1 || link.toLowerCase().indexOf('parkinghydeparkchart.aspx') > -1){
				var height=600;
				var width=800;				
				if(window.screen.availWidth <= width || window.screen.availHeight <= height){
					width = window.screen.availWidth;
					height = window.screen.availHeight;
				}
				
				var windowPrefix = getSecondWindowPrefix();
				windowPrefix += 'mipWindow';

				try{
					var tempWindow = window.open(link, windowPrefix, 'top=0,left=0,height='+height+',width='+width+',scrollbars=1,resizable=1');
					tempWindow.focus();
				}catch(e){
					alert(e.message + ' :: ' + e.number);
				}
			}else{
				parentWindow.top.focus();
				parentWindow.content.location = (link.indexOf('http://') > -1) ? link : 'http://' + parentWindow.location.hostname + link;				
			}
			return;
		}else if(topNavigationSection.setting == 'multiple'){
			var otherPagesWindow;
				
			//Check the existing window references to see if the window page is already loaded
			for(var i = 0; i < windowPageMappings.length; i++)
			{				
				if(link.indexOf(windowPageMappings[i].link) > -1 && link.length > 0 && windowPageMappings[i].link.length > 0)
				{
					if(windowPageMappings[i].windowRef != undefined && windowPageMappings[i].windowRef.closed != true)
					{				
						//Check if we are at home and we are going home, if so, exit
						if(windowPageMappings[i].windowRef.content.location.pathname.indexOf('home.aspx') > -1 && link.indexOf('home.aspx') > -1)
						{
							windowPageMappings[i].windowRef.focus();
							return;						
						}else if(link.indexOf('interactiveMap.aspx') > -1 && windowPageMappings[i].windowRef.content.location.href.indexOf('interactiveMap.aspx') > -1)
						{				
							var srch = windowPageMappings[i].windowRef.content.location.search;
							var linkDR = (link.lastIndexOf('&') < link.indexOf('dr=')) ? parseInt(link.substring(link.indexOf('dr=') + 3, link.length)) : parseInt(link.substring(link.indexOf('dr=') + 3, link.indexOf('&', 'dr=')));
							var currentDR = (srch.lastIndexOf('&') < srch.indexOf('dr=')) ? parseInt(srch.substring(srch.indexOf('dr=') + 3, srch.length)) : parseInt(srch.substring(srch.indexOf('dr=') + 3, srch.indexOf('&', 'dr=')));
				
							if(linkDR == currentDR){
								//Get all the offsets for different parameters
								var businessLocationID = parseInt(link.substr(link.indexOf('&businessLocationID=') + 20));
								
								if(!isNaN(businessLocationID)){
									var mapPage = windowPageMappings[i].windowRef.content;
									
									var location = mapPage.nemo.mapLocationSets.currentMapLocationSet.locations.getLocationByID(businessLocationID);
									mapPage.nemo.selectLocationFromMapIndex(location);
									mapPage.nemo.selectLocationFromMapDisplay(location);
									
									//windowPageMappings[i].windowRef.content.mapDetail.showIndexSelectedBusiness(businessID, categoryID, xCoordinate, yCoordinate);
									//windowPageMappings[i].windowRef.content.mapIndex.showSelectedBusiness(businessID, categoryID, xCoordinate, yCoordinate);
								}
								
								windowPageMappings[i].windowRef.focus();
								return;
							}else{
								windowPageMappings[i].windowRef.content.location.href = (link.indexOf('http://') > -1) ? link : 'http://' + parentWindow.content.location.hostname + link;	
								windowPageMappings[i].windowRef.focus();
								return;
							}
							
						}else if(link.indexOf('specialOffers.aspx') > -1 && windowPageMappings[i].windowRef.content.location.href.indexOf('specialOffers.aspx') > -1)
						{
							windowPageMappings[i].windowRef.focus();
							return;
						}else if(link.indexOf('businessDirectory.aspx') > -1 && windowPageMappings[i].windowRef.content.location.href.indexOf('businessDirectory.aspx') > -1 && link.indexOf('categoryID') == -1)
						{
							windowPageMappings[i].windowRef.focus();
							return;
						}else if(windowPageMappings[i].windowRef.content.location.pathname != link)
						{
							//If it exists, redirect its content frame
							windowPageMappings[i].windowRef.content.location.href = (link.indexOf('http://') > -1) ? link : 'http://' + parentWindow.content.location.hostname + link;
							windowPageMappings[i].windowRef.focus();
							return;
						}
										
					}else{
						//Otherwise, create the window and load the link by default
						if(link.indexOf('http://') > -1)
						{
							windowPageMappings[i].windowRef = window.open(link, '_blank', 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,width=' + windowPageMappings[i].width);
							windowPageMappings[i].windowRef.focus();
							
							syncRootWindow(i);	
							return;					
						}else{
							windowPageMappings[i].windowRef = window.open('http://' + parentWindow.content.location.hostname + '/default.aspx?redirect=' + escape(link), '_blank', 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,width=' + windowPageMappings[i].width);						
							windowPageMappings[i].windowRef.focus();
							
							syncRootWindow(i);
							return;
						} 
					}			
					
				}else if(windowPageMappings[i].link.length == 0){
					otherPagesWindowMapping = windowPageMappings[i]; 
					otherPagesWindowMappingIndex = i;
				}
			}						
			
		}else{
			parentWindow.content.location = (link.indexOf('http://') > -1) ? link : 'http://' + parentWindow.location.hostname + link;
			return;
		} 
			
					
		//Send the page to the "other" window if we got this far
		if(otherPagesWindowMapping.windowRef != undefined && otherPagesWindowMapping.windowRef.closed != true)
		{			
			if(otherPagesWindowMapping.windowRef.content.location.href != link)
			{		
				//If it exists, redirect its content frame
				otherPagesWindowMapping.windowRef.content.location.href = (link.indexOf('http://') > -1) ? link : 'http://' + parentWindow.content.location.hostname + link;
			}
				
			otherPagesWindowMapping.windowRef.focus();		
		}else{
			//Otherwise, create the window and load the link by default
			if(link.indexOf('http://') > -1)
			{
				otherPagesWindowMapping.windowRef = window.open(link, '_blank', 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,width=' + otherPagesWindowMapping.width);
			}else{
				otherPagesWindowMapping.windowRef = window.open('http://' + parentWindow.content.location.hostname + '/default.aspx?redirect=' + escape(link), '_blank', 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,width=' + otherPagesWindowMapping.width);
			}				
				
			otherPagesWindowMapping.windowRef.focus();	
							
			syncRootWindow(otherPagesWindowMappingIndex);
		}						
		
		
	}	
}




function getSecondWindowPrefix(){
	var host = document.location.hostname;

	switch(host){
		case 'cfl-inhouse.welcomeguide-map.com':
		case 'cfl-freelance.welcomeguide-map.com':
		case 'cfl-dev.welcomeguide-map.com':
		case 'cfl-stage1.welcomeguide-map.com':
		case 'cfl-stage2.welcomeguide-map.com':
		case 'centralflorida.welcomeguidemap.com':
			return 'cfl_';
		case 'tbb-inhouse.welcomeguide-map.com':
		case 'tbb-freelance.welcomeguide-map.com':
		case 'tbb-dev.welcomeguide-map.com':
		case 'tbb-stage1.welcomeguide-map.com':
		case 'tbb-stage2.welcomeguide-map.com':
		case 'tampabaybeaches.welcomeguidemap.com':
			return 'tbb_';
		case 'sar-inhouse.welcomeguide-map.com':
		case 'sar-freelance.welcomeguide-map.com':
		case 'sar-dev.welcomeguide-map.com':
		case 'sar-stage1.welcomeguide-map.com':
		case 'sar-stage2.welcomeguide-map.com':
		case 'sarasota.welcomeguidemap.com':
			return 'sar_';
		case 'swf-inhouse.welcomeguide-map.com':
		case 'swf-freelance.welcomeguide-map.com':
		case 'swf-dev.welcomeguide-map.com':
		case 'swf-stage1.welcomeguide-map.com':
		case 'swf-stage2.welcomeguide-map.com':
		case 'southwestflorida.welcomeguidemap.com':
			return 'swf_';
		case 'dsp-inhouse.discoverguidemap.com':
		case 'dsp-freelance.discoverguidemap.com':
		case 'dsp-dev.discoverguidemap.com':
		case 'dsp-stage1.discoverguidemap.com':
		case 'dsp-stage2.discoverguidemap.com':
		case 'www.discoverdowntown.com':
			return 'dsp_';
		case 'dit-inhouse.discoverguidemap.com':
		case 'dit-freelance.discoverguidemap.com':
		case 'dit-dev.discoverguidemap.com':
		case 'dit-stage1.discoverguidemap.com':
		case 'dit-stage2.discoverguidemap.com':
		case 'www.discoverintown.com':
			return 'dit_';
	}
}

