// <!--- BEGIN FILE --->
// <!--- All programming, design, and Cold Fusion code copyright 2002-2006 Alaskan Star Interactive, All rights reserved. Code may not be reproduced without permission  --->
// <!--- COMMON JAVASCRIPT FOR ALL PAGES --->
var nslayer = (document.layers)  ? 1:0;
var ielayer = (document.all)  ? 1:0;
var do_submit = "";

function checkform() {
do_submit = "YES";

if(do_submit=="YES") {
if(document.foreform.first.value=='')
{alert("Please enter a FIRST NAME.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.first.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
if(document.foreform.last.value=='')
{alert("Please enter a LAST NAME.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.last.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
if(document.foreform.address1.value=='')
{alert("Please enter an ADDRESS.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.address1.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
if(document.foreform.city.value=='')
{alert("Please enter a CITY.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.city.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
if(document.foreform.state.value=='')
{alert("Please enter a STATE.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.state.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
if(document.foreform.zip.value=='')
{alert("Please enter a ZIP.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.zip.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
if (checkemail(document.foreform.email.value)==false)
{alert("Please enter a valid EMAIL.          ");
if(nslayer==1 || ielayer==1)
{document.foreform.email.focus()}
do_submit="NO"}}

if(do_submit=="YES") {
document.foreform.submit();
}
}


function checkemail(the_value) {
// Checks the email field for:
// 1. must be at least 6 characters long i.e. 1@3.56
// 2. cannot begin with a "@" or a "."
// 3. cannot end with a "@" or a "."
// 4. cannot have 2 "." in a row
// 5. cannot have ".@" nor "@."
// 6. must contain 1 "@" and at least 1 "."
// 7. must have 2 or 3 characters after the final "."
// 8. checks specified bad chars like commas
var amp1 = 0;
var dot1 = 0;
var postdot1 = 0;
if (the_value.length<6)
{return false}
if (the_value.charAt(0)=='.')
{return false}
if (the_value.charAt(the_value.length)=='.')
{return false}
if (the_value.charAt(0)=='@')
{return false}
if (the_value.charAt(the_value.length)=='@')
{return false}
amp1 = 0;
dot1 = 0;
postdot1 = 0;
for (var i = 0; i < the_value.length; i++)
{
if (the_value.charAt(i)==',') // add bad chars here
{return false}
if (the_value.charAt(i)=='@')
{if (the_value.charAt(i-1)=='.')
{return false}
amp1=amp1+1}
if (the_value.charAt(i)=='.')
{if (the_value.charAt(i-1)=='.')
{return false}
if (the_value.charAt(i-1)=='@')
{return false}
if (dot1>0)
{dot1=0;
postdot1=0}
dot1=dot1+1}
if (dot1>0)
{postdot1=postdot1+1}
}
if (amp1!=1)
{return false}
if (dot1<1)
{return false}
if (postdot1!=5 && postdot1!=4 && postdot1!=3)
{return false}
return true
}
// 


// Browser detect
var doit = false

with(navigator) {
  code = appCodeName; 
  app = appName; 
  version = appVersion; 
  iver = parseInt(version); 
  ua = userAgent;
  }

// this will work in "Mozilla" 3+ (includes MSIE 4)
if ( code == "Mozilla" && iver >= 3 )
{doit = true}
else 
{doit = false}

if (doit==true)
{
if(document.images) {
// Main Rollover ON Graphics (when moused over)
submit_buton = new Image();  submit_buton.src = "images/submit_on.gif";
reset_buton = new Image();  reset_buton.src = "images/reset_on.gif";


// Main Rollover OFF Graphics (when NOT moused over)
submit_butoff = new Image();  submit_butoff.src = "images/submit_off.gif";
reset_butoff = new Image();  reset_butoff.src = "images/reset_off.gif";

}
}

// Main Rollover Functions (ON and OFF)
function turnOn(imageName) {
if (doit==true)
{if(document.images) {
    document[imageName].src = eval(imageName + "on.src"); }}
}        
function turnOff(imageName) {
if (doit==true)
{if(document.images) {
    document[imageName].src = eval(imageName + "off.src"); }}
}

var the_iframe = "";
var the_subdiv = "";
var whataction = "";

function subturn(objectnumber,the_action) {
<!--- <CFIF #parameterexists(is_mac)#><CFIF #trim(is_mac)# IS "NO">the_iframe =  "iframe_"+objectnumber;</CFIF></CFIF> --->
the_subdiv = "subdiv_"+objectnumber;
whataction = "";
if(the_action=="open") {whataction = "visible"} // open
if(the_action=="close") {whataction = "hidden"} // close
if(whataction!="") {
	if (moz5) {
	<!--- <CFIF #parameterexists(is_mac)#><CFIF #trim(is_mac)# IS "NO">document.getElementById(the_iframe).style.visibility=whataction;</CFIF></CFIF> --->
	document.getElementById(the_subdiv).style.visibility=whataction;
	}
	if (ns4) {
	<!--- <CFIF #parameterexists(is_mac)#><CFIF #trim(is_mac)# IS "NO">document.layers[the_iframe].style.visibility=whataction;</CFIF></CFIF> --->
	document.layers[the_subdiv].style.visibility=whataction;
	}
	if (ie4) {
	<!--- <CFIF #parameterexists(is_mac)#><CFIF #trim(is_mac)# IS "NO">document.all[the_iframe].style.visibility=whataction;</CFIF></CFIF> --->
	document.all[the_subdiv].style.visibility=whataction;
	}
}
}        
//-->
<!--- END OF FILE --->

