//Begin dropdown script -initialize array
//Contents for menu 1 GALLERY
var menu1=new Array()
menu1[0]='&nbsp;&nbsp;<a href="gallery_windows1.html" class="dropdown">WINDOWS</a><br>';
menu1[1]='&nbsp;&nbsp;<a href="javascript:void();" class="dropdown">DOORS</a><br>';
menu1[2]='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="gallery_ext_doors1.html" class="dropdown">EXTERIOR</a><br>';
menu1[3]='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="dropdown">INTERIOR</a><br>';
menu1[4]='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="gallery_doors.html" class="dropdown">SPECS</a><br>';
menu1[5]='&nbsp;&nbsp;<a href="#" class="dropdown">GLASSES</a><br>';

//Contents for menu 2 PORTFOLIO
var menu2=new Array()
menu2[0]='&nbsp;&nbsp;<a href="portfolio_res.html" class="dropdown">RESIDENTIAL</a><br>';
menu2[1]='&nbsp;&nbsp;<a href="portfolio_com.html" class="dropdown">COMMERCIAL</a><br>';


// end DROP DOWN SCRIPT

var menuwidth='94px'; //default menu width
var menubgcolor='#EA8912';  //menu bgcolor
var disappeardelay=10;  //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){
	str = '<div id="dropmenudiv1" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:#EA8912; padding: 1px 0px 0px 0px; visibility:hidden; width:'+menuwidth+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event, dropmenuobj1)"><table width='+menuwidth+' border=0 cellpadding="3" cellspacing="1" bgcolor="white" width="100%">';
	for (i=0;i<menu1.length;i++){
		str += "<tr bgcolor='#EA8912'><td>";
		str += menu1[i];
		str += "</td></tr>";
	}
	str += '</table></div>'
	
	str += '<div id="dropmenudiv2" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:#EA8912; padding: 1px 0px 0px 0px; visibility:hidden; width:'+menuwidth+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event, dropmenuobj2)"><table width='+menuwidth+' border=0 cellpadding="3" cellspacing="1" bgcolor="white" width="100%">';
	for (i=0;i<menu2.length;i++){
		str += "<tr bgcolor='#EA8912'><td>";
		str += menu2[i]
		str += "</td></tr>";
	}
	str += '</table></div>'
	
	
	//adding page titles with DIV and images
	str += '<div id="profile_title" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:white; border:0px solid gray; padding: 0px 0px 0px 0px; visibility:hidden;" ><img src="images/profile_title.jpg" width="146" height="63" alt="" border="0"></div>';

	str += '<div id="contact_title" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:white; border:0px solid gray; padding: 0px 0px 0px 0px; visibility:hidden;" ><img src="images/contact_title.jpg" width="142" height="54" alt="" border="0"></div>';

	str += '<div id="portfolio_title" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:white; border:0px solid gray; padding: 0px 0px 0px 0px; visibility:hidden;" ><img src="images/portfolio_title.jpg" width="170" height="68" alt="" border="0"></div>';

	str += '<div id="gallery_title" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:white; border:0px solid gray; padding: 0px 0px 0px 0px; visibility:hidden;" ><img src="images/gallery_title.jpg" width="143" height="75" alt="" border="0"></div>';

	//str += '<div id="gallery_windows_title" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:white; border:0px solid gray; padding: 0px 0px 0px 0px; visibility:hidden;" ><img src="images/test_bar.gif" width="197" height="696" alt="" border="0"></div>';

	str += '<div id="portfolio_com_title" style="position:absolute; font:normal 12px Verdana; line-height:16px; z-index:100; layer-background-color:white; border:0px solid gray; padding: 0px 0px 0px 0px; visibility:hidden;" ><img src="images/portfolio_com_title.jpg" width="171" height="71" alt="" border="0"></div>';
	
	document.write(str)
}


dropmenuobj1=document.getElementById? document.getElementById('dropmenudiv1') : dropmenudiv1
dropmenuobj2=document.getElementById? document.getElementById('dropmenudiv2') : dropmenudiv2


///adding titles to pages
profile_titleobj=document.getElementById? document.getElementById('profile_title') : profile_title; //profile title

contact_titleobj=document.getElementById? document.getElementById('contact_title') : contact_title; //contact title

portfolio_titleobj=document.getElementById? document.getElementById('portfolio_title') : portfolio_title; //portfolio title

gallery_titleobj=document.getElementById? document.getElementById('gallery_title') : gallery_title; //gallery title

right_column_barobj=document.getElementById? document.getElementById('right_column_bar') : right_column_bar; //gallery windows title

logo_obj=document.getElementById? document.getElementById('logo') : logo; //gallery windows title

portfolio_com_titleobj=document.getElementById? document.getElementById('portfolio_com_title') : portfolio_com_title; //gallery windows title

function positionObject(pos_where, menu, offsetxie, offsetyie, offsetxnet, offsetynet){
	
	//menu.x=getposOffset(pos_where, "left") - offsetx;
	if (ns6){
		menu.y=getposOffset(pos_where, "top") + offsetynet;
		menu.x=getposOffset(pos_where, "left") + offsetxnet;
	} else if (ie4) {
		menu.y=getposOffset(pos_where, "top") + offsetyie;
		menu.x=getposOffset(pos_where, "left") + offsetxie;
	}
	//alert(menu.x + " " + menu.y);
	
	menu.style.left=menu.x-clearbrowseredge(pos_where, "rightedge", menu)+"px"
	menu.style.top=menu.y-clearbrowseredge(pos_where, "bottomedge", menu)+pos_where.offsetHeight+"px"
	menu.style.visibility="visible";
	
}


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, menu){
	if (ie4||ns6){
		menu.style.left=menu.style.top=-500
	}
	if (menuwidth!=""){
		menu.widthobj=menu.style
		menu.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, menu){
	var edgeoffset=0
	if (whichedge=="rightedge"){
	var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	menu.contentmeasure=menu.offsetWidth
	if (windowedge-menu.x < menu.contentmeasure)
	edgeoffset=menu.contentmeasure-obj.offsetWidth
	}
	else{
	var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
	menu.contentmeasure=menu.offsetHeight
	if (windowedge-menu.y < menu.contentmeasure)
	edgeoffset=menu.contentmeasure+obj.offsetHeight
	}
	return edgeoffset
}

function populatemenu(what){
	if (ie4||ns6){
		//dropmenuobj.innerHTML=what.join("");
	}
}


function dropdownmenu(obj, e, menucontents, divname, menuwidth, menu){
	if (typeof prevMenu!="undefined"){
	if (ie4||ns6)
	prevMenu.style.visibility="hidden"
	}
	
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	
	//menu=document.getElementById? document.getElementById(divname) : divname
	populatemenu(menucontents)
	
	if (ie4||ns6){
	showhide(menu.style, e, "visible", "hidden", menuwidth, menu)
	menu.x=getposOffset(obj, "left")
	menu.y=getposOffset(obj, "top") - 1
	menu.style.left=menu.x-clearbrowseredge(obj, "rightedge", menu)+"px"
	menu.style.top=menu.y-clearbrowseredge(obj, "bottomedge", menu)+obj.offsetHeight+"px"
	}
	prevMenu = menu;
	return clickreturnvalue()
}




function clickreturnvalue(){
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b) {
	//alert(b.parentNode)
	
	while (b.parentNode)
	//alert(b.parentNode);
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function dynamichide(e, menu){
	if (ie4&&!menu.contains(e.toElement))
	delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	delayhidemenu()
}

function hidemenu(){
	if (typeof prevMenu!="undefined"){
	if (ie4||ns6)
	prevMenu.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

















//*********** ROLL OVER ***************//
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		for (var i=0; i<preloadImages.arguments.length; i++) {
			checkbox_on = newImage(preloadImages.arguments[i]);
			//alert(checkbox_on);
		}
	}
	preloadFlag = true;
}
preloadImages();


function toggleImage(id, img_on, img_off){
	//alert('');
	
	if (this["var_" + id]){
		preloadImages(img_off);
		changeImages(id, img_off);
		this["var_" + id] = false;
	} else {
		preloadImages(img_on);
		changeImages(id, img_on);
		this["var_" + id] = true;
	}
}


