﻿/// <reference path="jquery-1.2.6-vsdoc.js" />
/// <reference path="ui.datepicker.js" />

$(function() {
    //$.setupDefaultButtonForElements('', 'ctl00_ContentBody_lnkSubmit');
//    $('#txtDate').datepicker({ dateFormat: "dd/mm/yy", buttonImage: "images/icon_calendar_24.png", showOn: "both", buttonImageOnly: true });
//    var d = new Date();
//    $('#txtDate').datepicker('setDate', d.getDate());    
    $('#ctl00_ContentBody_ddlPosition').bind('change', function(event) {
        if ($('#ctl00_ContentBody_ddlPosition')[0].selectedIndex == 17) {
            $('#extraPosition').customFadeIn(300);
        }
        else {
            $('#extraPosition').hide();
        }
    });

    $('#ctl00_ContentBody_ddlIndustry').bind('change', function(event) {
        if ($('#ctl00_ContentBody_ddlIndustry')[0].selectedIndex == 7) {
            $('#extraIndustry').customFadeIn(300);
        }
        else {
            $('#extraIndustry').hide();
        }
    });

    $('#ctl00_ContentBody_lnkSubmit').bind('click', onSubmitClick);
    $('#ctl00_ContentBody_txtCompany').attr('jval', '{valid:/^[a-zA-Z0-9 ]{3,50}$/, message:"Invalid Company Name", styleType: "cover" }');
    $('#ctl00_ContentBody_txtName').attr('jval', '{valid:/^[a-zA-Z0-9 ]{3,50}$/, message:"Invalid Name", styleType: "cover" }');
    $('#ctl00_ContentBody_ddlIndustry').attr('jval', '{valid:function (val){ var myString = new String(val); if(myString.substring(0, 13) == "Please select") return false; else return true; }, message:"Required Field", styleType: "cover" }');

    $('#ctl00_ContentBody_txtEmailAddress').attr('jval', '{valid:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/, message:"Invalid Email Address", styleType:"cover"}');
    $('#ctl00_ContentBody_txtEmailAddress').attr('jValKey', '{valid:/[a-zA-Z0-9._%+-@]/, cFunc:"alert", cArgs:["Email Address: "+$(this).val()]}');

    $('#ctl00_ContentBody_ddlPosition').attr('jval', '{valid:function (val){ var myString = new String(val); if(myString.substring(0, 13) == "Please select") return false; else return true; }, message:"Required Field", styleType: "cover" }');
    $('#ctl00_ContentBody_txtTelephoneNumber').attr('jval', '{valid:/^[a-zA-Z0-9 ]{3,30}$/, message:"Invalid Telephone Number", styleType: "cover" }');
});

function onSubmitClick(event) {
    if (!$('#detailsForm').jVal()) {
        return false;
    }
}
