<!-- 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 forms have filled out properly.
function checkSubmission(){
	var msg = document.forms["contactus"].elements["textfield"].value;
	if ( (isName()) && (isEmail()) && (isSubject()) && (isComment()) ) {

		msg += "\r\r\r\r" + printDate();
		document.forms["contactus"].elements["success"].value = "http://www.samyasolutions.com/thankyou.html"
		document.forms["contactus"].elements["required-to"].value = "webmaster@samyasolutions.com"

		if (document.forms["contactus"].elements["sendcopy"].checked) {
			document.forms["contactus"].elements["sendcopy"].value = document.forms["contactus"].elements["required-email"].value;
		}
		else {
			document.forms["contactus"].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["contactus"].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["contactus"].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["contactus"].elements[2].select();         
                        document.forms["contactus"].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["contactus"].elements[4].value == ""){      
                alert("\nThe E-MAIL field is blank.\n\nPlease enter your e-mail address.")      
                document.forms["contactus"].elements[4].focus();      
                return false;       
        }   
        // Return false if e-mail field does not contain a '@' and '.' .   
        if (document.forms["contactus"].elements[4].value.indexOf ('@',0) == -1 || document.forms["contactus"].elements[4].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["contactus"].elements[4].select();      
                document.forms["contactus"].elements[4].focus();      
                return false;      
        }   
        else {
                return true;      
        }
}


// Checks the Subject field field.
function isSubject(){
		subj = document.forms["contactus"].elements["subject"];

		for (var i = 0; i < subj.options.length; i++) {
			if (subj.options[i].selected)
				subj_v = subj.options[i].value;
		}

		if (subj_v == "" || subj_v == " " || subj_v == "divider"){
			alert("\nPlease pick the most appropriate SUBJECT related to your inquiry.");
			subj.selectedIndex = 0;
			subj.focus();
			return false;
		}
		else return true;
}


// Checks the REQUEST/MESSAGE/TEXTFIELD field.
function isComment(){
		msg = document.forms["contactus"].elements["textfield"];
		if (msg.value == "" || msg.value == " "){
			alert("\nThe reason of using this form is to send us a request.\nTherefore, the request/message field may not be blank.");
			msg.select();
			msg.focus();
			return false;
		}
		else return true;
}



// Resets fields -hidden or not.
function Reset() {
	document.forms["contactus"].action = "";						// Where the form will submit.
	document.forms["contactus"].elements["success"].value = "";			// Successful submission page -initialized.
	document.forms["contactus"].elements["required-to"].value = "";		// Destination email -initialized.
	document.forms["contactus"].elements["required-name"].value = "";		// Destination email -initialized.
	document.forms["contactus"].elements["telephone"].value = ""; 		// Sender's phone number -initialized.
	document.forms["contactus"].elements["required-email"].value = "";		// Sender's email -initialized.
	document.forms["contactus"].elements["subject"].selectedIndex = 0;		// Subject pulldown -initialized.
	document.forms["contactus"].elements["textfield"].value = "";			// Message sent via email -initialized.
	document.forms["contactus"].elements["sendcopy"].checked = false;		// Send a copy to self -initialized.
	document.forms["contactus"].elements["required-name"].focus();		// Set focus on required-name.
}

// Reports if all forms have filled out properly.
function submitForm() {
	document.forms["contactus"].action = "http://www.samyasolutions.com/cgi-bin/cgiemail/forms/contactus.txt";
	document.forms["contactus"].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["contactus"].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["contactus"].elements[elnum].value = "";
			j = k + 1;
			document.forms["contactus"].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 -->

