/* 
 * Form handler
 */
//<![CDATA[
var content,title;
function res(){
    $('#err').hide('slow');
}
function validate()
{
    var t = true;
    var f = document.forms[0];
    var err = document.getElementById('err');
    $('#err').html('').hide();
    err.innerHTML += "Sorry, but the following issues exist:<ul>";
    var nm = f.name;
    var em = f.email;
    var co = f.comment;
	var emnull = false;
	
    if(nm.value == "" || nm.value == null || nm.value == "Name is required")
    {
        err.innerHTML += "<li>Name is required</li>";
        t = false;
    }
    if(em.value == "" || em.value == null || em.value == "E-mail is required")
    {
        err.innerHTML += "<li>E-mail is required</li>";
        t = false;
		emnull = true;
    }
	if(emnull == false)
	{
		if((em.value != "" || em.value != null) && checkemail(em.value) != true)
		{
			err.innerHTML += "<li>A <strong>VALID</strong> email address is required</li>";
			t = false;
		}
	}
    if(co.value == "" || co.value == null || co.value == "Question or comment is required")
    {
        err.innerHTML += "<li>Question or comment is required</li>";
        t = false;
    }
    err.innerHTML += "</ul>";

    if(t){f.submit();}else{$('#err').show('slow'); }
}
function revert( obj )
{
    res();
    if(obj. value == "Question or comment is required" || 	obj.value == "E-mail is required" ||  obj.value == "Name is required")
    {
        obj.value = "";
        obj.style.backgroundColor = "#fff";
        obj.style.color = "#000";
    }
}
var win;
function openr( loc )
{
    var screen_height = window.screen.availHeight;
    var screen_width = window.screen.availWidth;
    var left_point = parseInt(screen_width/2)-(800/2);
    var top_point = parseInt(screen_height/2)-(700/2);
    win = window.open(loc,"win","width=800,height=700,top="+top_point+",left="+left_point+",scrollbars=1,toolbars=0,location=1,statusbar=0,resizable=1");
    win.focus();
}
if(win){self.onfocus = win.close();}

var testresults;
function checkemail(val){
	var str=val;
	var filter=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
	if (filter.test(str))
		testresults=true;
	else{
	testresults=false;
	}
	return (testresults)
}
//]]>


