	
	function checkvalidate()
    {
		
	//Below for  Publication Type 
		//alert(document.frmpub.rdadvance_delv.length)
		
		var flagpubtype=0;
		for(i=0; i<document.frmpub.publication_type.length;i++)
		{
			if(document.frmpub.publication_type[i].checked == true)
			{
				 flagpubtype=1;
			}
			
		}
		
	 if(flagpubtype==0)
	 {
	   
	   alert('Please select any Publication Order Type')
	   return false;
	}
	// Above For Publication Type 
	
	
	
	
	
		// Below JS from Read By Road Div
		if(document.getElementById('readroadDiv').style.display=='')
		{
			
			
			if(document.frmpub.txtcopies_ryr.value=='')
			{
				alert('Please Enter Total No Of Copies');
				document.frmpub.txtcopies_ryr.focus();
				return false;
			}
			
			
		}
	
		//Below JS for Rodsafety Div
		
		if(document.getElementById('roadsaftyDiv').style.display=='')
		{
			
			
			if(document.frmpub.txttcopies_rsc.value=='')
			{
				alert('Please Enter Total No Of Copies');
				document.frmpub.txttcopies_rsc.focus();
				return false;
			}
			
			
		}
		

	//Below for Delivery Type 
		//alert(document.frmpub.rdadvance_delv.length)
		
		var flagpub=0;
		for(i=0; i<document.frmpub.rdadvance_delv.length;i++)
		{
			if(document.frmpub.rdadvance_delv[i].checked == true)
			{
				 flagpub=1;
			}
			
		}
		
	 if(flagpub==0)
	 {
	   
	   alert('Please select any Delivery Type')
	   return false;
	}
	// Above For Delivery Type 
		
		calculate_orderdetail();
		
         if(document.frmpub.txtfname.value=='')
	     {
	          alert('Please Enter First Name'); 
              document.frmpub.txtfname.focus();
	          return false;
	     }

		 if(document.frmpub.txtlname.value=='')
	     {
	          alert('Please Enter Last Name');
			  document.frmpub.txtlname.focus();
	          return false;
	     }

		 /*if(document.frmpub.txtorganization.value=='')
	     {
	          alert('Please Enter Organization');
			  document.frmpub.txtorganization.focus();
	          return false;
	     }*/
		 if(document.frmpub.txtaddress.value=='')
	     {
	          alert('Please Enter an Address');
			  document.frmpub.txtaddress.focus();
	          return false;
	     }
		 if(document.frmpub.txtcity.value=='')
	     {
	          alert('Please Enter a City');
			  document.frmpub.txtcity.focus();
	          return false;
	     }
		 if(document.frmpub.txtstate.value=='')
	     {
	          alert('Please Enter a State');
			  document.frmpub.txtstate.focus();
	          return false;
	     }
		 if(document.frmpub.txtzipcode.value=='')
	     {
	          alert('Please Enter a Zipcode');
			  document.frmpub.txtzipcode.focus();
	          return false;
	     }
		 if(document.frmpub.txtphone.value=='')
	     {
	          alert('Please Enter a Phone Number');
			  document.frmpub.txtphone.focus();
	          return false;
	     }

		 if(document.frmpub.txtemail.value=='')
	     {
	          alert('Please Enter Email');
			  document.frmpub.txtemail.focus();
	          return false;
	     }
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(document.frmpub.txtemail.value))
		{
			alert('Please Enter Valid Email');
			document.frmpub.txtemail.focus();
			return false;
		}
						
		/*if(document.frmpub.txtamt.value=='')
	     {
	          alert('Please Enter Payment Amount');
			  document.frmpub.txtamt.focus();
	          return false;
	     }
		 if(document.getElementById('selectamt').value=='0')
		   {
			   alert('Please Select Amount');
			   return false;
		   }*/
		  if(document.getElementById('paycc').style.display == '')
		 {
		
			 if(document.frmpub.txtcname.value=='')
			 {
				  alert('Please Enter Card Holder Name');
				  document.frmpub.txtcname.focus();
				  return false;
			 }
			 
			 if(document.frmpub.txtcno.value=='')
			 {
				  alert('Please Enter Credit Card Number');
				  document.frmpub.txtcno.focus();
				  return false;
			 }
			 
			 if(document.frmpub.txtedate.value=='')
			 {
				  alert('Please Enter Credit Card Expiry Date');
				  document.frmpub.txtedate.focus();
				  return false;
			 }
			 
			 if(document.frmpub.txtcvvno.value=='')
			 {
				  alert('Please Enter CVV Security No');
				  document.frmpub.txtcvvno.focus();
				  return false;
			 }
		 }
    return true;
    }

//////////////////////////////

	function calculate_orderdetail()
	{
	
		
		var tot_publication_cost = 0;
		var ryr_publication_cost = 0; 
		var rsc_publication_cost = 0; 
		var publication_qty = 0;
        var	standard_delv_fee = 0;
		var advance_delv_free = 0;
		var merchandise_tot = 0; 
		var tot_order_cost = 0;
		var is_member ='';
		var vchecked =0;
	is_member = document.getElementById('ismem').value;
	
		for(var i=0; i<document.frmpub.publication_type.length;i++)
		{
			
			if(document.frmpub.publication_type[i].checked)
			{
				var publication_type = document.frmpub.publication_type[i].value;
				vchecked = 1;
				//Check Publication type
				if(publication_type == 'read_your_road')
				{
					publication_qty = document.getElementById('txtcopies_ryr').value;
					if(publication_qty=='')
					{
							alert('Please enter number of copies For Read Your Road.');
							return false;
					
					}
					
					
					
					ryr_publication_cost = read_your_road(publication_qty,is_member);
					//alert("ryr_publication_cost "+ryr_publication_cost);
				}
				else
				{
					publication_qty = document.getElementById('txttcopies_rsc').value;
					
					if(publication_qty=='')
					{
							alert('Please enter number of copies For Roadway Safety Checklist.');
							return false;
					
					}
					
					rsc_publication_cost = road_safety(publication_qty,is_member);
					//alert("rsc_publication_cost "+rsc_publication_cost);
				}
		
			}
		}

		if(vchecked == 0)
		{
			alert("Please Select any one option of the Publication type");
			return false;
		}

		
		tot_publication_cost = ryr_publication_cost + rsc_publication_cost;
		//alert('total cost'+tot_publication_cost);
		// Following for selecting merchandise cost 
		
		if(tot_publication_cost >= 0 && tot_publication_cost <= 10)
		{
			
			document.frmpub.radiomerchandise[0].checked = true
			
		}
		if(tot_publication_cost >= 11 && tot_publication_cost <= 30)
		{
			
			document.frmpub.radiomerchandise[1].checked = true
			
		}
		if(tot_publication_cost >= 31 && tot_publication_cost <= 50)
		{
			
		document.frmpub.radiomerchandise[2].checked = true
			
		}
		if(tot_publication_cost >= 51 && tot_publication_cost <= 75)
		{
			
			document.frmpub.radiomerchandise[3].checked = true
			
		}
		// Above for selecting merchandise cost
		
		
		//alert(publication_type);
		
		
		
		
		
			
		//alert(publication_qty+'--'+is_member+'--'+publication_cost);
		
		
		if(publication_qty>500)
		{
			alert('Quantity are limited .Please Contact RSF at 202.857.1200');
			
		}
		
		
		//Check delivery type
		vchecked = 0;
		for(var i=0; i<document.frmpub.rdadvance_delv.length;i++)
		{
			
			if(document.frmpub.rdadvance_delv[i].checked)
			{
				var delivery_type = document.frmpub.rdadvance_delv[i].value;

				vchecked = 1;
			}
		}

		if(vchecked == 0)
		{
			alert("Please Select any one option of the Delivery type");
			return false;
		}

		
		if(delivery_type=='standard')
		{
			//Check delivery type
			vchecked = 0;
			for(var i=0; i<document.frmpub.radiomerchandise.length;i++)
				{
					
					if(document.frmpub.radiomerchandise[i].checked)
					{
						var delivery_fee = document.frmpub.radiomerchandise[i].value;
						document.frmpub.radiomerchandise[i].disabled=false;

						vchecked = 1;
					}
					else
					{
						document.frmpub.radiomerchandise[i].disabled=true;
					}
				}

		}
		else
		{
			delivery_fee = delivery_type;
		}

		//alert(delivery_fee);

		/*if(publication_cost=='0')
		{
			tot_order_cost=0;
		}
		else
		{
			tot_order_cost = parseFloat(publication_cost) + parseFloat(delivery_fee);
		}
		*/
		//Calculate Total
		tot_order_cost = parseFloat(tot_publication_cost) + parseFloat(delivery_fee);


	   document.getElementById('txtocost').value = tot_order_cost; 
	   document.getElementById('t1').value = tot_publication_cost; 
	   document.getElementById('t2').value = standard_delv_fee; 
	   document.getElementById('t3').value = advance_delv_free; 
	   document.getElementById('t4').value = tot_order_cost; 

	
	}


// Function For Set IsMember Value
function setIsmember(mem)
{
	//alert(mem);
	document.getElementById('ismem').value=mem;
	calculate_orderdetail();
	
}

//


// Function For Set Merchandise value

function setMechandise(mech)
{
	document.getElementById('setmech').value=mech;
	document.getElementById('setdel').value = document.getElementById('setmech').value;

		for(var i=0; i<document.frmpub.rdadvance_delv.length;i++)
		{
			if(document.frmpub.rdadvance_delv[i].checked && document.frmpub.rdadvance_delv[i].value=='standard')
			{
				calculate_orderdetail();
			}
		}
}
//

// Function For Set Delivery Type
function setDeliveryType(deltype)
{
	
	
	if(deltype =='standard')
	{
		document.getElementById('setdel').value='';
		//alert(document.frmpub.radiomerchandise.length);
		for(var i=0; i<document.frmpub.radiomerchandise.length;i++)
		{
			if(document.frmpub.radiomerchandise[i].checked)
			{
				//alert('here also')
//				document.getElementById('setdel').value = document.frmpub.radiomerchandise[i].value;
				document.getElementById('setdel').value = document.getElementById('setmech').value;
			}
		}
		for(var i=0; i<document.frmpub.radiomerchandise.length;i++)
		{
			
				if(document.frmpub.radiomerchandise[i].checked==true)
				{
					document.frmpub.radiomerchandise[i].disabled=false;
				}
				else
				{
					document.frmpub.radiomerchandise[i].disabled=true;
				}
			
		}
	}
	else
	{	
		document.getElementById('setdel').value='';
		document.getElementById('setdel').value=deltype;
		for(var i=0; i<document.frmpub.radiomerchandise.length;i++)
		{
			
				document.frmpub.radiomerchandise[i].disabled=true;
			
		}
	}
	calculate_orderdetail();
 
}

// 
	function read_your_road(publication_qty,is_member)
	{
		
		
		
		var p_cost = 0;
		//1-50
		if(publication_qty >= 1 && publication_qty <= 50)
		{
			if(is_member=='N')
			{
				p_cost = 0.20 * publication_qty;
			}
			else
			{
				p_cost = 0 * publication_qty;
			}
			
		}

		//51-100
		if(publication_qty >= 51 && publication_qty <= 100)
		{
			if(is_member=='N')
			{
				p_cost = 0.20 * publication_qty;
			}
			else
			{
				p_cost = 0 * publication_qty;
			}
			
		}
		
		//100-200
		if( publication_qty >= 101 && publication_qty <= 200)
		{
						
			if(is_member=='N')
			{
				p_cost = 0.15 * publication_qty;
			}
			else
			{
				p_cost = 0.12 * publication_qty;
			}
			
		}

		//200-400
		if( publication_qty >= 201 && publication_qty <= 400)
		{
			
			if(is_member=='N')
			{
				p_cost = 0.12 * publication_qty;
			}
			else
			{
				p_cost = 0.10 * publication_qty;
			}
			
		}

		//400-500
		if(publication_qty >= 401 && publication_qty <= 500)
		{
					
			if(is_member=='N')
			{
				p_cost = 0.10 * publication_qty;
			}
			else
			{
				p_cost = 0.08 * publication_qty;
			}
			
		}
	
		
		
		
		
		return p_cost;
	}

	function road_safety(publication_qty,is_member)
	{
		var p_cost = 0;
		
		//1-50
		if(publication_qty>=1 && publication_qty<=50)
		{
			if(is_member=='N')
			{
				p_cost = 0.10 * publication_qty;
			}
			else
			{
				p_cost = 0 * publication_qty;
			}
			
		}

		//51-100
		else if(publication_qty>=51 && publication_qty<=100)
		{
			if(is_member=='N')
			{
				p_cost = 0.10 * publication_qty;
			}
			else
			{
				p_cost = 0 * publication_qty;
			}
			
		}
		
		//100-200
		else if(publication_qty>=101 && publication_qty<=200)
		{
			
			if(is_member=='N')
			{
				p_cost = 0.08 * publication_qty;
			}
			else
			{
				p_cost = 0.05 * publication_qty;
			}
			
		}

		//200-400
		else if(publication_qty>=201 && publication_qty<=400)
		{
			if(is_member=='N')
			{
				p_cost = 0.06 * publication_qty;
			}
			else
			{
				p_cost = 0.04 * publication_qty;
			}
			
		}

		//400-500
		else if(publication_qty>=401 && publication_qty<=500)
		{
			if(is_member=='N')
			{
				p_cost = 0.05 * publication_qty;
			}
			else
			{
				p_cost = 0.03 * publication_qty;
			}
			
		}
		

		
		return p_cost;
	}
//-->




///////////////////////////////
// For Disable Payment Options 
function checkpaytype(paytype,paytype1,payamount)
{
	

	document.getElementById(paytype).style.display='';
	document.getElementById(paytype1).style.display='none';
	amount=document.getElementById(payamount).value;

	if(paytype=='paycheck')
	{
		        document.getElementById('txtamt1').value=amount;
				document.getElementById('ptype').value='cq';
		
	}
	if(paytype=='paycc')
	{
		document.getElementById('txtamt').value=amount;
		document.getElementById('ptype').value='cc';

	
		
	}
}


 

 function ontextvalue(amount)
{
	document.getElementById('selectamt').value=amount;
	
}

 function ontextvalue1(amount)
{
	if(document.getElementById('paycc').style.display=='')
		{	document.getElementById('txtamt').value=amount; }
		
		
	if(document.getElementById('paycheck').style.display=='')
		{	document.getElementById('txtamt1').value=amount; }
	
}


//
//
function showpubDiv(divid)
	{
				
			if(divid == 'readroadDiv')
			{
				if(document.frmpub.publication_type[0].checked)
				{
					document.getElementById(divid).style.display='inline';
				}
				else
				{
					document.getElementById(divid).style.display='none';
				}
			}
			else
			{
				if(document.frmpub.publication_type[1].checked)
				{
					document.getElementById(divid).style.display='inline';
				}
				else
				{
					document.getElementById(divid).style.display='none';
				}
			}
				
	}

//
function checktotal()
{
	calculate_orderdetail();
}