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)"

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 = ""
		}
		
}

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)
{
//alert(thisPrinter)
if(viewerScreen > 800)
{
finalWidth = parseInt(thisWidth)
finalWidth = finalWidth + 40
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 = "product_display.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 viewOrder(thisOrder,thisWidth,thisHeight,business)
{
//alert(thisPrinter)
if(viewerScreen > 800)
{
finalWidth = parseInt(thisWidth)
finalWidth = finalWidth + 40
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 = ""
thisOrder = "full_" + business + "details.asp?item=" + thisOrder
//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 = thisOrder
	newWin.document.close()
	}
}








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 == "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 == "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 Product List','view')
  }
  
    else
  
  if(thisForm.options[thisOne].value == "bungs")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('Add','add')
	resortField.options[2] = new Option('Change','change')
	
  }
  
  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')
	resortField.options[4] = new Option('View User Details','view')
  }
  
  else
  
    if(thisForm.options[thisOne].value == "shows")
  {
    
	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 == "orders")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Select','')
	resortField.options[1] = new Option('View','view')
	resortField.options[2] = new Option('Delete','delete')
  }
  
  else
  
    if(thisForm.options[thisOne].value == "vat")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Change','change')
  }
  
    else
  
    if(thisForm.options[thisOne].value == "company")
  {
    
	resortField.length = 0
	
	resortField.options[0] = new Option('Change','change')
  }
  
  
}

function validateQty(service)
{


if(service.itemQty.value == "0")
  {
    alert("Please enter a quantity other than zero.");
    service.itemQty.focus();
	service.itemQty.select();
    return (false);
  }


var checkOK = "0123456789";
  var checkStr = service.itemQty.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 \"Quantity\" field.");
    service.itemQty.focus();
	service.itemQty.select();
    return (false);
  }

return (true);

}




function quickOrder_validate(service)
{

  if(service.item.value == "")
  {
    alert("Please enter the product code you wish to order.");
    service.item.focus();
	service.item.select()
    return (false);
  }


if(service.itemQty.value == "")
  {
    alert("Please enter the required quantity.");
    service.itemQty.focus();
	service.itemQty.select();
    return (false);
  }


var checkOK = "0123456789";
  var checkStr = service.itemQty.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 \"Quantity\" field.");
    service.itemQty.focus();
	service.itemQty.select();
    return (false);
  }

return (true);

}

function verify(enquiry)
{


    if(enquiry.address.value == "")
  {
    alert("Please enter the required delivery address.");
    enquiry.address.focus();
	enquiry.address.select();
    return (false);
  }
  
        if(enquiry.town.value == "")
  {
    alert("Please enter the appropriate town or city.");
    enquiry.town.focus();
	enquiry.town.select();
    return (false);
  }
  
  
 
   
      if(enquiry.country.value == "")
  {
    alert("A country is required as well as the full delivery address.");
    enquiry.country.focus();
	enquiry.country.select();
    return (false);
  }
  	
if(enquiry.phone.value == "")
  {
    alert("Please enter a contact telephone number.");
    enquiry.phone.focus();
	enquiry.phone.select();
    return (false);
  }
  
  
  
  var checkOK = "0123456789-+() \t\r\n\f";
  var checkStr = enquiry.phone.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.phone.focus()
	enquiry.phone.select()
    return (false);
  }
  

  if(enquiry.email.value == "")
  {
    alert("An E-mail address is required for sending your order confirmation.");
    enquiry.email.focus();
	enquiry.email.select()
    return (false);
   }
	
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.@-0123456789";
  var checkStr = enquiry.email.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("Your e-mail appears to include an invalid character, please check it carefully.\nIt should NOT contain a space, comma or tab, but  MUST include the \"@\" character.");
    enquiry.email.focus();
	enquiry.email.select();
    return (false);
  }
  
    if(enquiry.requestor.value == "")
  {
    alert("Please enter your name in the requestor field.");
    enquiry.requestor.focus();
	enquiry.requestor.select()
    return (false);
  }
  

return (true);
}


function verify_account(enquiry)
{

    if(enquiry.realname.value == "")
  {
    alert("Please enter your name.");
    enquiry.realname.focus();
	enquiry.realname.select()
    return (false);
  }
  
  
      if(enquiry.company.value == "")
  {
    alert("Please enter your company name.");
    enquiry.company.focus();
	enquiry.company.select()
    return (false);
  }

  	
if(enquiry.phone.value == "")
  {
    alert("Please enter a contact telephone number.");
    enquiry.phone.focus();
	enquiry.phone.select();
    return (false);
  }
  
  
  
  var checkOK = "0123456789-+() \t\r\n\f";
  var checkStr = enquiry.phone.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.phone.focus()
	enquiry.phone.select()
    return (false);
  }
  

  if(enquiry.email.value == "")
  {
    alert("Please supply a relevant E-mail address.");
    enquiry.email.focus();
	enquiry.email.select()
    return (false);
  }
  
 if(enquiry.address.value == "")
  {
    alert("Please enter the required delivery address.");
    enquiry.address.focus();
	enquiry.address.select();
    return (false);
  }
  
        if(enquiry.town.value == "")
  {
    alert("Please enter the appropriate town or city.");
    enquiry.town.focus();
	enquiry.town.select();
    return (false);
  }
  
  
          if(enquiry.postcode.value == "")
  {
    alert("Please also provide your postcode.");
    enquiry.postcode.focus();
	enquiry.postcode.select();
    return (false);
  }
  
   
      if(enquiry.country.value == "")
  {
    alert("A country is required as well as the full delivery address.");
    enquiry.country.focus();
	enquiry.country.select();
    return (false);
  }
  

return (true);

}

function focusOnLogin(field)
{
//alert(field)
document.forms[0][field].focus()
}
