// JavaScript Document
function showRemainingCharacters(fieldname,totalchars,containerid)
{   words=fieldname.value;
    remains=parseInt(totalchars)-parseInt(fieldname.value.length);
	if(remains>=0)
	{
      containerid.innerText=remains +" Character Remaining.";
	}
	else
	{
	  event.keyCode=0;
	  words=words.substr(0,totalchars);
	  fieldname.value=words;
	}
}

function checkint()
 {
   a=event.keyCode;
   if (a!=40 && a!=41 && a!=43 && a!=45)
   {
    if (a<48 || a>57)
    {
     event.keyCode=0;
    }
   }	
 }

function emailvalidation(entered, alertbox)
{
with (entered)
{
apos=entered.indexOf("@");
dotpos=entered.lastIndexOf(".");
lastpos=entered.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function validarticle()
{
if(document.forms.articles.title.value=="")
  {
	  alert("Title field cannot be left blank.");
	  document.forms.articles.title.focus();
  }
else if(document.forms.articles.category.value=="0")
  {
	  alert("Please select a category.");
	  document.forms.articles.category.focus();
  }
else if(document.forms.articles.article.value=="")
  {
	  alert("You didn't write article.");
	  document.forms.articles.article.focus();
  }
else if(document.forms.articles.sendername.value=="")
  {
	  alert("Please write your Name");
	  document.forms.articles.sendername.focus();
  }
else if(document.forms.articles.man.value!=document.forms.articles.man2.value)
  {
	  alert("Please Enter Verification Code as same as written in the box right to the Verification Code text box.");
	  document.forms.articles.man.focus();
  }
else if(!emailvalidation(document.forms.articles.email.value,'Invalid Email Id'))
  {
	  articles.email.focus();
  }
else
  {
  	  document.forms.articles.submit();
  }
}

function validfreebusiness()
{
if(document.forms.freebusinesslisting.companyname.value=="")
  {
	  alert("Company Name cannot be left blank.");
	  document.forms.freebusinesslisting.companyname.focus();
  }
else if(document.forms.freebusinesslisting.address.value=="")
  {
	  alert("Address is an important information. It cannot be left blank.");
	  document.forms.freebusinesslisting.address.focus();
  }
else if(document.forms.freebusinesslisting.city.value=="")
  {
	  alert("City name cannot be left blank.");
	  document.forms.freebusinesslisting.city.focus();
  }
else if(document.forms.freebusinesslisting.stdcode.value=="")
  {
	  alert("STD code cannot be left blank.");
	  document.forms.freebusinesslisting.stdcode.focus();
  }
else if(document.forms.freebusinesslisting.ph1.value=="")
  {
	  alert("Please enter Contact Number.");
	  document.forms.freebusinesslisting.ph1.focus();
  }
else if(document.forms.freebusinesslisting.keywords.value=="")
  {
	  alert("You Didn't Entered Keywords.");
	  document.forms.freebusinesslisting.keywords.focus();
  }
else if(document.forms.freebusinesslisting.man.value!=document.forms.freebusinesslisting.man2.value)
  {
	  alert("Please Enter Verification Code as same as written in the box right to the Verification Code text box.");
	  document.forms.freebusinesslisting.man.focus();
  }
else
  {
	  document.forms.freebusinesslisting.submit();
  }
}

//------------city combo box setting---------
flagcity=1;
Arrcity=new Array;
Arrcity[0]="<select name=city style='width:144px'><option value=Doraha>Doraha<option value=Jagraon>Jagraon<option value=Ludhiana selected>Ludhiana<option value=Payal>Payal<option value=Macchiwara>Macchiwara<option value=Mullanpur>Mullanpur<option value=Samrala>Samrala</select>";

Arrcity[1]="<input type=text name='city'/>"
Arrcity[2]=" If other <input type=checkbox name=checkbox1 onPropertychange='othercity()' value=othercity/>"
Arrcity[3]="<input type=checkbox name=checkbox1 onPropertychange='othercity()' checked value=othercity/>"
 function othercity()
 {
  if (flagcity==0)
  {
    ccity.innerHTML=Arrcity[0]+Arrcity[2];
	flagcity=1;
  }
  else
  {
    ccity.innerHTML=Arrcity[1]+Arrcity[3];
	flagcity=0;
  }
 }
 
function validpaidbusiness()
{
if (document.forms.listwithus.companyname.value==""){alert("Please Enter Company Name.");document.forms.listwithus.companyname.focus();}else if (document.forms.listwithus.cperson.value==""){alert("Please Enter Contact Person Name.");document.forms.listwithus.cperson.focus();}else if (document.forms.listwithus.cpersonph.value==""){alert("Please Enter Contact Number.");document.forms.listwithus.cpersonph.focus();}else if (document.forms.listwithus.profile.value==""){alert("Please enter few words about your Company. It will help during search.");document.forms.listwithus.profile.focus();}else if (document.forms.listwithus.businessg.value=="0"){alert("Please Select a Business Group to which your Company belongs.");document.forms.listwithus.businessg.focus();}else if (document.forms.listwithus.category.value=="0"){alert("Please Select a Category.");document.forms.listwithus.category.focus();}else if (document.forms.listwithus.address.value==""){alert("Please Enter Address.");document.forms.listwithus.address.focus();}else if (document.forms.listwithus.cpersonph.value==""){alert("Please Enter City Name.");document.forms.listwithus.city.focus();}else if (document.forms.listwithus.stdcode.value==""){alert("Please Enter STD Code.");document.forms.listwithus.stdcode.focus();}else if (document.forms.listwithus.ph1.value==""){alert("Please Enter Phone Number.");document.forms.listwithus.ph1.focus();}else if(document.forms.listwithus.email.value!="" && document.forms.listwithus.email.value.indexOf('@',0)<1){alert("This is not a valid email address");document.forms.listwithus.email.focus();}else if (document.forms.listwithus.man.value!=document.forms.listwithus.man2.value){alert("Please Enter Verification Code as same as written in the box right to the Verification Code text box.");document.forms.listwithus.man.focus();}else{if(document.forms.listwithus.email.value==""){document.forms.listwithus.email.value= "---";}document.forms.listwithus.submit();}
} 

function validgeninfo()
{
if(document.forms.geninfor.title.value=="")
  {
	  alert("Title field cannot be left blank.");
	  document.forms.geninfor.title.focus();
  }
else if(document.forms.geninfor.article.value=="")
  {
	  alert("You didn't write Description.");
	  document.forms.geninfor.article.focus();
  }
else if(document.forms.geninfor.sendername.value=="")
  {
	  alert("Please write your Name");
	  document.forms.geninfor.sendername.focus();
  }
else if(!emailvalidation(document.forms.geninfor.email.value,'Invalid Email Id'))
  {
	  geninfor.email.focus();
  }
else if(document.forms.geninfor.man.value!=document.forms.geninfor.man2.value)
  {
	  alert("Please Enter Verification Code as same as written in the box right to the Verification Code text box.");
	  document.forms.geninfor.man.focus();
  }
else
  {
  	  document.forms.geninfor.submit();
  }
}


function validphonedir()
{
if(document.forms.phonedir.title.value=="")
  {
	  alert("Please enter your Name.");
	  document.forms.phonedir.title.focus();
  }
else if(document.forms.phonedir.address.value=="")
  {
	  alert("Please write your Address");
	  document.forms.phonedir.address.focus();
  }
else if(document.forms.phonedir.phone.value=="")
  {
	  alert("Please write your Phone Number");
	  document.forms.phonedir.phone.focus();
  }
else if(document.forms.phonedir.man.value!=document.forms.phonedir.man2.value)
  {
	  alert("Please Enter Verification Code as same as written in the box right to the Verification Code text box.");
	  document.forms.phonedir.man.focus();
  }
else
  {
  	  document.forms.phonedir.submit();
  }
}

function validyourviews()
{
	if(yourviews.sendername.value=="")
	{
		alert("Please enter your name.");
		yourviews.sendername.focus();
	}
	else if(!emailvalidation(yourviews.email.value,'Invalid Email Id'))
	{
		yourviews.email.focus();
	}
	else if(yourviews.profile.value=="")
	{
		alert("Please write your views.");
		yourviews.profile.focus();
	}
	else if(yourviews.man.value!=yourviews.man2.value)
    {
	  alert("Please Enter Verification Code as same as written in the box right to the Verification Code text box.");
	  yourviews.man.focus();
    }
	else
	{
		yourviews.submit();
	}
}