// JavaScript Document
function confirmMsg(msg){
	if(!confirm(msg)){
		return false;

	} else {
		return true;

	}
}


function password_validate()
{
	if(document.Frmgetpass.varUser.value == "")
	{
		alert("Please enter your username");
		document.Frmgetpass.varUser.focus();
		return false;
	}
	if(document.Frmgetpass.txtEmail.value == "")
	{
		alert("Please enter your registered email address");
		document.Frmgetpass.txtEmail.focus();
		return false;
	}
	if(!validateEmail(document.Frmgetpass.txtEmail.value,1,1))
	{
		document.Frmgetpass.txtEmail.focus();
		return false;
	}
}


//Email Validation Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}

 //Function phone validation Script
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}


/*function showState(passcountry){
		if (passcountry == "United States of America"){
			
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="block";
				postate.style.visibility="visible";
			}
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="none";
				pootherstate.style.visibility="hidden";
			}
		}
		else{
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="block";
				pootherstate.style.visibility="visible";
			}
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="none";
				postate.style.visibility="hidden";
			}
		}
	}*/
	
	function shodetails(){
	if (document.frm_register.txtcountry.value =="United States of America")
		{
		ap1=document.getElementById("msgid");
		    if(ap1){
			ap1.style.display="block";
			ap1.style.visibility="visible";
				}				
		}
      else {
		 
			ap1=document.getElementById("msgid");
			if(ap1){
			ap1.style.display="none";
			ap1.style.visibility="hidden";
			}
		}

	}
//Registration validation

function regvalidation(){
	
	if(document.frm_register.txtfname.value == "")
	{
	   alert("Please enter your first name");
	   document.frm_register.txtfname.focus();
	   return false;
	}
	
/*	if(document.frm_register.txtlname.value == "")
	{
	   alert("Please enter the last name");
	   document.frm_register.txtlname.focus();
	   return false;
	}
	*/
/*	Validation for address

if(document.frm_register.txtaddress.value == "")
	{
	   alert("Please enter the Address");
	   document.frm_register.txtaddress.focus();
	   return false;
	}*/
	
/*	if(document.frm_register.txtcity.value == "")
	{
	   alert("Please enter the city name");
	   document.frm_register.txtcity.focus();
	   return false;
	}*/
	if(document.frm_register.txtcountry.value == "Select a Country")
	{
	   alert("Please select a country");
	   document.frm_register.txtcountry.focus();
	   return false;
	}
	if(document.frm_register.txtcountry.value == "United States of America" && document.frm_register.state1.value == "choose"){
	
	   alert("Please select a state");
	   document.frm_register.state1.focus();
	   return false;
	}
	/*if(document.frm_register.txtcountry.value != "United States of America" && document.frm_register.state.value == ""){
	   alert("Please enter the state name");
	   document.frm_register.state.focus();
	   return false;
	}*/

	if(!validateEmail(document.frm_register.txtemail.value,1,1))
	{
	   document.frm_register.txtemail.focus();
	   return false;
	}
	if(document.frm_register.txtusername.value == "")
	{
		alert("Please Enter the Username");
		document.frm_register.txtusername.focus();
		return false;
	}
	

<!-- Original:  Russ Swift (rswift220@yahoo.com) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->


var invalid = " "; // Invalid character is a space
var minLength = 4; // Minimum length

// check for spaces
if (document.frm_register.txtusername.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed in the username.");
return false;
}

  var iChars = "!@`~#$%^&*()+=-[]\\\';,./{}|\":<>?";

  for (var i = 0; i < document.frm_register.txtusername.value.length; i++) {
  	if (iChars.indexOf(document.frm_register.txtusername.value.charAt(i)) != -1) {
  	alert ("Your username has special characters. \nThese are not allowed.\n Please remove them and try again.");
  	return false;
  	}
  }

  for (var i = 0; i < document.frm_register.txtpassword.value.length; i++) {
  	if (iChars.indexOf(document.frm_register.txtpassword.value.charAt(i)) != -1) {
  	alert ("Your password has special characters. \nThese are not allowed.\n Please remove them and try again.");
  	return false;
  	}
  }
  
    for (var i = 0; i < document.frm_register.txtconfirmpass.value.length; i++) {
  	if (iChars.indexOf(document.frm_register.txtconfirmpass.value.charAt(i)) != -1) {
  	alert ("Your password has special characters. \nThese are not allowed.\n Please remove them and try again.");
  	return false;
  	}
  }


// check for minimum length
if (document.frm_register.txtusername.value.length < minLength) {
alert('Your username must be at least ' + minLength + ' characters long. Try again.');
return false;
}

// check for spaces
if (document.frm_register.txtpassword.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed in the password.");
return false;
}


	
	// check for spaces
if (document.frm_register.txtconfirmpass.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed in the password.");
return false;
}


	
	
	
	var txtpassword=document.frm_register.txtpassword.value;
	if(document.frm_register.txtpassword.value == "")
	{
		alert("Please Enter the Password");
		document.frm_register.txtpassword.focus();
		return false;
	}
	var txtconfirmpass=document.frm_register.txtconfirmpass.value;
	if(document.frm_register.txtconfirmpass.value == "")
	{
		alert("Please Confirm Password");
		document.frm_register.txtconfirmpass.focus();
		return false;
	}
	if(txtconfirmpass != txtpassword){
	alert("Please make sure the password matches the confirmed password");
	document.frm_register.txtconfirmpass.focus();
	return false;
	}
	if(document.frm_register.txtusername.value == "")
	{
		alert("Please Enter the Username");
		document.frm_register.txtusername.focus();
		return false;
	}
	var formaddress = document.frm_register;
		if(!formaddress.chterms.checked)
			{
			alert("Please agree to the terms to proceed.");
			formaddress.chterms.focus;
			return false;
			}
return true;
}

function contact_validate(){
	if(document.frm_contact.name.value == ""){
		alert("Please Enter Your Name");
		document.frm_contact.name.focus();
		return false;
	}
	if(!validateEmail(document.frm_contact.email.value,1,1))
	{
	   document.frm_contact.email.focus();
	   return false;
	}
	if(document.frm_contact.message.value == ""){
		alert("Please submit your suggestions");
		document.frm_contact.message.focus();
		return false;
	}
	return true;
}


function reportabuse_validate(){

	
	if(document.frm_contact2.message.value == ""){
		alert("Please enter a reason for this abuse report");
		document.frm_contact2.message.focus();
		return false;
	}
	return true;
}


function suggestlink_validate(){

	
	if(document.frm_contact3.message.value == ""){
		alert("Please enter the URL you'd like to suggest.");
		document.frm_contact3.message.focus();
		return false;
	}
	return true;
}




function login_validate(){
	if(document.Frmlogin.txtUsername.value == ""){
		alert("Please Enter the Username");
		document.Frmlogin.txtUsername.focus();
		return false;
	}
	if(document.Frmlogin.txtPassword.value == ""){
		alert("Please Enter the Password");
		document.Frmlogin.txtPassword.focus();
		return false;
	}
	return true;
}


function createblog_validate(){
	if(document.frm_blog.txt_blogname.value == ""){
		alert("Please enter a title for your plog");
		document.frm_blog.txt_blogname.focus();
		return false;
	}
/*	if(document.frm_blog.txtshort.value == ""){
		alert("Please Enter the Short Description");
		document.frm_blog.txtshort.focus();
		return false;
	}*/
	//alert(document.getElementById("desc"));
	
	/*if(document.frm_blog.desc.value == ""){
		alert("Please Enter the Breif Description");
		document.frm_blog.desc.focus;
		return false;
	}*/
	return true;
}
//Email page validation
function email_validation(){
	if(document.frm_email.youremail.value == ""){
		alert("Please Enter Your Email");
		document.frm_email.youremail.focus();
		return false;
	}
	if(!validateEmail(document.frm_email.youremail.value,1,1))
	{
	   document.frm_email.youremail.focus();
	   return false;
	}
	if(document.frm_email.recemail.value == ""){
		alert("Please Enter Recipient Email");
		document.frm_email.recemail.focus();
		return false;
	}
	if(!validateEmail(document.frm_email.recemail.value,1,1))
	{
	   document.frm_email.recemail.focus();
	   return false;
	}
}


