function products() {
	if(trimString(document.getElementById("id").value) == "" || trimString(document.getElementById("id").value) == "0") {
		document.getElementById("id").focus();
		alert("Please select a Product Type.");
		return false;
	}
	
	if(trimString(document.getElementById("accociated_parent_id").value) == 0) {
		for(var i=1;i<=10;i++) {
			if(trimString(document.getElementById("associate_id_"+i).value) != 0 && trimString(document.getElementById("associate_id_"+i).value) != "") {
				for(var j=1;j<i;j++) {
					if(trimString(document.getElementById("associate_id_"+i).value) == trimString(document.getElementById("associate_id_"+j).value)) {
						document.getElementById("associate_id_"+i).focus();
						alert("Duplicate bond type identified. Please check the associate bond types.");
						return false;
					}
				}
			}
		}
	}
}

function loadProductType(id) {
	window.location = document.getElementById("base_path").value+"admin/admins/product/"+id;
}

function loadProductFaq(category_id) {
	var url = document.getElementById("base_path").value+"admin/admins/ajax_category_faq/";
	var params = 'category_id='+category_id+'&ids='+document.getElementById("product_faqIds").value;
	var amjax = new Ajax.Updater(
	{success: 'dgDiv'},url,
	{method: 'post', parameters: params,onComplete:getCategoryResult});
}
function getCategoryResult(request) {
	var val = removeHTMLTags(trimString(request.responseText));
}

function loadStateProductList() {
	var focusid = document.getElementById("tbx_focus_groups_id").value;
	var url = document.getElementById("base_path").value+"admin/admins/ajax_state_product/"+focusid;
	var params = 'state_id='+document.getElementById("state_id").value;
	
	var amjax = new Ajax.Updater(
	{success: 'product_div'},url,
	{method: 'post', parameters: params,onComplete:getStateResult});
}

function getStateResult(request) {
	var val = removeHTMLTags(trimString(request.responseText));
}

function selectFAQS(id) {
	if(document.getElementById("tbx_faq_id_"+id).checked == true) {
		document.getElementById("product_faqIds").value = document.getElementById("product_faqIds").value+"@"+id;
	} else {
		var arr = document.getElementById("product_faqIds").value.split("@");
		var ids = "";
		for(x=0;x<arr.length;x++) {
			if(trimString(arr[x])!="" && trimString(arr[x])!=id) {
				ids = ids+"@"+trimString(arr[x]);
			}
		}
		document.getElementById("product_faqIds").value = ids;
	}
}

function loadstate(focusid){
window.location = document.getElementById("base_path").value+"admin/admins/state_product/"+focusid;
}

function loadStateProductType(state_id,id) {
    var focusid = document.getElementById("tbx_focus_groups_id").value;
	window.location = document.getElementById("base_path").value+"admin/admins/state_product/"+focusid+"/"+state_id+"/"+id;
}

function loadStateProductFaq(state_id,product_id,category_id) {
	var focusid = document.getElementById("tbx_focus_groups_id").value;
	window.location = document.getElementById("base_path").value+"admin/admins/state_product/"+focusid+"/"+state_id+"/"+product_id+"/"+category_id;
}
function state_products() {
	if(trimString(document.getElementById("state_id").value) == "" || trimString(document.getElementById("state_id").value) == "0") {
		document.getElementById("state_id").focus();
		alert("Please select a State.");
		return false;
	}
	if(trimString(document.getElementById("product_id").value) == "" || trimString(document.getElementById("product_id").value) == "0") {
		document.getElementById("product_id").focus();
		alert("Please select a Product Type.");
		return false;
	}
}

function showCategoryDiv(id) {
	var ids = $F('category_ids');
	var ids_arr = ids.split(",");
	for(x=0;x<ids_arr.length-1;x++) {
		if(trimString(ids_arr[x])!="") {
			var div1 = "categoryDivShow"+ids_arr[x];
			var div2 = "categoryDivHide"+ids_arr[x];
			var div3 = "categoryProductsDiv"+ids_arr[x];
			if(ids_arr[x]==id) {
				$(div1).hide();
				$(div2).show();
				$(div3).show();
			} else {
				$(div2).hide();
				$(div1).show();
				$(div3).hide();
			}
		}
	}
}