if (top.frames.length!=0) {top.location=self.document.location;}	// pop join page out of frames
function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}	// popup script
// on price point change, update checkbox css
$(document).ready(function() {
	// bundle css swap
	$('.options input:radio').each(function(){
		if($(this).attr('hasbundle') == "1"){
			tobundle = $(this).attr('tobundle');
			bundlelabel = $(this).attr('bundlelabel');
			bundleprice = $(this).attr('bundleprice');
			bundlesubtext = $(this).attr('bundlesubtext');
			value = 'option_' + $(this).attr('value');
			parallelid = 'option_' + ($('#' + tobundle+ ' input:radio').attr('value'));
			$(this).attr('parallelid', parallelid);
			$('#' + tobundle+ ' input:radio').attr({
  				bundlelabel: bundlelabel,
  				bundleprice: bundleprice,
  				bundlesubtext: bundlesubtext,
  				parallelid: value,
  				hasbundle: '1'
			});
		}
	});
	$('.options input:radio').click(function(){
		if($(this).attr('hasbundle') == "1"){
			$('#bundlebox').fadeTo('fast', 1);
			$('#bundle_text').text($(this).attr('bundlelabel'));
			$('#bundle_price').text($(this).attr('bundleprice'));		
			$('#bundle_subtext').text($(this).attr('bundlesubtext'));}			
		else
			$('#bundlebox').fadeTo('fast', 0);
	});
	$('#addBundle').removeAttr('checked');
	$('.options input:radio:first').click();
	// selected option css swap
	$("input[type!='submit']").click(function() {	// cascade options
		var label = $(this).parent("label");
		var labels = $(this).parents("ul").find("label");
		if ($(this).attr("type") == "radio") $(labels).each(function(i) {$(this).removeClass("checked");});
		if ($(this).attr("checked") == true) $(label).addClass("checked");
		else $(label).removeClass("checked");
	});
	$("input[type!='submit']").each(function(i) {	// join options
		var label = $(this).parent("label");
		if ($(this).attr("checked") == true) $(label).addClass("checked");
		else $(label).removeClass("checked");
	});
});
// display checked/unchecked bundle 
function switchBundle(){
	if ($('#addBundle:checked').val() == 1) {
		$('.original').hide();
		$('.bundleoption').show();
	}
	else {
		$('.bundleoption').hide();
		$('.original').show();
	}
	optionid = $('#join_options  input:radio:checked').attr('parallelid');
	$('#' + optionid).attr('checked', 'checked'); 
	$('#' + optionid).click();
}
// show / hide available options for billers
function switchCascade (cascadeName) {
	$('#addBundle').removeAttr('checked');
	var label = $('#addBundle').parent("label").removeClass("checked");
	switch (cascadeName) {
		case "Join by Credit / Debit Card":		// credit card options
			$('#MonthlyRecurring').children("label").click();
			$('#Trial').show();
			$('#MonthlyRecurring').show();
			$('#MonthlyNonRecurring').show();
			$('#Mobile').show();
			$('#Quarterly').show();
		break;
		case "Join by Online Check":			// online check options
			$('#MonthlyRecurring').children("label").click();
			$('#Trial').hide();
			$('#MonthlyNonRecurring').hide();
			$('#Mobile').hide();
			$('#MonthlyRecurring').show();
			$('#Quarterly').show();
		break;
		case "EU Debit / DirectPay / AsiaPay":	// euro debit options
		case "EC / GiroCard / GiroPay":			// giropay (DE) options
			$('#MonthlyRecurring').children("label").click();
			$('#Mobile').hide();
			$('#MonthlyNonRecurring').show();
			$('#Trial').show();
			$('#MonthlyRecurring').show();
			$('#Quarterly').show();
		break;
		case "China / Taiwan Debit":			// chinapay (CN) & taiwanpay (TW) options
			$('#MonthlyNonRecurring').children("label").click();
			$('#Mobile').hide();
			$('#MonthlyRecurring').hide();
			$('#Trial').hide();
			$('#MonthlyNonRecurring').show();
			$('#Quarterly').show();
		break;
	}
}
// old function
function checkCascade (cascadeName) {
	switch (cascadeName) {
		// credit card options
		case "Join by Credit / Debit Card":
			showOption("Trial");
			showOption("MonthlyRecurring");
			showOption("MonthlyNonRecurring");
			showOption("Mobile");
			showOption("Quarterly");
		break;
		// online check options
		case "Join by Online Check":
			hideOption("Trial");
			hideOption("MonthlyNonRecurring");
			hideOption("Mobile");
			showOption("MonthlyRecurring");
			showOption("Quarterly");
		break;
		// euro debit options
		case "EU Debit / DirectPay / AsiaPay":
			$('#MonthlyRecurring').children("label").click();
			
			hideOption("Mobile");
			showOption("MonthlyNonRecurring");
			showOption("Trial");
			showOption("MonthlyRecurring");
			showOption("Quarterly");
		break;
		// giropay (DE) options
		case "EC / GiroCard / GiroPay":
			hideOption("Mobile");
			showOption("MonthlyNonRecurring");
			showOption("Trial");
			showOption("MonthlyRecurring");
			showOption("Quarterly");
		break;
		// chinapay (CN) & taiwanpay (TW) options
		case "China / Taiwan Debit":
			hideOption("Mobile");
			showOption("MonthlyNonRecurring");
			hideOption("Trial");
			hideOption("MonthlyRecurring");
			showOption("Quarterly");
		break;
	}
}
function checkOption (optionType) {	// on price change, set custom3 value for specific access
	// custom2 check
	switch (optionType) {
		case "MonthlyRecurringBundle": 
		case "MonthlyNonRecurringBundle": 
		case "MobileBundle": 
		case "QuarterlyBundle": document.getElementById('custom2').value = "cs1|c8d3ba970528727f7c7da97e4458d057|0"; 	break;
		default: 				document.getElementById('custom2').value = "";
	}
	// custom3 check
	switch (optionType) {
		case "Mobile":
		case "MobileBundle": 	document.getElementById('custom3').value = "access=mobi"; 	break;
		case "Trial": 			document.getElementById('custom3').value = "access=trial"; 	break;
		default: 				document.getElementById('custom3').value = "";
	}
}
function hideOption (joinOption) {	// hide option for option availability
	if (document.getElementById(joinOption)) {
		$('#'+joinOption).fadeOut('fast');
	}
}
function showOption (joinOption) {	// show option for option availability
	if (document.getElementById(joinOption)) {
		$('#'+joinOption).fadeIn('fast');
	}
}
