function textCounter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else cntfield.value = maxlimit - field.value.length; } function sp_trim(inputString) { // Removes leading and trailing spaces from the passed string. Also removes // consecutive spaces and replaces it with one space. If something besides // a string is passed in (null, custom object, etc.) then return the input. if (typeof inputString != "string") { return inputString; } var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); } while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; // Return the trimmed string back to the user } // Ends the "trim" function //Check to validate the email address function sp_isEmailAddr(email) { var result = false var theStr = new String(email) var index = theStr.indexOf("@"); if (index > 0) { var pindex = theStr.indexOf(".",index); if ((pindex > index+1) && (theStr.length > pindex+1)) result = true; } return result; } function sp_highlightTextField(field) { field.style.borderColor = 'red'; field.style.borderStyle = 'solid'; field.style.borderWidth = '1px;'; } function sp_nohighlightTextField(field) { field.style.borderColor = ''; field.style.borderStyle = ''; field.style.borderWidth = ''; } function sp_highlightSelectField(field) { field.style.backgroundColor = 'red'; field.style.color = 'black'; } function sp_nohighlightSelectField(field) { field.style.backgroundColor = ''; field.style.color = ''; } function sp_check_textfield(field, fieldname, ErrorMsg) { trimmed_string = sp_trim(field.value); if (trimmed_string.length == 0) { ErrorMsg = ErrorMsg + '- ' + fieldname + '\n'; sp_highlightTextField(field); field.focus(); } else { sp_nohighlightTextField(field); } return ErrorMsg; } function sp_check_selectfield(field, fieldname, ErrorMsg) { if(field.value == "") { ErrorMsg = ErrorMsg + '- ' + fieldname + '\n'; sp_highlightSelectField(field); field.focus(); } else { sp_nohighlightSelectField(field); } return ErrorMsg; } function sp_check_email(field, fieldname, ErrorMsg) { if(!sp_isEmailAddr(field.value)) { ErrorMsg = ErrorMsg + '- ' + fieldname + '\n'; sp_highlightTextField(field); field.focus(); } else { sp_nohighlightTextField(field); } return ErrorMsg; } function sp_checkdomain(field, fieldname, ErrorMsg) { var flag = 0; var found = ''; re = /^((http[s]?):\/\/)([^\/:]+)(:\d{1,5})?(\/[^\s\"\'`]*)?$/i; found = re.exec(field.value); if (!found) flag++; if(flag > 0) { ErrorMsg = ErrorMsg + '- ' + fieldname + '\n'; sp_highlightTextField(field); field.focus(); } else { sp_nohighlightTextField(field); } return ErrorMsg; } function sp_quick_checkdomain(url) { var flag = 0; re = /^((http[s]?):\/\/)([^\/:]+)(:\d{1,5})?(\/[^\s\"\'`]*)?$/i; found = re.exec(url); if (!found) flag++; if(flag > 0) { return false; } else { return true; } } function sp_recippop(siteid, recip_url) { var recipcheck_url = 'http://www.site-partners.com/plus/externalsp/recip_check.php'; var ErrorMsg = ''; if(!siteid){ ErrorMsg = ErrorMsg + '- Site Account ID'; } if(sp_quick_checkdomain(recip_url) == false){ ErrorMsg = ErrorMsg + '- Reciprocal URL'; } if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { s = new String(recip_url); s = s.replace(/&/g, "||"); s = encodeURI(s); recipcheck_url = recipcheck_url + '?siteid=' + siteid + '&url=' + s; window.open(recipcheck_url,"","height=325,width=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1"); } } function sp_linkpop(url) { window.open(url,"","height=475,width=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1"); } function sp_pop(url) { window.open(url,"","height=500,width=500,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1"); } function sp_checkAddLink() { var ErrorMsg = ''; var password_flag = ''; ErrorMsg = sp_check_selectfield(document.sp_add_link.sp_categoryid, "Site Category", ErrorMsg); ErrorMsg = sp_checkdomain(document.sp_add_link.recip_url, "Reciprocal URL", ErrorMsg); //check the password password_flag = sp_check_textfield(document.sp_add_link.sp_password1, "Password", password_flag); if( password_flag == '') { //Confirm password check if(document.sp_add_link.sp_password1.value != document.sp_add_link.sp_password2.value) { ErrorMsg = ErrorMsg + '- Confirm Password' +'\n'; sp_highlightTextField(document.sp_add_link.sp_password2); document.sp_add_link.sp_password2.focus(); } else { sp_nohighlightTextField(document.sp_add_link.sp_password1); sp_nohighlightTextField(document.sp_add_link.sp_password2); } } else { ErrorMsg = ErrorMsg + '- ' + 'Password' + '\n'; sp_highlightTextField(document.sp_add_link.sp_password1); sp_highlightTextField(document.sp_add_link.sp_password2); document.sp_add_link.sp_password1.focus(); } ErrorMsg = sp_check_email(document.sp_add_link.sp_contact_email, "Contact Email", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_contact_name, "Contact Name", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_desc, "Site Description", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_title, "Site Title", ErrorMsg); ErrorMsg = sp_checkdomain(document.sp_add_link.sp_url, "Site URL", ErrorMsg); if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { return true; } } function sp_checkModifyLink() { var ErrorMsg = ''; ErrorMsg = sp_checkdomain(document.sp_modify_link.sp_url, "Site URL", ErrorMsg); ErrorMsg = sp_check_email(document.sp_modify_link.sp_contact_email, "Contact Email", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_modify_link.sp_password, "Password", ErrorMsg); if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { return true; } } function sp_checkModifyLinkForm() { var ErrorMsg = ''; ErrorMsg = sp_check_selectfield(document.sp_add_link.sp_categoryid, "Site Category", ErrorMsg); ErrorMsg = sp_checkdomain(document.sp_add_link.recip_url, "Reciprocal URL", ErrorMsg); //check the password and confirm are not empty trimmed_string1 = sp_trim(document.sp_add_link.sp_password1.value); trimmed_string2 = sp_trim(document.sp_add_link.sp_password2.value); if ( (trimmed_string1.length > 0) || (trimmed_string2.length > 0) ) { //No password but a confirmed password if( (trimmed_string1.length == 0) && (trimmed_string2.length > 0) ) { ErrorMsg = ErrorMsg + '- ' + 'New Password' + '\n'; sp_highlightTextField(document.sp_add_link.sp_password1); document.sp_add_link.sp_password1.focus(); } else if(document.sp_add_link.sp_password1.value != document.sp_add_link.sp_password2.value) { ErrorMsg = ErrorMsg + '- Confirm Password' +'\n'; sp_highlightTextField(document.sp_add_link.sp_password2); document.sp_add_link.sp_password2.focus(); } else { sp_nohighlightTextField(document.sp_add_link.sp_password1); sp_nohighlightTextField(document.sp_add_link.sp_password2); } } ErrorMsg = sp_check_email(document.sp_add_link.sp_contact_email, "Contact Email", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_contact_name, "Contact Name", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_desc, "Site Description", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_title, "Site Title", ErrorMsg); ErrorMsg = sp_checkdomain(document.sp_add_link.sp_url, "Site URL", ErrorMsg); if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { return true; } } function sp_checkForgotPass() { var ErrorMsg = ''; ErrorMsg = sp_checkdomain(document.sp_forgotpass.sp_url, "Site URL", ErrorMsg); ErrorMsg = sp_check_email(document.sp_forgotpass.sp_contact_email, "Contact Email", ErrorMsg); if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { return true; } } function sp_checkPendingLinkForm() { var ErrorMsg = ''; ErrorMsg = sp_check_selectfield(document.sp_add_link.sp_categoryid, "Site Category", ErrorMsg); ErrorMsg = sp_checkdomain(document.sp_add_link.recip_url, "Reciprocal URL", ErrorMsg); //check the password and confirm are not empty trimmed_string1 = sp_trim(document.sp_add_link.sp_password1.value); trimmed_string2 = sp_trim(document.sp_add_link.sp_password2.value); if ( (trimmed_string1.length > 0) || (trimmed_string2.length > 0) ) { //No password but a confirmed password if( (trimmed_string1.length == 0) && (trimmed_string2.length > 0) ) { ErrorMsg = ErrorMsg + '- ' + 'New Password' + '\n'; sp_highlightTextField(document.sp_add_link.sp_password1); document.sp_add_link.sp_password1.focus(); } else if(document.sp_add_link.sp_password1.value != document.sp_add_link.sp_password2.value) { ErrorMsg = ErrorMsg + '- Confirm Password' +'\n'; sp_highlightTextField(document.sp_add_link.sp_password2); document.sp_add_link.sp_password2.focus(); } else { sp_nohighlightTextField(document.sp_add_link.sp_password1); sp_nohighlightTextField(document.sp_add_link.sp_password2); } } ErrorMsg = sp_check_email(document.sp_add_link.sp_contact_email, "Contact Email", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_contact_name, "Contact Name", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_desc, "Site Description", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_title, "Site Title", ErrorMsg); ErrorMsg = sp_checkdomain(document.sp_add_link.sp_url, "Site URL", ErrorMsg); if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { return true; } } function EnableSitesVars(val) { //enables the site to add's vars if(document.sp_add_link.elements['sp_sites[' + val + ']'].checked == true) { document.sp_add_link.elements['sp_categoryid[' + val + ']'].disabled = false; document.sp_add_link.elements['recip_url[' + val + ']'].disabled = false; if(document.sp_add_link.elements['recip_url[' + val + ']'].value == '') { document.sp_add_link.elements['recip_url[' + val + ']'].value = 'http://'; } } else { document.sp_add_link.elements['sp_categoryid[' + val + ']'].disabled = true; document.sp_add_link.elements['recip_url[' + val + ']'].disabled = true; if(document.sp_add_link.elements['recip_url[' + val + ']'].value == 'http://') { document.sp_add_link.elements['recip_url[' + val + ']'].value = ''; } } } function sp_checkGroupAddLink() { var ErrorMsg = ''; var password_flag = ''; ErrorMsg = sp_check_email(document.sp_add_link.sp_contact_email, "Contact Email", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_contact_name, "Contact Name", ErrorMsg); //check the password password_flag = sp_check_textfield(document.sp_add_link.sp_password1, "Password", password_flag); if( password_flag == '') { //Confirm password check if(document.sp_add_link.sp_password1.value != document.sp_add_link.sp_password2.value) { ErrorMsg = ErrorMsg + '- Confirm Password' +'\n'; sp_highlightTextField(document.sp_add_link.sp_password2); document.sp_add_link.sp_password2.focus(); } else { sp_nohighlightTextField(document.sp_add_link.sp_password1); sp_nohighlightTextField(document.sp_add_link.sp_password2); } } else { ErrorMsg = ErrorMsg + '- ' + 'Password' + '\n'; sp_highlightTextField(document.sp_add_link.sp_password1); sp_highlightTextField(document.sp_add_link.sp_password2); document.sp_add_link.sp_password1.focus(); } ErrorMsg = sp_checkdomain(document.sp_add_link.sp_url, "Site URL", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_title, "Site Title", ErrorMsg); ErrorMsg = sp_check_textfield(document.sp_add_link.sp_desc, "Site Description", ErrorMsg); //checking sites,categoryid,recip_url var website_check = 0; var category_check = 0; var err; var recip_check = 0; for (var i = 0; i -1)) { if (document.sp_add_link.elements[i].checked == true) { website_check = 1; //check if there is a category selected if(document.sp_add_link.elements['sp_categoryid[' + document.sp_add_link.elements[i].value + ']'].value == '') { category_check = category_check + 1; sp_highlightSelectField(document.sp_add_link.elements['sp_categoryid[' + document.sp_add_link.elements[i].value + ']']); } else { sp_nohighlightSelectField(document.sp_add_link.elements['sp_categoryid[' + document.sp_add_link.elements[i].value + ']']); } //check if there is a recip_url for each site err = sp_quick_checkdomain(document.sp_add_link.elements['recip_url[' + document.sp_add_link.elements[i].value + ']'].value); if( err == false) { recip_check = recip_check + 1; sp_highlightTextField(document.sp_add_link.elements['recip_url[' + document.sp_add_link.elements[i].value + ']']); } else { sp_nohighlightTextField(document.sp_add_link.elements['recip_url[' + document.sp_add_link.elements[i].value + ']']); } } } } if(website_check < 1) { ErrorMsg = ErrorMsg + "- No Websites selected for linking\n"; } else { if(category_check > 0) { ErrorMsg = ErrorMsg + "- Please select a website category for each site\n"; } if(recip_check > 0) { ErrorMsg = ErrorMsg + "- Please provide a reciprocal URL for each site\n"; } } if(ErrorMsg != '') { alert('Please complete ALL the following fields to continue:\n' + ErrorMsg); return false; } else { return true; } }