//jQuery functions
$(function() {
	/*	   
	$("#accordion").accordion({
	autoHeight: false,
	collapsible: true,
	active: false,
	header: 'h3'
	});
	*/
	$("#contentfooter").accordion({
	//autoHeight: false,
	collapsible: true,
	active: false,
	header: 'h3'
	});

});
//jQuery

var myEffect;

function newWindow(file,window) {
	msgWindow=open(file,window,'resizable=no,width=400,height=200');
	if (msgWindow.opener == null) msgWindow.opener = self;
}
    
function validate_scheduling() {
	var captcha = document.getElementById('captcha').value;
	new Ajax.Request('http://www.illuminationslighting.com/checkCaptcha.asp', {method:'post', postBody:'captcha=' + captcha, onSuccess:validate2, onFailure:captchaFail});
	return false;
	
	function validate2(t)
	{
		var imgver = t.responseText;	
		mNv=document.scheduling.txtName.value;
		mCv=document.scheduling.contact.value;
		
		if (mNv=='') {
		alert('Your name is a required field. Please try again.');
		return (false);
		}
		if (mCv != 'Contact me by phone' && mCv != 'Contact me by email') {
		alert('You must choose a way for us to contact you.  Please try again.');
		return (false);
		}
		if (mCv=='Contact me by phone' && (document.scheduling.txtHome.value=='' || document.scheduling.txtCell.value=='')) {
		alert('You must enter a phone number.  Please Try Again.');
		return (false);
		}
		if (mCv=='Contact me by email' && document.scheduling.txtEmail.value=='') {
		alert('You must enter an email address.  Please try again.');
		return (false);
		}
		if (imgver!='true')
		{
		alert('Image verification failed.  Please retype the code shown, or request a new image.');
		document.scheduling.captcha.focus();
		return false;
		}
		document.scheduling.submit();
	}
	
	function captchaFail()
	{
			alert('Image verification failed.  Please retype the code shown, or request a new image.');
			document.scheduling.captcha.focus();
			return false; 
	}
}

	    
function generateCap()
{
	var IMG = document.getElementById('captchaIMG');
	IMG.src = "http://www.illuminationslighting.com/aspcaptcha.asp?rnd_num=" + randomString();
}

function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function validate_employment()
{
	var captcha = document.getElementById('captcha').value;
	new Ajax.Request('http://www.illuminationslighting.com/checkCaptcha.asp', {method:'post', postBody:'captcha=' + captcha, onSuccess:validate_form2, onFailure:captchaFail});
	return false;
		
	function validate_form2(t)
	{	
		var imgver = t.responseText;	

		if (document.frmContact.txtName.value=='')
		{
			alert('Please enter your name before submitting this form.');
			document.frmContact.txtName.focus();
			return false;
		}
		else if (document.frmContact.txtPhone.value=='')
		{
			alert('Please enter your phone number before submitting this form.');
			document.frmContact.txtPhone.focus();
			return false;
		}
		else if (document.frmContact.txtEmail.value=='')
		{
			alert('Please enter your email address.  Note: we will not share your email address with any third parties.');
			document.frmContact.txtEmail.focus();
			return false;
		}
		else if (document.frmContact.txtDob.value=='')
		{
			alert('Please enter your date of birth.');
			document.frmContact.txtDob.focus();
			return false;
		}		else if (imgver!='true')
		{
			alert('Image verification failed.  Please retype the code shown, or request a new image.');
			document.frmContact.captcha.focus();
			return false;
		}
		else	
		{
		document.frmContact.submit();
		}
	}
	
	function captchaFail()
	{
			alert('Image verification failed.  Please retype the code shown, or request a new image.');
			document.frmContact.captcha.focus();
			return false; 
	}
}

function validate_form()
{
	var captcha = document.getElementById('captcha').value;
	new Ajax.Request('http://www.illuminationslighting.com/checkCaptcha.asp', {method:'post', postBody:'captcha=' + captcha, onSuccess:validate_form3, onFailure:captchaFail2});
	return false;
		
	function validate_form3(t)
	{	
		var imgver = t.responseText;	

		if (document.frmContact.txtName.value=='')
		{
			alert('Please enter your name before submitting this form.');
			document.frmContact.txtName.focus();
			return false;
		}
		else if (document.frmContact.txtPhone.value=='')
		{
			alert('Please enter your phone number before submitting this form.');
			document.frmContact.txtPhone.focus();
			return false;
		}
		else if (document.frmContact.txtEmail.value=='')
		{
			alert('Please enter your email address.  Note: we will not share your email address with any third parties.');
			document.frmContact.txtEmail.focus();
			return false;
		}
		else if (imgver!='true')
		{
			alert('Image verification failed.  Please retype the code shown, or request a new image.');
			document.frmContact.captcha.focus();
			return false;
		}
		else	
		{
		document.frmContact.submit();
		}
	}
	
	function captchaFail2()
	{
			alert('Image verification failed.  Please retype the code shown, or request a new image.');
			document.frmContact.captcha.focus();
			return false; 
	}
}
	
function validate_expert()
	{
	if (document.FrontPage_Form1.txtName.value=='')
	{
		alert('Please enter your name before submitting this form.');
		document.FrontPage_Form1.txtName.focus();
		return false;
	}
	else if (document.FrontPage_Form1.txtEmail.value=='')
	{
		alert('Please enter your email address.  Note: we will not share your email address with any third parties.');
		document.FrontPage_Form1.txtEmail.focus();
		return false;
	}
	else
	{
	return true;
	}
	}
	
function needsother()
    
    
    {
    
    if (document.scheduling.needs.selectedIndex == 7)
    	{
        document.getElementById("needsr").style.display='block';
    	}
    else
    {
        //document.getElementById("needsr").style.display='block';
    	}
    
    }
    
function assistother()
    
    
    {
    
    if (document.scheduling.assist.selectedIndex == 13)
    	{
        document.getElementById("assistr").style.display='block';
    	}
    else
    {
        //document.getElementById("assistr").style.display='block';
    	}
    
    }
    
function natureother()
    {
    
    if (document.scheduling.nature.selectedIndex == 6)
    	{
        document.getElementById("naturer").style.display='block';
    	}
    else
    {
        //document.getElementById("naturer").style.display='block';
    	}
    }

function newcustomer()
{
	if (document.scheduling.customer.selectedIndex == 1)
    	{
    	document.getElementById("addressr").style.display='block';   	
    	document.getElementById("cityr").style.display='block';
    	document.getElementById("emailr").style.display='block';
    	document.getElementById("homer").style.display='block';
    	document.getElementById("cellr").style.display='block';
    	document.getElementById("workr").style.display='block';
    	}
    	
    else 
    {
    	//document.getElementById("accountr").style.display='block';
    }

}

function contact1()
{
	if (!(document.scheduling.customer.selectedIndex == 1) && ((document.scheduling.contact.selectedIndex > 0) && (document.scheduling.contact.selectedIndex < 4)))
    	{
    	document.getElementById("homer").style.display='block';
    	document.getElementById("cellr").style.display='block';
    	document.getElementById("workr").style.display='block';
    	
    	}
    else if (!(document.scheduling.customer.selectedIndex == 1) && document.scheduling.contact.selectedIndex == 4)
    	{
    	document.getElementById("emailr").style.display='block';
    	}
}

function validate_creditapp()
	{
	var errs = 0;
	var missingdata = '';
	if (document.frmCredit.Legal_Company_Name.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your company name.';
		}
	if (document.frmCredit.Billing_Address.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your billing address.';
		}		
	if (document.frmCredit.Physical_Address.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your physical address.';
		}
	if (document.frmCredit.Telephone.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your telephone number.';
		}	
	if (document.frmCredit.Fax.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your fax number.';
		}
	if (document.frmCredit.Type_of_Business.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your type of business.';
		}		
	if (document.frmCredit.Website_URL.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your website URL.';
		}
	if (document.frmCredit.Email_Address.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your email address.';
		}		
	if (document.frmCredit.Number_years_in_Business.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter the number of years you have been in business.';
		}
	if (document.frmCredit.Proprietorship.checked==false && document.frmCredit.Partnership.checked==false && document.frmCredit.Corporation.checked==false)
		{
		errs++;
		missingdata = missingdata + '\nYou must select the legal structure of your business.';
		}		
	if (document.frmCredit.Corporation.checked==false && document.frmCredit.Date_Incorporated.value=='')
		{
		errs++;
		missingdata = missingdata + '\nIf your business is a corporation, you must enter the date you were incorporated.';
		}
	if (document.frmCredit.State_of.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter the state in which your company is doing business.';
		}		
	if (document.frmCredit.Federal_Tax_ID.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your company\'s Federal Tax ID.';
		}
	if (document.frmCredit.Owner_Partner_Officer.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter at least one Owner/Officer name.';
		}		
	if (document.frmCredit.Title.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter an Owner/Officer title.';
		}
	if (document.frmCredit.Registered_Agent.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter a registered agent name.';
		}
	if (document.frmCredit.Registered_Agent.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your registered agent\'s address.';
		}
	if (document.frmCredit.Acct_Payable_Manager.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter the name of your accounts payable manager.';
		}
	if (document.frmCredit.Authorized_Purchasers.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must a name of an authorized purchaser.';
		}
	if (document.frmCredit.Purchase_Order_Required_Yes.checked==false && document.frmCredit.Purchase_Order_Required_No.checked==false)
		{
		errs++;
		missingdata = missingdata + '\nYou must indicate whether your business requires purchase orders.';
		}
	if (document.frmCredit.Amt_Credit_Desired.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter the amount of credit desired.';
		}
	if (document.frmCredit.Bank_Name.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your bank\s name.';
		}
	if (document.frmCredit.Bank_Address.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your bank\'s address.';
		}
	if (document.frmCredit.Bank_Officer.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter the name of your bank officer.';
		}
	if (document.frmCredit.Bank_Telephone.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your bank\'s telephone number.';
		}
	if (document.frmCredit.Operating_Acct.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your primary account number.';
		}
	if (document.frmCredit.Trade_Name1.value=='' || document.frmCredit.Trade_Telephone1.value=='' || document.frmCredit.Trade_Address1.value=='' || document.frmCredit.Trade_Fax1.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must complete all reference information.';
		}
	if (document.frmCredit.Trade_Name2.value=='' || document.frmCredit.Trade_Telephone2.value=='' || document.frmCredit.Trade_Address2.value=='' || document.frmCredit.Trade_Fax2.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must complete all reference information.';
		}
	if (document.frmCredit.Trade_Name3.value=='' || document.frmCredit.Trade_Telephone3.value=='' || document.frmCredit.Trade_Address3.value=='' || document.frmCredit.Trade_Fax3.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must complete all reference information.';
		}
	if (document.frmCredit.Trade_Name4.value=='' || document.frmCredit.Trade_Telephone4.value=='' || document.frmCredit.Trade_Address4.value=='' || document.frmCredit.Trade_Fax4.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must complete all reference information.';
		}
	if (document.frmCredit.Printed_Name.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your printed name at the bottom.';
		}
	if (document.frmCredit.Name_Title.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your title.';
		}
	if (document.frmCredit.Initials.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter your initials.';
		}
	if (document.frmCredit.Date_Initials.value=='')
		{
		errs++;
		missingdata = missingdata + '\nYou must enter today\'s date at the bottom.';
		}
	if (errs==0)
		{
		return true;
		}
	else
		{
		alert('You are required to fill in all fields before proceeding.  (You may enter \'n/a\' if a field is not applicable.)' + missingdata);
		return false;
		} 
	}
/*	
var am = "Welcome to Residential Landscape Lighting & Design!";
var bV  = parseInt(navigator.appVersion);
var bNS = navigator.appName=="Netscape";
var bIE = navigator.appName=="Microsoft Internet Explorer";

function nrc(e) {
   if (bNS && e.which > 1){
      alert(am)
      return false
   } else if (bIE && (event.button >1)) {
     alert(am)
     return false;
   }
}

document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;
*/

function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
}