// JQuery Scripts
$(document).ready(function(){
    $('#content .scroll').jScrollPane({
        showArrows: false,
        arrowSize: 20,
        dragMinHeight: 19,
        dragMaxHeight: 19,
        scrollbarWidth: 19,
        scrollbarMargin: 10,
        wheelSpeed: 10
        
    });

    /**
	 * Image Rollover Functionality
	 */
	$(".rollover").mouseover(function(){
		imgsrc = $(this).attr("src");
		matches = imgsrc.match(/-ro/);
		// don't do the rollover if state is already ON
		if (!matches) {
			
			if(imgsrc.indexOf('.gif') > -1) {
				imgsrcON = imgsrc.replace(/.gif$/ig,"-ro.gif"); // strip off extension - Gif
			} else if(imgsrc.indexOf('.jpg') > -1) {
				imgsrcON = imgsrc.replace(/.jpg$/ig,"-ro.jpg"); // strip off extension - Jpg		
			}
			
			$(this).attr("src", imgsrcON);
		}
	});
	
	$(".rollover").mouseout(function() {
		$(this).attr("src", imgsrc);
	});
		
});


function Validator(theForm)
{

    if (theForm.contact_name.value == 0 || theForm.contact_name.value == 'your name') {
        alert("Please enter something in the \"Name\" field.");
        theForm.contact_name.value = '';
        theForm.contact_name.focus();
        return (false);
    }
    
    if (theForm.email.value == 0)  {
        alert("Please enter something in the \"Email\" field.");
        theForm.email.focus();
        return (false);
    }

    /////////////////////////////////////start of email check
    var emailStr = (document.theForm.email.value);

    var checkTLD=1;

    var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

    var emailPat=/^(.+)@(.+)$/;

    var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

    var validChars="\[^\\s" + specialChars + "\]";

    var quotedUser="(\"[^\"]*\")";

    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

    var atom=validChars + '+';

    var word="(" + atom + "|" + quotedUser + ")";

    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

    var matchArray=emailStr.match(emailPat);

    if (matchArray==null) {
        alert("Email email address seems incorrect (check @ and .'s)");
        
        var nogo="y";
        theForm.email.value = '';
        theForm.email.focus();

       
       return false;
    }

    var user=matchArray[1];
    var domain=matchArray[2];

    for (i=0; i<user.length; i++) {
        if (user.charCodeAt(i)>127) {
            alert("Ths username contains invalid characters.");
            var nogo="y";
                theForm.email.value = '';
                theForm.email.focus();
            return false;
        }
    }
    
    for (i=0; i<domain.length; i++) {
        if (domain.charCodeAt(i)>127) {
            alert("Ths domain name contains invalid characters.");
            var nogo="y";
                theForm.email.value = '';
                theForm.email.focus();
            return false;
        }
    }
    
    alert("Thank you, you're information has been submitted. We will get in contact with you shortly.");
}
