/*

###########################################################
# CUSTOMALOGO.COM										  #
#														  #
###########################################################
#                                                         #
# JAVASCRIPT FORM VALIDATION LIBRARY 					  #
#														  #
# BY KLOK FOR THE GLORY OF JESUS		   				  # 
# 18/08/2008						                      #
#                                                         #
###########################################################
*/
/*
###########################################################
# CONFIG PARAMS											  #
###########################################################
*/
var originalBorderColor = "#C0C0C0";
var errorBorderColor = "#FF6600";
var ajaxLoader = "../images/common/ajaxLoader.gif";
var spacer = "../images/common/spacer.gif";
var okIcon = "../images/common/accept.png";
var errorIcon = "../images/common/exclamation.png";
/*
###########################################################
# DICTIONARY											  #
###########################################################
*/
var errorReq = "YOU MISSED SOME REQUIRED FIELDS!";
var errorEmail = "TTHIS E-MAIL ADDRESS IS NOT VALID!";
var errorNumber = "THIS FIELD TAKES ONLY NUMBERS!";
var errorCheck = "YOU HAVE TO CHECK THE BOX";
var validatingMsg = "VALIDATING FORM";
/*
###########################################################
# END DICTIONARY										  #
# DO NOT EDIT BELOW THIS LINE							  #
###########################################################
*/

function validateForm(thisform) {
    var errors;
    var theForm = thisform;
	var formErrors = document.getElementById('formErrors');
	
	formErrors.style.backgroundRepeat = "no-repeat";
	formErrors.style.backgroundPosition = "center right";
	
	formErrors.style.backgroundImage = "url("+ajaxLoader+")";
	formErrors.innerHTML = validatingMsg;

    for (i = 0; i < theForm.elements.length; i++) {

		var theElement = theForm.elements[i];

        theElement.style.borderColor = originalBorderColor;

        if (theElement.id.indexOf('req') != -1) {
			
			if(theElement.type == "text" || theElement.type == "textarea" || theElement.type == "button"){
				if (theElement.value == "" || theElement.value == null) {
					errors = errorReq;
					theElement.style.borderColor = errorBorderColor;
				}
			}
			if(!errors && theElement.type == "checkbox" && !theElement.checked){
				errors = errorCheck;
				theElement.style.borderColor = errorBorderColor;
			}
			
        }

        if (!errors && theElement.id.indexOf('isEmail') != -1 && checkEmail(theElement.value) == false) {
            errors = errorEmail;
            theElement.style.borderColor = errorBorderColor;
        }

        if (!errors && theElement.id.indexOf('isNum') != -1 && isNaN(theElement.value)) {
            errors = errorNumber;
            theElement.style.borderColor = errorBorderColor;
        }

    }

    if (errors) {
		formErrors.style.backgroundImage="url("+errorIcon+")";
		window.location.hash = "formTop";
        formErrors.innerHTML = errors;
        return false;
    } else {
		formErrors.innerHTML = "";
		formErrors.style.backgroundImage="url("+okIcon+")";
        return true;
    }
}

function checkEmail(value) {

    apos = value.indexOf("@");
    dotpos = value.lastIndexOf(".");
    if (apos < 1 || dotpos - apos < 2) {
        return false;
    } else {
        return true;
    }

}
function transError() {
alert("waap");
   var formErrors = document.getElementById('formErrors');
   formErrors.style.backgroundImage="url("+errorIcon+")";
   window.location.hash = "formTop";
   formErrors.innerHTML = transactionError;
   return false;

}
