//<script> // Added to workaround syntax highlighting bug in CoffeeCup Free editor
/*******************************************************************************
 *                       C O P Y R I G H T  (c) 2007-2011
 *             E Y E D R O   G R E E N   S O L U T I O N S   I N C.
 *                             All Rights Reserved
 *******************************************************************************
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF EYEDRO GREEN SOLUTIONS INC. 
 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, WHETHER 
 * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO 
 * THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR 
 * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *                 
 *            The copyright notice above does not evidence any
 *           actual or intended publication of such source code.
 *
 * The software is owned by Eyedro Green Solutions Inc. and/or its supplier, 
 * and is protected under applicable copyright laws. All rights are reserved. 
 * Any use in violation of the foregoing restrictions may subject the user to 
 * criminal sanctions under applicable laws, as well as to civil liability for 
 * the breach of the terms and conditions of this license.
 *******************************************************************************/


function validateNewsletterForm()
{
    // Ensure valid email address has been entered
    var x=document.forms["NewsletterForm"]["Email"].value
    var atpos=x.indexOf("@");
    var dotpos=x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }
}

function fillContactUsForm(cat, msg, email)
{
    document.forms["ContactUsForm"]["Category"].value = cat;
    document.forms["ContactUsForm"]["Message"].value = msg;
    if (email.length>0) {
        document.forms["ContactUsForm"]["Email"].value = email;
    } else {
        document.forms["ContactUsForm"]["Email"].focus(); 
        document.forms["ContactUsForm"]["Email"].select();
    }
}
function validateContactUsForm()
{
    // Ensure a category is selected
    var mesg=document.forms["ContactUsForm"]["Category"].value;
    if (mesg==0) {
        alert("Please choose an appropriate category for your request.");
        return false;
    }
    // Ensure Message field isn't empty
    var mesg=document.forms["ContactUsForm"]["Message"].value;
    if (mesg.length==0 || mesg=='Type message.') {
        alert("Please enter a message for the Eyedro staff in the appropriate field.");
        return false;
    }
    // Ensure valid email address has been entered
    var x=document.forms["ContactUsForm"]["Email"].value
    var atpos=x.indexOf("@");
    var dotpos=x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }
}

function sendEmailLink(subject)
{
    document.forms["contactUsForm"]["subject"].value = subject;
}


function activateInputPlaceholders() {
    var inputs = document.getElementsByTagName("input");
    for (var i=0;i<inputs.length;i++) {
        if (inputs[i].getAttribute("type") == "text") {
            if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
                inputs[i].value = inputs[i].getAttribute("placeholder");
                inputs[i].onclick = function() {
                    if (this.value == this.getAttribute("placeholder")) {
                       this.value = "";
                    }
                    return false;
                }
                inputs[i].onblur = function() {
                    if (this.value.length < 1) {
                        this.value = this.getAttribute("placeholder");
                    }
                }
            }
        }
    }
}
function activateTextareaPlaceholders() {
    var inputs = document.getElementsByTagName("textarea");
    for (var i=0;i<inputs.length;i++) {
        if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
            inputs[i].value = inputs[i].getAttribute("placeholder");
            inputs[i].onclick = function() {
                if (this.value == this.getAttribute("placeholder")) {
                   this.value = "";
                }
                return false;
            }
            inputs[i].onblur = function() {
                if (this.value.length < 1) {
                    this.value = this.getAttribute("placeholder");
                }
            }
        }
    }
}
window.onload=function() {
    var detect = navigator.userAgent.toLowerCase(); 
    if (detect.indexOf("safari") > 0) return false;
    if (detect.indexOf("chrome") > 0) return false;
    if (detect.indexOf("opera") > 0) return false;
    activateInputPlaceholders();
    activateTextareaPlaceholders();
}

