/* CSS Document
 * @Revision $Revision: 271 $
 * @Author $Author: abhishek $
 * @Date $Date: 2008-10-17 11:52:06 +0530 (Fri, 17 Oct 2008) $
*/
function splchars(str){
		var mycars=new Array("(@@)","(##)","\\+\\+","\\$\\$","\\!\\!","\\~","\\>\\>\\>","\\<\\<\\<","\\?\\?","\\;","\\*\\*","\\%\\%","\\=\\=");
		for(var i = 0; i <mycars.length; i++ )
		{
			if(str.match(mycars[i])!=null){
			alert("Please do not enter continous special characters like '@','#','+','$','!','~','>','<','?',';','*' ");
			return false;
			}
		}
return true;
}

function trim(stringToTrim) {
 //alert(stringToTrim);
	return stringToTrim.replace(/^\s+|\s+$/g,'');
	}

function echeck(email){
	if(email==""){
	alert('Please enter email -id');
	return false;}
	else{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) {
      alert('Invalid email address');
      return false;
   }
	}
}
//////
function ValidateSendEmail(theForm)
{
	if(theForm.email_rcv.value=="" || theForm.email_rcv.value==0 )	{
	 alert("Please enter receiver's email");
	 theForm.email_rcv.focus();
	 return false;
	}
    var emailvalue=theForm.email_rcv.value;
	var mytool_array=emailvalue.split(",");
	for(i=0;i<mytool_array.length;i++)
	{
       //alert(mytool_array[i]);

		if (echeck(trim(mytool_array[i]))==false)
		{
		theForm.email_rcv.value="";
		theForm.email_rcv.focus();
		return false;
		}
	}


	var ur_name=trim(theForm.ur_name.value);
	if(ur_name=="" || ur_name==0 )
	{
	 alert("Please enter your name");
	 theForm.ur_name.focus();
	 return false;
	}

	var u_name=theForm.ur_name.value;
	u_name=u_name.replace(/(\s)+/g,'');
	if(u_name.length<3){
	alert("Please enter a name with more than two characters");
	theForm.ur_name.focus();
	 return false;
	}
	if(splchars(trim(theForm.ur_name.value))==false){
	theForm.ur_name.value="";
	theForm.ur_name.focus();
			return false;
	}
	if(theForm.ur_mail.value=="" || theForm.ur_mail.value==0)
	{
	 alert("Please enter your email");
	theForm.ur_mail.focus();
	 return false;
	}
	var emailvalue=theForm.ur_mail.value;
	if (echeck(trim(emailvalue))==false){
		theForm.ur_mail.value="";
		theForm.ur_mail.focus();
		return false;
	}
	if(splchars(theForm.ur_msg.value)==false){
	theForm.ur_msg.value="";
			theForm.ur_msg.focus();
			return false;
	}
	if(theForm.ur_msg.value=="" || theForm.ur_msg.value==0)
	{
	 alert("Please enter your message");
	 theForm.ur_msg.focus();
	 return false;
	}
	var flag12=false;
	var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for (var i = 0; i <theForm.ur_msg.value.length; i++)
		 {
			if (iChars.indexOf(theForm.ur_msg.value.charAt(i)) != -1)
			  {
					flag12=true;
					break;
			  }
		 }

		if(flag12==false)
		{
			alert("Please do not enter continous special characters like '@','#','+','$','!','~','>','<','?',';','*' ");
			theForm.ur_msg.value="";
			theForm.ur_msg.focus();
			return false;
	   }

	if(theForm.sec_img.value == ""){
	alert('Enter the  picture code shown');
	theForm.sec_img.focus();
	return false;
	}
}


function validate(form1,msgdiv){
	//alert(form1.cmnts_msg.value);

	var comment=trim(form1.cmnts_msg.value);
	var myRegExp = /fuck|asshole|www|^ass$|^.com$/;
	if(comment==""){
		alert('Enter a comment');
		msgdiv.style.display='block';
		form1.cmnts_msg.focus();
		return false;
	}

	var flag12=false;
	var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for (var i = 0; i <form1.cmnts_msg.value.length; i++)
		 {
			if (iChars.indexOf(form1.cmnts_msg.value.charAt(i)) != -1)
			  {
					flag12=true;
					break;
			  }
		 }

		if(flag12==false)
		{
			alert("Please do not enter continous special characters like '@','#','+','$','!','~','>','<','?',';','*' ");
			//form1.cmnts_msg.value="";
			msgdiv.style.display='block';
			form1.cmnts_msg.focus();
			return false;
	   }
if(splchars(form1.cmnts_msg.value)==false){
	//form1.cmnts_msg.value="";
	        msgdiv.style.display='block';
			form1.cmnts_msg.focus();
			return false;
	}
	var comnt=form1.cmnts_msg.value;
	var pattern=/([A-Z]|[a-z]|[0-9])(\1)(\1)(\1)/;
	if(pattern.test(comnt)){
		//form1.cmnts_msg.value="";
		form1.cmnts_msg.focus();
		alert("Continuous entry of characters.Please remove those characters");
		msgdiv.style.display='block';
		return false;
	}

	form1.cmnts_msg.value=form1.cmnts_msg.value.replace(/&/g,'|');

	var pass=trim(form1.cmnts_name.value);
	if(pass=="")
	{
		alert ("Enter your name");
		msgdiv.style.display='block';
		form1.cmnts_name.focus();
		return false;
	}
	else if(pass.length <3)
	{
		alert ("Name must contain morethan 3 characters");
		msgdiv.style.display='block';
		form1.cmnts_name.focus();
		return false;
		}
	if(pattern.test(pass)){
		//form1.cmnts_name.value="";
		form1.cmnts_name.focus();
		alert("Continuous entry of characters.Please remove those characters");
		msgdiv.style.display='block';
		return false;
	}
	if(splchars(form1.cmnts_name.value)==false){
	//form1.cmnts_name.value="";
			form1.cmnts_name.focus();
			return false;
	}
	var mail=echeck(form1.cmnts_mail.value);
	if(mail== false){
		//form1.cmnts_mail.value="";
		msgdiv.style.display='block';
		form1.cmnts_mail.focus();
		return false;
	}
	if(trim(form1.sec_img_cmnts.value) == ""){
		alert("Please enter the picture code shown");
		msgdiv.style.display='block';
		form1.sec_img_cmnts.value="";
		form1.sec_img_cmnts.focus();
		return false;
	}


	var comment=comment.toLowerCase();
	var matchPos1 = comment.search(myRegExp);

	if(matchPos1 != -1)
	{
	 alert('Your comments will be posted after editorial review');
	 msgdiv.style.display='block';
	 form1.cmnts_msg.focus();
	 return true;
	}
   //form1.submit();
   return true;
}


function login_validate(frm){
	var mail=echeck(frm.email.value);
	if(mail== false){
		frm.email.value='';
		frm.email.focus();
		return false;
		}
	var pass= trim(frm.password.value);
	if(pass == '')
	{
		alert('Enter a password');
		frm.password.value='';
		frm.password.focus();
	return false;
		}
	frm.submit();
}


function sho_hide1(num,cntcount){
examples="examples"+num;
document.getElementById(examples).style.display='block';
for(i=2;i<=cntcount+1;i++)
{
	if(i!=num)
	{
	examples="examples"+i;
	document.getElementById(examples).style.display='none';
	}
}
}

function sho_hide2(num){

examples="examples"+num;
document.getElementById(examples).style.display='none';
}