var screensize = window.screen.width

if(screensize < 800)
	{window.location.href="resolution.asp"}

var version = navigator.appVersion
var offset = ""
offset = version.indexOf("MSIE")
version = version.charAt(offset + 5)

//alert(navigator.appVersion)
var isNav, isIe

if(navigator.appName.indexOf("Netscape") != -1)
	{isNav = true}
else

if(navigator.appName.indexOf("Microsoft") != -1)
	{isIe = true}


function setBackground(thisOne,thisImage,thisColour)

{

			var obj
thisImage = "url(images/" + thisImage + ".gif)"
//alert(thisImage)
if (document.all)
		{
		
		obj = document.all(thisOne).style.backgroundImage = thisImage
		thisOne = "a" + thisOne
		obj = document.all(thisOne).style.color = thisColour		
		}
		
	else if (document.getElementById)
		{
		//alert("netscapev6+")
		obj = document.getElementById(thisOne).style.backgroundImage = thisImage
		thisOne = "a" + thisOne
		obj = document.getElementById(thisOne).style.color = thisColour
		}
		
	else if (document.layers)
		{
		//alert("netscapev4")
		obj = ""
		}		
}

function resetBackground(thisOne,thisImage,thisColour)

{
			var obj
thisImage = "url(images/" + thisImage + ".gif)"

if (document.all)
		{
		
	//alert("IE")
		obj = document.all(thisOne).style.backgroundImage = thisImage
		thisOne = "a" + thisOne
		obj = document.all(thisOne).style.color = thisColour		
		}
		
	else if (document.getElementById)
		{
		//alert("netscapev6+")
		obj = document.getElementById(thisOne).style.backgroundImage = thisImage
		thisOne = "a" + thisOne
		obj = document.getElementById(thisOne).style.color = thisColour
		}
		
	else if (document.layers)
		{
		//alert("netscapev4")
		obj = ""
		}
}





var finalWidth = ""
var screenRes = window.screen.width /2
var viewerScreen = window.screen.width
var leftAnchor = ""

function create(thisWidth,thisHeight,thisProduct)
{

if (parseInt(thisWidth) < 300 )
{thisWidth = 360}
//alert(thisWidth)

if(viewerScreen > 800)
{
finalWidth = parseInt(thisWidth)
finalWidth = finalWidth + 50
finalHeight = parseInt(thisHeight)
finalHeight = finalHeight + 10
}

else

{
finalWidth = parseInt(thisWidth)
finalWidth = finalWidth + 40
finalHeight = parseInt(thisHeight)
finalHeight = finalHeight + 10
}





leftAnchor = screenRes - (finalWidth / 2)
//alert("status=no,toolbar=no,title=no,location=no,scrollbars=yes,resizable=yes,screenX=100,left=" + leftAnchor + ", top=0")
//alert(finalWidth)



var writeBody = ""
thisProduct = "view_dessert.asp?action=display&id=" + thisProduct
//alert(thisProduct)
var newWin = window.open("","","status=no,toolbar=no,title=no,location=no,scrollbars=yes,resizable=yes,screenX=100,left=" + leftAnchor + ", top=0")
//alert(newWin.value)
if(newWin!=null || newWin.closed)

	{
	newWin.window.resizeTo(finalWidth,finalHeight)
	newWin.location = thisProduct
	newWin.document.close()
	}
}

function directions(thisWidth,thisHeight)
{

//alert(thisPrinter)
if(viewerScreen > 800)
{
finalWidth = parseInt(thisWidth)
finalWidth = finalWidth + 50
finalHeight = parseInt(thisHeight)
finalHeight = finalHeight + 10
}

else

{
finalWidth = parseInt(thisWidth)
finalWidth = finalWidth + 40
finalHeight = parseInt(thisHeight)
finalHeight = finalHeight + 10
}

leftAnchor = screenRes - (finalWidth / 2)
//alert("status=no,toolbar=no,title=no,location=no,scrollbars=yes,resizable=yes,screenX=100,left=" + leftAnchor + ", top=0")
//alert(finalWidth)



var writeBody = ""
thisProduct = "directions.asp"
//alert(thisProduct)
var newWin = window.open("","","status=no,toolbar=no,title=no,location=no,scrollbars=yes,resizable=yes,screenX=100,left=" + leftAnchor + ", top=0")
//alert(newWin.value)
if(newWin!=null || newWin.closed)

	{
	newWin.window.resizeTo(finalWidth,finalHeight)
	newWin.location = thisProduct
	newWin.document.close()
	}
}


function focusOnUser()
{
obj.username.focus()
}


function goSend()
{
//alert("send")
document.forms[0].submit()

}


function setOptions()
{
var thisForm = document.forms[0].section
var resortField = document.forms[0].action
var thisOne = parseInt(thisForm.selectedIndex)

//alert(thisOne)

	  
  if(thisForm.options[thisOne].value == "products")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('Add','add')
	resortField.options[2] = new Option('Change','change')
	resortField.options[3] = new Option('Delete','delete')
	resortField.options[4] = new Option('New Image','image')
	resortField.options[5] = new Option('Full Dessert List','view')
  }
  
  
  
  else
  
    if(thisForm.options[thisOne].value == "users")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('Add','add')
	resortField.options[2] = new Option('Change','change')
	resortField.options[3] = new Option('Delete','delete')
  }
  
  
  else
  
    if(thisForm.options[thisOne].value == "links")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('Add','add')
	resortField.options[2] = new Option('Change','change')
	resortField.options[3] = new Option('Delete','delete')
  }
  
    else
  
    if(thisForm.options[thisOne].value == "categories")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('Add','add')
	resortField.options[2] = new Option('Change','change')
	resortField.options[3] = new Option('Delete','delete')
  }
 
     else
  
    if(thisForm.options[thisOne].value == "company")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('Change','change')

  }
 
}


function verify(enquiry)
{


    if(enquiry.contactName.value == "")
  {
    alert("Please enter a contact name.");
    enquiry.contactName.focus();
	enquiry.contactName.select();
    return (false);
  }
  

if(enquiry.contactPhone.value == "")
  {
    alert("Please enter a contact telephone number.");
    enquiry.contactPhone.focus();
	enquiry.contactPhone.select();
    return (false);
  }
  
  
  
  var checkOK = "0123456789-+() \t\r\n\f";
  var checkStr = enquiry.contactPhone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digits in the \"phone\" field.");
    enquiry.contactPhone.focus()
	enquiry.contactPhone.select()
    return (false);
  }
  

  if(enquiry.contactEmail.value == "")
  {
    alert("An E-mail address is preferred, to allow us to respond to your enquiry.\nIf you don't have an eMail address, type in n/a.");
    enquiry.contactEmail.focus();
	enquiry.contactEmail.select()
    return (false);
  }
  
    
return (true);
}



var fromHere = ""
var counter = 0
var imageSelected = ""
var paneSelected = ""
var showPane = ""
var t = ""

var showImages = new Array()

//This array holds the string names of the actual images we will be changing
var whichOne = new Array()
whichOne[0] = "one"
whichOne[1] = "two"
whichOne[2] = "three"

//This array holds the names of the first x-number of images on the screen, vary as required to reach the upper image to be changed
var currentImages = new Array(4)
currentImages[0] = ""
currentImages[1] = ""
currentImages[2] = ""
currentImages[3] = ""




function count_images()
{
counter++
if(counter < 9)
	{
	loadImages()
	}


else
	{
	runShow()
	}


}

function loadImages()
{
showImages[counter] = new Image();
showImages[counter].onload = count_images
showImages[counter].src = "images/window_pane/" + counter + ".jpg";
}

function runShow()
{
var currentImage = ""
var gotMatch = false
//This is the pane we will update
paneSelected = whichOne[Math.round(Math.random() * 2)]
//alert(paneSelected)


//store all of the current file names
for(i=1; i<4; i++)
{
currentImages[i] =  document.images[i].src.substr(document.images[i].src.lastIndexOf("/")+1, document.images[i].src.length)
//alert(currentImages[i])
}


//select a new image at random to show
var numberSelected = Math.round(Math.random() * 8)
imageSelected = "images/window_pane/" + numberSelected + ".jpg".toString()


//check the number of the image selected against all those currently displayed
for(i=1; i<=3; i++)
{
	if(imageSelected == ("images/window_pane/" + currentImages[i]))
		{gotMatch = true
		//if they are equal break out
		//alert(gotMatch)
		break
		
		}

}


if(!gotMatch)
	{
	setTimeout("document." + paneSelected + ".src = imageSelected,runShow()	", 2000)
	}
	
	else
	
	{
	setTimeout("runShow()", 2000)
	}
	
}

function focusOnLogin(field)
{
//alert(field)
document.forms[0][field].focus()
}

function setIndent(field)

{
//alert(field)
document.getElementById(field).style.textDecoration="underline"
}

function resetIndent(field)

{
//alert(field)
document.getElementById(field).style.textDecoration="none"
}
