// JavaScript Document

/*jquery top menu*/
$(document).ready(function()
{

	$("ul.topnav li").hover(function()
	{
			$(this).addClass("hover");
			$('ul:first',this).css("visibility", "visible");
	
	}, function()
	{
			$(this).removeClass("hover");
			$('ul:first',this).css("visibility", "hidden");

	});	
	
	$("ul.subnav li").hover(function()
	{
			$(this).addClass("hover");
			$('ul:first',this).css("visibility", "visible");
	
	}, function()
	{
			$(this).removeClass("hover");
			$('ul:first',this).css("visibility", "hidden");

	});	

});

/*End of Top Menu*/


/*Products page template*/
function prodMenu(show) {
  	   var divName
	   switch (show) {
			case '1':
			 divName = '#ib_overview';
			break;
			case '2':
			 divName = '#ib_pricing';
			break;
			case '3':
			 divName = '#ib_catalog';
			break;
			case '4':
			 divName = '#ib_faq';
			break;		   
	   }
	   $('.ibox').hide();
	   $(divName).show('slow');
}


/*faq answer loader*/
function faqAnswer(id)
{
		$.ajax({
				type: "GET",
				url: "/js/faq.php",
				data: "id=" + id,
				success: function(output) {
					$("#ib_faq_answer").html("<p><b>Answer:</b> <br />" + output + "</p>");	
				}
		});
		
}

/*Change info on map click*/
function mapClick(region, title) {
	$("#contact_disp").show('slow');
	$("#curr_region").html(region);
	$("#selected_region_title").html(title);
	chgContact(1); /*opens waterworks contact by default */
}


/*mainpulate contact information divs */
function chgContact(id) {
	var reg = $("#curr_region").html();
	$.ajax({
			type: "GET",
			url: "/js/contact.php",
			data: "b=" + id + "&r=" + reg,
			success: function(output) {
				$(".contact_details").hide('slow');
				$(".contact_header").css("background-image","url(../images/contact_bar.png)");
				$("#contact_"+id).html(output);
				$("#contact_"+id).show('slow');
				$("#hdr_"+id).css("background-image","url(../images/contact_bar_open.png)");
			}
		   });
}

/*change Newsletter */
function chgNwsltr(id) {
	$.ajax({
			type: "GET",
			url: "/js/news.php",
			data: "i=" + id,
			success: function(output) {
				$("#enews_result_det").hide();
				$("#enews_result_det").load(output);
				$("#enews_result_det").show('slow');
				$("#enews_result_title").html("");
			}
		   });
}

/*Populate the catalog lists*/
function getCatalog(group) {
	/*get the group name and graphic*/
	$.ajax({
		   type: "GET",
		   url: "/js/catalog_hdr.php",
		   data: "g=" + group,
		   dataType: "json",
		   success: function(arrOut) {
				$("#cat_result_title").html('<p class="SectionText" style="text-indent:15px;">'+arrOut.title+'</p>');		
				$("#cat_result_pic").css("background-image","url(../images/"+ arrOut.pic +")");
			}
		
	});
	
	/*get the list of catalogs*/
	$.ajax({
		   type: "GET",
		   url: "/js/catalog.php",
		   data: "g=" + group,
		   success: function(output) {
			   	var strHTML;
				$("#cat_result_det").hide();
				$("#cat_result_det").html('<ul style="list-style-type:square; margin-left:-20px;">' + output + '</ul>');
			   	$("#cat_result_det").show('slow');				
		   }
	});
}


/*drive Quality Management Content */
function chgQuality(id) {
	$.ajax({
		   type: "GET",
		   url: "/js/quality.php",
		   data: "q=" + id + "&a=hdr" ,
		   dataType: "json",
		   success: function(arrOut) {
				$("#qc_result_title").html('<p class="SectionText" style="text-indent:15px;">'+arrOut.title+'</p>');		
				$("#qc_left_content").css("background-image","url(../images/"+ arrOut.pic +")");

			}
		
	});

	$.ajax({
		   type: "GET",
		   url: "/js/quality.php",
		   data: "q=" + id + "&a=body" ,
		   success: function(output) {
			   	$("#qc_result_det").hide();
				$("#qc_result_det").html(output);
			   	$("#qc_result_det").show('slow');				

			}
		
	});
	

}


/*Populate the price lists*/
function getPricing(group) {
	/*get the group name and graphic*/
	$.ajax({
		   type: "GET",
		   url: "/js/catalog_hdr.php",
		   data: "g=" + group,
		   dataType: "json",
		   success: function(arrOut) {
				$("#cat_result_title").html('<p class="SectionText" style="text-indent:15px;">'+arrOut.title+'</p>');		
				$("#cat_result_pic").css("background-image","url(../images/"+ arrOut.pic +")");
			}
		
	});
	
	/*get the list of catalogs*/
	$.ajax({
		   type: "GET",
		   url: "/js/pricing.php",
		   data: "g=" + group,
		   success: function(output) {
			   	var strHTML;
				$("#cat_result_det").hide();
				$("#cat_result_det").html('<ul style="list-style-type:square; margin-left:-20px;">' + output + '</ul>');
			   	$("#cat_result_det").show('slow');				
		   }
	});
}
function chgOem(id) {
	$.ajax({
		   type: "GET",
		   url: "/js/oem.php",
		   data: "i=" + id,
		   dataType: "json",
		   success: function(arrOut) {
				$("#qc_result_title").html('<p class="SectionText" style="text-indent:15px;">'+arrOut.title+'</p>');
				$("#qc_left_content").css("background-image","url(../images/"+ arrOut.pic +")");
                                $("#qc_result_det").hide();
				$("#qc_result_det").html(arrOut.content);
			   	$("#qc_result_det").show('slow');
                                
			}

	});
}
