// JavaScript Document

function validRequired(formField,fieldLabel,txtmsg)

{

	var result = true;

	

	if (formField.value == "" || formField.value == txtmsg)

	{

		alert(fieldLabel);

		formField.focus();

		result = false;

	}

	

	return result;

}



function checkEmail(myForm,mess)

{

 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.value))

 {

	return (true)

 }

	alert(mess);

	myForm.focus();

	return (false)

}

function checkCorpEmail(eml)



 {

	if (eml.indexOf("hotmail.com") > 0 ||eml.indexOf("gmail.com") > 0 || eml.indexOf("yahoo.com") > 0 || eml.indexOf("test.com") > 0 || eml.indexOf("rediffmail.com") > 0 || eml.indexOf("aol.com") > 0 ) 

	

	{

		alert("Please enter corporate email address ");



		return false;

		

	 } 

	

	else {

		return true;

	     }

}





function cleartext(feildname,txtmsg)

{

	if(feildname.value == txtmsg)

	{

		feildname.value = "";

	}

	

}

function filltext(feildname,txtmsg)

{

	if(feildname.value == "")

	{

		feildname.value = txtmsg;

	}

	

}

var n;



var p;



var p1;



function ValidatePhone(){



p=p1.value



if(p.length==3){



	//d10=p.indexOf('(')



	pp=p;



	d4=p.indexOf('(')



	d5=p.indexOf(')')



	if(d4==-1){



		pp="("+pp;



	}



	if(d5==-1){



		pp=pp+")";



	}



	//pp="("+pp+")";



	document.JoinActionForm.tel.value="";



	document.JoinActionForm.tel.value=pp;



}



if(p.length>3){



	d1=p.indexOf('(')



	d2=p.indexOf(')')



	if (d2==-1){



		l30=p.length;



		p30=p.substring(0,4);



		//alert(p30);



		p30=p30+")"



		p31=p.substring(4,l30);



		pp=p30+p31;



		//alert(p31);



		document.JoinActionForm.tel.value="";



		document.JoinActionForm.tel.value=pp;



	}



	}



if(p.length>5){



	p11=p.substring(d1+1,d2);



	if(p11.length>3){



	p12=p11;



	l12=p12.length;



	l15=p.length



	//l12=l12-3



	p13=p11.substring(0,3);



	p14=p11.substring(3,l12);



	p15=p.substring(d2+1,l15);



	document.JoinActionForm.tel.value="";



	pp="("+p13+")"+p14+p15;



	document.JoinActionForm.tel.value=pp;



	//obj1.value="";



	//obj1.value=pp;



	}



	l16=p.length;



	p16=p.substring(d2+1,l16);



	l17=p16.length;



	if(l17>3&&p16.indexOf('-')==-1){



		p17=p.substring(d2+1,d2+4);



		p18=p.substring(d2+4,l16);



		p19=p.substring(0,d2+1);



		//alert(p19);



	pp=p19+p17+"-"+p18;



	document.JoinActionForm.tel.value="";



	document.JoinActionForm.tel.value=pp;



	//obj1.value="";



	//obj1.value=pp;



	}



}



//}



setTimeout(ValidatePhone,100)



}



function getIt(m){



n=m.name;



//p1=document.forms[0].elements[n]



p1=m



ValidatePhone()



}



function testphone(obj1){



p=obj1.value



//alert(p)



p=p.replace("(","")



p=p.replace(")","")



p=p.replace("-","")



p=p.replace("-","")



//alert(isNaN(p))



if (isNaN(p)==true){



alert("Check phone");



return false;



}



}



function isNotNumeric(str){

		for (var i = 0; i < str.length; i++)

		{

				var ch = str.substring(i, i + 1);

				if((ch < '0' || '9' < ch)) 

				{

					if(ch == "+" || ch == "-" || ch == "." || ch == ")" || ch == "("  || ch == " ") continue;

					return true;

				}

		}

		return false;

}

function isNotAlphabets(str){

		for (var i = 0; i < str.length; i++)

		{

				re = / /gi				//Replace the space between words with no space

				str = str.replace(re,"");

			

				var ch = str.substring(i, i + 1);

				

				if((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) 

				{

					return true;

				}

		}

		return false;

}

function checkMyForm(nForm) 

{

		if (!checkEmail(document.JoinActionForm.email,"Please enter valid Email "))

			return false;

			

			var avl=document.getElementById('avl').value;

			if(avl=='0')

			{

				alert("Email already exists")

				return false;

			}

		if(!validRequired(document.JoinActionForm.pass,"Please enter Password","Password "))

			return false;

			   

  var pass=document.getElementById('pass').value; 

	var xpass=document.getElementById('cpass').value;

	if(pass=='')

	{

		alert('Password cannot Be blank');

		return false;

	}

	if(pass.length < 8)

	{

		alert('Password Must be 8 digit');

		return false;

	}

	

	 

			

			if(!validRequired(document.JoinActionForm.cpass,"Please enter Confirm Password"," confirm Password "))

			return false;

			

if(xpass.length < 8)

	{

		alert('Password Must be 8 digit');

		document.JoinActionForm.cpass.focus();

		return false;

	}

	 if(xpass!=pass)

	{

		alert('Password not Match');

		document.JoinActionForm.cpass.focus();

		return false;

	}

			

		 if(!validRequired(document.JoinActionForm.fname,"Please enter your First Name","First Name"))

			return false;

			if(isNotAlphabets(document.JoinActionForm.fname.value))

		 {

			alert("Invalid characters in first Name");

			document.JoinActionForm.fname.focus();

			return false;

		 }

			

		if(!validRequired(document.JoinActionForm.lname,"Please enter your Last Name","Last Name"))

			return false;

			if(isNotAlphabets(document.JoinActionForm.lname.value))

		 {

			alert("Invalid characters in Last Name");

			document.JoinActionForm.lname.focus();

			return false;

		 }

		 

		 	if(!validRequired(document.JoinActionForm.cmpname,"Please enter Company Name","Company Name"))

			return false;

			
if(document.getElementById('terms').checked==false)

			{

			alert("Please Select terms & condition");

			return false;

			}		
     if(document.getElementById('op').checked)

	 {

		var chosen=document.getElementById('op').value;

	 }

	if(document.getElementById('op1').checked)

	 {

		var chosen1=document.getElementById('op1').value;

	 }

    if(document.getElementById('op2').checked)

	 {

		var chosen2=document.getElementById('op2').value;

	 }

		var ch1;

		var ch2;

		var ch3;

		

		



if(chosen2=='sub' || chosen1=='outright')

{

	if(chosen2=='sub')

	{

		//alert('here');

	 if(document.getElementById('sub_1').checked==true || document.getElementById('sub_2').checked==true || document.getElementById('sub_3').checked==true || document.getElementById('sub_5').checked==true)

	 {

		 

		var ch1=document.getElementById('sub_1').value;

		//alert(ch1);

		

	 }

	 else

	 {

		 alert('Please select Subscription Plan');

		 return false;

	 }

	

	

	

	}



	

		

			

			

		 

			if (!validRequired(document.JoinActionForm.tel,"Please enter Phone","Phone"))

			return false;

			

			

			if (!validRequired(document.JoinActionForm.fax,"Please enter Fax","Fax"))

			return false;

			if (!validRequired(document.JoinActionForm.address,"Please enter address","Address"))

			return false;

			if (!validRequired(document.JoinActionForm.postaladd,"Please enter  Postal address","PostalAddress"))

			return false;

			

		

			var vat=document.JoinActionForm.vat.value;

			if(vat=="")

			{

				return true;

				

			}

			else

			{

			  

			var vlength = vat.length;



			if(vlength < 9)

			{

			   alert("Please Enter 10 digit ");

			   document.JoinActionForm.vat.focus();

			return false;

			}

			if(vat.charAt(0)!='4')

			{

				alert("Please Enter Valid Vat Number");

			   document.JoinActionForm.vat.focus();

			   return false;

			}

			}

			if (!validRequired(document.JoinActionForm.contact,"Please enter  contact","contact"))

			return false;

			

			if (!validRequired(document.JoinActionForm.useracc,"Please enter  Your Account Number","useracc"))

			return false;

			

				 

		

}



			

}

function visibleForm()

{

	//alert(document.getElementById('condivv').style.visibility);

	

	if(document.getElementById('condivv').style.visibility=='collapse')

	{

		

		document.getElementById('condivv').style.visibility='visible';

	}

	else if(document.getElementById('condivv').style.visibility=='visible')

	{

		document.getElementById('condivv').style.visibility='collapse';

	}

}

function checkcontactForm(nForm)

{

	

			

		

		 

	if (!checkEmail(document.JoinActionForm.email,"Please enter valid Email "))

			return false;

			if (!validRequired(document.JoinActionForm.phoneno,"Please enter Phone","Phone"))

			return false;

			

			 if(isNotNumeric(document.JoinActionForm.phoneno.value))

				 {

					alert("Invalid characters in phone.");

					document.JoinActionForm.phoneno.focus();

					return false;

				 }

				 

	 if(!validRequired(document.JoinActionForm.msg,"Please enter Message","Msg"))

			return false;

}



function checkloginForm(nForm)

{

	 if (!checkEmail(document.JoinActionForm.email,"Please enter valid Email "))

			return false;

			

		if(!validRequired(document.JoinActionForm.pass,"Please enter Password","Password "))

			return false;

			

}



function visibleForm1()

{

	//alert(document.getElementById('condivv').style.visibility);

	

	if(document.getElementById('condiv').style.visibility=='collapse')

	{

		

		document.getElementById('condiv').style.visibility='visible';

	}



	if(document.getElementById('condivv').style.visibility=='collapse')

	{

		

		document.getElementById('condivv').style.visibility='visible';

	}

	

}



function visibleFormother()

{

	//alert(document.getElementById('condivv').style.visibility);

	if(document.getElementById('condiv').style.visibility=='visible')

	{

		document.getElementById('condiv').style.visibility='collapse';

	}

	if(document.getElementById('condivv').style.visibility=='visible')

	{

		document.getElementById('condivv').style.visibility='collapse';

	}





 

}

function visibleFormout()

{

	//alert(document.getElementById('condivv').style.visibility);

	

  if(document.getElementById('condivv').style.visibility=='collapse')

	{

		

		document.getElementById('condivv').style.visibility='visible';

	}

	//alert(document.getElementById('condivv').style.visibility);

	if(document.getElementById('condiv').style.visibility=='visible')

	{

		document.getElementById('condiv').style.visibility='collapse';

	}

}



function formCampigin(nForm)

{

	//alert('here');

	var title=document.frm.title.value;

	title=title.trim();

	var desc=document.frm.desc.value;

	desc=desc.trim();

	if (title=='')

	{

		alert("Please Enter Title");

		return false;

	}

	if (desc=='')

	{

		alert("Please Enter Description");

		return false;

	}

	

}

function checkoutright(nForm) 



{

var contact=document.frm.contact.value;

var user=document.frm.useracc.value;

title=contact.trim();

desc=user.trim();

	if (title=='')

	{

		alert("Please Enter Contact");

		return false;

	}



		if (desc=='')

	{

		alert("Please Enter User account number");

		return false;

	}





}



var n;

var p;

var p1;

function ValidatePhone1(){

p=p1.value

if(p.length==3){

	//d10=p.indexOf('(')

	pp=p;

	d4=p.indexOf('(')

	d5=p.indexOf(')')

	if(d4==-1){

		pp="("+pp;

	}

	if(d5==-1){

		pp=pp+")";

	}

	//pp="("+pp+")";

	document.JoinActionForm.fax.value="";

	document.JoinActionForm.fax.value=pp;

}

if(p.length>3){

	d1=p.indexOf('(')

	d2=p.indexOf(')')

	if (d2==-1){

		l30=p.length;

		p30=p.substring(0,4);

		//alert(p30);

		p30=p30+")"

		p31=p.substring(4,l30);

		pp=p30+p31;

		//alert(p31);

		document.JoinActionForm.fax.value="";

		document.JoinActionForm.fax.value=pp;

	}

	}

if(p.length>5){

	p11=p.substring(d1+1,d2);

	if(p11.length>3){

	p12=p11;

	l12=p12.length;

	l15=p.length

	//l12=l12-3

	p13=p11.substring(0,3);

	p14=p11.substring(3,l12);

	p15=p.substring(d2+1,l15);

	document.JoinActionForm.fax.value="";

	pp="("+p13+")"+p14+p15;

	document.JoinActionForm.fax.value=pp;

	//obj1.value="";

	//obj1.value=pp;

	}

	l16=p.length;

	p16=p.substring(d2+1,l16);

	l17=p16.length;

	if(l17>3&&p16.indexOf('-')==-1){

		p17=p.substring(d2+1,d2+4);

		p18=p.substring(d2+4,l16);

		p19=p.substring(0,d2+1);

		//alert(p19);

	pp=p19+p17+"-"+p18;

	document.JoinActionForm.fax.value="";

	document.JoinActionForm.fax.value=pp;

	//obj1.value="";

	//obj1.value=pp;

	}

}

//}

setTimeout(ValidatePhone1,100)

}

function getIt1(m){

n=m.name;

//p1=document.forms[0].elements[n]

p1=m

ValidatePhone1()

}

function testphone1(obj1){

p=obj1.value

//alert(p)

p=p.replace("(","")

p=p.replace(")","")

p=p.replace("-","")

p=p.replace("-","")

//alert(isNaN(p))

if (isNaN(p)==true){

alert("Check phone");

return false;

}

}



function lastdata()

{

 if(isNotAlphabets(document.JoinActionForm.lname.value))

		 {

			alert("Invalid characters in Last Name");

			document.JoinActionForm.lname.focus();

			return false;

		 }

}
