function payChange(vPType, vCurrency)
{
	var frm = document.frmJoin;
	frm.currencycode.value = vCurrency;
}

function selectPPRow(frm)
{
	for(i=0; i<=frm.elements.length-1; i++)
	{
		if(frm.elements[i].type == "radio" && frm.elements[i].name == "pricepointid")
		{
			var rowid = document.getElementById("pprow"+frm.elements[i].value);
			if( frm.elements[i].checked )
				rowid.className = "selectedRow";
			else
				rowid.className = "normalRow";
		}
	}
}

function doSubmit(frm)
{
	var vPPIndex;
	var vPPId;
	vPPIndex = getSelectedIndex(frm.pricepointid);

	if( vPPIndex == -1 )
	{
		alert("STEP ONE SELECT MEMBERSHIP TERM:\n\nPlease select the account type.");
		frm.pricepointid[0].focus();
		return false;
	}

	vPPId = frm.pricepointid[vPPIndex].value;
	vDuration = document.getElementById('multi'+vPPId);

	if( isBlank(frm.firstname.value, 2) )
	{
		alert("STEP THREE CONTACT INFO:\n\nFirst Name should be atleast 2 characters in length.");
		frm.firstname.focus();
		return false;
	}

	if( isBlank(frm.lastname.value, 2) )
	{
		alert("STEP THREE CONTACT INFO:\n\nLast Name should be atleast 2 characters in length.");
		frm.lastname.focus();
		return false;
	}

	
	if( !EmailValidation(frm.email, "E-Mail Address") )
	{
		return false;
	}

	//Added on 12Dec08 for email subscription validations by anji 
	if( getSelectedIndex(frm.email_subscription) == -1 )
	{
		alert("STEP FIVE SUBMIT INFO:\n\nPlease select the email subscriptions.");
		frm.email_subscription[0].focus();
		return false;
	}
	//end of email subscription 

	var vPayType = '';

	if( frm.paytype.length )
	{
		if( getSelectedIndex(frm.paytype) == -1 )
		{
			alert("STEP FOUR SELECT PAYMENT TYPE:\n\nPlease select the payment type.");
			frm.paytype[0].focus();
			return false;
		}

		//alert(frm.paytype[getSelectedIndex(frm.paytype)].value);
		
		vPayType = frm.paytype[getSelectedIndex(frm.paytype)].value;

		if( frm.paytype[getSelectedIndex(frm.paytype)].value == 'pp' )
		{
				var ppidx;
				ppidx = getSelectedIndex(frm.pricepointid);
				//alert(frm.pricepointid[ppidx].alt);
				if( frm.pricepointid[ppidx].alt )
				{
						if( frm.pricepointid[ppidx].alt == '0' )
						{
								alert("You can not use PayPal as payment method for this price plan. Please select Credit Card or WorldPay.");
								return false;
						}
				}
		}
	}
	else
	{
		if( !frm.paytype.checked )
		{
			alert("STEP FOUR SELECT PAYMENT TYPE:\n\nPlease select the payment type.");
			frm.paytype.focus();
			return false;
		}
		else
		{
			vPayType = frm.paytype.value;
		}
	}

	if( getSelectedIndex(frm.autorecycle) == -1 )
	{
		alert("STEP TWO BILLING FREQUENCY:\n\nPlease select the recycling type.");
		frm.autorecycle[0].focus();
		return false;
	}
	
	if( frm.couponcode.value != '' )
	{
		//Check if the user is trying to use coupon with a multi month plan
		if( vDuration.value > 1 )
		{
		  alert("COUPONS ARE NOT ALLOWED WITH MULTI-MONTH PLANS:\n\nNewsdemon multi-month plans are offered in discounted prices.");
			frm.couponcode.focus();
			return false;
		}
	}
	
	//Added By Anji on 11Dec08 For Recycling is not supported for pp and wp
	
	var autorecycle = frm.autorecycle[getSelectedIndex(frm.autorecycle)].value;
	var paytype = frm.paytype[getSelectedIndex(frm.paytype)].value;
	if((autorecycle == 1 && paytype == 'wp') || (autorecycle == 1 && paytype == 'pp'))
	{
		alert('Currently, we do not support Auto-Recycle for PayPal and WorldPay payment methods.\nPlease select "PAY WITH US DOLLARS" option if you would like to have Auto-Recycle.\n');	
		return false;
	}
	// End of recycling not supporting code
	
	/*
	if( frm.user_q_ref.value == '- SELECT -' )
	{
		alert('Please specify How did you hear about Newsdemon?');
		frm.user_q_ref.focus();
		return false;
	}
	*/
	/* POST the form now */
	return true;
}
