//for blog and products
function blogtabSetect(id){
	  var li = document.getElementById('blogtab').getElementsByTagName("li");
	  for(var i=1; i<=li.length; i++){
		 tabTitle = document.getElementById('blogtab' +i + 'link').innerHTML;
		 tabClass = 'tabLink';
		 tabedClass = 'blogtabed';
		 if (i == 4 || i == 6) {
			 tabClass = tabClass + ' blogtabLine';
			 tabedClass = tabedClass + ' blogtabLine';
		 }
	     if(i == id){
		   document.getElementById('blogtabBox' + i).innerHTML = '<span class="' + tabedClass + '" id="blogtab'+i+'link">'+ tabTitle +'</span>';
		   document.getElementById('blogtab'+i+'List').className = 'hotList disb';
		   blogImgResize(i);
		 }else{
		   document.getElementById('blogtabBox' + i).innerHTML ='<a href="#" onclick="javascript:blogtabSetect('+i+'); return false;" id="blogtab'+i+'link" class="' + tabClass + '">' + tabTitle + '</a>';
		   document.getElementById('blogtab'+i+'List').className = 'hotList disn';
		 }
	  }
	  return false;
	}

function blogImgResize(i){
	$('#blogtab' + i + 'List > div.blogcontent > #blogimg > a > img').each(function(){
	    var image = $(this);
	    var maxheight = 180;
	    var maxwidth = 180;
	    var height = image.height();
	    var width = image.width();
	    if(height > 0 && width > 0){

		    if(width/height >= maxwidth/maxheight){
			if(width > maxwidth){
				image.width(maxwidth);
				image.height((height * maxwidth)/width);
			}
		    } else{
			    if(height > maxheight){
				image.height(maxheight);
				image.width((width * maxheight)/height);
			    }
		    }
	    }
	    return false;
	});
	
}
