// JavaScript Document

$(document).ready( function(){
	accordion(); 
	panelCont();
});

function accordion() {
	$('.hideit').css('display','none');
	$('#ft0').css('display','block');
		//hide the all of the element with class msg_body
	$(".acc-content").hide();
	$('#elm1').show();
	var el;
	var divel=$('#kui-accordion');
	var elLeng=$("#kui-accordion h4");
	//slides the element with class "msg_body" when paragraph with class "msg_head" is clicked 
	$("#kui-accordion h4").click(function()
    {

		var tagid=this.id;
		el=$('#kui-accordion')[0].offsetHeight;
		$(this).next(".acc-content").slideToggle('fast').siblings(".acc-content").slideUp("fast");
		 $(this).toggleClass("active");
		 $(this).siblings("h4").removeClass("active");
		//$('#kui-accordion').css('height', el);
		if(tagid=='facts') {
			$('.hideit').css('display','none');
			//alert('facts');
			$('#d-img').attr('src', 'images/img_flea.jpg');
			$('#d-img').attr('alt', 'Flea');
			$('#ft0').css('display','block');
		}
		else if(tagid=='trouble') {
			$('.hideit').css('display','none');
			//alert('trouble');
			$('#d-img').attr('src','images/img_tick.jpg');
			$('#d-img').attr('alt','Tick');
			$('#tt0').css('display','block');
		}
		//else if(tagid=='solution') {
//			$('.hideit').css('display','none');
//			//alert('solution');
//			$('#d-img').attr('src','images/img_flea.jpg');
//			$('#ts0').css('display','block');
//		}
	});
}

function panelCont(){
	$('.hideit').css('display','none'); var elmHide=$('.hideit').css('display','none');$('#ft0').css('display','block');
	$(".acc-content ul li a").click(function(){		
		var tgid=this.id;
		//alert(tgid);
		var tgt=$(this).attr('href');
		//alert(tgt);
		$(".hideit:not('#tgt')").css('display','none');
		$(tgt).css('display','block');
	});	
}


//var blank = new Image();
// blank.src = 'blank.gif';
// 	
// $(document).ready(function() {
//							
//   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
//   if (badBrowser) {
//     // get all pngs on page
//     $('img[src$=.png]').each(function() {
//       if (!this.complete) {
//         this.onload = function() { fixPng(this) };
//       } else {
//         fixPng(this);
//       }
//     });
//	}
//	//$('#tabs div').hide(); // Hide all divs
//	//$('#tabs div:first').show(); // Show the first div
//	var c=0;
//	var currentTab;
//	var t;	
// 	var t1;
//	var slideCount = $('#tabs ul li').length;
//	$('#tabs ul li:first').addClass('active'); // Set the class of the first link to active
//	
//	$('#tabs ul li a:not(:last)').click(function(){ //When any link is clicked
//		c= $('#tabs ul li a').index(this);
//		$('#tabs ul li').removeClass('active'); // Remove active class from all links
//		$(this).parent().addClass('active'); //Set clicked link class to active
//		currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
//		$("#tabs div:visible").fadeOut(250, function(){ //fade out visible div
//			$(currentTab).fadeIn(250);//fade in target div
//		});
//		$('#mastHome').css( {backgroundPosition: "50% 0"} )
//		$('#footer').css( {backgroundPosition: "50% 0"} )
//		$('#tabs ul li').css( {backgroundPosition: "0 0"} )
//	});
//	$('#tabs ul li a:last').click(function(){
//		c= $('#tabs ul li a').index(this);
//		$('#tabs ul li').removeClass('active'); // Remove active class from all links
//		
//		$(this).parent().addClass('active'); //Set clicked link class to active
//		currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
//		$("#tabs div:visible").fadeOut(500, function(){ //fade out visible div
//			$(currentTab).fadeIn(500);//fade in target div
//			$('#mastHome').animateToClass("stage1", 200).animateToClass("stage2", 200);
//			$('#footer').css( {backgroundPosition: "50% -48px"} )
//			$('#tabs ul li').css( {backgroundPosition: "95% 0"} )
//		})
//	});
//	
//	$('.prev').click(function(){ //When any link is clicked
//	    clearTimeout(t);
//		clearInterval(t1);
//		var pretab=currentTab.split("-");
//		currentTabno=Number(pretab[1]-2);
//		if(currentTabno < 0)
//		{
//			currentTabno=4;	
//		}
//		$('#tabs ul li a:eq('+currentTabno+')').click();
//		t1=setInterval("check_times()",6000);
//	});
//	$('.next').click(function(){ //When any link is clicked
//		clearTimeout(t);
//		clearInterval(t1);
//		var pretab=currentTab.split("-");
//		currentTabno=Number(pretab[1]);
//		if(currentTabno > (slideCount-1))
//		{
//			currentTabno=0;	
//		}
//		$('#tabs ul li a:eq('+currentTabno+')').click();
//		t1=setInterval("check_times()",6000);
//	});
//	
//	function autoPlay (){
//		
//		//initialDelay()
//		timedCount()
//		function initialDelay(){ // initial gallery delay
//			t=setTimeout(timedCount,6000);
//		}
//		function timedCount(){ // delay between slides
//			$('#tabs ul li a:eq('+c+')').click();
//			t=setTimeout(
//				function(){
//					if(c < (slideCount - 1)){ 	// loops through slides
//						c=c+1;
//						timedCount()
//					}else{ 					// rests slide to beginning
//						c=0;
//						timedCount()
//					}
//				},
//				6000
//			)
//		}
//		function stopCount(){
//			clearTimeout(t);
//		}
//	};
//	autoplays=function autoPlay1 (){
//		clearTimeout(t);
//		//initialDelay()
//		timedCount()
//		function initialDelay(){ // initial gallery delay
//			t=setTimeout(timedCount,6000);
//		}
//		function timedCount(){ // delay between slides
//			c++;
//			if(c ==(slideCount))
//			{
//				c=0;
//			}
//			$('#tabs ul li a:eq('+c+')').click();
//			t=setTimeout(
//				function(){
//					if(c < (slideCount - 1)){ 	// loops through slides
//						c=c+1;
//						timedCount()
//					}else{ 					// rests slide to beginning
//						c=0;
//						timedCount()
//					}
//				},
//				6000
//			)
//		}
//		function stopCount(){
//			clearTimeout(t);
//		}
//	};
//	if($('#mastHome').length){
//		autoPlay()
//	}
//	check_times=function check_time()
//	{		
//		clearInterval(t1);
//		autoPlay()
//	}
// });
// function fixPng(png) {
//   // get src
//   var src = png.src;
//   // set width and height
//   if (!png.style.width) { png.style.width = $(png).width(); }
//   if (!png.style.height) { png.style.height = $(png).height(); }
//   // replace by blank image
//   png.onload = function() { };
//   png.src = blank.src;
//   // set filter (display original image)
//   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
// }