var escapetimes=0;
var escapetimer;
var saveurl='';

function framesync()
{
    var currentUrl = top.view.location.href;

    if (currentUrl != top.saveUrl && top.saveUrl != '')
	{
        top.edit.location.href = currentUrl + 'manage.html';
    }
    top.saveUrl = currentUrl;
    setTimeout('top.framesync()',100);
}

function framesync2()
{
	var newurl = top.edit.location.href;
	newurl = newurl.replace(/manage\.html$/gi,'');

	if ( top.view.location.href != newurl )
    	top.view.location.href = newurl;
}

function findframe(name)
{
    for (var i=0;i<parent.frames.length;i++) {
         if (parent.frames[i].name == name)
             return parent.frames[i];
    }
    return false;
}

function keypress1()
{
    if (window.event.keyCode == 27)
    {
	    clearTimeout(escapetimer);
    	escapetimes++;
    	if ( escapetimes >= 3 )
    	{
    	    clearkeypress();
    	    if ( findframe('edit') )
			{
				window.top.location.href='./';
			}
			else
			{
				window.top.location.href='admin';
			}
		}
		else
		{
			escapetimer = setTimeout('clearkeypress()',2500);
		}
	}
}

function clearkeypress()
{
	/*alert('cleared');*/
   	escapetimes=0;
}

function newWin(symbol)
{
	window.open(symbol,"",'width=200,height=200,left=100,screenX=100,top=50,screenY=50,scrollbars');
}

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://artcobell.com/products/lines/Sagus%20Archetype/">Archetype</a>'
menu1[1]='<a href="/products/lines/discover/">Discover</a>'
menu1[2]='<a href="/products/lines/prodigy/">Prodigy</a>'
menu1[3]='<a href="/products/lines/uniflex/">Uniflex</a>'
menu1[4]='<a href="/products/lines/plastic/">Solid Plastic</a>'
menu1[5]='<a href="/products/categories/chairs/">Chairs</a>'
menu1[6]='<a href="/products/categories/students/">Student Desks</a>'
menu1[7]='<a href="/products/categories/combos/">Chair Desk Combinations</a>'
menu1[8]='<a href="/products/categories/computers/">Computer Furniture</a>'
menu1[9]='<a href="/products/categories/tables/">Activity Tables</a>'
menu1[10]='<a href="/products/categories/teachers/">Teacher\'s Desks</a>'
menu1[11]='<a href="/products/categories/stools/">Stools</a>'
menu1[12]='<a href="/products/categories/accessories/">Accessories</a>'
menu1[13]='<a href="/products/lines/Catalyst/">Catalyst</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="#">test</a>'
menu2[1]='<a href="#">test</a>'
menu2[2]='<a href="#">test</a>'

var menuwidth='210px' //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 editing needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" 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

// main contact form
function submitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.name.value.length < 1) {
		alert("Please enter your first name.");
		document.theForm.name.focus();
		return;
	} else if(document.theForm.lastname.value.length < 1) {
		alert("Please enter your last name.");
		document.theForm.lastname.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone1.value.length < 3) {
		alert("Please enter your area code.");
		document.theForm.phone1.focus();
		return;
	} else if(document.theForm.phone2.value.length < 3) {
		alert("Please enter your phone prefix.");
		document.theForm.phone2.focus();
		return;
	} else if(document.theForm.phone3.value.length < 4) {
		alert("Please enter your phone number.");
		document.theForm.phone3.focus();
		return;
	} else if(document.theForm.state.value.length < 1) {
		alert("Please select your state of residence.");
		document.theForm.state.focus();
		return;
	} else if(document.theForm.source.value.length < 1) {
		alert("Please indicate how you found us.");
		document.theForm.source.focus();
		return;
	}
	document.theForm.submit();
}

// Search Submit
function ssubmitForm() {
	document.searchForm.submit();
}

// dealer contact form
function dsubmitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.fname.value.length < 1) {
		alert("Please enter your first name.");
		document.theForm.fname.focus();
		return;
	} else if(document.theForm.lname.value.length < 1) {
		alert("Please enter your last name.");
		document.theForm.lname.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone1.value.length < 3) {
		alert("Please enter your area code.");
		document.theForm.phone1.focus();
		return;
	} else if(document.theForm.phone2.value.length < 3) {
		alert("Please enter your phone prefix.");
		document.theForm.phone2.focus();
		return;
	} else if(document.theForm.phone3.value.length < 4) {
		alert("Please enter your phone number.");
		document.theForm.phone3.focus();
		return;
	} else if(document.theForm.state.value.length < 1) {
		alert("Please select your state of residence.");
		document.theForm.state.focus();
		return;
	} else if(document.theForm.source.value.length < 1) {
		alert("Please indicate how you found us.");
		document.theForm.source.focus();
		return;
	}
	document.theForm.submit();
}

// request catalog contact form
function rcsubmitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.name.value.length < 1) {
		alert("Please enter your first name.");
		document.theForm.name.focus();
		return;
	} else if(document.theForm.lastname.value.length < 1) {
		alert("Please enter your last name.");
		document.theForm.lastname.focus();
		return;
	} else if(document.theForm.organization.value.length < 1) {
		alert("Please enter your organization.");
		document.theForm.organization.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone.value.length < 3) {
		alert("Please enter your phone number.");
		document.theForm.phone.focus();
		return;
	} else if(document.theForm.city.value.length < 1) {
		alert("Please select your city.");
		document.theForm.city.focus();
		return;
	} else if(document.theForm.state.value.length < 1) {
		alert("Please select your state of residence.");
		document.theForm.state.focus();
		return;
	} else if(document.theForm.zip.value.length < 1) {
		alert("Please select your zip or mail code.");
		document.theForm.zip.focus();
		return;
	} else if(document.theForm.country.value.length < 1) {
		alert("Please indicate how your country.");
		document.theForm.country.focus();
		return;
	}
	document.theForm.submit();
}

// request spec contact form
function rssubmitForm() {
emailRegEx = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if(document.theForm.model.value.length < 1) {
		alert("Please select a model series.");
		document.theForm.model.focus();
		return;
	} else if(document.theForm.name.value.length < 1) {
		alert("Please enter your name.");
		document.theForm.name.focus();
		return;
	} else if(document.theForm.organization.value.length < 1) {
		alert("Please enter your organization.");
		document.theForm.organization.focus();
		return;
	} else if(! emailRegEx.test(document.theForm.email.value)) {
		alert("Please enter a valid email address.");
		document.theForm.email.focus();
		return;
	} else if(document.theForm.phone.value.length < 10) {
		alert("Please enter your phone.");
		document.theForm.phone.focus();
		return;
	}
	document.theForm.submit();
}

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 1500;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();

// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
