



//  Copyright Lonni Clarke Fine Art, 2003. All of this code is the
//  copyrighted work of Lonni Clarke Fine Art. All Rights Reserved.
//  Any redistribution or reproduction of any materials
//  herein is strictly prohibited.

//  This code was written by Sue Bolander, Webworks7, Saint George, Utah
//  http://www.webworks7.com

// ---------------------------------------------------------------------

// Prevent this site from being framed

if(window != top)
{
window.open(location.href);
history.go(-1);
}

// ---------------------------------------------------------------------

// Select image for Home page

function pickPhoto()

{

var Photos = new Array(3);

Photos[0] = 'home_2.jpg'
Photos[1] = 'home_3.jpg'
Photos[2] = 'home_4.jpg'

n = Math.round(Math.random() * 2);

document.images.randomphoto.src=Photos[n];

}

// ---------------------------------------------------------------------

// Prevent right click image downloads

var mousebutton=0;
function displayCopyrightMessage(mousebutton)
{

  if ((navigator.appName == 'Netscape' && mousebutton.which==3) || (navigator.appName == 'Microsoft Internet Explorer' && event.button == 2))
  {
  alert('Sorry, all images and source code on these pages are protected by copyright and are not available for reproduction.');
  return false;
  }
  else
  {  
    return true;
  }

}

// ---------------------------------------------------------------------

// Script for Order Form


var price_paper = 272.00
var price_canvas = 372.00


function checkNumber(inputString,fieldname)

{
  var thisform = document.forms[2]

  for(var n=0; n < thisform.elements.length ; n++)
    {  
      if(thisform.elements[n].name == fieldname)  
      {      
        break
      }
    }


  for (var i = 0; i < inputString.length; i ++)
  {
    var oneChar = inputString.substring(i, i + 1)
    if (oneChar < "0" || oneChar > "9" || oneChar == ".")
    {
      alert("Please Enter only whole numbers in this field. If you made an entry by mistake, change it to blank or zero.       Thanks!")
      thisform.elements[n].focus()
      thisform.elements[n].select()
      return false
    }
  }
  calculate(thisform)
  return true
}

function format (expression, decplaces)
{
  var string = "" + Math.round(eval(expression) * Math.pow(10,decplaces))
  while(string.length <= decplaces)
  {
    string = "0" + string
  }
  var decpoint = string.length - decplaces
  return string.substring(0,decpoint) + "." + string.substring(decpoint,string.length)
}

function calculate(form)
{
    var totalprice = 0
    if(form.Number_of_paper_prints.value != "")
    {
      totalprice += parseFloat(form.Number_of_paper_prints.value)*price_paper
    }

  if(form.Number_of_canvas_prints.value != "")
    {
      totalprice += parseFloat(form.Number_of_canvas_prints.value)*price_canvas
    }

    form.total_price.value = format(totalprice,2)
  
}


function checkItOut()
{
  var form = document.forms[2]

  if (VerifyIt(form))
  {
    return true   
  }

  return false
}

function VerifyIt(form)

{
  var confirmed = false

  if (form.Name.value == "")
  {
    alert("Please fill in your name.")
    form.Name.focus()	
    return false 			
  }

 if (form.Address.value == "")
  {
    alert("Please fill in your address.")
    form.Address.focus()	
    return false 			
  }

  if (form.City.value == "")
  {
    alert("Please fill in your city name.")
    form.City.focus()	
    return false 			
  }

  if (form.State.value == "")
  {
    alert("Please fill in your state.")
    form.State.focus()	
    return false 			
  }
  if (form.Zip.value == "")
  {
    alert("Please fill in your zip code.")
    form.Zip.focus()	
    return false 			
  }
if (form.Area_Code.value == "")
  {
    alert("Please fill in your area code.")
    form.Area_Code.focus()	
    return false 			
  }

if (form.Phone.value == "")
  {
    alert("Please fill in your phone number.")
    form.Phone.focus()	
    return false 			
  }

  if (form.email.value == "")
  {
    alert("Please fill in your e-mail address.")
    form.email.focus()
    return false 		
  }

  if (!isEmail(form.email.value) && form.email.value != "")
  {
    alert("Please enter a valid e-mail address.")
    form.email.focus()
    return false 		
  }

  if ((form.Number_of_paper_prints.value == "") && (form.Number_of_canvas_prints.value == ""))
  {
    alert("Please fill in the number prints that you would like to order.")
    form.Number_of_paper_prints.focus()	
    return false 			
  }

 if ((form.Payment_Method[0].checked!=true) && (form.Payment_Method[1].checked!=true))
  {
    alert("Please click a button for your payment method.")
    form.Payment_Method[0].focus()
    return false 			
  }

 
  alert("Your printer will now print your order form.")
  window.print()
  return true


 

}

/*----------------------------------------*/

function isEmail(inputVal)

{
  var atsymbol = false
  var dot = false
     
  inputStr = inputVal.toString()

  if (inputStr.charAt(0) == "@")
    {
      return false
    }

  for (var i = 0; i < inputStr.length; i++)
  { 
    if (inputStr.charAt(i) == "/" || inputStr.charAt(i) == ":" || inputStr.charAt(i) == ";"
            || inputStr.charAt(i) == ",")
    {
      return false
    }
     
    if (inputStr.charAt(i) == "@" && atsymbol)
    {
      return false
    }

    if (inputStr.charAt(i) == "@" && !atsymbol)
    {
      var atsymbol = true

      if (inputStr.substring(i+1, i+2) == "." || inputStr.substring(i+1, i+2) == " ")
      {
        return false
      }
    }
       
    if (inputStr.charAt(i) == ".")
    {
                
      if (atsymbol == true)
      {
        var dot = true
      }
           
      if (inputStr.substring(i+1, i+2) == "")
      {
        return false
      }

    }
       
  }

  if (atsymbol == false || dot == false)
  {
    return false
  }

  while (inputStr.charAt(i) != "." && i > 0)
  {
    i--
  }  
  
  if (inputStr.toLowerCase().substring(i+1) != "com"
         && inputStr.toLowerCase().substring(i+1) != "net"
         && inputStr.toLowerCase().substring(i+1) != "edu"
         && inputStr.toLowerCase().substring(i+1) != "gov"
         && inputStr.toLowerCase().substring(i+1) != "org"
         && inputStr.toLowerCase().substring(i+1) != "us"
         && inputStr.toLowerCase().substring(i+1) != "biz"
         && inputStr.toLowerCase().substring(i+1) != "info")
  {
    return DomainConfirm()
  }
    else
  {
    confirmed = true
    return true
  }

  return false
}

/*-----------------------------*/

function DomainConfirm()

{
  return window.confirm("This is not a typical United States domain name - is this e-mail address correct?")
}





