var transparentImage = "images/transparent.gif";

function fixTrans()
{
	if (typeof document.body.style.maxHeight == 'undefined') {

	var imgs = document.getElementsByTagName("img");
	
	for (i = 0; i < imgs.length; i++)
	{	
		if (imgs[i].src.indexOf(transparentImage) != -1)
		{
			return;
		}

		if (imgs[i].src.indexOf(".png") != -1)
			{
				var src = imgs[i].src;
				imgs[i].src = transparentImage;
				imgs[i].runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
				imgs[i].style.display = "block";
			}
		}	
	}
}

if (document.all && !window.opera)
	attachEvent("onload", fixTrans);
	
/*--- IE6 hover ---*/
function ieHover(h_list, h_class){
	if(jQuery.browser.msie && jQuery.browser.version < 7){
		if(!h_class) var h_class = 'hover';
		jQuery(h_list).mouseenter(function(){
			jQuery(this).addClass(h_class);
		}).mouseleave(function(){
			jQuery(this).removeClass(h_class);
		});
	}
}





function initToltip(){
	jQuery('div.tooltip-holder').each(function(){
		var hold = jQuery(this);
		var links = hold.find('> a');
		var toltips = hold.find('> div.tooltip');
		var _active;
		
		function findPosY(obj){
			var posTop = 0;
			while(obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
			return posTop;
		}
		function findPosX(obj){
			var posLeft = 0;
			while(obj.offsetParent) {posLeft += obj.offsetLeft; obj = obj.offsetParent;}
			return posLeft;
		}
		links.hover(function(){
			_active = links.index(jQuery(this));
			toltips.eq(_active).css({
				top: links.eq(_active).position().top - 15
		//		left: links.eq(_active).position().left - toltips.outerWidth(true)-4
			}).show();
			
		}, function(){
			toltips.eq(_active).hide();
		});
	});
}
function initTabs(){
	jQuery('ul.tabset').each(function(){
		var btn_h = jQuery(this);
		var _btn = jQuery(this).find('a.tab');
		var _a = _btn.index(_btn.filter('.active:eq(0)'));
		if(_a == -1) _a = 0;
		_btn.parents('div.tweet-box').removeClass('active').eq(_a).addClass('active');
		_btn.each(function(_i){
			this._box = this.href.substr(this.href.indexOf("#") + 1);
			if(this._box){
				this._box = jQuery('#'+this._box);
				if(_i == _a) this._box.show();
				else this._box.hide();
			}
			this.onclick = function(){
				changeTab(_i);
				return false;
			}
		});
		
		function changeTab(_ind){
			if(_ind != _a){
				if(_btn.get(_a)._box) _btn.get(_a)._box.hide();
				if(_btn.get(_ind)._box) _btn.get(_ind)._box.show();
				_btn.eq(_a).removeClass('active');
				_btn.eq(_ind).addClass('active');
				_a = _ind;
			}
		}
	});
	jQuery('ul.tabset2').each(function(){
		var btn_h = jQuery(this);
		var _btn = jQuery(this).find('a.tab');
		var _a = _btn.index(_btn.filter('.active:eq(0)'));
		if(_a == -1) _a = 0;
		_btn.parents('div.tweet-box').removeClass('active').eq(_a).addClass('active');
		_btn.each(function(_i){
			this._box = this.href.substr(this.href.indexOf("#") + 1);
			if(this._box){
				this._box = jQuery('#'+this._box);
				if(_i == _a) this._box.show();
				else this._box.hide();
			}
			this.onclick = function(){
				changeTab(_i);
				return false;
			}
		});
		function changeTab(_ind){
			if(_ind != _a){
				if(_btn.get(_a)._box) _btn.get(_a)._box.hide();
				if(_btn.get(_ind)._box) _btn.get(_ind)._box.show();
				_btn.eq(_a).removeClass('active');
				_btn.eq(_ind).addClass('active');
				_a = _ind;
			}
		}
	});
}





jQuery(document).ready(function() {
   jQuery("ul.sort-nav li:last-child").addClass("last-child");
   
   jQuery('#tabs-prod div').hide(); // Hide all divs
   jQuery('#tabs-prod div:first').show(); // Show the first div
   jQuery('#tabs-prod ul li:first').addClass('active'); // Set the class of the first link to active
   jQuery('#tabs-prod ul li a').click(function() {
      //When any link is clicked
      jQuery('#tabs-prod ul li').removeClass('active'); // Remove active class from all links
      jQuery(this).parent().addClass('active'); //Set clicked link class to active
      var currentTab = jQuery(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
      jQuery('#tabs-prod div').hide(); // Hide all divs
      jQuery(currentTab).show(); // Show div with id equal to variable currentTab
      return false; }
   ); }
   
   
); 


jQuery(document).ready(function(){
								
   jQuery('#tabs-offer div').hide(); // Hide all divs
   jQuery('#tabs-offer div:first').show(); // Show the first div
   jQuery('#tabs-offer ul li:first').addClass('active'); // Set the class of the first link to active
   jQuery('#tabs-offer ul li a').click(function() {
      //When any link is clicked
      jQuery('#tabs-offer ul li').removeClass('active'); // Remove active class from all links
      jQuery(this).parent().addClass('active'); //Set clicked link class to active
      var currentTab1 = jQuery(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
      jQuery('#tabs-offer div').hide(); // Hide all divs
      jQuery(currentTab1).show(); // Show div with id equal to variable currentTab
      return false; }
   ); }
);


jQuery(document).ready(function(){
	ieHover(".sort-nav > li");
	ieHover(".nav-holder ul > li");
	ieHover(".main-gallery .product", "product-hover");
	ieHover(".main-gallery .big", "big-hover");
	ieHover(".footer-nav li");
	initToltip();
	initTabs();			
});




								   


