 function echeck(str) {

  var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail")
		  return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail")
		   return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail")
		   return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail")
		   return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail")
		   return false
		 }
		   return true	
}	

var http_request = false;
 var tagtoprint;


     function makeRequest(url) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, true);
        http_request.send(null);

    }

    function alertContents()
    {
        if (http_request.readyState == 4)
        {
            if (http_request.status == 200)
            {
                 //tagtoprint.firstChild.nodeValue=http_request.responseText.toString();
                 tagtoprint.innerHTML=http_request.responseText;    
				             
            }
            else
                alert('There was a problem with the request.');
        }
    }

    function fetchinfo(url,div)
    {
       tagtoprint=document.getElementById(div);
       makeRequest(url); 
	   document.getElementById(div).style.display = 'block'; 
    }
    function fetchinfo2(url,div)
    {
       tagtoprint=document.getElementById(div);
       makeRequest(url); 
    }
    function recbranch(str)
    { 
	 var url='prt.grabrecbranch.php';	   
		 url=url+"?fldRecID="+str	 
	var div='recbrsel';
       tagtoprint=document.getElementById(div);
       makeRequest(url); 
	   document.getElementById(div).style.display = 'block'; 
    }
    function empbranch(str)
    { 
	 var url='prt.grabempbranch.php';	   
		 url=url+"?fldEmpID="+str	 
	var div='empbrsel';
       tagtoprint=document.getElementById(div);
       makeRequest(url); 
	   document.getElementById(div).style.display = 'block'; 
    }
 
function closediv(div){
   document.getElementById(div).style.display = 'none'; 
   }

function validate_form ( )
{
    valid = true;

    if ( document.addmessage.fldTitle.value == "" )
    {
        alert ( "You have not entered any text for your message title." );
        valid = false;
    }
	if(document.addmessage.mymessage.value.length < 10)
	{
		alert("You must enter at least 10 charaters");
		valid = false;
	}
    return valid;
}


function blockspan(select){
var span ='depth';
document.getElementById(span).innerHTML = (select.options[select.selectedIndex].value * 125) 
				} 
function opendiv(div){ 

   document.getElementById(div).style.display = 'block'; 
				}
function comments()
    {
	 var errors=0; 
	
	if (document.blogcomments.name.value.length < 2 )
    {
        alert ( "Please add your name");
        errors ++;
    } 
	
	var emailID=document.blogcomments.email
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		valid = false;
	}
	
   	 if (document.blogcomments.comment.value.length < 10 )
    {
        alert ( "Please add your comments (min 10 chars)");
        errors ++;
    } 
     if(!errors)
   {

  
	var str=document.blogcomments.n.value;
	var name=document.blogcomments.name.value;
	var email=document.blogcomments.email.value;
	var comment=escape(encodeURI(document.blogcomments.comment.value));
	
	var url='http://www.hirescores.com/prt.comments.php';
	 	url=url+"?n="+str+"&name="+name+"&email="+email+"&comment="+comment;
       tagtoprint=document.getElementById('comments');
       makeRequest(url); 

   }

    } 

