function validates_link(){
	
	//Check Package selected or not


	var pack=0;
	for (var i=0; i<document.form1.package.length;i++){
		if (document.form1.package[i].checked){
			pack=1;
		}
	}
	if(pack==0){
		alert("Please select membership package");
		document.form1.package[0].focus();
		return false;
	}
	
	var card=0;
	for (var i=0; i<document.form1.cardcat.length;i++){
		if (document.form1.cardcat[i].checked){
			card=1;
		}
	}
	if(card==0){
		alert("Please select the card type");
		document.form1.cardcat[0].focus();
		return false;
	}
	
	//Check Paymentmode selected or not
	if(document.form1.card.checked==false){
		alert("Please select payment mode");
		document.form1.card.focus();
		return false;
	}
	return true;
}



function echeck( Email )
{
	var atCharPresent = false;
	var dotPresent = false;

	for ( var Idx = 0; Idx < Email.length; Idx++ )
	{
		if ( Email.charAt ( Idx ) == '@' )
			atCharPresent = true;
		if ( Email.charAt ( Idx ) == '.' )
			dotPresent = true;
	}

	if ( !atCharPresent || !dotPresent )
		return false;

	return true;
}

function trim(Val)
{	
	while(''+Val.charAt(0)==' ')
	Val=Val.substring(1,Val.length);
	return Val
}


function toggle(id) {
	
	alert(document.getElementById(id).style.display);
				var state = document.getElementById(id).style.display;
				alert(state);
				if (state == 'none') {
					document.getElementById(id).style.display = 'block';
				} else {
					document.getElementById(id).style.display = 'none';
				}
			} 

function show(){
	if(document.form1.cardcat[1].checked){
	document.getElementById('courier').style.display = 'block';
	}
	if(document.form1.cardcat[0].checked){
	document.getElementById('emailing').style.display = 'block';
	}
	if ((document.form1.cardcat[0].checked) || (document.form1.cardcat[1].checked)) {
	document.getElementById('b1').style.display="none";}
}

function showtab2(){
	if(document.form1.card.checked==true)  {
		document.getElementById('courier').style.display = 'block';
		document.getElementById('emailing').style.display = 'none';
	}
	/*if(document.form1.card[1].checked){

		
		document.getElementById('emailing').style.display = 'none';
		document.getElementById('b1').style.display="none";
	}
	else{*/
	//document.getElementById('b1').style.display="block";
	//}
	
}

function showtab1(){
	if(document.form1.card.checked==true)  {
		document.getElementById('courier').style.display = 'none';
		document.getElementById('emailing').style.display = 'block';
	}
	/*if(document.form1.card[1].checked){

		document.getElementById('emailing').style.display = 'block';
		document.getElementById('courier').style.display = 'none';
		document.getElementById('b1').style.display="none";
	}
	else{*/
	//document.getElementById('b1').style.display="block";
	//}

}


function hide(){
		document.getElementById('courier').style.display = 'none';
		document.getElementById('emailing').style.display = 'none';
		document.getElementById('b1').style.display="block";
}
function ccvalidate(){
//Check Package selected or not
	var pack=0;
	for (var i=0; i<document.form1.package.length;i++){
		if (document.form1.package[i].checked){
			pack=1;
		}
	}
	if(pack==0){
		alert("Please select the Membership Package");
		document.form1.package[0].focus();
		return false;
	}
	
	var card=0;
	for (var i=0; i<document.form1.cardcat.length;i++){
		if (document.form1.cardcat[i].checked){
			card=1;
		}
	}
	if(card==0){
		alert("Please select Card Type");
		document.form1.cardcat[0].focus();
		return false;
	}
	
	
	//Check Paymentmode selected or not
	var card=0;
	for (var i=0; i<document.form1.card.length;i++){
		if (document.form1.card[i].checked){
			card=1;
		}
	}
	if(card==0){
		alert("Please select Payment Mode");
		document.form1.card[0].focus();
		return false;
	}
	if(document.form1.card[1].checked){
		//document.form1.action="https://www.ccavenue.com/shopzone/cc_details.jsp";
		//document.form1.action="ccavenuepayment.php";
		document.form1.action="giftccpaymentredirect.php";
		return true;
	}
	if(document.form1.card[0].checked){

		document.form1.action="membership.php";
		return true;
	}
	
	//if(document.form1.cardcat[0].checked){validate2();}
	//if(document.form1.cardcat[1].checked){validate1();}
	return true;
}

function validate2(){
//return true;
if (trim(document.form1.recpname.value)==''){
	document.getElementById('recpname_span').innerHTML='Please enter the name of the person';
	document.form1.recpname.focus();
	return false;
	}else{document.getElementById('recpname_span').innerHTML='&nbsp;';}

if (trim(document.form1.recpemailid.value)==''){
		document.getElementById('recpemailid_span').innerHTML='Please enter your E-mail';		
		document.form1.recpemailid.focus();
		return false;
	}else{document.getElementById('recpemailid_span').innerHTML='';}


if (echeck(document.form1.recpemailid.value)==false){
		document.getElementById('recpemailid_span').innerHTML='Invalid E-mail';
		document.form1.recpemailid.focus();
		return false;
	}else{document.getElementById('recpemailid_span').innerHTML='';}


if (trim(document.form1.relation.value)==''){
		document.getElementById('relation_span').innerHTML='Please enter your relationship';
		document.form1.relation.focus();
		return false;
	}else{document.getElementById('relation_span').innerHTML='&nbsp;';}

if (trim(document.form1.sendername.value)==''){
		document.getElementById('sendername_span').innerHTML='Please enter your name';		
		document.form1.sendername.focus();
		return false;
	}else{document.getElementById('sendername_span').innerHTML='';}

if (trim(document.form1.sendermailid.value)==''){
		document.getElementById('sendermailid_span').innerHTML='Please enter your E-mail';		
		document.form1.sendermailid.focus();
		return false;
	}else{document.getElementById('sendermailid_span').innerHTML='';}

if (echeck(document.form1.sendermailid.value)==false){
		document.getElementById('sendermailid_span').innerHTML='Invalid E-mail';		
		document.form1.sendermailid.focus();
		return false;
	}else{document.getElementById('sendermailid_span').innerHTML='';}
return true;
}

function validate1(){

if (trim(document.form1.recpname1.value)==''){
		document.getElementById('recpname_span1').innerHTML='Please enter the name of the person';
		document.form1.recpname1.focus();
		return false;
	}else{document.getElementById('recpname_span1').innerHTML='';}

if (trim(document.form1.relation1.value)==''){
		document.getElementById('relation_span1').innerHTML='Please enter your relationship';
		document.form1.relation1.focus();
		return false;
	}else{document.getElementById('relation_span1').innerHTML='';}

if (trim(document.form1.address1.value)==''){
		document.getElementById('address_span1').innerHTML='Please enter the address and phone number of the person you want the card delivered';
		document.form1.address1.focus();
		return false;
	}else{document.getElementById('address_span1').innerHTML='&nbsp;';}


if (trim(document.form1.sendername1.value)==''){
		document.getElementById('sendername_span1').innerHTML='Please enter your name';		
		document.form1.sendername1.focus();
		return false;
	}else{document.getElementById('sendername_span1').innerHTML='';}
	if (trim(document.form1.sendermailid1.value)==''){
		document.getElementById('sendermailid_span1').innerHTML='Please enter your E-mail';		
		document.form1.sendermailid1.focus();
		return false;
	}else{document.getElementById('sendermailid_span1').innerHTML='';}
	
	if (echeck(document.form1.sendermailid1.value)==false){
		document.getElementById('sendermailid_span1').innerHTML='Invalid E-mail';		
		document.form1.sendermailid1.focus();
		return false;
	}else{document.getElementById('sendermailid_span1').innerHTML='';}

	if (trim(document.form1.phnumber1.value)==''){
		document.getElementById('phnumber_span1').innerHTML='Please enter your phone number';		
		document.form1.phnumber1.focus();
		return false;
	}
return true;
}


function validates(){
	
	//Check Package selected or not
	var pack=0;
	for (var i=0; i<document.form1.package.length;i++){
		if (document.form1.package[i].checked){
			pack=1;
		}
	}
	if(pack==0){
		alert("Please select the Membership Package");
		document.form1.package[0].focus();
		return false;
	}
	
	var card=0;
	for (var i=0; i<document.form1.cardcat.length;i++){
		if (document.form1.cardcat[i].checked){
			card=1;
		}
	}
	if(card==0){
		alert("Please select Card Type");
		document.form1.cardcat[0].focus();
		return false;
	}
	
	
	//Check Paymentmode selected or not
	/*var card=0;
	for (var i=0; i<document.form1.card.length;i++){
		if (document.form1.card[i].checked){
			card=1;
		}
	}*/
	if(document.form1.card.checked==false){
		alert("Please select Payment Mode");
		document.form1.card.focus();
		return false;
	}
	//if (document.form1.cardcat[0].checked){
	//	document.form1.action="emembership.php";
	//}
	//if (document.form1.cardcat[1].checked){
	//	document.form1.action="scratchcard.php";
	//}
		
	//if(document.form1.card[1].checked){
	if(document.form1.cardcat[0].checked){

		if (!validate2()) {
			return false;
		}
	}
	if(document.form1.cardcat[1].checked) {

		if (!validate1()) {
			return false;
		}
	}
	//}

	if(document.form1.card[0].checked){
		//document.form1.action="https://www.ccavenue.com/shopzone/cc_details.jsp";
		//document.form1.action="ccavenuepayment.php";
		document.form1.action="giftccpaymentredirect.php";
		document.form1.submit();
	}
	/*if(document.form1.card[0].checked){

		//document.form1.action="membership.php";
		//document.form1.submit();
			return true;


	}*/
	return true;

}
function pro() {
	alert('Hello');
}


