/**********************************************************************************************
Email address validation script
***********************************************************************************************/
function email_validation(str)


    	{
    		at_flag=0;
    		dot_flag=0;
    		sp_flag=0;
    		sq_dot=0;
    		email_id="";
    		server="";
    		for(i=0;i<str.value.length;i++)


        		{
        			if(at_flag>0 && str.value.charAt(i)!=".")
        				server+=str.value.charAt(i)
        			if(str.value.charAt(i)==" ")
        				sp_flag++
        			if(str.value.charAt(i)=="@" && i!=0)
        				at_flag++
        			if(at_flag==0)
        				email_id=email_id+str.value.charAt(i)
        			if(str.value.charAt(i)=="." && str.value.charAt(i+1)==".")
        				sq_dot++;
        			if(str.value.charAt(i)=="." && at_flag==1 && (str.value.length-1)!=i && str.value.charAt(i-1)!="@")
        				dot_flag++
        		}
        		if(at_flag>1 || dot_flag==0 || at_flag==0 || sp_flag!=0 || sq_dot!=0 || str.value.charAt(str.value.length-1)=='.')
        			//alert("invalid");
					return("invalid");
        		else


            		{
            			if(email_string_validation(email_id) && email_string_validation(server))
						{
            				return(true);}
            			else
						return("invalid");
            			//	alert("invalid");
            		}
            	}
            	
            	//validate email strimg
            	
            	function email_string_validation(str)


                	{
                		flag=0
                		for(i=0;i<str.length;i++)


                    		{
                    			chr=str.charAt(i)
                    			if((chr>='a' && chr<='z') || (chr>='A' && chr<='Z') || (chr>='0' && chr<='9' && i!=0) || (chr=='_') || (chr=='-') || (i!=0 && chr=='.'))
                    				flag++;
                    		}
                    		if(flag==str.length)
                    			return(true)
                    		else
                    			return(false)
                    	}


/****************************************************************/

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

/**********************************************************************************************
Open and closes DIVs layers
***********************************************************************************************/

<!--
function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
//-->

function show_hide(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
		
	}
	else {
		document.getElementById(obj).visibility='visible';
		el.style.display = '';
	}
}

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

