// JavaScript Document
var justPop = 0;
var oldX = '0px';
var oldY = '0px';
//This moves the image a little and gives is a drop shadow on mouse over
function mainImg(dID)
{
	var mainBox = $(dID);
	oldX = mainBox.style.left;
	oldY = mainBox.style.top;
	//move them 5px
	var intX = parseInt( oldX );
	var intY = parseInt( oldY );
	var intX = intX + 5;
	var intY = intY + 5;
	if (navigator.appName !== 'Microsoft Internet Explorer')
	{
		mainBox.style.left = intX + 'px';
		mainBox.style.top = intY + 'px';
	}
	mainBox.className = 'pictureS';
}
//put image back
function mainBack( dID )
{
	var mainBox = $(dID);
	if (navigator.appName !== 'Microsoft Internet Explorer')
	{
		mainBox.style.left = oldX;
		mainBox.style.top = oldY;
	}
	mainBox.className = 'pictureBox';
}

function validateCont(frm)
{
	var valid = true;
	var msg = '';
	
	// check if first name was provided
	if (frm.name.value == '') {
		valid = false;
		msg = msg + '* Your Name is required\n';
	}
	
	if (frm.business_name.value == '') {
		valid = false;
		msg = msg + '* Your Company Name is required\n';
	}
	
	if (frm.email.value == '') {
		valid = false;
		msg = msg + '* Your Email Address is required\n';
	}
	else
	{
		//make sure email is valid email	
		if ( atCheck( frm.email.value ) == 1 )
		{
			//check domain
			if ( domainCheck( frm.email.value ) == 0 )
			{
				valid = false;
			msg = msg + '* A valid Email is required\n';
			}
		}
		else
		{
			valid = false;
			msg = msg + '* A valid Email is required\n';
		}
	}
	
	if (frm.daytime_phone.value == '') {
		valid = false;
		msg = msg + '* Your Daytime Phone Number is required\n';
	}
	
	if (frm.interest4.value == '') {
		valid = false;
		msg = msg + '* Please select level of urgency in "How Urgent is you request"\n';
	}
	
	if (frm.interest1.value == '') {
		valid = false;
		msg = msg + '* Please select an interest\n';
	}

	//send a captcha check
	/*  May work one day - throws challenge error
	DWREngine.setAsync(false);
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'captcha', 'document.f_contact.recaptcha_challenge_field.value', 'document.f_contact.recaptcha_response_field.value', retCap );
	DWREngine.setAsync(true);
	*/
	if (msg != '') alert(msg);
	return valid;
}

function retCap(r)
{
	alert(r);	
}

function atCheck( addy ) {
// Here, substitute formName and elementName for your
// form name and email textbox name.
// i.e. document.myForm.email.value
        var address = addy ;
        var at = address.indexOf("@") ;
        if(at >= 3) 
		{
        	return 1;
        } 
		else 
		{
        	return 0;
        }
}

function domainCheck( addy ) {
// Here, substitute formName and elementName for your
// form name and email textbox name.
// i.e. document.myForm.email.value
        var address = addy ;
        email = address.split("@") ;
        email.reverse() ;
        var server = email[0] ;
        domain = server.split(".") ;
        domain.reverse() ;
        var topLevel = domain[0] ;
        topLevelArray = new Array("com", "net", "org", "edu", "gov", "mil", "us", "at", "au", "br",
        "ca", "ch", "cn", "dk", "es", "fr", "de", "gb", "hk", "ie", "it", "jp", "mx", "no", "nt", "nz",
        "pt", "se", "sg", "th", "tw", "uk", "ad", "ae", "af", "ag", "ai", "al", "am", "an", "ao", "aq",
        "ar", "arpa", "as", "aw", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bm", "bn",
        "bo", "bs", "bt", "bv", "bw", "by", "bz", "cc", "cf", "cg", "ci", "ck", "cl", "cm", "co", "cr",
        "cs", "cu", "cv", "cx", "cy", "cz", "dj", "dm", "do", "dz", "ec", "ee", "eg", "eh", "et", "fi",
        "fj", "fk", "fm", "fo", "fx", "de", "ga", "gd", "ge", "gf", "gh", "gi", "gl", "gm", "gn", "gp",
        "gq", "gr", "gs", "gt", "gu", "gw", "gy", "hm", "hn", "hr", "ht", "hu", "id", "il", "in", "int",
        "io", "iq", "ir", "is", "jm", "jo", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky",
        "kz", "la", "lb", "lc", "li", "lk", "lr", "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "mg",
        "mh", "mk", "ml", "mm", "mn", "mo", "mp", "mq", "mr", "ms", "mt", "mu", "mv", "mw", "my", "mz",
        "na", "nato", "nc", "ne", "nf", "ng", "ni", "nl", "np", "nr", "nu", "om", "pa", "pe", "pf", "pg",
        "ph", "pk", "pl", "pm", "pn", "pr", "pw", "py", "qa", "re", "ro", "ru", "rw", "sa", "sb", "sc",
        "sd", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sr", "st", "su", "sv", "sy", "sz", "tc",
        "td", "tf", "tg", "tj", "tk", "tm", "tn", "to", "tp", "tr", "tt", "tv", "tz", "ua", "ug", "um", "uy",
        "uz", "va", "vc", "ve", "vg", "vi", "vn", "vu", "wf", "ws", "ye", "yt", "yu", "za", "zm", "zr", "zw") ;
        var tlaLength = topLevelArray.length - 1 ;
        if(server.indexOf(".") == -1) {
                return 0 ;
        }
        for(i = 0; i <= tlaLength; i++) {
                if(topLevelArray[i] == topLevel) {
                        var topLevelVal = true ;
                        return 1;
                }
        }
        if(topLevelVal != true) {
                return 0;
        }
}

