// JavaScript Document
/*$(document).ready(function(){ 
   $("#sortProvider").click(function(){ 
     $("#list_ziptable").load("inc/zipTableSort.php"); 
   }); 
}); */
//the following is an example 
function setTabValue(tab) {
	$("#tabvalue").html(tab);
}
function sortProvider(sortColumn,zip,type,tableType,sortType,tab,ref,customKwh,refurl) {
	if (tab != $("#tabvalue").text()) {
		tab = $("#tabvalue").text();
	}
	var param = "ftZip=" + zip + "&sort=" + sortColumn + "&type=" + type + "&order=" + sortType + 
			    "&ref=" + ref + "&tableType=" + tableType + "&tab=" + tab + "&customKwh=" + customKwh + "&refurl=" + refurl;
	$.ajax({   
		type: "GET",   
		url: "inc/zipTableSort.php",   
		data: param,   
		dataType: "text/html",   
		success: function(html){ 
			var result=html.split("<--RECORDCOUNTSEPARATOR-->"); 
			$("#list_ziptable").html(result[0]);  
			$("#recordCountSpan").text(result[1]); 
			$(document).ready(function() {
				//Navigation
				$('#ziptable_nav li').click(function() {
					$('#ziptable_nav li').removeClass('selected_item')
					$('#ziptable_nav li').addClass('item');
					$(this).removeClass('item');
					$(this).addClass('selected_item');
				})
				//slide
				$('.link_provider_detail').click(function() {
					if ($(this).parent().find('#provider_details').is(":hidden")) {
						$('.link_plan_detail').removeClass('selected_item');
						$(this).addClass('selected_item');
						$(this).parent().find('#plan_details').hide();
						$(this).parent().find('#promotion_details').hide();
						$(this).parent().find('#provider_details').slideDown();
						$(this).parent().find('.ziptable_detail_link_close').show();
					} else {
						$(this).parent().find('#provider_details').slideUp();
						$(this).parent().find('.link_provider_detail').removeClass('selected_item');
						$(this).parent().find('.ziptable_detail_link_close').hide();
					}
				});
				$('.link_plan_detail').click(function() {
					if ($(this).parent().find('#plan_details').is(":hidden")) {
						$('.link_provider_detail').removeClass('selected_item');
						$(this).addClass('selected_item');
						$(this).parent().find('#provider_details').hide();
						$(this).parent().find('#promotion_details').hide();
						$(this).parent().find('#plan_details').slideDown();
						$(this).parent().find('.ziptable_detail_link_close').show();
					} else {
						$(this).parent().find('#plan_details').slideUp();
						$(this).parent().find('.link_plan_detail').removeClass('selected_item');
						$(this).parent().find('.ziptable_detail_link_close').hide();
					}
				});
				$('.link_promotion_detail').click(function() {
					if ($(this).parent().find('#promotion_details').is(":hidden")) {
						$('.link_provider_detail').removeClass('selected_item');
						$(this).addClass('selected_item');
						$(this).parent().find('#provider_details').hide();
						$(this).parent().find('#plan_details').hide();
						$(this).parent().find('#promotion_details').slideDown();
						$(this).parent().find('.ziptable_detail_link_close').show();
					} else {
						$(this).parent().find('#promotion_details').slideUp();
						$(this).parent().find('.link_promotion_detail').removeClass('selected_item');
						$(this).parent().find('.ziptable_detail_link_close').hide();
					}
				});
				$('.ziptable_detail_link_close').click(function() {
					$(this).hide();
					$(this).parent().find('#provider_details').slideUp();
					$(this).parent().find('#plan_details').slideUp();
					$(this).parent().find('#promotion_details').slideUp();
					$(this).parent().find('.link_plan_detail').removeClass('selected_item');
					$(this).parent().find('.link_provider_detail').removeClass('selected_item');
					$(this).parent().find('.link_promotion_detail').removeClass('selected_item');
				})
			})
			Shadowbox.setup();
			enableTooltips();
		}  
	}); 
} 
function countClick(url,linkId,planId,affiliateId) {
	var param = 'url=' + url + '&linkId=' + linkId + '&planId=' + planId + '&affiliateId=' + affiliateId;
	//alert(param);
	$.ajax({   
		type: "GET",   
		url: "inc/addClick.php",   
		data: param,   
		dataType: "text/html",   
		success: function(html){ 
			//do nothing
		}
	});
}
