 extArray = new Array(".txt");

function checkFileType(file) {
	allowSubmit = false;
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}	
	if (!allowSubmit) {
		alert(	"Please only upload file type:  " + (extArray.join("  ")) + 
				"\nPlease select a different output or ignore this option!");
	}	
}

function refer(id, word) {
	$.post("/refer/" + id, { word_id: id }, null);
}

function setPaymentValues() {
	$('#fh0').val($('#fv0').val());
	$('#fh1').val($('#fv1').val());
	$('#fh3').val($('#gift').attr('checked'));
	if ($('input[name=gift]').attr('checked')) {
		$('#fh3').val(1);
	} else {
		$('#fh3').val(0);
	}
}

function previewApply() {
	var website = $("#website").val();
	if (website.length == 0 || website == "http://") {
		alert("Website is not valid!");
	} else {
		var protocol = website.substring(7, 0);
		if (protocol != "http://") {
			website = "http://" + website;
			$("#website").attr("value", website);
		}
		
		$("#blink").css("display", "block");
		$("#purchase").css("display", "block");
		
 		$("a#word").attr("href", website);
 		$("a#word").attr("target", "_blank");
 		$("a#word").removeClass("active0");
 		$("a#word").addClass("active1");
 		$("#word_link").attr("value", website);
	}
}

$(document).ready(function() {
	// faq spell
	$(".faq_body").hide();
	$(".faq_head").click(function() { $(this).next(".faq_body").slideToggle(700); });
});