 /* CSS Document
 * @Revision $Revision: 1172 $
 * @Author $Author: muthu $
 * @Date $Date: 2009-07-16 16:23:04 +0530 (Thu, 16 Jul 2009) $
*/
function showdiv()
{
if(document.getElementById('sharenews51')!=null)
document.getElementById('sharenews51').style.display='block';
else if(document.getElementById('sharenews52')!=null)
document.getElementById('sharenews52').style.display='block';
}
function hidediv()
{
if(document.getElementById('sharenews51')!=null)
document.getElementById('sharenews51').style.display='none';
else if(document.getElementById('sharenews52')!=null)
document.getElementById('sharenews52').style.display='none';
}
function showdiv1()
{
if(document.getElementById('sharenews21')!=null)
document.getElementById('sharenews21').style.display='block';
else if(document.getElementById('sharenews22')!=null)
document.getElementById('sharenews22').style.display='block';
}
function hidediv1()
{
if(document.getElementById('sharenews21')!=null)
document.getElementById('sharenews21').style.display='none';
else if(document.getElementById('sharenews22')!=null)
document.getElementById('sharenews22').style.display='none';
}

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 special characters");
			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.recieve_mail.value=="" || theForm.recieve_mail.value==0 )
	{
	 alert("Please enter receiver's email");
	 theForm.recieve_mail.focus();
	 return false;
	}
	var emailvalue=theForm.recieve_mail.value;
	var mytool_array=emailvalue.split(",");
	for(i=0;i<mytool_array.length;i++)
	{

		if(trim(mytool_array[i])== ""){
			alert("Please Enter valid mail Id");
			theForm.recieve_mail.value="";
			theForm.recieve_mail.focus();
			return false;
		}
		else if (echeck(trim(mytool_array[i]))==false)
		{
		theForm.recieve_mail.value="";
		theForm.recieve_mail.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.message.value)==false){
	theForm.message.value="";
			theForm.message.focus();
			return false;
	}
	if(theForm.message.value=="" || theForm.message.value==0)
	{
	 alert("Please enter your message");
	 theForm.message.focus();
	 return false;
	}
	var flag12=false;
	var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for (var i = 0; i <theForm.message.value.length; i++)
		 {
			if (iChars.indexOf(theForm.message.value.charAt(i)) != -1)
			  {
					flag12=true;
					break;
			  }
		 }

		if(flag12==false)
		{
			alert("Sorry! symbols or special characters are not allowed.");
			theForm.message.value="";
			theForm.message.focus();
			return false;
	   }

	if(theForm.sec_img1.value == ""){
	alert('Enter the  picture code shown');
	theForm.sec_img1.focus();
	return false;
	}
}

//////
function validate(form1){
	var comment=trim(form1.comment.value);
	if(comment==""){
		alert('Enter a comment');
		form1.comment.focus();
		return false;
	}


	var flag12=false;
	var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for (var i = 0; i <form1.comment.value.length; i++)
		 {
			if (iChars.indexOf(form1.comment.value.charAt(i)) != -1)
			  {
					flag12=true;
					break;
			  }
		 }

		if(flag12==false)
		{
			alert("Sorry! symbols or special characters are not allowed.");
			form1.comment.value="";
			form1.comment.focus();
			return false;
	   }
if(splchars(form1.comment.value)==false){
	form1.comment.value="";
			form1.comment.focus();
			return false;
	}
	var comnt=form1.comment.value;
	var pattern=/([A-Z]|[a-z]|[0-9])(\1)(\1)(\1)/;
	if(pattern.test(comnt)){
		form1.comment.value="";
		form1.comment.focus();
		alert("Continuous entry of a character.Please remove those characters");
		return false;
	}

	var mail=echeck(form1.email.value);
	if(mail== false){form1.email.value="";form1.email.focus(); return false;}

	var pass=trim(form1.pass.value);
	if(pass=="")
	{
		alert ("Enter the password");
		form1.pass.focus();
		return false;
	}
	if(splchars(form1.pass.value)==false){
	form1.pass.value="";
			form1.pass.focus();
			return false;
	}


}





function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function printThis()
{
    var usertype=navigator.userAgent.toLowerCase();
    if (window.print) {
        setTimeout('window.print();',200);
    }
    else if (usertype.indexOf("mac") != -1) {
        alert("Press 'Cmd+p' on your keyboard to print article.");
    }
    else {
        alert("Press 'Ctrl+p' on your keyboard to print article.")
    }
}


//Code by kumar... 0n 13-07-09
function hide()
{
	/*document.getElementById('textarea').value = "";*/
if(trim(document.form1.textarea.value)==trim("Please mention your email id, phone number and address, it will help the buyers to contact you."))
	{
		document.form1.textarea.value="";
	}

}

function textCounter(field,cntfield,maxlimit)
 {
 // if too long...trim it!

   if (field.value.length > maxlimit)
   {

   field.value = field.value.substring(0, maxlimit);
   //alert(field.value.length);
   }
   else
   {
   cntfield.value = maxlimit - field.value.length;
   //alert(cntfield.value);
   }
 }


