function openwindow(x,y)
		{
			if(ie){
				if(y=="showmsg")
					var intr = window.open("popBulletinIndex.aspx?messageid=" + x,"pop","fullscreen")
				if(y=="addmsg")
					var intr = window.open("popBulletinIndex.aspx?topicid=" + x,"pop","fullscreen")
				intr.resizeTo(461,450);
				intr.moveTo(0,0)
				}
			if(ns){
				if(y=="showmsg")
					var intr = window.open("popMessageDesc.aspx?messageid=" + x ,"pop","toolbar=no,left=0,location=no,menubar=no,scrollbars=yes,width=460,height=525,top=0")	
				if(y=="addmsg")
					var intr = window.open("popMessageAdd.aspx?topicid=" + x ,"pop","toolbar=no,left=0,location=no,menubar=no,scrollbars=yes,width=460,height=525,top=0")	
				}	
		}
function validdate(dd,mm,yy)
{
	 if  (((yy % 4 == 0) && (yy % 100 != 0)) || (yy % 400 == 0))
	  {
		  if(mm == 2)
	  	{
				if(dd > 29)
				{
					alert("It is a Leap Year, Select a date upto 29th");
					return false;
				}
			}
		}
	  else
	  {
			if(mm == 2)
			{
				if(dd > 28)
				{
					alert("Select a date upto 28th for February");
					return false;
				}
			}
	  }
		if(mm == 4 || mm == 6 || mm == 9 || mm == 11)
		{
			if(dd > 30)
			{
				alert("Select date upto 30th")
				return false;
			}
		}
		return true;
}
		
function emailchk(x)
{
	var email = /[-a-zA-Z0-9&_\.]+@[-a-zA-Z0-9]+\.[-a-zA-Z0-9\.]+/;
	var eflag = x.value.match(email);
	//var semail = x.value;
	var squote = x.value.indexOf("'");
	//alert(x.indexOf("'"));
	//alert(semail);
	//alert(semail.indexOf("'"));
	//return false
	if(eflag!=x.value){				
		if(squote>0)
			alert("Email address must not have a single quote (')");
		else
			alert("Please Enter a Valid Email Address")
		x.focus();
		x.select();
		return false;
	}
	return true;
}



function isBlank(x,y)
{    
	if(x.selectedIndex==0)
	{
		alert("Please enter " + y);
		x.focus();			
		return false;
	}
	else
	{	    
	    return true;
    }
}

function validAddress(x)
{
	var num=/[0-9A-Za-z\.\,\-\s]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Please enter a valid address");
		x.focus();
		x.select();
		return false;
	}
	return true;
}


function validComment(x)
{
	var num=/[0-9A-Za-z\.\,\-\s]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Please enter valid characters in the Comment field");
		x.focus();
		x.select();
		return false;
	}
	return true;
}

function chkquotes(x)
{
	str = x.value
	for (a = 0; a<str.length; a++)
	{
		ch = str.charAt(a);
		if (ch == "'")
		{
			alert ("\' is not a valid character");
			x.focus();
			x.select();
			return true;
		}
	}
}
function dropdownchk(x,y)
{
	
	if(x.selectedIndex==0)
	{
		alert("please select a valid option for " + y);
		x.focus();
		return false;
	}
	else
	{
	return true;
	}
}
function alphanum(x)
{
	var num=/[0-9A-Za-z]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Only alphanumeric values are allowed");
		x.focus();
		x.select();
		return false;
	}
	else{
	return true;
	}
}
function spalpha(x,y)
{
	var num=/[\sA-Za-z]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Only alphabets are allowed in field " + y);
		x.focus();
		x.select();
		return false;
	}
	return true;
}
function percentchk(x)
{
	var num=/[0-9\%]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Please enter valid percentage");
		x.focus();
		x.select();
		return false;
	}
	return true;
}
function spalphadot(x,y)
{
	var num=/[A-Za-z\s\.]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Please enter valid " + y);
		x.focus();
		x.select();
		return false;
	}
	return true;
}
function numchk(x)
{

	var num=/[0-9\.\-]+/;
	uidflag=x.value.match(num);	
	//alert(uidflag);
	if(uidflag != x.value)
	{
		alert("Please enter numbers only");
		x.focus();
		x.select();
		return false;
	}
	else{
	return true;
	}
}

function spalphanum(x)
{
	var num=/[0-9A-Za-z\s]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Only alphanumeric values are allowed");
		x.focus();
		x.select();
		return false;
	}
	return true;
}

function validphone(x)
{
	var num=/[0-9\-\,\+\s\(\)\[\]]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Please enter a valid Telephone Number (Numbers, + and spaces only).");
		x.focus();
		x.select();
		return false;
	}
	return true;
}

function validFax(x)
{
	var num=/[0-9\-]+/;
	uidflag=x.value.match(num);	
	if(uidflag != x.value)
	{
		alert("Please enter valid Fax number");
		x.focus();
		x.select();
		return false;
	}
	return true;
}
function trimit(x)
{
	splitstr=x.value.split("");
	var i=0;
	if(splitstr[i]==" ")
	{
		x.value=""
		while(splitstr[i]==" ")
			i++;
		for(j=i;j<splitstr.length;j++,i++)
			x.value=x.value+splitstr[i];
	}
	splitstr=x.value.split("");
	
	i=splitstr.length-1
	if(splitstr[i]==" ")
	{
		x.value="";
		while(splitstr[i]==" ")
			i--;
		for(j=0;j<=i;j++)
			x.value=x.value+splitstr[j];
	}
}
function getChapters(){
	if(ie){
		chaptersDiv.style.visibility="visible";
		sidediv.style.visibility="visible";
	}
}

function getBookmarks(){
	if(ie){
		BookmarkDiv.style.visibility="visible";
		sidediv.style.visibility="visible";
	}
}




var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

if(input.value.length >= len && !containsElement(filter,keyCode)) {
	input.value = input.value.slice(0, len);
	input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
	found = true;
	else
	index++;
	return found;
	}
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
	}
	return true;
}



		