// JavaScript Document
/** IE7 FIX **/
if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

function initialize(){
	global_number = 1;
	return;
}

function add_events_over(){
	this.style.color='#FFFFFF';
	this.style.textDecoration='underline'; 
}
function add_events_out(){
	this.style.color='#FFFFFF';
	this.style.textDecoration='none'; 
}

function show_events_area_2(which)
{
	document.getElementById('events_area_3').style.display='none';
	document.getElementById('events_area_2').style.display='none';
	document.getElementById('events_area_1').style.display='none';
	
	if (which == 1){
		document.getElementById('events_area_1').style.display='block';
	}
	if (which == 2){
		document.getElementById('events_area_2').style.display='block'; 
	}
	if (which == 3){
		document.getElementById('events_area_3').style.display='block';
	}
	
	for (i=1; i <= 3; i++){
		for (j=1; j <= 3; j++){
			document.getElementById('events_tab_'+i+'_'+j).className = 'events_tab_off_'+j;
		}
	}
	
	for (i=1; i <= 3; i++){
		document.getElementById('events_tab_'+which+'_'+i).className = 'events_tab_on_'+i;
	}
}

function show_news_tabs(which)
{
	document.getElementById('news_col_1').style.display='none';
	document.getElementById('news_col_2').style.display='none';
	document.getElementById('news_col_3').style.display='none';
	document.getElementById('news_col_4').style.display='none';
	document.getElementById('news_col_5').style.display='none';
	
	for (i=1; i <= 5; i++){
		document.getElementById('img_'+i).src = 'images/news_tabs_'+i+'.gif';
	}
	document.getElementById('img_'+which).src = 'images/news_tabs_'+which+'_i.gif';
	
	if (which == 1){
		document.getElementById('news_col_1').style.display='block';
	}
	if (which == 2){
		document.getElementById('news_col_2').style.display='block'; 
	}
	if (which == 3){
		document.getElementById('news_col_3').style.display='block';
	}
	if (which == 4){
		document.getElementById('news_col_4').style.display='block';
	}
	if (which == 5){
		document.getElementById('news_col_5').style.display='block';
	}	
}

var menu = Array();
var links = Array();

menu[1] = Array('Why Choose us','Dr Mark Gadeley','Dr Arvin K. Bartolazo','Dental Team','What to expect at your cosmetic dental appiontment','Choosing the right cosmetic dentist');
links[1] = Array('why-choose-us.htm','get-to-know-us.htm','bartolazo.htm','dental_team.html','what_to_expect.html','right_cosmetic_dentist.html');

menu[2] = Array('What is Cosmetic Dentistry','Invisalign','Dental Implants','At home dental smile analysis for cosmetic dentistry','Making a six unit smile design "disappear" in the mouth using porcelain veneers.','Concerns','Not all Cosmetic Dentistry is created equal');
links[2] = Array('cosmetic.htm','invisalign.htm','dental-implants.htm','smile-analysis.html','six-unit.html','concern.htm','unnatural_appearing.html');

menu[3] = Array();
links[3] = Array();

menu[4] = Array();
links[4] = Array();

menu[5] = Array();
links[5] = Array();
menu[6] = Array();
links[6] = Array();
menu[7] = Array();
links[7] = Array();
menu[8] = Array();
links[8] = Array();
menu[9] = Array();
links[9] = Array();

menuPos = Array();

var menuElements = Array();
var t;
var show = false;

function getY( oElement )
{
    var iReturnValue = 0;
    while( oElement != null ) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}

function getX( oElement )
{
    var iReturnValue = 0;
    while( oElement != null ) {
        iReturnValue += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}


function clearMenu(){
	p = document.getElementById('sub_menu_elements');
	c = p.firstChild
	while (c != null){
		n = c.nextSibling;
		p.removeChild(c);
		c = n;
	}
}

function show_menu(number){
	if (show)
		return;
		
	global_number = number;
	
	menuElements[number].firstChild.style.textDecoration = 'none';
	menuElements[number].firstChild.style.color = '#FFFFFF';
	menuElements[number].firstChild.style.backgroundPosition = '0px -32px';
	menuElements[number].firstChild.style.textWeight = 'bold';
	
	show = true;
	elems = document.getElementById('sub_menu');
	clearMenu();
	
	if (menu[number].length > 0)
		elems.style.display = 'block';	
		
	var add = (number == 1)? 8 : 0;
	elems.style.left = getX(menuElements[number]) + add - 4 + 'px';
	elems.style.top = getY(menuElements[number]) + menuElements[number].offsetHeight + 'px';
	
	elems = document.getElementById('sub_menu_elements');


	for (i = 0; i < menu[number].length; i++){
		node = document.createElement('LI');
		a = document.createElement('A');
		a.appendChild(document.createTextNode(menu[number][i]));
		a.href = links[number][i];
		node.appendChild(a);
		elems.appendChild(node);
		node.style.dipslay = 'none';
		node.style.zIndex = 30;
	}

}

function hide_menu(number){
	if (!show)
		return;
	
	menuElements[number].firstChild.style.textDecoration = 'none';
	menuElements[number].firstChild.style.color = '#fff';
	menuElements[number].firstChild.style.backgroundPosition = '0px 0px';
	
		
	show = false;	
	elems = document.getElementById('sub_menu');
	elems.style.display = 'none';
}

function show_submenu(obj){
	show_menu(global_number);
	obj.style.display='block';
}

function hide_submenu(obj){
	hide_menu(global_number);
	obj.style.display='none';
	
}

function register_menus(){
	/* !!! menu is off!!! */
	return;
	
	menus = document.getElementById('main_menu_area');
	obj = menus.firstChild;
	no = 1;
	while (obj.nextSibling != null){
		if (obj.tagName != 'DIV'){
			obj = obj.nextSibling;
			continue;
		}
		obj.onmouseover = new Function('show_menu('+no+')');
		obj.onmouseout  = new Function('hide_menu('+no+')');
		menuElements[no] = obj;
		no++;
		obj = obj.nextSibling;
	}
}



