function log(msg) {
	if(window.console && console.log) {
		console.log(msg);
	}
}

jQuery.noConflict(); //prototype is loaded after main

jQuery(function() {
	if (jQuery(".partner_box").length ) {
		jQuery(".partner_box").partnerbox({
				'boxClass': 'partner_box',
				'titleTag':'h1',
				'holderClass':'holder',
				'elementClass':'partner',
				'datasource':'/includes/scripts/functions.php?partnerBoxJson=1',
				'prevClass' : 'prev',
				'nextClass' : 'next',
				'animSpeed' : 1000,
				'timerSpeed' : 5000,
				'itemSpacing' : 10,
				'itemHeight' : 100
		});
	}
})
		
		var root_link = "http://www.cars21.com";
		
		var tempContent = "";
		
		var loadedContent = 1;
		
		var initLoaded = 1;
		
		var openListing = 1;
		
		var rotateTimer = 7000;
		
		var loadingStart = 1;
		
		var currHomeFeature = 1;
		var featureOpen = 1;
		var featureTimer = 0;
		
		var communityUpdatesTop = 0;
		var communityUpdatesOffset = 70;
		var communityUpdatesLimit = 560;
		var communityUpdatesTimer = 0;
		var communityUpdatesTimerSec = 0;
		
		var opacityTimeoutVar = new Array();
		opacityTimeoutVar[0] = "";
		opacityTimeoutVar[1] = "";
		
		var directoryStartCompany = 0;
		var directoryStartCompanyAnchor = 1;
		
		var homeSubscribeOpen = 0;
		
		var rotateTimeout = "";
		var currTimeout = "";
		
		var tempFunction = "";
		
		var currLib	= "";
		
		var currRegion = "";
		
		var currCountry = "";
		var currCountryLeft = 0;
		var currCountryTop = 0;
		
		var setCurrVisible = 1;
		
		var currSelect = "";
		var currSelectTop = 0;
		var currSelectStart = 26;
		
		var companyBlurbTimeout = "";
		var currCompanyBlurb = 0;
		var currCompanyMove = 0;
		var currCompanyMoveLeft = 0;
		var currCompanyMoveTop = 0;
		
		var currMapResults = "";
		var currMapResultsLeft = 0;
		var currMapResultsStart = 0;
		
		var currMapped = 0;
		
		//var directoryTopOffset = 346;
		var directoryTopOffset = 258;
		
		var cursorTimer = "";
		
		var resetResults = 0;
		
		var currScrollMouse = -1;
		var currScrollOffset = 0;
		
		var currMoveMapLeft = -1;
		var currMoveMapTop = -1;
		
		var currListing = 1;
		var currListingTop = 0;
		
		var moveMapResults = 0;
		
		var moveMapTimer = "";
		
		var safariLoader = 1;
		
		var loaded	= 0;
		
		var waitFunction = "";
		
		var noLoading = 0;
		
		var playerHeight = 0;
		
		var commentsOn = 0;
		
		var currItem = 0;
		
		var ajaxFunction = new Array();
		
		var ajaxFunctionCounter = 0;
		
		var currDiv = "";
		var currFeat = 1;
		var currAnchor = "";
		var currFunction = "";
		var secondaryFunction = "";
		var ajaxTimeout = 0;
		
		var currSection = 0;
		var currSubSection = 0;
		
		var CurrNav = 0;
		var currNavTimeout = "";
		
		var currCircleLeft = 0;
		var currCircleTop = 0;
		var currCircleTimeout = "";
		
		var currPartner = 1;
		var currPartnerWide = 1;
		var partnerRotateTimeout = null;
		var partnerRotateTimeoutMain = null;
		
		var CurrInfoBox = -1;
		var LinkInfoBoxOpen = 0;
		var LinkInfoBoxTimer = 0;
		var AbortCloseBox = 0;
		
		var divCount = 2;
		var currDiv = 0;
		var openDiv = 0;
		
		var clearForumPost = 0;
		
		var galleryPos = 1;
		
		var timeoutVar = 0;
		
		var currMapZoom = 0;
		var prevMapZoom = 0;
		
		var startLoad = 1;
		
		var optionCounter = 0;
		
		var mapFields = new Array();		
		var fieldsCounter = 0;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'Categories';
		mapFields[fieldsCounter][1] = '';
		fieldsCounter++;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'Types';
		mapFields[fieldsCounter][1] = '';
		fieldsCounter++;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'Regions';
		mapFields[fieldsCounter][1] = '';
		fieldsCounter++;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'Countries';
		mapFields[fieldsCounter][1] = '';
		fieldsCounter++;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'Keyword';
		mapFields[fieldsCounter][1] = '';
		fieldsCounter++;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'PositionLeft';
		mapFields[fieldsCounter][1] = 0;
		fieldsCounter++;
		
		mapFields[fieldsCounter] = new Array();
		mapFields[fieldsCounter][0] = 'PositionTop';
		mapFields[fieldsCounter][1] = 0;
		fieldsCounter++;
		
		image1 = new Image();
		image1.src = root_link+"/images/main/directory-city.png";
		
		image2 = new Image();
		image2.src = root_link+"/images/main/directory-pin.png";
		
		var mapImages = new Array();
		var mapImagesBg = new Array();
		var mapImagesBgName = new Array();
		
		var mapImagesCount = 0;
		
		mapImages[mapImagesCount] = new Array();
		mapImages[mapImagesCount][0]		= 'world-map';
		mapImages[mapImagesCount][1]		= 940;
		mapImages[mapImagesCount][2]		= 540;
		mapImages[mapImagesCount][3]		= '';
		mapImages[mapImagesCount][4]		= 1;
		mapImages[mapImagesCount][5]		= 4230;
		mapImages[mapImagesCount][6]		= 2430;
		mapImages[mapImagesCount][7]		= 10;
		
		mapImagesBg[mapImagesCount] = new Array();
		mapImagesBgName[mapImagesCount] = new Array();
		for (i = 0; i < 1; i++) {
			mapImagesBg[mapImagesCount][i] = 0;
		}
		
		mapImagesCount++;
		
		mapImages[mapImagesCount] = new Array();
		mapImages[mapImagesCount][0]		= 'world-map';
		mapImages[mapImagesCount][1]		= 1880;
		mapImages[mapImagesCount][2]		= 1080;
		mapImages[mapImagesCount][3]		= '1';
		mapImages[mapImagesCount][4]		= 15;
		mapImages[mapImagesCount][5]		= 3760;
		mapImages[mapImagesCount][6]		= 2160;
		mapImages[mapImagesCount][7]		= 5;
		
		mapImagesBg[mapImagesCount] = new Array();
		mapImagesBgName[mapImagesCount] = new Array();
		for (i = 0; i < 15; i++) {
			if (i < 10) {
				locationPoint = '0'+i.toString();	
			} else {
				locationPoint = i.toString();
			}
			//mapImagesBgName[mapImagesCount][i] = new Image();
			//mapImagesBgName[mapImagesCount][i].src = root_link+'/images/directory/'+mapImages[mapImagesCount][3]+'/'+mapImages[mapImagesCount][0]+'_'+locationPoint+'.png';
			mapImagesBg[mapImagesCount][i] = 0;
		}
		
		mapImagesCount++;
		
		mapImages[mapImagesCount] = new Array();
		mapImages[mapImagesCount][0]		= 'world-image';
		mapImages[mapImagesCount][1]		= 4700;
		mapImages[mapImagesCount][2]		= 2700;
		mapImages[mapImagesCount][3]		= '2';
		mapImages[mapImagesCount][4]		= 84;
		mapImages[mapImagesCount][5]		= 2350;
		mapImages[mapImagesCount][6]		= 1350;
		mapImages[mapImagesCount][7]		= 2;
		
		mapImagesBg[mapImagesCount] = new Array();
		mapImagesBgName[mapImagesCount] = new Array();
		for (i = 0; i < 84; i++) {
			if (i < 10) {
				locationPoint = '0'+i.toString();	
			} else {
				locationPoint = i.toString();
			}
			//mapImagesBgName[mapImagesCount][i] = new Image();
			//mapImagesBgName[mapImagesCount][i].src = root_link+'/images/directory/'+mapImages[mapImagesCount][3]+'/'+mapImages[mapImagesCount][0]+'_'+locationPoint+'.png';
			mapImagesBg[mapImagesCount][i] = 0;
		}
		
		mapImagesCount++;
		
		mapImages[mapImagesCount] = new Array();
		mapImages[mapImagesCount][0]		= 'big-world';
		mapImages[mapImagesCount][1]		= 9400;
		mapImages[mapImagesCount][2]		= 5400;
		mapImages[mapImagesCount][3]		= '3';
		mapImages[mapImagesCount][4]		= 336;
		mapImages[mapImagesCount][5]		= 0;
		mapImages[mapImagesCount][6]		= 0;
		mapImages[mapImagesCount][7]		= 1;
		
		mapImagesBg[mapImagesCount] = new Array();
		mapImagesBgName[mapImagesCount] = new Array();
		for (i = 0; i < 336; i++) {
			if (i < 10) {
				locationPoint = '0'+i.toString();	
			} else {
				locationPoint = i.toString();
			}
			//mapImagesBgName[mapImagesCount][i] = new Image();
			//mapImagesBgName[mapImagesCount][i].src = root_link+'/images/directory/'+mapImages[mapImagesCount][3]+'/'+mapImages[mapImagesCount][0]+'_'+locationPoint+'.png';
			mapImagesBg[mapImagesCount][i] = 0;
		}
		
		mapImagesCount++;
		
		var origLeft = new Array();
		var origTop = new Array();
		var currLeft = new Array();
		var currTop = new Array();
		var limitLeft = new Array();
		var limitTop = new Array();
		var offsetLeft = new Array();
		var offsetTop = new Array();
		
		origLeft[0] = 362;
		origLeft[1] = 587;
		origTop[0] = 100;
		origTop[1] = 190;
		
		currLeft[0] = 362;
		currLeft[1] = 587;
		currTop[0] = 100;
		currTop[1] = 190;
		limitLeft[0] = 317;
		limitLeft[1] = 707;
		limitTop[0] = 10;
		limitTop[1] = 10;
		offsetLeft[0] = 5;
		offsetLeft[1] = 10;
		offsetTop[0] = 10;
		offsetTop[1] = 15;
		
		var winW = 0;
		var winH = 0;
		
		// Detect if the browser is IE or not.
		// If it is not IE, we assume that the browser is NS.
		var IE = document.all?true:false
		
		// If NS -- that is, !IE -- then set up for mouse capture
		if (!IE) document.captureEvents(Event.MOUSEMOVE)
		
		// Main function to retrieve mouse x-y pos.s
		
		var tempX = 0;
		var tempY = 0;
		
		// Set-up to use getMouseXY function onMouseMove
		document.onmousemove = getMouseXY;
		
		// Temporary variables to hold mouse x-y pos.s
		var tempMouseX = 0
		var tempMouseY = 0
		
		// Main function to retrieve mouse x-y pos.s
		
		function getMouseXY(e) {
		  if (IE) { // grab the x-y pos.s if browser is IE
			tempMouseX = event.clientX + document.body.scrollLeft
			tempMouseY = event.clientY + document.body.scrollTop
		  } else {  // grab the x-y pos.s if browser is NS
			tempMouseX = e.pageX
			tempMouseY = e.pageY
		  }  
		  // catch possible negative values in NS4
		  if (tempMouseX < 0){tempMouseX = 0}
		  if (tempMouseY < 0){tempMouseY = 0}  
		  // show the position values in the form named Show
		  // in the text fields named MouseX and MouseY
		  if (document.getElementById('thisMapOffsetLeft')) {
		  	mapCoord(0);
		  }
		  if (currFunction != '') {
			
			eval(currFunction);
			//alert(currFunction);
			
		  }
		  
		  return true
		}
		
		function check_email(email) {
			
			ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
			
			for(i=0; i < email.length ;i++){
				if(ok.indexOf(email.charAt(i))<0){ 
					return (false);
				}	
			}
			
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!email.match(re) && email.match(re_two)) {
				return (-1);		
			} 
			
		
		}
		
		function getScrollOffset() {
		
			setWindowProps();
		
			tempX = 0;
			tempY = 0;
			
			if (IE) { // grab the x-y pos.s if browser is IE
				tempX = document.body.scrollLeft;
				tempY = document.body.scrollTop;
			} else {
				tempX = window.pageXOffset;
				tempY = window.pageYOffset;
			}
			
			// catch possible negative values in NS4
			if (tempX < 0){tempX = 0}
			if (tempY < 0){tempY = 0}
			
			//alert(tempX + " " + tempY); 
		
		}

		function setWindowProps() {
			
			if (parseInt(navigator.appVersion)>3) {
				if (navigator.appName=="Netscape") {
					winW = window.innerWidth;
					winH = window.innerHeight;
				}
				if (navigator.appName.indexOf("Microsoft")!=-1) {
					winW = (document.body.offsetWidth-21);
					winH = (document.body.offsetHeight-4);
				}
			}
			
		}
		
		function setOpacity(divName,value) {
			if(document.getElementById(divName) == null) {
				return;
			}
			document.getElementById(divName).style.opacity = value/10;
			document.getElementById(divName).style.filter = 'alpha(opacity=' + value*10 + ')';
		}
		
		function displayOpacity(divName,value) {
			
			if (value == 10) {
				setOpacity(divName,value);
				clearTimeout(opacityTimeoutVar);
			} else {
				setOpacity(divName,value);
				opacityTimeoutVar = window.setTimeout("displayOpacity('"+divName+"',"+(value+1)+")",50);
			}
			
		}
		
		function displayOpacityNew(divName,value,increment,limit,num) {
			
			if (value == limit) {
				setOpacity(divName,value);
				clearTimeout(opacityTimeoutVar[num]);
			} else {
				setOpacity(divName,value);
				opacityTimeoutVar[num] = window.setTimeout("displayOpacityNew('"+divName+"',"+(value+increment)+","+increment+","+limit+","+num+")",20);
			}
			
		}
		
		function init(resize) {
			if (document.getElementById('DEVMODE')) {
				root_link = "http://www.cars21.local";
			}
			else {
				root_link = "http://www.cars21.com";
			}
			if (document.getElementById('currLib')) {
				currLib = document.getElementById('currLib').value;
				//alert(currLib);
			}
			
			if (document.getElementById('partnersRotateDiv')) {
				window.setTimeout('partnerOpacityStart(10)',rotateTimer);
			}
			
			if (document.getElementById('eventBanner1')) {
				window.setTimeout('eventBannerSwitch(1)',5000);
			}
			
			if (document.getElementById('eventBanner3')) {
				window.setTimeout('eventBannerSwitch2(1)',5000);
			}
			
			if (document.getElementById('featureDesc')) {
				featureTimer = window.setTimeout("closeFeatureImageFinal()",4000);
			}
			
			/*
			if (document.getElementById('communityUpdates')) {
				window.setTimeout('communityUpdatesSwitch()',2000);
			}
			*/
			
			//window.setTimeout('PartnerRotateWide(1)',4000);
			
			setWindowProps();
			
			loaded = 1;
			
			setVisit();
			
			if (document.getElementById('mapContent')) {
				//populateMap();	
			}
			
			if (document.getElementById('directoryListingInfo')) {
				document.getElementById('directoryListingInfo').style.visibility = "visible";
			}
			
			if (document.getElementById('directoryMapLoading')) {
				document.getElementById('directoryMapLoadingTopCircle').style.visibility = "visible";
				document.getElementById('directoryMapLoading').style.visibility = "visible";
				document.getElementById('directoryMapLoader').style.visibility = "visible";
			}
			
			if (document.getElementById('directoryListingContent')) {

				if (document.getElementById('directoryStartCompany').value != 0) {
					directoryStartCompanyAnchor = 0;
					directoryListingCompany(document.getElementById('directoryStartCompany').value);
					directoryStartCompany = document.getElementById('directoryStartCompany').value*1;
				} else {
					listingPartners(1,1);
				}
				
			}
			
			if (document.getElementById('resultsListContent')) {
				secondaryFunction = 'drawMaps()';
			}			
		}
		
		function setVisit() {
		
			currIp = document.getElementById('CurrIp').value;
			currMember = document.getElementById('CurrMem').value;
			currSession = document.getElementById('CurrSession').value;
		
			currHref = document.location.href;
		
			//alert(currHref);
		
			questionLocation = currHref.indexOf('?');
			
			variables = '';
			currPage = currHref;
			
			if (questionLocation != -1) {
				variables = currHref.split('?');
				currPage = variables[0];
				variables = variables[1].split('&');
			}
			
			//alert("functions.php?PageView=1&currPage="+currPage+"&variables="+variables+"&currMember="+currMember+"&currIp="+currIp+"&currSession="+currSession);
			
			currDiv = 'test';
			sendAjax("functions.php?PageView=1&currPage="+currPage+"&variables="+variables+"&currMember="+currMember+"&currIp="+currIp+"&currSession="+currSession,processAjax);
			
		}
		
		function setVisitGallery() {
		
			currIp = document.getElementById('CurrIp').value;
			currMember = document.getElementById('CurrMem').value;
			currSession = document.getElementById('CurrSession').value;
			
			currType = 0;
			currItem = 0;
			
			if (document.getElementById('ViewTypeId')) {
				currType = document.getElementById('ViewTypeId').value;
				currItem = document.getElementById('ViewItemId').value;
			}
		
			//currHref = document.location.href;
		
			//alert(currHref);
		
			questionLocation = currHref.indexOf('?');
			
			variables = '';
			currPage = 'Gallery';
			
			if (questionLocation != -1) {
				variables = currHref.split('?');
				currPage = variables[0];
				variables = variables[1].split('&');
			}
			
			//alert("functions.php?PageView=1&currPage="+currPage+"&variables="+variables+"&currMember="+currMember+"&currIp="+currIp+"&currSession="+currSession);
			
			currDiv = 'test';
			sendAjax("functions.php?PageView=1&currPage='GalleryView'&variables="+variables+"&currMember="+currMember+"&currIp="+currIp+"&currSession="+currSession+"&currType="+currType+"&currItem="+currItem,processAjax);
			
		}
				
		function IsNumeric(sText) {
		
			var ValidChars = "0123456789.,";
			var IsNumber=true;
			var Char;
		 
			for (i = 0; i < sText.length && IsNumber == true; i++) { 
				Char = sText.charAt(i); 
				if (ValidChars.indexOf(Char) == -1) {
					IsNumber = false;
				}
			}
			
			return IsNumber;
		   
		}
		
		function defaultField(fieldValue,fieldObject,fieldState) {
			
			if ((fieldState == 0) && (fieldObject.value == fieldValue)) {
				fieldObject.value = '';	
			} else if ((fieldState == 1) && (fieldObject.value == '')) {
				fieldObject.value = fieldValue;	
			}
		
		}
		
		function getTabBlog(CurrResults,SourceId,CategoryId,DateMonth,DateYear,Keyword) {
			
			document.location = '#listContentAnchor';
			currDiv = 'listContent';
			sendAjax("functions.php?getTabBlog=1&CurrResults="+CurrResults+"&SourceId="+SourceId+"&CategoryId="+CategoryId+"&DateMonth="+DateMonth+"&DateYear="+DateYear+"&Keyword="+Keyword,processAjax);			
			
		}
		
		function nothing() {}
		
		function sendAjax(urlContent,returnFunc) {
		
			if (loaded == 1) {
		
				if (currLib != '') {
					urlContent	+= "&LibName="+currLib;
				}
			
				if (noLoading == 0) {
			
				thisWidth = document.getElementById(currDiv).style.width.substring(0,((document.getElementById(currDiv).style.width.length*1)-2))*1;
				thisHeight = document.getElementById(currDiv).style.height.substring(0,((document.getElementById(currDiv).style.height.length*1)-2))*1;
				topPadding = Math.round(thisHeight/2);
				leftPadding = Math.round(thisWidth/2);
				
				document.getElementById(currDiv).innerHTML = '<div align="center" style="padding: '+topPadding+'px 0px 0px '+leftPadding+'px"><img src="'+root_link+'/images/main/ajax_loader.gif"></br></div>';
			
				}
			
				createRequest();			
				
				//alert(urlContent);
				
				request.open("GET", root_link + "/includes/scripts/" + urlContent, true);
				request.onreadystatechange = eval(returnFunc);
				request.send(null);
				/*
				window.clearTimeout(ajaxTimeout);
				ajaxTimeout = window.setTimeout("request.send(null)",500);
				*/
			
			}
			
		}
		
		function processAjax() {
			
			var thisFunction = '';
		
			if(request.readyState == 4) {
				
				if(request.status == 200) {
					
					if (currDiv == 'directoryListingInfo') {
						//alert(trim(request.responseText));
					}
				
					//alert(trim(request.responseText));
				
					if((document.getElementById(currDiv)) && (trim(request.responseText) != '')) {
						//alert(document.getElementById('hoverMain').innerHTML);
						document.getElementById(currDiv).innerHTML = trim(request.responseText);
						
						if (setCurrVisible == 1) {						
							document.getElementById(currDiv).style.visibility = "visible";
						}
						setCurrVisible = 1;
						//setOpacity(currDiv,9.7);
						/*
						clearTimeout(opacityTimeoutVar);
						displayOpacity(currDiv,1);
						*/
						//document.getElementById(currDiv).style.visibility = "visible";
						
						if (currDiv == 'imageMapZoom3') {
							//alert(document.getElementById('worldMap').useMap);	
							//alert(currFunction);
							//alert(document.getElementById('worldMap').useMap);
							//alert(document.getElementById(currDiv).style.zIndex);
							//alert(trim(request.responseText));
						}
						
						if (ajaxFunctionCounter > 0) {
							/*
							alert(ajaxFunctionCounter);
							*/
							ajaxFunctionCounter--;
							thisFunction = ajaxFunction[ajaxFunctionCounter];
							ajaxFunction[ajaxFunctionCounter] = '';
							eval(thisFunction);
						}
						
						if (secondaryFunction != '') {
							thisFunction = secondaryFunction;
							secondaryFunction = '';
							eval(thisFunction);
						}
						
						if (currAnchor != '') {
							document.location.href = currAnchor;
							currAnchor = '';
						}
						
						tempContent = '';
						loadedContent = 1;
						noLoading = 0;
						
						if (document.getElementById('directoryMapLoader') && (currDiv != 'mapContentCompanies') && (loadingStart == 0)) {
							document.getElementById('directoryMapLoader').style.visibility = 'hidden';	
						}
						
						if (currDiv == 'mapContentCompanies') {
							//alert(document.getElementById(currDiv).style.zIndex+ ' ' +document.getElementById(currDiv).style.visibility);
							//alert(ajaxFunctionCounter);
							window.setTimeout("document.getElementById('directoryMapLoader').style.visibility='hidden'",2000);
							loadingStart = 0;
						}
			
						
						/*
						if (waitFunction != '') {
							eval(waitFunction);	
						}
						*/
						
					}
					
				}
				
			}
		
		}
		
		function pageScroll() {
			getScrollOffset();
			if ((tempY+winH) < 570) {
				window.scrollBy(0,10); // horizontal and vertical scroll increments
				scrolldelay = setTimeout("pageScroll()",20); // scrolls every 100 milliseconds
			}
		}
		
		function trim(stringToTrim) {
			return stringToTrim.replace(/^\s+|\s+$/g,"");
		}
		
		function print_page(pageLink) {
			myRef = window.open(''+pageLink,'mywin','left=20,top=20,width=760,height=500,toolbar=0,resizable=0,scrollbars=1;');
		}
		
		var recaptchaVisible = false;
		
		function showRecaptcha() {
			if(recaptchaVisible) {
				return true;
			}
			
			//make room
//			document.getElementById('InputMessage').style.height = 80;
			
			//create recaptcha objecy
			Recaptcha.create("6LeLTcQSAAAAAHUXSq3OTRPsJv4HomNGvL-toHFI",
				"recaptcha_placeholder",
				{
				  theme: "clean",
				  callback: Recaptcha.focus_response_field
				}
			  );
				  
			recaptchaVisible = true;
			
			return false;
		}
		
		function check_errors(formName) {
			
			var submitOk = 1;
			var formatErrorMessage = 1;
			var errorContent = '<div style="font-weight: bold; padding-bottom: 5px;">The following fields have not been entered:</div>';
		//	var SecurityWord = document.CommentForm.SecurityWord.value;
		//	var SecurityWordVerify = document.CommentForm.SecurityWordVerify.value;
				
				
			if (formName == 'LoginForm') {
				
				document.LoginForm.LoginCorrect.value = 1;
				document.getElementById('loginerror').style.visibility = 'hidden';
				
				var Username = document.LoginForm.Username.value;
				var Password = document.LoginForm.Password.value;
				
				if ((Username == '') || (Username == 'your email address')) {
					submitOk = 0;
				}
				
				if ((Password == '') || (Password == 'your password')) {
					submitOk = 0;
				}
				
			} else if (formName == 'RegistrationForm') {
			
				var PrefixId = document.RegistrationForm.PrefixId.value;
				var FirstName = document.RegistrationForm.FirstName.value;
				var LastName = document.RegistrationForm.LastName.value;
				var Email = document.RegistrationForm.Email.value;
				var Username = document.RegistrationForm.Username.value;
				var UsernameValid = document.RegistrationForm.UsernameValid.value;
				var Password = document.RegistrationForm.Password.value;
				var PasswordRepeat = document.RegistrationForm.PasswordRepeat.value;
				
				var Company = document.RegistrationForm.Company.value;
				
				if (PrefixId == 0) {
					submitOk = 0;
					errorContent += 'Please select your title<br>';
				}
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if (Company.indexOf('google') != -1) {
					submitOk = 0;
					errorContent += 'Please enter a valid organisation<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
				
				/*else {
				
					if (EmailValid == 0) {
						submitOk = 0;
						errorContent += 'Please enter a valid username<br>';
					}
				
				}*/
				
				if (Username == '') {
					submitOk = 0;
					errorContent += 'Please enter a username of at least 4 characters<br>';
				} else {
				
					if (UsernameValid == 0) {
						submitOk = 0;
						errorContent += 'Please enter a valid username of at least 4 characters<br>';
					}
				
				}
				
				if (Password.length < 6) {
					submitOk = 0;
					errorContent += 'Please enter a password of at least 6 characters<br>';
				}
				
				if (Password != PasswordRepeat) {
					submitOk = 0;
					errorContent += 'Your passwords do not match!<br>';
				}
				
				if (!document.RegistrationForm.terms.checked) {
					submitOk = 0;
					errorContent += 'Please confirm that you have read our terms and conditions<br>';
				}
			
			} else if (formName == 'PartnerRequest') {
			
				var FirstName = document.PartnerRequest.FirstName.value;
				var LastName = document.PartnerRequest.LastName.value;
				var Email = document.PartnerRequest.Email.value;
				var Company = document.PartnerRequest.Company.value;
				var Message = document.PartnerRequest.Message.value;
				
				formatErrorMessage = 0;
				
				if(!recaptchaVisible) {
					showRecaptcha();
					submitOk = 0;
					errorContent += 'Please enter the captcha<br>';
				}
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
				
				if ((Company == '')) {
					submitOk = 0;
					errorContent += 'Please enter a valid company name<br>';
				} else if (Company.indexOf('google') != -1) {
					submitOk = 0;
					errorContent += 'Please enter a valid company name<br>';
				}
				
				if (Message == '') {
					submitOk = 0;
					errorContent += 'Please enter your request text<br>';
				} else if ((Message.toLowerCase().indexOf('href') != -1) || (Message.toLowerCase().indexOf('<a') != -1) || (Message.toLowerCase().indexOf('http') != -1) || (Message.toLowerCase().indexOf('www') != -1)) {
					submitOk = 0;
					errorContent += 'Please do not include links in your text<br>';
				}
			
			} else if (formName == 'ContactRequest') {
				
				var FirstName = document.ContactRequest.FirstName.value;
				var LastName = document.ContactRequest.LastName.value;
				var Email = document.ContactRequest.Email.value;
				var Company = document.ContactRequest.Company.value;
				var Message = document.ContactRequest.Message.value;
				
				formatErrorMessage = 0;
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
				
				if ((Company == '')) {
					submitOk = 0;
					errorContent += 'Please enter a valid company name<br>';
				} else if (Company.indexOf('google') != -1) {
					submitOk = 0;
					errorContent += 'Please enter a valid company name<br>';
				}
				
				if (Message == '') {
					submitOk = 0;
					errorContent += 'Please enter your enquiry text<br>';
				} else if ((Message.toLowerCase().indexOf('href') != -1) || (Message.toLowerCase().indexOf('<a') != -1) || (Message.toLowerCase().indexOf('http') != -1) || (Message.toLowerCase().indexOf('www') != -1)) {
					submitOk = 0;
					errorContent += 'Please do not include links in your text<br>';
				}
			
			} else if (formName == 'SubscriptionForm') {
			
				var FirstName = document.SubscriptionForm.FirstName.value;
				var LastName = document.SubscriptionForm.LastName.value;
				var Email = document.SubscriptionForm.Email.value;
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
			
			} else if (formName == 'ProfileForm') {
			
				var PrefixId = document.ProfileForm.PrefixId.value;
				var FirstName = document.ProfileForm.FirstName.value;
				var LastName = document.ProfileForm.LastName.value;
				var Email = document.ProfileForm.Email.value;
				var Username = document.ProfileForm.Username.value;
				var UsernameValid = document.ProfileForm.UsernameValid.value;
				var Password = document.ProfileForm.Password.value;
				var PasswordRepeat = document.ProfileForm.PasswordRepeat.value;
				/*
				var Password = document.RegistrationForm.Password.value;
				var PasswordRepeat = document.RegistrationForm.PasswordRepeat.value;
				*/
				if (PrefixId == 0) {
					submitOk = 0;
					errorContent += 'Please select your title<br>';
				}
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}

				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
				
				if (Username == '') {
					submitOk = 0;
					errorContent += 'Please enter a username of at least 4 characters<br>';
				} else {
				
					if (UsernameValid == 0) {
						submitOk = 0;
						errorContent += 'Please enter a valid username of at least 4 characters<br>';
					}
				
				}
				
				if (Password != '') {
				
					if (Password.length < 6) {
						submitOk = 0;
						errorContent += 'Please enter a password of at least 6 characters<br>';
					}
					
					if (Password != PasswordRepeat) {
						submitOk = 0;
						errorContent += 'Your passwords do not match!<br>';
					}
				
				}
			
			} else if (formName == 'PaperForm') {
			
				var Title = document.PaperForm.Title.value;
				
				var Year = document.PaperForm.Year.value;
				var Pages = document.PaperForm.Pages.value;
				var SectorCount = document.PaperForm.SectorCount.value;
				var TopicCount = document.PaperForm.TopicCount.value;
				var AuthorCount = document.PaperForm.AuthorCount.value;
				var OrgCount = document.PaperForm.OrgCount.value;
				
				var SectorId = document.PaperForm.SectorId.value;
				var TopicId = document.PaperForm.TopicId.value;
				var AuthorId = document.PaperForm.AuthorId.value;
				var AuthorNew = document.PaperForm.AuthorNew.value;
				var OrgId = document.PaperForm.OrgId.value;
				var OrgNew = document.PaperForm.OrgNew.value;
				
				var FileSource = document.PaperForm.FileSource.value;
				
				document.getElementById('loaderPaper').style.visibility = "visible";
				
				//errorContent = '';
				
				var fileExt = FileSource.substring((FileSource.length-4),FileSource.length);
				
				if (Title == '') {
					submitOk = 0;
					errorContent += 'Please enter the title of your paper<br>';
				}
				
				if ((Year == '') || (Year == 0)) {
					submitOk = 0;
					errorContent += 'Please enter the year of publication of your paper<br>';
				}
				
				if ((Pages == '') || (Pages == 0)) {
					submitOk = 0;
					errorContent += 'Please enter the number of pages in your paper<br>';
				}
				
				if ((SectorCount == 1) && (SectorId == 0)) {
					submitOk = 0;
					errorContent += 'Please add at least 1 sector<br>';
				}
				
				if ((TopicCount == 1) && (TopicId == 0)) {
					submitOk = 0;
					errorContent += 'Please add at least 1 topic<br>';
				}
				
				if ((AuthorCount == 1) && (AuthorId == 0) && (AuthorNew == '')) {
					submitOk = 0;
					errorContent += 'Please select at least 1 author<br>';
				}
				
				if ((OrgCount == 1) && (OrgId == 0) && (OrgNew == '')) {
					submitOk = 0;
					errorContent += 'Please select at least 1 organisation<br>';
				}
				
				if (FileSource == '') {
					submitOk = 0;
					errorContent += 'Please choose your file before submitting<br>';
				}
				
				if ((fileExt != '.pdf') && (fileExt != '.ppt') && (fileExt != '.doc') && (fileExt != '.xls')) {
					submitOk = 0;
					errorContent += 'Please upload a file of "pdf format", "powerpoint", "document" or "excel"<br>';
				}
			
			} else if (formName == 'ProfileNewsForm') {
			
				var SourceId = document.ProfileNewsForm.SourceId.value;
				var SourceNew = document.ProfileNewsForm.SourceNew.value;
				var Title = document.ProfileNewsForm.Title.value;
				var Synopsis = document.ProfileNewsForm.Synopsis.value;
				var AttachCount = document.ProfileNewsForm.AttachCount.value;
				
				var Title = document.ProfileNewsForm.AttachCount.value;
				
				document.getElementById('loaderNews').style.visibility = "visible";
				
				InvalidDoc = 0;
				
				for (i = 1; i < AttachCount; i++) {
				
					if (eval('document.ProfileNewsForm.AttachFile_'+i)) {
						FileSource = eval('document.ProfileNewsForm.AttachFile_'+i).value;
						fileExt = FileSource.substring((FileSource.length-4),FileSource.length);
						if (fileExt != '.pdf'){
							InvalidDoc = 1;
						}
					}
				
				}
				
				//errorContent = '';
				//var fileExt = FileSource.substring((FileSource.length-4),FileSource.length);
				
				if ((SourceNew == '') && (SourceId == 0)) {
					submitOk = 0;
					errorContent += 'Please enter the source of your news article<br>';
				}
				
				if (Title == '') {
					submitOk = 0;
					errorContent += 'Please enter the title of your news article<br>';
				}
				
				if ((Synopsis == '') || (Synopsis.length > 300)) {
					submitOk = 0;
					errorContent += 'Please enter the summary for your news article, without exceeding 300 characters<br>';
				}
				
				if (InvalidDoc == 1) {
					submitOk = 0;
					errorContent += 'Please add attachments of "pdf format" only<br>';
				}
				
				if (document.getElementById('AttachDocContent_'+AttachCount).style.visibility == 'visible') {
					submitOk = 0;
					errorContent += 'Please click on the Attach button to add your file or link before sharing your news<br>';
				}
				
				/*
				if (FileSource == '') {
					submitOk = 0;
					errorContent += 'Please choose your file before submitting<br>';
				}
				
				if ((fileExt != '.pdf') && (fileExt != '.ppt') && (fileExt != '.doc') && (fileExt != '.xls')) {
					submitOk = 0;
					errorContent += 'Please upload a file of "pdf format", "powerpoint", "document" or "excel"<br>';
				}*/
				
			} else if (formName == 'ProfileDocForm') {
			
				var Title = document.ProfileDocForm.Title.value;
				var FileName = document.ProfileDocForm.FileName.value;
				
				if (Title == '') {
					submitOk = 0;
					errorContent += 'Please enter the document title<br>';
				}
				
				if (FileName == '') {
					submitOk = 0;
					errorContent += 'Please specify the file you wish to upload<br>';
				}
			
			} else if (formName == 'ProfileInviteForm') {
			
				var FirstName = document.ProfileInviteForm.FirstName.value;
				var LastName = document.ProfileInviteForm.LastName.value;
				var Email = document.ProfileInviteForm.Email.value;
				var Message = document.ProfileInviteForm.Message.value;
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter the first name of the person you wish to invite<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter the last name of the person you wish to invite<br>';
				}
				
				if (Email == '') {
					submitOk = 0;
					errorContent += 'Please enter the email address of the person you wish to invite<br>';
				}
				
				if (Message == '') {
					submitOk = 0;
					errorContent += 'Please enter a brief message to accompany your invitation<br>';
				}
			
			} else if (formName == 'CommentForm') {
			
				var Comment = document.CommentForm.Comment.value;
				
				if (document.CommentForm.Email) {
					
					var Email = document.CommentForm.Email.value;
								
					if (trim(Email) == '') {
						submitOk = 0;
						errorContent += 'Please enter your email address before submitting<br>';
					} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
					
				}
								
				if (trim(Comment) == '') {
					submitOk = 0;
					errorContent += 'Please enter a comment before submitting<br>';
				}
				
				if ((Comment.indexOf('<a') != -1) || (Comment.indexOf('<A') != -1) || (Comment.indexOf('http://') != -1) || (Comment.indexOf('www.') != -1)) {
					submitOk = 0;
					errorContent += 'Please do not enter any links in your comment<br>';
				}
				/*if (SecurityWord != SecurityWordVerify) {
					submitOk = 0;
					errorContent += 'Your security word is not correct!<br>';
				}
			*/				
			} else if (formName == 'ForumPostForm') {
			
				var Title = document.ForumPostForm.Title.value;
				
				if (trim(Title) == '') {
					submitOk = 0;
					errorContent += 'Please enter a subject before submitting<br>';
				}
							
			} else if (formName == 'GroupPostForm') {
			
				var Title = document.GroupPostForm.Title.value;
				
				if (trim(Title) == '') {
					submitOk = 0;
					errorContent += 'Please enter a subject before submitting<br>';
				}
							
			} else if (formName == 'GroupShareFileForm') {
			
				var Title = document.GroupShareFileForm.Title.value;
				var File = document.GroupShareFileForm.File.value;
				var Link = document.GroupShareFileForm.Link.value;
				
				var checkFile = 1;
				
				if ((document.GroupShareFileForm.MemberDocument) && (document.GroupShareFileForm.MemberDocument.selectedIndex != 0)) {
					checkFile = 0;	
				}
				
				if (checkFile == 1) {
				
					if (trim(Title) == '') {
						submitOk = 0;
						errorContent += 'Please enter a file title<br>';
					}
				
					if ((trim(File) == '') && ((trim(Link) == '') || (trim(Link) == 'http://'))) {
						submitOk = 0;
						errorContent += 'Please choose a file through the browser or enter a link url<br>';
					}
				
				}
							
			} else if (formName == 'GroupMemberForm') {
			
				var Name = document.GroupMemberForm.Name.value;
				var Email = document.GroupMemberForm.Email.value;
				
				if (trim(Name) == '') {
					submitOk = 0;
					errorContent += 'Please enter the full name of the person you wish to invite<br>';
				}
			
				if (trim(Email) == '') {
					submitOk = 0;
					errorContent += 'Please enter the email address of the person you wish to invite<br>';
				}
			
			} else if (formName == 'GroupMeetingForm') {
			
				var Name = document.GroupMeetingForm.Name.value;
				var Location = document.GroupMeetingForm.Location.value;
				var StartDate = document.GroupMeetingForm.StartDate.value;
				var EndDate = document.GroupMeetingForm.EndDate.value;
				
				if (trim(Name) == '') {
					submitOk = 0;
					errorContent += 'Please enter the name of the meeting<br>';
				}
			
				if (trim(Location) == '') {
					submitOk = 0;
					errorContent += 'Please enter the location of the meeting <br>';
				}
			
				if (trim(StartDate) == '') {
					submitOk = 0;
					errorContent += 'Please enter the start date of the meeting <br>';
				}
			
				if (trim(EndDate) == '') {
					submitOk = 0;
					errorContent += 'Please enter the end date of the meeting <br>';
				}
							
			} else if (formName == 'GroupThreadForm') {
			
				var Name = document.GroupThreadForm.Name.value;
				var Synopsis = document.GroupThreadForm.Synopsis.value;
				
				if (trim(Name) == '') {
					submitOk = 0;
					errorContent += 'Please enter the subject of your thread<br>';
				}
			
				if (trim(Synopsis) == '') {
					submitOk = 0;
					errorContent += 'Please enter the message of your thread <br>';
				}
							
			} else if (formName == 'GroupDocForm') {
			
				var Title = document.GroupDocForm.Title.value;
				var Synopsis = document.GroupDocForm.Synopsis.value;
				
				if (trim(Title) == '') {
					submitOk = 0;
					errorContent += 'Please enter the title of the document<br>';
				}
			
				if (trim(Synopsis) == '') {
					submitOk = 0;
					errorContent += 'Please enter the description of the document <br>';
				}
							
			} else if (formName == 'GroupDocSectionForm') {
			
				var Title = document.GroupDocSectionForm.Title.value;
				var Synopsis = document.GroupDocSectionForm.Synopsis.value;
				
				if (trim(Title) == '') {
					submitOk = 0;
					errorContent += 'Please enter the name of the section<br>';
				}
			
				if (trim(Synopsis) == '') {
					submitOk = 0;
					errorContent += 'Please enter the description of the section <br>';
				}
							
			} else if (formName == 'ContactInquiry') {
			
				var FirstName = document.ContactInquiry.FirstName.value;
				var LastName = document.ContactInquiry.LastName.value;
				var Email = document.ContactInquiry.Email.value;
				var Comments = document.ContactInquiry.Comments.value;
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
				
				if (Comments == '') {
					submitOk = 0;
					errorContent += 'Please enter your comments<br>';
				}
				
			} else if (formName == 'GroupSuggest') {
			
				var Name = document.GroupSuggest.Name.value;
				var Synopsis = document.GroupSuggest.Synopsis.value;
				
				if (Name == '') {
					submitOk = 0;
					errorContent += 'Please enter the group name<br>';
				}
				/*
				if (Synopsis == '') {
					submitOk = 0;
					errorContent += 'Please enter a description of the group<br>';
				}
				*/
				
			} else if (formName == 'ProfileMessageForm') {
			
				var Contact_1 = document.ProfileMessageForm.Contact_1.value;
				var Subject = document.ProfileMessageForm.Subject.value;
				
				//alert(Contact_1);
				
				if (Contact_1 == 0) {
					submitOk = 0;
					errorContent += 'Please select at least on contact<br>';
				}
				if (Subject == '') {
					submitOk = 0;
					errorContent += 'Please enter the subject of your message<br>';
				}
				/*
				if (Synopsis == '') {
					submitOk = 0;
					errorContent += 'Please enter a description of the group<br>';
				}
				*/
				
			} else if (formName == 'SurveyFormHome') {
			
				var PrefixId = document.RegistrationForm.PrefixId.value;
				var FirstName = document.RegistrationForm.FirstName.value;
				var LastName = document.RegistrationForm.LastName.value;
				var Email = document.RegistrationForm.Email.value;
				var Username = document.RegistrationForm.Username.value;
				var UsernameValid = document.RegistrationForm.UsernameValid.value;
				var Password = document.RegistrationForm.Password.value;
				var PasswordRepeat = document.RegistrationForm.PasswordRepeat.value;
				
				var Company = document.RegistrationForm.Company.value;
				
				if (PrefixId == 0) {
					submitOk = 0;
					errorContent += 'Please select your title<br>';
				}
				
				if (FirstName == '') {
					submitOk = 0;
					errorContent += 'Please enter your first name<br>';
				}
				
				if (LastName == '') {
					submitOk = 0;
					errorContent += 'Please enter your last name<br>';
				}
				
				if (Company.indexOf('google') != -1) {
					submitOk = 0;
					errorContent += 'Please enter a valid organisation<br>';
				}
				
				if ((Email == '')) {
					submitOk = 0;
					errorContent += 'Please enter your email address<br>';
				} else if (!check_email(Email)) {
					submitOk = 0;
					errorContent += 'Please enter a valid email address<br>';
				}
				
				if (Username == '') {
					submitOk = 0;
					errorContent += 'Please enter a username of at least 4 characters<br>';
				} else {
				
					if (UsernameValid == 0) {
						submitOk = 0;
						errorContent += 'Please enter a valid username of at least 4 characters<br>';
					}
				
				}
				
				if (Password.length < 6) {
					submitOk = 0;
					errorContent += 'Please enter a password of at least 6 characters<br>';
				}
				
				if (Password != PasswordRepeat) {
					submitOk = 0;
					errorContent += 'Your passwords do not match!<br>';
				}
				
				if (!document.RegistrationForm.terms.checked) {
					submitOk = 0;
					errorContent += 'Please confirm that you have read our terms and conditions<br>';
				}
			
			}
			
			if (submitOk == 1) {
				if (formName == 'SurveyFormHome') {
					document.SurveyFormHome.submit();
				} else if (formName == 'LoginForm') {
					document.LoginForm.submit();
				} else {
					return true;
				}
			} else {
				
				if (formName == 'LoginForm') {
				
					document.getElementById('homeLoginRemember').style.visibility = 'hidden';
					document.getElementById('loginerror').innerHTML = 'invalid login detailss';
					document.getElementById('loginerror').style.visibility = 'visible';
					document.getElementById('loginerror').style.color='red';
				
				} else {
				
					if (document.getElementById('loaderPaper')) {
					document.getElementById('loaderPaper').style.visibility = "hidden";
					}
					
					if (document.getElementById('loaderNews')) {
					document.getElementById('loaderNews').style.visibility = "hidden";
					}
					
					document.location.href = '#formErrors';
					if (formatErrorMessage == 1) {
					document.getElementById('formErrorsDiv').style.padding = "10px 5px 5px 0px";
					document.getElementById('formErrorsDiv').style.display = "block";
					document.getElementById('formErrorsDiv').style.color = "#CC0000";
					}
					document.getElementById('formErrorsDiv').innerHTML = errorContent;
					return false;
				
				}
				
			}
			
		}
		
		
	
	function verifyLogin() {
		
		var Username = document.LoginForm.Username.value;
		var Password = document.LoginForm.Password.value;
		
		if (Username != '' && Password != '' && Username != 'your email address' && Password != 'your password') {
			document.getElementById('loginerror').style.visibility = 'hidden';
			noLoading = 1;
			currDiv = 'loginerror';
			sendAjax("functions.php?verifyLogin=1&Username="+Username+"&Password="+Password,processAjax);
			
		} 
	
	}
	
	
	function carsLogin() {
		
		//alert(document.LoginForm.LoginCorrect.value);
				
		if (document.LoginForm.LoginCorrect.value==1) {
			document.LoginForm.submit();
		} else {
			check_errors('LoginForm');
		}
	}
	
	
	function verifySubmit(keyCode,formName) {
	
		if (keyCode == 13) {
			if (formName == 'RegisterForm') {
				check_errors(formName);	
			} else if (formName == 'LoginForm') {
				check_errors(formName);	
			} else if (formName == 'ContactFindList') {
				popupContactsList();	
			} else {
				if (formName == 'StartRegisterForm') {
					verifyEmail(document.StartRegisterForm.Email);
					window.setTimeout("eval('document."+formName+"').submit()",500);
				} else {
					eval('document.'+formName).submit();
				}
			}
		}
	
	}
		
		function dispNavSub(SetNav,CurrNavDisp) {
			
			clearTimeout(currNavTimeout);
			
			if (CurrNavDisp != CurrNav) {
				hideNavSub(CurrNav);
			}
			
			hideNavSub(CurrNavDisp);
			
			CurrNav = SetNav;
			
			ImageName = document.getElementById('ImageNameNav'+CurrNav).value;
			//eval('document.Nav'+CurrNav).src= root_link+'/images/menu/'+ImageName+'-on.jpg';
		
			document.getElementById('topNavSub'+SetNav).style.visibility = 'visible';
		
		}
		
		function dispNavSubSec(SetNav,CurrNavDisp) {
			
			clearTimeout(currNavTimeout);
			
			if (CurrNavDisp != CurrNav) {
				hideNavSub(CurrNav);
			}
			
			hideNavSub(CurrNavDisp);
			
			CurrNav = SetNav;
			
			ImageName = document.getElementById('ImageNameNav'+CurrNav).value;
			eval('document.Nav'+CurrNav).src= root_link+'/images/menu/'+ImageName+'-on.gif';
		
			document.getElementById('topNavSub'+SetNav).style.visibility = 'visible';
		
		}
		
		function hideNavSub(SetNav) {
			
			ImageName = document.getElementById('ImageNameNav'+SetNav).value;
		//	eval('document.Nav'+SetNav).src= root_link+'/images/menu/'+ImageName+'.gif';
			document.getElementById('topNavSub'+SetNav).style.visibility = 'hidden';
		
		}
		
		function hideNavSubDelay(SetNav) {
			
			currNavTimeout = window.setTimeout("dispNavSub("+SetNav+","+CurrNav+")",500);
			
		}
		
		function setNavLinks(SectionId,SubSectionId) {
			
			noLoading = 1;
			currDiv = 'topNav';
			sendAjax("functions.php?setNavLinks=1&SectionId="+SectionId+"&SubSectionId="+SubSectionId,processAjax);
			
		}
		
		function displayFeat(featNum,type,Id) {
			
			if (currFeat != featNum) {
				
				clearTimeout(currCircleTimeout);
				
				//alert(document.getElementById('FeatText'+currFeat));
				document.getElementById('FeatText'+currFeat).style.visibility = "hidden";
				
				currFeat = featNum;
				
				document.getElementById('FeatText'+currFeat).style.visibility = "visible";
				
				if (featNum == 1) {
					//document.getElementById('featCircle').style.left = "0px";
					//document.getElementById('featCircle').style.top = "0px";
					moveFeatCircle(0,0,16);
				} else if (featNum == 2) {
					//document.getElementById('featCircle').style.left = "141px";
					//document.getElementById('featCircle').style.top = "0px";
					moveFeatCircle(141,0,16);
				} else if (featNum == 3) {
					//document.getElementById('featCircle').style.left = "0px";
					//document.getElementById('featCircle').style.top = "79px";
					moveFeatCircle(0,79,16);
				} else if (featNum == 4) {
					//document.getElementById('featCircle').style.left = "141px";
					//document.getElementById('featCircle').style.top = "79px";
					moveFeatCircle(141,79,16);
				}
				//alert(document.getElementById('featCircle').style.left);
				currDiv = 'featContent';
							
				/*
			
				document.getElementById('featArrow'+currFeat).style.visibility = "hidden";
			
				waitFunction = 'displayFeat('+featNum+','+type+','+Id+')';
				
				window.clearTimeout(rotateTimeout);
				document.getElementById('featIcon'+currFeat).style.opacity = 6/10;
				document.getElementById('featIcon'+currFeat).style.filter = 'alpha(opacity=' + 6*10 + ')';
				document.getElementById('featIcon'+currFeat).style.backgroundColor = '#FFF';
				currFeat = featNum;
				document.getElementById('featIcon'+currFeat).style.opacity = 10/10;
				document.getElementById('featIcon'+currFeat).style.filter = 'alpha(opacity=' + 10*10 + ')';
				document.getElementById('featIcon'+currFeat).style.backgroundColor = '#912422';
				currDiv = 'featContent';
				
				tempContent = document.getElementById(currDiv).innerHTML;
				
				document.getElementById('featArrow'+featNum).style.visibility = "visible";
				
				*/
				
				loadedContent = 0;
				//alert("functions.php?featureSpaceContent=1&type=");
				sendAjax("functions.php?featureSpaceContent=1&type="+type+"&Id="+Id,processAjax);
							
			}
			
		}
		
		function show_star(num){
			
			//alert(num);
			
			for (i = 1; i <= num; i++) {
				//alert(document.getElementById('star'+i));
				document.getElementById('star'+i).src = root_link + '/images/main/star_on.gif';
			}
			
		}
		
		function hide_star(){
			
			for (i = 1; i <= 5; i++) {
				document.getElementById('star'+i).src = root_link + '/images/main/star_off.gif';
			}
			
		}
		
		function setRating(TypeId,Id,Num,UserId) {
			
			currDiv = 'ratingDisp';
			//alert("functions.php?setRating=1&TypeId="+TypeId+"&Id="+Id+"&Num="+Num+"&UserId="+UserId);
			sendAjax("functions.php?setRating=1&TypeId="+TypeId+"&Id="+Id+"&Num="+Num+"&UserId="+UserId,processAjax);
		}
		
		function PartnerRotateTop() {
			
			/*
			var totalDivs = document.getElementById('partnersTopTotal').value;
			var packageId = document.getElementById('package'+currPartnerWide).value;			
			document.getElementById('partnerDiv'+currPartnerWide).style.visibility = 'hidden';
			document.getElementById('partnerLogo'+packageId).style.visibility = 'hidden';
			
			if (currPartnerWide == totalDivs) {
				currPartnerWide = 1;
			} else {
				currPartnerWide++;
			}
			
			packageId = document.getElementById('package'+currPartnerWide).value;			
			document.getElementById('partnerDiv'+currPartnerWide).style.visibility = 'visible';
			document.getElementById('partnerLogo'+packageId).style.visibility = 'visible';
			*/
			partnerOpacityStart(10);
			//window.setTimeout('PartnerRotateTop()',4000);
			
		}
		
		function partnerOpacityStart(opacityValue) {
		
			setOpacity('partnerDiv'+currPartnerWide,opacityValue);
			
			opacityValue--;
			
			if (opacityValue >= 0) {
				window.setTimeout("partnerOpacityStart("+opacityValue+")",80);
			} else {
				var totalDivs = document.getElementById('partnersTopTotal').value;
				if(document.getElementById('package'+currPartnerWide) == null) {
					return;
				}
				var packageId = document.getElementById('package'+currPartnerWide).value;			
				
				document.getElementById('partnerDiv'+currPartnerWide).style.visibility = 'hidden';
				
				if (!document.getElementById('partnerHeaderTitle')) {
					//document.getElementById('partnerLogo'+packageId).style.visibility = 'hidden';
				}
			
				if (currPartnerWide == totalDivs) {
					currPartnerWide = 1;
				} else {
					currPartnerWide++;
				}
			
				packageId = document.getElementById('package'+currPartnerWide).value;			
				//document.getElementById('partnerDiv'+currPartnerWide).style.visibility = 'visible';
				if (document.getElementById('partnerHeaderTitle')) {
					var PackName = document.getElementById('PackName'+currPartnerWide).value;			
					//document.getElementById('partnerHeaderTitle').innerHTML = PackName+' PARTNERS';
				} else {
					//document.getElementById('partnerLogo'+packageId).style.visibility = 'visible';
				}
				
				partnerOpacityEnd(0);				
			}
		
		}
		
		function partnerOpacityEnd(opacityValue) {
		
			setOpacity('partnerDiv'+currPartnerWide,opacityValue);
			document.getElementById('partnerDiv'+currPartnerWide).style.visibility = 'visible';
			
			opacityValue++;
			
			if (rotateTimer == 7000) {
				rotateTimer = 3000;	
			} else if (rotateTimer == 3000) {
				rotateTimer = 2000;	
			} else {
				rotateTimer = 7000;	
			}
			
			if (opacityValue <= 10) {
				window.setTimeout("partnerOpacityEnd("+opacityValue+")",50);
			} else {
				window.setTimeout('partnerOpacityStart(10)',rotateTimer);
			}
		
		}
		
		function PartnerRotateWide(num) {
			
			if (document.getElementById('partnerDiv'+currPartnerWide)) {
			
				//document.getElementById('partnerDiv'+currPartnerWide).style.visibility = "hidden";
				
				opacityDiv('partnerDiv'+currPartnerWide,10,0);
				
				if (num == 0) {
					if (currPartnerWide > 1) {
						currPartnerWide--;
					} else {
						currPartnerWide = (document.getElementById('partnersWideTotal').value*1);
					}
				}
				else {
					if (currPartnerWide < (document.getElementById('partnersWideTotal').value*1)) {
						currPartnerWide++;
					} else {
						currPartnerWide = 1;
					}
				}
				
				currPackage = document.getElementById('packageId'+currPartnerWide).value*1;
				//alert(currPackage + ' ' + currPartnerWide);
				currBg = document.getElementById('partnerBg'+currPackage).value;
				currTitle = document.getElementById('partnerTitle'+currPackage).value;
				//currBorder = document.getElementById('partnerBorder'+currPackage).value;
				
				//document.getElementById('partnerBg').style.backgroundColor = "#"+currBg;
				//document.getElementById('partnerBorder').style.backgroundColor = "#"+currBg;
				
				//rotateDiv('partnerDiv'+currPartnerWide,8,-300,0);
				//document.getElementById('partnerDiv'+currPartnerWide).style.visibility = "visible";
	
				clearTimeout(partnerRotateTimeoutMain);
				
				//partnerRotateTimeoutMain = window.setTimeout('PartnerRotateWide(1)',4000);
				
			}
			
		}
		
		function opacityDiv(divName,opacityValue,direction) {
		
			setOpacity(divName,opacityValue);
			
			if (direction == 1) {
				if (opacityValue < 10) {
					window.setTimeout("opacityDiv('"+divName+"','"+(opacityValue+1)+"',"+direction+")",120);
				} else {
					partnerRotateTimeoutMain = window.setTimeout('PartnerRotateWide(1)',(4000));
				}
			} else {
				if (opacityValue > 0) {
					window.setTimeout("opacityDiv('"+divName+"','"+(opacityValue-1)+"',"+direction+")",50);
				} else {
					document.getElementById(divName).style.visibility = "hidden";
					opacityDiv('partnerDiv'+currPartnerWide,0,1);
					document.getElementById('partnerDiv'+currPartnerWide).style.visibility = "visible";
				}
			}
		
		}
	
		function openBoxInfo(num) {
			
			if (CurrInfoBox != num) {
			
				CurrInfoBox = num;
			
				AbortCloseBox = 1;
				
				document.getElementById('linkInfoBox').style.visibility = "visible";
				
				document.getElementById('linkInfoContent').innerHTML = document.getElementById('linkInfoContent'+num).innerHTML;
				
				if (LinkInfoBoxOpen == 0) {
					expandBoxInfo('linkInfoBox',10,300);
				} else {
					clearTimeout(LinkInfoBoxTimer);
					LinkInfoBoxTimer = window.setTimeout("closeBoxInfo('linkInfoBox',300,0)",10000);
				}
				
				window.setTimeout("AbortCloseBox = 0",200);
			
			}
			
		}
			
		function expandBoxInfo(DivId,Width,ThisLimit) {
			
			window.clearTimeout(LinkInfoBoxTimer);
			
			document.getElementById(DivId).style.visibility = "visible";
		
			if (Width >= ThisLimit) {
			document.getElementById(DivId).style.left=((ThisLimit*(-1))-1)+"px";		
			document.getElementById(DivId).style.width=ThisLimit+"px";		
			LinkInfoBoxOpen = 1;
			LinkInfoBoxTimer = window.setTimeout("closeBoxInfo('linkInfoBox',300,0)",10000);
			} else {
			document.getElementById(DivId).style.left=((Width*(-1))-1)+"px";	
			document.getElementById(DivId).style.width=Width+"px";
			Width+=20;
			LinkInfoBoxTimer = window.setTimeout("expandBoxInfo('"+DivId+"',"+Width+","+ThisLimit+")",10);
			}/**/

			//alert(LinkInfoBoxOpen);
		
		}
		
		function closeFormBox() {
			
			if (clearForumPost == 0) {
				
				if (document.ForumPostForm) {
			
				if (document.ForumPostForm.Title) {
					tempForumSubject = document.ForumPostForm.Title.value;	
				}
				if (document.ForumPostForm.Content) {
					tempForumPost = document.ForumPostForm.Content.value;	
				}
				
				}
				
			} else {
				tempForumSubject = '';
				tempForumPost = '';
			}
			
			clearForumPost = 0;
			
			document.getElementById('formBox').style.visibility = "hidden";
			document.getElementById('formBoxContent').innerHTML = '&nbsp;';
			document.getElementById('formBoxContent').style.visibility = "hidden";
		}
		
		
		function moveGallery(direction,stopLoc) {
		
			//alert(document.getElementById('gallery').style.width);
		
			if ((direction == 0) && (galleryPos <= 0)) {
				galleryPos += 10;
				document.getElementById('gallery').style.left = galleryPos + "px";
				timeoutVar = window.setTimeout("moveGallery("+direction+","+stopLoc+")",50);
			} else if ((direction == 1) && (galleryPos >= (stopLoc+10))) {
				galleryPos -= 10;
				document.getElementById('gallery').style.left = galleryPos + "px";
				timeoutVar = window.setTimeout("moveGallery("+direction+","+stopLoc+")",50);
			}
		
		}
		
		function stopGallery() {
			window.clearTimeout(timeoutVar);
		}
			
		function closeBoxInfo(DivId,Width,ThisLimit) {
			
			//alert(LinkInfoBoxOpen);
			
			if ((LinkInfoBoxOpen == 1) && (AbortCloseBox == 0)) {
		
				window.clearTimeout(LinkInfoBoxTimer);
			
				if (Width <= ThisLimit) {
				document.getElementById(DivId).style.left=((ThisLimit*(-3))-1)+"px";		
				document.getElementById(DivId).style.width=ThisLimit+"px";		
				LinkInfoBoxOpen = 0;
				document.getElementById(DivId).style.visibility = "hidden";
				} else {
				//alert(Width);
				document.getElementById(DivId).style.left=((Width*(-1))-1)+"px";	
				document.getElementById(DivId).style.width=Width+"px";
				Width-=20;
				LinkInfoBoxTimer = window.setTimeout("closeBoxInfo('"+DivId+"',"+Width+","+ThisLimit+")",10);
				}
				
				CurrInfoBox = -1;
				
			}
		
		}
		
		function moveFeatCircle(endLeft,endTop,interval) {
			
			if (Math.abs(currCircleLeft - endLeft) < interval) {
				currCircleLeft = endLeft;
				moveFeatCircleVert(endTop,10);
			} else {
			
				if (currCircleLeft > endLeft) {
					currCircleLeft -= interval;
				} else {
					currCircleLeft += interval;
				}
				
				if (interval > 3) {
					interval--;
				}
				currCircleTimeout = window.setTimeout("moveFeatCircle("+endLeft+","+endTop+","+interval+")",10);
				
			}
			
			document.getElementById('featCircle').style.left = currCircleLeft + "px";
			
		}
		
		function moveFeatCircleVert(endTop,interval) {
			
			if (Math.abs(currCircleTop - endTop) < interval) {
				currCircleTop = endTop;
			} else {
			
				if (currCircleTop > endTop) {
					currCircleTop -= interval;
				} else {
					currCircleTop += interval;
				}
				
				if (interval > 3) {
					interval--;
				}
				currCircleTimeout = window.setTimeout("moveFeatCircleVert("+endTop+","+interval+")",10);
				
			}
			
			document.getElementById('featCircle').style.top = currCircleTop + "px";
			
		}
		
		function saveSubscribe() {
			
			clearTimeout(LinkInfoBoxTimer);
		
			var Email = document.getElementById('subscribeEmail').value;
			var Ip = document.getElementById('subscribeIp').value;
		
			if (!check_email(Email)) {
				document.getElementById('subscribeMessage').innerHTML = 'Invalid email, please try again.';
			} else {
				currDiv = 'subscribeMessage';
				sendAjax("functions.php?saveSubscribe=1&Email="+Email+"&Ip="+Ip,processAjax);
				document.getElementById('subscribeEmail').value = '';
			}
			
			expandSubscribeBox('subscribeBox',113,153);
			LinkInfoBoxTimer = window.setTimeout("closeSubscribeBox('subscribeBox',153,113)",8000);
			/*
			*/
		
		}
		
		function contentInsideSubscribeForm(Ip) {
		
			currDiv = 'contentInsideSocialSubscribe';
			sendAjax("functions.php?contentInsideSubscribeForm=1&Ip="+Ip,processAjax);
				
		}
		
		function saveSubscribeNew() {
		
			var Name = document.SubscribeHome.Name.value;
			var Email = document.SubscribeHome.Email.value;
			var Organisation = document.SubscribeHome.Organisation.value;
			var Ip = document.SubscribeHome.Ip.value;
		
			if (!check_email(Email)) {
				document.getElementById('SubscribeHomeError').innerHTML = 'Invalid email.';
				document.SubscribeHome.Email.style.color = "red";
			} else {
				currDiv = 'contentInsideSocialSubscribe';
				sendAjax("functions.php?saveSubscribeNew=1&Name="+Name+"&Email="+Email+"&Organisation="+Organisation+"&Ip="+Ip,processAjax);
			}
			
		}
			
		function expandSubscribeBox(DivId,Height,ThisLimit) {
		
			if (Height >= ThisLimit) {	
			document.getElementById(DivId).style.height=ThisLimit+"px";		
			} else {
			document.getElementById(DivId).style.height=Height+"px";
			Height+=10;
			LinkInfoBoxTimer = window.setTimeout("expandSubscribeBox('"+DivId+"',"+Height+","+ThisLimit+")",10);
			}
		
		}
		
		function closeSubscribeBox(DivId,Height,ThisLimit) {
		
			if (Height <= ThisLimit) {	
			document.getElementById(DivId).style.height=ThisLimit+"px";
			} else {
			//alert(Width);
			document.getElementById(DivId).style.height=Height+"px";
			Height-=10;
			LinkInfoBoxTimer = window.setTimeout("closeSubscribeBox('"+DivId+"',"+Height+","+ThisLimit+")",10);
			}
		
		}
		
		function changeTextsize(num) {
			
			if (!document.getElementById('textContent').style.fontSize) {
				document.getElementById('textContent').style.fontSize = "13px";	
			}
		
			currFontSize = (document.getElementById('textContent').style.fontSize.substr(0,(document.getElementById('textContent').style.fontSize.length-2)))*1;
			currLineHeight = (document.getElementById('textContent').style.lineHeight.substr(0,(document.getElementById('textContent').style.lineHeight.length-2)))*1;
			
			currFontSize += num;
		
			if ((currFontSize > 8) && (currFontSize < 17)) { 
		
			document.getElementById('textContent').style.fontSize = (currFontSize) + "px";
			document.getElementById('textContent').style.lineHeight = (currLineHeight+num) + "px";
			
			}
		
		}
		
		function loginFormBox(text,oclass,sendURL) {
			
			currDiv = 'loginFormBox';
			sendAjax("functions.php?loginFormBox=1&text="+text+"&class="+oclass+"&sendURL="+sendURL,processAjax);
			
		}
		
		function paperResults(Fields,CurrResults) {
			
			currDiv = 'paperResults';
			//alert(Fields);
			//alert("functions.php?setRating=1&TypeId="+TypeId+"&Id="+Id+"&Num="+Num+"&UserId="+UserId);
			sendAjax("functions.php?paperResults=1&Fields="+Fields+"&CurrResults="+CurrResults,processAjax);
			
		}
		
		function goToFeature() {
		
			currLink = document.getElementById('featureLink'+currFeat).value;
			//alert(currLink);
			document.location = currLink;
		
		}
		
		function partnerTabs(PartnerId,MemberId,TabId) {
			
			currDiv = 'partnerTabs';
			//alert(currDiv);
			sendAjax("functions.php?partnerTabs=1&PartnerId="+PartnerId+"&ThisMemberId="+MemberId+"&TabId="+TabId,processAjax);
			
		}
		
		function subscribeTop() {
			
			//document.getElementById('subscribeTopLink').style.backgroundColor='#80807f';
			document.getElementById('searchTopBox').style.visibility = "hidden";
			document.getElementById('subscribeTopBox').style.visibility = "visible";
			document.getElementById('subscribeTopLink').style.color = "#3399cc"
		}
		
		function searchTop() {
			
			//document.getElementById('subscribeTopLink').style.backgroundColor='#80807f';
			document.getElementById('subscribeTopBox').style.visibility = "hidden";
			document.getElementById('searchTopBox').style.visibility = "visible";
			
		}
		
		function closeSubscribe() {
			
			//document.getElementById('subscribeTopLink').style.backgroundColor='#80807f';
			document.getElementById('subscribeTopBox').style.height = "33px";
			document.getElementById('subscribeTopBox').style.visibility = "hidden";
			document.getElementById('subscribeMessage').innerHTML = "&nbsp;";
			
		}
		
		function closeSearch() {
			
			//document.getElementById('subscribeTopLink').style.backgroundColor='#80807f';
			document.getElementById('searchTopBox').style.visibility = "hidden";
			
		}
		
		function openEmailBox(DivId,Height,ThisLimit) {
		
			document.getElementById(DivId).style.visibility = 'visible';
		
			//alert(Height);
		
			if (Height >= ThisLimit) {	
			document.getElementById(DivId).style.height=ThisLimit+"px";		
			} else {
			document.getElementById(DivId).style.height=Height+"px";
			Height+=10;
			LinkInfoBoxTimer = window.setTimeout("openEmailBox('"+DivId+"',"+Height+","+ThisLimit+")",10);
			}
		
		}
		
		function closeEmailBox(DivId,Height,ThisLimit) {
		
			if (Height <= ThisLimit) {	
			document.getElementById(DivId).style.height=ThisLimit+"px";
			document.getElementById(DivId).style.visibility = 'hidden';
			} else {
			//alert(Width);
			document.getElementById(DivId).style.height=Height+"px";
			Height-=10;
			LinkInfoBoxTimer = window.setTimeout("closeEmailBox('"+DivId+"',"+Height+","+ThisLimit+")",10);
			}
		
		}
		
		function scrollList(divName,direction,limit) {
			
			if (scrolling == 1) {
				
				document.getElementById(divName).onselectstart = function () { return false; } // ie

				document.getElementById(divName).onmousedown = function () { return false; } // mozilla
	
				var newscrollingTop = scrollingTop + ((direction)*10);
				
				//alert(newscrollingTop+ ' ' +limit*(-1));
				
				if ((newscrollingTop >= (limit*(-1))) && (newscrollingTop <= 26)) {
					scrollingTop = newscrollingTop;
					document.getElementById(divName).style.top = scrollingTop + "px";
					window.setTimeout("scrollList('"+divName+"',"+direction+","+limit+")",50);
				}
			
			}
			
		}
		
		function viewGallery(GalleryId,ItemId) {
		
			getScrollOffset();
			document.body.scroll="no";
			//document.body.style.overflow="hidden";
			setWindowProps();
			currDiv = 'temp';
			document.getElementById(currDiv).style.top = tempY + "px";
			sendAjax("functions.php?viewGallery=1&GalleryId="+GalleryId+"&ItemId="+ItemId+"&Width="+winW+"&Height="+winH,processAjax);	
		
		}
		
		function viewGalleryItem(ItemId) {
			
			ImageTitle = document.getElementById('galleryImageTitle'+ItemId).value;
			ImageName = document.getElementById('galleryImageName'+ItemId).value;
			GalleryName = document.getElementById('galleryName').value;
			ImageOn = document.getElementById('galleryImageOn').value;
			
			document.getElementById('galleryContentThumb'+ImageOn).style.backgroundColor = 'transparent';
			
			document.getElementById('galleryImageOn').value = ItemId;
			document.getElementById('galleryContentThumb'+ItemId).style.backgroundColor = '#4997d2';
			
			document.getElementById('galleryContentImage').style.visibility = "hidden";
			document.getElementById('galleryContentTitleBox').style.visibility = "hidden";
			document.getElementById('galleryContentLoader').style.visibility = "visible";
			
			
			document.getElementById('galleryContentTitle').innerHTML = ImageTitle;
			document.getElementById('galleryContentImage').innerHTML = '<img src="'+root_link+'/images/galleries/'+GalleryName+'/400/'+ImageName+'" border="0" hspace="0" vspace="0" style="border: solid 0px #912422" onload="dispGalleryImage(this.height,this.width)"><br>';
			
			setVisit();
			
			//currDiv = 'galleryContentImage';
			//sendAjax("functions.php?viewGalleryItem=1&ItemId="+ItemId,processAjax);	
		
		}
		
		function dispGalleryImage(ImageHeight,ImageWidth) {
			
			BoxHeight = document.getElementById('galleryImageBoxHeight').value;
			BoxWidth = document.getElementById('galleryImageBoxWidth').value;
			//alert(Math.floor((BoxHeight-ImageHeight)/2));
			topOffset = Math.ceil((BoxHeight-ImageHeight)/2);
			leftOffset = Math.ceil((BoxWidth-ImageWidth)/2);
			document.getElementById('galleryContentImage').style.top = topOffset+"px";
			
			document.getElementById('galleryContentTitleBox').style.width = (ImageWidth)+"px";
			document.getElementById('galleryContentTitleBox').style.top = ((topOffset+ImageHeight)+2)+"px";
			document.getElementById('galleryContentTitleBox').style.left = (leftOffset)+"px";
			document.getElementById('galleryContentTitleBox').style.visibility = "visible";
			
			
			document.getElementById('galleryArrowLeft').style.left =  Math.ceil(leftOffset/2)+"px";
			document.getElementById('galleryArrowRight').style.right =  Math.ceil(leftOffset/2)+"px";

			window.setTimeout("document.getElementById('galleryContentImage').style.visibility='visible'",500);
			
		}
		
		function viewGalleryItemToggle(direction) {
		
			currItemCounter = document.getElementById('galleryItemCounter').value*1;
			itemCounterTotal = document.getElementById('galleryItemTotal').value*1;
		
			if (direction == 0) {
				
				if (currItemCounter == 1) {
					document.getElementById('galleryItemCounter').value = itemCounterTotal;
					nextItemCounter = itemCounterTotal;
				} else {
					nextItemCounter = currItemCounter - 1;
				}
				
			} else {
				
				if (currItemCounter == itemCounterTotal) {
					nextItemCounter = 1;
				} else {
					nextItemCounter = currItemCounter + 1;
				}
				
			}
		
			nextItem = document.getElementById('galleryItem'+nextItemCounter).value;
			
			document.getElementById('galleryItemCounter').value = nextItemCounter;
			
			viewGalleryItem(nextItem);
		
		}
		
		function closeGallery() {
			
			document.body.scroll="yes";
			document.body.style.overflow="auto";
			document.getElementById('temp').style.width = "10px";
			document.getElementById('temp').style.height = "10px";
			document.getElementById('temp').style.left = "0px";
			document.getElementById('temp').style.top = "0px";
			document.getElementById('temp').innerHTML = "";
			document.getElementById('temp').style.visibility = "hidden";
			
		}
		
		function sendPartnerRequest(PartnerId,MemberId,TypeId,ItemId) {
			
			currDiv = 'partnerTabContent';
			TabId = document.getElementById('currPartnerTab').value;
			//alert(document.getElementById('currPartnerTab'));
			//document.getElementById(currDiv).innerHTML = 'test';
			//alert("functions.php?partnerRequest=1&PartnerId="+PartnerId+"&MemberId="+MemberId+"&TabId="+TabId);
			sendAjax("functions.php?partnerRequest=1&PartnerId="+PartnerId+"&MemberId="+MemberId+"&TypeId="+TypeId+"&ItemId="+ItemId+"&TabId="+TabId,processAjax);			
			
		}
		
		function sendProductPartnerRequest(PartnerId,MemberId,TypeId,ItemId) {
			
			currDiv = 'productpartnerTabContent';
			
			//alert(document.getElementById('currPartnerTab'));
			//document.getElementById(currDiv).innerHTML = 'test';
			//alert("functions.php?partnerRequest=1&PartnerId="+PartnerId+"&MemberId="+MemberId+"&TabId="+TabId);
			sendAjax("functions.php?partnerRequest=1&PartnerId="+PartnerId+"&MemberId="+MemberId+"&TypeId="+TypeId+"&ItemId="+ItemId,processAjax);			
			
		}
		
		function displayMapArea(num) {
			
			clearTimeout(currTimeout);
			
			if (currRegion != num) {
			
				//alert(num);
			
				currRegion = num;
			
				getScrollOffset();
				
				//topOffset = Math.round((winH-60)/2) + tempY;
				topOffset = (tempMouseY-30);
				if ((num == 1) || (num == 2)) {
					leftOffset = (tempMouseX+10);
				} else {
					leftOffset = (tempMouseX-160);
				}
				
				//alert(document.getElementById('region'+num));
				
				document.getElementById('temp').innerHTML = document.getElementById('region'+num).innerHTML;
				document.getElementById('temp').style.top = topOffset + "px";
				document.getElementById('temp').style.left = leftOffset + "px";
				document.getElementById('temp').style.visibility = "visible";
			
			}
			
		}
		
		function hideMapArea() {
			
			currRegion = 0;
			
			document.getElementById('temp').innerHTML = "";
			document.getElementById('temp').style.top = "0px";
			document.getElementById('temp').style.left = "0px";
			document.getElementById('temp').style.visibility = "hidden";
			
		}
		
		function viewFAQItem(ItemId) {
		
			if (currItem != ItemId) {
			
				currItem = ItemId;
				
				//alert(document.getElementById('FAQItem'+currItem).style.overflow);
				
				document.getElementById('FAQItem'+currItem).style.height = "auto";
				
			} else {
				hideFAQItem(currItem);
				currItem = 0;
			}
		
		}
		
		function hideFAQItem(ItemId) {
			
			document.getElementById('FAQItem'+ItemId).style.height = "21px";
			
		}
		
		function viewBlogItem(ItemId) {
		
			if (currItem != ItemId) {
				if (currItem != 0) {
					hideBlogItem(currItem);
				}
				
				currItem = ItemId;
				
				
				document.getElementById('BlogItemText'+currItem).style.height = "540";
				document.getElementById('BlogItemText'+currItem).style.backgroundColor = "#efefef"; 
				document.getElementById('BlogItemText'+currItem).style.overflow = "auto"; 
				document.getElementById('BlogItem'+currItem).style.height = "620";
				document.getElementById('More'+currItem).innerHTML = '<img  valign="bottom" style="border: 0px;" src="'+root_link+'/images/main/closearrow.png" /> Close';
		} else {
				hideBlogItem(currItem);
				currItem = 0;
			}
		
		}
		
		function hideBlogItem(ItemId) {
			
			document.getElementById('BlogItem'+ItemId).style.height = "135px";
			document.getElementById('BlogItemText'+ItemId).style.height = "79px";
			document.getElementById('BlogItemText'+currItem).style.backgroundColor = "#ffffff"; 
			document.getElementById('BlogItemText'+currItem).style.overflow = "hidden"; 
			document.getElementById('More'+currItem).innerHTML = '<img  valign="bottom" style="border: 0px;" src="'+root_link+'/images/main/morearrow.png" /> Read More';
		}
		
		function hideSelect() {
		
			//alert(currSelect);
			if (currSelect != '') {
			
				var interval = 10;
				if (!IE) {
					interval = 5;
				}
			
				expandDiv(currSelect,currSelectStart,currSelectTop,interval,0,'top');
				currSelect = '';
				currSelectTop = 26;
			
			}
		
		}
		
		function dispSelect(dispTop,divName) {
			
			var interval = 10;
			if (!IE) {
				interval = 5;
			}
			
			if (currSelect != divName) {
				
				if (currSelect != '') {
					expandDiv(currSelect,currSelectStart,currSelectTop,interval,0,'top');
				}
				
				currSelect = divName;
				currSelectTop = dispTop*(-1);
				document.getElementById(divName+'Arrow').style.visibility = "hidden";
				expandDiv(currSelect,currSelectTop,currSelectStart,interval,1,'top');
			
			} else {
				expandDiv(currSelect,currSelectStart,currSelectTop,interval,0,'top');
				currSelect = '';
				currSelectTop = 26;
			}
			
		}
		
		function dispMapResults(dispLeft,divName) {
			
			var interval = 10;
			if (!IE) {
				interval = 2;
			}
			
			if (currMapResults != divName) {
				
				if (currMapResults != '') {
					expandDiv(currMapResults,currMapResultsStart,currMapResultsLeft,interval,0,'right');
				}
				
				currMapResults = divName;
				currMapResultsLeft = dispLeft*(-1);
				document.getElementById(divName+'Arrow').style.visibility = "hidden";
				expandDiv(currMapResults,currMapResultsLeft,currMapResultsStart,interval,1,'right');
			
			} else {
				expandDiv(currMapResults,currMapResultsStart,currMapResultsLeft,interval,0,'right');
				currMapResults = '';
				currMapResultsLeft = 26;
			}
			
		}
		
		function expandDiv(divName,currPos,endPos,interval,direction,type) {
						
			if (direction == 0) {
				
				if (currPos < endPos) {
					if (document.getElementById(divName+'Arrow')) {
						document.getElementById(divName+'Arrow').style.visibility = "visible";
					}
					eval("document.getElementById('"+divName+"').style."+type+"= '"+endPos+"px'");
					
				} else {
					eval("document.getElementById('"+divName+"').style."+type+"= '"+currPos+"px'");
					currPos -= 10;
					window.setTimeout("expandDiv('"+divName+"',"+currPos+","+endPos+","+interval+","+direction+",'"+type+"')",interval);
				}
				
			} else {
				
				if (currPos > endPos) {
					eval("document.getElementById('"+divName+"').style."+type+"= '"+endPos+"px'");	
					moveMapResults = 0;
				} else {
					eval("document.getElementById('"+divName+"').style."+type+"= '"+currPos+"px'");
					currPos += 10;
					window.setTimeout("expandDiv('"+divName+"',"+currPos+","+endPos+","+interval+","+direction+",'"+type+"')",interval);
					
					/*
					if (moveMapResults == 1) {
						// MOVING MAP
						var MapPos = document.getElementById('thisMapStartLeft').value*1;
						MapPos += 5;
						document.getElementById('thisMapStartLeft').value = MapPos;
						document.getElementById('mapContent').style.left = (MapPos*(-1));
						// MOVING MAP
					}
					*/
					
				}
				
			}
			
		}
		
		function disableSelect(divName) {
			
			if (document.getElementById(divName)) {
			document.getElementById(divName).onselectstart = function () { return false; } // ie
			document.getElementById(divName).style.MozUserSelect = "none";
			//document.getElementById(divName).onmousedown = function () { return false; } // mozilla
			}
			
		}
		
		function moveMap() {
		
			window.clearTimeout(cursorTimer);
		
			//changeCursor('dragging','-moz-dragging');
			
			//alert(document.body.style.cursor);
			
			var mapStartLeft = document.getElementById('thisMapStartLeft').value*1;
			var mapStartTop = document.getElementById('thisMapStartTop').value*1;
			
			if (currMoveMapLeft == -1) {
				currMoveMapLeft = tempMouseX*1;	
			}		
			if (currMoveMapTop == -1) {
				currMoveMapTop = tempMouseY*1;	
			}
			
			//alert(mapStartLeft + ' ' + currMoveMapLeft + ' ' + tempMouseX);
			//alert(mapStartTop + ' ' + currMoveMapTop + ' ' + tempMouseY);
			
			var offsetLeft = (mapStartLeft-((tempMouseX*1)-currMoveMapLeft))*1;
			var offsetTop = (mapStartTop-((tempMouseY*1)-currMoveMapTop))*1;
						
			document.getElementById('tempMouseX').value = tempMouseX;
			document.getElementById('tempMouseY').value = tempMouseY;
			
			if ((offsetTop >= mapImages[currMapZoom][6]) && (offsetTop <= (mapImages[currMapZoom][6]+(mapImages[currMapZoom][2]-425))) && (offsetLeft >= (mapImages[currMapZoom][5]-250)) && (offsetLeft <= (mapImages[currMapZoom][5]+(mapImages[currMapZoom][1]-600)))) {
			//if ((offsetTop >= mapImages[currMapZoom][6]) && (offsetTop <= (mapImages[currMapZoom][6]+(mapImages[currMapZoom][2]-425)))) {
				currMoveMapTop	= (tempMouseY*1);
				currMoveMapLeft	= (tempMouseX*1);			
				document.getElementById('mapContent').style.left = ((-1)*offsetLeft)+"px";
				document.getElementById('mapContent').style.top = ((-1)*offsetTop)+"px";
				document.getElementById('thisMapStartLeft').value = offsetLeft;
				document.getElementById('thisMapStartTop').value = offsetTop;
			}
			
			mapPosLeft = document.getElementById('currMapPosX').value;
			mapPosTop = document.getElementById('currMapPosY').value;
			
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			
			//cursorTimer = window.setTimeout("document.body.style.cursor = 'auto'",200);

			//return false;			
			
		}
		
		function changeCursor(nameIE,name) {
			if (IE) {
				document.body.style.cursor = 'url(\''+root_link+'/images/main/grab.cur\')';
			} else {
				document.body.style.cursor = 'url(\''+root_link+'/images/main/grab.cur\')';
				//alert(document.body.style.cursor+' '+nameIE+' '+name);
			}
		}
		
		function moveMapPosition(Direction,Offset) {
		
			clearTimeout(moveMapTimer);
			
			var offsetLeft = 0;
			var offsetTop = 0;
			
			var offsetLeft = document.getElementById('thisMapStartLeft').value*1;
			var offsetTop = document.getElementById('thisMapStartTop').value*1;
			
			var mapPosLeft = document.getElementById('currMapPosX').value*1;
			var mapPosTop = document.getElementById('currMapPosY').value*1;
			
			if (Direction == 0) {
				offsetLeft += Offset;
				mapPosLeft += Offset;
			} else {
				offsetTop += Offset;
				mapPosTop += Offset;
			}
			
			if (((Direction == 1) && (offsetTop >= mapImages[currMapZoom][6]) && (offsetTop <= (mapImages[currMapZoom][6]+(mapImages[currMapZoom][2]-425)))) || ((Direction == 0) && (offsetLeft >= (mapImages[currMapZoom][5]-250)) && (offsetLeft <= (mapImages[currMapZoom][5]+(mapImages[currMapZoom][1]-600))))) {
			
				//alert(1);
			
				document.getElementById('thisMapStartLeft').value = offsetLeft;
				document.getElementById('thisMapStartTop').value = offsetTop;
				
				document.getElementById('currMapPosX').value = mapPosLeft;
				document.getElementById('currMapPosY').value = mapPosTop;
				
				document.getElementById('mapContent').style.left = ((-1)*offsetLeft)+"px";
				document.getElementById('mapContent').style.top = ((-1)*offsetTop)+"px";
				
				setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
				setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom+1);
				
				if (Offset < 0) {
					Offset -= 2;
				} else {
					Offset += 2;
				}
				
				moveMapTimer = window.setTimeout("moveMapPosition("+Direction+","+Offset+")",10);
			
			}
			
		}
		
		function scrollDirectoryResults() {
		
			//document.body.style.cursor = 'default';
			
			if (currScrollMouse == -1) {
				currScrollMouse = tempMouseY;	
			}
			
			var resultsListHeight = document.getElementById('resultsListHeight').value*1;
			
			var scrollBarStart = document.getElementById('scrollBarStart').value*1;
			var scrollBarEnd = document.getElementById('scrollBarEnd').value*1;
			
			resultsListHeight -= scrollBarEnd;
			
			var ratio = resultsListHeight/scrollBarEnd;
			
			var offsetMove = tempMouseY-currScrollMouse;
			
			var offsetList = (Math.round(offsetMove*ratio))*(-1);
			
			//document.getElementById('scrollMouse').value = tempMouseY;
			//document.getElementById('scrollOffset').value = currScrollMouse;
			
			//alert(offsetMove);
			
			currScrollOffset = offsetMove;
			
			if (currScrollOffset < scrollBarStart) {
				currScrollOffset = scrollBarStart;
				offsetList = scrollBarStart;
			} else if (currScrollOffset > scrollBarEnd) {
				currScrollOffset = scrollBarEnd;
				offsetList = (Math.round(scrollBarEnd*ratio))*(-1);
			}
			
			document.getElementById('scrollResults').style.top = currScrollOffset+"px";
			document.getElementById('resultsList').style.top = offsetList+"px";
			
			return false;
			
			
			
			//document.body.style.cursor = 'default';
		
		}
		
		function setScrollDirectoryResults() {
			
			if (currScrollMouse == -1) {
				currScrollMouse = tempMouseY;	
			}
			
			var resultsListHeight = document.getElementById('resultsListHeight').value*1;
			
			var scrollBarStart = document.getElementById('scrollBarStart').value*1;
			var scrollBarEnd = document.getElementById('scrollBarEnd').value*1;
			
			resultsListHeight -= scrollBarEnd;
			
			var ratio = resultsListHeight/scrollBarEnd;
			
			var offsetMove = tempMouseY-currScrollMouse;
			
			var offsetList = (Math.round(offsetMove*ratio))*(-1);
			
			//document.getElementById('scrollMouse').value = tempMouseY;
			//document.getElementById('scrollOffset').value = currScrollMouse;
			
			//alert(offsetMove);
			
			currScrollOffset = offsetMove;
			
			if (currScrollOffset < scrollBarStart) {
				currScrollOffset = scrollBarStart;
				offsetList = scrollBarStart;
			} else if (currScrollOffset > scrollBarEnd) {
				currScrollOffset = scrollBarEnd;
				offsetList = (Math.round(scrollBarEnd*ratio))*(-1);
			}
			
			document.getElementById('scrollResults').style.top = currScrollOffset+"px";
			document.getElementById('resultsList').style.top = offsetList+"px";
			
			return false;
			
		}
		
		function listingPartners(PackageId,topOffset) {
			PackageId = 1;
			
			document.getElementById('listingsNav'+currListing).className = 'listingsNav';
			document.getElementById('listingsNav'+PackageId).className = 'listingsNavOn';
			document.getElementById('listingsNavBox').style.top = topOffset+'px';
			currListing = PackageId;
			if (currListingTop < topOffset) {
				moveListingNav('listingsNavBox',(topOffset-1),0);
			} else {
				//document.getElementById('listingsNavBox').style.top = (topOffset-1)+'px';
				//currListingTop = (topOffset-1);
				moveListingNav('listingsNavBox',topOffset,1);
			}
			
			noLoading = 1;
			
			setListingHeight(455);
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.test.php?directoryListingPartnersList=1&PackageId="+PackageId+"&currResults=0",processAjax);			
			
		}
		
		function directoryListingPartners(PackageId) {
			
			noLoading = 1;
			
			//alert(PackageId);
		
			setListingHeight(455);
			
			currDiv = 'directoryListingInfo';
			sendAjax("functions.php?directoryListingPartners=1",processAjax);			
			
		}
		
		function listingPartnersReset(PackageId,topOffset) {

			
			noLoading = 1;
			
			setListingHeight(455);
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.php?directoryListingPartnersList=1&PackageId="+PackageId+"&currResults=0",processAjax);			
			
		}
		
		function directoryListingCompanyTab(CompanyId,TabNum,topOffset) {
		
			clearTimeout(companyBlurbTimeout);
			
			if (document.getElementById('companyNav'+currListing)) {
			document.getElementById('companyNav'+currListing).className = 'listingsNav';
			}
			document.getElementById('companyNav'+TabNum).className = 'listingsNavOn';
			document.getElementById('companyNavBox').style.top = topOffset+'px';
			currListing = TabNum;
			if (currListingTop < topOffset) {
				moveListingNav('companyNavBox',(topOffset-1),0);
			} else {
				//document.getElementById('listingsNavBox').style.top = (topOffset-1)+'px';
				//currListingTop = (topOffset-1);
				moveListingNav('companyNavBox',topOffset,1);
			}
			
			noLoading = 1;
			
			setListingHeight(455);			
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.php?directoryListingCompanyContent=1&TabNum="+TabNum+"&CompanyId="+CompanyId,processAjax);			
					
		}
		
		function directoryNewsResults(CompanyId,CurrResults) {
			
			setListingHeight(455);
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.php?directoryNewsResults=1&CurrResults="+CurrResults+"&CompanyId="+CompanyId,processAjax);			
					
		}
		
		function directoryListingCompanyRequest(PartnerId) {
			
			setListingHeight(455);
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.php?partnerRequest=1&MemberId=0&TypeId=1&ItemId=0&TabId=0&PartnerId="+PartnerId,processAjax);			
					
		}
		
		function directoryListingCompanyRequestContact(ContactId,MemberId) {
			
			setListingHeight(455);
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.php?directoryListingCompanyRequestContact=1&MemberId="+MemberId+"&ContactId="+ContactId,processAjax);			
					
		}
		
		function directoryListingCompanyJoin(CompanyId) {
			
			setListingHeight(595);
			
			currDiv = 'directoryListingContent';
			sendAjax("functions.php?directoryListingCompanyJoin=1&CompanyId="+CompanyId,processAjax);			
					
		}
		
		function nl2br(text){
			
			text = escape(text);
			
			var re_nlchar = /\r/g ;
			
			if (text.indexOf('%0D%0A') > -1) {
				re_nlchar = /%0D%0A/g ;
			} else if (text.indexOf('%0A') > -1) {
				re_nlchar = /%0A/g ;
			} else if (text.indexOf('%0D') > -1) {
				re_nlchar = /%0D/g ;
			}
			
			return unescape(text.replace(re_nlchar,'<br />'));
			
		}
		
		function saveCompanyJoin() {
			
			var CompanyId = trim(document.DirectoryJoinRequest.CompanyId.value);
			var FirstName = trim(document.DirectoryJoinRequest.FirstName.value);
			var LastName = trim(document.DirectoryJoinRequest.LastName.value);
			var Telephone = trim(document.DirectoryJoinRequest.Telephone.value);
			var Fax = trim(document.DirectoryJoinRequest.Fax.value);
			var Position = trim(document.DirectoryJoinRequest.Position.value);
			var Department = trim(document.DirectoryJoinRequest.Department.value);
			var City = trim(document.DirectoryJoinRequest.City.value);
			var PostalCode = trim(document.DirectoryJoinRequest.PostalCode.value);
			var Email = trim(document.DirectoryJoinRequest.Email.value);
			var Description = nl2br(trim(document.DirectoryJoinRequest.Description.value));
			
			var submitOk = 1;
			
			document.getElementById('DescriptionHeader').style.color = "#231F20";
			
			if (verifyWordCount(Description,900) == 1) {
				document.getElementById('DescriptionHeader').style.color = "red";
				submitOk = 0;
			}
			if (FirstName == '') {
				submitOk = 0;
			}
			if (LastName == '') {
				submitOk = 0;
			}
			if (Telephone == '') {
				submitOk = 0;
			}
			if (Fax == '') {
				submitOk = 0;
			}
			if (Position == '') {
				submitOk = 0;
			}
			if (Department == '') {
				submitOk = 0;
			}
			if (City == '') {
				submitOk = 0;
			}
			if (PostalCode == '') {
				submitOk = 0;
			}
			if (!check_email(Email) || (Email == '')) {
				submitOk = 0;
			}
			if (Description == '') {
				submitOk = 0;
			}
			
			if (submitOk == 0) {
				
				setListingHeight(605);
			
				var formErrors = 'Please fill in all the fields below<div style="padding-top: 5px; color: red; font-weight: bold; font-style: italic;">';
				formErrors += 'Please make sure all fields are complete in order to continue';
				formErrors += '</div>';
				document.getElementById('formErrorsDiv').innerHTML = formErrors;
					
			} else {
				
				setListingHeight(455);
			
				Description = Description.split('&').join('-||-');
				
				//alert("functions.php?directoryListingCompanyJoinSave=1&CompanyId="+CompanyId+"&FirstName="+FirstName+"&LastName="+LastName+"&Telephone="+Telephone+"&Fax="+Fax+"&Position="+Position+"&Department="+Department+"&City="+City+"&PostalCode="+PostalCode+"&Email="+Email+"&Description="+Description);
				//alert(currLib);
				
				currDiv = 'directoryListingContent';
				sendAjax("functions.php?directoryListingCompanyJoinSave=1&CompanyId="+CompanyId+"&FirstName="+FirstName+"&LastName="+LastName+"&Telephone="+Telephone+"&Fax="+Fax+"&Position="+Position+"&Department="+Department+"&City="+City+"&PostalCode="+PostalCode+"&Email="+Email+"&Description="+Description,processAjax);			
					
			}
			
		}
		
		function directoryListingCompany(CompanyId) {
			
			var CompanyPos = 0;
			
			if (document.getElementById('CompanyResultsList')) {
				var CompaniesList = document.getElementById('CompanyResultsList').value;
				CompanyPos = CompaniesList.indexOf('-'+CompanyId+'-');
			}
			
			if (CompanyPos != -1) {
			
				ajaxFunction[ajaxFunctionCounter] = "setVisit()";
				ajaxFunctionCounter++;
			
				if (directoryStartCompanyAnchor == 1) {
					document.location = "#directoryListingInfoAnchor";
				}
				
				directoryStartCompanyAnchor = 1;
				
				noLoading = 1;
				//alert(CompanyId);
				
				currListing = 1;
				
				setListingHeight(455);
			
				currDiv = 'directoryListingInfo';
				document.getElementById(currDiv).innerHTML = '';
				window.setTimeout('sendAjax("functions.php?directoryListingCompany=1&CompanyId='+CompanyId+'",processAjax)',200);			
					
			} else {
				setVisit();
			}
					
		}
		
		function directoryListingCompanyTemp(CompanyId) {
			
			var CompanyPos = 0;
			
			document.location = "#directoryListingInfoAnchor";
			
			noLoading = 1;
			//alert(CompanyId);
			
			currListing = 1;
			
			setListingHeight(455);
			
			currDiv = 'directoryListingInfo';
			document.getElementById(currDiv).innerHTML = '';
			window.setTimeout('sendAjax("functions.php?directoryListingCompany=1&CompanyId='+CompanyId+'",processAjax)',200);			
				
					
		}
		
		function moveListingNav(divName,limit,direction) {
			
			clearTimeout(currTimeout);
			
			if (direction == 0) {
				if (currListingTop > limit) {
					document.getElementById(divName).style.top = limit+'px';
				} else {
					document.getElementById(divName).style.top = currListingTop+'px';
					currListingTop += 8;
					currTimeout = window.setTimeout("moveListingNav('"+divName+"',"+limit+","+direction+")",20);
				}
			} else {
				if (currListingTop < limit) {
					document.getElementById(divName).style.top = limit+'px';
				} else {
					document.getElementById(divName).style.top = currListingTop+'px';
					currListingTop -= 8;
					currTimeout = window.setTimeout("moveListingNav('"+divName+"',"+limit+","+direction+")",20);
				}
			}
			
		}
		
		function countryDisp(MappedId,ratio) {
			
			if (currMapped != MappedId) {
				if (currMapped != 0) {
					document.getElementById('CountryPartMain'+currMapped).style.visibility = 'hidden';
				}
				document.getElementById('CountryPartMain'+MappedId).style.visibility = 'visible';
			} 
			
			currMapped = MappedId;
			
			//alert('url(\''+root_link+'/draw.image.php?Id='+MappedId+'&Zoom='+ratio+'&Color=1\')');
			
		}
		
		function countryHide(MappedId,ratio) {
			document.getElementById('CountryPartMain'+MappedId).style.visibility = 'hidden';
			
			currMapped = 0;
		}
		
		function mapCoord(MappedId) {
			
			setWindowProps();
			
			var topOffset = directoryTopOffset;
			var leftOffset = (winW-900)/2;
			
			/*
			if (((tempMouseX > leftOffset) && (tempMouseX <= (leftOffset+900))) && ((tempMouseY > topOffset) && (tempMouseY <= (topOffset+450)))) {
				ajaxFunction[ajaxFunctionCounter] = 'companyBlurbLocate()';			
				ajaxFunctionCounter++;
			}
			*/
			
			topOffset = tempMouseY-directoryTopOffset;
			leftOffset = tempMouseX-leftOffset;
			
			var thisMapOffsetLeft = document.getElementById('thisMapOffsetLeft').value*1;
			var thisMapOffsetTop = document.getElementById('thisMapOffsetTop').value*1;
			var thisMapStartLeft = document.getElementById('thisMapStartLeft').value*1;
			var thisMapStartTop = document.getElementById('thisMapStartTop').value*1;
			
			var leftDiff = thisMapStartLeft - thisMapOffsetLeft;
			var topDiff = thisMapStartTop - thisMapOffsetTop;
			
			var mapPosLeft = (thisMapOffsetLeft+leftOffset+leftDiff)-mapImages[currMapZoom][5];
			var mapPosTop = (thisMapOffsetTop+topOffset+topDiff)-mapImages[currMapZoom][6];
			
			document.getElementById('currMapPosX').value = mapPosLeft;
			document.getElementById('currMapPosY').value = mapPosTop;
			
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom+1);
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			
			/*
			var width	= 0;
			var height	= 400;
			var start = 1;
			
			var thisHeight = 400;
			var thisWidth = 400;
			
			var Zoom = ratio+1;
			
			if (Zoom == 4) {
				Zoom =	2;
			}
			
			for (i = 1; i <= mapImages[Zoom][4]; i++) {
				
				thisWidth = 400;
				
				if ((width == 0) && (start == 0)) {
					
					if ((height+thisHeight) > mapImages[Zoom][2]) {
						thisHeight	= mapImages[Zoom][2]-height;
					}
					height += thisHeight;
					
				}
				
				if ((width+thisWidth) > mapImages[Zoom][1]) {
					thisWidth	= mapImages[Zoom][1]-width;
					width		= 0;
				} else {
					width += thisWidth;
				}
				
				thisId = 'Map_'+Zoom+'_'+i;
				//background-image: url(\''.mainRoot.'/images/directory/'.mapImages[Zoom][3].'/'.mapImages[Zoom][0].'_'.imageNum.'.png\')">';
				start = 0;
			
			}
			*/		
			
		}


		/*
			*/
		function setMapImage(leftPos,topPos,zoom1,zoom2) {
			
			if (zoom2 == 4) {
				zoom2 = 3;
			}
			
			//alert(1);
			
			leftPos		= (leftPos*mapImages[zoom1][7]) / mapImages[zoom2][7];
			topPos		= (topPos*mapImages[zoom1][7]) / mapImages[zoom2][7];
			
			var horizontalCount = Math.ceil(mapImages[zoom2][1]/400);
			//var verticalCount = Math.ceil(mapImages[currMapZoom][2]/400);
			
			var locationLeft = Math.ceil(leftPos/400);
			var locationTop = Math.floor(topPos/400);
			
			var locationCount = (horizontalCount*locationTop)+locationLeft;
			
			//var locationPoint = (horizontalCount*locationTop).toString()+locationLeft.toString();
			
			var locationPoint = '';
			
			if (locationCount < 10) {
				locationPoint = '0'+locationCount.toString();	
			} else {
				locationPoint = locationCount.toString();
			}
				
			document.getElementById('LocationCounter').value = locationPoint;
			
			var mapSides = new Array();
			
			mapSides[0] = locationCount-(horizontalCount+1);
			mapSides[1] = locationCount-(horizontalCount);
			mapSides[2] = locationCount-(horizontalCount-1);
			mapSides[3] = locationCount-1;
			mapSides[4] = locationCount;
			mapSides[5] = locationCount+1;
			mapSides[6] = locationCount+(horizontalCount-1);
			mapSides[7] = locationCount+(horizontalCount);
			mapSides[8] = locationCount+(horizontalCount+1);
			
			for (i = 0; i < 9; i++) {
			
				if (mapSides[i] < 10) {
					locationPoint = '0'+mapSides[i].toString();	
				} else {
					locationPoint = mapSides[i].toString();
				}
				
				if (document.getElementById('mapImage_'+zoom2+'_'+mapSides[i])) {
				
					if (mapImagesBg[zoom2][(mapSides[i]-1)] != 1) {
						//alert('url(\''+root_link+'/images/directory/'+mapImages[thisZoom][3]+'/'+mapImages[thisZoom][0]+'_'+locationPoint+'.png\')');
						//document.getElementById('mapImage_'+zoom2+'_'+mapSides[i]).style.backgroundImage = 'url(\''+root_link+'/images/directory/'+mapImages[zoom2][3]+'/'+mapImages[zoom2][0]+'_'+locationPoint+'.png\')';
						document.getElementById('mapImage_'+zoom2+'_'+mapSides[i]).innerHTML = '<img src="'+root_link+'/images/directory/'+mapImages[zoom2][3]+'/'+mapImages[zoom2][0]+'_'+locationPoint+'.png"><br>';
						mapImagesBg[zoom2][(mapSides[i]-1)] = 1;
					}
					
				}
				
			}
			
		}	
		
		function zoomMap(CountryId,Type,zoomLevel) {
			
			document.getElementById('directoryMapLoader').style.visibility = 'visible';
			document.getElementById('mapContentZoom'+currMapZoom).style.visibility = "hidden";
			//document.getElementById('mapContentCities'+currMapZoom).style.visibility = "hidden";
			//document.getElementById('mapContentCompanies'+currMapZoom).style.visibility = "hidden";
			
			//alert(document.getElementById('mapContentZoom'+currMapZoom).style.visibility+' '+currMapZoom);
			
			/*
			for (i = 0; i < 4; i++) {		
				document.getElementById('mapContentCompaniesPos'+i).style.visibility = 'hidden';
				document.getElementById('mapContentCitiesPos'+i).style.visibility = 'hidden';
			}
			*/
			
			companyBlurbHide();
			
			if (zoomLevel >= 4) {
				zoomLevel = 3;	
			} else if (zoomLevel <= -1) {
				zoomLevel = 0;	
			}
			
			if (zoomLevel == 0) {
				Type = 3;	
			}
			
			if (Type == 3) {
				//var currMapPosX = document.getElementById('thisMapStartLeft').value;
				//var currMapPosY = document.getElementById('thisMapStartTop').value;
				var thisMapStartLeft = document.getElementById('thisMapStartLeft').value;
				var thisMapStartTop = document.getElementById('thisMapStartTop').value;
				
				var currMapPosX = (4300/mapImages[currMapZoom][7]);
				var currMapPosY = (2100/mapImages[currMapZoom][7]);
				
				thisMapStartLeft = Math.round((thisMapStartLeft*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
				thisMapStartTop = Math.round((thisMapStartTop*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
				
			} else if (Type == 5) {
				
				var currMapPosX = (4300/mapImages[zoomLevel][7])-430;
				var currMapPosY = (2100/mapImages[zoomLevel][7])-210;
				
				var currMapPosX = document.getElementById('currMapPosX').value;
				var currMapPosY = document.getElementById('currMapPosY').value;
				
				var thisMapStartLeft = document.getElementById('thisMapStartLeft').value*1;
				var thisMapStartTop = document.getElementById('thisMapStartTop').value*1;
								
				thisMapStartLeft = Math.round((((thisMapStartLeft+430)-mapImages[currMapZoom][5])*mapImages[currMapZoom][7])/mapImages[zoomLevel][7])+mapImages[zoomLevel][5]-430;
				thisMapStartTop = Math.round((((thisMapStartTop+210)-mapImages[currMapZoom][6])*mapImages[currMapZoom][7])/mapImages[zoomLevel][7])+mapImages[zoomLevel][6]-210;
				
				//alert(thisMapStartLeft + " " + thisMapStartTop);
				
			} else {
				
				var currMapPosX = document.getElementById('currMapPosX').value;
				var currMapPosY = document.getElementById('currMapPosY').value;
				
				var thisMapStartLeft = document.getElementById('thisMapStartLeft').value;
				var thisMapStartTop = document.getElementById('thisMapStartTop').value;
				
				thisMapStartLeft = Math.round((thisMapStartLeft*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
				thisMapStartTop = Math.round((thisMapStartTop*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
				
			}
			
			document.getElementById('currMapPosX').value = Math.round((currMapPosX*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
			document.getElementById('currMapPosY').value = Math.round((currMapPosY*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
			
			prevMapZoom = currMapZoom;
			currMapZoom = zoomLevel;
			
			if (Type == 4) {
				centerMapPos(currCountryLeft,currCountryTop);
			} else if (Type == 5) {
				centerMapPosNew(thisMapStartLeft,thisMapStartTop);
			} else if (Type != 2) {
				centerMap(Type);
			} else {
				//centerMap(Type);
				centerMapPos(0,0);
				//alert(thisMapStartLeft+","+thisMapStartTop);
				//centerMapPosNew(thisMapStartLeft,thisMapStartTop);
				//centerMapAbs(currMapPosX,currMapPosY);
			}
			
			//populateMap();
			
			document.getElementById('mapContentZoom'+currMapZoom).style.visibility = "visible";
			//document.getElementById('mapContentCities'+currMapZoom).style.visibility = "visible";
			//document.getElementById('mapContentCompanies'+currMapZoom).style.visibility = "visible";
			
			//alert(document.getElementById('worldMap').useMap);
		
			document.getElementById('worldMap').useMap = "#worldMap"+(currMapZoom);
			
			//document.getElementById('worldMap').useMap = "#worldMap"+(currMapZoom+1);
			//alert(document.getElementById('worldMap').useMap);
			
			//document.getElementById('directoryMapLoader').style.visibility = 'visible';
			
			for (i = 0; i < 4; i++) {
			
				if (i <= currMapZoom) {
					document.getElementById('zoomLevel'+(i+1)+'Off').style.visibility = "hidden";
				} else {
					document.getElementById('zoomLevel'+(i+1)+'Off').style.visibility = "visible";
				}
			
			}
			
		}
		
		function centerMapPosNew(PositionLeft,PositionTop) {
		
			setMapImage(((PositionLeft-mapImages[currMapZoom][5])+430),((PositionTop-mapImages[currMapZoom][6])+210),currMapZoom,currMapZoom);
			
			document.getElementById('mapContent').style.left = ((-1)*PositionLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*PositionTop)+"px";	
			
			document.getElementById('thisMapStartLeft').value = PositionLeft;
			document.getElementById('thisMapStartTop').value = PositionTop;
			
			window.setTimeout("directoryMapResultsContent()",500);
		
		}
		
		function centerMapPos(PositionLeft,PositionTop) {
			
			var mapPosLeft = (mapImages[currMapZoom][5]+(PositionLeft*1));
			var mapPosTop = (mapImages[currMapZoom][6]+(PositionTop*1));
		
			//if (Type == 0) {
			//	mapPosLeft -= 450;
			//	mapPosTop -= 212;
			//}
		
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			
			document.getElementById('mapContent').style.left = ((-1)*mapPosLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*mapPosTop)+"px";	
			
			document.getElementById('thisMapStartLeft').value = mapPosLeft;
			document.getElementById('thisMapStartTop').value = mapPosTop;
			
			window.setTimeout("directoryMapResultsContent()",500);
		
		}
		
		function centerMap(Type) {
			
			var mapPosLeft = (mapImages[currMapZoom][5]+(document.getElementById('currMapPosX').value*1));
			var mapPosTop = (mapImages[currMapZoom][6]+(document.getElementById('currMapPosY').value*1));
					
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			
			if ((mapPosLeft != mapImages[currMapZoom][5]) && (mapPosTop != mapImages[currMapZoom][6])) {
			mapPosLeft -= 450;
			mapPosTop -= 212;
			}
		
			document.getElementById('mapContent').style.left = ((-1)*mapPosLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*mapPosTop)+"px";	
			
			document.getElementById('thisMapStartLeft').value = mapPosLeft;
			document.getElementById('thisMapStartTop').value = mapPosTop;
			
			window.setTimeout("directoryMapResultsContent()",500);
		
		}
		
		function centerMapAbs(PositionLeft,PositionTop) {
			
			var currMapPosX = (4300/mapImages[currMapZoom][7]);
			var currMapPosY = (2100/mapImages[currMapZoom][7]);
			
			document.getElementById('currMapPosX').value = currMapPosX;
			document.getElementById('currMapPosY').value = currMapPosY;
			
			
			var mapPosLeft = (mapImages[currMapZoom][5]+(document.getElementById('currMapPosX').value*1));
			var mapPosTop = (mapImages[currMapZoom][6]+(document.getElementById('currMapPosY').value*1));
					
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			
			if ((mapPosLeft != mapImages[currMapZoom][5]) && (mapPosTop != mapImages[currMapZoom][6])) {
			mapPosLeft -= 450;
			mapPosTop -= 212;
			}
		
			document.getElementById('mapContent').style.left = ((-1)*mapPosLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*mapPosTop)+"px";	
			
			document.getElementById('thisMapStartLeft').value = mapPosLeft;
			document.getElementById('thisMapStartTop').value = mapPosTop;
			
			/*
			
			if (Type == 3) {
				var currMapPosX = (4300/mapImages[currMapZoom][7]);
				var currMapPosY = (2100/mapImages[currMapZoom][7]);
			} else {
				var currMapPosX = document.getElementById('currMapPosX').value;
				var currMapPosY = document.getElementById('currMapPosY').value;
			}
			
			document.getElementById('currMapPosX').value = Math.round((currMapPosX*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
			document.getElementById('currMapPosY').value = Math.round((currMapPosY*mapImages[currMapZoom][7])/mapImages[zoomLevel][7]);
			
			
			if (currMapZoom == 0) {
			var mapPosLeft = mapImages[currMapZoom][5];
			var mapPosTop = mapImages[currMapZoom][6];
			} else {
			var mapPosLeft = mapImages[currMapZoom][5]+(Math.round(mapImages[currMapZoom][1]/2)-450);
			var mapPosTop = mapImages[currMapZoom][6]+(Math.round(mapImages[currMapZoom][2]/2)-350);
			}
		
			//if (Type == 0) {
			//	mapPosLeft -= 450;
			//	mapPosTop -= 212;
			//}
		
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			
			document.getElementById('mapContent').style.left = ((-1)*mapPosLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*mapPosTop)+"px";	
			
			document.getElementById('thisMapStartLeft').value = mapPosLeft;
			document.getElementById('thisMapStartTop').value = mapPosTop;
			*/
			
		}
		
		function centerMapPosMover(PositionLeft,PositionTop) {
			
			var mapPosLeft = (mapImages[currMapZoom][5]+(PositionLeft*1));
			var mapPosTop = (mapImages[currMapZoom][6]+(PositionTop*1));
		
			//if (Type == 0) {
			//	mapPosLeft -= 450;
			//	mapPosTop -= 212;
			//}
		
			document.getElementById('mapContent').style.left = ((-1)*mapPosLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*mapPosTop)+"px";	
			
			document.getElementById('thisMapStartLeft').value = mapPosLeft;
			document.getElementById('thisMapStartTop').value = mapPosTop;
			
			directoryMapResultsContent();
		
		}
		
		function populateMap() {
			
			for (i = 1; i <= mapImages[currMapZoom][4]; i++) {
			
				if (i < 10) {
					locationPoint = '0'+i.toString();	
				} else {
					locationPoint = i.toString();
				}
				
				//alert(locationPoint);
				
				if (document.getElementById('mapImage_'+currMapZoom+'_'+i)) {
					
					//alert(document.getElementById('mapImage_'+currMapZoom+'_'+locationPoint).style.backgroundImage);
				
					if (mapImagesBg[currMapZoom][i] != 1) {
						//alert('url(\''+root_link+'/images/directory/'+mapImages[thisZoom][3]+'/'+mapImages[thisZoom][0]+'_'+locationPoint+'.png\')');
						//document.getElementById('mapImage_'+currMapZoom+'_'+i).style.backgroundImage = 'url(\''+root_link+'/images/directory/'+mapImages[currMapZoom][3]+'/'+mapImages[currMapZoom][0]+'_'+locationPoint+'.png\')';
						document.getElementById('mapImage_'+currMapZoom+'_'+mapSides[i]).innerHTML = '<img src="'+root_link+'/images/directory/'+mapImages[currMapZoom][3]+'/'+mapImages[currMapZoom][0]+'_'+locationPoint+'.png"><br>';
						mapImagesBg[currMapZoom][i] = 1;
					}
					
				}
				
			}
			
		
		}
		
		function companyBlurbLocate() {
			
			var PositionLeft = document.getElementById('currMapPosX').value;
			var PositionTop = document.getElementById('currMapPosY').value;
			
			//alert(PositionLeft);
			
			var sendFields = '';
					
			for (i = 0; i < (fieldsCounter-2); i++) {
			
				sendFields += '&'+mapFields[i][0]+'='+mapFields[i][1];
			
			}
			
			//alert(sendFields);
			
			if (IE) {
				PositionLeft -= 10;
			}
			
			currDiv = 'temp';
			sendAjax("functions.php?companyBlurbLocate=1&PositionLeft="+PositionLeft+"&PositionTop="+PositionTop+"&Zoom="+currMapZoom+sendFields,processCompanyBlurb);			
	
			//alert(currMapPosX+' '+currMapPosY);
			
		}
		
		function processCompanyBlurb() {
			
			var thisFunction = '';
		
			if(request.readyState == 4) {
				
				if(request.status == 200) {
				
					if((document.getElementById(currDiv)) && (trim(request.responseText) != '')) {
						
						var responseContent = trim(request.responseText);
						
						//alert(responseContent);
						
						if (responseContent != '0') {
							
							var responseArray = new Array();
							responseArray = responseContent.split(',');
						
							//alert(document.getElementById('CompanyResultsList').value+' -- '+responseArray[0]);
						
							window.setTimeout("companyBlurb("+responseArray[1]+","+responseArray[2]+","+responseArray[0]+",0)",100);
							
						}
						
						if (ajaxFunctionCounter > 0) {
							ajaxFunctionCounter--;
							thisFunction = ajaxFunction[ajaxFunctionCounter];
							ajaxFunction[ajaxFunctionCounter] = '';
							eval(thisFunction);
						}
						
						if (secondaryFunction != '') {
							thisFunction = secondaryFunction;
							secondaryFunction = '';
							eval(thisFunction);
						}
						
						if (currAnchor != '') {
							document.location.href = currAnchor;
							currAnchor = '';
						}
						
						tempContent = '';
						loadedContent = 1;
						noLoading = 0;
						
					}
					
				}
				
			}
		
		}
		
		function companyBlurb(PositionLeft,PositionTop,CompanyId,Center) {
				
			//clearTimeout(companyBlurbTimeout);
			
			//alert(PositionLeft+' - '+PositionTop);var CompanyPos = 0;
			
			var MoveLeft = 0;
			var MoveTop = 0;
			var newPosLeft = 0;
			var newPosTop = 0;
			
			if (document.getElementById('CompanyResultsList')) {
				var CompaniesList = document.getElementById('CompanyResultsList').value;
				CompanyPos = CompaniesList.indexOf('-'+CompanyId+'-');
			}
			
			if (CompanyPos != -1) {
			
				PositionLeft = mapImages[currMapZoom][5]+Math.round(PositionLeft/mapImages[currMapZoom][7]);
				PositionTop = mapImages[currMapZoom][6]+Math.round(PositionTop/mapImages[currMapZoom][7]);
				
				tempPosStartLeft = (document.getElementById('thisMapStartLeft').value*1);
				tempPosStartTop = (document.getElementById('thisMapStartTop').value*1);
				
				//tempPosStartTop += 50;
				
				if ((document.getElementById('resultsDisp').style.right != '0px') || (document.getElementById('resultsDisp').style.right == '')) {
					var LeftVerify = 650;	
				} else {
					var LeftVerify = 350;
				}
				
				if ((PositionLeft < (tempPosStartLeft+50))) {
					MoveLeft = Math.round((PositionLeft-(tempPosStartLeft+50))/10);
					newPosLeft = PositionLeft;
				} else if (PositionLeft > (tempPosStartLeft+LeftVerify)) {
					newPosLeft = tempPosStartLeft+(PositionLeft-(tempPosStartLeft+LeftVerify));
					MoveLeft = Math.round((newPosLeft-tempPosStartLeft)/10);
				}
				
				if ((PositionTop < (tempPosStartTop+40))) {
					MoveTop = Math.round((PositionTop-(tempPosStartTop+40))/10);
					newPosTop = PositionTop;
				} else if (PositionTop > (tempPosStartTop+300)) {
					newPosTop = tempPosStartTop+(PositionTop-(tempPosStartTop+300));
					MoveTop = Math.round((newPosTop-tempPosStartTop)/10);
				}
				/*
				if (PositionLeft < tempPosStartLeft) {
					tempPosStartLeft += (tempPosStartLeft-PositionLeft);
				} else if (PositionLeft > (tempPostStartLeft+386)) {
					tempPosStartLeft -= (PositionLeft-(tempPosStartLeft+386));
				}
				
				if (PositionTop < tempPosStartTop) {
					tempPosStartTop += (tempPosStartTop-PositionTop);
				} else if (PositionTop > (tempPosStartTop+386)) {
					tempPosStartTop -= (PositionTop-(tempPosStartTop+386));
				}*/
				
				if ((document.getElementById('resultsDisp').style.right == '0px')) {
					//centerMapPos((tempPosStartLeft-450),(tempPosStartTop-212));
				}
				
				PositionLeft -= 8;
				PositionTop -= 16;
				
				if (CompanyId != currCompanyBlurb) {
				
					if (Center == 1) {
					
						//PositionLeft = mapImages[currMapZoom][5]+Math.round(PositionLeft/mapImages[currMapZoom][7])-13;
						//PositionTop = mapImages[currMapZoom][6]+Math.round(PositionTop/mapImages[currMapZoom][7])-34;
						document.getElementById('mapContentHover').style.left = (PositionLeft)+"px";
						document.getElementById('mapContentHover').style.top = (PositionTop)+"px";
						document.getElementById('mapContentHoverInside').style.left = (PositionLeft+15)+"px";
						document.getElementById('mapContentHoverInside').style.top = (PositionTop+15)+"px";
					
					} else {
						document.getElementById('mapContentHover').style.left = PositionLeft+"px";
						document.getElementById('mapContentHover').style.top = PositionTop+"px";
						document.getElementById('mapContentHoverInside').style.left = (PositionLeft+15)+"px";
						document.getElementById('mapContentHoverInside').style.top = (PositionTop+15)+"px";
					}
					
					document.getElementById('mapContentHover').style.visibility = "visible";
					document.getElementById('mapContentHoverInside').style.visibility = "visible";
					
					currDiv = 'mapContentHoverInside';
					sendAjax("functions.php?directoryMapBriefHover=1&CompanyId="+CompanyId,processAjax);			
	
					currCompanyBlurb = CompanyId;
				
					if ((MoveTop != 0) || (MoveLeft != 0)) {
						//alert(newPosLeft+' '+newPosTop+' '+MoveLeft+' '+MoveTop);
						companyBlurbMove(newPosLeft,newPosTop,MoveLeft,MoveTop);
					}
	
				}
				
			}
			
		}
		
		function companyBlurbMove(PositionLeft,PositionTop,MoveLeft,MoveTop) {
		
			clearTimeout(moveMapTimer);
			
			var movingTop = 1;
			var movingLeft = 1;
			
			var offsetLeft = document.getElementById('thisMapStartLeft').value*1;
			var offsetTop = document.getElementById('thisMapStartTop').value*1;
		
			if ((MoveLeft < 0) && (PositionLeft < (offsetLeft+50))) {
				offsetLeft += MoveLeft;
			} else if ((MoveLeft > 0) && (PositionLeft > offsetLeft)) {
				offsetLeft += MoveLeft;
			} else {
				movingLeft = 0;	
			}
		
			if ((MoveTop < 0) && (PositionTop < (offsetTop+40))) {
				offsetTop += MoveTop;
			} else if ((MoveTop > 0) && (PositionTop > offsetTop)) {
				offsetTop += MoveTop;
			} else {
				movingTop = 0;	
			}
			
			var mapPosLeft = document.getElementById('currMapPosX').value*1;
			var mapPosTop = document.getElementById('currMapPosY').value*1;
			
			document.getElementById('thisMapStartLeft').value = offsetLeft;
			document.getElementById('thisMapStartTop').value = offsetTop;
			
			document.getElementById('currMapPosX').value = mapPosLeft;
			document.getElementById('currMapPosX').value = mapPosTop;
			
			document.getElementById('mapContent').style.left = ((-1)*offsetLeft)+"px";
			document.getElementById('mapContent').style.top = ((-1)*offsetTop)+"px";
			
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom);
			setMapImage(mapPosLeft,mapPosTop,currMapZoom,currMapZoom+1);
			
			if ((movingTop != 0) || (movingLeft != 0)) {
				moveMapTimer = window.setTimeout("companyBlurbMove("+PositionLeft+","+PositionTop+","+MoveLeft+","+MoveTop+")",10);
			}
			
		}
		
		function companyBlurbHide() {
			
			clearTimeout(moveMapTimer);
			document.getElementById('mapContentHover').style.visibility = "hidden";
			document.getElementById('mapContentHoverInside').style.visibility = "hidden";
			currCompanyBlurb = 0;
			return false;
		}
		
		function hoverInfo(PositionLeft,PositionTop,Name) {
			
			/*
			var thisMapStartLeft = document.getElementById('thisMapStartLeft').value;
			var thisMapStartTop = document.getElementById('thisMapStartTop').value;
			var currMapPosX = document.getElementById('currMapPosX').value;
			var currMapPosY = document.getElementById('currMapPosY').value;
			
			var thisMapPosX = thisMapStartLeft+currMapPosX;
			var thisMapPosY = thisMapStartTop+currMapPosY;
			*/
			
			PositionLeft = mapImages[currMapZoom][5]+Math.round(PositionLeft/mapImages[currMapZoom][7])-2;
			PositionTop = mapImages[currMapZoom][6]+Math.round(PositionTop/mapImages[currMapZoom][7])-2;
						
			var contentDisp = '<div style="padding: 1px 2px 1px 2px; font-size: 10px; color: #999;">'+Name+'</div>';
			
			document.getElementById('mapContentHoverInfo').style.left = (PositionLeft+10)+"px";
			document.getElementById('mapContentHoverInfo').style.top = (PositionTop-10)+"px";
			document.getElementById('mapContentHoverInfo').innerHTML = contentDisp;
			document.getElementById('mapContentHoverInfo').style.visibility = "visible";
			
		}
		
		function hideHoverInfo() {
			
			document.getElementById('mapContentHoverInfo').style.innerHTML = "";
			document.getElementById('mapContentHoverInfo').style.visibility = "hidden";
			
		}
		
		function centerMapCountry(CountryId) {
		
			currDiv = 'temp';
			noLoading = 1;
			sendAjax("functions.php?countryPosDetails=1&CountryId="+CountryId,processCountryPos);						
		
		}
		
		function processCountryPos() {
		
			if(request.readyState == 4) {
				
				if(request.status == 200) {
				
					if(trim(request.responseText) != '') {
						
						params = request.responseText.split(",");
						
						currCountryLeft = (Math.round(params[0]/mapImages[((params[2]*1)-1)][7])+100);
						currCountryTop = Math.round(params[1]/mapImages[((params[2]*1)-1)][7]);
						
						currCountryLeft -= 450;
						currCountryTop -= 212;
						
						zoomMap(0,4,((params[2]*1)-1));
						//centerMapPos((PositionLeft+100),PositionTop);
						
						//alert(document.getElementById('worldMap').useMap + ' ' + ((params[2]*1)-1));
						//alert(secondaryFunction);
						if (secondaryFunction != '') {
							var thisFunction = secondaryFunction;
							//alert(secondaryFunction);
							secondaryFunction = '';
							//secondaryFunction = 'directoryMapCompanies('+currMapZoom+')';
							eval(thisFunction);
						}
												
						tempContent = '';
						loadedContent = 1;
						noLoading = 0;
						
					}
					
				}
				
			}
		
		}
		
		function setDirectoryResultsOLD(Categories,Types,Regions,Countries) {
			
			//alert(Countries + ' ' + currCountry);
			
			
			if ((Countries != '') && (Countries != 0) && (Countries == currCountry)) {
				//alert(1);
				zoomMap(currCountry,1,(currMapZoom+1));
				directoryMapCompanies((currMapZoom+1));
			} else {
				//alert(2);
				setDirectoryResultsLoader(Categories,Types,Regions,Countries);
				
			}
												 
		}
		
		function setDirectoryResults() {

			companyBlurbHide();
			//zoomMap(0,2,0);moveCompanies();
			
			ajaxFunction[ajaxFunctionCounter] = "moveCompanies()";
			ajaxFunctionCounter++;
			
			ajaxFunction[ajaxFunctionCounter] = "setDirectoryResultsText()";
			ajaxFunctionCounter++;
			
			directoryMapResultsContentInside(0);
									 
		}
		
		function setDirectoryResultsText() {
			
			if (document.getElementById('resultsListCounter')) {
				
				var resultsListCounter = document.getElementById('resultsListCounter').value;
				
				if (resultsListCounter == 1) {
					resultsListCounter += ' result';	
				} else {
					resultsListCounter += ' results';	
				}
				
				if ((mapFields[4][1] != '') && (mapFields[4][1] != 'search by keywords...')) {
					resultsListCounter += ' for '+mapFields[4][1];
				}
				
				document.getElementById('resultsListContentCounter').innerHTML = resultsListCounter;
			
				if (resetResults == 1) {
					if (document.getElementById('resultsDisp').style.right == '0px') {
						dispMapResults(291,'resultsDisp');	
					}
				} else {
					if ((document.getElementById('resultsDisp').style.right != '0px') || (document.getElementById('resultsDisp').style.right == '')) {
						dispMapResults(291,'resultsDisp');
					}
				}
				
				resetResults = 0;
			
			}
			
			if ((currCountry != 0) && (currCountry != "")) {
				centerMapCountry(currCountry);
				currCountry = 0;
			} else if ((currRegion != 0) && (currRegion != "")) {
						
				currCountryLeft = (Math.round((document.getElementById('RegionLeft'+currRegion).value)/mapImages[1][7])+100);
				currCountryTop = Math.round((document.getElementById('RegionTop'+currRegion).value)/mapImages[1][7]);
				
				currCountryLeft -= 450;
				currCountryTop -= 212;
						
				zoomMap(0,4,1);
				currRegion = 0;
			} else {
				zoomMap(0,2,0);
			}
			//hideCompanies();
			
		}
		
		function hideCompanies() {
		
			var CompaniesList = document.getElementById('CompanyResultsList').value;
			
			//companyImageId_
		
		}
		
		function setDirectoryResultsLoader(Categories,Types,Regions,Countries) {
		
			var Keyword = document.getElementById('DirectorySearch').value;
				
			if (document.getElementById('resultsDisp').style.left != '-291px') {
				dispMapResults(291,'resultsDisp');	
			}
			
			if ((Regions != 0) && (Regions != '')) {
				//alert('a');
				zoomMap(0,0,1);
				var PositionLeft = Math.round(document.getElementById('RegionLeft'+Regions).value/mapImages[currMapZoom][7]);
				var PositionTop = Math.round(document.getElementById('RegionTop'+Regions).value/mapImages[currMapZoom][7]);
				centerMapPos((PositionLeft+100),PositionTop);
			}
			
			moveMapResults = 1;
			currMapResults = 0;
			if (currSelect != '') {
				dispSelect(currSelectTop*(-1),currSelect);
			}
			if ((Countries != 0) && (Countries != '')) {
				//alert('b');
				currCountry = Countries;
				secondaryFunction = "directoryMapResultsContent('"+Categories+"','"+Types+"','"+Regions+"','"+Countries+"','"+Keyword+"')";
				centerMapCountry(Countries);
			} else {
				//alert('c');
				directoryMapResultsContent(Categories,Types,Regions,Countries,Keyword);
			}
			//alert(document.getElementById('resultsDisp').style.right);
		
		}
		
		function directoryMapResultsContentOLD(Categories,Types,Regions,Countries,Keyword) {
		
			//alert(Countries+' '+currMapZoom);
		
			noLoading = 1;
			currDiv = 'resultsListContent';
			
			mapFields[0][1] = Categories;
			mapFields[1][1] = Types;
			mapFields[2][1] = Regions;
			mapFields[3][1] = Countries;
			mapFields[4][1] = Keyword;
			
			//alert(Categories+','+Types+','+Regions+','+Countries+','+Keyword);
			//alert(currMapZoom);
			secondaryFunction = "directoryMapCompanies("+currMapZoom+")";
			//alert(secondaryFunction);
			//secondaryFunction = "dispMapResults(291,'resultsDisp')";
		
			sendAjax("functions.php?directoryMapResultsContent=1&Categories="+Categories+"&Types="+Types+"&Regions="+Regions+"&Countries="+Countries+"&Keyword="+Keyword,processAjax);						
						
		}
		
		function mapPoints() {
		
			document.getElementById('worldMap').useMap = "#worldMap"+(currMapZoom);
		
			/*
		
			var coordsList = 0;
			var coordsArray = new Array();
			
			for (i = 0; i < 300; i++) {
				
				if (document.getElementById('mappedPoints_'+i)) {
			
					coordsList = document.getElementById('mappedPoints_'+i).coords;
					
					coordsList = coordsList.toString().replace(' ','');
					
					coordsArray = coordsList.split(',');

					for (j = 0; j < coordsArray.length; j++) {
							
						coordsArray[j]	*= 1;
							
						if ((j % 2) == 0) {
							coordsArray[j] -= mapImages[prevMapZoom][5];
						} else {
							coordsArray[j] -= mapImages[prevMapZoom][6];
						}
						coordsArray[j] = Math.round((coordsArray[j]*mapImages[prevMapZoom][7])/mapImages[currMapZoom][7]);
						if ((j % 2) == 0) {
							coordsArray[j] += mapImages[currMapZoom][5];
						} else {
							coordsArray[j] += mapImages[currMapZoom][6];
						}
					}
					
					coordsList = coordsArray.join(',');
					
					document.getElementById('mappedPoints_'+i).coords = coordsList;
					
				}
			
			}
			
			*/
		
		}
		
		function mapCities() {
		
			var coordsList = 0;
			var coordsArray = new Array();
			
			var PositionLeft = 0;
			var PositionTop = 0;
			
			for (i = 0; i < 300; i++) {
				
				if (document.getElementById('mappedCities_'+i)) {
			
					coordsList = document.getElementById('mappedCities_'+i).coords;
					
					coordsList = coordsList.toString().replace(' ','');
					
					//alert(coordsList);
					coordsArray = coordsList.split(',');

					PositionLeft = (((coordsArray[0]*1)+2)-mapImages[prevMapZoom][5])*mapImages[prevMapZoom][7];
					PositionTop = (((coordsArray[1]*1)+2)-mapImages[prevMapZoom][6])*mapImages[prevMapZoom][7];

					PositionLeft = mapImages[currMapZoom][5]+Math.round(PositionLeft/mapImages[currMapZoom][7])-2;
					PositionTop = mapImages[currMapZoom][6]+Math.round(PositionTop/mapImages[currMapZoom][7])-2;
					
					coordsList = PositionLeft+','+PositionTop+', '+(PositionLeft+5)+','+PositionTop+', '+(PositionLeft+5)+','+(PositionTop+5)+', '+PositionLeft+','+(PositionTop+5);
					
					//alert(coordsList);
					
					document.getElementById('mappedCities_'+i).coords = coordsList;
					
				}
			
			}
			
			document.getElementById('directoryMapLoader').style.visibility = 'hidden';
		
		}
		
		function mapCompanies() {
		
			var coordsList = 0;
			var coordsArray = new Array();
			
			var PositionLeft = 0;
			var PositionTop = 0;
			
			for (i = 0; i < 300; i++) {
				
				if (document.getElementById('mappedCompanies_'+i)) {
			
					coordsList = document.getElementById('mappedCompanies_'+i).coords;
					
					coordsList = coordsList.toString().replace(' ','');
					
					//alert(coordsList);
					coordsArray = coordsList.split(',');

					PositionLeft = (((coordsArray[0]*1)+6)-mapImages[prevMapZoom][5])*mapImages[prevMapZoom][7];
					PositionTop = (((coordsArray[1]*1)+15)-mapImages[prevMapZoom][6])*mapImages[prevMapZoom][7];

					PositionLeft = mapImages[currMapZoom][5]+Math.round(PositionLeft/mapImages[currMapZoom][7])-6;
					PositionTop = mapImages[currMapZoom][6]+Math.round(PositionTop/mapImages[currMapZoom][7])-15;
					
					coordsList = PositionLeft+','+PositionTop+', '+(PositionLeft+13)+','+PositionTop+', '+(PositionLeft+6)+','+(PositionTop+15);
					
					//alert(coordsList);
					
					document.getElementById('mappedCompanies_'+i).coords = coordsList;
					
				}
			
			}
		
		}
		
		function moveCompanies() {
		
			/**/
		
			if (IE) {
		
			document.getElementById('mapContentCompanies').innerHTML = '';
			document.getElementById('mapContentCompaniesPos').style.visibility = 'hidden';
			document.getElementById('directoryMapLoader').style.visibility = 'visible';
			
			directoryMapCompanies(currMapZoom);
			
			document.getElementById('mapContentCompaniesPos').style.visibility = 'visible';
			
			} else {
			moveCompaniesOld();	
			}
		
		}
		
		function moveCompaniesOld() {
		
			/**/
		
			document.getElementById('mapContentCompaniesPos').style.visibility = 'hidden';
			document.getElementById('directoryMapLoader').style.visibility = 'visible';
			
			//alert(document.getElementById('directoryMapLoader').style.visibility);
			
			var leftPos = 0;
			var topPos = 0;
			var CompanyId = 0;
			
			var elem = '';
			
			var CompaniesList = 'zzz';
			
			var compFunction = moveCompanyItem;
			
			if (document.getElementById('CompanyResultsList')) {
				CompaniesList = document.getElementById('CompanyResultsList').value;
				CompanyPos = CompaniesList.indexOf('-'+CompanyId+'-');
			}
			
			elem = document.getElementById('companyImage_0');
			
			var i = 0;
			
			while (elem) {
				
				compFunction(i,CompaniesList);
			
				i++;
				elem = document.getElementById('companyImage_'+i);
				/*
				
				if (elem) {
			
					CompanyId = document.getElementById('companyImageId_'+i).value;
					
					if ((CompaniesList.indexOf('-'+CompanyId+'-') != -1) || (CompaniesList == 'zzz')) {
					
					leftPos = document.getElementById('companyPosLeft_'+i).value*1;
					topPos = document.getElementById('companyPosTop_'+i).value*1;
					
					leftPos = Math.round(leftPos/mapImages[currMapZoom][7])-6;
					topPos = Math.round(topPos/mapImages[currMapZoom][7])-15;
					
					elem.style.visibility = "visible";
										
					elem.style.left = leftPos+"px";
					elem.style.top = topPos+"px";
					
					elem.style.visibility = "visible";	
					} else {
					elem.style.visibility = "hidden";	
					}
				
				}
				*/
			
			}
			
			
			/*
			document.getElementById('mapContentCompaniesPos'+prevMapZoom).style.visibility = 'hidden';
			document.getElementById('mapContentCompaniesPos'+currMapZoom).style.visibility = 'visible';
			*/
			document.getElementById('directoryMapLoader').style.visibility = 'hidden';
			document.getElementById('mapContentCompaniesPos').style.visibility = 'visible';
		
		}
		
		function moveCompanyItem(num,CompaniesList) {
		
			var leftPos = 0;
			var topPos = 0;
			var CompanyId = 0;
			
			var elem = document.getElementById('companyImage_'+num);
				
			if (elem) {
		
				CompanyId = document.getElementById('companyImageId_'+num).value;
				
				if ((CompaniesList.indexOf('-'+CompanyId+'-') != -1) || (CompaniesList == 'zzz')) {
				
				leftPos = document.getElementById('companyPosLeft_'+num).value*1;
				topPos = document.getElementById('companyPosTop_'+num).value*1;
				
				leftPos = Math.round(leftPos/mapImages[currMapZoom][7])-6;
				topPos = Math.round(topPos/mapImages[currMapZoom][7])-15;
				
				elem.style.visibility = "visible";
									
				elem.style.left = leftPos+"px";
				elem.style.top = topPos+"px";
				/**/
				elem.style.visibility = "visible";	
				} else {
				elem.style.visibility = "hidden";	
				}
			
			}
			
		}
		
		function moveCities() {
			
			var cityFunction = moveCitiesItem;
			
			var elem = document.getElementById('cityImage_0');
			
			var i = 0;
			
			while (elem) {
				
				cityFunction(i);
			
				i++;
				
				elem = document.getElementById('cityImage_'+i);
			
			}
			
			/*
			document.getElementById('mapContentCitiesPos'+prevMapZoom).style.visibility = 'hidden';
			document.getElementById('mapContentCitiesPos'+currMapZoom).style.visibility = 'visible';
			*/
			document.getElementById('mapContentCitiesPos').style.visibility = 'visible';
			
		}
		
		function moveCitiesItem(i) {
		
			var leftPos = 0;
			var topPos = 0;
			
			var elem = 0;
				
			elem = document.getElementById('cityImage_'+i);
			
			if (elem) {
		
				leftPos = elem.style.left.substr(0,(elem.style.left.length-2))*1;
				topPos = elem.style.top.substr(0,(elem.style.top.length-2))*1;
			
				leftPos = Math.round(((leftPos+2)*mapImages[prevMapZoom][7])/mapImages[currMapZoom][7])-2;
				topPos = Math.round(((topPos+2)*mapImages[prevMapZoom][7])/mapImages[currMapZoom][7])-2;
				
				elem.style.left = leftPos+"px";
				elem.style.top = topPos+"px";
				
				elem = document.getElementById('cityName_'+i);
				
				elem.style.left = (leftPos+9)+"px";
				elem.style.top = (topPos-8)+"px";
				
				if (currMapZoom == 3) {
					elem.style.visibility = "visible";
				} else {
					elem.style.visibility = "hidden";
				}
			
			}
			
		}
		
		function directoryMapResultsContent() {	
		
			//alert(1);
			
			noLoading = 1;
			
			document.getElementById('mapContentCitiesPos').style.left = mapImages[currMapZoom][5]+'px';
			document.getElementById('mapContentCitiesPos').style.top = mapImages[currMapZoom][6]+'px';
			document.getElementById('mapContentCitiesPos').style.width = mapImages[currMapZoom][1]+'px';
			document.getElementById('mapContentCitiesPos').style.height = mapImages[currMapZoom][2]+'px';
			document.getElementById('mapContentCities').style.width = mapImages[currMapZoom][1]+'px';
			document.getElementById('mapContentCities').style.height = mapImages[currMapZoom][2]+'px';
			
			document.getElementById('mapContentCompaniesPos').style.left = mapImages[currMapZoom][5]+'px';
			document.getElementById('mapContentCompaniesPos').style.top = mapImages[currMapZoom][6]+'px';
			document.getElementById('mapContentCompaniesPos').style.width = mapImages[currMapZoom][1]+'px';
			document.getElementById('mapContentCompaniesPos').style.height = mapImages[currMapZoom][2]+'px';
			document.getElementById('mapContentCompanies').style.width = mapImages[currMapZoom][1]+'px';
			document.getElementById('mapContentCompanies').style.height = mapImages[currMapZoom][2]+'px';
			/**/
			moveCompanies();
			if (prevMapZoom != currMapZoom) {
			moveCities();
			//mapPoints();
			//mapCompanies();
			//mapCities();
			}
			
			//document.getElementById('directoryMapLoader').style.visibility = 'hidden';
			
			/*
			ajaxFunction[ajaxFunctionCounter] = "directoryMapCompanies("+currMapZoom+")";
			ajaxFunctionCounter++;
			
			if (document.getElementById('resultsDisp').style.right != '0px') {
				ajaxFunction[ajaxFunctionCounter] = "dispMapResults(291,'resultsDisp')";
				ajaxFunctionCounter++;
			}
			
			ajaxFunction[ajaxFunctionCounter] = "directoryMapResultsContentInside("+currMapZoom+")";
			ajaxFunctionCounter++;
			
			ajaxFunction[ajaxFunctionCounter] = "imageMapCompanies("+currMapZoom+")";
			ajaxFunctionCounter++;
			
			ajaxFunction[ajaxFunctionCounter] = "directoryMapCities("+currMapZoom+")";
			ajaxFunctionCounter++;
			*/
			
			//imageMapCities(currMapZoom,0,0);
			
		}
		
		function drawMaps() {	
			
			noLoading = 1;
			
			//document.getElementById('directoryMapLoader').style.visibility = 'visible';
			if (document.getElementById('directoryRequest')) {
				
				ajaxFunction[ajaxFunctionCounter] = "directoryListingCompanyRequestContactSend();";
				ajaxFunctionCounter++;
				
			}
			
			ajaxFunction[ajaxFunctionCounter] = "directoryMapResultsContentInside(0)";
			ajaxFunctionCounter++;
			
			ajaxFunction[ajaxFunctionCounter] = "directoryMapCompanies(0)";
			ajaxFunctionCounter++;
			
			/*
			ajaxFunction[ajaxFunctionCounter] = "document.getElementById('directoryMapLoader').style.visibility = 'hidden'";
			ajaxFunctionCounter++;
			*/
			/*
			ajaxFunction[ajaxFunctionCounter] = "imageMapCompanies(0)";
			ajaxFunctionCounter++;
			
			ajaxFunction[ajaxFunctionCounter] = "directoryMapCities(0)";
			ajaxFunctionCounter++;
			*/
			
			directoryMapCities(0);
			
			//imageMapCities(0,0,0);
				
		}
		
		function directoryListingCompanyRequestContactSend() {
			
			if (document.getElementById('directoryContactPartner')) {
			
				var PartnerId = document.getElementById('directoryContactPartner').value*1;
				directoryListingCompanyRequest(PartnerId);
				
			} else {
			
				var ContactId = document.getElementById('directoryContactId').value*1;
				directoryListingCompanyRequestContact(ContactId,0);
				
			}
						
		}
		
		function directoryMapResultsContentInside(CurrResults) {
			
			noLoading = 1;
		
			currScrollMouse = -1;
			currScrollOffset = 0;
		
			var sendFields = '';
					
			for (i = 0; i < fieldsCounter; i++) {
			
				sendFields += '&'+mapFields[i][0]+'='+mapFields[i][1];
			
			}
			
			if (directoryStartCompany != 0) {
				
				var PositionLeft = document.getElementById('companyPosLeftById_'+directoryStartCompany).value*1;
				var PositionTop = document.getElementById('companyPosTopById_'+directoryStartCompany).value*1;
				
				//alert("test:"+PositionLeft+","+PositionTop+","+directoryStartCompany);
				
				//companyBlurb(PositionLeft,PositionTop,directoryStartCompany,0);
				
				ajaxFunction[ajaxFunctionCounter] = "companyBlurb("+PositionLeft+","+PositionTop+","+directoryStartCompany+",0)";
				ajaxFunctionCounter++;
				
				directoryStartCompany = 0;
				
				scrollSmooth(0,450);
			
			} else if (openListing == 1) {
			
				openListing = 0;
			
				ajaxFunction[ajaxFunctionCounter] = "dispMapResults(291,'resultsDisp')";
				ajaxFunctionCounter++;
				
			}
				
			//alert(sendFields);
			
			currDiv = 'resultsListContent';	
			sendAjax("functions.php?directoryMapResultsContent=1"+sendFields+"&CurrResults="+CurrResults,processAjax);						
		
			document.getElementById('scrollResults').style.top = "0px";
			
			document.getElementById('directoryMapLoader').style.visibility = "hidden";
			
			var offsetLeft = document.getElementById('thisMapStartLeft').value*1;
			var offsetTop = document.getElementById('thisMapStartTop').value*1;
			
			if (safariLoader == 1) {
				resetMap();
			}
			
			//companyBlurbMove((offsetLeft+10),offsetTop,5,0);
			
		}
		
		function scrollSmooth(offset,limit) {
			
			if (offset > limit) {
				
				window.scrollTo(0, limit);
				
			} else {
				
				window.scrollTo(0, offset);
				offset += 10;
				window.setTimeout("scrollSmooth("+offset+","+limit+")",10);
				
			}
			
		}
		
		function imageMapCities(Zoom,PositionLeft,PositionTop) {
			
			noLoading = 1;
			
			currDiv = 'citiesMap';
			
			sendAjax("functions.php?imageMapCities=1&Zoom="+Zoom+"&PositionLeft="+PositionLeft+"&PositionTop="+PositionTop,processAjax);
			
		}
		
		function imageMapCompanies(Zoom) {
			
			noLoading = 1;
		
			var sendFields = '';
					
			for (i = 0; i < fieldsCounter; i++) {
			
				sendFields += '&'+mapFields[i][0]+'='+mapFields[i][1];
			
			}
			
			currDiv = 'companiesMap';
			sendAjax("functions.php?imageMapCompanies=1&Zoom="+Zoom+sendFields,processAjax);	
			
		}
		
		function directoryMapCities(Zoom) {
			
			noLoading = 1;
			
			currDiv = 'mapContentCities';
			sendAjax("functions.php?directoryMapCities=1&Zoom="+Zoom,processAjax);
			
		}
		
		function directoryMapCompanies(Zoom) {
			
			noLoading = 1;
			
			//setCurrVisible = 0;
		
			var sendFields = '';
			
			if (document.getElementById('resultsListCounter')) {
				
				var resultsListCounter = document.getElementById('resultsListCounter').value;
				
				if (resultsListCounter == 1) {
					resultsListCounter += ' result';	
				} else {
					resultsListCounter += ' results';	
				}
				
				if ((mapFields[4][1] != '') && (mapFields[4][1] != 'search by keywords...')) {
					resultsListCounter += ' for '+mapFields[4][1];
				}
				
				document.getElementById('resultsListContentCounter').innerHTML = resultsListCounter;
			
			}
		
			for (i = 0; i < fieldsCounter; i++) {
			
				sendFields += '&'+mapFields[i][0]+'='+mapFields[i][1];
			
			}
			
			/*
			if (directoryStartCompany != 0) {
				var PositionLeft = document.getElementById('companyPosLeftById_'+directoryStartCompany).value*1;
				var PositionTop = document.getElementById('companyPosTopById_'+directoryStartCompany).value*1;
				ajaxFunction[ajaxFunctionCounter] = "companyBlurb("+PositionLeft+","+PositionTop+","+directoryStartCompany+",0)";
				ajaxFunctionCounter++;
				directoryStartCompany = 0;
			}
			*/
			
			currDiv = 'mapContentCompanies';
			//alert(Zoom);		
			sendAjax("functions.php?directoryMapCompanies=1&Zoom="+Zoom+sendFields,processAjax);	
			
		}
		
		function drawMap(Zoom) {
			
			if (Zoom < 4) {
			
				noLoading = 1;
				
				//secondaryFunction = 'imageMapPoints('+Zoom+')';	
				
				//alert(secondaryFunction);
				
				setCurrVisible = 0;
				
				if (Zoom < 1) {
					secondaryFunction = 'directoryMapCompanies('+Zoom+')';
				} else {
					secondaryFunction = 'drawMap('+(Zoom+1)+')';
				}
		
				currDiv = 'mapContentZoom'+Zoom;
				sendAjax("functions.php?drawMap=1&Zoom="+Zoom,processAjax);
			
			}
					
		}
		
		/*
		function directoryMapCompanies(Zoom) {
			
			noLoading = 1;
			
			//setCurrVisible = 0;
		
			var sendFields = '';
			
			if (document.getElementById('resultsListCounter')) {
				
				var resultsListCounter = document.getElementById('resultsListCounter').value;
				
				if (resultsListCounter == 1) {
					resultsListCounter += ' result';	
				} else {
					resultsListCounter += ' results';	
				}
				
				if ((mapFields[4][1] != '') && (mapFields[4][1] != 'search by keywords...')) {
					resultsListCounter += ' for '+mapFields[4][1];
				}
				
				document.getElementById('resultsListContentCounter').innerHTML = resultsListCounter;
			
			}
		
			for (i = 0; i < fieldsCounter; i++) {
			
				sendFields += '&'+mapFields[i][0]+'='+mapFields[i][1];
			
			}
			//alert(sendFields);
			secondaryFunction = 'imageMapPoints('+Zoom+')';
		
			//alert('imageMapZoom'+Zoom+' - '+sendFields+' - '+document.getElementById('mapContentZoom'+Zoom).style.visibility);
		
			currDiv = 'imageMapZoom'+Zoom;
			sendAjax("functions.php?imageMapPoints=1&Zoom="+Zoom+sendFields,processAjax);	
			
		}
		*/
		
		function imageMapPoints(Zoom) {
			
			noLoading = 1;
			
			if (startLoad == 1) {
				secondaryFunction = 'drawMap('+(Zoom+1)+')';
				startLoad = 0;
			}
					
			var sendFields = '';
		
			for (i = 0; i < fieldsCounter; i++) {
			
				sendFields += '&'+mapFields[i][0]+'='+mapFields[i][1];
			
			}
			
			//alert('mapContentCompanies'+Zoom);
			
			//currDiv = 'mapContentCompanies'+Zoom;
			//sendAjax("functions.php?directoryMapCompanies=1&Zoom="+Zoom+sendFields,processAjax);
			
		}
		
		function setDirectoryNavCats(CategoryId) {
			
			document.getElementById('DirectorySearch').value = 'search by keywords...';
			
			mapFields[4][1] = '';
			
			var directoryCatsTotal = document.getElementById('directoryCatsTotal').value;
			
			var catsFields = new String(mapFields[0][1]);
			var catsArray = new Array();
			var newCatsFields = '';
			
			catsArray = catsFields.split(',');
			
			if (CategoryId == 0) {
				mapFields[0][1] = 0;
				
				document.getElementById('directoryCats_0').checked = true;
				
				for (i = 1; i <= directoryCatsTotal; i++) {
					document.getElementById('directoryCats_'+i).checked = false;
				}
				
			} else {
				
				document.getElementById('directoryCats_0').checked = false;
				
				var counter = document.getElementById('directoryCatsNum_'+CategoryId).value;
					
				document.getElementById('directoryCats_'+counter).checked = false;
				
				addField = 1;
				
				for (i = 0; i < catsArray.length; i++) {
					if (catsArray[i] != 0) {
						if (catsArray[i] != CategoryId) {
							if (newCatsFields != '') {
								newCatsFields += ','+catsArray[i];
							} else {
								newCatsFields = catsArray[i];
							}
						} else {
							addField = 0;	
						}
					}
				}
				
				if (addField == 1) {
				
					document.getElementById('directoryCats_'+counter).checked = true;
				
					if (newCatsFields != '') {
						newCatsFields += ','+CategoryId;
					} else {
						newCatsFields = CategoryId;
					}
				}
				
				catsFields = newCatsFields;
				
				if (catsFields == '') {
					mapFields[0][1] = 0;
					document.getElementById('directoryCats_0').checked = true;	
				} else {
					mapFields[0][1] = catsFields;
				}
				
			}
			
			setDirectoryResults();

		}
		
		function setDirectoryNavTypes(TypeId) {
			
			document.getElementById('DirectorySearch').value = 'search by keywords...';
			
			mapFields[4][1] = '';
			
			var directoryTypesTotal = document.getElementById('directoryTypesTotal').value;
			
			var typesFields = new String(mapFields[1][1]);
			var typesArray = new Array();
			var newTypesFields = '';
			
			typesArray = typesFields.split(',');
			
			if (TypeId == 0) {
				mapFields[1][1] = 0;
				
				document.getElementById('directoryTypes_0').checked = true;
				
				for (i = 1; i <= directoryTypesTotal; i++) {
					document.getElementById('directoryTypes_'+i).checked = false;
				}
				
			} else {
				
				document.getElementById('directoryTypes_0').checked = false;
				
				var counter = document.getElementById('directoryTypesNum_'+TypeId).value;
					
				document.getElementById('directoryTypes_'+counter).checked = false;
				
				addField = 1;
				
				for (i = 0; i < typesArray.length; i++) {
					if (typesArray[i] != 0) {
						if (typesArray[i] != TypeId) {
							if (newTypesFields != '') {
								newTypesFields += ','+typesArray[i];
							} else {
								newTypesFields = typesArray[i];
							}
						} else {
							addField = 0;	
						}
					}
				}
				
				if (addField == 1) {
				
					document.getElementById('directoryTypes_'+counter).checked = true;
				
					if (newTypesFields != '') {
						newTypesFields += ','+TypeId;
					} else {
						newTypesFields = TypeId;
					}
				}
				
				typesFields = newTypesFields;
				
				if (typesFields == '') {
					mapFields[1][1] = 0;
					document.getElementById('directoryTypes_0').checked = true;	
				} else {
					mapFields[1][1] = typesFields;
				}
				
			}
			
			setDirectoryResults();
			
			//alert(mapFields[1][1]);
			
		}
		
		function setDirectoryNavCountries(CountryId) {
			
			document.getElementById('DirectorySearch').value = 'search by keywords...';
			
			mapFields[4][1] = '';
			
			var contentLength = 0;
			
			var directoryCountriesTotal = document.getElementById('directoryCountriesTotal').value;
			
			var countriesFields = new String(mapFields[3][1]);
			var countriesArray = new Array();
			var newCountriesFields = '';
			
			countriesArray = countriesFields.split(',');
			
			mapFields[2][1] = 0;
			var directoryRegionsTotal = document.getElementById('directoryRegionsTotal').value;
			
			for (i = 1; i <= directoryRegionsTotal; i++) {
				document.getElementById('directoryRegions_'+i).checked = false;
			}
			
			if (CountryId == 0) {
				mapFields[3][1] = 0;
				
				if ((mapFields[2][1] == 0) || (mapFields[2][1] == '')) {
					document.getElementById('directoryRegions_0').checked = true;
				}
				
				for (i = 1; i <= directoryCountriesTotal; i++) {
					document.getElementById('directoryCountries_'+i).checked = false;
				}
				
			} else {
				
				document.getElementById('directoryRegions_0').checked = false;
				
				var counter = document.getElementById('directoryCountriesNum_'+CountryId).value;
					
				document.getElementById('directoryCountries_'+counter).checked = false;
				
				addField = 1;
				
				for (i = 0; i < countriesArray.length; i++) {
					if (countriesArray[i] != 0) {
						if ((countriesArray[i] != CountryId)) {
							if (newCountriesFields != '') {
								newCountriesFields += ','+countriesArray[i];
							} else {
								newCountriesFields = countriesArray[i];
							}
							contentLength++;
						} else {
							addField = 0;	
						}
					}
				}
				
				if (addField == 1) {
				
					document.getElementById('directoryCountries_'+counter).checked = true;
			
					currCountry = CountryId;
				
					if (newCountriesFields != '') {
						newCountriesFields += ','+CountryId;
					} else {
						newCountriesFields = CountryId;
					}
							
				} else {
					
					if (contentLength == 1) {
						currCountry = newCountriesFields;	
					}

				}
				
				countriesFields = newCountriesFields;
				
				if (countriesFields == '') {
					mapFields[3][1] = 0;
					if ((mapFields[2][1] == 0) || (mapFields[2][1] == '')) {
						document.getElementById('directoryRegions_0').checked = true;	
					}
				} else {
					
					mapFields[3][1] = countriesFields;
				}
				
			}
			
			setDirectoryResults();
			
		}
		
		function setDirectoryNavRegions(RegionId) {
			
			document.getElementById('DirectorySearch').value = 'search by keywords...';
			
			mapFields[4][1] = '';
			
			var contentLength = 0;
			
			var directoryRegionsTotal = document.getElementById('directoryRegionsTotal').value;
			
			var regionsFields = new String(mapFields[2][1]);
			var regionsArray = new Array();
			var newRegionsFields = '';
			
			mapFields[3][1] = 0;
			var directoryCountriesTotal = document.getElementById('directoryCountriesTotal').value;
			
			for (i = 1; i <= directoryCountriesTotal; i++) {
				document.getElementById('directoryCountries_'+i).checked = false;
			}
			
			regionsArray = regionsFields.split(',');
			
			if (RegionId == 0) {
				mapFields[2][1] = 0;
				
				if ((mapFields[2][1] == 0) || (mapFields[2][1] == '')) {
					document.getElementById('directoryRegions_0').checked = true;
				}
				
				for (i = 1; i <= directoryRegionsTotal; i++) {
					document.getElementById('directoryRegions_'+i).checked = false;
				}
				
			} else {
				
				document.getElementById('directoryRegions_0').checked = false;
				
				var counter = document.getElementById('directoryRegionsNum_'+RegionId).value;
					
				document.getElementById('directoryRegions_'+counter).checked = false;
				
				addField = 1;
				
				for (i = 0; i < regionsArray.length; i++) {
					if (regionsArray[i] != 0) {
						if ((regionsArray[i] != RegionId)) {
							if (newRegionsFields != '') {
								newRegionsFields += ','+regionsArray[i];
							} else {
								newRegionsFields = regionsArray[i];
							}
							contentLength++;
						} else {
							addField = 0;	
						}
					}
				}
				
				if (addField == 1) {
				
					document.getElementById('directoryRegions_'+counter).checked = true;
			
					currRegion = RegionId;
				
					if (newRegionsFields != '') {
						newRegionsFields += ','+RegionId;
					} else {
						newRegionsFields = RegionId;
					}
				} else {
					
					if (contentLength == 1) {
						currRegion = newRegionsFields;	
					}

				}
				
				regionsFields = newRegionsFields;
				
				if (regionsFields == '') {
					mapFields[2][1] = 0;
					if ((mapFields[3][1] == 0) || (mapFields[3][1] == '')) {
						document.getElementById('directoryRegions_0').checked = true;	
					}
				} else {
					mapFields[2][1] = regionsFields;
				}
				
			}
			
			setDirectoryResults();
			//alert(mapFields[2][1]);
			
		}
		
		function setResultsCountrySearch(CountryName,CountryId) {
			
			resetFields(0);
			
			currCountry = CountryId;
			
			document.getElementById('DirectorySearch').value = CountryName;
			
			mapFields[4][1] = document.getElementById('DirectorySearch').value;
			
			if (mapFields[4][1] == 'search by keywords...') {
				mapFields[4][1] = '';
			}
			
			setDirectoryResults();
			
		}
		
		function setDirectoryNavSearch() {
			
			resetFields(0);
			
			mapFields[4][1] = document.getElementById('DirectorySearch').value;
			
			if (mapFields[4][1] == 'search by keywords...') {
				mapFields[4][1] = '';
			}
			
			setDirectoryResults();
						
		}
		
		function resetFields(KeywordReset) {
			
			var directoryCatsTotal = document.getElementById('directoryCatsTotal').value;
			
			document.getElementById('directoryCats_0').checked = true;
				
			for (i = 1; i <= directoryCatsTotal; i++) {
				document.getElementById('directoryCats_'+i).checked = false;
			}
				
			var directoryTypesTotal = document.getElementById('directoryTypesTotal').value;
			
			document.getElementById('directoryTypes_0').checked = true;
				
			for (i = 1; i <= directoryTypesTotal; i++) {
				document.getElementById('directoryTypes_'+i).checked = false;
			}
			
			var directoryRegionsTotal = document.getElementById('directoryRegionsTotal').value;
			
			document.getElementById('directoryRegions_0').checked = true;
				
			for (i = 1; i <= directoryRegionsTotal; i++) {
				document.getElementById('directoryRegions_'+i).checked = false;
			}
			
			var directoryCountriesTotal = document.getElementById('directoryCountriesTotal').value;
			
			for (i = 1; i <= directoryCountriesTotal; i++) {
				document.getElementById('directoryCountries_'+i).checked = false;
			}
			
			mapFields[0][1] = 0;
			mapFields[1][1] = 0;
			mapFields[2][1] = 0;
			mapFields[3][1] = 0;
			
			if (KeywordReset == 1) {
				mapFields[4][1] = '';			
				document.getElementById('DirectorySearch').value = 'search by keywords...';
			}
						
		}
		
		
		function resetMap() {
		
			zoomMap(0,3,0);
			resetFields(1);
			if (currSelect != '') {
				dispSelect(currSelectTop*(-1),currSelect);
			}
			
			resetResults = 1;
			
			if ((safariLoader == 1) && (document.getElementById('directoryStartCompany').value != 0)) {
			
				//alert(1);
				
				var thisDirectoryCompany = document.getElementById('directoryStartCompany').value*1;
				
				var PositionLeft = document.getElementById('companyPosLeftById_'+thisDirectoryCompany).value*1;
				var PositionTop = document.getElementById('companyPosTopById_'+thisDirectoryCompany).value*1;
				
				//alert("test:"+PositionLeft+","+PositionTop+","+directoryStartCompany);
				
				companyBlurb(PositionLeft,PositionTop,thisDirectoryCompany,0);
				
				//ajaxFunction[ajaxFunctionCounter] = "companyBlurb("+PositionLeft+","+PositionTop+","+thisDirectoryCompany+",0)";
				//ajaxFunctionCounter++;
							
				safariLoader = 0;
			
				setDirectoryResults();
			
			} else {
			
				safariLoader = 0;
				
				if (initLoaded == 0) {
			
					ajaxFunctionCounter = 0;
				
					ajaxFunction[ajaxFunctionCounter] = "setDirectoryResults()";
					ajaxFunctionCounter++;
				
					ajaxFunction[ajaxFunctionCounter] = "listingPartnersReset(1,1)";
					ajaxFunctionCounter++;
				
					directoryListingPartners(1);
					
				} else {
					initLoaded = 0;
					setDirectoryResults();
				}
				
			}
		
		}
		
		function directoryDisclaimer() {
		
			document.getElementById('mapContentBox').style.height = "450px";
			document.getElementById('mapContentBoxDisclaimer').style.visibility = "hidden";
			document.getElementById('mapContentBoxDisclaimer').style.height = "0px";
			document.getElementById('mapContentBoxDisclaimer').style.overflow = "hidden";
			document.getElementById('mapContentBoxDisclaimer').innerHTML = "";
			document.getElementById('mapContentBoxInside').style.top = "0px";
			
			directoryTopOffset = 258;
		
		}
		
		function contentInsideItemsSpecific(Type) {
		
			noLoading = 1;
		
			for (i = 0; i <= 6; i++) {
			
				if (document.getElementById('headerLink'+i)) {
					if (i == Type) {
						document.getElementById('headerLink'+i).className = 'contentHeaderLinksOn';
					} else {
						document.getElementById('headerLink'+i).className = 'contentHeaderLinks';
					}
				}
			
			}
			
			document.getElementById('contentInsideItems').innerHTML = '&nbsp;';
			contentInsideLoading('visible');
			
			secondaryFunction = "contentInsideLoading('hidden')";
			
			currDiv = 'contentInsideItems';
			sendAjax("functions.php?contentInsideItemsSpecific=1&Type="+Type,processAjax);
			
		}
		
		function contentInsideLoading(setting) {
		
			document.getElementById('contentInsideItemsLoading').style.visibility = setting;
		
		}
		
		function contentInsideSubscribeExpand(direction) {
			
			if (homeSubscribeOpen == 1) {
				direction = 0;	
			}
			
			if (direction == 1) {
				document.getElementById('contentInside').style.height = '1468px';
				document.getElementById('contentInsideRight').style.height = '1448px';
				expandDiv('contentInsideSocial',101,259,2,direction,'height');
				homeSubscribeOpen = 1;
			} else {
				document.getElementById('contentInside').style.height = '1310px';
				document.getElementById('contentInsideRight').style.height = '1290px';
				expandDiv('contentInsideSocial',259,101,2,direction,'height');
				homeSubscribeOpen = 0;
			}
		}
		
		function homeFeatureArrow(type) {
			
			if (type == 0) {
				if (currHomeFeature != 1) {
					homeFeature(currHomeFeature-1);	
				} else { 
					homeFeature(4);	
				}
			} else {
				if (currHomeFeature != 4) {
					homeFeature(currHomeFeature+1);	
				} else { 
					homeFeature(1);	
				}
			}
			
		}
		
		function homeFeatureOld(num) {
			
			noLoading = 1;
			
			currPosLeft = ((currHomeFeature-1)*616)*(-1);
							   
			if (currHomeFeature > num) {
				difference = (currHomeFeature-num);
				document.getElementById('featureNumbers'+currHomeFeature).className = 'featureNumbersInside';
				currHomeFeature = num;
				document.getElementById('featureNumbers'+currHomeFeature).className = 'featureNumbersInsideOn';
				tempFunction = "expandDiv('featureImageContent',"+currPosLeft+","+(currPosLeft+(616*difference))+",2,1,'left')";
				//moveFeature(0,currPosLeft,(currPosLeft+616));
			} else if (currHomeFeature < num) {
				difference = (num-currHomeFeature);
				document.getElementById('featureNumbers'+currHomeFeature).className = 'featureNumbersInside';
				currHomeFeature = num;
				document.getElementById('featureNumbers'+currHomeFeature).className = 'featureNumbersInsideOn';
				tempFunction = "expandDiv('featureImageContent',"+currPosLeft+","+(currPosLeft-(616*difference))+",2,0,'left')";
				//moveFeature(1,currPosLeft,(currPosLeft-616));
			}
			
			if (document.getElementById('featureItem'+currHomeFeature).innerHTML == '&nbsp;') {
				currDiv = 'featureItem'+currHomeFeature;
				FeatureId = document.getElementById('featureItemId'+currHomeFeature).value*1;
				sendAjax("functions.php?featureImage=1&FeatureId="+FeatureId,processAjax);				
				secondaryFunction = 'featureDescText('+FeatureId+')';
			} else {
				FeatureId = document.getElementById('featureItemId'+currHomeFeature).value*1;
				featureDescText(FeatureId);
			}
			
		}
		
		function homeFeature(num) {
			
			noLoading = 1;
			
			/*
			if (num == 1) {
				document.getElementById('featureArrowLeft').style.visibility = "hidden";
			} else {
				document.getElementById('featureArrowLeft').style.visibility = "visible";
			}
			
			if (num == 4) {
				document.getElementById('featureArrowRight').style.visibility = "hidden";
			} else {
				document.getElementById('featureArrowRight').style.visibility = "visible";
			}
			*/
			
			if (num != currHomeFeature) {
				document.getElementById('featureNumbers'+currHomeFeature).className = 'featureNumbersInside';
				displayOpacityNew('featureItem'+currHomeFeature,10,-2,0,0);
				document.getElementById('featureItem'+currHomeFeature).style.zIndex = 0;
				currHomeFeature = num;
				document.getElementById('featureItem'+currHomeFeature).style.zIndex = 0;
				document.getElementById('featureNumbers'+currHomeFeature).className = 'featureNumbersInsideOn';
				
				var FeatureId = document.getElementById('featureItemId'+currHomeFeature).value*1;
				document.getElementById('featureItem'+currHomeFeature).style.visibility = "hidden";
				setOpacity('featureItem'+currHomeFeature,0);
				
				if (document.getElementById('featureItem'+currHomeFeature).innerHTML == '&nbsp;') {
					secondaryFunction = 'featureDescText('+FeatureId+')';
					currDiv = 'featureItem'+currHomeFeature;
					sendAjax("functions.php?featureImage=1&FeatureId="+FeatureId,processAjax);
				} else {
					featureDescText(FeatureId);
				}
				window.setTimeout("homeFeatureFade()",200);
			}
			
		}
		
		function homeFeatureFade() {
			
			document.getElementById('featureItem'+currHomeFeature).style.visibility = "visible";
			displayOpacityNew('featureItem'+currHomeFeature,0,1,10,1);
			
		}
		
		function featureDescText(FeatureId) {
			
			noLoading = 1;
			
			if (tempFunction != '') {
				secondaryFunction = tempFunction;
				tempFunction = '';
			}
			
			currDiv = 'featureDescText';
			sendAjax("functions.php?featureDescText=1&FeatureId="+FeatureId,processAjax);				
			
		}
		
		function contentDirectoryHover(num) {
			
			noLoading = 1;
			
			clearTimeout(timeoutVar);
			timeoutVar = window.setTimeout("contentDirectoryHoverHide()",3000);
			
			document.getElementById('contentDirectoryArrow').style.left = (((num-1)*19)+((num-1)*50)+14)+"px";
			document.getElementById('contentDirectoryArrow').style.visibility = "visible";
			document.getElementById('contentDirectoryHover').style.visibility = "visible";
			
			CompanyId = document.getElementById('directoryCompanyId'+num).value*1;

			currDiv = 'contentDirectoryHover';
			sendAjax("functions.php?contentInsideDirectoryCompaniesBrief=1&CompanyId="+CompanyId,processAjax);				
			
		}
		
		function contentDirectoryHoverHide() {
			document.getElementById('contentDirectoryHover').style.visibility = "hidden";
			document.getElementById('contentDirectoryArrow').style.visibility = "hidden";
		}
		
		function expandFeatureImage() {
		
			clearTimeout(featureTimer);
		
			if (featureOpen == 0) {
				expandDiv('featureDesc',346,221,10,0,'top');
				featureOpen = 1;
			}
		
		}
		
		function closeFeatureImage() {
			
			featureTimer = window.setTimeout("closeFeatureImageFinal()",2000);
			
		}
		
		function closeFeatureImageFinal() {
			featureOpen = 0;
			expandDiv('featureDesc',221,346,10,1,'top');
		}
		
		function surveyFormVerifyCount(itemField) {
			
			if (itemField.checked) {
			
				if (optionCounter == 3) {
					itemField.checked = false;
				} else {
					optionCounter++;	
				}
				
			} else {
				optionCounter--;	
			}
			
		}
		
		function setListingHeight(height) {
		
			document.getElementById('directoryListingBox').style.height = (height+20)+"px";
			document.getElementById('directoryListingBoxLoader').style.height = (height+20)+"px";
			document.getElementById('directoryListingInfo').style.height = height+"px";
			
			document.getElementById('companyListingContent').style.height = height+"px";
			
			var mainHeight	= height-3;
			
			document.getElementById('companyListingContentLeft').style.height = mainHeight+"px";
			document.getElementById('companyListingContentRight').style.height = mainHeight+"px";
			document.getElementById('directoryListingContent').style.height = (mainHeight-34)+"px";
			
		}
		
		function verifyWordCount(string,Limit) {
		
			/*
			var stringArray = new Array();
			stringArray = string.split(' ');
			*/
			
			if(string.split(' ').join('').length < Limit) {
				return 0;
			} else {
				return 1;	
			}
		
		}
		
		function dispWordCount(field,limit,divName) {
			
			var fieldText = field.value.split(' ').join('');
			var counter = fieldText.length;
			var newCounter = fieldText.length;
			
			if (counter > limit) {
				var actualCounter = field.value.length;
				var newText = field.value;
				
				while (newCounter > limit) {
					newText = newText.substr(0,(newText.length-1));
					newCounter = newText.split(' ').join('').length;
				}
				field.value = newText;
				counter = newCounter;
			}
			
			document.getElementById(divName).innerHTML = counter;
			
		}
		
		function partnerBlurb(PositionLeft,PositionTop,CompanyId) {
					
			ajaxFunction[ajaxFunctionCounter] = "directoryListingCompany("+CompanyId+")";
			ajaxFunctionCounter++;
			
			directoryStartCompanyAnchor=0;
			companyBlurb(PositionLeft,PositionTop,CompanyId,0);
		
		}
		
		function eventBannerSwitch(num) {
		
			if (num == 1) {
				setOpacity('eventBanner1',0);
				document.getElementById('eventBanner2').style.zIndex = 0;
				document.getElementById('eventBanner1').style.zIndex = 1;
				window.setTimeout("displayOpacityNew('eventBanner1',0,1,10,2)",250);
				displayOpacityNew('eventBanner2',10,-1,0,1);
				//divName,value,increment,limit,num
				//document.getElementById('eventBanner2').style.visibility = 'hidden';
				//document.getElementById('eventBanner1').style.visibility = 'visible';
				window.setTimeout("eventBannerSwitch(2)",7000);
			} else {
				setOpacity('eventBanner2',0);
				document.getElementById('eventBanner1').style.zIndex = 0;
				document.getElementById('eventBanner2').style.zIndex = 1;
				displayOpacityNew('eventBanner1',10,-1,0,1);
				window.setTimeout("displayOpacityNew('eventBanner2',0,1,10,2)",250);
				//displayOpacityNew('eventBanner2',0,1,10,2);
				//document.getElementById('eventBanner1').style.visibility = 'hidden';
				//document.getElementById('eventBanner2').style.visibility = 'visible';
				window.setTimeout("eventBannerSwitch(1)",7000);
			}
		
		}
		
		function eventBannerSwitch2(num) {
		
			if (num == 1) {
				setOpacity('eventBanner3',0);
				document.getElementById('eventBanner4').style.zIndex = 0;
				document.getElementById('eventBanner3').style.zIndex = 1;
				window.setTimeout("displayOpacityNew('eventBanner3',0,1,10,2)",250);
				displayOpacityNew('eventBanner4',10,-1,0,1);
				//divName,value,increment,limit,num
				//document.getElementById('eventBanner2').style.visibility = 'hidden';
				//document.getElementById('eventBanner1').style.visibility = 'visible';
				window.setTimeout("eventBannerSwitch2(2)",7000);
			} else {
				setOpacity('eventBanner4',0);
				document.getElementById('eventBanner4').style.zIndex = 0;
				document.getElementById('eventBanner3').style.zIndex = 1;
				displayOpacityNew('eventBanner3',10,-1,0,1);
				window.setTimeout("displayOpacityNew('eventBanner4',0,1,10,2)",250);
				//displayOpacityNew('eventBanner2',0,1,10,2);
				//document.getElementById('eventBanner1').style.visibility = 'hidden';
				//document.getElementById('eventBanner2').style.visibility = 'visible';
				window.setTimeout("eventBannerSwitch2(1)",7000);
			}
		
		}
		
		function communityUpdatesSwitch() {
		
			if (communityUpdatesTop == communityUpdatesLimit) {
				document.getElementById('communityUpdates').scrollTop = 0;
				communityUpdatesTop = 0;
				clearTimeout(communityUpdatesTimer);
				communityUpdatesTimer = window.setTimeout("communityUpdatesSwitch()",3000);
			} else {
				if ((communityUpdatesTop%communityUpdatesOffset) != 0) {
					communityUpdatesTop = Math.ceil(communityUpdatesTop/communityUpdatesOffset)*communityUpdatesOffset;
				}
				communityUpdatesMove(communityUpdatesTop,(communityUpdatesTop+communityUpdatesOffset));
			}
		
		}
		
		function communityUpdatesMove(currPos,endPos) {
			
			clearTimeout(communityUpdatesTimer);
			clearTimeout(communityUpdatesTimerSec);
			
			if (currPos < endPos) {
				currPos += 10;
				document.getElementById('communityUpdates').scrollTop = currPos;
				communityUpdatesTimerSec = window.setTimeout("communityUpdatesMove("+currPos+","+endPos+")",60);
			} else {
				document.getElementById('communityUpdates').scrollTop = endPos;
				communityUpdatesTop += communityUpdatesOffset;
				communityUpdatesTimer = window.setTimeout("communityUpdatesSwitch()",3000);
			}
			
		}
	
	function setFieldChecked(fieldName) {
	
		if (fieldName.checked) {
			fieldName.checked = false;
		} else {
			fieldName.checked = true;
		}
	
	}
	
	function seeAllMembers(ArticleId) {
		currDiv = 'MembersBox';
		sendAjax("functions.php?seeAllMembers=1&ArticleId="+ArticleId,processAjax);				
			
	}
	
	function openRegisterBox() {
	
	document.getElementById('formBoxOut').style.visibility = 'visible';
	document.getElementById('moreButton').style.visibility = 'hidden';
	
	}

