// JavaScript Document

	//function validate(form)
//	{
//		alert ("FCK Editor value is "  + form.description.value);
//	}

	function limitText(limitField, limitCount, limitNum)
	{
		if (limitField.value.length > limitNum)
		{
			limitField.value = limitField.value.substring(0, limitNum);
		}
		else 
		{
			document.getElementById("charsLeft").innerHTML= (limitNum - limitField.value.length);
			limitCount.value = limitNum - limitField.value.length;
		}
	}

	function limitTextDIV(limitField, limitCount, limitNum)
	{
		if (limitField.value.length > limitNum)
		{
			limitField.value = limitField.value.substring(0, limitNum);
		}
		else 
		{
			document.getElementById("charsLeft").innerHTML= "You have <SPAN style='color:#ff0000;'>" + (limitNum - limitField.value.length) + "</SPAN> characters left.";
			limitCount.value = limitNum - limitField.value.length;
		}
	}


	function isBlank(data)
	{
		// Remove all cases of "<br>" and "&nbsp;"
		data = data.replace(/\r|\n|\<br>|\&nbsp;/g, "");
		// Remove all spaces
		data = data.replace(/\s/g, "");	

		if (data == '')
			return true;
		else
			return false;	
	}

	function confirmYesNo()
	{
		return confirm("Are you sure?");
	}

	function validateCreateWebsiteForm(form)
	{	
		var theMLSColumns = form.mlsColumns.value;
		theMLSColumns = theMLSColumns.replace(/\D/g, "");		
		if ((isBlank(theMLSColumns)) || (form.mlsColumns.value <= 0))
		{
			alert("You must enter a number greater than zero for columns!");
			return false;
		}				

		var theDomain = form.domain.value;
		var httpString = theDomain.match("http://www.");
		if ((isBlank(theDomain)) || (httpString == null))
		{
			alert("You must enter a domain and it must be in the format http://www.<domain name>\nExamples: http://www.yourdomain.com, http://www.yourdomain.net, http://www.yourdomain.org");
			return false;
		}				

		var theMLSRadius = form.mlsRadius.value;
		theMLSRadius = theMLSRadius.replace(/\D/g, "");		
		if ((isBlank(theMLSRadius)) || (form.mlsRadius.value <= 0))
		{
			alert("You must enter a number greater than zero for the MLS Radius!");
			return false;
		}				

		var theMLSNumberOfCities = form.mlsNumberOfCities.value;
		theMLSNumberOfCities = theMLSNumberOfCities.replace(/\D/g, "");		
		if ((isBlank(theMLSNumberOfCities)) || (form.mlsNumberOfCities.value <= 0))
		{
			alert("You must enter a number greater than zero for the MLS # of Cities!");
			return false;
		}				


		return true;
	}




	function validateContactForm(form)
	{
		if (form.name.value == '')
		{
			alert("You must enter a name!");
			return false;
		}

		if (form.email.value == '')
		{
			alert("You must enter an email address!");
			return false;
		}

		if (form.phone.value == '')
		{
			alert("You must enter a phone address!");
			return false;
		}

		if (form.content.value == '')
		{
			alert("You must enter comments!");
			return false;
		}

		return true;
	}

	function validateArticleForm(form)
	{			
		if (isBlank(form.title.value))
		{
			alert("You must enter a title");
			return false;
		}

		if (isBlank(form.author.value))
		{
			alert("You must enter an author!");
			return false;
		}

		if (isBlank(form.source.value))
		{
			alert("You must enter a source");
			return false;
		}
		
		if (isBlank(form.hyperlink.value))
		{
			alert("You must enter a link!");
			return false;
		}

		if (checkFCKEditorContent("fckEditorContent") == false)
		{
			alert("You must enter the article content!");
			return false;
		}

		return true;
	}



function validatePendingArticleForm(form)
{			
	var errorString='';
	if (isBlank(form.name.value))
	{		
		errorString = errorString + "- Name\n";
	}

	if (isBlank(form.phone.value))
	{
		errorString = errorString + "- Phone\n";
	}

	if (isBlank(form.email.value))
	{
		errorString = errorString + "- Email\n";
	}

	if (isBlank(form.title.value))
	{
		errorString = errorString + "- Title of Article\n";
	}

	if (isBlank(form.author.value))
	{
		errorString = errorString + "- Article Author\n";
	}

	if (isBlank(form.source.value))
	{
		errorString = errorString + "- Article Source\n";
	}
	
	if (checkFCKEditorContent("fckEditorContent") == false)
	{
		errorString = errorString + "- Article content\n";
	}

	if (errorString!='')
	{
		alert("The following information is required:\n" + errorString);
		return false;
	}
	else
	{
		return true;
	}
}


	function validateSignupForm(form)
	{			
		if (isBlank(form.firstName.value))
		{
			alert("You must enter a first name");
			return false;
		}
		if (isBlank(form.lastName.value))
		{
			alert("You must enter a last name");
			return false;
		}
		
		if (isBlank(form.username.value))
		{
			alert("You must enter a username");
			return false;
		}
		
		if (isBlank(form.email.value))
		{
			alert("You must enter an email");
			return false;
		}
		
		if (isBlank(form.password.value))
		{
			alert("You must enter a password");
			return false;
		}

	/*	if (form.password2.value == form.password.value)
		{
			alert("Your password and repeat password must match");
			return false;
		}

		if (isBlank(form.gender.value))
		{
			alert("You must choose a gender");
			return false;
		}
*/
		if (isBlank(form.bMonth.value))
		{
			alert("You must choose a birth month");
			return false;
		}
		if (isBlank(form.bDay.value))
		{
			alert("You must choose a birth day");
			return false;
		}
		if (isBlank(form.bYear.value))
		{
			alert("You must choose a birth year");
			return false;
		}

		return true;
	}



	function validateCityProfileForm(form)
	{			
		if (isBlank(form.city.value))
		{
			alert("You must enter a city!");
			return false;
		}
				
		if (checkFCKEditorContent("fckContent") == false)
		{
			alert("You must enter a city description!");
			return false;
		}

		return true;
	}



	function validateGuideLinkForm(form)
	{			
		if (isBlank(form.title.value))
		{
			alert("You must enter a title!");
			return false;
		}

		if (isBlank(form.hyperlink.value))
		{
			alert("You must enter a link!");
			return false;
		}


		if (checkFCKEditorContent("fckContent") == false)
		{
			alert("You must enter the guide link description!");
			return false;
		}

		return true;
	}

	function validateBDLF(form)
	{			
		if (isBlank(form.name.value))
		{
			alert("You must enter a name!");
			return false;
		}

		if (isBlank(form.phone.value))
		{
			alert("You must enter a phone number!");
			return false;
		}

		if (isBlank(form.email.value))
		{
			alert("You must enter an email!");
			return false;
		}

		if (isBlank(form.title.value))
		{
			alert("You must enter a title!");
			return false;
		}

		if (isBlank(form.hyperlink.value))
		{
			alert("You must enter a link!");
			return false;
		}
		
		if (isBlank(form.categoryID.value))
		{
			alert("You must enter a category!");
			return false;
		}

		if (isBlank(form.description.value))
		{
			alert("You must enter a description!");
			return false;
		}

		return true;
	}

	function validateTestimonialForm(form)
	{			
		
		if (form.name.value == '')
		{
			alert("You must enter a name!");
			return false;
		}

		if (form.location.value == '')
		{
			alert("You must enter a location!");
			return false;
		}

		if (checkFCKEditorContent("testimonial") == false)
		{
			alert("You must enter a description!");
			return false;
		}

		return true;
	}

	function validateGuideCategoryForm(form)
	{					
		if (form.name.value == '')
		{
			alert("You must enter a name!");
			return false;
		}

		return true;
	}


	function validateTeamInfoForm(form)
	{					 
		if (form.name.value == '')
		{
			alert("You must enter a name!");
			return false;
		}

		if (form.slogan.value == '')
		{
			alert("You must enter a slogan!");
			return false;
		}

		if (checkFCKEditorContent("description") == false)
		{
			alert("You must enter a description!");
			return false;
		}

		return true;
	}



	function validateTeamMemberForm(form)
	{					 
		if (form.name.value == '')
		{
			alert("You must enter a name!");
			return false;
		}

		if (checkFCKEditorContent("description") == false)
		{
			alert("You must enter a description!");
			return false;
		}

		return true;
	}

	function validateRelocationGuide(form)
	{	
		if (isBlank(form.first_name.value))
		{
			alert("You must enter your first name!");
			return false;
		}		
		
		if (isBlank(form.last_name.value))
		{
			alert("You must enter your last name!");
			return false;
		}		

		if (isBlank(form.email.value))
		{
			alert("You must enter your email address!");
			return false;
		}		
		if (isBlank(form.address_1.value))
		{
			alert("You must enter your address!");
			return false;
		}		
		if (isBlank(form.city.value))
		{
			alert("You must enter your City!");
			return false;
		}		
		if (isBlank(form.state.value))
		{
			alert("You must enter your State!");
			return false;
		}		
		if (isBlank(form.zip.value))
		{
			alert("You must enter your zip code!");
			return false;
		}		
		if (isBlank(form.phone.value))
		{
			alert("You must enter your Main Telephone number!");
			return false;
		}		

		return true;
	}



	function checkFCKEditorContent(fckEditorInstanceName)
	{
		var oEditor = FCKeditorAPI.GetInstance(fckEditorInstanceName);		
		var content = oEditor.GetHTML(true);

		// Remove all cases of "<br>" and "&nbsp;"
		content	= content.replace(/\r|\n|\<br>|\&nbsp;/g, "");
		// Remove all spaces
		content = content.replace(/\s/g, "");	

		// Check if content is empty
		if (content == '')
		{
			return false;
		}
		else
		{
			return true;
		}
	}

	function removeCharacters( strValue, strMatchPattern ) 
	{
	/************************************************
	DESCRIPTION: Removes characters from a source string
	  based upon matches of the supplied pattern.

	PARAMETERS:
	  strValue - source string containing number.

	RETURNS: String modified with characters
	  matching search pattern removed

	USAGE:  strNoSpaces = removeCharacters( ' sfdf  dfd',
									'\s*')
	*************************************************/
	 var objRegExp =  new RegExp( strMatchPattern, 'gi' );

	 //replace passed pattern matches with blanks
	  return strValue.replace(objRegExp,'');
	}

function changeImage(img1,ref1)
{
	browser_name = navigator.appName;
	browser_version = parseFloat(navigator.appVersion);

	if (browser_name == "Netscape" && browser_version >= 3.0)
	{
			roll = 'true';
	}
	else if (browser_name == "Microsoft Internet Explorer" && browser_version >= 4.0)
	{
			roll = 'true';
	}
	else
	{
			roll = 'false';
	}

	if (roll == 'true')
	{
			document.images[img1].src = ref1;
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById(n)) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function flash_write(divID, flashFile, width, height) {
document.write("<object z-index=-1 bgcolor='#ffffff' class='playerpreview' type='application/x-shockwave-flash' data='/player_flv_maxi.swf?flv="+flashFile+
										   "&amp;width="+width+
										   "&amp;height="+height+
										   "&amp;showstop=1&amp;showvolume=1&amp;showtime=1&amp;showfullscreen=1&amp;bgcolor1=ffffff&amp;bgcolor2=008bf6&amp;playercolor=008bf6' width='320' height='240'><param name='movie' value='/player_flv_maxi.swf?flv="+flashFile+
										   "&amp;width="+width+
										   "&amp;height="+height+
										   "&amp;showstop=1&amp;showvolume=1&amp;showtime=1&amp;showfullscreen=1&amp;bgcolor1=ffffff&amp;bgcolor2=008bf6&amp;playercolor=008bf6' /><param name='allowFullScreen' value='true' /><param name='bgcolor' value='#ffffff' /></object>");
}
