
function regular(string)
{
if (!string) return false;
var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";

for (var i = 0; i < string.length; i++)
{ if (Chars.indexOf(string.charAt(i)) == -1)
return false;
}
return true;
}

function plantsubmit(){
	var val = document.getElementById("currency").value;
	if(val){
		document.selectcurrency1.action = "plant_on_special.php";
		document.selectcurrency1.submit();
	}else{
		alert("Please select the currency type");
		return false;
	}
}

function dedicateplant(){
	var val = document.getElementById("donatecurrency").value;
	if(val){
		document.selectcurrency2.action = "dedicate_tree.php";
		document.selectcurrency2.submit();
	}else{
		alert("Please select the currency type");
		return false;
	}

}

function regular1(string)
{
if (!string) return false;
var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ ";

for (var i = 0; i < string.length; i++)
{ if (Chars.indexOf(string.charAt(i)) == -1)
return false;
}
return true;
}


function emailCheck (emailStr) {
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 address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    //alert("The username doesn't seem to be valid.")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   //alert("The address must end in a three-letter domain, or two letter country.")
   return false
}
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
return true;
}

function ValidateNo( NumStr, String )
	{
 		for( var Idx = 0; Idx < NumStr.length; Idx ++ )
 		{
			 var Char = NumStr.charAt( Idx );
			 var Match = false;

				for( var Idx1 = 0; Idx1 < String.length; Idx1 ++)
				{
					 if( Char == String.charAt( Idx1 ) )
					 Match = true;
				}

				if ( !Match )
					return false;
 		}

        	return true;
	}


// popup for login page

function vis(frm)
   {
   	 document.getElementById("forgotdiv").style.display="none";
   }
 
 function open_win1()
   {

//	document.getElementById("logindiv").style.display="block";
	document.getElementById("logindiv").innerHTML='<table cellpadding="0" cellspacing="0" border="0" width="230"><tr><td><img src="images/view_online.jpg" alt="" name="login" border="0" id="login" /></td></tr><tr><td><div class="loginbox"><div style="height:100px; width:229px; background-color:#EFF0EB; padding:0px; margin:0px;"><form name="frm" method="post" action="" onSubmit="return validate(this);"><div class="textgray" style="padding-top:10px; padding-left:10px;">E-mail<img src="images/trans.gif" alt="" height="1" width="31" /><input type="text" name="uname" class="textbox1" style="width:120px; height:17px;" value="" /><br /><img src="images/trans.gif" alt="" height="5" /><br />Password<img src="images/trans.gif" alt="" width="13" /><input type="password" value="" name="password" class="textbox1" style="width:120px; height:17px;" /><br /><img src="images/trans.gif" alt="" height="5" /><br /><img src="images/trans.gif" alt="" height="1" width="66" /><input type="image" src="images/login_button.jpg"/><br /><img src="images/trans.gif" alt="" height="2" width="67" /><a href="#" style="color:#575757; text-decoration:none; font-weight:normal;" onClick=document.getElementById(\"lightpic\").style.display=\"block\"; document.getElementById(\"fade\").style.display=\"block\";document.getElementById(\"lightpic\").className=\"dispdiv\"; document.getElementById(\"fade\").className=\"fadediv\";ll();floatdiv(\"lightpic\",lpos,100).floatIt();>Forgot Password?</a></div></form></div></div></td></tr><tr><td><img src="images/view_online_bottom.jpg" border="0" alt="" align="bottom" /></td></tr></table>'; 
   }
 
function open_win()
   {
//   window.open('forgetpassword_popup.html','welcome', 'width=248,height=124,menubar=no,status=no,location=no,toolbar=no,scrollbars=no,resizable=no');
	document.getElementById("forgotdiv").style.display="block";
	document.getElementById("forgotdiv").innerHTML="<div style='background:url(images/forgot_password_popup.jpg) no-repeat; width:229px; height:115px;' class='textgray'><div style='padding-left:15px; padding-right:15px; padding-top:5px;'><div style='text-align:right;'><img str='images/trans.gif' alt='' height='2' width='80' /><a href='#' onclick='vis();' style='cursor: pointer;'><img src='images/close_icon.jpg' border='0' alt='' /></a></div></div><div style='padding-left:25px; padding-right:25px;'><span class='greenheading'>Forgot Password?</span><br />Please enter the e-mail ID that you have mentioned at the time of making a donation. We will send your password to the same.</div></div>"; 
   }
   
var http;
function getHTTPObject()
{
		var http_request;
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) { 
						//alert(e);
					}
            }
        }
        if (!http_request) {
            //alert("Giving up :( Cannot create an XMLHTTP instance");
            return false;
        }
        return http_request;
	}





