//to avoid the overhead of the SDK, I pulled the appropriate validate functions from it
function IsName(str){
    return str.match(/^[a-zA-Z0-9 -]+$/) != null;
}
	
function IsEmail(str){
    return str.match(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/) != null;
}

function OptionSelected(index){
    return (index != 0);
}

function IsEmpty(val){
    return (val != '' || val.search(/[a-zA-Z0-9]/) != -1);
}

function FormCheck(form){
    var check = {"name" : IsName, "EMAIL_SENDER" : IsEmail, "topIssues" : OptionSelected, "desc" : IsEmpty}
    var curVal;
    var success = true;
    
    for(var item in check){
        //grab the value and the corresponding label for the field we are checking
        if(item == 'topIssues')
            curVal = form[item].selectedIndex;
        else
            curVal = form[item].value;
        if(check[item](curVal)){
            document.getElementById('label_' + item).className = '';
        }
        else{
            document.getElementById('label_' + item).className = 'error';
            success = false;
        }
    }
    
    if(!success){
        document.getElementById('errorMsg').style.display = 'block';
        return false;
    }

    return true;
} 	

// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.document.getElementById1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.document.getElementById1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();