<!-- Activate Cloaking Device

function printDate() {
	// function returns Sun., December 23rd
	dayNames = new Array('Sun.','Mon.','Tues.','Wed.','Thur.','Fri.','Sat.'); 
	monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

	today = new Date();
	k = today.getDate();
	while(k>10)
		k=k-10;
	switch(k) {
		case 1:
		suffix="st"; break;
		case 2:
		suffix="nd"; break;
		case 3:
		suffix="rd"; break;
		default:
		suffix="th";
	}
	thisDay = today.getDate();
	// Fixing a bug when date is 11, 12 or 13 above code subtracts 10 making the date display 11st, 12nd and 13rd respectively.
	if (thisDay == 11 || thisDay == 12 || thisDay == 13) {
		suffix = "th";
	}
	var yy = today.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;
	return dayNames[today.getDay()]+', '+monthNames[today.getMonth()]+' '+thisDay+suffix+' '+year;
}



// Reports if all form fields have filled out properly.
function testForms(pageURL){
	var msg = document.forms[0].elements["textfield"].value
	var sname = document.forms[0].elements["required-name"].value
	emptyMsg = false;
	if (msg == "" || msg == " ") {
		emptyMsg = true;
	}
	houseURL = pageURL;
	if (pageURL == "" || pageURL == " "){
		houseURL = new String("http://www.samyasolutions.com");
	}

	if ( (isName()) && (isEmail()) && (isEmail2()) && (isComment()) ){

		document.forms[0].elements["subject"].value = "Check out Samya Solutions";
		document.forms[0].elements["success"].value = "http://www.samyasolutions.com/thanks.html?ref=" + houseURL;
		msg += "\r" + sname + " recommends Samya Solutions as a site that offers Small Businesses Professional Web Design.\r" + sname + " specifically recommends " + houseURL + " \r\rSamya Solutions offers Web design in such technologies as:\r- HTML, JavaScript and CSS (together known as DHTML)\r- CGI, Perl and SSI\r- PHP\r- Flash\r- Streaming Media\r\rAs we also offer:\r- Graphics (banners, etc.)\r- Logo Creation\r- Ad-copy\r- Digital Photography & Manipulation\r-Résumés (both print or online use)\r- And best of all ... Training\r\rThe above are merely a few.\rContact us online or off (214.207.3251)\r\r"
		if (emptyMsg) {
			msg += sname + " did not include a personal message for you.\r";
		}
		msg += printDate();

		document.forms[0].elements["textfield"].value = msg;

		if (document.forms[0].elements["sendcopy"].checked) {
			document.forms[0].elements["sendcopy"].value = document.forms[0].elements["required-email"].value;
		}
		else {
			document.forms[0].elements["sendcopy"].value = ""
		}
		submitForm();
	}
}


// Checks the NAME field.
// Assumes that the field is the 3rd element in the 1st form; after hidden fields, for example.
function isName(){   
        var str = document.forms[0].elements[2].value;   
        
        // Return false if name field is blank.   
        if (str == ""){      
                alert("\nThe NAME field is blank.\n\nPlease enter your name.")      
                document.forms[0].elements[2].focus();      
                return false;      
        }   
        
        // Return false if characters are not a-z, A-Z, or a space.   
        for (var i = 0; i < str.length; i++){      
                var ch = str.substring(i, i + 1);      
                if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' ' && ch != "-"){         
                        alert("\nThe NAME field only accepts letters, spaces & a dash.\n\nPlease re-enter your name.");         
                        document.forms[0].elements[2].select();         
                        document.forms[0].elements[2].focus();         
                        return false;         
                }      
        }   
        return true;   
}

// Checks the E-MAIL field of the sender
// Assumes that the field is the 4th element in the 1st form.
function isEmail(){   
        // Return false if e-mail field is blank.   
        if (document.forms[0].elements[3].value == ""){      
                alert("\nThe E-MAIL field is blank.\n\nPlease enter your e-mail address.")      
                document.forms[0].elements[3].focus();      
                return false;       
        }   
        // Return false if e-mail field does not contain a '@' and '.' .   
        if (document.forms[0].elements[3].value.indexOf ('@',0) == -1 || document.forms[0].elements[3].value.indexOf ('.',0) == -1){      
                alert("\nThe E-MAIL field requires a \"@\" and a \".\" be used.\n\nPlease re-enter your e-mail address.")      
                document.forms[0].elements[3].select();      
                document.forms[0].elements[3].focus();      
                return false;      
        }   
        else {
                return true;      
        }
}

// Checks the E-MAIL field of the destination.
// Assumes that the field is the 5th element in the 1st form.
function isEmail2(){   
        // Return false if e-mail field is blank.   
        if (document.forms[0].elements[4].value == ""){      
                alert("\nThe recipient\'s E-MAIL field is blank.\n\nPlease enter an e-mail address.")      
                document.forms[0].elements[4].focus();      
                return false;       
        }   
        // Return false if e-mail field does not contain a '@' and '.' .   
        if (document.forms[0].elements[4].value.indexOf ('@',0) == -1 || document.forms[0].elements[4].value.indexOf ('.',0) == -1){      
                alert("\nThe recipient\'s E-MAIL field requires an \"@\" and a \".\" be used.\n\nPlease re-enter the e-mail address.")      
                document.forms[0].elements[4].select();      
                document.forms[0].elements[4].focus();      
                return false;      
        }   
        else {      
                return true;      
        }   
}


// Checks the COMMENT field.
// Assumes that the field is the 6th element in the 1st form.
function isComment(){   
        // If comment field is blank, asks for confirmation that no comment is desired.   
        if (document.forms[0].elements[5].value == ""){      
                if (confirm("\nAlthough optional, you have not entered a personal message.\n\n- Click on CANCEL to include one.\n- Click on OK to continue without one."))
                        return true      
                else {         
                        document.forms[0].elements[5].focus();         
                        return false;               
                }      
        }
        else return true      
}



// Resets fields -hidden or not.
function Reset() {
	document.forms[0].action = "";					// Where the form will submit.
	document.forms[0].elements["success"].value = "";		// Successful submission "Thank you" page (url) -initialized.
	document.forms[0].elements["required-to"].value = "";		// Destination email -initialized.
	document.forms[0].elements["subject"].value = "";		// Email subject -initialized.
	document.forms[0].elements["required-email"].value = "";	// Sender's email -initialized.
	document.forms[0].elements["required-name"].value = "";	// Destination email -initialized.
	document.forms[0].elements["textfield"].value = "";		// Message sent via email -initialized.
	document.forms[0].elements["required-name"].focus();		// Set focus on required-name.
}

// Reports if all forms have filled out properly.
function submitForm() {
	document.forms[0].action = "http://www.samyasolutions.com/cgi-bin/cgiemail/forms/recommendus.txt";
	document.forms[0].submit();
}



// Add the following onBlur="checkForProfanity(5);" to the text field.
// The 5 assumes that the text field you're adding this to is the 6th element in your 1st form.
var k = 20;
var isProfane = new makeArray(k);
var word = new makeArray(k);
function checkForProfanity(elnum) {
	var temp = document.forms[0].elements[elnum].value;
	temp = temp.toLowerCase();
	word[1] = "shit";
	word[2] = "motherfucker";
	word[3] = "nigger";
	word[4] = " ass ";
	word[5] = "cunt";
	word[6] = "suck ";
	word[7] = "pussy";
	word[8] = "cock ";
	word[9] = "cum";
	word[10] = "penis";
	word[11] = "sex";
	word[12] = " dick";
	word[13] = "fuck";
	word[14] = "ass";
	word[15] = " fag ";
	word[16] = "bloody hell";
	word[17] = "asshole";
	word[18] = "bitch";
	word[19] = "blow job";
	word[20] = "biatch";
	for (var j = 1; j <= k; j++) {
		isProfane[j] = temp.indexOf(word[j]);
	}
	for (var j = 1; j <= k; j++) {
		if (isProfane[j] != -1) {
//			alert("Please refrain from using the word \'"+word[j]+"\'.");
			alert("samyasolutions.com is a respectable site.  Please refrain from using PROFANITY.\nYour personal message will now be erased.  Try again, only cleaner this time.");
			document.forms[0].elements[elnum].value = "";
			j = k + 1;
			document.forms[0].elements[elnum].focus();
		}
		else {}
	}
}

function makeArray(n) {
	this.length = n
	for (var i = 1; i<=n; i++) {
		this[i] = new String();
	}
	return this
}
// Deactivate Cloaking -->

