// JavaScript Document

// build a footer so that I only have to update this to make the footer the same on all pages
function create_footer() {
    var current_date = new Date().getFullYear();
    document.write('Copyright '+current_date+'. Terraco. All rights reserved.<br />Web site design and integration by <a href="http://www.swj.cc" target="_blank">SWJ Strategic Marketing &amp; Advertising</a>.');
}



// this javascript was developed by November Group to send emails
// code on page is <a href="javascript:sendToMe('info@no', 'abc', 'vgrou', '123', 'p.com', 'p.ca', 1);">General Enquiries</a>
function sendToMe(one, two, three, four, five, six, seven) { 

  switch (seven) {
    case 1:
	  // 'two', 'four' and 'six' are ignored - just junk.
	  window.location = 'mailto:'+ one + three + five + '?subject=Inquiry from Home page.';
	  break;
	default:
	  	// 'two', 'four' and 'six' are ignored - just junk.
	  window.location = 'mailto:'+ one + three + five;
	  break;
  }
} 




//Created / Generates the captcha function    
function DrawCaptcha()  {
    var a = Math.ceil(Math.random() * 10)+ '';
    var b = Math.ceil(Math.random() * 10)+ '';       
    var c = Math.ceil(Math.random() * 10)+ '';  
    var d = Math.ceil(Math.random() * 10)+ '';  
    var e = Math.ceil(Math.random() * 10)+ '';  
    var f = Math.ceil(Math.random() * 10)+ '';  
    var g = Math.ceil(Math.random() * 10)+ '';  
    var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
    document.getElementById("txtCaptcha").value = code;
}


// Validate the Entered input aganist the generated security code function   
function ValidCaptcha() {

    var str1 = removeSpaces(document.getElementById("txtCaptcha").value);
    var str2 = removeSpaces(document.getElementById("txtInput").value);

    if (str1 == str2) {
	  return true;
	}
    return false;
        
}


// Remove the spaces from the entered and generated code
function removeSpaces(string) {
    return string.split(' ').join('');
}

/*
function isEmpty(obj) {
    if (typeof obj == 'undefined' || obj === null || obj === '') return true;
    if (typeof obj == 'number' && isNaN(obj)) return true;
    if (obj instanceof Date && isNaN(Number(obj))) return true;
    return false;
}
*/



// reset the lubricant drop down
function reset_lubricant_select() {
  document.getElementById('terraco_petro_rep').selectedIndex = 0;
}



// reset the fertilizer select drop down
function reset_fertilizer_select() {
  document.getElementById('terraco_fert_rep').selectedIndex = 0;
}


