function get_cookie(find_key) { var cookies = document.cookie.split(";"); var c_val = ""; for (var x in cookies) { var next_cookie = cookies[x].replace(/^[\r\s\t\n]*/, "").replace(/[\r\s\t\n]*$/, ""); key = next_cookie.split("=")[0]; val = next_cookie.split("=")[1]; if (key == find_key) { c_val = unescape(val); break; } } return c_val; } function write_cookie(cookie_name, cookie_value) { document.cookie = cookie_name+"="+escape(cookie_value); } function check_search_form(form) { form.elements["q"].value = remove_whitespace(form.elements["q"].value); if (form.elements["q"].value == "") { alert("Please enter in a valid Search Keyword."); form.elements["q"].focus(); form.elements["q"].select(); return false; } else { return true; } } var show_search_box = 0; function linkexchange_search_box() { var stext = (search_text) ? search_text : ""; document.writeln('
Keyword Search:   

'); show_search_box++; } function remove_whitespace(s) { return s.replace(/^[\r\t\n\s]*/, "").replace(/[\r\t\n\s]*$/, ""); } function check_email(email) { var email_reg = /^\w+[\.\-\w]+?\w+@\w+[\.\-\w]+?(\.\w{2,4})+$/; return email_reg.test(email); } function check_form(form) { form.elements["name"].value = remove_whitespace(form.elements["name"].value); form.elements["email"].value = remove_whitespace(form.elements["email"].value); form.elements["site_url"].value = remove_whitespace(form.elements["site_url"].value); form.elements["site_description"].value = remove_whitespace(form.elements["site_description"].value); form.elements["link_text"].value = remove_whitespace(form.elements["link_text"].value); form.elements["our_link"].value = remove_whitespace(form.elements["our_link"].value); if (form.elements["name"].value == "") { return form_field_error(form,"name","Your Name"); } if (!check_email(form.elements["email"].value)) { return form_field_error(form,"email","Email Address"); } if (form.elements["site_url"].value == "" || !(/^http:\/\/(\w+\.)?.+\.\w+.*$/.test(form.elements["site_url"].value))) { return form_field_error(form,"site_url","Site URL"); } if (form.elements["site_category"].options[form.elements["site_category"].selectedIndex].value == "") { return form_field_error(form,"site_category","Site Category"); } if (form.elements["site_description"].value == "") { return form_field_error(form,"site_description","Site Description"); } if (form.elements["link_text"].value == "") { return form_field_error(form,"link_text","Link Text"); } if (form.elements["our_link"].value == "" || !(/^http:\/\/(\w+\.)?.+\.\w+.*$/.test(form.elements["our_link"].value))) { return form_field_error(form,"our_link","Our Link"); } // write cookies write_cookie("name", form.elements["name"].value); write_cookie("email", form.elements["email"].value); write_cookie("site_url", form.elements["site_url"].value); write_cookie("site_category", form.elements["site_category"].options[form.elements["site_category"].selectedIndex].value); write_cookie("site_description", form.elements["site_description"].value); write_cookie("link_text", form.elements["link_text"].value); write_cookie("our_link", form.elements["our_link"].value); // return return true; } function form_field_error(form, field_name, field_display) { alert("The following field is invalid:\n\n"+ field_display + "\n\nPlease re-enter this field now."); form.elements[field_name].focus(); if (form.elements[field_name].type != 'select-one') { form.elements[field_name].select(); } return false; } function linkexchange_text() { document.writeln('

Welcome to the '+ sitename +' link directory! The directory is filled with reliable online resources that we have found, as well as internet sites that our visitors have submitted to us.

\

Browsing the Directory
'); if (show_search_box) { document.writeln('You can browse through the directory by choosing one of the link categories on the main navigation menu, or by using the Keyword Search box located towards the top of the page.

'); } else { document.writeln('You can browse through the directory by choosing one of the link categories on the main navigation menu.

'); } document.writeln('

Add a Site to the Directory
\ To add a site to the link directory, we require that you place a link to our site first. This site can be from the same site you are submitting below or from any other website you manage.

\

Once we review your site, you will be immediately notified by email on the status of your link (whether the site was accepted or declined).

\


\

Instructions:

    \
  1. Place a link to our website using the following code:

    \

    '+ link_code +'

    \
  2. Fill out the form below in it\'s entirety and then click \'Submit Site\'.\

'); } function linkexchange_form() { document.writeln('

NOTE: All Fields Are Required!

\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
Your Name: 
Email Address: 
Site URL: 
Site Category: 
Site Description: 
Link Text: 
Our Link Location: 

\ '); } function linkexchange_error(type) { if (type == 'invalid_fields') { document.writeln('Error: The following fields are invalid:
'+ invalid_fields +'
Please re-enter these fields now.

'); } else if (type == 'site_found') { document.writeln('Error: The Site URL you entered below already exists in the database! Please enter another URL below if you would like to exchange links.

'); } else if (type == 'our_link_found') { document.writeln('Error: Our website has already been linked on the page you specified below. Please place our link on a different URL.

'); } else if (type == 'site_url_bad') { document.writeln('Error: The Site URL entered below seems to be invalid. Please check this field and re-enter the Site URL.

'); } else if (type == 'no_link') { document.writeln('Error: Our link could not be found on the URL you entered below. Please make sure you have entered our link code onto your html page correctly, and try again.

'); } } function linkexchange_setform() { var form = document.forms["linkexchange"]; form.elements["name"].value = get_cookie("name"); form.elements["email"].value = get_cookie("email"); form.elements["site_url"].value = get_cookie("site_url"); form.elements["site_category"].value = get_cookie("site_category"); form.elements["site_description"].value = get_cookie("site_description"); form.elements["link_text"].value = get_cookie("link_text"); form.elements["our_link"].value = get_cookie("our_link"); }