﻿
function loader()
{
	var id = document.getElementById('pageName');
	hiliteNav(id);
}
function swapImgOn()
{
	document.getElementById('bulletImg').src = "images/BulletNavs5.jpg";
}
function swapImgOff()
{
	document.getElementById('bulletImg').src = "images/BulletNavs6.jpg";
}

function hiliteNav(pageName)
{
	var lnk = ""; //.toLowerCase();
	try
	{
		lnk = "link"+pageName.value;
		document.getElementById(lnk).className = "activeTab";
	}
	catch(err)
	{
	}
}
function hiliteMenu(id)
{
	document.getElementById(id).style.backgroundColor = '#ccccff';
}
function deHiliteMenu(id)
{
	document.getElementById(id).style.backgroundColor = '#fff';
}

function showMenu(id)
{
	var x = document.getElementById(id);
	if(x.style.display == "none")
	{
		x.style.display = "block";
	}
	else
	{
		x.style.display = "none";
	}
}
function hideMenu(id)
{
	document.getElementById(id).style.display = "none";
}

var arr = "";
function validateForm(ids)
{
	arr = ids.split(",");
	var isGood = false;
	for (i=0;i<=arr.length;i++)
	{
		var id = document.getElementById(arr[i]);
		if (id.value.length < 1)
		{
		
			if(id.id == "Email")
			{
				if(id.value.indexOf("@") < 1)
				{
					alert("Valid email is required!");
					isGood = false;
					break;
				}
				else if(id.value.indexOf(".") < 1)
				{
					alert("Valid email is required!");
					isGood = false;
					break;
				}
			}
			else
			{
				alert(id.id + " is required!");
				isGood = false;
				break;
			}
		}
		else
		{
			isGood = true;
		}
	}
	if (isGood)
	{
		sendEmail(ids);
	}
	return isGood;
}
function sendEmail()
{
		// strip array of any bad values
		for (i=0;i<=arr.length;i++)
		{
			var id = document.getElementById(arr[i]);
			try
			{
				id.value.Replace("<", "");
				id.value.Replace("/>", "");
				id.value.Replace("[", "");
				id.value.Replace("]", "");
				id.value.Replace("'", "");
				id.value.Replace("\"", "");
				id.value.toLowerCase().Replace("select", "");
			}
			catch(err)
			{}
		}

	var form = document.getElementById('ContactUs');

	//ajax email
}
function openFlash(file)
{
	window.open(file, "_blank", "toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=800, height=600");
}
function drawFlash(theFile,w,h)
{
	var file = "http://www.braceyourselves.com/images/" + theFile;
	var str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+w+"' height='"+h+"' id='Flash Animation' align='middle'>"
	str += "<param name='allowScriptAccess' value='sameDomain' />"
	str += "<param name='movie' value='" + file + "' />"
	str += "<param name='quality' value='high' />"
	str += "<param name='wmode' value='transparent' />"
	str += "<embed src='" + file + "' quality='high' wmode='transparent' width='"+w+"' height='"+h+"' name='Flash Animation' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	str += "<" + "/" + "" + "object>"
	document.write(str);
}

var xmlHttp;
var myDiv;
var myPage;
function getData(elemID, page, query)
{ 
	myDiv = elemID; //the div to display data
	myPage = page; //the serverpage to get the data from
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url=page;
	url=url+"?q="+query;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	}
	else
	{
		document.getElementById(myDiv).innerHTML = "<h3>Loading...</h3>";
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
try
{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
catch (e)
	{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
}
return xmlHttp;
}




/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="OfficeFeatures.aspx">Office Features</a>'
menu1[1]='<a href="MissionStatement.aspx">Mission Statement</a>'
menu1[2]='<a href="Contest.aspx">Contest</a>'
menu1[3]='<a href="Newsletter.aspx">Newsletter</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="YourFirstVisit.aspx">Your First Visit</a>'
menu2[1]='<a href="ChoosingOrthodontist.aspx">Choosing an Orthodontist</a>'
menu2[2]='<a href="FinancialInfo.aspx">Financial Information</a>'
menu2[3]='<a href="LifeWithBraces.aspx">Life with Braces</a>'
		
var menuwidth='165px' //165px default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)

document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu








