var browser=navigator.appName;
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

$(document).ready(function() { // activates the promo slider
	
	jQuery("a.picture").fancybox();
	
	
	
	// ====================================
	// store and portfolio hover effects
	// ====================================

	if (document.getElementById("PortfolioList") != null) {
		
		var maxheight = 0;
		$("h2").children("a").each(function() {
			
			var hheight = parseInt($(this).height());
			if (hheight > maxheight) {
				maxheight = hheight;
			}

		});
		
		$("h2").children("a").each(function() {
			
			var hheight = parseInt($(this).height());
			var padd = parseInt($(this).css("paddingTop"));
			padd = padd+(maxheight-hheight)/2;
		
			$(this).css({paddingTop: padd, paddingBottom: padd});
		
			if(!$.browser.msie || ($.browser.msie && parseInt(jQuery.browser.version) != 7)) {
		
				// store 
				var bpadd = parseInt($(".PortfolioItem").children(".ItemContent").height());
				var theight = parseInt($(".PortfolioThumbnail").children("a").height());
				$(this).parent("h2").parent(".PortfolioItem").children(".PortfolioThumbnail").mouseover(function() {
				
					npadd = padd+7;
					ntheight = theight-14;
					nbpadd = bpadd+7;
		
					$(this).parent(".PortfolioItem").children("h2").children("a").animate({paddingTop: npadd}, 100, "linear");
					$(this).children("a").animate({height: ntheight}, 100, "linear");
					$(this).parent(".PortfolioItem").children(".ItemContent").animate({height: nbpadd}, 100, "linear");
				
				}).mouseout(function() {
					
					$(this).parent(".PortfolioItem").children("h2").children("a").animate({paddingTop: padd}, 100, "linear");
					$(this).children("a").animate({height: theight}, 100, "linear");
					$(this).parent(".PortfolioItem").children(".ItemContent").animate({height: bpadd}, 100, "linear");
			
				});		
		
			 // portfolio 
				var bpadd = parseInt($(".PortfolioItem").children(".ItemContent").height());
				var theight = parseInt($(".PortfolioThumbnail").children("a").height());
				$(this).parent("h2").parent(".ItemContent").parent(".PortfolioItem").children(".PortfolioThumbnail").mouseover(function() {
				
					ntheight = theight-7;
					nbpadd = bpadd+7;
	
					$(this).children("a").animate({height: ntheight}, 100, "linear");
					$(this).parent(".PortfolioItem").children(".ItemContent").animate({height: nbpadd}, 100, "linear");
				
				}).mouseout(function() {
					$(this).children("a").animate({height: theight}, 100, "linear");
					$(this).parent(".PortfolioItem").children(".ItemContent").animate({height: bpadd}, 100, "linear");
				
				});		
		
			}
		
		});
		
		$(".PortfolioItem").each(function() {
			
			var thish = parseInt($(this).height());
			$(this).css({height: thish});
			
		});
	
	}

	// ====================================
	// homepage sliding articles
	// ====================================
	
	if(!$.browser.msie || ($.browser.msie && parseInt(jQuery.browser.version) != 7)) {
		var padd = parseInt($(".SlidingBox").children("h3").children("a").css("paddingTop"));
		var newheightBoxes = 0;
		var bpadd = parseInt($(".SlidingBoxContainer").children(".ContentContainer").height());
		//BLAKKAT MODIF		
		$(".SlidingBoxContainer").children(".ContentContainer").each(function(){				
				var actualheight = parseInt($(this).height());
				if(actualheight > newheightBoxes){ // BLAKKAT MODIF
					//if (newheight < actualheight) {
						newheightBoxes = actualheight;
					//}
				}
				//alert(newheight);
			});		
		$(".SlidingBoxContainer").children(".ContentContainer").each(function() {				
				$(this).css({height: newheightBoxes});
			});
		//FIN
		
		
		
		var theight = parseInt($(".SlidingBoxThumbnail").children("a").children("span").height());
			
		$(".SlidingBoxThumbnail").mouseover(function() {

			npadd = padd+7;
			ntheight = theight-14;
			//nbpadd = bpadd+7;
			//BLAKKAT MODIF
			nbpadd = newheightBoxes+7;

			$(this).parent(".SlidingBoxContainer").parent(".SlidingBox").children("h3").children("a").animate({paddingTop: npadd}, 100, "linear");
			$(this).children("a").children("span").animate({height: ntheight}, 100, "linear");
			$(this).parent(".SlidingBoxContainer").children(".ContentContainer").animate({height: nbpadd}, 100, "linear");
			
		}).mouseout(function() {
			$(this).parent(".SlidingBoxContainer").parent(".SlidingBox").children("h3").children("a").animate({paddingTop: padd}, 100, "linear");
			$(this).children("a").children("span").animate({height: theight}, 100, "linear");
			$(this).parent(".SlidingBoxContainer").children(".ContentContainer").animate({height: newheightBoxes}, 100, "linear");
			
		});	
			
	}
	   
	
	$(window).bind("load", function() {

	  $(".SlidingArticles").each(function() {
		
			var newheight = 0;
			var nr = 0;
			//var heightMax = Math.max($("div.step1 div.blockBottom").height(),$("div.step2 div.blockBottom").height(),$("div.step3 div.blockBottom").height());
			$(this).children(".SlidingArticlesSlider").children(".SlidingBox").each(function(){
				
				var actualheight = parseInt($(this).height());
				//if(actualheight > newheight){ // BLAKKAT MODIF
				if (newheight < actualheight) {
					newheight = actualheight;
				} //}
							
				nr = nr+1;
                                
                                // BLAKKAT begin
                                //
                                // replace the bleu triangle on span with class corner by an orange one
                                //
                                
                                if( nr == 4 )
                                {
                                    $(this).find(".corner").toggleClass('corner2');
                                    $(this).find(".corner").removeClass('corner');
                                }
                                
                                // BLAKKAT end
                                // 
				//alert(newheight);
			});
		
			if ($.browser.opera) {
				snewheight = newheight+20;
			}
			else {
				snewheight = newheight;
			}
		
			if ($.browser.msie) {
				$(this).css({height: snewheight, opacity: '10'});
			}
			else {
				$(this).css({height: snewheight, opacity: '1'});
			}
		
			$(".SlidingBox").each(function() {
				var thish = parseInt($(this).height());
				//$(this).css({height: thish});
				//BLAKKAT MODIF
				$(this).css({height: newheight});
			});

			// 02. build buttons
			var boxwidth = parseInt($(this).children(".SlidingArticlesSlider").children(".SlidingBox").width());
			var newwidth = (boxwidth+20)*nr;
		
				
			$(this).children(".SlidingArticlesSlider").css({width: newwidth});
		
			rightm = parseInt($(this).width())-23;
			maxleft =  -2-(boxwidth + 12)*nr +  parseInt($(this).width());
			if (browser == 'Microsoft Internet Explorer' && version == 7) {	
				rightm = rightm+10;
			}
			
			$(this).parent("div").children(".SlidingButtons").children(".slidingbutton").click(function() {
				buttnr = $(this).attr("id").replace("sbutt", "");
				newleft = -20-(parseInt($(this).parent(".SlidingButtons").parent("div").children(".SlidingArticles").width())+20)*(buttnr-1);

				$(this).parent(".SlidingButtons").parent("div").children(".SlidingArticles").children(".SlidingArticlesSlider").animate({marginLeft: newleft}, 500);	
				$(this).parent(".SlidingButtons").children(".SlidingButt_on").removeClass("SlidingButt_on").addClass("SlidingButt");
				$(this).removeClass("SlidingButt").addClass("SlidingButt_on");
			});
		
			$(".slidingbuttonfirst").click(function() {
				newleft = -20;
				$(this).parent(".SlidingButtons").parent("div").children(".SlidingArticles").children(".SlidingArticlesSlider").animate({marginLeft: newleft}, 500);	
			
				$(this).parent(".SlidingButtons").children(".SlidingButt_on").removeClass("SlidingButt_on").addClass("SlidingButt");
				$(this).removeClass("SlidingButt").addClass("SlidingButt_on");
			});	
		
			$(".slidingbuttonlast").click(function() {
				newleft = -20-parseInt($(this).parent(".SlidingButtons").parent("div").children(".SlidingArticles").children(".SlidingArticlesSlider").width())+parseInt($(this).parent(".SlidingButtons").parent("div").children(".SlidingArticles").width())+20;
				$(this).parent(".SlidingButtons").parent("div").children(".SlidingArticles").children(".SlidingArticlesSlider").animate({marginLeft: newleft}, 500);	
			
				$(this).parent(".SlidingButtons").children(".SlidingButt_on").removeClass("SlidingButt_on").addClass("SlidingButt");
				$(this).removeClass("SlidingButt").addClass("SlidingButt_on");
			});			
		});
	});	

	// ====================================
	// header objects positioning
	// ====================================	
 
	logosrc = $("#WebsiteLogo").attr('src');
	flogosrc = $("#FooterLogo").attr('src');

	if ($.browser.webkit || $.browser.mozilla || $.browser.opera || $.browser.chrome) {
		$("#WebsiteLogo").load(logosrc, function(){ 
			$("#WebsiteLogo").load(flogosrc,function() {
				positioningObjects(); 
			});
		});
	}
	else {
		//positioningObjects();
	}

	// ====================================
	// product single price align adjustment
	// ====================================		
	
	if ($("#ArticlePriceContainer") && $("#ProductMainImage")) {
		
		var gwidth = parseInt($("#ProductMainImage").width())+10;
		$("#ArticlePriceContainer").css({marginLeft: gwidth});
		
	}

	// ====================================
	// skins window - just on demo website
	// ====================================	
		
		
	$(".ChooseSkin").click(function() {
		fullwidth = document.body.clientWidth;
		fullheight = $(window).height();
		wleft = (parseInt(fullwidth)-parseInt($(".TemplateSkins").width()))/2;		
		wtop = (parseInt(fullheight)-parseInt($(".TemplateSkins").height()))/2;		
		$(".WindowBg").css({display: 'block'});
		$(".TemplateSkins").css({left:wleft, top: wtop, display: 'block'});
		
	});
	
	$(".closebutt").click(function() {
		$(".WindowBg").css({display: 'none'});
		$(".TemplateSkins").css({display: 'none'});
	});
	
		
	// ====================================
	// slider activation
	// ====================================	
	
	if (document.getElementById("Slider") != null) {
		promoSetUp();
	}
	
	// ====================================
	// setup minimum height for left column and equalize left and right column
	// ====================================	
	
	if (parseInt($("#LeftColumn").height()) < 280) {
		$("#LeftColumn").css({height: '280px'});
	}
	
	if(parseInt($("#LeftColumn").height()) < parseInt($("#RightColumn").height())) {
		$("#LeftColumn").css({height: parseInt($("#RightColumn").height())});
	}
	
	// ====================================	
  // Photo gallery hover effect
  // ====================================	
  
	$("a.picture, a.video").mouseover(function() { 
  	$(this).parent().clearQueue();
    $(this).parent().animate({opacity: '0.7'}, 300); 
	});
	
	$("a.picture, a.video").mouseout(function() { 
  	$(this).parent().clearQueue();
    $(this).parent().animate({opacity: '1'}, 300); 
  });
  
  // ====================================	
	// inputs hover - add class .over 
	// ====================================	
			
	$("input").mouseover(function() { $(this).addClass('over'); });
	$("select").mouseover(function() { $(this).addClass('over'); });			
	$("textarea").mouseover(function() { $(this).addClass('over'); });						
		
	$("input").mouseout(function() { $(this).removeClass('over'); });			
	$("select").mouseout(function() { $(this).removeClass('over'); });		
	$("textarea").mouseout(function() { $(this).removeClass('over'); });								
			
	// ====================================			
	// tabs shortcode	
	// ====================================	
  
  $('span.tabsTab').mouseover(function () {
		$(this).addClass('over');						
	});
		
	$('span.tabsTab').mouseout(function () {
		$(this).removeClass('over');						
	});
		
	$('span.tabsTab').click(function () {
		$(this).parent().children('span.tabsTab').each(function(index) {
			$(this).removeClass('selected');
		});			
		$(this).addClass('selected');
	});		
		
	$(".contentTabs").each(function(index) {
		$(this).children("div:first").css({display: "block"});
	}); 

	// ====================================			
	// main menu drop down
	// ====================================		
	
	$("#MainMenu").children(".menu").children("li").children(".sub-menu-container").each(function() {
		$(this).parent().children("a").addClass("submenuexists");
	});
        
        if ( $.browser.msie )
        {
            //$("#MainMenu").children(".menu").children("li").addClass("submenuexists2");
            //$("#MainMenu").children(".menu").children("li").children("a").corner("top 7px");
        }

	$("ul.menu").children("li").mouseover(function() {

		$(this).children(".sub-menu-container").stop(true, true);
		$(this).addClass("over");
		$(this).children(".sub-menu-container").slideDown(300);
		
	}).mouseleave(function() {
		
		$(this).children(".sub-menu-container").stop(true, true);
		if (!$(this).children("a").hasClass("submenuexists")) {
			$(this).removeClass("over");
		}
		$(this).children(".sub-menu-container").slideUp(300, function() {
			$(this).parent().removeClass("over");
		});
				
	});
	
	$(".sub-menu-container").each(function() {
		
		$(this).children("ul").children("li").mouseover(function() {
		$(this).children(".sub-menu-container").stop(true, true);
		newwidth = $(this).parent("ul").parent(".sub-menu-container").width();
		leftpos = parseInt(newwidth);
		$(this).children(".sub-menu-container").css({left: leftpos}).slideDown(300);
				
		}).mouseleave(function() {
			$(this).children(".sub-menu-container").stop(true, true);
			$(this).children(".sub-menu-container").slideUp(300);
			
		});
	
	});


	// ====================================			
	// add to cart button mouse over
	// ====================================		
	
	$("#AddToCart").mouseover(function() {
		$(this).addClass("over");
	}).mouseout(function() {
		$(this).removeClass("over");
	});
	

	// ====================================			
	// product tabs
	// ====================================		
	
	if (document.getElementById("Submenu") != null) {
	
		var websiteoffset = $("#Wrap").offset();
		var cartbuttleft = parseInt(websiteoffset.left)+parseInt($("#LeftColumn").width())-parseInt($("#AddToCart").width())-20;
		var cartbutttop = parseInt($("#AddToCart").height())+20;
		$("#AddToCart").css({marginLeft: cartbuttleft, marginTop: cartbutttop, display: 'block'});  		
		
		var cookie = readCookie("producttab");
	  
	  var activetab = cookie;
	  
	  if (activetab == 'undefined' || activetab == 'null' || !activetab) {
	  	activetab = 'OverviewTab';
	  }  
	  
	  if (activetab != 'OverviewTab') {
			$("#AddToCart").css({marginTop: 0});  	
	  }
	  setActiveTab(activetab);
		
		if (activetab == 'GalleryTab') {
	  	photoGallerySetUp();
	  }
		
		$("#Submenu").children("li").not('#AddToCart').click( function() {
		
			var activetab = $(this).attr("id");
			setActiveTab(activetab);
			
			$("#Submenu").children("li").removeClass("clicked");
			$(this).addClass("clicked");
			
			tabname = $(this).attr("id");
			$(".ContentTab").css({display:'none'});
			$("#"+tabname+"Content").css({display:'block'});
			
			if (tabname != "OverviewTab" && parseInt($("#AddToCart").css("marginTop")) == cartbutttop) {
				$("#AddToCart").animate({marginTop: 0}, 400);
			}
			
			if (tabname == "OverviewTab" && parseInt($("#AddToCart").css("marginTop")) == 0) {
				$("#AddToCart").animate({marginTop: cartbutttop}, 400);
			}
		
		});
		
		$("#GalleryTab").click(function() {
			photoGallerySetUp();
		});
			
		
		$(".GalleryTitle").children("a").click(function() {
			
			$("#Submenu").children("li").removeClass("clicked");
			$("#GalleryTab").addClass("clicked");
			
			$(".ContentTab").css({display:'none'});
			$("#GalleryTabContent").css({display:'block'});
			
			$("#AddToCart").animate({marginTop: 0}, 400);
			
			photoGallerySetUp();
			
		});
	
	}
	
	
	// ====================================			
	// blog more categories and tags
	// ====================================			
	
	$(".blogmore").click(function() {
		
		var mloffset = $(this).offset();
		
		var mloffsetleft = parseInt(mloffset.left);
		var olwith = parseInt($(this).parent().children(".otherlinks").width());
		var coffset = $("#Wrap").offset();
		var coffsetleft = parseInt(coffset.left);
		var leftpos = mloffsetleft-coffsetleft-olwith;
		
		$(this).parent().children(".otherlinks").css({left: leftpos});
		
		
		if ($(this).parent().children(".otherlinks").css("display") == 'none') {
			$(this).parent().children(".otherlinks").css({display: 'block'});
		}
		else {
			$(this).parent().children(".otherlinks").css({display: 'none'});
		}
		
	});
	 
	// ====================================			
	// product listing sort tab
	// ====================================			
	
		$(".SubMenuTab").each(function() {
		var eloffset = $(this).children(".ddtab").offset();
		
		var toppos = parseInt(eloffset.top)+parseInt($(this).children(".ddtab").height())+parseInt($(this).children(".ddtab").css("paddingTop"))*2;
		var leftpos = parseInt(eloffset.left);
		
		$(this).parent(".SubMenuTabContainer").children(".SelectTab").css({top: toppos, left: leftpos});
		
			
		$(this).parent(".SubMenuTabContainer").children(".SelectTab").children("li").mouseover(function() {
			$(this).addClass("over");
		}).mouseout(function() {
			$(this).removeClass("over");
		});
		
		$(this).parent(".SubMenuTabContainer").children(".SelectTab").children("li").click(function() {
			
			var tabval = $(this).text();
			$(this).parent("ul").parent(".SubMenuTabContainer").children("input").val(tabval);
			$(this).parent("ul").parent(".SubMenuTabContainer").children(".SubMenuTab").children(".ddtab").text(tabval);
			
			var formid = $(this).parent("ul").parent(".SubMenuTabContainer").parent("form").attr("id");
			
			 $(this).parent("ul").css({display: 'none'});
			
			$("#"+formid).submit();
			
		});
		
		$(this).click(function() {
			
			if ($(this).parent(".SubMenuTabContainer").children(".SelectTab").css("display") == 'none') {
				$(this).parent(".SubMenuTabContainer").children(".SelectTab").slideDown(100);
			} else {
				$(this).parent(".SubMenuTabContainer").children(".SelectTab").slideUp(100);
			}
			
		});
	
	});
	// ====================================
	// Homepage /***** BLAKKAT ************/
	// ====================================

	$("#fdArticleBlog").easySlider();
	
        
        //
        // Blakkat begin
        //
        // new code
        
        $("#HomepageContent .HomepageElement .SlidingArticles .SlidingArticlesSlider .SlidingBox:last-child h3 a").css('background', 'url(wp-content/themes/mercury/images/fond_sliding_box_boutique.png) no-repeat top left #fff');
        $("#HomepageContent .HomepageElement .SlidingArticles .SlidingArticlesSlider .SlidingBox:last-child h3").css('background', 'url(wp-content/themes/mercury/images/fond_sliding_box_boutique.png) no-repeat top left #fff');
        
        // old code
        //
        //$("#HomepageContent .HomepageElement .SlidingArticles .SlidingArticlesSlider .SlidingBox:last-child h3 a").css('background', 'url("../../images/buttons/boxheader-boutique.png") repeat-x scroll left top #e8820a');
	//$("#HomepageContent .HomepageElement .SlidingArticles .SlidingArticlesSlider .SlidingBox:last-child .corner").css('background', '#e8820a');
            
        //
        // Blakkat end
        //
	
});

// -- end $(document).ready

		
function positioningObjects() {

	// positioning backgrounds
	if (document.getElementById("Slider") != null) {
		var off = $("#Slider").offset();	
	}
	else {
		var off = $("#WebSite").offset();	
	}
	var offw = $("#Wrap").offset();
	var off_top = parseInt(off.top);
	if ($.browser.mozilla) {
		off_top = off_top+1;
	}
	
	$("#topbg").css({height: off_top, width: '100%', top: '0px'});
	
	if (document.getElementById("LoadBar") != null) {
		$("#linebg").css({height: '3px', width: '100%', top: off_top});
	}
	
	
	var fheight = parseInt($("#Footer").height())+parseInt($("#Wrap").css("marginBottom"))+parseInt($("#Footer").css("paddingTop"))+parseInt($("#Footer").css("paddingBottom"));
	var fmtop = 0-fheight;
	
	$("#bottombg").css({height: fheight, width: '100%', marginTop: fmtop});		
	
	// positioning search form and shopping cart
	
	headertop = parseInt($("#HeaderContainer").height())+parseInt($("#HeaderContainer").css("paddingTop"))+parseInt($("#HeaderContainer").css("paddingBottom"));	
	headeroffset = $("#Header").offset();
	headertopspace = parseInt(headeroffset.top);
	logoright = $("#Logo").width();

	//alert($(".MainSearch").height());
	
	newheightm = (headertop-parseInt($("#Motto").height()))/2+headertopspace;
	newwidthm = parseInt(logoright)+parseInt(headeroffset.left)+25;
	
	/*$("#Motto").css({top: newheightm, left: newwidthm, display: 'block'});*/
	
	if (document.getElementById("TopShoppingCart") == null) {
		newheighta = (headertop-parseInt($(".MainSearch").height()))/2+headertopspace;
		headerright = parseInt(headeroffset.left)+parseInt($("#Header").width())-parseInt($(".MainSearch").width())-20;

		$(".MainSearch").css({top: newheighta, left: headerright, display: 'block'});
	}
	else {
		align_top_shoppingcart();
	}
}

//single or page starts here

function ShowGallery(videotype, linkaddress, showtype, window_w, window_h) {

	if (showtype == 'video') {
  if (videotype == 'vimeo') {
    		
    		$('#PhotoGalleryWindow').html('<div id="PostGallery" style="width:'+window_w+'px; height:'+window_h+'px; overflow: hidden;"><object width="'+window_w+'" height="'+window_h+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+linkaddress+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+linkaddress+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+window_w+'" height="'+window_h+'"></embed></object></div>');
    	}
    	
    	if (videotype == 'youtube') {
    		
    		$('#PhotoGalleryWindow').html('<div id="PostGallery" style="width:'+window_w+'px; height:'+window_h+'px; overflow: hidden;"><object width="'+window_w+'" height="'+window_h+'"><param name="movie" value="http://www.youtube.com/v/'+linkaddress+'&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+linkaddress+'&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+window_w+'" height="'+window_h+'"></embed></object></div>');
    	}
    }
    	if (showtype == 'picture') {
    		$('#PhotoGalleryWindow').html('<div id="PostGallery" style="width:'+window_w+'px; height:'+window_h+'px; overflow: hidden;"><img src="'+linkaddress+'" border=0></div>');
    	}
    	
    	$('#PostGalleryContainer').show();
    	$('#PhotoGalleryWindow').show();
    	$('#PostGallery').fadeIn(200);
    	
    	windoww = parseInt($("#PostGallery").width());
			windowh = parseInt($("#PostGallery").height());
    	screen_h = $(window).height();
    	window_top = parseInt(screen_h)/2-(windowh+100)/2+parseInt($(window).scrollTop());
    	
    	$('#PostGallery').css({top: window_top, width: window_w});
    	
			

    	closetop = window_top-15;
    	closepos = $('#PostGallery').offset();
    	closeleft = parseInt(closepos.left)+windoww+5;
    	thumbtop = window_top+windowh+30;
    	thumbleft = parseInt(closepos.left);
    	
    	$('#PhotoGalleryThumbnails').css({width: windoww, top: thumbtop, left: thumbleft});
    	$('#PhotoGalleryThumbnails').show(0);

    	$("#CloseButton").css({left: closeleft, top: closetop})
    	$("#CloseButton").show();
    }
	
		
function switchContentTabs(obj) {
			
	if ($.browser.msie) {	
		
		$("#tabtext_"+obj).parent().children('div.tabText').each(function(index) {
				$(this).children("p").css({display: 'none'});
				$(this).css({display: 'none'});
			});			
					
			$("#tabtext_"+obj).css({display: 'block'});
			$("#tabtext_"+obj).children("p").css({display: 'block'});
		
	}		
	else {	
			
	$("#tabtext_"+obj).parent().children('div.tabText').each(function(index) {
		$(this).children("p").fadeOut(0);
		$(this).fadeOut(0);
	});			
			
	$("#tabtext_"+obj).fadeIn(0);
	$("#tabtext_"+obj).children("p").fadeIn(800);
	}
			
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


window.onunload = function(e) {
  createCookie("producttab", activetab, 365);
}

var cookie = readCookie("producttab");
var activetab = cookie;


function setActiveTab(activetab) {
	
	$("#Submenu").children("li").removeClass("clicked");
	$("#"+activetab).addClass("clicked");
	$(".ContentTab").css({display:'none'});
	$("#"+activetab+"Content").css({display:'block'});	
	
	createCookie("producttab", activetab, 365);
}

deg2rad = Math.PI * 2 / 360;

function SetRotation(deg, mydiv)
{
    rad = deg * deg2rad;

    costheta = Math.cos(rad);
    sintheta = Math.sin(rad);

    mydiv.filters.item(0).M11 = costheta;
    mydiv.filters.item(0).M12 = -sintheta;
    mydiv.filters.item(0).M21 = sintheta;
    mydiv.filters.item(0).M22 = costheta;
}
