
function jsSelectColor(ObjText) {

    var sColor = dlgHelper.ChooseColorDlg();
    if (sColor != 0) {
        sColor = sColor.toString(16);
        if (sColor.length < 6) {
            var numLeading0 = "000000".substring(0, (6 - sColor.length));
            sColor = "#" + numLeading0.concat(sColor).toUpperCase();
        } else {
            sColor = "#" + sColor.toUpperCase();
        }
        ObjText.value = sColor
        ObjText.style.backgroundColor = sColor

    }

}

function isEmpty(str_content) {
    string_input = str_content
    while (string_input.search(" ") > -1) {
        string_input = string_input.replace(" ", "")
    }
    if (string_input == "") {
        return true
    } else {
        return false
    }
}

function validatefrmsubscribe() {
    blnAllValid = true
    if (isEmpty(document.frmsubscribe.txtName.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your name")
        document.frmsubscribe.txtName.focus()
    }

    if ((isEmpty(document.frmsubscribe.txtEmail.value) == true && blnAllValid == true) || (isEmail(document.frmsubscribe.txtEmail.value) == false && blnAllValid == true)) {
        blnAllValid = false
        alert("Please enter a valid email address")
        document.frmsubscribe.txtEmail.focus()
    }

    if (blnAllValid == true) {
        document.frmsubscribe.submit()
    }
}


function validatefrmShop() {
    blnAllValid = true

    if (isEmpty(document.frmShop.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a shop name")
        document.frmShop.txtValue.focus()
    }

    if (isEmpty(document.frmShop.txtAddress.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a shop address")
        document.frmShop.txtAddress.focus()
    }

    if (isEmpty(document.frmShop.txtTel.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a shop telephone number")
        document.frmShop.txtTel.focus()
    }

    if (document.frmShop.drpSuburb.value == "0" && blnAllValid == true) {
        blnAllValid = false
        alert("Please select a suburb")
        document.frmShop.drpSuburb.focus()
    }

    if (blnAllValid == true) {
        document.frmShop.submit()
    }
}

function validatefrmSuburb() {
    blnAllValid = true

    if (isEmpty(document.frmSuburb.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a suburb name")
        document.frmSuburb.txtValue.focus()
    }

    if (document.frmSuburb.drpProvince.value == "0" && blnAllValid == true) {
        blnAllValid = false
        alert("Please select a province")
        document.frmSuburb.drpProvince.focus()
    }

    if (blnAllValid == true) {
        document.frmSuburb.submit()
    }
}

function validatefrmProvince() {
    blnAllValid = true

    if (isEmpty(document.frmProvince.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a province name")
        document.frmProvince.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmProvince.submit()
    }
}



function validatefrmCategory() {
    blnAllValid = true

    if (isEmpty(document.frmCategory.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a category name")
        document.frmCategory.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmCategory.submit()
    }
}

function confirmDeletion(strMessage, strLocation) {
    if (confirm(strMessage)) {
        document.location = strLocation
    }
}

function validatefrmTechnology() {
    blnAllValid = true

    if (isEmpty(document.frmTechnology.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a technology name")
        document.frmTechnology.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmTechnology.submit()
    }
}

function validatefrmSizes() {
    blnAllValid = true

    if (isEmpty(document.frmSizes.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a size name")
        document.frmSizes.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmSizes.submit()
    }
}

function validatefrmCountry() {
    blnAllValid = true

    if (isEmpty(document.frmCountry.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a country name")
        document.frmCountry.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmCountry.submit()
    }
}



function validatefrmShoeType() {
    blnAllValid = true

    if (isEmpty(document.frmShoeType.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a shoe type")
        document.frmShoeType.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmShoeType.submit()
    }
}

function validatefrmHandbagColor() {
    blnAllValid = true

    if (isEmpty(document.frmHandbagColor.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a Handbag color")
        document.frmHandbagColor.txtValue.focus()
    }

    if (isEmpty(document.frmHandbagColor.txtCode.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please select a color code")
    }

    if (blnAllValid == true) {
        document.frmHandbagColor.submit()
    }
}

function validatefrmSeasons() {
    blnAllValid = true

    if (isEmpty(document.frmSeasons.nvcSeasons.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a season name")
        document.frmSeasons.nvcSeasons.focus()
    }

    if (blnAllValid == true) {
        document.frmSeasons.submit()
    }
}

function validatefrmShoeColor() {
    blnAllValid = true

    if (isEmpty(document.frmShoeColor.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a shoe color")
        document.frmShoeColor.txtValue.focus()
    }

    if (blnAllValid == true) {
        document.frmShoeColor.submit()
    }
}

function validatefrmColors() {
    blnAllValid = true
    if (isEmpty(document.frmColors.nvcColors.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a color name")
        document.frmColors.nvcColors.focus()
    }

    if (isEmpty(document.frmColors.FILE1.value) != true) {
        document.frmColors.hdnFile1.value = "1"
    } else {
        document.frmColors.hdnFile1.value = "0"
    }

    if (isEmpty(document.frmColors.FILE2.value) != true) {
        document.frmColors.hdnFile2.value = "1"
    } else {
        document.frmColors.hdnFile2.value = "0"
    }

    if (blnAllValid == true) {
        document.frmColors.submit()
    }
}

function validatefrmShoe() {
    blnAllValid = true
    if (isEmpty(document.frmShoe.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a style")
        document.frmShoe.txtValue.focus()
    }

    if (document.frmShoe.drpGender.value == "0" && blnAllValid == true) {
        blnAllValid = false
        alert("Please select a gender")
        document.frmShoe.drpGender.focus()
    }



    if (isEmpty(document.frmShoe.txtPrice.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a price")
        document.frmShoe.txtPrice.focus()
    }

    //if(blnAllValid==true){
    //	blnAllValid=false
    //	for(x=0;x<document.frmShoe.elements.length;x++){
    //		if(document.frmShoe.elements[x].name.substring(0,15)=="chkTechnologies"){
    //			if (document.frmShoe.elements[x].checked){
    //				blnAllValid=true
    //			}
    //		}
    //	}
    //	if (blnAllValid==false){
    //		alert("Please select at least one Technology")
    //	}
    //}

    if (blnAllValid == true) {
        blnAllValid = false
        for (x = 0; x < document.frmShoe.elements.length; x++) {
            if (document.frmShoe.elements[x].name.substring(0, 13) == "chkCategories") {
                if (document.frmShoe.elements[x].checked) {
                    blnAllValid = true
                }
            }
        }
        if (blnAllValid == false) {
            alert("Please select at least one category")
        }
    }

    //if(blnAllValid==true){
    //	blnAllValid=false
    //	for(x=0;x<document.frmShoe.elements.length;x++){
    //		if(document.frmShoe.elements[x].name.substring(0,8)=="chkColor"){
    //			if (document.frmShoe.elements[x].checked){
    //				blnAllValid=true
    //			}
    //		}
    //	}
    //	if (blnAllValid==false){
    //		alert("Please select at least one category")
    //	}
    //}



    if (isEmpty(document.frmShoe.FILE1.value) != true) {
        document.frmShoe.hdnFile1.value = "1"
    } else {
        document.frmShoe.hdnFile1.value = "0"
    }

    if (isEmpty(document.frmShoe.FILE2.value) != true) {
        document.frmShoe.hdnFile2.value = "1"
    } else {
        document.frmShoe.hdnFile2.value = "0"
    }

    if (blnAllValid == true) {
        document.frmShoe.submit()
    }
}

function validatefrmToy() {
    blnAllValid = true
    if (isEmpty(document.frmShoe.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a style")
        document.frmShoe.txtValue.focus()
    }

    if (isEmpty(document.frmShoe.txtPrice.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a price")
        document.frmShoe.txtPrice.focus()
    }

    //if(blnAllValid==true){
    //	blnAllValid=false
    //	for(x=0;x<document.frmShoe.elements.length;x++){
    //		if(document.frmShoe.elements[x].name.substring(0,15)=="chkTechnologies"){
    //			if (document.frmShoe.elements[x].checked){
    //				blnAllValid=true
    //			}
    //		}
    //	}
    //	if (blnAllValid==false){
    //		alert("Please select at least one Technology")
    //	}
    //}

    if (blnAllValid == true) {
        blnAllValid = false
        for (x = 0; x < document.frmShoe.elements.length; x++) {
            if (document.frmShoe.elements[x].name.substring(0, 13) == "chkCategories") {
                if (document.frmShoe.elements[x].checked) {
                    blnAllValid = true
                }
            }
        }
        if (blnAllValid == false) {
            alert("Please select at least one category")
        }
    }

    //if(blnAllValid==true){
    //	blnAllValid=false
    //	for(x=0;x<document.frmShoe.elements.length;x++){
    //		if(document.frmShoe.elements[x].name.substring(0,8)=="chkColor"){
    //			if (document.frmShoe.elements[x].checked){
    //				blnAllValid=true
    //			}
    //		}
    //	}
    //	if (blnAllValid==false){
    //		alert("Please select at least one category")
    //	}
    //}



    if (isEmpty(document.frmShoe.FILE1.value) != true) {
        document.frmShoe.hdnFile1.value = "1"
    } else {
        document.frmShoe.hdnFile1.value = "0"
    }

    if (isEmpty(document.frmShoe.FILE2.value) != true) {
        document.frmShoe.hdnFile2.value = "1"
    } else {
        document.frmShoe.hdnFile2.value = "0"
    }

    if (blnAllValid == true) {
        document.frmShoe.submit()
    }
}


function validatefrmHandbag() {
    blnAllValid = true
    if (isEmpty(document.frmHandbag.txtValue.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a Handbag style")
        document.frmHandbag.txtValue.focus()
    }

    if (isEmpty(document.frmHandbag.nvcTitle.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a title")
        document.frmHandbag.nvcTitle.focus()
    }

    if (isEmpty(document.frmHandbag.FILE1.value) != true) {
        document.frmHandbag.hdnFile1.value = "1"
    } else {
        document.frmHandbag.hdnFile1.value = "0"
    }

    if (isEmpty(document.frmHandbag.FILE2.value) != true) {
        document.frmHandbag.hdnFile2.value = "1"
    } else {
        document.frmHandbag.hdnFile2.value = "0"
    }

    if (blnAllValid == true) {
        document.frmHandbag.submit()
    }
}

function validatefrmContact() {
    blnAllValid = true
    if (isEmpty(document.frmContact.txtName.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your name")
        document.frmContact.txtName.focus()
    }

    if (isEmpty(document.frmContact.txtSurname.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your surname")
        document.frmContact.txtSurname.focus()
    }

    if (isEmpty(document.frmContact.txtEmail.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your email address")
        document.frmContact.txtEmail.focus()
    }

    if (isEmail(document.frmContact.txtEmail.value) == false && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a valid email address")
        document.frmContact.txtEmail.focus()
    }


    if (isEmpty(document.frmContact.txtMobile.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your daytime telephone number")
        document.frmContact.txtMobile.focus()
    }

    if (document.frmContact.drpSuburb.value == "0" && blnAllValid == true) {
        blnAllValid = false
        alert("Please select your province / territory")
        document.frmContact.drpSuburb.focus()
    }

    if (isEmpty(document.frmContact.txtComment.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a note")
        document.frmContact.txtComment.focus()
    }



    if (blnAllValid == true) {
        document.frmContact.submit()

    }
}


function validatefrmEntry() {
    blnAllValid = true
    if (isEmpty(document.frmEntry.txtName.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your name")
        document.frmEntry.txtName.focus()
    }

    if (isEmpty(document.frmEntry.txtSurname.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your surname")
        document.frmEntry.txtSurname.focus()
    }

    if (isEmpty(document.frmEntry.txtEmail.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your email address")
        document.frmEntry.txtEmail.focus()
    }

    if (isEmail(document.frmEntry.txtEmail.value) == false && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a valid email address")
        document.frmEntry.txtEmail.focus()
    }


    if (isEmpty(document.frmEntry.txtMobile.value) == true && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter your mobile number")
        document.frmEntry.txtMobile.focus()
    }

    if (isMobile(document.frmEntry.txtMobile.value) == false && blnAllValid == true) {
        blnAllValid = false
        alert("Please enter a valid mobile number eg: 0821234567")
        document.frmEntry.txtMobile.focus()
    }

    if (IsvalidDate(document.frmEntry.drpDOB1.value, document.frmEntry.drpDOB2.value, document.frmEntry.drpDOB3.value) == false && blnAllValid == true) {
        blnAllValid = false
        alert("Please select a valid date")
        document.frmEntry.drpDOB1.focus()
    }

    //if((document.frmEntry.gender[0].checked==false && document.frmEntry.gender[1].checked==false) && blnAllValid==true){
    //	blnAllValid=false
    //	alert("Please indicate youre gender")
    //}

    if (document.frmEntry.drpSuburb.value == "0" && blnAllValid == true) {
        blnAllValid = false
        alert("Please select your province / territory")
        document.frmEntry.drpSuburb.focus()
    }


    if (blnAllValid == true) {
        document.frmEntry.submit()

    }
}

function isMobile(str_content) {
    string_input = str_content
    blnReturn = true
    if (string_input.length != 10) {
        blnReturn = false
    }

    for (i = 0; i < string_input.length; i++) {
        if (str_content.charAt(i) != "0" && str_content.charAt(i) != "1" && str_content.charAt(i) != "2" && str_content.charAt(i) != "3" && str_content.charAt(i) != "4" && str_content.charAt(i) != "5" && str_content.charAt(i) != "6" && str_content.charAt(i) != "7" && str_content.charAt(i) != "8" && str_content.charAt(i) != "9") {
            blnReturn = false
        }
    }

    if (blnReturn == true) {
        if (str_content.charAt(0) != "0") {
            blnReturn = false
        }
    }

    return blnReturn
}

function isEmail(str_content) {
    string_input = str_content
    blnReturn = true
    if (string_input.indexOf("@") < 0) {
        blnReturn = false
    }
    if (string_input.indexOf(".") < 0) {
        blnReturn = false
    }
    return blnReturn
}

function IsvalidDate(valDay, valMonth, valYear) {
    blnreturn = true
    if (valDay == "-" && valMonth == "-" && valYear == "-") {
    } else {
        if (obj_dateobjects1.value == "31") {
            if (obj_dateobjects2.value == "2" || obj_dateobjects2.value == "4" || obj_dateobjects2.value == "6" || obj_dateobjects2.value == "9" || obj_dateobjects2.value == "11") {
                blnreturn = false
            }
        }
        if (obj_dateobjects2.value == "2") {
            if (obj_dateobjects3.value == "1996" || obj_dateobjects3.value == "2000" || obj_dateobjects3.value == "2004" || obj_dateobjects3.value == "2008" || obj_dateobjects3.value == "2012" || obj_dateobjects3.value == "2016" || obj_dateobjects3.value == "2020" || obj_dateobjects3.value == "2024" || obj_dateobjects3.value == "2028" || obj_dateobjects3.value == "2032" || obj_dateobjects3.value == "2036" || obj_dateobjects3.value == "2040") {
                if (obj_dateobjects1.value > 29) {
                    blnreturn = false
                }
            } else {
                if (obj_dateobjects1.value > 28) {
                    blnreturn = false
                }
            }
        }
        if (valDay == "-" || valMonth == "-" || valYear == "-") {
            blnreturn = false
        }
    }
    return blnreturn
}



function js_validateDateTime(szControlName, szformname) {

    obj_dateobjects1 = eval(szformname + "." + szControlName + "1")
    obj_dateobjects2 = eval(szformname + "." + szControlName + "2")
    obj_dateobjects3 = eval(szformname + "." + szControlName + "3")

    if (obj_dateobjects1.value == "31") {
        if (obj_dateobjects2.value == "2" || obj_dateobjects2.value == "4" || obj_dateobjects2.value == "6" || obj_dateobjects2.value == "9" || obj_dateobjects2.value == "11") {
            obj_dateobjects1.value = "30"
        }
    }
    if (obj_dateobjects2.value == "2") {
        if (obj_dateobjects3.value == "1996" || obj_dateobjects3.value == "2000" || obj_dateobjects3.value == "2004" || obj_dateobjects3.value == "2008" || obj_dateobjects3.value == "2012" || obj_dateobjects3.value == "2016" || obj_dateobjects3.value == "2020" || obj_dateobjects3.value == "2024" || obj_dateobjects3.value == "2028" || obj_dateobjects3.value == "2032" || obj_dateobjects3.value == "2036" || obj_dateobjects3.value == "2040") {
            if (obj_dateobjects1.value > 29) {
                obj_dateobjects1.value = "29"
            }
        } else {
            if (obj_dateobjects1.value > 28) {
                obj_dateobjects1.value = "28"
            }
        }
    }
}





