﻿/// intellisense documentation for jquery
/// <reference path="jquery-1.3.2.intellisense.js" />

function showhide(layer_ref) {
    $("#" + layer_ref).toggle();
}

function closeScreen() {
    location.href = window.location;
}
 function pageScroll() {
    window.scroll(0, -10000);
}

function validate() {
    errorVal = false;
    errorVal = validateEmailField("email") || errorVal;
    errorVal = validateField("name") || errorVal;

    if ($(":input[name=professionSelector]").val() == "0") {
        errProfession = $(":input[name=profession]").val() == "";
        setErrorField(errProfession, ":input[name=professionSelector]");
        errorVal = errProfession || errorVal;
    }

    if (errorVal) {
        $(".body .errormsg").show();
    }
    else {
        $(".body .errormsg").hide();
    }
    return !errorVal;
}

$(
    	function() {
    	    $("#submitForm").bind("click",
			    function() {
			        valid = validate();
			        if (valid) {
			            fieldId = ":input[name=filledForm]";
			            $(fieldId).val('subscribe');
			        }
			        return valid;
			    }
			)


    	    $("#cancelForm").bind("click",
			    function() {
			        valid = validate();
			        if (valid) {
			            fieldId = ":input[name=filledForm]";
			            $(fieldId).val('unsubscribe');
			        }
			        return valid;
			    }
			)

    	    $(":input[name=professionSelector]").change(
			    function() {
			        $val = $.trim($(this).val());
			        if ($val == "0") {
			            $(":input[name=profession]").parent().show();
			        }
			        else {
			            $(":input[name=profession]").parent().hide();
			        }
			    }
			)

    	}
    )

