
//Popup Window
function popup(mylink, windowname)
{
	if (! window.focus)
		return true;
	
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	
	window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
	
	return false;
}



//Confirmation Window
function confirmDelete() 
{
        return confirm('Do you really want to Delete?')
		//onclick="return confirm('Are you sure you want to delete this record?')"
}
   
// Validate eamil address
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)
		{
		     return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		    return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		   
		    return false
		}

		if (str.indexOf(at,(lat+1))!=-1)
		{
		    
		    return false
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		   
		    return false
		}

		if (str.indexOf(dot,(lat+2))==-1)
		{
		   
		    return false
		}
		
		if (str.indexOf(" ")!=-1)
		{
		   
		    return false
		}

 		return true					
}

//Validate contant forms
function ValidateContactForm()
{
	var username=document.contactForm.username
	var email=document.contactForm.email
	var comment=document.contactForm.comment
	
	if ((username.value==null)||(username.value==""))
	{
		alert("Enter your name!")
		username.focus()
		return false;
	}
	
	if ((email.value==null)||(email.value==""))
	{
		alert("Enter your email address!")
		email.focus()
		return false;
	}
	
	if (echeck(email.value)==false)
	{
		alert("Enter valid eamil address!")
		email.focus()
		return false;
	}
		
	if ((comment.value==null)||(comment.value==""))
	{
		alert("Enter your comments!")
		comment.focus()
		return false;
	}
	
	return true;
 }



