VAR = new Object()

function startmenu()
{
//setInterval("menumove()",10)
menu = document.getElementById('menu');
menu.style.top = '0px'
mobilemenu = 1;
dswitch('background_div','background_switch',1)
dswitch('background_image_div','background_image_switch',1)
dswitch('table_background_div','table_background_switch',1)
dswitch('table_background_image_div','table_background_image_switch',1)
dswitch('image_3d_div','image_3d_switch',1)
dswitch('scrollbar_div','scrollbar_switch',1)
dswitch('image_style_div','image_style_switch',1)
dswitch('image_hover_style_div','image_hover_style_switch',1)
dswitch('table_border_div','table_border_switch',1)
dswitch('text_div','text_switch',1)
dswitch('text_link_div','text_link_switch',1)
dswitch('text_heading_div','text_heading_switch',1)
text_font=document.getElementById('text_font')
display('text_font_other',(text_font.value=='other')?'inline':0)
text_heading_font=document.getElementById('text_heading_font')
display('text_heading_font_other',(text_heading_font.value=='other')?'inline':0)
text_link_font=document.getElementById('text_link_font')
display('text_link_font_other',(text_link_font.value=='other')?'inline':0)
startcolors()
}

menu = document.getElementById('menu');
mobilemenu = 1;

function lockmenu(doit)
{
if(doit)
mobilemenu = 0;
else
mobilemenu = 1;
}

function menudist(menutop,bodytop)
{

dist = Math.abs(menutop - bodytop)
dist = Math.sqrt(dist)
dist = Math.floor(dist)
return dist;

}

function menumove()
{
var menu = document.getElementById('menu');
var menutop = parseInt(menu.style.top)
var bodytop = parseInt(document.body.scrollTop)
var temp = document.getElementById('menulocker')
var mobilemenu2 = Math.abs(temp.value-1)
//var mobilemenu2 = Math.abs(temp.checked-1)

if(menutop != bodytop && mobilemenu2)
{
var menutop = parseInt(menu.style.top)
var bodytop = parseInt(document.body.scrollTop)
menutop += (menutop<bodytop)?menudist(menutop,bodytop):-1*menudist(menutop,bodytop);
menu.style.top = String(menutop) + 'px';
}

}

function dselect(doit)
{
if(doit)
sdisplay= 'hidden'
else
sdisplay= 'visible'

elements = document.getElementsByTagName('select')
for(x=0;x<elements.length;x++)
{
elements[x].style.visibility = sdisplay
}
}

function display(what,which)
{
var tempval=document.getElementById(what)
if(which==0)
tempval.style.display="none"
else
{
	if(which==1)
	tempval.style.display="block"
	else
	{
		if(which==2)
		{
			if(tempval.style.display=="none")
			tempval.style.display="block"
			else
			tempval.style.display="none"
		}
		else
		{
			tempval.style.display=which
		}
	}
}
}

function dswitch(what,who,nswitch)
{
var tempval=document.getElementById(what)
var temp = who + "_temp"
var who=document.getElementById(who)
var temp = document.getElementById(temp)

if(!nswitch)
temp.value = (temp.value == 0)?1:0

if(temp.value == 1)
{
tempval.style.display = (document.all)?'inline':'table';
who.value = 'Yes'
}
else
{
tempval.style.display = 'none'
who.value = 'No'
}
display('colorchart',0)
}

function getelementposition(which,what)
{
var temp = document.getElementById(which);
coords = new Array();
var x = 0;
var y = 0;
var yoff = temp.offsetHeight;
var xoff = temp.offsetWidth;
if(temp && typeof temp.offsetParent != 'undefined')
{
while(temp && typeof temp.offsetLeft == 'number')
{
x += temp.offsetLeft;
temp = temp.offsetParent;
}
var temp = document.getElementById(which);
while(temp && typeof temp.offsetTop == 'number')
{
y += temp.offsetTop;
temp = temp.offsetParent;
}
}
coords.xoff = xoff
coords.yoff = yoff
coords.x = x
coords.y = y
return coords;
}


function showcolors(where,forwhat)
{
fixoffset = 0;
forwhat = where
var coords = getelementposition(where)
var temp = document.getElementById('colorchart')
temp.style.top = coords.y + coords.yoff +'px'
temp.style.left = coords.x + 'px'
display('colorchart',1)
whichitem = forwhat
dselect(1)
}

function colorchoose(what)
{
var temp = document.getElementById('value_' + whichitem.substr(5))
var temp2 = document.getElementById(whichitem)
if(what)
{
temp.value = what
temp2.parentNode.parentNode.style.backgroundColor = what
}
else
{
temp2.parentNode.parentNode.style.backgroundColor = 'transparent';
temp.value = ''
}
}

function startcolors()
{
var x = 1
	while(document.getElementById('value_item' + x))
	{
		var temp = document.getElementById('value_item' + x)
		var temp2 = document.getElementById('pick_item' + x)
		if(temp.value != '')
		{
			temp2.parentNode.parentNode.style.backgroundColor = temp.value
		}
		x++
	}
}

function colorchoose2(which)
{
which = which.substr(6)
var temp = document.getElementById('box_' + which)
var temp2 = document.getElementById('value_' + which)
temp.style.backgroundColor = temp2.value
}
