/*---------------------------------------------------------------------------------
-    ________  ____ ___________/ /_     / // /    ____ ___  (_)___ _____ ___  (_) -
-   / ___/ _ \/ __ `/ ___/ ___/ __ \   / // /_   / __ `__ \/ / __ `/ __ `__ \/ /  -
-  (__  )  __/ /_/ / /  / /__/ / / /  /__  __/  / / / / / / / /_/ / / / / / / /   -
- /____/\___/\__,_/_/   \___/_/ /_/     /_/    /_/ /_/ /_/_/\__,_/_/ /_/ /_/_/    -
-                                                                                 -
---------     / /_  ____  ____ ___  ___  _____ _________  ____ ___   --------------
---------    / __ \/ __ \/ __ `__ \/ _ \/ ___// ___/ __ \/ __ `__ \  --------------
---------   / / / / /_/ / / / / / /  __(__  )/ /__/ /_/ / / / / / /  --------------
---------  /_/ /_/\____/_/ /_/ /_/\___/____(_)___/\____/_/ /_/ /_/   --------------
-----------------------------------------------------------------------------------
-----CODE WRITTEN BY FLAVIO KOTTAR FOR SEARCH4MIAMIHOMES.COM & PETER FRAGOS--------
---------------------------------------------------------------------------------*/

	if (top.location!==self.location) 
	{
	document.write('<style type=\"text/css\" media=\"all\">@import \"http://www.search4miamihomes.com/include/framed.css\";<\/style>')
	}
else
	{
	document.write('<style type=\"text/css\" media=\"all\">@import \"http://www.search4miamihomes.com/include/frameless.css\";<\/style>')
	}

var DHTML = (document.getElementById || document.all || document.layers)

function getObj(name)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
		this.style.height = document.getElementById(name).style.height;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
		this.style = document.layers[name].style;
	}
}

function setFontSize()
{
	if (DHTML)
	{
		lineH=size + 10;
		var contentObj = new getObj('content');
		contentObj.style.fontSize = size + 'px';
		contentObj.style.lineHeight = lineH + 'px';
	}
}

//function setNavHeight()
//{
//	if (DHTML)
//	{
//		if (top.location == self.location) 
//		{
//			var contentObj = new getObj('content');
//			var navleftObj = new getObj('nav-left');
//			navleftObj.style.height = '2000px';
//			var flavioNav = document.getElementById('nav-left').style.height;
//			var flavioCont = document.getElementById('content').style.height;
//			alert('Nav=' + flavioNav + ' Content=' + flavioCont);
//			}
//	}
//}

//var checkHeight = setInterval('setNavHeight()', 4000); //NOT IN USE



function getFontSizeCookie()
{
	if (document.cookie.length > 0)
	{
		cookieStart = document.cookie.indexOf('fontsize=')
		if (cookieStart !== -1)
		{
			cookieStart += 9
			cookieEnd = document.cookie.indexOf(';',cookieStart)
			if (cookieEnd == -1)
			{
				cookieEnd = document.cookie.length
				return unescape(document.cookie.substring(cookieStart,cookieEnd))
			}
		}
	}
	return '12'	
}

var max = 32
var min = 10
var size = Number(getFontSizeCookie())

function adjustTextSize(change)
{
	if (DHTML)
	{
		size += change;
		if(size > max)
		{
			size = max
		}
		if(size < min)
		{
			size = min
		}
		lineH = size + 8;
		var contentObj = new getObj('content');
		contentObj.style.fontSize = size + 'px';
		contentObj.style.lineHeight = lineH + 'px';
		setFontSizeCookie(size);
		//setNavHeight();
	}
}

function setFontSizeCookie(value)
{
	exdate = new Date();
	exdate.setTime(exdate.getTime() + 365 * 24 * 3600 * 1000);
	document.cookie = 'fontsize=' + escape(value) + '; expires = '+exdate;
}
	
function testLoad()
{
	if (document.getElementsByTagName('body')[0])
	{
		setFontSize();
		//setNavHeight();
		clearTimeout(t);
	}
	else
	{
		var t = setTimeout('testLoad()',5)
	}
}



function validateForm()
{
	if (DHTML)
	{
	var nameObj = new getObj('name');
	var emailObj = new getObj('email');
	var phoneObj = new getObj('phone');
	var subjectObj = new getObj('subject');
	if (nameObj.obj.value.length == '0')
		{
			var invalidName = 1
			nameObj.style.backgroundColor = "#FFD992";
			nameObj.style.borderColor = "#FFAD15";
		}
		else
		{
			nameObj.style.backgroundColor = "#FFF";
			nameObj.style.borderColor = "#006";
		}
		if (emailObj.obj.value.indexOf('@') == '-1')
		{
			var invalidEmail = 1;
			emailObj.style.backgroundColor = "#FFD992";
			emailObj.style.borderColor = "#FFAD15";
		}
		else
		{
			emailObj.style.backgroundColor = "#FFF";
			emailObj.style.borderColor = "#006";
		}
		if (phoneObj.obj.value.length == '0')
		{
			var invalidPhone = 1;
			phoneObj.style.backgroundColor = "#FFD992";
			phoneObj.style.borderColor = "#FFAD15";
		}
		else
		{
			phoneObj.style.backgroundColor = "#FFF";
			phoneObj.style.borderColor = "#006";
		}


		if (invalidName == '1' && invalidEmail == '1' && invalidPhone == '1')
		{
			alert('Please provide your Name and either a Phone Number or an E-mail address');
			return false;
		}

		if (invalidName == '1' && invalidEmail !== '1' && invalidPhone !== '1')
		{
			alert('Please provide your Name');
			return false;
		}

		if (invalidEmail == '1' && invalidPhone == '1')
		{
			alert('Please provide either a Phone Number or an E-mail address');
			return false;
		}

		subjectObj.obj.value = 'Contact Form from ' + self.location;
		return true;
	}
}
