
function validatelogin()  {
	if (formlogin.userid.value=="") {
    	alert("Please enter your userid")
	    FormLogin.userid.select ()
	    FormLogin.userid.focus ()
	    return false
   		}
	if (formlogin.password.value=="") {
	    alert("Please enter your password")
    	FormLogin.password.select ()
	    FormLogin.password.focus ()
    	return false
   		}
	}

function validatenewquestion()
	{
  	if (document.formnewquestion.userid.value=="")
		{
	    alert("Please Enter Your userid")
	    document.formnewquestion.userid.select()
	    document.formnewquestion.userid.focus()
	    return false;
	}
	if (document.formnewquestion.password.value=="")
	{
	    alert("Please Enter Your Password")
	    document.formnewquestion.password.select()
	    document.formnewquestion.password.focus()
	    return false;
	}
	if (document.formnewquestion.question.value=="")
	{
	    alert("Please Enter Your question")
	    document.formnewquestion.question.select()
	    document.formnewquestion.question.focus()
	    return false;
	}
	var messagelength = document.formnewquestion.question.value;
	if (messagelength.length>200)
	{
	    alert("The text counted "+messagelength.length+" characters. Please enter within 200 characters")
	    document.formnewquestion.question.select()
	    document.formnewquestion.question.focus()
	    return false;
	}
	return true; 
}

function validatenewtopic()
	{
  	if (document.formnewtopic.userid.value=="")
		{
	    alert("Please Enter Your UserID")
	    document.formnewtopic.userid.select()
	    document.formnewtopic.userid.focus()
	    return false;
	}
	if (document.formnewtopic.password.value=="")
	{
	    alert("Please Enter Your Password")
	    document.formnewtopic.password.select()
	    document.formnewtopic.password.focus()
	    return false;
	}
	if (document.formnewtopic.topic.value=="")
	{
	    alert("Please enter a Topic name")
	    document.formnewtopic.topic.select()
	    document.formnewtopic.topic.focus()
	    return false;
	}
	var topiclength = document.formnewtopic.topic.value;
	if (topiclength.length>35)
	{
	    alert("The topic name counted "+messagelength.length+" characters. Please enter within 35 characters")
	    document.formnewtopic.topic.select()
	    document.formnewtopic.topic.focus()
	    return false;
	}
	if (document.formnewtopic.message.value=="")
	{
	    alert("Please describe your topic")
	    document.formnewtopic.message.select()
	    document.formnewtopic.message.focus()
	    return false;
	}
	var messagelength = document.formnewtopic.message.value;
	if (messagelength.length>500)
	{
	    alert("The text counted "+messagelength.length+" characters. Please enter within 500 characters")
	    document.formnewtopic.message.select()
	    document.formnewtopic.message.focus()
	    return false;
	}
	return true; 
}


function validatediscsubject(newname)
{ 
  if (newname.value=="")
  {
    alert("Please Enter The SubjectName")
    newname.select()
    newname.focus()
    return false
   }
   return true;
 } 
 function warning()
 {
	var reply=confirm("All the topics under this subject will be lost.Are you sure you want to delete")
    if (reply == true)
      	return true
    else
    	return false    
    }
function validateNewExample()
	{
  	if (document.formnewexample.userid.value=="")
		{
	    alert("Please Enter Your trterterter UserID")
	    document.formnewexample.userid.select()
	    document.formnewexample.userid.focus()
	    return false;
	}
	if (document.formnewexample.password.value=="")
	{
	    alert("Please Enter Your Password")
	    document.formnewexample.password.select()
	    document.formnewexample.password.focus()
	    return false;
	}
	if (document.formnewexample.question.value=="")
	{
	    alert("Please enter a short title of your Example")
	    document.formnewexample.question.select()
	    document.formnewexample.question.focus()
	    return false;
	}
	var mtitle = document.formnewexample.question.value;
	if (mtitle.length > 35)
	{
	    alert("The title counted "+mtitle.length+" characters. Please enter within 35 characters")
	    document.formnewexample.question.select()
	    document.formnewexample.question.focus()
	    return false;
	}
	if (document.formnewexample.answer.value=="")
	{
	    alert("Please enter the details of your example")
	    document.formnewexample.answer.select()
	    document.formnewexample.answer.focus()
	    return false;
	}
	var manswer = document.formnewexample.answer.value;
	if (manswer.length > 1000)
	{
	    alert("The description counted "+manswer.length+" characters. Please enter within 1000 characters")
	    document.formnewexample.answer.select()
	    document.formnewexample.answer.focus()
	    return false;
	}
		return true; 
}
function validateNewProblem()
	{
  	if (document.formnewproblem.userid.value=="")
		{
	    alert("Please Enter Your trterterter UserID")
	    document.formnewproblem.userid.select()
	    document.formnewproblem.userid.focus()
	    return false;
	}
	if (document.formnewproblem.password.value=="")
	{
	    alert("Please Enter Your Password")
	    document.formnewproblem.password.select()
	    document.formnewproblem.password.focus()
	    return false;
	}
	if (document.formnewproblem.question.value=="")
	{
	    alert("Please enter a short title of your Example")
	    document.formnewproblem.question.select()
	    document.formnewproblem.question.focus()
	    return false;
	}
	var mtitle = document.formnewproblem.question.value;
	if (mtitle.length > 35)
	{
	    alert("The title counted "+mtitle.length+" characters. Please enter within 35 characters")
	    document.formnewproblem.question.select()
	    document.formnewproblem.question.focus()
	    return false;
	}
	if (document.formnewproblem.answer.value=="")
	{
	    alert("Please enter the details of your problem")
	    document.formnewproblem.answer.select()
	    document.formnewproblem.answer.focus()
	    return false;
	}
	var manswer = document.formnewproblem.answer.value;
	if (manswer.length > 500)
	{
	    alert("The description counted "+manswer.length+" characters. Please enter within 500 characters")
	    document.formnewproblem.answer.select()
	    document.formnewproblem.answer.focus()
	    return false;
	}
	if (document.formnewproblem.answer1.value=="")
	{
	    alert("Please enter the solution to your problem")
	    document.formnewproblem.answer1.select()
	    document.formnewproblem.answer1.focus()
	    return false;
	}
	var manswer = document.formnewproblem.answer1.value;
	if (manswer.length > 1000)
	{
	    alert("The description counted "+manswer.length+" characters. Please enter within 1000 characters")
	    document.formnewproblem.answer1.select()
	    document.formnewproblem.answer1.focus()
	    return false;
	}
		return true; 
}

function validateReplytopic()
	{
  	if (document.replytopic.userid.value=="")
		{
	    alert("Please Enter Your userid")
	    document.replytopic.userid.select()
	    document.replytopic.userid.focus()
	    return false;
	}
	if (document.replytopic.password.value=="")
	{
	    alert("Please Enter Your Password")
	    document.replytopic.password.select()
	    document.replytopic.password.focus()
	    return false;
	}
	if (document.replytopic.topic.value=="")
	{
	    alert("Please Enter Your Topic")
	    document.replytopic.topic.select()
	    document.replytopic.topic.focus()
	    return false;
	}
	if (document.replytopic.message.value=="")
	{
	    alert("Please Enter Your Message")
	    document.replytopic.message.select()
	    document.replytopic.message.focus()
	    return false;
	}
	var messagelength = document.replytopic.message.value;
	if (messagelength.length>500)
	{
	    alert("The reply counted "+messagelength.length+" characters. Please enter within 500 characters")
	    document.replytopic.message.select()
	    document.replytopic.message.focus()
	    return false;
	}
	return true; 
}

function check_len500(txtfield) {
	//txtfield is the name of field to count length, like onkeypress(fieldname)
	//txtlen is the if of <td> where the value to be displayed
    document.getElementById("txtlen500").innerHTML="<font class=fontred>Char count: "+txtfield.value.length+"/ 500</font><br><br><br><br>";
	return true;
	}
function check_len1000(txtfield) {
	//txtfield is the name of field to count length, like onkeypress(fieldname)
	//txtlen is the if of <td> where the value to be displayed
    document.getElementById("txtlen1000").innerHTML="<font class=fontred>Char count: "+txtfield.value.length+"/ 1000</font><br><br><br><br><br><br>";
	return true;
	}

function validatemember()
	{
	if (document.member.firstname.value=="")
		{
		alert("Please Enter Your Firstname")
		document.member.firstname.select()
		document.member.firstname.focus()
		return false;
		}
	if (document.member.lastname.value=="")
		{
		alert("Please Enter Your Lastname")
		document.member.lastname.select()
		document.member.lastname.focus()
		return false;
		}  
	if (document.member.emailid.value=="")
		{
		alert("Please Enter Your Emailid")
		document.member.emailid.select()
		document.member.emailid.focus()
		return false;
		} 
	var post=document.member.postalcode.value;
	if (post != "")
		{
		for (var i= 0;i <post.length;i++)
			{
			var ch=post.substring(i,i+1);
			if (( ch < "0"|| "9"< ch))
			{
			alert("Invalid characters in the postalcode")
			document.member.postalcode.select()
			document.member.postalcode.focus()
			return false;
			} 
			}  
		}     
	var phone=document.member.phonenumber.value; 
	if (phone!="")
		{
		for (var i= 0;i<phone.length; i++)
			{
			var ch = phone.substring(i,i+1);
			if (( ch < '0' || '9'< ch)&& (ch != '-')&&(ch != '(') &&(ch != ')'))
			{
			alert("Invalid characters in the phone number")
			document.member.phonenumber.select()
			document.member.phonenumber.focus()
			return false;
			} 
		}
    	}
    fax=document.member.faxnumber.value
    if (fax != "")
		{
		for (var i= 0;i<fax.length; i++)
		{
		var ch = fax.substring(i,i+1);
		if (( ch < '0' || '9'< ch)&& (ch != '-')&&(ch != '(') &&(ch != ')'))
			{
			alert("Invalid characters in the fax number")
			document.member.faxnumber.select()
			document.member.faxnumber.focus()
			return false;
			} 
		}
    	} 
   	if (document.member.tmpuserid.value=="")
		{
		alert("Please Enter Your userid")
		document.member.tmpuserid.select()
		document.member.tmpuserid.focus()
		return false;
		}
	if (document.member.password.value=="")
		{
		alert("Please Enter Your Password")
		document.member.password.select()
		document.member.password.focus()
		return false;
		}
	if (document.member.confirmpassword.value=="")
		{
		alert("Please Enter Your confirmpassword")
		document.member.confirmpassword.select()
		document.member.confirmpassword.focus()
		return false;
		}
	if (document.member.hintquestion.value=="")
		{
		alert("Please Enter Your HintQuestion")
		document.member.hintquestion.select()
		document.member.hintquestion.focus()
		return false;
		}
	if (document.member.hintanswer.value=="")
		{
		alert("Please Enter Your HintAnswer")
		document.member.hintanswer.select()
		document.member.hintanswer.focus()
		return false
		}
	var x=document.member.password.value
	var y = document.member.confirmpassword.value 
	if (x!=y)
		{
		alert("Confirm Password Not Matching")
		document.member.confirmpassword.select()
		document.member.confirmpassword.focus()
		return false;
		}
	return true; 
	}
function validemail(email){			//function for validating emailid
	invalidchar="/:;'%&#$*()"
	for (i=0;i<invalidchar.length;i++){
	badchar=invalidchar.charAt(i)
	if (email.indexOf(badchar,0) > -1)
	{   return false }
	}
	atpos=email.indexOf("@",1)
    if (atpos == -1)
    {   return false  }
    if (email.indexOf("@",atpos+1)!= -1)
    {  return false  }
    periodpos=email.indexOf(".",atpos)
    if (periodpos == -1)
    { return false }
    if (periodpos+3 >email.length)
    {return false}
    return true
    }
function realcheck(value)
	{
    if(!validemail(value))
    {
     alert("Invalid EmailId")
     document.member.emailid.focus()
     document.member.emailid.select()
     return false;
    }
     return true;
	}
 
 function show_vpopup(elementid,event)
 {
 var xposition,yposition,xpage,ypage,element=null;
 var offset= 20;           
 var bulletWidth=150;       
 var bulletgap=100;           
 bulletStyle=null;
  
  if (document.layers) {
    bulletStyle=document.layers[elementid];
    xpage = event.pageX ; ypage  = event.pageY;
    xposition = xpage ;yposition = ypage ;		
  } else if (document.all) {
    element=document.all[elementid]
    xposition = event.x ;yposition = event.y ;
    xpage=xposition ; ypage=yposition	;	
    if (document.body.scrollLeft) xpage = xposition + document.body.scrollLeft ; 
    if (document.body.scrollTop) ypage = yposition + document.body.scrollTop;
  } else if (document.getElementById) {
	  element=document.getElementById(elementid)
    xposition = event.clientX ; yposition = event.clientY ;
    xpage=xposition ; ypage=yposition	;	
    if(event.pageX) xpage = event.pageX ;
    if(event.pageY) ypage  = event.pageY ;
  }
  if(element)  bulletStyle=element.style;

  if(bulletStyle) {
   
     var yp0=ypage;
		 var yf0=yposition;
		 
     if(bulletStyle.width) bulletWidth = parseFloat(bulletStyle.width);
     if(bulletStyle.height) bulletgap = parseFloat(bulletStyle.height);
		 
     if (xposition > bulletWidth+offset) xpage=xpage-bulletWidth-offset;
     else {
         if (xposition >0.5*bulletWidth+offset) xpage=xpage-0.5*bulletWidth-offset;
				 else xpage=xpage+15;}
     if ( yposition > bulletgap+offset ) ypage=ypage-bulletgap-offset
		 else ypage=ypage+offset;
			 
		 if (!bulletStyle.width)	ypage=yposition+offset;
		 if(typeof(bulletStyle.left)=='string') {
				 bulletStyle.left=xpage+'px'; bulletStyle.top=ypage+'px';  
		} else {
				bulletStyle.left=xpage     ; bulletStyle.top=ypage ; }
     bulletStyle.visibility="visible"; 
     bulletStyle.zIndex="99";}
 }
 function hide_vpopup(m_id)
 {
 		document.getElementById(m_id).style.visibility = "hidden";
 }
function topichelp()
 {
 		 openWin = window.open("../discussion/images/topichelp.gif","helpwindow",
 		 "top=200,left=200,width=620,height=200,scrollbars=no,menubar=no,resizable=no,status=no,toolbar=no");
 }
function discussionhelp()
 {
 		 openWin = window.open("../discussion/images/discussionhelp.gif","helpwindow",
 		 "top=200,left=200,width=620,height=250,scrollbars=no,menubar=no,resizable=no,status=no,toolbar=no");
 }
	