var blank = new Image();
blank.src = '/site/templates/styles/images/blank.gif';

$(document).ready(function() {
	
	$('#jscheck').remove();
	
	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);
	   }
	 });
	}
	
	//drop-dowm menu in topbar
	$("body").bind("click", function (e) {
	$('.dropdown-toggle, .menu').parent("li").removeClass("open");
	});
	$(".dropdown-toggle, .menu").click(function (e) {
	var $li = $(this).parent("li").toggleClass('open');
	return false;
	});
	
	//tabs
	$("ul.tabs li").click(function (e) {
		$("ul.tabs li").removeClass("active");
		$(this).addClass('active');
		$curid=$(this).attr('id');
		$(".well").addClass("closetab");
		$("."+$curid).removeClass("closetab");
	});
	
	$("ul.tabs2 li").click(function (e) {
		$("ul.tabs2 li").removeClass("active");
		$(this).addClass('active');
		$curid=$(this).attr('id');
		$(".well").addClass("closetab");
		$("."+$curid).removeClass("closetab");
	});
			
});

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')";
 }
