/*
 WebSweet JavaScript.
 (c) Caters-Hardy Design Studio
*/
// Changes/corrects the action url of the form which defaults to /page/home to fool spam bots.
// Here we need to get the page ID or page name from the window.location and use it in /contact/index/execute/page/contact';
function ws_mod_contact_url(user_form) {
    if (user_form) {
        // matches: /admin/page/name/contact or /admin/page/name/123
        admin_page_regex = /admin\/page\/name\/([\w-]+)/i;
        // matches: /page/contact
        page_regex = /\/page\/([\w-]+)/i;

        str = new String(window.location);

        page = 'contact';
        if (str.match(admin_page_regex)) {
            page = str.match(admin_page_regex);
            page = page[1];
            // make the form stay in admin when it is called from admin
            page += '/a/1';
        } else if (str.match(page_regex)) {
            page = str.match(page_regex);
            page = page[1];
        }
        user_form.action = '/contact/index/execute/page/' + page;
    } else {
        user_form.action = '/page/home';
    }
}