var imageArray = [
	['image1.bmp', 'GRTC'],
	['image2.bmp', '8F2H'],
	['image3.bmp', 'N9RZ'],
	['image4.bmp', 'SCA2'],
	['image5.bmp', 'UCQ4'],
	['image6.bmp', 'ZQEK'],
	['image7.bmp', 'VJ8W'],
	['image8.bmp', '73PS'],
	['image9.bmp', '9MTV'],
	['image10.bmp', 'YFF3'],
	['image11.bmp', 'M8KH'],
	['image12.bmp', 'RYCA'],
	['image13.bmp', 'T49K'],
	['image14.bmp', 'Q7XQ'],
	['image15.bmp', 'QZTB'],
	['image16.bmp', 'YZL7'],
	['image17.bmp', 'MRAV'],
	['image18.bmp', 'QZPU'],
	['image19.bmp', 'AJ7K'],
	['image20.bmp', '7CC4']
]

var IMAGEDIR = "images/CAPTCHA/";

function checkcode(f) {
    var i = f.sdx.value;
    if(f.code.value == imageArray[i][1])
	return true;
    else
	return false;
}

function isValidEmail(email) {
    reg = /^([A-Za-z0-9])+([_.\-\\&][A-Za-z0-9]+)*\@([A-Za-z0-9])+([_.-][A-Za-z0-9]+)*\.([A-Za-z]{2,4})$/;
    if(reg.test(email) == false)
	return false;
    else
	return true;
}

function validate(f) {
    var msg = "";
    
    if(f.name.value == "")
        msg = "Please enter your Name.\n";
        
    if(f.email.value == "")
        msg += "Please enter your Email Address.\n";
    else
    if(!isValidEmail(f.email.value))
        msg += "Email Address is invalid.\n";

    if(!checkcode(f))
        msg += "You entered an invalid security code.\n";

    if(msg != "") {
        msg += "\nPlease correct all errors and resubmit the form.";
        alert(msg);
        return false;
    }

    return true;    
}

function validate2(f) {
    var msg = "";
    
    if(f.first.value == "")
        msg = "Please enter your First Name.\n";
    
    if(f.last.value == "")
        msg += "Please enter your Last Name.\n";
    
    if(f.address.value == "")
        msg += "Please enter your Street Address.\n";
    
    if(f.city.value == "")
        msg += "Please enter your City.\n";
    
    if(f.state.value == "00")
        msg += "Please enter your State.\n";
    
    if(f.zip.value == "")
        msg += "Please enter your Zip Code.\n";
    
    if(f.phone.value == "")
        msg += "Please enter your Phone.\n";
        
    if(f.email.value == "")
        msg += "Please enter your Email Address.\n";
    else
    if(!isValidEmail(f.email.value))
        msg += "Email Address is invalid.\n";
    
    if(f.available.value == "")
        msg += "Please enter the Date Available.\n";
    
    if(f.rate.value == "")
        msg += "Please enter the Desired Hourly Rate.\n";

    if(!checkcode(f))
        msg += "You entered an invalid security code.\n";

    if(msg != "") {
        msg += "\nPlease correct all errors and resubmit the form.";
        alert(msg);
        return false;
    }

    return true;    
}

function setWrapperHeight(min) {
    var c = document.getElementById('content').offsetHeight + HDR + FTR;
    var m = 0;
    
//    alert("container="+c);
    if (typeof min != "undefined")
        m = min;
    if(m > c) {
        document.getElementById('container').style.height = m+"px";
    }
    else {
        document.getElementById('container').style.height = c+"px";
    }
    
    return;
}

function displayPopup(url) {

    window.open(url, "_blank", "width=800,height=200,left=180,top=200,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes");
}

function getFormattedDate() {
    var d = new Date();
    return d.toLocaleDateString();
}

function writeHeaderMenu() {
    document.writeln('<div id="nav">');
    document.writeln('<div id="navFull"><a href="index.html" class="topmenu menuStart">Home</a></div>');
    document.writeln('<div id="navFull"><a href="salon.html" class="topmenu menuLeft">Salon</a></div>');
    document.writeln('<div id="navFull"><a href="specials.html" class="topmenu menuLeft">Specials</a></div>');
    document.writeln('<div id="navFull"><a href="products.html" class="topmenu menuLeft">Products</a></div>');
    document.writeln('<div id="navFull"><a href="contact.html" class="topmenu menuLeft">Contact Us</a></div>');
    document.writeln('<div id="navFull"><a href="about.html" class="topmenu menuLeft">About Us</a></div>');
    document.writeln('<div id="navFull"><a href="gallery.html" class="topmenu menuLeft">Gallery</a></div>');
    document.writeln('</div>');
}

